diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 4a528b63..f03b80e7 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -5,19 +5,20 @@ repositories { } dependencies { - compile 'com.android.support:support-v4:23.0.+' + compile 'com.android.support:support-v4:23.1.+' compile 'com.google.android.gms:play-services:3.2.+' //compile 'com.google.android.gms:play-services:7.5.0' compile 'net.hockeyapp.android:HockeySDK:3.5.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+' compile 'org.apache.httpcomponents:httpmime:4.2.1' - //compile 'com.android.support:multidex:1.0.1' } android { - compileSdkVersion 22 + compileSdkVersion 23 buildToolsVersion '23.0.1' + useLibrary 'org.apache.http.legacy' + packagingOptions { exclude 'META-INF/NOTICE.txt' exclude 'META-INF/LICENSE.txt' @@ -87,9 +88,8 @@ android { defaultConfig { applicationId "org.telegram.plus" minSdkVersion 8 - targetSdkVersion 22 - versionCode 632 - versionName "3.2.2.2" - //multiDexEnabled true + targetSdkVersion 23 + versionCode 655 + versionName "3.2.6.0" } } diff --git a/TMessagesProj/config/release/AndroidManifest.xml b/TMessagesProj/config/release/AndroidManifest.xml index 77f154e4..4d673eb9 100644 --- a/TMessagesProj/config/release/AndroidManifest.xml +++ b/TMessagesProj/config/release/AndroidManifest.xml @@ -34,7 +34,7 @@ diff --git a/TMessagesProj/jni/Android.mk b/TMessagesProj/jni/Android.mk index bd054413..7953965a 100644 --- a/TMessagesProj/jni/Android.mk +++ b/TMessagesProj/jni/Android.mk @@ -187,7 +187,7 @@ include $(CLEAR_VARS) LOCAL_PRELINK_MODULE := false LOCAL_STATIC_LIBRARIES := webp sqlite tgnet breakpad -LOCAL_MODULE := tmessages.12 +LOCAL_MODULE := tmessages.14 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 diff --git a/TMessagesProj/jni/image.c b/TMessagesProj/jni/image.c index a2cc1dfb..5445075b 100644 --- a/TMessagesProj/jni/image.c +++ b/TMessagesProj/jni/image.c @@ -16,11 +16,6 @@ jfieldID jclass_Options_inJustDecodeBounds; jfieldID jclass_Options_outHeight; jfieldID jclass_Options_outWidth; -jclass jclass_Bitmap; -jmethodID jclass_Bitmap_createBitmap; -jclass jclass_Config; -jfieldID jclass_Config_ARGB_8888; - const uint32_t PGPhotoEnhanceHistogramBins = 256; const uint32_t PGPhotoEnhanceSegments = 4; @@ -58,24 +53,6 @@ jint imageOnJNILoad(JavaVM *vm, void *reserved, JNIEnv *env) { return -1; } - jclass_Bitmap = createGlobarRef(env, (*env)->FindClass(env, "android/graphics/Bitmap")); - if (jclass_Bitmap == 0) { - return -1; - } - jclass_Bitmap_createBitmap = (*env)->GetStaticMethodID(env, jclass_Bitmap, "createBitmap", "(IILandroid/graphics/Bitmap$Config;)Landroid/graphics/Bitmap;"); - if (jclass_Bitmap_createBitmap == 0) { - return -1; - } - - jclass_Config = createGlobarRef(env, (*env)->FindClass(env, "android/graphics/Bitmap$Config")); - if (jclass_Config == 0) { - return -1; - } - jclass_Config_ARGB_8888 = (*env)->GetStaticFieldID(env, jclass_Config, "ARGB_8888", "Landroid/graphics/Bitmap$Config;"); - if (jclass_Config_ARGB_8888 == 0) { - return -1; - } - return JNI_VERSION_1_6; } @@ -511,7 +488,7 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jcl } } -JNIEXPORT jobject Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *env, jclass class, jobject buffer, int len, jobject options) { +JNIEXPORT jboolean Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *env, jclass class, jobject outputBitmap, jobject buffer, jint len, jobject options, jboolean unpin) { if (!buffer) { (*env)->ThrowNew(env, jclass_NullPointerException, "Input buffer can not be null"); return 0; @@ -529,43 +506,36 @@ JNIEXPORT jobject Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *en if (options && (*env)->GetBooleanField(env, options, jclass_Options_inJustDecodeBounds) == JNI_TRUE) { (*env)->SetIntField(env, options, jclass_Options_outWidth, bitmapWidth); (*env)->SetIntField(env, options, jclass_Options_outHeight, bitmapHeight); - return 0; + return 1; } - - jobject value__ARGB_8888 = (*env)->GetStaticObjectField(env, jclass_Config, jclass_Config_ARGB_8888); - jobject outputBitmap = (*env)->CallStaticObjectMethod(env, jclass_Bitmap, jclass_Bitmap_createBitmap, (jint)bitmapWidth, (jint)bitmapHeight, value__ARGB_8888); + if (!outputBitmap) { - (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to allocate Bitmap"); + (*env)->ThrowNew(env, jclass_NullPointerException, "output bitmap can not be null"); return 0; } - outputBitmap = (*env)->NewLocalRef(env, outputBitmap); AndroidBitmapInfo bitmapInfo; if (AndroidBitmap_getInfo(env, outputBitmap, &bitmapInfo) != ANDROID_BITMAP_RESUT_SUCCESS) { - (*env)->DeleteLocalRef(env, outputBitmap); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to get Bitmap information"); return 0; } void *bitmapPixels = 0; if (AndroidBitmap_lockPixels(env, outputBitmap, &bitmapPixels) != ANDROID_BITMAP_RESUT_SUCCESS) { - (*env)->DeleteLocalRef(env, outputBitmap); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to lock Bitmap pixels"); return 0; } if (!WebPDecodeRGBAInto((uint8_t*)inputBuffer, len, (uint8_t*)bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) { AndroidBitmap_unlockPixels(env, outputBitmap); - (*env)->DeleteLocalRef(env, outputBitmap); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to decode webp image"); return 0; } - if (AndroidBitmap_unlockPixels(env, outputBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) { - (*env)->DeleteLocalRef(env, outputBitmap); + if (unpin && AndroidBitmap_unlockPixels(env, outputBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) { (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to unlock Bitmap pixels"); return 0; } - return outputBitmap; + return 1; } diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 834f1af1..306d735e 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -12,8 +12,6 @@ - - @@ -26,7 +24,6 @@ - @@ -39,6 +36,7 @@ + + + + + + + + diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_0.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_0.jpg deleted file mode 100644 index 251747ff..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_1.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_1.jpg deleted file mode 100644 index 21bc015e..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_2.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_2.jpg deleted file mode 100644 index c1c6fd3b..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_3.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_3.jpg deleted file mode 100644 index bb398488..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_4.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_4.jpg deleted file mode 100644 index a74e170f..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_0.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_0.jpg deleted file mode 100644 index 2fe760d0..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_1.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_1.jpg deleted file mode 100644 index 776bf588..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_2.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_2.jpg deleted file mode 100644 index 43a7aa37..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_3.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_3.jpg deleted file mode 100644 index 95d146fe..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_4.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_4.jpg deleted file mode 100644 index 2be40c47..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji2.0x_a_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_0.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_0.jpg deleted file mode 100644 index bc1d03b4..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_1.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_1.jpg deleted file mode 100644 index 8288773c..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_2.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_2.jpg deleted file mode 100644 index feea1209..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_3.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_3.jpg deleted file mode 100644 index 0e3bcede..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_4.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_4.jpg deleted file mode 100644 index 1f74e835..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_0.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_0.jpg deleted file mode 100644 index 5218c3ca..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_0.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_1.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_1.jpg deleted file mode 100644 index e6192101..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_1.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_2.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_2.jpg deleted file mode 100644 index 58476054..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_2.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_3.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_3.jpg deleted file mode 100644 index 7e4ea184..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_3.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_4.jpg b/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_4.jpg deleted file mode 100644 index 9bb3ea6c..00000000 Binary files a/TMessagesProj/src/main/assets/emoji/v4_emoji3.0x_a_4.jpg and /dev/null differ diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteCursor.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteCursor.java index 87deca40..01275c5a 100644 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteCursor.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteCursor.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.SQLite; diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java index 0aecf4b2..eb8bd6ad 100644 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteDatabase.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.SQLite; @@ -22,7 +22,7 @@ public class SQLiteDatabase { } public SQLiteDatabase(String fileName) throws SQLiteException { - sqliteHandle = opendb(fileName, ApplicationLoader.applicationContext.getFilesDir().getPath()); + sqliteHandle = opendb(fileName, ApplicationLoader.getFilesDirFixed().getPath()); isOpen = true; } diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteException.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteException.java index d27cfb6a..2540c094 100644 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteException.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteException.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.SQLite; diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteNoRowException.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteNoRowException.java index 042f0070..944d2143 100644 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteNoRowException.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLiteNoRowException.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.SQLite; diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java index a2c87140..cd933701 100644 --- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java +++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.SQLite; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index 35190043..46561fb4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -17,6 +17,7 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; +import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.res.Configuration; import android.graphics.drawable.ColorDrawable; @@ -96,7 +97,7 @@ public class ApplicationLoader extends Application { cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd); isCustomTheme = false; } else { - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); + File toFile = new File(getFilesDirFixed(), "wallpaper.jpg"); if (toFile.exists()) { cachedWallpaper = Drawable.createFromPath(toFile.getAbsolutePath()); isCustomTheme = true; @@ -155,7 +156,7 @@ public class ApplicationLoader extends Application { } try { - File file = new File(ApplicationLoader.applicationContext.getFilesDir(), "tgnet.dat"); + File file = new File(getFilesDirFixed(), "tgnet.dat"); RandomAccessFile fileOutputStream = new RandomAccessFile(file, "rws"); byte[] bytes = buffer.toByteArray(); fileOutputStream.writeInt(Integer.reverseBytes(bytes.length)); @@ -169,6 +170,24 @@ public class ApplicationLoader extends Application { } } + public static File getFilesDirFixed() { + for (int a = 0; a < 10; a++) { + File path = ApplicationLoader.applicationContext.getFilesDir(); + if (path != null) { + return path; + } + } + try { + ApplicationInfo info = applicationContext.getApplicationInfo(); + File path = new File(info.dataDir, "files"); + path.mkdirs(); + return path; + } catch (Exception e) { + FileLog.e("tmessages", e); + } + return new File("/data/data/org.telegram.messenger/files"); + } + public static void postInitApplication() { if (applicationInited) { return; @@ -205,7 +224,7 @@ public class ApplicationLoader extends Application { String langCode; String appVersion; String systemVersion; - String configPath = ApplicationLoader.applicationContext.getFilesDir().toString(); + String configPath = getFilesDirFixed().toString(); try { langCode = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); @@ -233,7 +252,7 @@ public class ApplicationLoader extends Application { } MessagesController.getInstance(); - ConnectionsManager.getInstance().init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildVars.APP_ID, deviceModel, systemVersion, appVersion, langCode, configPath, UserConfig.getClientUserId()); + ConnectionsManager.getInstance().init(BuildVars.BUILD_VERSION, TLRPC.LAYER, BuildVars.APP_ID, deviceModel, systemVersion, appVersion, langCode, configPath, FileLog.getNetworkLogPath(), UserConfig.getClientUserId()); if (UserConfig.getCurrentUser() != null) { MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true); ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java b/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java index 529cbdbc..f1a1918e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/DispatchQueue.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java index 64ab95a7..686066cf 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoadOperation.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -256,7 +256,8 @@ public class FileLoadOperation { nextDownloadOffset = downloadedBytes = downloadedBytes / currentDownloadChunkSize * currentDownloadChunkSize; } - if (BuildVars.DEBUG_VERSION) { + //if (BuildVars.DEBUG_VERSION) { + if (BuildConfig.DEBUG) { FileLog.d("tmessages", "start loading file to temp = " + cacheFileTemp + " final = " + cacheFileFinal); } @@ -377,13 +378,15 @@ public class FileLoadOperation { } if (cacheFileTemp != null) { if (!cacheFileTemp.renameTo(cacheFileFinal)) { - if (BuildVars.DEBUG_VERSION) { + //if (BuildVars.DEBUG_VERSION) { + if (BuildConfig.DEBUG) { FileLog.e("tmessages", "unable to rename temp = " + cacheFileTemp + " to final = " + cacheFileFinal); } cacheFileFinal = cacheFileTemp; } } - if (BuildVars.DEBUG_VERSION) { + //if (BuildVars.DEBUG_VERSION) { + if (BuildConfig.DEBUG) { FileLog.e("tmessages", "finished downloading file to " + cacheFileFinal); } delegate.didFinishLoadingFile(FileLoadOperation.this, cacheFileFinal); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java index f5256ae7..c4dd00ed 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -8,7 +8,6 @@ package org.telegram.messenger; - import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; @@ -27,7 +26,7 @@ public class FileLoader { public interface FileLoaderDelegate { void fileUploadProgressChanged(String location, float progress, boolean isEncrypted); - void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile, byte[] key, byte[] iv); + void fileDidUploaded(String location, TLRPC.InputFile inputFile, TLRPC.InputEncryptedFile inputEncryptedFile, byte[] key, byte[] iv, long totalFileSize); void fileDidFailedUpload(String location, boolean isEncrypted); @@ -112,6 +111,7 @@ public class FileLoader { } uploadSizes.remove(location); if (operation != null) { + uploadOperationPathsEnc.remove(location); uploadOperationQueue.remove(operation); uploadSmallOperationQueue.remove(operation); operation.cancel(); @@ -175,7 +175,7 @@ public class FileLoader { } operation.delegate = new FileUploadOperation.FileUploadOperationDelegate() { @Override - public void didFinishUploadingFile(FileUploadOperation operation, final TLRPC.InputFile inputFile, final TLRPC.InputEncryptedFile inputEncryptedFile, final byte[] key, final byte[] iv) { + public void didFinishUploadingFile(final FileUploadOperation operation, final TLRPC.InputFile inputFile, final TLRPC.InputEncryptedFile inputEncryptedFile, final byte[] key, final byte[] iv) { fileLoaderQueue.postRunnable(new Runnable() { @Override public void run() { @@ -204,7 +204,7 @@ public class FileLoader { } } if (delegate != null) { - delegate.fileDidUploaded(location, inputFile, inputEncryptedFile, key, iv); + delegate.fileDidUploaded(location, inputFile, inputEncryptedFile, key, iv, operation.getTotalFileSize()); } } }); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index 64be4517..809e20ab 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -22,6 +22,7 @@ public class FileLog { private FastDateFormat dateFormat = null; private DispatchQueue logQueue = null; private File currentFile = null; + private File networkFile = null; private static volatile FileLog Instance = null; public static FileLog getInstance() { @@ -66,6 +67,22 @@ public class FileLog { } } + public static String getNetworkLogPath() { + try { + File sdCard = ApplicationLoader.applicationContext.getExternalFilesDir(null); + if (sdCard == null) { + return ""; + } + File dir = new File(sdCard.getAbsolutePath() + "/logs"); + dir.mkdirs(); + getInstance().networkFile = new File(dir, getInstance().dateFormat.format(System.currentTimeMillis()) + "_net.txt"); + return getInstance().networkFile.getAbsolutePath(); + } catch (Throwable e) { + e.printStackTrace(); + } + return ""; + } + public static void e(final String tag, final String message, final Throwable exception) { //if (!BuildVars.DEBUG_VERSION) { if (!BuildConfig.DEBUG) { @@ -186,6 +203,9 @@ public class FileLog { if (getInstance().currentFile != null && file.getAbsolutePath().equals(getInstance().currentFile.getAbsolutePath())) { continue; } + if (getInstance().networkFile != null && file.getAbsolutePath().equals(getInstance().networkFile.getAbsolutePath())) { + continue; + } file.delete(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java index da776516..e60cc289 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -63,6 +63,10 @@ public class FileUploadOperation { estimatedSize = estimated; } + public long getTotalFileSize() { + return totalFileSize; + } + public void start() { if (state != 0) { return; @@ -77,7 +81,7 @@ public class FileUploadOperation { } public void cancel() { - if (state != 1) { + if (state == 3) { return; } state = 2; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageKeyData.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageKeyData.java index 3789758c..ac218a10 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageKeyData.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageKeyData.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java index eb8acd4d..8b8563a1 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -38,6 +38,7 @@ public class UserConfig { public static int autoLockIn = 60 * 60; public static int lastPauseTime = 0; public static boolean isWaitingForPasscodeEnter = false; + public static boolean useFingerprint = true; public static int lastUpdateVersion; public static int lastContactsSyncTime; public static boolean channelsLoaded = false; @@ -79,6 +80,7 @@ public class UserConfig { editor.putInt("lastUpdateVersion", lastUpdateVersion); editor.putInt("lastContactsSyncTime", lastContactsSyncTime); editor.putBoolean("channelsLoaded", channelsLoaded); + editor.putBoolean("useFingerprint", useFingerprint); if (currentUser != null) { if (withFile) { @@ -128,7 +130,7 @@ public class UserConfig { public static void loadConfig() { synchronized (sync) { - final File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat"); + final File configFile = new File(ApplicationLoader.getFilesDirFixed(), "user.dat"); if (configFile.exists()) { try { SerializedData data = new SerializedData(configFile); @@ -207,6 +209,7 @@ public class UserConfig { passcodeType = preferences.getInt("passcodeType", 0); autoLockIn = preferences.getInt("autoLockIn", 60 * 60); lastPauseTime = preferences.getInt("lastPauseTime", 0); + useFingerprint = preferences.getBoolean("useFingerprint", true); lastUpdateVersion = preferences.getInt("lastUpdateVersion", 511); lastContactsSyncTime = preferences.getInt("lastContactsSyncTime", (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60); channelsLoaded = preferences.getBoolean("channelsLoaded", false); @@ -281,6 +284,7 @@ public class UserConfig { passcodeSalt = new byte[0]; autoLockIn = 60 * 60; lastPauseTime = 0; + useFingerprint = true; isWaitingForPasscodeEnter = false; lastUpdateVersion = BuildVars.BUILD_VERSION; lastContactsSyncTime = (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java index c66e0277..6c7c69c9 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x.x. + * 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). * @@ -63,17 +63,11 @@ 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 void blurBitmap(Object bitmap, int radius, int unpin); - public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer); - - public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options); - + public native static boolean loadWebpImage(Bitmap bitmap, ByteBuffer buffer, int len, BitmapFactory.Options options, boolean unpin); public native static int convertVideoFrame(ByteBuffer src, ByteBuffer dest, int destFormat, int width, int height, int padding, int swap); - private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length); public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) { @@ -172,6 +166,11 @@ public class Utilities { } } + String hex = bytesToHex(prime); + if (hex.equals("C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B")) { + return true; + } + BigInteger dhBI2 = dhBI.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(2)); return !(!dhBI.isProbablePrime(30) || !dhBI2.isProbablePrime(30)); } 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 503ba87e..e0300ccd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; @@ -22,10 +22,15 @@ 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; + public class ActionBar extends FrameLayout { public static class ActionBarMenuOnItemClick { @@ -45,6 +50,8 @@ public class ActionBar extends FrameLayout { private ActionBarMenu menu; private ActionBarMenu actionMode; private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21; + private boolean actionModeVisible; + private boolean addToContainer = true; private boolean allowOverlayTitle; private CharSequence lastTitle; @@ -55,7 +62,6 @@ public class ActionBar extends FrameLayout { private boolean isBackOverlayVisible; protected BaseFragment parentFragment; public ActionBarMenuOnItemClick actionBarMenuOnItemClick; - private int extraHeight; public ActionBar(Context context) { super(context); @@ -68,6 +74,7 @@ public class ActionBar extends FrameLayout { backButtonImageView = new ImageView(getContext()); backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); + backButtonImageView.setPadding(AndroidUtilities.dp(1), 0, 0, 0); addView(backButtonImageView, LayoutHelper.createFrame(54, 54, Gravity.LEFT | Gravity.TOP)); backButtonImageView.setOnClickListener(new OnClickListener() { @@ -90,6 +97,9 @@ public class ActionBar extends FrameLayout { } backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE); backButtonImageView.setImageDrawable(drawable); + if (drawable instanceof BackDrawable) { + ((BackDrawable) drawable).setRotation(isActionModeShowed() ? 1 : 0, false); + } } public void setBackButtonImage(int resource) { @@ -111,7 +121,15 @@ public class ActionBar extends FrameLayout { subTitleTextView.setLines(1); subTitleTextView.setMaxLines(1); subTitleTextView.setEllipsize(TextUtils.TruncateAt.END); - addView(subTitleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); + addView(subTitleTextView, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); + } + + public void setAddToContainer(boolean value) { + addToContainer = value; + } + + public boolean getAddToContainer() { + return addToContainer; } public void setSubtitle(CharSequence value) { @@ -136,7 +154,7 @@ public class ActionBar extends FrameLayout { titleTextView.setEllipsize(TextUtils.TruncateAt.END); titleTextView.setTextColor(0xffffffff); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - addView(titleTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); + addView(titleTextView, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP)); } public void setTitle(CharSequence value) { @@ -183,12 +201,7 @@ public class ActionBar extends FrameLayout { return menu; } menu = new ActionBarMenu(getContext(), this); - addView(menu); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams(); - layoutParams.height = LayoutHelper.MATCH_PARENT; - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.gravity = Gravity.RIGHT; - menu.setLayoutParams(layoutParams); + addView(menu, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT)); return menu; } @@ -201,8 +214,8 @@ public class ActionBar extends FrameLayout { return actionMode; } actionMode = new ActionBarMenu(getContext(), this); - actionMode.setBackgroundResource(R.drawable.editheader); - addView(actionMode); + actionMode.setBackgroundColor(0xffffffff); + addView(actionMode, indexOfChild(backButtonImageView)); actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; @@ -227,34 +240,95 @@ public class ActionBar extends FrameLayout { } public void showActionMode() { - if (actionMode == null) { + if (actionMode == null || actionModeVisible) { return; } + actionModeVisible = true; + if (Build.VERSION.SDK_INT >= 14) { + ArrayList animators = new ArrayList<>(); + animators.add(ObjectAnimatorProxy.ofFloat(actionMode, "alpha", 0.0f, 1.0f)); + if (occupyStatusBar && actionModeTop != null) { + animators.add(ObjectAnimatorProxy.ofFloat(actionModeTop, "alpha", 0.0f, 1.0f)); + } + AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); + animatorSetProxy.playTogether(animators); + animatorSetProxy.setDuration(200); + animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationStart(Object animation) { actionMode.setVisibility(VISIBLE); if (occupyStatusBar && actionModeTop != null) { actionModeTop.setVisibility(VISIBLE); } + } + + @Override + public void onAnimationEnd(Object animation) { if (titleTextView != null) { titleTextView.setVisibility(INVISIBLE); } if (subTitleTextView != null) { subTitleTextView.setVisibility(INVISIBLE); } - if (backButtonImageView != null) { - backButtonImageView.setVisibility(INVISIBLE); - } if (menu != null) { menu.setVisibility(INVISIBLE); } } + }); + animatorSetProxy.start(); + } else { + actionMode.setVisibility(VISIBLE); + if (occupyStatusBar && actionModeTop != null) { + actionModeTop.setVisibility(VISIBLE); + } + if (titleTextView != null) { + titleTextView.setVisibility(INVISIBLE); + } + if (subTitleTextView != null) { + subTitleTextView.setVisibility(INVISIBLE); + } + if (menu != null) { + menu.setVisibility(INVISIBLE); + } + } + if (backButtonImageView != null) { + Drawable drawable = backButtonImageView.getDrawable(); + if (drawable instanceof BackDrawable) { + ((BackDrawable) drawable).setRotation(1, true); + } + backButtonImageView.setBackgroundResource(R.drawable.bar_selector_mode); + } + } public void hideActionMode() { - if (actionMode == null) { + if (actionMode == null || !actionModeVisible) { return; } - actionMode.setVisibility(INVISIBLE); - if (occupyStatusBar && actionModeTop != null) { - actionModeTop.setVisibility(INVISIBLE); + actionModeVisible = false; + if (Build.VERSION.SDK_INT >= 14) { + ArrayList animators = new ArrayList<>(); + animators.add(ObjectAnimatorProxy.ofFloat(actionMode, "alpha", 0.0f)); + if (occupyStatusBar && actionModeTop != null) { + animators.add(ObjectAnimatorProxy.ofFloat(actionModeTop, "alpha", 0.0f)); + } + AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); + animatorSetProxy.playTogether(animators); + animatorSetProxy.setDuration(200); + animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + actionMode.setVisibility(INVISIBLE); + if (occupyStatusBar && actionModeTop != null) { + actionModeTop.setVisibility(INVISIBLE); + } + } + }); + animatorSetProxy.start(); + } else { + actionMode.setVisibility(INVISIBLE); + if (occupyStatusBar && actionModeTop != null) { + actionModeTop.setVisibility(INVISIBLE); + } } if (titleTextView != null) { titleTextView.setVisibility(VISIBLE); @@ -262,12 +336,16 @@ public class ActionBar extends FrameLayout { if (subTitleTextView != null) { subTitleTextView.setVisibility(VISIBLE); } - if (backButtonImageView != null) { - backButtonImageView.setVisibility(VISIBLE); - } if (menu != null) { menu.setVisibility(VISIBLE); } + if (backButtonImageView != null) { + Drawable drawable = backButtonImageView.getDrawable(); + if (drawable instanceof BackDrawable) { + ((BackDrawable) drawable).setRotation(0, true); + } + backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); + } } public void showActionModeTop() { @@ -284,7 +362,7 @@ public class ActionBar extends FrameLayout { } public boolean isActionModeShowed() { - return actionMode != null && actionMode.getVisibility() == VISIBLE; + return actionMode != null && actionModeVisible; } protected void onSearchFieldVisibilityChanged(boolean visible) { @@ -297,7 +375,7 @@ public class ActionBar extends FrameLayout { } Drawable drawable = backButtonImageView.getDrawable(); if (drawable != null && drawable instanceof MenuDrawable) { - ((MenuDrawable)drawable).setRotation(visible ? 1 : 0, true); + ((MenuDrawable) drawable).setRotation(visible ? 1 : 0, true); } } @@ -322,7 +400,7 @@ public class ActionBar extends FrameLayout { int actionBarHeight = getCurrentActionBarHeight(); int actionBarHeightSpec = MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.EXACTLY); - setMeasuredDimension(width, actionBarHeight + extraHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0)); + setMeasuredDimension(width, actionBarHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0)); int textLeft; if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) { @@ -483,17 +561,6 @@ public class ActionBar extends FrameLayout { return isSearchFieldVisible; } - public void setExtraHeight(int value, boolean layout) { - extraHeight = value; - if (layout) { - requestLayout(); - } - } - - public int getExtraHeight() { - return extraHeight; - } - public void setOccupyStatusBar(boolean value) { occupyStatusBar = value; if (actionMode != null) { @@ -510,7 +577,7 @@ public class ActionBar extends FrameLayout { if (backButtonImageView != null) { backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); } - setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); //Plus + setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); //Plus } public void setCastShadows(boolean value) { @@ -536,4 +603,9 @@ public class ActionBar extends FrameLayout { return AndroidUtilities.dp(56); } } + + @Override + public boolean hasOverlappingRendering() { + return false; + } } \ No newline at end of file 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 5a70d96c..492f7597 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; @@ -59,7 +59,6 @@ public class ActionBarLayout extends FrameLayout { if (child instanceof ActionBar) { return super.drawChild(canvas, child, drawingTime); } else { - //boolean wasActionBar = false; int actionBarHeight = 0; int childCount = getChildCount(); for (int a = 0; a < childCount; a++) { @@ -70,24 +69,10 @@ public class ActionBarLayout extends FrameLayout { if (view instanceof ActionBar && view.getVisibility() == VISIBLE) { if (((ActionBar) view).getCastShadows()) { actionBarHeight = view.getMeasuredHeight(); - //wasActionBar = true; } break; } } - /*if (!wasActionBar) { - if (child instanceof ViewGroup) { - ViewGroup viewGroup = (ViewGroup) child; - childCount = viewGroup.getChildCount(); - for (int a = 0; a < childCount; a++) { - View possibleActionBar = viewGroup.getChildAt(a); - if (possibleActionBar instanceof ActionBar) { - actionBarHeight = possibleActionBar.getMeasuredHeight(); - break; - } - } - } - }*/ boolean result = super.drawChild(canvas, child, drawingTime); if (actionBarHeight != 0 && headerShadowDrawable != null) { headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight()); @@ -96,6 +81,11 @@ public class ActionBarLayout extends FrameLayout { return result; } } + + @Override + public boolean hasOverlappingRendering() { + return false; + } } private static Drawable headerShadowDrawable; @@ -129,6 +119,7 @@ public class ActionBarLayout extends FrameLayout { private boolean useAlphaAnimations; private View backgroundView; private boolean removeActionBarExtraHeight; + private Runnable animationRunnable; private float animationProgress = 0.0f; private long lastFrameTime; @@ -257,7 +248,7 @@ public class ActionBarLayout extends FrameLayout { } final int restoreCount = canvas.save(); - if (!transitionAnimationInProgress) { + if (!transitionAnimationInProgress && clipLeft != 0 && clipRight != 0) { canvas.clipRect(clipLeft, 0, clipRight, getHeight()); } final boolean result = super.drawChild(canvas, child, drawingTime); @@ -312,7 +303,7 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(lastFragment.fragmentView); } } - if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { + if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) { ViewGroup parent = (ViewGroup) lastFragment.actionBar.getParent(); if (parent != null) { parent.removeView(lastFragment.actionBar); @@ -320,7 +311,6 @@ public class ActionBarLayout extends FrameLayout { } } containerViewBack.setVisibility(View.GONE); - //AndroidUtilities.unlockOrientation(parentActivity); startedTracking = false; animationInProgress = false; @@ -350,7 +340,7 @@ public class ActionBarLayout extends FrameLayout { if (parent != null) { parent.removeView(fragmentView); } - if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { + if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) { parent = (ViewGroup) lastFragment.actionBar.getParent(); if (parent != null) { parent.removeView(lastFragment.actionBar); @@ -370,8 +360,6 @@ public class ActionBarLayout extends FrameLayout { fragmentView.setBackgroundColor(0xffffffff); } lastFragment.onResume(); - - //AndroidUtilities.lockOrientation(parentActivity); } public boolean onTouchEvent(MotionEvent ev) { @@ -516,6 +504,10 @@ public class ActionBarLayout extends FrameLayout { } currentAnimation = null; } + if (animationRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(animationRunnable); + animationRunnable = null; + } ViewProxy.setAlpha(this, 1.0f); ViewProxy.setAlpha(containerView, 1.0f); ViewProxy.setScaleX(containerView, 1.0f); @@ -548,7 +540,7 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(fragment.fragmentView); } } - if (fragment.needAddActionBar() && fragment.actionBar != null) { + if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) { ViewGroup parent = (ViewGroup) fragment.actionBar.getParent(); if (parent != null) { parent.removeView(fragment.actionBar); @@ -570,17 +562,18 @@ public class ActionBarLayout extends FrameLayout { if (first) { animationProgress = 0.0f; lastFrameTime = System.nanoTime() / 1000000; - if (Build.VERSION.SDK_INT >= 11) { - if (open) { - containerView.setLayerType(LAYER_TYPE_HARDWARE, null); - } else { - containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null); - } + if (Build.VERSION.SDK_INT > 15) { + containerView.setLayerType(LAYER_TYPE_HARDWARE, null); + containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null); } } - AndroidUtilities.runOnUIThread(new Runnable() { + AndroidUtilities.runOnUIThread(animationRunnable = new Runnable() { @Override public void run() { + if (animationRunnable != this) { + return; + } + animationRunnable = null; if (first) { transitionAnimationStartTime = System.currentTimeMillis(); } @@ -632,7 +625,7 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(fragmentView); } } - if (fragment.needAddActionBar() && fragment.actionBar != null) { + if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) { if (removeActionBarExtraHeight) { fragment.actionBar.setOccupyStatusBar(false); } @@ -663,7 +656,6 @@ public class ActionBarLayout extends FrameLayout { setInnerTranslationX(0); bringChildToFront(containerView); - if (!needAnimation) { presentFragmentInternalRemoveOld(removeLast, currentFragment); if (backgroundView != null) { @@ -680,7 +672,7 @@ public class ActionBarLayout extends FrameLayout { onOpenAnimationEndRunnable = new Runnable() { @Override public void run() { - fragment.onOpenAnimationEnd(); + fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); } }; @@ -691,7 +683,7 @@ public class ActionBarLayout extends FrameLayout { animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f)); } - fragment.onOpenAnimationStart(); + fragment.onTransitionAnimationStart(true, false); currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether(animators); currentAnimation.setInterpolator(accelerateDecelerateInterpolator); @@ -714,50 +706,44 @@ public class ActionBarLayout extends FrameLayout { onOpenAnimationEndRunnable = new Runnable() { @Override public void run() { - if (Build.VERSION.SDK_INT >= 18) { + if (Build.VERSION.SDK_INT > 15) { containerView.setLayerType(LAYER_TYPE_NONE, null); + containerViewBack.setLayerType(LAYER_TYPE_NONE, null); } presentFragmentInternalRemoveOld(removeLast, currentFragment); - fragment.onOpenAnimationEnd(); + fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); ViewProxy.setTranslationX(containerView, 0); } }; - ViewProxy.setAlpha(containerView, 0.0f); - ViewProxy.setTranslationX(containerView, 48.0f); - fragment.onOpenAnimationStart(); - startLayoutAnimation(true, true); - /*currentAnimation = new AnimatorSetProxy(); - currentAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f), - ObjectAnimatorProxy.ofFloat(containerView, "translationX", AndroidUtilities.dp(48), 0)); - currentAnimation.setInterpolator(decelerateInterpolator); - currentAnimation.setDuration(200); - currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + fragment.onTransitionAnimationStart(true, false); + AnimatorSetProxy animation = fragment.onCustomTransitionAnimation(true, new Runnable() { @Override - public void onAnimationStart(Object animation) { - transitionAnimationStartTime = System.currentTimeMillis(); - } - - @Override - public void onAnimationEnd(Object animation) { - onAnimationEndCheck(false); - } - - @Override - public void onAnimationCancel(Object animation) { + public void run() { onAnimationEndCheck(false); } }); - currentAnimation.start();*/ + if (animation == null) { + ViewProxy.setAlpha(containerView, 0.0f); + ViewProxy.setTranslationX(containerView, 48.0f); + startLayoutAnimation(true, true); + } else { + if (Build.VERSION.SDK_INT > 15) { + //containerView.setLayerType(LAYER_TYPE_HARDWARE, null); + //containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null); + } + ViewProxy.setAlpha(containerView, 1.0f); + ViewProxy.setTranslationX(containerView, 0.0f); + currentAnimation = animation; + } } } else { if (backgroundView != null) { ViewProxy.setAlpha(backgroundView, 1.0f); backgroundView.setVisibility(VISIBLE); } - fragment.onOpenAnimationStart(); - fragment.onOpenAnimationEnd(); + fragment.onTransitionAnimationStart(true, false); + fragment.onTransitionAnimationEnd(true, false); fragment.onBecomeFullyVisible(); } return true; @@ -836,7 +822,7 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(fragmentView); } } - if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { + if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) { if (removeActionBarExtraHeight) { previousFragment.actionBar.setOccupyStatusBar(false); } @@ -852,7 +838,8 @@ public class ActionBarLayout extends FrameLayout { layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; fragmentView.setLayoutParams(layoutParams); - previousFragment.onOpenAnimationStart(); + previousFragment.onTransitionAnimationStart(true, true); + currentFragment.onTransitionAnimationStart(false, false); previousFragment.onResume(); currentActionBar = previousFragment.actionBar; if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) { @@ -870,42 +857,35 @@ public class ActionBarLayout extends FrameLayout { onCloseAnimationEndRunnable = new Runnable() { @Override public void run() { - if (Build.VERSION.SDK_INT >= 18) { + if (Build.VERSION.SDK_INT > 15) { + containerView.setLayerType(LAYER_TYPE_NONE, null); containerViewBack.setLayerType(LAYER_TYPE_NONE, null); } closeLastFragmentInternalRemoveOld(currentFragment); ViewProxy.setTranslationX(containerViewBack, 0); - previousFragmentFinal.onOpenAnimationEnd(); + currentFragment.onTransitionAnimationEnd(false, false); + previousFragmentFinal.onTransitionAnimationEnd(true, true); previousFragmentFinal.onBecomeFullyVisible(); } }; - startLayoutAnimation(false, true); - - /*currentAnimation = new AnimatorSetProxy(); - currentAnimation.playTogether( - ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f), - ObjectAnimatorProxy.ofFloat(containerViewBack, "translationX", 0, AndroidUtilities.dp(48))); - currentAnimation.setInterpolator(decelerateInterpolator); - currentAnimation.setDuration(200); - currentAnimation.addListener(new AnimatorListenerAdapterProxy() { + AnimatorSetProxy animation = currentFragment.onCustomTransitionAnimation(false, new Runnable() { @Override - public void onAnimationStart(Object animation) { - transitionAnimationStartTime = System.currentTimeMillis(); - } - - @Override - public void onAnimationEnd(Object animation) { - onAnimationEndCheck(false); - } - - @Override - public void onAnimationCancel(Object animation) { + public void run() { onAnimationEndCheck(false); } }); - currentAnimation.start();*/ + if (animation == null) { + startLayoutAnimation(false, true); + } else { + if (Build.VERSION.SDK_INT > 15) { + //containerView.setLayerType(LAYER_TYPE_HARDWARE, null); + //containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null); + } + currentAnimation = animation; + } } else { - previousFragment.onOpenAnimationEnd(); + currentFragment.onTransitionAnimationEnd(false, false); + previousFragment.onTransitionAnimationEnd(true, true); previousFragment.onBecomeFullyVisible(); } } else { @@ -968,6 +948,22 @@ public class ActionBarLayout extends FrameLayout { if (fragmentsStack.isEmpty()) { return; } + for (int a = 0; a < fragmentsStack.size() - 1; a++) { + BaseFragment previousFragment = fragmentsStack.get(a); + if (previousFragment.actionBar != null) { + ViewGroup parent = (ViewGroup) previousFragment.actionBar.getParent(); + if (parent != null) { + parent.removeView(previousFragment.actionBar); + } + } + if (previousFragment.fragmentView != null) { + ViewGroup parent = (ViewGroup) previousFragment.fragmentView.getParent(); + if (parent != null) { + previousFragment.onPause(); + parent.removeView(previousFragment.fragmentView); + } + } + } BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1); previousFragment.setParentLayout(this); View fragmentView = previousFragment.fragmentView; @@ -979,7 +975,7 @@ public class ActionBarLayout extends FrameLayout { parent.removeView(fragmentView); } } - if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { + if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) { if (removeActionBarExtraHeight) { previousFragment.actionBar.setOccupyStatusBar(false); } @@ -1136,4 +1132,9 @@ public class ActionBarLayout extends FrameLayout { } } } + + @Override + public boolean hasOverlappingRendering() { + return false; + } } 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 e7f4ac34..ee58185b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenu.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; 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 44d22d65..c73a11e8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java index 36f3dd0d..fb6c27ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarPopupWindow.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ //Thanks to https://github.com/JakeWharton/ActionBarSherlock/ 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 95c86d01..5ecd758e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; @@ -21,6 +21,7 @@ import android.widget.Button; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; @@ -49,6 +50,14 @@ public class BaseFragment { classGuid = ConnectionsManager.getInstance().generateClassGuid(); } + public ActionBar getActionBar() { + return actionBar; + } + + public View getFragmentView() { + return fragmentView; + } + public View createView(Context context) { return null; } @@ -164,7 +173,7 @@ public class BaseFragment { actionBar.onPause(); } try { - if (visibleDialog != null && visibleDialog.isShowing()) { + if (visibleDialog != null && visibleDialog.isShowing() && dismissDialogOnPause(visibleDialog)) { visibleDialog.dismiss(); visibleDialog = null; } @@ -185,6 +194,10 @@ public class BaseFragment { } + public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { + + } + public void saveSelfArgs(Bundle args) { } @@ -218,6 +231,10 @@ public class BaseFragment { } } + public boolean dismissDialogOnPause(Dialog dialog) { + return true; + } + public void onBeginSlide() { try { if (visibleDialog != null && visibleDialog.isShowing()) { @@ -232,11 +249,11 @@ public class BaseFragment { } } - protected void onOpenAnimationEnd() { + protected void onTransitionAnimationStart(boolean isOpen, boolean backward) { } - protected void onOpenAnimationStart() { + protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) { } @@ -244,12 +261,12 @@ public class BaseFragment { } - public void onLowMemory() { - + protected AnimatorSetProxy onCustomTransitionAnimation(boolean isOpen, final Runnable callback) { + return null; } - public boolean needAddActionBar() { - return true; + public void onLowMemory() { + } public Dialog showDialog(Dialog dialog) { 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 65057f9d..85f32fe7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java @@ -1,13 +1,14 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; +import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; @@ -72,12 +73,14 @@ public class DrawerLayoutContainer extends FrameLayout { if (Build.VERSION.SDK_INT >= 21) { setFitsSystemWindows(true); - configureApplyInsets(this); + setOnApplyWindowInsetsListener(new InsetsListener()); + 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) { @@ -87,13 +90,7 @@ public class DrawerLayoutContainer extends FrameLayout { } } - private void configureApplyInsets(View drawerLayout) { - if (Build.VERSION.SDK_INT >= 21) { - drawerLayout.setOnApplyWindowInsetsListener(new InsetsListener()); - drawerLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); - } - } - + @SuppressLint("NewApi") private void dispatchChildInsets(View child, Object insets, int drawerGravity) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { @@ -104,6 +101,7 @@ public class DrawerLayoutContainer extends FrameLayout { child.dispatchApplyWindowInsets(wi); } + @SuppressLint("NewApi") private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { WindowInsets wi = (WindowInsets) insets; if (drawerGravity == Gravity.LEFT) { @@ -416,6 +414,7 @@ public class DrawerLayoutContainer extends FrameLayout { } } + @SuppressLint("NewApi") @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthSize = MeasureSpec.getSize(widthMeasureSpec); @@ -438,7 +437,7 @@ public class DrawerLayoutContainer extends FrameLayout { if (applyInsets) { if (child.getFitsSystemWindows()) { dispatchChildInsets(child, lastInsets, lp.gravity); - } else { + } else if (child.getTag() == null) { applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21); } } @@ -495,6 +494,7 @@ public class DrawerLayoutContainer extends FrameLayout { } final int height = getHeight(); final boolean drawingContent = child != drawerLayout; + int lastVisibleChild = 0; int clipLeft = 0, clipRight = getWidth(); final int restoreCount = canvas.save(); @@ -502,6 +502,9 @@ public class DrawerLayoutContainer extends FrameLayout { final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View v = getChildAt(i); + if (v.getVisibility() == VISIBLE && v != drawerLayout) { + lastVisibleChild = i; + } if (v == child || v.getVisibility() != VISIBLE || v != drawerLayout || v.getHeight() < height) { continue; } @@ -511,14 +514,18 @@ public class DrawerLayoutContainer extends FrameLayout { clipLeft = vright; } } + if (clipLeft != 0) { canvas.clipRect(clipLeft, 0, clipRight, getHeight()); } + } final boolean result = super.drawChild(canvas, child, drawingTime); canvas.restoreToCount(restoreCount); if (scrimOpacity > 0 && drawingContent) { + if (indexOfChild(child) == lastVisibleChild) { scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24); canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint); + } } else if (shadowLeft != null) { final float alpha = Math.max(0, Math.min(drawerPosition / AndroidUtilities.dp(20), 1.0f)); if (alpha != 0) { @@ -529,4 +536,9 @@ public class DrawerLayoutContainer extends FrameLayout { } return result; } + + @Override + public boolean hasOverlappingRendering() { + return false; + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java index ca19e51b..3543bbe7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.ActionBar; @@ -11,6 +11,7 @@ package org.telegram.ui.ActionBar; 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; @@ -80,11 +81,11 @@ public class MenuDrawable extends Drawable { canvas.save(); canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2); canvas.rotate(currentRotation * (reverseAngle ? -180 : 180)); - canvas.drawLine(-AndroidUtilities.dp(9), 0, AndroidUtilities.dp(9) - AndroidUtilities.dp(1) * currentRotation, 0, paint); + canvas.drawLine(-AndroidUtilities.dp(9), 0, AndroidUtilities.dp(9) - AndroidUtilities.dp(3.0f) * currentRotation, 0, paint); float endYDiff = AndroidUtilities.dp(5) * (1 - Math.abs(currentRotation)) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation); - float endXDiff = AndroidUtilities.dp(9) - AndroidUtilities.dp(0.5f) * Math.abs(currentRotation); - float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(3.5f) * Math.abs(currentRotation); - float startXDiff = -AndroidUtilities.dp(9) + AndroidUtilities.dp(8.5f) * Math.abs(currentRotation); + float endXDiff = AndroidUtilities.dp(9) - AndroidUtilities.dp(2.5f) * Math.abs(currentRotation); + float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(2.0f) * Math.abs(currentRotation); + float startXDiff = -AndroidUtilities.dp(9) + AndroidUtilities.dp(7.5f) * Math.abs(currentRotation); canvas.drawLine(startXDiff, -startYDiff, endXDiff, -endYDiff, paint); canvas.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint); canvas.restore(); @@ -103,7 +104,7 @@ public class MenuDrawable extends Drawable { @Override public int getOpacity() { - return 0; + return PixelFormat.TRANSPARENT; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseFragmentAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseFragmentAdapter.java index 13196134..57bd70eb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseFragmentAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseFragmentAdapter.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java index c80eb04b..bfd0457e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseLocationAdapter.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSearchAdapter.java index 011144e6..36f36779 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSearchAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSectionsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSectionsAdapter.java index f9b75add..a6b49329 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSectionsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/BaseSectionsAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; 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 afe18248..91049dbe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ChatActivityAdapter.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java index 2c058d51..9b4df546 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; @@ -18,15 +18,13 @@ import android.view.View; import android.view.ViewGroup; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.AnimationCompat.ViewProxy; - import org.telegram.messenger.LocaleController; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.ContactsController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.R; - +import org.telegram.messenger.AnimationCompat.ViewProxy; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.LetterSectionCell; @@ -298,12 +296,6 @@ public class ContactsAdapter extends BaseSectionsAdapter { ViewProxy.setAlpha(convertView, 1.0f); } } - //((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0); - //((UserCell) convertView).setStatusColors(themePrefs.getInt("contactsStatusColor", 0xffa8a8a8), themePrefs.getInt("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); - //((UserCell) convertView).setNameColor(cColorBlack); - //((UserCell) convertView).setNameSize(themePrefs.getInt("contactsNameSize", 17)); - //((UserCell) convertView).setStatusSize(themePrefs.getInt("contactsStatusSize", 14)); - //((UserCell) convertView).setAvatarRadius(themePrefs.getInt("contactsAvatarRadius", 32)); } //parent.setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff)); //Plus updateListBG(parent); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountryAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountryAdapter.java index 3c577880..216f27c8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountryAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountryAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java index b7da3404..0282d9df 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; 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 cb3f72c7..dc19455c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; 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 217646cc..1301d865 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; @@ -180,7 +180,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { } public boolean isRecentSearchDisplayed() { - return (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty(); + return needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty(); } public void loadRecentSearch() { @@ -778,7 +778,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { @Override public int getItemCount() { - if ((lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { + if (needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { return recentSearchObjects.size() + 1; } if (!searchResultHashtags.isEmpty()) { @@ -797,7 +797,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { } public Object getItem(int i) { - if ((lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { + if (needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { if (i > 0 && i - 1 < recentSearchObjects.size()) { return recentSearchObjects.get(i - 1).object; } else { @@ -868,7 +868,6 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { boolean isRecent = false; String un = null; String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); - Object obj = getItem(position); if (obj instanceof TLRPC.User) { @@ -885,7 +884,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { user = MessagesController.getInstance().getUser(encryptedChat.user_id); } - if ((lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { + if (needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { isRecent = true; cell.useSeparator = position != getItemCount() - 1; } else { @@ -922,7 +921,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { GreySectionCell cell = (GreySectionCell) holder.itemView; cell.setBackgroundColor(themePrefs.getInt("chatsRowColor", 0xfff2f2f2)); cell.setTextColor(themePrefs.getInt("chatsNameColor", 0xff8a8a8a)); - if ((lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { + if (needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { cell.setText(LocaleController.getString("Recent", R.string.Recent).toUpperCase()); } else if (!searchResultHashtags.isEmpty()) { cell.setText(LocaleController.getString("Hashtags", R.string.Hashtags).toUpperCase()); @@ -957,7 +956,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler { @Override public int getItemViewType(int i) { - if ((lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { + if (needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty()) { return i == 0 ? 1 : 0; } if (!searchResultHashtags.isEmpty()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java index ce09b9ba..fce3bc38 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DrawerLayoutAdapter.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java index a0efeae9..dbdadeba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivityAdapter.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivitySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivitySearchAdapter.java index bc030a09..94669e13 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivitySearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/LocationActivitySearchAdapter.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 370c0268..65b94218 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/MentionsAdapter.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapter.java index 09fd654b..ceb80201 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/SearchAdapter.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java index 4bbe6a5e..326e207a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/StickersAdapter.java @@ -3,12 +3,13 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Adapters; import android.content.Context; +import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; @@ -87,8 +88,18 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio } public void loadStikersForEmoji(CharSequence emoji) { - boolean search = emoji != null && emoji.length() > 0 && emoji.length() <= 4; + boolean search = emoji != null && emoji.length() > 0 && emoji.length() <= 14; if (search) { + int length = emoji.length(); + for (int a = 0; a < length; a++) { + if (a < length - 1 && emoji.charAt(a) == 0xD83C && emoji.charAt(a + 1) >= 0xDFFB && emoji.charAt(a + 1) <= 0xDFFF) { + emoji = TextUtils.concat(emoji.subSequence(0, a), emoji.subSequence(a + 2, emoji.length())); + break; + } else if (emoji.charAt(a) == 0xfe0f) { + emoji = TextUtils.concat(emoji.subSequence(0, a), emoji.subSequence(a + 1, emoji.length())); + length--; + } + } lastSticker = emoji.toString(); HashMap> allStickers = StickersQuery.getAllStickers(); if (allStickers != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java index ac206ccc..5c455ef6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AddMemberCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AddMemberCell.java index e6128be7..cbfbd8ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AddMemberCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AddMemberCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -11,7 +11,9 @@ package org.telegram.ui.Cells; import android.content.Context; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; +import android.os.Build; import android.view.Gravity; +import android.view.MotionEvent; import android.widget.FrameLayout; import android.widget.ImageView; @@ -42,9 +44,19 @@ public class AddMemberCell extends FrameLayout { addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : 129, 22.5f, LocaleController.isRTL ? 129 : 28, 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(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY)); } public void setTextColor(int color) { 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 5ee2f776..d3215137 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/BaseCell.java @@ -3,7 +3,7 @@ * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -33,11 +33,11 @@ public class BaseCell extends View { public void run() { if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) { checkingForLongPress = false; + performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + onLongPress(); MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0); onTouchEvent(event); event.recycle(); - performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - onLongPress(); } } } 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 85ff80a8..7a04a4e4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java index 80309e63..df142fdf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatAudioCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -19,14 +19,14 @@ import android.view.MotionEvent; import android.view.SoundEffectConstants; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.ImageLoader; -import org.telegram.messenger.MessagesController; -import org.telegram.messenger.SendMessagesHelper; -import org.telegram.messenger.BuildVars; +import org.telegram.messenger.BuildConfig; import org.telegram.messenger.FileLoader; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.ImageLoader; import org.telegram.messenger.MediaController; import org.telegram.messenger.MessageObject; -import org.telegram.messenger.FileLog; +import org.telegram.messenger.MessagesController; +import org.telegram.messenger.SendMessagesHelper; import org.telegram.ui.Components.RadialProgress; import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.SeekBar; @@ -149,6 +149,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega invalidate(); } } else if (buttonState == 2) { + radialProgress.setProgress(0, false); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true); buttonState = 3; radialProgress.setBackground(getDrawableForCurrentState(), true, false); @@ -223,7 +224,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega if (cacheFile == null) { cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); } - if (BuildVars.DEBUG_VERSION) { + //if (BuildVars.DEBUG_VERSION) { + if (BuildConfig.DEBUG) { FileLog.d("tmessages", "looking for audio in " + cacheFile); } if (cacheFile.exists()) { @@ -308,6 +310,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(13) - (((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) ? AndroidUtilities.dp(leftBound) : 0); timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(66) - (((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) ? AndroidUtilities.dp(leftBound) : 0); } else { + //if (isChat && currentMessageObject.messageOwner.from_id > 0) { if ((isChat || showAvatar) && currentMessageObject.messageOwner.from_id > 0) { //seekBarX = AndroidUtilities.dp(116); //buttonX = AndroidUtilities.dp(74); @@ -336,7 +339,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega boolean dataChanged = currentMessageObject == messageObject && isUserDataChanged(); if (currentMessageObject != messageObject || dataChanged) { if (AndroidUtilities.isTablet()) { - backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.messageOwner.from_id > 0 ? 102 : 50), AndroidUtilities.dp(300)); + //backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(isChat && messageObject.messageOwner.from_id > 0 ? 102 : 50), AndroidUtilities.dp(300)); backgroundWidth = Math.min(AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp( ((isChat || showAvatar) && messageObject.messageOwner.from_id > 0) || (messageObject.isOutOwner() && ((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat))) ? leftBound + 50 : 50), AndroidUtilities.dp(300)); } else { //backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.messageOwner.from_id > 0 ? 102 : 50), AndroidUtilities.dp(300)); 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 668ba91b..cb44a84d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -50,7 +50,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo void didPressedCancelSendButton(ChatBaseCell cell); void didLongPressed(ChatBaseCell cell); void didPressReplyMessage(ChatBaseCell cell, int id); - void didPressUrl(MessageObject messageObject, ClickableSpan url); + void didPressUrl(MessageObject messageObject, ClickableSpan url, boolean longPress); void needOpenWebView(String url, String title, String originalUrl, int w, int h); void didClickedImage(ChatBaseCell cell); boolean canPerformActions(); @@ -71,6 +71,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo private boolean wasLayout = false; protected boolean isAvatarVisible = false; protected boolean drawBackground = true; + protected boolean allowAssistant = false; protected MessageObject currentMessageObject; private static TextPaint timePaintIn; @@ -119,11 +120,16 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo private StaticLayout timeLayout; protected int timeWidth; + private int timeTextWidth; private int timeX; private TextPaint currentTimePaint; private String currentTimeString; protected boolean drawTime = true; + private StaticLayout viewsLayout; + private int viewsTextWidth; + private String currentViewsString; + private TLRPC.User currentUser; private TLRPC.Chat currentChat; private TLRPC.FileLocation currentPhoto; @@ -301,6 +307,10 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo invalidate(); } + public void setAllowAssistant(boolean value) { + allowAssistant = value; + } + protected boolean isUserDataChanged() { if (currentMessageObject == null || currentUser == null && currentChat == null) { return false; @@ -371,27 +381,11 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } protected void measureTime(MessageObject messageObject) { - if (!media) { - if (messageObject.isOutOwner()) { - currentTimePaint = timePaintOut; - } else { - currentTimePaint = timePaintIn; - } - } else { - currentTimePaint = timeMediaPaint; - } - String timeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000); + currentTimeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000); + timeTextWidth = timeWidth = (int) Math.ceil(timeMediaPaint.measureText(currentTimeString)); if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { - currentTimeString = String.format("%s ", LocaleController.formatShortNumber(messageObject.messageOwner.views, null)) + timeString; - } else { - currentTimeString = timeString; - } - timeWidth = (int) Math.ceil(currentTimePaint.measureText(currentTimeString)); - if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { - timeWidth += ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4); - } - if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0 && (messageObject.isSending() || messageObject.isSendError())) { - currentTimeString = timeString; + currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null)); + timeWidth += (int) Math.ceil(timeMediaPaint.measureText(currentViewsString)) + ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10); } } @@ -462,18 +456,12 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo currentTimePaint = timeMediaPaint; } - String timeString = LocaleController.formatterDay.format((long) (currentMessageObject.messageOwner.date) * 1000); - if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { - currentTimeString = String.format("%s ", LocaleController.formatShortNumber(currentMessageObject.messageOwner.views, null)) + timeString; - } else { - currentTimeString = timeString; - } - timeWidth = (int)Math.ceil(currentTimePaint.measureText(currentTimeString)); - if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { - timeWidth += ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4); - } - if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0 && (currentMessageObject.isSending() || currentMessageObject.isSendError())) { - currentTimeString = timeString; + currentTimeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000); + timeTextWidth = timeWidth = (int)Math.ceil(currentTimePaint.measureText(currentTimeString)); + 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(currentTimePaint.measureText(currentViewsString)); + timeWidth += viewsTextWidth + ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10); } namesOffset = 0; @@ -493,8 +481,6 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } nameWidth = getMaxNameWidth(); - - CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (nameLayout.getLineCount() > 0) { @@ -764,7 +750,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo layoutWidth = getMeasuredWidth(); layoutHeight = getMeasuredHeight(); - timeLayout = new StaticLayout(currentTimeString, currentTimePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + timeLayout = new StaticLayout(currentTimeString, currentTimePaint, timeTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (!media) { if (!currentMessageObject.isOutOwner()) { //timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat && currentMessageObject.messageOwner.from_id > 0 ? AndroidUtilities.dp(52) : 0); @@ -785,6 +771,12 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } } + if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { + viewsLayout = new StaticLayout(currentViewsString, currentTimePaint, viewsTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + } else { + viewsLayout = null; + } + if (isAvatarVisible) { //avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); if(((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && currentMessageObject.isOutOwner()){ @@ -1036,6 +1028,13 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo } else { setDrawableBounds(ResourceLoader.viewsMediaCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(10) - timeLayout.getHeight()); ResourceLoader.viewsMediaCountDrawable.draw(canvas); + + if (viewsLayout != null) { + canvas.save(); + canvas.translate(timeX + ResourceLoader.viewsMediaCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(12.0f) - timeLayout.getHeight()); + viewsLayout.draw(canvas); + canvas.restore(); + } } } @@ -1066,6 +1065,13 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo setDrawableBounds(ResourceLoader.viewsOutCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight()); ResourceLoader.viewsOutCountDrawable.draw(canvas); } + + if (viewsLayout != null) { + canvas.save(); + canvas.translate(timeX + ResourceLoader.viewsOutCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dp(6.5f) - timeLayout.getHeight()); + viewsLayout.draw(canvas); + canvas.restore(); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java index c5716bef..1fa7fbe6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatContactCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -28,8 +28,8 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; -import org.telegram.messenger.UserConfig; import org.telegram.tgnet.TLRPC; +import org.telegram.messenger.UserConfig; import org.telegram.ui.Components.AvatarDrawable; public class ChatContactCell extends ChatBaseCell { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java index 4d8ecbb8..2aff7168 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -46,6 +46,7 @@ import org.telegram.ui.Components.GifDrawable; import org.telegram.ui.Components.RadialProgress; import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.StaticLayoutEx; +import org.telegram.ui.Components.URLSpanBotCommand; import org.telegram.ui.PhotoViewer; import java.io.File; @@ -100,6 +101,7 @@ public class ChatMediaCell extends ChatBaseCell { // private StaticLayout nameLayout; private int nameWidth = 0; + private int nameOffsetX = 0; private String currentNameString; private ChatMediaCellDelegate mediaDelegate = null; @@ -196,7 +198,11 @@ public class ChatMediaCell extends ChatBaseCell { if (left <= x2 && left + nameLayout.getLineWidth(line) >= x2) { Spannable buffer = (Spannable) currentMessageObject.caption; ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); - if (link.length != 0) { + boolean ignore = false; + if (link.length == 0 || link.length != 0 && link[0] instanceof URLSpanBotCommand && !URLSpanBotCommand.enabled) { + ignore = true; + } + if (!ignore) { resetPressedLink(); pressedLink = link[0]; linkPreviewPressed = true; @@ -220,7 +226,7 @@ public class ChatMediaCell extends ChatBaseCell { } } else if (linkPreviewPressed) { try { - delegate.didPressUrl(currentMessageObject, pressedLink); + delegate.didPressUrl(currentMessageObject, pressedLink, false); } catch (Exception e) { FileLog.e("tmessages", e); } @@ -460,7 +466,7 @@ public class ChatMediaCell 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=13&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:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); if (!url.equals(currentUrl)) { return true; } @@ -504,6 +510,7 @@ public class ChatMediaCell extends ChatBaseCell { public void setMessageObject(MessageObject messageObject) { boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) { + drawForwardedName = (messageObject.type == 3 || messageObject.type == 1) && messageObject.messageOwner.fwd_from_id != null && messageObject.messageOwner.fwd_from_id.channel_id != 0; media = messageObject.type != 9; cancelLoading = false; additionHeight = 0; @@ -518,7 +525,6 @@ public class ChatMediaCell extends ChatBaseCell { drawBackground = true; photoImage.setForcePreview(messageObject.isSecretPhoto()); - if (messageObject.type == 9) { String name = messageObject.getDocumentName(); if (name == null || name.length() == 0) { @@ -535,6 +541,7 @@ public class ChatMediaCell extends ChatBaseCell { nameLayout = StaticLayoutEx.createStaticLayout(currentNameString, namePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth, 1); if (nameLayout.getLineCount() > 0) { nameWidth = Math.min(maxWidth, (int) Math.ceil(nameLayout.getLineWidth(0))); + nameOffsetX = (int) Math.ceil(-nameLayout.getLineLeft(0)); } else { nameWidth = maxWidth; } @@ -554,7 +561,7 @@ public class ChatMediaCell extends ChatBaseCell { } ext = ext.toUpperCase(); - String str = AndroidUtilities.formatFileSize(messageObject.messageOwner.media.document.size) + " " + ext; + String str = AndroidUtilities.formatFileSize(messageObject.messageOwner.media.document.size) + " " + messageObject.getExtension(); if (currentInfoString == null || !currentInfoString.equals(str)) { currentInfoString = str; @@ -641,7 +648,7 @@ public class ChatMediaCell extends ChatBaseCell { currentNameString = null; infoLayout = null; nameLayout = null; - updateSecretTimeText(); + updateSecretTimeText(messageObject); infoLayout2 = null; //Plus } if (messageObject.type == 9) { //doc @@ -663,7 +670,7 @@ public class ChatMediaCell extends ChatBaseCell { 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.isOut() ? 102 : 40) + 86 + 24); + //int maxWidth = (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) - AndroidUtilities.dp((isChat && !messageObject.isOutOwner() ? 102 : 40) + 86 + 24); int maxWidth = (AndroidUtilities.isTablet() ? AndroidUtilities.getMinTabletSide() : Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y)) - AndroidUtilities.dp(((isChat || showAvatar) && !messageObject.isOutOwner() ? leftBound + 50 : 40) + 86 + 24); nameLayout = 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); int lineCount = nameLayout.getLineCount(); @@ -687,12 +694,12 @@ public class ChatMediaCell extends ChatBaseCell { } } backgroundWidth = photoWidth + AndroidUtilities.dp(21) + maxWidth; - currentUrl = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&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:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); } else { 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=13&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:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int) Math.ceil(AndroidUtilities.density)), lat, lon); } photoImage.setNeedsQualityThumb(false); @@ -914,11 +921,20 @@ public class ChatMediaCell extends ChatBaseCell { } super.setMessageObject(messageObject); + if (drawForwardedName) { + namesOffset += AndroidUtilities.dp(5); + } + invalidate(); } updateButtonState(dataChanged); } + @Override + protected int getMaxNameWidth() { + return backgroundWidth - AndroidUtilities.dp(14); + } + @Override public ImageReceiver getPhotoImage() { return photoImage; @@ -1040,12 +1056,13 @@ public class ChatMediaCell extends ChatBaseCell { deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45)); } - private void updateSecretTimeText() { - if (currentMessageObject == null || currentMessageObject.isOut()) { + private void updateSecretTimeText(MessageObject messageObject) { + if (messageObject == null || messageObject.isOut()) { return; } - String str = currentMessageObject.getSecretTimeString(); + String str = messageObject.getSecretTimeString(); if (str == null) { + infoLayout = null; return; } if (currentInfoString == null || !currentInfoString.equals(str)) { @@ -1166,7 +1183,7 @@ public class ChatMediaCell extends ChatBaseCell { int offset = AndroidUtilities.dp(2); invalidate((int) deleteProgressRect.left - offset, (int) deleteProgressRect.top - offset, (int) deleteProgressRect.right + offset * 2, (int) deleteProgressRect.bottom + offset * 2); } - updateSecretTimeText(); + updateSecretTimeText(currentMessageObject); } } @@ -1187,7 +1204,11 @@ public class ChatMediaCell extends ChatBaseCell { if (pressedLink != null) { canvas.drawPath(urlPath, urlPaint); } - nameLayout.draw(canvas); + try { + nameLayout.draw(canvas); + } catch (Exception e) { + FileLog.e("tmessages", e); + } canvas.restore(); } //if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto())) { @@ -1226,7 +1247,7 @@ public class ChatMediaCell extends ChatBaseCell { locationAddressPaint.setColor(currentMessageObject.isOutOwner() ? 0xff70b15c : 0xff999999); canvas.save(); - canvas.translate(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(3)); nameLayout.draw(canvas); canvas.restore(); @@ -1260,7 +1281,7 @@ public class ChatMediaCell extends ChatBaseCell { } } else if (nameLayout != null) { canvas.save(); - canvas.translate(photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); + canvas.translate(nameOffsetX + photoImage.getImageX() + photoImage.getImageWidth() + AndroidUtilities.dp(10), photoImage.getImageY() + AndroidUtilities.dp(8)); nameLayout.draw(canvas); canvas.restore(); 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 7df1b38a..a019b35f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -3,7 +3,7 @@ * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -26,6 +26,7 @@ import android.text.TextUtils; import android.text.style.ClickableSpan; import android.view.MotionEvent; import android.view.SoundEffectConstants; +import android.view.ViewStructure; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; @@ -40,6 +41,8 @@ import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.RadialProgress; import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.StaticLayoutEx; +import org.telegram.ui.Components.URLSpanBotCommand; +import org.telegram.ui.Components.URLSpanNoUnderline; import java.io.File; import java.util.Locale; @@ -116,7 +119,11 @@ public class ChatMessageCell extends ChatBaseCell { if (left <= x && left + block.textLayout.getLineWidth(line) >= x) { Spannable buffer = (Spannable) currentMessageObject.messageText; ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); - if (link.length != 0) { + boolean ignore = false; + if (link.length == 0 || link.length != 0 && link[0] instanceof URLSpanBotCommand && !URLSpanBotCommand.enabled) { + ignore = true; + } + if (!ignore) { if (event.getAction() == MotionEvent.ACTION_DOWN) { resetPressedLink(); pressedLink = link[0]; @@ -132,7 +139,7 @@ public class ChatMessageCell extends ChatBaseCell { } else { if (link[0] == pressedLink) { try { - delegate.didPressUrl(currentMessageObject, pressedLink); + delegate.didPressUrl(currentMessageObject, pressedLink, false); } catch (Exception e) { FileLog.e("tmessages", e); } @@ -176,7 +183,11 @@ public class ChatMessageCell extends ChatBaseCell { if (left <= x && left + descriptionLayout.getLineWidth(line) >= x) { Spannable buffer = (Spannable) currentMessageObject.linkDescription; ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); - if (link.length != 0) { + boolean ignore = false; + if (link.length == 0 || link.length != 0 && link[0] instanceof URLSpanBotCommand && !URLSpanBotCommand.enabled) { + ignore = true; + } + if (!ignore) { resetPressedLink(); pressedLink = link[0]; linkPreviewPressed = true; @@ -352,6 +363,18 @@ public class ChatMessageCell extends ChatBaseCell { } } + @Override + protected void onLongPress() { + if (pressedLink instanceof URLSpanNoUnderline) { + URLSpanNoUnderline url = (URLSpanNoUnderline) pressedLink; + if (url.getURL().startsWith("/")) { + delegate.didPressUrl(currentMessageObject, pressedLink, true); + return; + } + } + super.onLongPress(); + } + @Override public void setMessageObject(MessageObject messageObject) { boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); @@ -379,23 +402,25 @@ public class ChatMessageCell extends ChatBaseCell { int maxWidth; if (AndroidUtilities.isTablet()) { + //if (isChat && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0) { if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 || ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) { //maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122); maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(leftBound + 70); drawName = true; } else { - drawName = messageObject.messageOwner.to_id.channel_id != 0; + drawName = messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isOutOwner(); maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(80); } } else { + //if (isChat && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0) { if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 || ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) { maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122); drawName = true; } else { maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80); - drawName = messageObject.messageOwner.to_id.channel_id != 0; + drawName = messageObject.messageOwner.to_id.channel_id != 0 && !messageObject.isOutOwner(); } } @@ -563,7 +588,7 @@ public class ChatMessageCell extends ChatBaseCell { totalHeight += height; for (int a = 0; a < descriptionLayout.getLineCount(); a++) { int lineLeft = (int) Math.ceil(descriptionLayout.getLineLeft(a)); - if (descriptionX == 0) { + if (a == 0 && descriptionX == 0) { descriptionX = -lineLeft; } else { descriptionX = Math.max(descriptionX, -lineLeft); @@ -990,4 +1015,12 @@ public class ChatMessageCell extends ChatBaseCell { updateButtonState(false); } } + + @Override + public void onProvideStructure(ViewStructure structure) { + super.onProvideStructure(structure); + if (allowAssistant && Build.VERSION.SDK_INT >= 23) { + structure.setText(currentMessageObject.messageText); + } + } } 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 6ff8a221..53a9d83c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -3,7 +3,7 @@ * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -23,23 +23,18 @@ import android.view.MotionEvent; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ContactsController; import org.telegram.messenger.Emoji; +import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; -import org.telegram.messenger.UserObject; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; -import org.telegram.tgnet.TLRPC; -import org.telegram.messenger.ContactsController; -import org.telegram.messenger.Emoji; -import org.telegram.messenger.MessagesController; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; -import org.telegram.messenger.ImageReceiver; +import org.telegram.messenger.UserObject; +import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.AvatarDrawable; import java.util.ArrayList; @@ -64,9 +59,11 @@ public class DialogCell extends BaseCell { private static Drawable errorDrawable; private static Drawable lockDrawable; private static Drawable countDrawable; + private static Drawable countDrawableGrey; private static Drawable groupDrawable; private static Drawable broadcastDrawable; private static Drawable muteDrawable; + private static Drawable verifiedDrawable; private static Paint linePaint; private static Paint backPaint; @@ -126,6 +123,8 @@ public class DialogCell extends BaseCell { private int countWidth; private StaticLayout countLayout; + private boolean drawVerified; + private int avatarTop = AndroidUtilities.dp(10); private boolean isSelected; @@ -196,11 +195,11 @@ public class DialogCell extends BaseCell { clockDrawable = getResources().getDrawable(R.drawable.msg_clock); errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); + countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2); groupDrawable = getResources().getDrawable(R.drawable.list_group); broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); muteDrawable = getResources().getDrawable(R.drawable.mute_grey); - - updateTheme(); + verifiedDrawable = getResources().getDrawable(R.drawable.check_list); } setBackgroundResource(R.drawable.list_selector); @@ -289,6 +288,7 @@ public class DialogCell extends BaseCell { drawNameGroup = false; drawNameBroadcast = false; drawNameLock = false; + drawVerified = false; if (encryptedChat != null) { drawNameLock = true; @@ -309,6 +309,7 @@ public class DialogCell extends BaseCell { drawNameGroup = true; nameLockTop = AndroidUtilities.dp(17.5f); } + drawVerified = (chat.flags & TLRPC.CHAT_FLAG_IS_VERIFIED) != 0; if (!LocaleController.isRTL) { nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); @@ -390,7 +391,7 @@ public class DialogCell extends BaseCell { messageString = message.messageText; currentMessagePaint = messagePrintingPaint; } else { - if (chat != null && chat.id > 0) { + if (chat != null && chat.id > 0 && fromChat == null) { String name; if (message.isOutOwner()) { name = LocaleController.getString("FromYou", R.string.FromYou); @@ -567,12 +568,18 @@ public class DialogCell extends BaseCell { } } - if (dialogMuted) { + if (dialogMuted && !drawVerified) { int w = AndroidUtilities.dp(6) + muteDrawable.getIntrinsicWidth(); nameWidth -= w; if (LocaleController.isRTL) { nameLeft += w; } + } else if (drawVerified) { + int w = AndroidUtilities.dp(6) + verifiedDrawable.getIntrinsicWidth(); + nameWidth -= w; + if (LocaleController.isRTL) { + nameLeft += w; + } } nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth); @@ -647,8 +654,10 @@ public class DialogCell extends BaseCell { if (nameLayout != null && nameLayout.getLineCount() > 0) { left = nameLayout.getLineLeft(0); widthpx = Math.ceil(nameLayout.getLineWidth(0)); - if (dialogMuted) { + if (dialogMuted && !drawVerified) { nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - muteDrawable.getIntrinsicWidth()); + } else if (drawVerified) { + nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - verifiedDrawable.getIntrinsicWidth()); } if (left == 0) { if (widthpx < nameWidth) { @@ -674,7 +683,7 @@ public class DialogCell extends BaseCell { nameLeft -= (nameWidth - widthpx); } } - if (dialogMuted) { + if (dialogMuted || drawVerified) { nameMuteLeft = (int) (nameLeft + left + AndroidUtilities.dp(6)); } } @@ -877,6 +886,7 @@ public class DialogCell extends BaseCell { clockDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN); countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN); + countDrawableGrey.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN); nColor = themePrefs.getInt("chatsGroupIconColor", themePrefs.getInt("chatsGroupNameColor", 0xff000000)); groupDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN); @@ -951,21 +961,29 @@ public class DialogCell extends BaseCell { } } - if (dialogMuted) { + if (dialogMuted && !drawVerified) { setDrawableBounds(muteDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f)); muteDrawable.draw(canvas); + } else if (drawVerified) { + setDrawableBounds(verifiedDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f)); + verifiedDrawable.draw(canvas); } if (drawError) { setDrawableBounds(errorDrawable, errorLeft, errorTop); errorDrawable.draw(canvas); } else if (drawCount) { - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int size = themePrefs.getInt("chatsCountSize", 13); - size = size > 13 ? (size - 13) / 2 : 0; - //setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); - setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop + AndroidUtilities.dp(size), countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); - countDrawable.draw(canvas); + if (dialogMuted) { + setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); + countDrawableGrey.draw(canvas); + } else { + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int size = themePrefs.getInt("chatsCountSize", 13); + size = size > 13 ? (size - 13) / 2 : 0; + //setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); + setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop + AndroidUtilities.dp(size), countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); + countDrawable.draw(canvas); + } canvas.save(); canvas.translate(countLeft, countTop + AndroidUtilities.dp(4)); countLayout.draw(canvas); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java index cfe7acf1..9fd168e0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DividerCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java index ebddfa19..8e3d7239 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -17,6 +17,7 @@ import android.widget.FrameLayout; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.FileLog; import org.telegram.ui.Components.LayoutHelper; public class DrawerActionCell extends FrameLayout { @@ -36,7 +37,6 @@ public class DrawerActionCell extends FrameLayout { textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); textView.setCompoundDrawablePadding(AndroidUtilities.dp(34)); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 14, 0, 16, 0)); - //updateTheme(); } @Override @@ -49,9 +49,14 @@ public class DrawerActionCell extends FrameLayout { textView.setText(text); //textView.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0); int color = AndroidUtilities.getIntDef("drawerIconColor", 0xff737373); - Drawable d = getResources().getDrawable(resId); - d.setColorFilter(color, PorterDuff.Mode.SRC_IN); - textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); + try{ + Drawable d = getResources().getDrawable(resId); + d.setColorFilter(color, PorterDuff.Mode.SRC_IN); + textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); + } catch (Exception e) { + textView.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0); + FileLog.e("tmessages", e); + } } public void setTextAndIcon(String text, Drawable drawable) { 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 ba6e5649..7bd106cb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -260,7 +260,9 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV public void setPhotoChecked(int index) { } @Override - public void cancelButtonPressed() { } + public boolean cancelButtonPressed() { + return true; + } @Override public void sendButtonPressed(int index) { } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java index 0458b98f..30d0a42e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/EmptyCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java index 65aea734..d53f95f1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GreySectionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HashtagSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HashtagSearchCell.java index d8cfc706..bd0cb55e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HashtagSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HashtagSearchCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java index 404b5b24..cc541400 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/HeaderCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java index 2eee5ce4..d7f5005c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LetterSectionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java index 6da6b9db..6d8ba1d4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LoadingCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationCell.java index a3bbf7ed..548202dd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationLoadingCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationLoadingCell.java index dbed1458..84ab570d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationLoadingCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationLoadingCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationPoweredCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationPoweredCell.java index 3b3393f3..6b0b0677 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationPoweredCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/LocationPoweredCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 7674c25e..f952ae1a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/MentionCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java index afc6128b..8e16a1cc 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoEditToolCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java index 458ffa32..fc45e904 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; 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 cda365f6..620d2312 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerPhotoCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -13,6 +13,10 @@ import android.view.Gravity; import android.widget.FrameLayout; 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.R; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.CheckBox; @@ -23,6 +27,7 @@ public class PhotoPickerPhotoCell extends FrameLayout { public BackupImageView photoImage; public FrameLayout checkFrame; public CheckBox checkBox; + private AnimatorSetProxy animator; public int itemWidth; public PhotoPickerPhotoCell(Context context) { @@ -39,11 +44,44 @@ public class PhotoPickerPhotoCell extends FrameLayout { checkBox.setCheckOffset(AndroidUtilities.dp(1)); checkBox.setDrawBackground(true); checkBox.setColor(0xff3ccaef); - addView(checkBox, LayoutHelper.createFrame(30, 30, Gravity.RIGHT | Gravity.TOP, 0, 6, 6, 0)); + addView(checkBox, LayoutHelper.createFrame(30, 30, Gravity.RIGHT | Gravity.TOP, 0, 4, 4, 0)); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY)); } + + public void setChecked(final boolean checked, boolean animated) { + checkBox.setChecked(checked, animated); + if (animator != null) { + animator.cancel(); + animator = null; + } + if (animated) { + if (checked) { + setBackgroundColor(0xff0A0A0A); + } + animator = new AnimatorSetProxy(); + animator.playTogether(ObjectAnimatorProxy.ofFloat(photoImage, "scaleX", checked ? 0.85f : 1.0f), + ObjectAnimatorProxy.ofFloat(photoImage, "scaleY", checked ? 0.85f : 1.0f)); + animator.setDuration(200); + animator.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (animator.equals(animation)) { + animator = null; + if (!checked) { + setBackgroundColor(0); + } + } + } + }); + animator.start(); + } else { + setBackgroundColor(checked ? 0xff0A0A0A : 0); + ViewProxy.setScaleX(photoImage, checked ? 0.85f : 1.0f); + ViewProxy.setScaleY(photoImage, checked ? 0.85f : 1.0f); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java index 7a81c153..0b71286e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerSearchCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; 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 c147fdf9..8854a00f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -24,6 +24,7 @@ import android.view.MotionEvent; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.ChatObject; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; @@ -46,6 +47,7 @@ public class ProfileSearchCell extends BaseCell { private static Drawable broadcastDrawable; private static Drawable groupDrawable; private static Drawable countDrawable; + private static Drawable checkDrawable; private static Paint linePaint; private CharSequence currentName; @@ -81,6 +83,8 @@ public class ProfileSearchCell extends BaseCell { private int countWidth; private StaticLayout countLayout; + private boolean drawCheck; + private int onlineLeft; private StaticLayout onlineLayout; @@ -120,7 +124,7 @@ public class ProfileSearchCell extends BaseCell { lockDrawable = getResources().getDrawable(R.drawable.list_secret); groupDrawable = getResources().getDrawable(R.drawable.list_group); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); - + checkDrawable = getResources().getDrawable(R.drawable.check_list); updateTheme(); } @@ -132,11 +136,9 @@ public class ProfileSearchCell extends BaseCell { private void updateTheme(){ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); - countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13))); countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff)); countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN); - } @Override @@ -199,6 +201,7 @@ public class ProfileSearchCell extends BaseCell { drawNameBroadcast = false; drawNameLock = false; drawNameGroup = false; + drawCheck = false; if (encryptedChat != null) { drawNameLock = true; @@ -219,9 +222,15 @@ public class ProfileSearchCell extends BaseCell { nameLockTop = AndroidUtilities.dp(28.5f); } else { dialog_id = -chat.id; + if (ChatObject.isChannel(chat)) { + drawNameBroadcast = true; + nameLockTop = AndroidUtilities.dp(28.5f); + } else { drawNameGroup = true; nameLockTop = AndroidUtilities.dp(30); } + } + drawCheck = (chat.flags & TLRPC.CHAT_FLAG_IS_VERIFIED) != 0; if (!LocaleController.isRTL) { nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); @@ -504,6 +513,14 @@ public class ProfileSearchCell extends BaseCell { canvas.translate(nameLeft, nameTop); nameLayout.draw(canvas); canvas.restore(); + if (drawCheck) { + if (LocaleController.isRTL) { + setDrawableBounds(checkDrawable, nameLeft - AndroidUtilities.dp(4) - checkDrawable.getIntrinsicWidth(), nameLockTop); + } else { + setDrawableBounds(checkDrawable, nameLeft + (int) nameLayout.getLineWidth(0) + AndroidUtilities.dp(4), nameLockTop); + } + checkDrawable.draw(canvas); + } } if (onlineLayout != null) { 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 ab3b1eba..d6fe2833 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SendLocationCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java index 5c132453..2115f261 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SessionCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowBottomSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowBottomSectionCell.java index b7a4d0df..e391e8d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowBottomSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowBottomSectionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java index 52ac3f2e..6c6572a9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ShadowSectionCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -33,7 +33,7 @@ public class ShadowSectionCell extends View { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(12), MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(12), MeasureSpec.EXACTLY)); if(bTheme)setTheme(); } 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 65ea4745..870cf338 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -204,8 +204,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F loaded = false; loading = false; - //if (document != null && document.messageOwner.media != null) { - if (document != null && document.messageOwner.media != null && document.messageOwner.media.document != null) { //To try to fix NullPointerException: Attempt to read from field 'java.lang.String org.telegram.tgnet.TLRPC$Document.mime_type' on a null object reference + if (document != null && document.messageOwner.media != null && document.messageOwner.media.document != null) { int idx; String name = FileLoader.getDocumentFileName(document.messageOwner.media.document); placeholderImabeView.setVisibility(VISIBLE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java index 09495fc0..b4631b4d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedMediaSectionCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 7748c735..4ab37ad3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -19,6 +19,10 @@ import android.widget.LinearLayout; 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.AnimationCompat.ViewProxy; import org.telegram.messenger.MessageObject; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLoader; @@ -51,21 +55,26 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { private LinearLayout videoInfoContainer; private View selector; private CheckBox checkBox; + private FrameLayoutFixed container; + private AnimatorSetProxy animator; public PhotoVideoView(Context context) { super(context); + container = new FrameLayoutFixed(context); + addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); + imageView = new BackupImageView(context); imageView.getImageReceiver().setNeedsQualityThumb(true); imageView.getImageReceiver().setShouldGenerateQualityThumb(true); - addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); + container.addView(imageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); videoInfoContainer = new LinearLayout(context); videoInfoContainer.setOrientation(LinearLayout.HORIZONTAL); videoInfoContainer.setBackgroundResource(R.drawable.phototime); videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0); videoInfoContainer.setGravity(Gravity.CENTER_VERTICAL); - addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT)); + container.addView(videoInfoContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 16, Gravity.BOTTOM | Gravity.LEFT)); ImageView imageView1 = new ImageView(context); imageView1.setImageResource(R.drawable.ic_video); @@ -83,7 +92,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { checkBox = new CheckBox(context, R.drawable.round_check2); checkBox.setVisibility(INVISIBLE); - addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 6, 6, 0)); + addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 2, 2, 0)); } @Override @@ -93,6 +102,51 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { } return super.onTouchEvent(event); } + + public void setChecked(final boolean checked, boolean animated) { + if (checkBox.getVisibility() != VISIBLE) { + checkBox.setVisibility(VISIBLE); + } + checkBox.setChecked(checked, animated); + if (animator != null) { + animator.cancel(); + animator = null; + } + if (animated) { + if (checked) { + setBackgroundColor(0xfff5f5f5); + } + animator = new AnimatorSetProxy(); + animator.playTogether(ObjectAnimatorProxy.ofFloat(container, "scaleX", checked ? 0.85f : 1.0f), + ObjectAnimatorProxy.ofFloat(container, "scaleY", checked ? 0.85f : 1.0f)); + animator.setDuration(200); + animator.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (animator.equals(animation)) { + animator = null; + if (!checked) { + setBackgroundColor(0); + } + } + } + }); + animator.start(); + } else { + setBackgroundColor(checked ? 0xfff5f5f5 : 0); + ViewProxy.setScaleX(container, checked ? 0.85f : 1.0f); + ViewProxy.setScaleY(container, checked ? 0.85f : 1.0f); + } + } + + @Override + public void clearAnimation() { + super.clearAnimation(); + if (animator != null) { + animator.cancel(); + animator = null; + } + } } public SharedPhotoVideoCell(Context context) { @@ -134,6 +188,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { public void setItemsCount(int count) { for (int a = 0; a < photoVideoViews.length; a++) { + photoVideoViews[a].clearAnimation(); photoVideoViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE); } itemsCount = count; @@ -158,10 +213,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { } public void setChecked(int a, boolean checked, boolean animated) { - if (photoVideoViews[a].checkBox.getVisibility() != VISIBLE) { - photoVideoViews[a].checkBox.setVisibility(VISIBLE); - } - photoVideoViews[a].checkBox.setChecked(checked, animated); + photoVideoViews[a].setChecked(checked, animated); } public void setItem(int a, int index, MessageObject messageObject) { @@ -195,6 +247,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed { photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); } } else { + photoVideoViews[a].clearAnimation(); photoVideoViews[a].setVisibility(INVISIBLE); messageObjects[a] = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java index 5b4d57a5..af2d4baf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -45,7 +45,7 @@ public class StickerCell extends FrameLayoutFixed { } public void setSticker(TLRPC.Document document, int side) { - if (document != null) { + if (document != null && document.thumb != null) { imageView.setImage(document.thumb.location, null, "webp", null); } if (side == -1) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java index c6c8d941..d450fe34 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerEmojiCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -57,7 +57,9 @@ public class StickerEmojiCell extends FrameLayout { public void setSticker(TLRPC.Document document, boolean showEmoji) { if (document != null) { sticker = document; - imageView.setImage(document.thumb.location, null, "webp", null); + if (document.thumb != null) { + imageView.setImage(document.thumb.location, null, "webp", null); + } if (showEmoji) { boolean set = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextBlockCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextBlockCell.java index 082d38c0..3361937f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextBlockCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextBlockCell.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 4fb80447..ad5f4e05 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -64,7 +64,7 @@ public class TextCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, multiline ? MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED) : MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), multiline ? MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED) : MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY)); } public void setTextColor(int color) { 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 09374d77..7665d0fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java index 36b5c46d..975e7c04 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextColorCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -33,7 +33,7 @@ public class TextColorCell extends FrameLayout { private boolean needDivider; private int currentColor; - private Drawable colorDrawable; //no static + private Drawable colorDrawable; private static Paint paint; public TextColorCell(Context context) { @@ -43,10 +43,10 @@ public class TextColorCell extends FrameLayout { paint = new Paint(); paint.setColor(0xffd9d9d9); paint.setStrokeWidth(1); - - //colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2); } + colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2); + textView = new TextView(context); textView.setTextColor(0xff212121); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); @@ -57,7 +57,6 @@ public class TextColorCell extends FrameLayout { 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, 45, 0)); - colorDrawable = getResources().getDrawable(R.drawable.switch_to_on2); } @Override @@ -72,6 +71,7 @@ public class TextColorCell extends FrameLayout { currentColor = color; colorDrawable.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY)); setWillNotDraw(!needDivider && currentColor == 0); + invalidate(); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java index c666d7c5..dd728658 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -55,7 +55,7 @@ public class TextDetailCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), View.MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), View.MeasureSpec.EXACTLY)); } public void setTextAndValue(String text, String value) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java index e12a14d8..7b6da298 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java index 4a59dd80..47dff3d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -35,10 +35,6 @@ public class TextInfoCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); - //if( textView.getContext() instanceof LaunchActivity ){ - //textView.setTextColor(AndroidUtilities.getIntDef("drawerVersionColor", 0xffa3a3a3)); - //textView.setTextSize(AndroidUtilities.getIntDef("drawerVersionSize", 13)); - //} } public void setText(String text) { 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 a0bbde2a..b44a3437 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java index 9b4b96e5..57910d05 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; 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 ef2a9966..b1767146 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Cells; @@ -146,7 +146,7 @@ public class UserCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY)); + super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64), MeasureSpec.EXACTLY)); } public void setStatusColors(int color, int onlineColor) { @@ -226,8 +226,6 @@ public class UserCell extends FrameLayout { lastName = newName == null ? currentChat.title : newName; } nameTextView.setText(lastName); - ////nameTextView.setTextColor(nameColor); - ////nameTextView.setTextSize(themePrefs.getInt("contactsNameSize", 17)); } if (currrntStatus != null) { statusTextView.setTextColor(statusColor); @@ -269,6 +267,11 @@ public class UserCell extends FrameLayout { avatarImageView.setImage(photo, "50_50", avatarDrawable); } + @Override + public boolean hasOverlappingRendering() { + return false; + } + public void setNameColor(int color) { nameColor = color; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java index 0f9b1d2d..3302cb82 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -158,11 +158,14 @@ public class ChangeChatNameActivity extends BaseFragment { done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); } + @Override - public void onOpenAnimationEnd() { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { firstNameField.requestFocus(); AndroidUtilities.showKeyboard(firstNameField); } + } private void saveName() { MessagesController.getInstance().changeChatTitle(chat_id, firstNameField.getText().toString()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java index 26f14781..2c81b5f0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -206,8 +206,10 @@ public class ChangeNameActivity extends BaseFragment { } @Override - public void onOpenAnimationEnd() { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { firstNameField.requestFocus(); AndroidUtilities.showKeyboard(firstNameField); } } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java index b547176c..3b0fa7d7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -28,7 +28,6 @@ import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; import android.view.View; -import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; @@ -40,26 +39,26 @@ import android.widget.TextView; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MessagesController; -import org.telegram.messenger.MessagesStorage; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.BuildVars; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.R; -import org.telegram.tgnet.ConnectionsManager; -import org.telegram.tgnet.RequestDelegate; -import org.telegram.tgnet.TLObject; -import org.telegram.tgnet.TLRPC; -import org.telegram.messenger.UserConfig; -import org.telegram.ui.ActionBar.ActionBar; -import org.telegram.ui.ActionBar.ActionBarMenu; -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.messenger.BuildConfig; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.MessagesController; +import org.telegram.messenger.MessagesStorage; +import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.R; +import org.telegram.messenger.UserConfig; +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.ActionBar; +import org.telegram.ui.ActionBar.ActionBarMenu; +import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.SlideView; import org.telegram.ui.Components.TypefaceSpan; @@ -196,10 +195,11 @@ public class ChangePhoneActivity extends BaseFragment { } @Override - public void onOpenAnimationEnd() { - super.onOpenAnimationEnd(); + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { views[currentViewNum].onShow(); } + } public void needShowAlert(final String text) { if (text == null || getParentActivity() == null) { @@ -649,7 +649,7 @@ public class ChangePhoneActivity extends BaseFragment { if (countryState == 1) { needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); return; - } else if (countryState == 2 && !BuildVars.DEBUG_VERSION) { + } else if (countryState == 2 && !BuildConfig.DEBUG){//!BuildVars.DEBUG_VERSION) { needShowAlert(LocaleController.getString("WrongCountry", R.string.WrongCountry)); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java index 83d89690..904a1467 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java index 5de21409..a9cb7a23 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -406,8 +406,10 @@ public class ChangeUsernameActivity extends BaseFragment { } @Override - public void onOpenAnimationEnd() { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { firstNameField.requestFocus(); AndroidUtilities.showKeyboard(firstNameField); } } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 43fcf68d..d299d828 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1,13 +1,14 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; +import android.Manifest; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -93,6 +94,7 @@ import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; +import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.Adapters.MentionsAdapter; @@ -114,6 +116,8 @@ import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.ui.Components.ChatAttachView; import org.telegram.ui.Components.FrameLayoutFixed; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.NumberTextView; +import org.telegram.ui.Components.PlayerView; import org.telegram.ui.Components.RadioButton; import org.telegram.ui.Components.RecordStatusDrawable; import org.telegram.ui.Components.RecyclerListView; @@ -122,6 +126,7 @@ import org.telegram.ui.Components.SendingFileExDrawable; import org.telegram.ui.Components.SizeNotifierFrameLayout; import org.telegram.ui.Components.TimerDrawable; import org.telegram.ui.Components.TypingDotsDrawable; +import org.telegram.ui.Components.URLSpanBotCommand; import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanReplacement; import org.telegram.ui.Components.WebFrameLayout; @@ -176,7 +181,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private FrameLayout avatarContainer; private TextView bottomOverlayText; private TextView secretViewStatusTextView; - private TextView selectedMessagesCountTextView; + private NumberTextView selectedMessagesCountTextView; private RecyclerListView stickersListView; private StickersAdapter stickersAdapter; private FrameLayout stickersPanel; @@ -194,6 +199,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private LinearLayout reportSpamView; private TextView addToContactsButton; private TextView reportSpamButton; + private PlayerView playerView; + + private ObjectAnimatorProxy pagedownButtonAnimation; private TLRPC.User reportSpamUser; @@ -337,10 +345,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not RecyclerListView.OnItemLongClickListener onItemLongClickListener = new RecyclerListView.OnItemLongClickListener() { @Override - public void onItemClick(View view, int position) { + public boolean onItemClick(View view, int position) { if (!actionBar.isActionModeShowed()) { createMenu(view, false); + return true; } + return false; } }; @@ -545,14 +555,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + URLSpanBotCommand.enabled = false; if (userId != 0 && (currentUser.flags & TLRPC.USER_FLAG_BOT) != 0) { BotQuery.loadBotInfo(userId, true, classGuid); + URLSpanBotCommand.enabled = true; } else if (info instanceof TLRPC.TL_chatFull) { for (int a = 0; a < info.participants.participants.size(); a++) { TLRPC.TL_chatParticipant participant = info.participants.participants.get(a); TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) { BotQuery.loadBotInfo(user.id, true, classGuid); + URLSpanBotCommand.enabled = true; } } } @@ -667,22 +680,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ResourceLoader.loadRecources(context); - //actionBar.setBackButtonImage(R.drawable.ic_ab_back); - Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); + actionBar.setBackButtonDrawable(new BackDrawable(false)); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - back.setColorFilter(themePrefs.getInt("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); - actionBar.setBackButtonDrawable(back); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(final int id) { if (id == -1) { - finishFragment(); - } else if (id == -2) { + if (actionBar.isActionModeShowed()) { selectedMessagesIds.clear(); selectedMessagesCanCopyIds.clear(); - cantDeleteMessagesCount = 0; + cantDeleteMessagesCount = 0; actionBar.hideActionMode(); updateVisibleRows(); + } else { + finishFragment(); + } } else if (id == copy) { String str = ""; ArrayList ids = new ArrayList<>(selectedMessagesCanCopyIds.keySet()); @@ -758,7 +770,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not QuoteForward = false; } Bundle args = new Bundle(); - //args.putBoolean("quote", QuoteForward); args.putBoolean("onlySelect", true); args.putInt("dialogsType", 1); DialogsActivity fragment = new DialogsActivity(args); @@ -863,8 +874,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ArrayList photos = new ArrayList<>(); ArrayList captions = new ArrayList<>(); for (HashMap.Entry entry : selectedPhotos.entrySet()) { - photos.add(entry.getValue().path); - captions.add(""); + 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); @@ -934,6 +954,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not args.putInt("chat_id", currentChat.id); ProfileActivity fragment = new ProfileActivity(args); fragment.setChatInfo(info); + fragment.setPlayProfileAnimation(true); presentFragment(fragment); } else if (id == add_member) { //Plus openAddMember(); @@ -946,7 +967,7 @@ 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); - actionBar.addView(avatarContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 56, 0, 40, 0)); + 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() { @Override public void onClick(View v) { @@ -957,12 +978,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (currentEncryptedChat != null) { args.putLong("dialog_id", dialog_id); } - presentFragment(new ProfileActivity(args)); + 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 { @@ -1066,7 +1090,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not searchDownItem.setVisibility(View.GONE); highlightMessageId = Integer.MAX_VALUE; updateVisibleRows(); - scrollToLastMessage(); + scrollToLastMessage(false); } @Override @@ -1146,31 +1170,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateSubtitle(); updateTitleIcons(); - //attachItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_other).setOverrideMenuClick(true).setAllowCloseAnimation(false); - attachItem = menu.addItem(chat_menu_attach, dots).setOverrideMenuClick(true).setAllowCloseAnimation(false); - attachItem.setVisibility(View.GONE); + //attachItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_other).setOverrideMenuClick(true).setAllowCloseAnimation(false); + attachItem = menu.addItem(chat_menu_attach, dots).setOverrideMenuClick(true).setAllowCloseAnimation(false); + attachItem.setVisibility(View.GONE); - //menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach).setAllowCloseAnimation(false); - Drawable clip = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_attach_white); + //menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach).setAllowCloseAnimation(false); + Drawable clip = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_attach_white); clip.setColorFilter(themePrefs.getInt("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY); menuItem = menu.addItem(chat_menu_attach, clip).setAllowCloseAnimation(false); - menuItem.setBackgroundDrawable(null); + menuItem.setBackgroundDrawable(null); actionModeViews.clear(); final ActionBarMenu actionMode = actionBar.createActionMode(); - actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + //actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - selectedMessagesCountTextView = new TextView(actionMode.getContext()); + selectedMessagesCountTextView = new NumberTextView(actionMode.getContext()); selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); selectedMessagesCountTextView.setTextColor(0xff737373); - selectedMessagesCountTextView.setSingleLine(true); - selectedMessagesCountTextView.setLines(1); - selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); - selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2)); - selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); - actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f)); + actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 65, 0, 0, 0)); selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -1211,6 +1230,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int heightSize = MeasureSpec.getSize(heightMeasureSpec); setMeasuredDimension(widthSize, heightSize); + heightSize -= getPaddingTop(); int keyboardSize = getKeyboardHeight(); @@ -1286,7 +1306,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not switch (verticalGravity) { case Gravity.TOP: - childTop = lp.topMargin; + childTop = lp.topMargin + getPaddingTop(); break; case Gravity.CENTER_VERTICAL: childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin; @@ -1317,7 +1337,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not SizeNotifierFrameLayout contentView = (SizeNotifierFrameLayout) fragmentView; //contentView.setBackgroundImage(ApplicationLoader.getCachedWallpaper()); updateBackground(contentView); - //.e("mainColor 0", "" + ApplicationLoader.getCachedWallpaper()); emptyViewContainer = new FrameLayout(context); emptyViewContainer.setVisibility(View.INVISIBLE); contentView.addView(emptyViewContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); @@ -1466,22 +1485,18 @@ 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 <= 10) { - if (!endReached && !loading) { + if (firstVisibleItem <= 25 && !endReached && !loading) { if (messagesByDays.size() != 0) { - MessagesController.getInstance().loadMessages(dialog_id, 20, maxMessageId, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); + MessagesController.getInstance().loadMessages(dialog_id, 50, maxMessageId, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); } else { - MessagesController.getInstance().loadMessages(dialog_id, 20, 0, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); + MessagesController.getInstance().loadMessages(dialog_id, 50, 0, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); } loading = true; } - } - if (firstVisibleItem + visibleItemCount >= totalItemCount - 6) { - if (!forward_end_reached && !loadingForward) { - MessagesController.getInstance().loadMessages(dialog_id, 20, minMessageId, !cacheEndReached, maxDate, classGuid, 1, 0, channelMessagesImportant); + if (!forward_end_reached && !loadingForward && firstVisibleItem + visibleItemCount >= totalItemCount - 10) { + MessagesController.getInstance().loadMessages(dialog_id, 50, minMessageId, !cacheEndReached, maxDate, classGuid, 1, 0, channelMessagesImportant); loadingForward = true; } - } if (firstVisibleItem + visibleItemCount == totalItemCount && forward_end_reached) { showPagedownButton(false, true); } @@ -1531,6 +1546,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AndroidUtilities.cancelRunOnUIThread(openSecretPhotoRunnable); openSecretPhotoRunnable = null; } + chatListView.setOnItemClickListener(onItemClickListener); + chatListView.setOnItemLongClickListener(onItemLongClickListener); + chatListView.setLongClickable(true); } } } @@ -1629,7 +1647,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not reportSpamButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - if (reportSpamUser == null) { + if (reportSpamUser == null || getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); @@ -1642,6 +1660,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { + if (reportSpamUser == null) { + return; + } TLRPC.TL_messages_reportSpam req = new TLRPC.TL_messages_reportSpam(); req.peer = new TLRPC.TL_inputPeerUser(); req.peer.user_id = reportSpamUser.id; @@ -1828,12 +1849,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); } + pagedownButton = new ImageView(context); + pagedownButton.setVisibility(View.INVISIBLE); + pagedownButton.setImageResource(R.drawable.pagedown); + contentView.addView(pagedownButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 4)); + pagedownButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + if (returnToMessageId > 0) { + scrollToMessageId(returnToMessageId, 0, true); + } else { + scrollToLastMessage(true); + } + } + }); + chatActivityEnterView = new ChatActivityEnterView(getParentActivity(), contentView, this, true); chatActivityEnterView.setDialogId(dialog_id); chatActivityEnterView.addToAttachLayout(menuItem); chatActivityEnterView.setId(id_chat_compose_panel); chatActivityEnterView.setBotsCount(botsCount, hasBotsCommands); - contentView.addView(chatActivityEnterView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); + contentView.addView(chatActivityEnterView, contentView.getChildCount() - 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { @Override public void onMessageSend(String message) { @@ -2148,21 +2184,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not bottomOverlayChatText.setTextColor(0xff3e6fa1); bottomOverlayChat.addView(bottomOverlayChatText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); - pagedownButton = new ImageView(context); - pagedownButton.setVisibility(View.INVISIBLE); - pagedownButton.setImageResource(R.drawable.pagedown); - contentView.addView(pagedownButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 4)); - pagedownButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (returnToMessageId > 0) { - scrollToMessageId(returnToMessageId, 0, true); - } else { - scrollToLastMessage(); - } - } - }); - if (loading && messages.isEmpty()) { progressView.setVisibility(View.VISIBLE); chatListView.setEmptyView(null); @@ -2173,6 +2194,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatActivityEnterView.setButtons(botButtons); + if (!AndroidUtilities.isTablet() || AndroidUtilities.isSmallTablet()) { + contentView.addView(playerView = new PlayerView(context, this), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); + } + updateContactStatus(); updateBottomOverlay(); updateSecretStatus(); @@ -2311,6 +2336,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FileLog.e("tmessages", e); } } else if (which == attach_gallery) { + if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); + return; + } PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, ChatActivity.this); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override @@ -2351,41 +2380,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } }); presentFragment(fragment); - } /*else if (which == attach_sticker) { - PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, ChatActivity.this); - fragment.imageFilter = ".webp"; - fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { - @Override - public void didSelectPhotos(ArrayList photos, ArrayList captions, ArrayList webPhotos) { - SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject, captions); - SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject); - showReplyPanel(false, null, null, null, false, true); - } - - @Override - public void startPhotoSelectActivity() { - try { - Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); - startActivityForResult(photoPickerIntent, 40); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - } - - @Override - public boolean didSelectVideo(String path) { - if (Build.VERSION.SDK_INT >= 16) { - return !openVideoEditor(path, true, true); - } else { - SendMessagesHelper.prepareSendingVideo(path, 0, 0, 0, 0, null, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); - showReplyPanel(false, null, null, null, false, true); - return true; - } - } - }); - presentFragment(fragment); - // - }*/ else if (which == attach_video) { + } else if (which == attach_video) { try { Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); File video = AndroidUtilities.generateVideoPath(); @@ -2418,6 +2413,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); presentFragment(fragment); } else if (which == attach_document) { + if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); + return; + } DocumentSelectActivity fragment = new DocumentSelectActivity(); fragment.setDelegate(new DocumentSelectActivity.DocumentSelectActivityDelegate() { @Override @@ -2440,6 +2439,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); presentFragment(fragment); } else if (which == attach_audio) { + if (Build.VERSION.SDK_INT >= 23 && getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); + return; + } AudioSelectActivity fragment = new AudioSelectActivity(); fragment.setDelegate(new AudioSelectActivity.AudioSelectActivityDelegate() { @Override @@ -2450,6 +2453,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); presentFragment(fragment); } else if (which == attach_contact) { + if (Build.VERSION.SDK_INT >= 23) { + if (getParentActivity().checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { + getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, 5); + return; + } + } try { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.setType(ContactsContract.CommonDataKinds.Phone.CONTENT_TYPE); @@ -2460,6 +2469,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + @Override + public boolean dismissDialogOnPause(Dialog dialog) { + return !(dialog == chatAttachViewSheet && PhotoViewer.getInstance().isVisible()) && super.dismissDialogOnPause(dialog); + } + private void searchLinks(CharSequence charSequence, boolean force) { if (currentEncryptedChat != null) { return; @@ -2576,10 +2590,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } name = chat.title; } + forwardingMessages = null; replyingMessageObject = messageObject; chatActivityEnterView.setReplyingMessageObject(messageObject); - if (foundWebPage != null) { return; } @@ -2839,9 +2853,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatAdapter.notifyDataSetChanged(); } - private void scrollToLastMessage() { + private void scrollToLastMessage(boolean pagedown) { if (forward_end_reached && first_unread_id == 0 && startLoadFromMessageId == 0) { - chatLayoutManager.scrollToPositionWithOffset(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + if (pagedown && chatLayoutManager.findLastCompletelyVisibleItemPosition() == chatAdapter.getItemCount() - 1) { + showPagedownButton(false, true); + highlightMessageId = Integer.MAX_VALUE; + updateVisibleRows(); + } else { + chatLayoutManager.scrollToPositionWithOffset(messages.size() - 1, -100000 - chatListView.getPaddingTop()); + } } else { clearChatData(); MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReached, 0, classGuid, 0, 0, channelMessagesImportant); @@ -2918,7 +2938,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not chatLayoutManager.scrollToPositionWithOffset(messages.size() - messages.indexOf(object), -chatListView.getPaddingTop() - AndroidUtilities.dp(7) + yOffset); } updateVisibleRows(); - showPagedownButton(true, true); + boolean found = false; + int count = chatListView.getChildCount(); + for (int a = 0; a < count; a++) { + View view = chatListView.getChildAt(a); + if (view instanceof ChatBaseCell) { + ChatBaseCell cell = (ChatBaseCell) view; + if (cell.getMessageObject() != null && cell.getMessageObject().getId() == object.getId()) { + found = true; + break; + } + } else if (view instanceof ChatActionCell) { + ChatActionCell cell = (ChatActionCell) view; + if (cell.getMessageObject() != null && cell.getMessageObject().getId() == object.getId()) { + found = true; + break; + } + } + } + if (!found) { + showPagedownButton(true, true); + } } else { query = true; } @@ -2969,26 +3009,40 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } if (show) { - if (pagedownButton.getVisibility() == View.INVISIBLE) { + if (pagedownButton.getTag() == null) { + if (pagedownButtonAnimation != null) { + pagedownButtonAnimation.cancel(); + pagedownButtonAnimation = null; + } if (animated) { + if (ViewProxy.getTranslationY(pagedownButton) == 0) { + ViewProxy.setTranslationY(pagedownButton, AndroidUtilities.dp(100)); + } pagedownButton.setVisibility(View.VISIBLE); - ViewProxy.setAlpha(pagedownButton, 0); - ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 1.0f).setDuration(200).start(); + pagedownButton.setTag(1); + pagedownButtonAnimation = ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "translationY", 0).setDuration(200).start(); } else { pagedownButton.setVisibility(View.VISIBLE); } } } else { returnToMessageId = 0; - if (pagedownButton.getVisibility() == View.VISIBLE) { + if (pagedownButton.getTag() != null) { + pagedownButton.setTag(null); + if (pagedownButtonAnimation != null) { + pagedownButtonAnimation.cancel(); + pagedownButtonAnimation = null; + } if (animated) { - ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "alpha", 0.0f).setDuration(200).addListener(new AnimatorListenerAdapterProxy() { + pagedownButtonAnimation = ObjectAnimatorProxy.ofFloatProxy(pagedownButton, "translationY", AndroidUtilities.dp(100)).setDuration(200).addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { + pagedownButton.clearAnimation(); pagedownButton.setVisibility(View.INVISIBLE); } }).start(); } else { + pagedownButton.clearAnimation(); pagedownButton.setVisibility(View.INVISIBLE); } } @@ -3065,10 +3119,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private int updateOnlineCount() { + onlineCount = 0; if (!(info instanceof TLRPC.TL_chatFull)) { return 0; } - onlineCount = 0; int currentTime = ConnectionsManager.getInstance().getCurrentTime(); for (TLRPC.TL_chatParticipant participant : info.participants.participants) { TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); @@ -3230,7 +3284,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (actionBar.isActionModeShowed()) { if (selectedMessagesIds.isEmpty()) { actionBar.hideActionMode(); - } + } else { actionBar.createActionMode().getItem(copy).setVisibility(selectedMessagesCanCopyIds.size() != 0 ? View.VISIBLE : View.GONE); actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); if (actionBar.createActionMode().getItem(reply) != null) { @@ -3242,6 +3296,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } + } private void processRowSelect(View view) { MessageObject message = null; @@ -3266,7 +3321,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } if (!selectedMessagesIds.isEmpty()) { - selectedMessagesCountTextView.setText(String.format("%d", selectedMessagesIds.size())); + selectedMessagesCountTextView.setNumber(selectedMessagesIds.size(), true); } } @@ -3419,7 +3474,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not lastStatus = newStatus; onlineTextView.setText(newStatus); } - if(newStatus.equals(LocaleController.getString("Online", R.string.Online))){ onlineTextView.setTextColor(themePrefs.getInt("chatOnlineColor", themePrefs.getInt("chatStatusColor", lightColor))); } @@ -3738,30 +3792,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not FileLog.e("tmessages", e); } } - } /*else if (requestCode == 32) { - if (data == null || data.getData() == null) { - showAttachmentError(); - return; - } - Uri uri = data.getData(); - String path = AndroidUtilities.getPath(uri); - if (path != null) { - TLRPC.TL_audio audio = new TLRPC.TL_audio(); - audio.dc_id = Integer.MIN_VALUE; - audio.id = Integer.MIN_VALUE; - audio.user_id = UserConfig.getClientUserId(); - audio.mime_type = "audio/mp3"; - SendMessagesHelper.getInstance().sendMessage(audio, path, dialog_id, replyingMessageObject, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); - showReplyPanel(false, null, null, null, false, true); - } - } else if (requestCode == 40) { //attach_sticker - if (data == null || data.getData() == null) { - showAttachmentError(); - return; - } - SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject, null, chatActivityEnterView == null || chatActivityEnterView.asAdmin()); - showReplyPanel(false, null, null, null, false, true); - }*/ + } } } @@ -3862,13 +3893,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not Collections.reverse(messArr); } ReplyMessageQuery.loadReplyMessagesForMessages(messArr, dialog_id); - for (int a = 0; a < messArr.size(); a++) { MessageObject obj = messArr.get(a); if (messagesDict.containsKey(obj.getId())) { continue; } - if (obj.getId() > 0) { maxMessageId = Math.min(obj.getId(), maxMessageId); minMessageId = Math.max(obj.getId(), minMessageId); @@ -3998,11 +4027,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not newRowsCount--; } if (newRowsCount != 0) { + int firstVisPos = chatLayoutManager.findLastVisibleItemPosition(); + int top = 0; + if (firstVisPos != chatLayoutManager.getItemCount() - 1) { + firstVisPos = RecyclerView.NO_POSITION; + } else { + View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); + top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); + } chatAdapter.notifyItemRangeInserted(chatAdapter.getItemCount() - 1, newRowsCount); + if (firstVisPos != RecyclerView.NO_POSITION) { + chatLayoutManager.scrollToPositionWithOffset(firstVisPos, top); + } } loadingForward = false; } else { - if (messArr.size() < count) { + if (messArr.size() < count && load_type != 3) { if (isCache) { if (currentEncryptedChat != null || isBroadcast) { endReached = true; @@ -4053,7 +4093,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); if (newRowsCount - (endReached ? 1 : 0) > 0) { - chatAdapter.notifyItemRangeInserted((chatAdapter.isBot ? 2 : 1), newRowsCount - (endReached ? 1 : 0)); + chatAdapter.notifyItemRangeInserted((chatAdapter.isBot ? 2 : 1) + (endReached ? 0 : 1), newRowsCount - (endReached ? 1 : 0)); } chatLayoutManager.scrollToPositionWithOffset(firstVisPos + newRowsCount - (endReached ? 1 : 0), top); } else if (endReached) { @@ -4100,8 +4140,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateBottomOverlay(); } - if (progressView != null) { - progressView.setVisibility(View.INVISIBLE); + if (newRowsCount == 0 && currentEncryptedChat != null && !endReached) { + first = true; + chatListView.setEmptyView(null); + emptyViewContainer.setVisibility(View.INVISIBLE); + if (messagesByDays.size() != 0) { + MessagesController.getInstance().loadMessages(dialog_id, 50, maxMessageId, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); + } else { + MessagesController.getInstance().loadMessages(dialog_id, 50, 0, !cacheEndReached, minDate, classGuid, 0, 0, channelMessagesImportant); + } + loading = true; + } else { + if (progressView != null) { + progressView.setVisibility(View.INVISIBLE); + } } } } else if (id == NotificationCenter.emojiDidLoaded) { @@ -4195,7 +4247,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not timerDrawable.setTime(action.ttl_seconds); } if (obj.isOut() && obj.isSending()) { - scrollToLastMessage(); + scrollToLastMessage(false); return; } if (messagesDict.containsKey(obj.getId())) { @@ -4505,27 +4557,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject obj = messagesDict.get(msgId); if (obj != null) { Integer newMsgId = (Integer) args[1]; - 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()); - } catch (Exception e) { //TODO - FileLog.e("tmessages", e); - } - if (newMsgObj != null) { - obj.messageOwner.media = newMsgObj.media; - obj.generateThumbs(true); - } - int oldCount = messagesDict.size(); + if (!newMsgId.equals(msgId) && messagesDict.containsKey(newMsgId)) { MessageObject removed = messagesDict.remove(msgId); - messagesDict.put(newMsgId, obj); - obj.messageOwner.id = newMsgId; - obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - ArrayList messArr = new ArrayList<>(); - messArr.add(obj); - ReplyMessageQuery.loadReplyMessagesForMessages(messArr, dialog_id); - updateVisibleRows(); - if (oldCount != messagesDict.size()) { + if (removed != null) { int index = messages.indexOf(removed); messages.remove(index); ArrayList dayArr = messagesByDays.get(removed.dateKey); @@ -4537,6 +4571,29 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } chatAdapter.notifyDataSetChanged(); + } + return; + } + 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()); + } catch (Exception e) { //TODO + FileLog.e("tmessages", e); + } + if (newMsgObj != null) { + obj.messageOwner.media = newMsgObj.media; + obj.generateThumbs(true); + } + messagesDict.remove(msgId); + messagesDict.put(newMsgId, obj); + obj.messageOwner.id = newMsgId; + obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; + ArrayList messArr = new ArrayList<>(); + messArr.add(obj); + ReplyMessageQuery.loadReplyMessagesForMessages(messArr, dialog_id); + if (chatAdapter != null) { + chatAdapter.updateRowWithMessageObject(obj); } if (mediaUpdated && chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - 1) { moveScrollToLastMessage(); @@ -4548,7 +4605,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject obj = messagesDict.get(msgId); if (obj != null) { obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; - updateVisibleRows(); + if (chatAdapter != null) { + chatAdapter.updateRowWithMessageObject(obj); + } } } else if (id == NotificationCenter.messageSendError) { Integer msgId = (Integer) args[0]; @@ -4573,14 +4632,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not hasBotsCommands = false; botInfo.clear(); botsCount = 0; + URLSpanBotCommand.enabled = false; for (int a = 0; a < info.participants.participants.size(); a++) { TLRPC.TL_chatParticipant participant = info.participants.participants.get(a); TLRPC.User user = MessagesController.getInstance().getUser(participant.user_id); if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) { + URLSpanBotCommand.enabled = true; botsCount++; BotQuery.loadBotInfo(user.id, true, classGuid); } } + if (chatListView != null) { + chatListView.invalidateViews(); + } } if (chatActivityEnterView != null) { chatActivityEnterView.setBotsCount(botsCount, hasBotsCommands); @@ -4637,22 +4701,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateVisibleRows(); } } else if (id == NotificationCenter.audioDidReset || id == NotificationCenter.audioPlayStateChanged) { - Integer mid = (Integer) args[0]; if (chatListView != null) { 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.getMessageObject().getId() == mid) { + if (cell.getMessageObject() != null) { cell.updateButtonState(false); - break; } } else if (view instanceof ChatMusicCell) { ChatMusicCell cell = (ChatMusicCell) view; - if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) { + if (cell.getMessageObject() != null) { cell.updateButtonState(false); - break; } } } @@ -4788,15 +4849,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not View view = chatListView.getChildAt(a); if (view instanceof ChatAudioCell) { ChatAudioCell cell = (ChatAudioCell) view; - if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) { + if (cell.getMessageObject() != null) { cell.updateButtonState(false); - break; } } else if (view instanceof ChatMusicCell) { ChatMusicCell cell = (ChatMusicCell) view; - if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) { + if (cell.getMessageObject() != null) { cell.updateButtonState(false); - break; } } } @@ -4832,7 +4891,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } } - if (changed) { + if (changed && chatLayoutManager != null) { if (mediaUpdated && chatLayoutManager.findLastVisibleItemPosition() >= messages.size() - (chatAdapter.isBot ? 2 : 1)) { moveScrollToLastMessage(); } @@ -4986,13 +5045,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } @Override - protected void onOpenAnimationStart() { + public void onTransitionAnimationStart(boolean isOpen, boolean backward) { + if (isOpen) { NotificationCenter.getInstance().setAnimationInProgress(true); openAnimationEnded = false; } + } @Override - protected void onOpenAnimationEnd() { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { NotificationCenter.getInstance().setAnimationInProgress(false); openAnimationEnded = true; int count = chatListView.getChildCount(); @@ -5008,6 +5070,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessagesController.getInstance().loadFullUser(MessagesController.getInstance().getUser(currentUser.id), classGuid); } } + } @Override protected void onDialogDismiss(Dialog dialog) { @@ -5237,6 +5300,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (lastMessageText != null) { preferences.edit().remove("dialog_" + dialog_id).commit(); chatActivityEnterView.setFieldText(lastMessageText); + if (getArguments().getBoolean("hasUrl", false)) { + chatActivityEnterView.setSelection(lastMessageText.indexOf('\n') + 1); + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (chatActivityEnterView != null) { + chatActivityEnterView.setFieldFocused(true); + chatActivityEnterView.openKeyboard(); + } + } + }, 700); + } } } else { preferences.edit().remove("dialog_" + dialog_id).commit(); @@ -5434,40 +5509,38 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { selectedMessagesCountTextView.setTextSize(20); } - if (AndroidUtilities.isTablet()) { - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int color = themePrefs.getInt("chatHeaderIconsColor", 0xffffffff); - if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { - //actionBar.setBackButtonImage(R.drawable.ic_ab_back); - Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); - if(back != null) { - back.setColorFilter(color, PorterDuff.Mode.MULTIPLY); - actionBar.setBackButtonDrawable(back); - } - } else { - //actionBar.setBackButtonImage(R.drawable.ic_close_white); - Drawable close = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white); - if(close != null) { - close.setColorFilter(color, PorterDuff.Mode.MULTIPLY); - actionBar.setBackButtonDrawable(close); - } - } - } + int padding = (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2; avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams(); layoutParams.topMargin = (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0); avatarContainer.setLayoutParams(layoutParams); - if (!resume) { - int firstVisPos = chatLayoutManager.findLastVisibleItemPosition(); - if (firstVisPos == RecyclerView.NO_POSITION) { - firstVisPos = 0; + if (AndroidUtilities.isTablet()) { + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int color = themePrefs.getInt("chatHeaderIconsColor", 0xffffffff); + if (AndroidUtilities.isSmallTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { + actionBar.setBackButtonDrawable(new BackDrawable(false)); + + /*Drawable back = context.getResources().getDrawable(R.drawable.ic_ab_back); + back.setColorFilter(color, PorterDuff.Mode.MULTIPLY); + actionBar.setBackButtonDrawable(back);*/ + + 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)); + + /*Drawable close = context.getResources().getDrawable(R.drawable.ic_ab_back); + close.setColorFilter(color, PorterDuff.Mode.MULTIPLY); + actionBar.setBackButtonDrawable(close);*/ + + if (playerView != null && playerView.getParent() != null) { + fragmentView.setPadding(0, 0, 0, 0); + ((ViewGroup) fragmentView).removeView(playerView); + } } - View firstVisView = chatListView.getChildAt(chatListView.getChildCount() - 1); - int top = ((firstVisView == null) ? 0 : firstVisView.getTop()) - chatListView.getPaddingTop(); - chatListView.setAdapter(null); - chatListView.setAdapter(chatAdapter); - chatLayoutManager.scrollToPositionWithOffset(firstVisPos, top); + return false; } return true; } @@ -5723,19 +5796,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not for (int a = 0; a < actionModeViews.size(); a++) { View view = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view); - if (a < 1) { - animators.add(ObjectAnimatorProxy.ofFloat(view, "translationX", -AndroidUtilities.dp(56), 0)); - } else { animators.add(ObjectAnimatorProxy.ofFloat(view, "scaleY", 0.1f, 1.0f)); } - } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); } addToSelectedMessages(message); - updateActionModeTitle(); + selectedMessagesCountTextView.setNumber(1, false); updateVisibleRows(); } @@ -5808,10 +5877,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (path == null || path.length() == 0) { path = FileLoader.getPathToMessage(selectedObject.messageOwner).toString(); } - if (selectedObject.type == 3) { - MediaController.saveFile(path, getParentActivity(), 1, null); - } else if (selectedObject.type == 1) { - MediaController.saveFile(path, getParentActivity(), 0, null); + 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); + return; + } + MediaController.saveFile(path, getParentActivity(), selectedObject.type == 3 ? 1 : 0, null); } else if (selectedObject.type == 8 || selectedObject.type == 9 || selectedObject.type == 14) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(selectedObject.messageOwner.media.document.mime_type); @@ -5902,6 +5973,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(path))); getParentActivity().startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareFile", R.string.ShareFile)), 500); } else { + 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); + return; + } MediaController.saveFile(path, getParentActivity(), 0, null); } } @@ -5949,6 +6024,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } 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); + return; + } String fileName = FileLoader.getDocumentFileName(selectedObject.messageOwner.media.document); if (fileName == null || fileName.length() == 0) { fileName = selectedObject.getFileName(); @@ -6202,7 +6281,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } @Override - public void cancelButtonPressed() { + public boolean cancelButtonPressed() { + return true; } @Override @@ -6315,7 +6395,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not fragment.setSearchString(url); presentFragment(fragment); } else if (url.startsWith("/")) { - chatActivityEnterView.setCommand(null, url); + chatActivityEnterView.setCommand(null, url, false); } } }); @@ -6324,6 +6404,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (view instanceof ChatBaseCell) { + if (currentEncryptedChat == null) { + ((ChatBaseCell) view).setAllowAssistant(true); + } ((ChatBaseCell) view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() { @Override public void didPressedChannelAvatar(ChatBaseCell cell, TLRPC.Chat chat) { @@ -6347,7 +6430,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (user != null && user.id != UserConfig.getClientUserId()) { Bundle args = new Bundle(); args.putInt("user_id", user.id); - presentFragment(new ProfileActivity(args)); + ProfileActivity fragment = new ProfileActivity(args); + fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == user.id); + presentFragment(fragment); } } @@ -6370,7 +6455,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } @Override - public void didPressUrl(MessageObject messageObject, final ClickableSpan url) { + public void didPressUrl(MessageObject messageObject, final ClickableSpan url, boolean longPress) { if (url instanceof URLSpanNoUnderline) { String str = ((URLSpanNoUnderline) url).getURL(); if (str.startsWith("@")) { @@ -6384,21 +6469,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not presentFragment(fragment); } } else if (str.startsWith("/")) { - chatActivityEnterView.setCommand(messageObject, str); - //Plus: Confirm before send - /*final MessageObject msg = messageObject; - final String cmd = str; - AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); - builder.setMessage(str); - builder.setTitle(LocaleController.getString("Send", R.string.Send)); - builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialogInterface, int i) { - chatActivityEnterView.setCommand(msg, cmd); - } - }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); - showDialog(builder.create());*/ + if (URLSpanBotCommand.enabled) { + chatActivityEnterView.setCommand(messageObject, str, longPress); + } } } else if (url instanceof URLSpanReplacement) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); @@ -6618,7 +6691,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (uid != UserConfig.getClientUserId()) { Bundle args = new Bundle(); args.putInt("user_id", uid); - presentFragment(new ProfileActivity(args)); + if (currentEncryptedChat != null && uid == currentUser.id) { + args.putLong("dialog_id", dialog_id); + } + ProfileActivity fragment = new ProfileActivity(args); + fragment.setPlayProfileAnimation(currentUser != null && currentUser.id == uid); + presentFragment(fragment); } } }); @@ -6768,6 +6846,5 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not updateRows(); super.notifyItemRangeRemoved(positionStart, itemCount); } - } -} + } 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 afaff465..03a2daae 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; @@ -11,6 +11,7 @@ package org.telegram.ui.Components; import android.graphics.Canvas; import android.graphics.ColorFilter; import android.graphics.Paint; +import android.graphics.PixelFormat; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; @@ -20,11 +21,11 @@ import android.text.StaticLayout; import android.text.TextPaint; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; -import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; -import org.telegram.messenger.ApplicationLoader; +import org.telegram.tgnet.TLRPC; import java.util.Locale; @@ -33,8 +34,8 @@ public class AvatarDrawable extends Drawable { private static Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); private static TextPaint namePaint; private static TextPaint namePaintSmall; - private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xffeec764, 0xff76c84d, 0xff5fbed5, 0xff549cdd, 0xff8e85ee, 0xfff2749a}; - private static int[] arrColorsProfiles = {0xffd86f65, 0xfff69d61, 0xfffabb3c, 0xff67b35d, 0xff56a2bb, 0xff5c98cd, 0xff8c79d2, 0xfff37fa6}; + private static int[] arrColors = {0xffe56555, 0xfff28c48, 0xff549cdd, 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[] arrColorsNames = {0xffca5650, 0xffd87b29, 0xff4e92cc, 0xff50b232, 0xff42b1a8, 0xff4e92cc, 0xff4e92cc, 0xff4e92cc}; @@ -342,7 +343,7 @@ public class AvatarDrawable extends Drawable { @Override public int getOpacity() { - return 0; + return PixelFormat.TRANSPARENT; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java index abda6c20..d740dfa5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java @@ -1,18 +1,21 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; +import android.Manifest; import android.app.Activity; import android.content.Intent; +import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.media.ExifInterface; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.provider.MediaStore; @@ -73,6 +76,12 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg } public void openGallery() { + if (Build.VERSION.SDK_INT >= 23 && parentFragment != null && parentFragment.getParentActivity() != null) { + if (parentFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + parentFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4); + return; + } + } PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(true, null); fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() { @Override @@ -179,6 +188,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg } smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false); bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320); + bitmap.recycle(); if (bigPhoto != null && smallPhoto != null) { if (returnOnly) { if (delegate != null) { @@ -195,7 +205,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg } @Override - public void didFinishEdit(Bitmap bitmap, Bundle args) { + public void didFinishEdit(Bitmap bitmap) { processBitmap(bitmap); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java index 4ff18a9b..dc1e5f8a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 e74d7b44..fd47b599 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -1,20 +1,25 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; +import android.Manifest; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.graphics.Canvas; +import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; import android.media.AudioManager; +import android.os.Build; import android.os.PowerManager; import android.text.Editable; import android.text.TextWatcher; @@ -25,7 +30,8 @@ import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.view.animation.AccelerateDecelerateInterpolator; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.FrameLayout; @@ -35,26 +41,26 @@ import android.widget.PopupWindow; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ChatObject; +import org.telegram.messenger.Emoji; +import org.telegram.messenger.LocaleController; +import org.telegram.messenger.MediaController; +import org.telegram.messenger.MessageObject; +import org.telegram.messenger.MessagesController; +import org.telegram.messenger.SendMessagesHelper; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.NotificationCenter; +import org.telegram.messenger.R; +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.messenger.ChatObject; -import org.telegram.messenger.Emoji; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.LocaleController; -import org.telegram.messenger.MediaController; -import org.telegram.messenger.MessageObject; -import org.telegram.messenger.MessagesController; -import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.R; -import org.telegram.messenger.SendMessagesHelper; -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.BaseFragment; import java.util.Locale; @@ -77,6 +83,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private ImageView audioSendButton; private FrameLayout recordPanel; private LinearLayout slideText; + private RecordDot recordDot; private SizeNotifierFrameLayout sizeNotifierLayout; private LinearLayout attachButton; private ImageView botButton; @@ -85,6 +92,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private PopupWindow botKeyboardPopup; private BotKeyboardView botKeyboardView; private ImageView asAdminButton; + private RecordCircle recordCircle; private int currentPopupContentType = -1; @@ -102,7 +110,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat private PowerManager.WakeLock mWakeLock; private AnimatorSetProxy runningAnimation; private AnimatorSetProxy runningAnimation2; - private ObjectAnimatorProxy runningAnimationAudio; + private AnimatorSetProxy runningAnimationAudio; private int runningAnimationType; private int audioInterfaceState; @@ -152,6 +160,124 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } }; + private class RecordDot extends View { + + private Drawable dotDrawable; + private float alpha; + private long lastUpdateTime; + private boolean isIncr; + + public RecordDot(Context context) { + super(context); + + dotDrawable = getResources().getDrawable(R.drawable.rec); + } + + public void resetAlpha() { + alpha = 1.0f; + lastUpdateTime = System.currentTimeMillis(); + isIncr = false; + invalidate(); + } + + @Override + protected void onDraw(Canvas canvas) { + dotDrawable.setBounds(0, 0, AndroidUtilities.dp(11), AndroidUtilities.dp(11)); + dotDrawable.setAlpha(185 + (int) (70 * alpha)); + long dt = (System.currentTimeMillis() - lastUpdateTime); + if (!isIncr) { + alpha -= dt / 200.0f; + if (alpha <= 0) { + alpha = 0; + isIncr = true; + } + } else { + alpha += dt / 200.0f; + if (alpha >= 1) { + alpha = 1; + isIncr = false; + } + } + lastUpdateTime = System.currentTimeMillis(); + dotDrawable.draw(canvas); + invalidate(); + } + } + + private class RecordCircle extends View { + + private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + private Paint paintRecord = new Paint(Paint.ANTI_ALIAS_FLAG); + private Drawable micDrawable; + private float scale; + private float amplitude; + private float animateToAmplitude; + private float animateAmplitudeDiff; + private long lastUpdateTime; + + public RecordCircle(Context context) { + super(context); + paint.setColor(0xff5795cc); + paintRecord.setColor(0x0d000000); + micDrawable = getResources().getDrawable(R.drawable.mic_pressed); + } + + public void setAmplitude(double value) { + animateToAmplitude = (float) Math.min(100, value) / 100.0f; + animateAmplitudeDiff = (animateToAmplitude - amplitude) / 150.0f; + lastUpdateTime = System.currentTimeMillis(); + invalidate(); + } + + public float getScale() { + return scale; + } + + public void setScale(float value) { + scale = value; + invalidate(); + } + + @Override + protected void onDraw(Canvas canvas) { + int cx = getMeasuredWidth() / 2; + int cy = getMeasuredHeight() / 2; + float sc; + float alpha; + if (scale <= 0.5f) { + alpha = sc = scale / 0.5f; + } else if (scale <= 0.75f) { + sc = 1.0f - (scale - 0.5f) / 0.25f * 0.1f; + alpha = 1; + } else { + sc = 0.9f + (scale - 0.75f) / 0.25f * 0.1f; + alpha = 1; + } + long dt = System.currentTimeMillis() - lastUpdateTime; + if (animateToAmplitude != amplitude) { + amplitude += animateAmplitudeDiff * dt; + if (animateAmplitudeDiff > 0) { + if (amplitude > animateToAmplitude) { + amplitude = animateToAmplitude; + } + } else { + if (amplitude < animateToAmplitude) { + amplitude = animateToAmplitude; + } + } + invalidate(); + } + lastUpdateTime = System.currentTimeMillis(); + if (amplitude != 0) { + canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, (AndroidUtilities.dp(42) + AndroidUtilities.dp(20) * amplitude) * scale, paintRecord); + } + canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, AndroidUtilities.dp(42) * sc, paint); + micDrawable.setBounds(cx - micDrawable.getIntrinsicWidth() / 2, cy - micDrawable.getIntrinsicHeight() / 2, cx + micDrawable.getIntrinsicWidth() / 2, cy + micDrawable.getIntrinsicHeight() / 2); + micDrawable.setAlpha((int) (255 * alpha)); + micDrawable.draw(canvas); + } + } + public ChatActivityEnterView(Activity context, SizeNotifierFrameLayout parent, BaseFragment fragment, boolean isChat) { super(context); setBackgroundResource(R.drawable.compose_panel); @@ -406,9 +532,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat linearLayout.setBackgroundColor(0xffffffff); recordPanel.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL)); - imageView = new ImageView(context); - imageView.setImageResource(R.drawable.rec); - linearLayout.addView(imageView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 0, 1, 0, 0)); + recordDot = new RecordDot(context); + linearLayout.addView(recordDot, LayoutHelper.createLinear(11, 11, Gravity.CENTER_VERTICAL, 0, 1, 0, 0)); recordTimeText = new TextView(context); recordTimeText.setText("00:00"); @@ -421,7 +546,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat audioSendButton = new ImageView(context); audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - //audioSendButton.setImageResource(R.drawable.mic_button_states); + //audioSendButton.setImageResource(R.drawable.mic); //audioSendButton.setBackgroundColor(0xffffffff); audioSendButton.setSoundEffectsEnabled(false); Drawable mic = getResources().getDrawable(R.drawable.mic); @@ -438,6 +563,13 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat mic.setColorFilter(0xffda564d, PorterDuff.Mode.SRC_IN); audioSendButton.setImageDrawable(mic); if (parentFragment != null) { + if (Build.VERSION.SDK_INT >= 23) { + if (parentActivity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { + parentActivity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 3); + return false; + } + } + String action; TLRPC.Chat currentChat; if ((int) dialog_id < 0) { @@ -477,6 +609,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); if (startedDraggingX != -1) { float dist = (x - startedDraggingX); + ViewProxy.setTranslationX(recordCircle, dist); params.leftMargin = AndroidUtilities.dp(30) + (int) dist; slideText.setLayoutParams(params); float alpha = 1.0f + dist / distCanMove; @@ -500,6 +633,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } if (params.leftMargin > AndroidUtilities.dp(30)) { params.leftMargin = AndroidUtilities.dp(30); + ViewProxy.setTranslationX(recordCircle, 0); slideText.setLayoutParams(params); ViewProxy.setAlpha(slideText, 1); startedDraggingX = -1; @@ -510,6 +644,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } }); + recordCircle = new RecordCircle(context); + recordCircle.setVisibility(GONE); + sizeNotifierLayout.addView(recordCircle, LayoutHelper.createFrame(124, 124, Gravity.BOTTOM | Gravity.RIGHT, 0, 0, -36, -38)); + sendButton = new ImageView(context); sendButton.setVisibility(View.INVISIBLE); sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); @@ -630,7 +768,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation == currentTopViewAnimation) { + if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { setTopViewAnimation(1.0f); if (!forceShowSendButton) { openKeyboard(); @@ -675,7 +813,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation == currentTopViewAnimation) { + if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) { topView.setVisibility(GONE); setTopViewAnimation(0.0f); currentTopViewAnimation = null; @@ -935,7 +1073,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat runningAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (runningAnimation.equals(animation)) { + if (runningAnimation != null && runningAnimation.equals(animation)) { sendButton.setVisibility(View.VISIBLE); audioSendButton.setVisibility(View.GONE); audioSendButton.clearAnimation(); @@ -1010,7 +1148,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat runningAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (runningAnimation.equals(animation)) { + if (runningAnimation != null && runningAnimation.equals(animation)) { sendButton.setVisibility(View.GONE); sendButton.clearAnimation(); audioSendButton.setVisibility(View.VISIBLE); @@ -1081,8 +1219,11 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } AndroidUtilities.lockOrientation(parentActivity); - recordPanel.setVisibility(View.VISIBLE); + recordPanel.setVisibility(VISIBLE); + recordCircle.setVisibility(VISIBLE); + recordCircle.setAmplitude(0); recordTimeText.setText("00:00"); + recordDot.resetAlpha(); lastTimeString = null; FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) slideText.getLayoutParams(); @@ -1090,19 +1231,25 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat slideText.setLayoutParams(params); ViewProxy.setAlpha(slideText, 1); ViewProxy.setX(recordPanel, AndroidUtilities.displaySize.x); + ViewProxy.setTranslationX(recordCircle, 0); if (runningAnimationAudio != null) { runningAnimationAudio.cancel(); } - runningAnimationAudio = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", 0).setDuration(300); + runningAnimationAudio = new AnimatorSetProxy(); + runningAnimationAudio.playTogether(ObjectAnimatorProxy.ofFloat(recordPanel, "translationX", 0), + ObjectAnimatorProxy.ofFloat(recordCircle, "scale", 1), + ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 0)); + runningAnimationAudio.setDuration(300); runningAnimationAudio.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animator) { if (runningAnimationAudio != null && runningAnimationAudio.equals(animator)) { ViewProxy.setX(recordPanel, 0); - } + runningAnimationAudio = null; + } } }); - runningAnimationAudio.setInterpolator(new AccelerateDecelerateInterpolator()); + runningAnimationAudio.setInterpolator(new DecelerateInterpolator()); runningAnimationAudio.start(); } else { if (mWakeLock != null) { @@ -1122,7 +1269,11 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat if (runningAnimationAudio != null) { runningAnimationAudio.cancel(); } - runningAnimationAudio = ObjectAnimatorProxy.ofFloatProxy(recordPanel, "translationX", AndroidUtilities.displaySize.x).setDuration(300); + runningAnimationAudio = new AnimatorSetProxy(); + runningAnimationAudio.playTogether(ObjectAnimatorProxy.ofFloat(recordPanel, "translationX", AndroidUtilities.displaySize.x), + ObjectAnimatorProxy.ofFloat(recordCircle, "scale", 0.0f), + ObjectAnimatorProxy.ofFloat(audioSendButton, "alpha", 1.0f)); + runningAnimationAudio.setDuration(300); runningAnimationAudio.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animator) { @@ -1132,10 +1283,12 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat slideText.setLayoutParams(params); ViewProxy.setAlpha(slideText, 1); recordPanel.setVisibility(View.GONE); + recordCircle.setVisibility(View.GONE); + runningAnimationAudio = null; } } }); - runningAnimationAudio.setInterpolator(new AccelerateDecelerateInterpolator()); + runningAnimationAudio.setInterpolator(new AccelerateInterpolator()); runningAnimationAudio.start(); } } @@ -1144,22 +1297,28 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat this.delegate = delegate; } - public void setCommand(MessageObject messageObject, String command) { + public void setCommand(MessageObject messageObject, String command, boolean longPress) { if (command == null || getVisibility() != VISIBLE) { return; } - TLRPC.User user = messageObject != null && (int) dialog_id < 0 ? MessagesController.getInstance().getUser(messageObject.messageOwner.from_id) : null; - if (botCount != 1 && user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0 && !command.contains("@")) { - SendMessagesHelper.getInstance().sendMessage(String.format(Locale.US, "%s@%s", command, user.username), dialog_id, null, null, false, asAdmin()); - } else { - SendMessagesHelper.getInstance().sendMessage(command, dialog_id, null, null, false, asAdmin()); - } - /*String text = messageEditText.getText().toString(); + if (longPress) { + String text = messageEditText.getText().toString(); text = command + " " + text.replaceFirst("^/[a-zA-Z@\\d_]{1,255}(\\s|$)", ""); ignoreTextChange = true; messageEditText.setText(text); messageEditText.setSelection(messageEditText.getText().length()); - ignoreTextChange = false;*/ + ignoreTextChange = false; + if (!keyboardVisible && currentPopupContentType == -1) { + openKeyboard(); + } + } else { + TLRPC.User user = messageObject != null && (int) dialog_id < 0 ? MessagesController.getInstance().getUser(messageObject.messageOwner.from_id) : null; + if (botCount != 1 && user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0 && !command.contains("@")) { + SendMessagesHelper.getInstance().sendMessage(String.format(Locale.US, "%s@%s", command, user.username), dialog_id, null, null, false, asAdmin()); + } else { + SendMessagesHelper.getInstance().sendMessage(command, dialog_id, null, null, false, asAdmin()); + } + } } public void setFieldText(String text) { @@ -1175,6 +1334,13 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } } + public void setSelection(int start) { + if (messageEditText == null) { + return; + } + messageEditText.setSelection(start, messageEditText.length()); + } + public int getCursorPosition() { if (messageEditText == null) { return 0; @@ -1353,6 +1519,10 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat return view == botKeyboardView || view == emojiView; } + public boolean isRecordCircle(View view) { + return view == recordCircle; + } + private void showPopup(int show, int contentType) { SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int color = themePrefs.getInt("chatEditTextIconsColor", 0xffadadad); @@ -1379,7 +1549,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat } try { innerTextChange = 2; - CharSequence localCharSequence = Emoji.replaceEmoji(symbol/* + "\uFE0F"*/, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); + CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false); messageEditText.setText(messageEditText.getText().insert(i, localCharSequence)); int j = i + localCharSequence.length(); messageEditText.setSelection(j, j); @@ -1463,6 +1633,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat emojiButton.setImageDrawable(d); //emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles); } + currentPopupContentType = -1; if (emojiView != null) { emojiView.setVisibility(GONE); } @@ -1612,6 +1783,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat recordTimeText.setText(str); } } + if (recordCircle != null) { + recordCircle.setAmplitude((Double) args[1]); + } } else if (id == NotificationCenter.closeChats) { if (messageEditText != null && messageEditText.isFocused()) { AndroidUtilities.hideKeyboard(messageEditText); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java index 60444884..1bb73b56 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CheckBox.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 59ec72db..a9ddcaac 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java index d4a1717c..76a19b05 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; @@ -12,6 +12,9 @@ import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; import android.database.DataSetObserver; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -21,9 +24,12 @@ import android.support.v4.view.ViewPager; import android.util.TypedValue; import android.view.Gravity; import android.view.HapticFeedbackConstants; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; +import android.view.WindowManager; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.BaseAdapter; @@ -31,22 +37,25 @@ import android.widget.FrameLayout; import android.widget.GridView; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.PopupWindow; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AnimationCompat.ViewProxy; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.Emoji; -import org.telegram.messenger.FileLog; +import org.telegram.messenger.EmojiData; 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.FileLog; +import org.telegram.messenger.R; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Cells.EmptyCell; import org.telegram.ui.Cells.StickerEmojiCell; import org.telegram.ui.StickerPreviewViewer; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -60,9 +69,415 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific void onStickerSelected(TLRPC.Document sticker); } + private static final Field superListenerField; + static { + Field f = null; + try { + f = PopupWindow.class.getDeclaredField("mOnScrollChangedListener"); + f.setAccessible(true); + } catch (NoSuchFieldException e) { + /* ignored */ + } + superListenerField = f; + } + private static final ViewTreeObserver.OnScrollChangedListener NOP = new ViewTreeObserver.OnScrollChangedListener() { + @Override + public void onScrollChanged() { + /* do nothing */ + } + }; + + private class ImageViewEmoji extends ImageView { + + private boolean touched; + private float lastX; + private float lastY; + private float touchedX; + private float touchedY; + + public ImageViewEmoji(Context context) { + super(context); + + setOnClickListener(new View.OnClickListener() { + public void onClick(View view) { + sendEmoji(null); + } + }); + setOnLongClickListener(new OnLongClickListener() { + @Override + public boolean onLongClick(View view) { + String code = (String) view.getTag(); + if (EmojiData.emojiColoredMap.containsKey(code)) { + touched = true; + touchedX = lastX; + touchedY = lastY; + + String color = emojiColor.get(code); + if (color != null) { + switch (color) { + case "\uD83C\uDFFB": + pickerView.setSelection(1); + break; + case "\uD83C\uDFFC": + pickerView.setSelection(2); + break; + case "\uD83C\uDFFD": + pickerView.setSelection(3); + break; + case "\uD83C\uDFFE": + pickerView.setSelection(4); + break; + case "\uD83C\uDFFF": + pickerView.setSelection(5); + break; + } + } else { + pickerView.setSelection(0); + } + view.getLocationOnScreen(location); + int x = emojiSize * pickerView.getSelection() + AndroidUtilities.dp(4 * pickerView.getSelection() - (AndroidUtilities.isTablet() ? 5 : 1)); + if (location[0] - x < AndroidUtilities.dp(5)) { + x += (location[0] - x) - AndroidUtilities.dp(5); + } else if (location[0] - x + popupWidth > AndroidUtilities.displaySize.x - AndroidUtilities.dp(5)) { + x += (location[0] - x + popupWidth) - (AndroidUtilities.displaySize.x - AndroidUtilities.dp(5)); + } + int xOffset = -x; + int yOffset = view.getTop() < 0 ? view.getTop() : 0; + + pickerView.setEmoji(code, AndroidUtilities.dp(AndroidUtilities.isTablet() ? 30 : 22) - xOffset + (int) AndroidUtilities.dpf2(0.5f)); + + pickerViewPopup.setFocusable(true); + pickerViewPopup.showAsDropDown(view, xOffset, -view.getMeasuredHeight() - popupHeight + (view.getMeasuredHeight() - emojiSize) / 2 - yOffset); + view.getParent().requestDisallowInterceptTouchEvent(true); + return true; + } + return false; + } + }); + setBackgroundResource(R.drawable.list_selector); + setScaleType(ImageView.ScaleType.CENTER); + } + + private void sendEmoji(String override) { + String code = override != null ? override : (String) getTag(); + if (override == null) { + if (pager.getCurrentItem() != 0) { + String color = emojiColor.get(code); + if (color != null) { + code += color; + } + } + Integer count = emojiUseHistory.get(code); + if (count == null) { + count = 0; + } + if (count == 0 && emojiUseHistory.size() > 50) { + for (int a = recentEmoji.size() - 1; a >= 0; a--) { + String emoji = recentEmoji.get(a); + emojiUseHistory.remove(emoji); + recentEmoji.remove(a); + if (emojiUseHistory.size() <= 50) { + break; + } + } + } + emojiUseHistory.put(code, ++count); + if (pager.getCurrentItem() != 0) { + sortEmoji(); + } + saveRecentEmoji(); + adapters.get(0).notifyDataSetChanged(); + if (listener != null) { + listener.onEmojiSelected(Emoji.fixEmoji(code)); + } + } else { + if (listener != null) { + listener.onEmojiSelected(Emoji.fixEmoji(override)); + } + } + + } + + @Override + public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(widthMeasureSpec)); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + if (touched) { + if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) { + if (pickerViewPopup != null && pickerViewPopup.isShowing()) { + pickerViewPopup.dismiss(); + + String color = null; + switch (pickerView.getSelection()) { + case 1: + color = "\uD83C\uDFFB"; + break; + case 2: + color = "\uD83C\uDFFC"; + break; + case 3: + color = "\uD83C\uDFFD"; + break; + case 4: + color = "\uD83C\uDFFE"; + break; + case 5: + color = "\uD83C\uDFFF"; + break; + } + String code = (String) getTag(); + if (pager.getCurrentItem() != 0) { + if (color != null) { + emojiColor.put(code, color); + code += color; + } else { + emojiColor.remove(code); + } + setImageDrawable(Emoji.getEmojiBigDrawable(code)); + sendEmoji(null); + saveEmojiColors(); + } else { + sendEmoji(code + (color != null ? color : "")); + } + } + touched = false; + touchedX = -10000; + touchedY = -10000; + } else if (event.getAction() == MotionEvent.ACTION_MOVE) { + boolean ignore = false; + if (touchedX != -10000) { + if (Math.abs(touchedX - event.getX()) > AndroidUtilities.getPixelsInCM(0.2f, true) || Math.abs(touchedY - event.getY()) > AndroidUtilities.getPixelsInCM(0.2f, false)) { + touchedX = -10000; + touchedY = -10000; + } else { + ignore = true; + } + } + if (!ignore) { + getLocationOnScreen(location); + float x = location[0] + event.getX(); + pickerView.getLocationOnScreen(location); + x -= location[0] + AndroidUtilities.dp(3); + int position = (int) (x / (emojiSize + AndroidUtilities.dp(4))); + if (position < 0) { + position = 0; + } else if (position > 5) { + position = 5; + } + pickerView.setSelection(position); + } + } + } + lastX = event.getX(); + lastY = event.getY(); + return super.onTouchEvent(event); + } + } + + private class EmojiPopupWindow extends PopupWindow { + + private ViewTreeObserver.OnScrollChangedListener mSuperScrollListener; + private ViewTreeObserver mViewTreeObserver; + + public EmojiPopupWindow() { + super(); + init(); + } + + public EmojiPopupWindow(Context context) { + super(context); + init(); + } + + public EmojiPopupWindow(int width, int height) { + super(width, height); + init(); + } + + public EmojiPopupWindow(View contentView) { + super(contentView); + init(); + } + + public EmojiPopupWindow(View contentView, int width, int height, boolean focusable) { + super(contentView, width, height, focusable); + init(); + } + + public EmojiPopupWindow(View contentView, int width, int height) { + super(contentView, width, height); + init(); + } + + private void init() { + if (superListenerField != null) { + try { + mSuperScrollListener = (ViewTreeObserver.OnScrollChangedListener) superListenerField.get(this); + superListenerField.set(this, NOP); + } catch (Exception e) { + mSuperScrollListener = null; + } + } + } + + private void unregisterListener() { + if (mSuperScrollListener != null && mViewTreeObserver != null) { + if (mViewTreeObserver.isAlive()) { + mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); + } + mViewTreeObserver = null; + } + } + + private void registerListener(View anchor) { + if (mSuperScrollListener != null) { + ViewTreeObserver vto = (anchor.getWindowToken() != null) ? anchor.getViewTreeObserver() : null; + if (vto != mViewTreeObserver) { + if (mViewTreeObserver != null && mViewTreeObserver.isAlive()) { + mViewTreeObserver.removeOnScrollChangedListener(mSuperScrollListener); + } + if ((mViewTreeObserver = vto) != null) { + vto.addOnScrollChangedListener(mSuperScrollListener); + } + } + } + } + + @Override + public void showAsDropDown(View anchor, int xoff, int yoff) { + try { + super.showAsDropDown(anchor, xoff, yoff); + registerListener(anchor); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + @Override + public void update(View anchor, int xoff, int yoff, int width, int height) { + super.update(anchor, xoff, yoff, width, height); + registerListener(anchor); + } + + @Override + public void update(View anchor, int width, int height) { + super.update(anchor, width, height); + registerListener(anchor); + } + + @Override + public void showAtLocation(View parent, int gravity, int x, int y) { + super.showAtLocation(parent, gravity, x, y); + unregisterListener(); + } + + @Override + public void dismiss() { + setFocusable(false); + try { + super.dismiss(); + } catch (Exception e) { + //don't promt + } + unregisterListener(); + } + } + + private class EmojiColorPickerView extends View { + + private Drawable backgroundDrawable; + private Drawable arrowDrawable; + private String currentEmoji; + private int arrowX; + private int selection; + private Paint rectPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private RectF rect = new RectF(); + + public void setEmoji(String emoji, int arrowPosition) { + currentEmoji = emoji; + arrowX = arrowPosition; + rectPaint.setColor(0x2f000000); + invalidate(); + } + + public String getEmoji() { + return currentEmoji; + } + + public void setSelection(int position) { + if (selection == position) { + return; + } + selection = position; + invalidate(); + } + + public int getSelection() { + return selection; + } + + public EmojiColorPickerView(Context context) { + super(context); + + backgroundDrawable = getResources().getDrawable(R.drawable.stickers_back_all); + arrowDrawable = getResources().getDrawable(R.drawable.stickers_back_arrow); + } + + @Override + protected void onDraw(Canvas canvas) { + backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), AndroidUtilities.dp(AndroidUtilities.isTablet() ? 60 : 52)); + backgroundDrawable.draw(canvas); + + arrowDrawable.setBounds(arrowX - AndroidUtilities.dp(9), AndroidUtilities.dp(AndroidUtilities.isTablet() ? 55.5f : 47.5f), arrowX + AndroidUtilities.dp(9), AndroidUtilities.dp((AndroidUtilities.isTablet() ? 55.5f : 47.5f) + 8)); + arrowDrawable.draw(canvas); + + if (currentEmoji != null) { + String code; + for (int a = 0; a < 6; a++) { + int x = emojiSize * a + AndroidUtilities.dp(5 + 4 * a); + int y = AndroidUtilities.dp(9); + if (selection == a) { + rect.set(x, y - (int) AndroidUtilities.dpf2(3.5f), x + emojiSize, y + emojiSize + AndroidUtilities.dp(3)); + canvas.drawRoundRect(rect, AndroidUtilities.dp(4), AndroidUtilities.dp(4), rectPaint); + } + code = currentEmoji; + if (a != 0) { + code += "\uD83C"; + switch (a) { + case 1: + code += "\uDFFB"; + break; + case 2: + code += "\uDFFC"; + break; + case 3: + code += "\uDFFD"; + break; + case 4: + code += "\uDFFE"; + break; + case 5: + code += "\uDFFF"; + break; + } + } + Drawable drawable = Emoji.getEmojiBigDrawable(code); + if (drawable != null) { + drawable.setBounds(x, y, x + emojiSize, y + emojiSize); + drawable.draw(canvas); + } + } + } + } + } + private ArrayList adapters = new ArrayList<>(); - private HashMap emojiUseHistory = new HashMap<>(); - private ArrayList recentEmoji = new ArrayList<>(); + private HashMap emojiUseHistory = new HashMap<>(); + private static HashMap emojiColor = new HashMap<>(); + private ArrayList recentEmoji = new ArrayList<>(); private HashMap stickersUseHistory = new HashMap<>(); private ArrayList recentStickers = new ArrayList<>(); private HashMap stickerSetsUseCount = new HashMap<>(); @@ -90,6 +505,12 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific private AdapterView.OnItemClickListener stickersOnItemClickListener; private Runnable openStickerPreviewRunnable; private StickerEmojiCell currentStickerPreviewCell; + private EmojiColorPickerView pickerView; + private EmojiPopupWindow pickerViewPopup; + private int popupWidth; + private int popupHeight; + private int emojiSize; + private int location[] = new int[2]; private int startX; private int startY; @@ -110,7 +531,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15)); int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10); //setOrientation(LinearLayout.VERTICAL); - for (int i = 0; i < Emoji.data.length + 1; i++) { + for (int i = 0; i < EmojiData.dataColored.length + 1; i++) { GridView gridView = new GridView(context); if (AndroidUtilities.isTablet()) { gridView.setColumnWidth(AndroidUtilities.dp(60)); @@ -537,7 +958,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific GradientDrawable gd = new GradientDrawable(go, colors); setBackgroundDrawable(gd); pagerSlidingTabStripContainer.setBackgroundColor(0x00000000); - scrollSlidingTabStrip.setUnderlineColor(0x00000000); + if(scrollSlidingTabStrip != null)scrollSlidingTabStrip.setUnderlineColor(0x00000000); pagerSlidingTabStrip.setUnderlineColor(0x00000000); view.setBackgroundColor(0x00000000); } @@ -556,11 +977,26 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0)); - loadRecents(); + emojiSize = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 40 : 32); + pickerView = new EmojiColorPickerView(context); + pickerViewPopup = new EmojiPopupWindow(pickerView, popupWidth = AndroidUtilities.dp((AndroidUtilities.isTablet() ? 40 : 32) * 6 + 10 + 4 * 5), popupHeight = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 64 : 56)); + pickerViewPopup.setOutsideTouchable(true); + pickerViewPopup.setClippingEnabled(true); + pickerViewPopup.setInputMethodMode(EmojiPopupWindow.INPUT_METHOD_NOT_NEEDED); + pickerViewPopup.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED); + pickerViewPopup.getContentView().setFocusableInTouchMode(true); + pickerViewPopup.getContentView().setOnKeyListener(new OnKeyListener() { + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0 && event.getAction() == KeyEvent.ACTION_UP && pickerViewPopup != null && pickerViewPopup.isShowing()) { + pickerViewPopup.dismiss(); + return true; + } + return false; + } + }); - if (Emoji.data[0] == null || Emoji.data[0].length == 0) { - pager.setCurrentItem(1); - } + loadRecents(); } private void onPageScrolled(int position, int width, int positionOffsetPixels) { @@ -629,7 +1065,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific private void saveRecentEmoji() { SharedPreferences preferences = getContext().getSharedPreferences("emoji", Activity.MODE_PRIVATE); StringBuilder stringBuilder = new StringBuilder(); - for (HashMap.Entry entry : emojiUseHistory.entrySet()) { + for (HashMap.Entry entry : emojiUseHistory.entrySet()) { if (stringBuilder.length() != 0) { stringBuilder.append(","); } @@ -637,7 +1073,21 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific stringBuilder.append("="); stringBuilder.append(entry.getValue()); } - preferences.edit().putString("emojis", stringBuilder.toString()).commit(); + preferences.edit().putString("emojis2", stringBuilder.toString()).commit(); + } + + private void saveEmojiColors() { + SharedPreferences preferences = getContext().getSharedPreferences("emoji", Activity.MODE_PRIVATE); + StringBuilder stringBuilder = new StringBuilder(); + for (HashMap.Entry entry : emojiColor.entrySet()) { + if (stringBuilder.length() != 0) { + stringBuilder.append(","); + } + stringBuilder.append(entry.getKey()); + stringBuilder.append("="); + stringBuilder.append(entry.getValue()); + } + preferences.edit().putString("color", stringBuilder.toString()).commit(); } private void saveRecentStickers() { @@ -684,12 +1134,12 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific private void sortEmoji() { recentEmoji.clear(); - for (HashMap.Entry entry : emojiUseHistory.entrySet()) { + for (HashMap.Entry entry : emojiUseHistory.entrySet()) { recentEmoji.add(entry.getKey()); } - Collections.sort(recentEmoji, new Comparator() { + Collections.sort(recentEmoji, new Comparator() { @Override - public int compare(Long lhs, Long rhs) { + public int compare(String lhs, String rhs) { Integer count1 = emojiUseHistory.get(lhs); Integer count2 = emojiUseHistory.get(rhs); if (count1 == null) { @@ -797,40 +1247,49 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific String str; SharedPreferences preferences = getContext().getSharedPreferences("emoji", Activity.MODE_PRIVATE); - if (preferences.contains("recents")) { - try { - str = preferences.getString("recents", ""); - if (str != null && str.length() > 0) { - String[] args = str.split(","); - for (int i = 0; i < args.length; i++) { - emojiUseHistory.put(Long.parseLong(args[i]), args.length - i); - } - } - } catch (Exception e) { - FileLog.e("tmessages", e); - } - sortEmoji(); - preferences.edit().remove("recents").commit(); - saveRecentEmoji(); - adapters.get(0).notifyDataSetChanged(); - } else { try { emojiUseHistory.clear(); + if (preferences.contains("emojis")) { str = preferences.getString("emojis", ""); if (str != null && str.length() > 0) { String[] args = str.split(","); for (String arg : args) { String[] args2 = arg.split("="); - emojiUseHistory.put(Long.parseLong(args2[0]), Integer.parseInt(args2[1])); + long value = Long.parseLong(args2[0]); + String string = ""; + for (int a = 0; a < 4; a++) { + char ch = (char) value; + string = String.valueOf(ch) + string; + value >>= 16; + if (value == 0) { + break; + } + } + if (string.length() > 0) { + emojiUseHistory.put(string, Integer.parseInt(args2[1])); + } + } + } + preferences.edit().remove("emojis").commit(); + saveRecentEmoji(); + } else { + str = preferences.getString("emojis2", ""); + if (str != null && str.length() > 0) { + String[] args = str.split(","); + for (String arg : args) { + String[] args2 = arg.split("="); + emojiUseHistory.put(args2[0], Integer.parseInt(args2[1])); + } } } if (emojiUseHistory.isEmpty()) { - long[] newRecent = new long[]{0x00000000D83DDE02L, 0x00000000D83DDE18L, 0x0000000000002764L, 0x00000000D83DDE0DL, 0x00000000D83DDE0AL, 0x00000000D83DDE01L, - 0x00000000D83DDC4DL, 0x000000000000263AL, 0x00000000D83DDE14L, 0x00000000D83DDE04L, 0x00000000D83DDE2DL, 0x00000000D83DDC8BL, - 0x00000000D83DDE12L, 0x00000000D83DDE33L, 0x00000000D83DDE1CL, 0x00000000D83DDE48L, 0x00000000D83DDE09L, 0x00000000D83DDE03L, - 0x00000000D83DDE22L, 0x00000000D83DDE1DL, 0x00000000D83DDE31L, 0x00000000D83DDE21L, 0x00000000D83DDE0FL, 0x00000000D83DDE1EL, - 0x00000000D83DDE05L, 0x00000000D83DDE1AL, 0x00000000D83DDE4AL, 0x00000000D83DDE0CL, 0x00000000D83DDE00L, 0x00000000D83DDE0BL, - 0x00000000D83DDE06L, 0x00000000D83DDC4CL, 0x00000000D83DDE10L, 0x00000000D83DDE15L}; + String[] newRecent = new String[]{ + "\uD83D\uDE02", "\uD83D\uDE18", "\u2764", "\uD83D\uDE0D", "\uD83D\uDE0A", "\uD83D\uDE01", + "\uD83D\uDC4D", "\u263A", "\uD83D\uDE14", "\uD83D\uDE04", "\uD83D\uDE2D", "\uD83D\uDC8B", + "\uD83D\uDE12", "\uD83D\uDE33", "\uD83D\uDE1C", "\uD83D\uDE48", "\uD83D\uDE09", "\uD83D\uDE03", + "\uD83D\uDE22", "\uD83D\uDE1D", "\uD83D\uDE31", "\uD83D\uDE21", "\uD83D\uDE0F", "\uD83D\uDE1E", + "\uD83D\uDE05", "\uD83D\uDE1A", "\uD83D\uDE4A", "\uD83D\uDE0C", "\uD83D\uDE00", "\uD83D\uDE0B", + "\uD83D\uDE06", "\uD83D\uDC4C", "\uD83D\uDE10", "\uD83D\uDE15"}; for (int i = 0; i < newRecent.length; i++) { emojiUseHistory.put(newRecent[i], newRecent.length - i); } @@ -841,6 +1300,18 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific } catch (Exception e) { FileLog.e("tmessages", e); } + + try { + str = preferences.getString("color", ""); + if (str != null && str.length() > 0) { + String[] args = str.split(","); + for (String arg : args) { + String[] args2 = arg.split("="); + emojiColor.put(args2[0], args2[1]); + } + } + } catch (Exception e) { + FileLog.e("tmessages", e); } if (showStickers) { @@ -961,6 +1432,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific if (stickersGridAdapter != null) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.stickersDidLoaded); } + if (pickerViewPopup != null && pickerViewPopup.isShowing()) { + pickerViewPopup.dismiss(); + } } @Override @@ -1128,7 +1602,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific if (emojiPage == -1) { return recentEmoji.size(); } - return Emoji.data[emojiPage].length; + return EmojiData.dataColored[emojiPage].length; } public Object getItem(int i) { @@ -1141,51 +1615,22 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific } public View getView(int i, View view, ViewGroup paramViewGroup) { - ImageView imageView = (ImageView)view; + ImageViewEmoji imageView = (ImageViewEmoji) view; if (imageView == null) { - imageView = new ImageView(getContext()) { - public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - setMeasuredDimension(View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(widthMeasureSpec)); - } - }; - imageView.setOnClickListener(new View.OnClickListener() { - public void onClick(View view) { - Long code = (Long) view.getTag(); - Integer count = emojiUseHistory.get(code); - if (count == null) { - count = 0; - } - if (count == 0 && emojiUseHistory.size() > 50) { - for (int a = recentEmoji.size() - 1; a >= 0; a--) { - Long emoji = recentEmoji.get(a); - emojiUseHistory.remove(emoji); - recentEmoji.remove(a); - if (emojiUseHistory.size() <= 50) { - break; - } - } - } - emojiUseHistory.put(code, ++count); - if (pager.getCurrentItem() != 0) { - sortEmoji(); - } - saveRecentEmoji(); - adapters.get(0).notifyDataSetChanged(); - if (listener != null) { - listener.onEmojiSelected(convert((Long)view.getTag())); - } - } - }); - imageView.setBackgroundResource(R.drawable.list_selector); - imageView.setScaleType(ImageView.ScaleType.CENTER); + imageView = new ImageViewEmoji(getContext()); } - long code; + String code; + String coloredCode; if (emojiPage == -1) { - code = recentEmoji.get(i); + coloredCode = code = recentEmoji.get(i); } else { - code = Emoji.data[emojiPage][i]; + coloredCode = code = EmojiData.dataColored[emojiPage][i]; + String color = emojiColor.get(code); + if (color != null) { + coloredCode += color; + } } - imageView.setImageDrawable(Emoji.getEmojiBigDrawable(code)); + imageView.setImageDrawable(Emoji.getEmojiBigDrawable(coloredCode)); imageView.setTag(code); return imageView; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java index 26323f5e..1db8f632 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ForegroundDetector.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java index cd169b3f..26f791a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/IdenticonDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/IdenticonDrawable.java index 394b6af4..0d0e70d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/IdenticonDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/IdenticonDrawable.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutHelper.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutHelper.java index c1a65b6c..700d5827 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LayoutHelper.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterSectionsListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterSectionsListView.java index fbac8a24..60a26421 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterSectionsListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LetterSectionsListView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LineProgressView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LineProgressView.java index 9b7db2ce..26e73d7b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LineProgressView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LineProgressView.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/MapPlaceholderDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/MapPlaceholderDrawable.java index c522342d..7c4ba414 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/MapPlaceholderDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/MapPlaceholderDrawable.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java index 4ca7692f..0531e8e9 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PagerSlidingTabStrip.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; @@ -323,7 +323,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { currentPosition = position; - currentPositionOffset = positionOffset; scrollToChild(position, (int) (positionOffset * tabsContainer.getChildAt(position).getWidth())); invalidate(); @@ -347,9 +346,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView { if (delegatePageListener != null) { delegatePageListener.onPageSelected(position); } - //plus - //if(position == currentPosition)paintTabIcons(position); - // for (int a = 0; a < tabsContainer.getChildCount(); a++) { tabsContainer.getChildAt(a).setSelected(a == position); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java index a8a2015e..86d093d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PasscodeView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -9,7 +9,9 @@ package org.telegram.ui.Components; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Canvas; @@ -19,6 +21,8 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Vibrator; +import android.support.v4.hardware.fingerprint.FingerprintManagerCompat; +import android.support.v4.os.CancellationSignal; import android.text.Editable; import android.text.InputFilter; import android.text.InputType; @@ -38,6 +42,7 @@ import android.view.inputmethod.EditorInfo; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.RelativeLayout; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; @@ -185,7 +190,7 @@ public class PasscodeView extends FrameLayout { currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation.equals(currentAnimation)) { + if (currentAnimation != null && currentAnimation.equals(animation)) { currentAnimation = null; } } @@ -219,7 +224,7 @@ public class PasscodeView extends FrameLayout { currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation.equals(currentAnimation)) { + if (currentAnimation != null && currentAnimation.equals(animation)) { currentAnimation = null; } } @@ -296,7 +301,7 @@ public class PasscodeView extends FrameLayout { currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation.equals(currentAnimation)) { + if (currentAnimation != null && currentAnimation.equals(animation)) { currentAnimation = null; } } @@ -304,7 +309,7 @@ public class PasscodeView extends FrameLayout { currentAnimation.start(); } - private void eraseAllCharacters(boolean animated) { + private void eraseAllCharacters(final boolean animated) { if (stringBuilder.length() == 0) { return; } @@ -342,7 +347,7 @@ public class PasscodeView extends FrameLayout { currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (animation.equals(currentAnimation)) { + if (currentAnimation != null && currentAnimation.equals(animation)) { currentAnimation = null; } } @@ -409,10 +414,19 @@ public class PasscodeView extends FrameLayout { private ImageView checkImage; private int keyboardHeight = 0; + private CancellationSignal cancellationSignal; + private ImageView fingerprintImageView; + private TextView fingerprintStatusTextView; + private boolean selfCancelled; + private AlertDialog fingerprintDialog; + private Rect rect = new Rect(); private PasscodeViewDelegate delegate; + private final static int id_fingerprint_textview = 1000; + private final static int id_fingerprint_imageview = 1001; + public PasscodeView(final Context context) { super(context); @@ -497,7 +511,7 @@ public class PasscodeView extends FrameLayout { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_DONE) { - processDone(); + processDone(false); return true; } return false; @@ -517,7 +531,7 @@ public class PasscodeView extends FrameLayout { @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4 && UserConfig.passcodeType == 0) { - processDone(); + processDone(false); } } }); @@ -561,7 +575,7 @@ public class PasscodeView extends FrameLayout { checkImage.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - processDone(); + processDone(false); } }); @@ -707,7 +721,7 @@ public class PasscodeView extends FrameLayout { break; } if (passwordEditText2.lenght() == 4) { - processDone(); + processDone(false); } } }); @@ -728,7 +742,8 @@ public class PasscodeView extends FrameLayout { this.delegate = delegate; } - private void processDone() { + private void processDone(boolean fingerprint) { + if (!fingerprint) { String password = ""; if (UserConfig.passcodeType == 0) { password = passwordEditText2.getString(); @@ -745,6 +760,7 @@ public class PasscodeView extends FrameLayout { onPasscodeError(); return; } + } passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); @@ -816,16 +832,148 @@ public class PasscodeView extends FrameLayout { } }, 200); } + checkFingerprint(); + } + + public void onPause() { + if (fingerprintDialog != null) { + try { + if (fingerprintDialog.isShowing()) { + fingerprintDialog.dismiss(); + } + fingerprintDialog = null; + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + try { + if (Build.VERSION.SDK_INT >= 23 && cancellationSignal != null) { + cancellationSignal.cancel(); + cancellationSignal = null; + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + + private void checkFingerprint() { + Activity parentActivity = (Activity) getContext(); + if (Build.VERSION.SDK_INT >= 23 && parentActivity != null && UserConfig.useFingerprint && !ApplicationLoader.mainInterfacePaused) { + try { + if (fingerprintDialog != null && fingerprintDialog.isShowing()) { + return; + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + try { + FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.from(ApplicationLoader.applicationContext); + if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) { + RelativeLayout relativeLayout = new RelativeLayout(getContext()); + relativeLayout.setPadding(AndroidUtilities.dp(24), AndroidUtilities.dp(16), AndroidUtilities.dp(24), AndroidUtilities.dp(8)); + + TextView fingerprintTextView = new TextView(getContext()); + fingerprintTextView.setTextColor(0xff939393); + fingerprintTextView.setId(id_fingerprint_textview); + fingerprintTextView.setTextAppearance(android.R.style.TextAppearance_Material_Subhead); + fingerprintTextView.setText(LocaleController.getString("FingerprintInfo", R.string.FingerprintInfo)); + relativeLayout.addView(fingerprintTextView); + RelativeLayout.LayoutParams layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); + layoutParams.addRule(RelativeLayout.ALIGN_PARENT_START); + fingerprintTextView.setLayoutParams(layoutParams); + + fingerprintImageView = new ImageView(getContext()); + fingerprintImageView.setImageResource(R.drawable.ic_fp_40px); + fingerprintImageView.setId(id_fingerprint_imageview); + relativeLayout.addView(fingerprintImageView, LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0, RelativeLayout.ALIGN_PARENT_START, RelativeLayout.BELOW, id_fingerprint_textview)); + + fingerprintStatusTextView = new TextView(getContext()); + fingerprintStatusTextView.setGravity(Gravity.CENTER_VERTICAL); + fingerprintStatusTextView.setText(LocaleController.getString("FingerprintHelp", R.string.FingerprintHelp)); + fingerprintStatusTextView.setTextAppearance(android.R.style.TextAppearance_Material_Body1); + fingerprintStatusTextView.setTextColor(0x42000000); + relativeLayout.addView(fingerprintStatusTextView); + layoutParams = LayoutHelper.createRelative(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT); + layoutParams.setMarginStart(AndroidUtilities.dp(16)); + layoutParams.addRule(RelativeLayout.ALIGN_BOTTOM, id_fingerprint_imageview); + layoutParams.addRule(RelativeLayout.ALIGN_TOP, id_fingerprint_imageview); + layoutParams.addRule(RelativeLayout.END_OF, id_fingerprint_imageview); + fingerprintStatusTextView.setLayoutParams(layoutParams); + + AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setView(relativeLayout); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + builder.setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + if (cancellationSignal != null) { + selfCancelled = true; + cancellationSignal.cancel(); + cancellationSignal = null; + } + } + }); + if (fingerprintDialog != null) { + try { + if (fingerprintDialog.isShowing()) { + fingerprintDialog.dismiss(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + fingerprintDialog = builder.show(); + + cancellationSignal = new CancellationSignal(); + selfCancelled = false; + fingerprintManager.authenticate(null, 0, cancellationSignal, new FingerprintManagerCompat.AuthenticationCallback() { + @Override + public void onAuthenticationError(int errMsgId, CharSequence errString) { + if (!selfCancelled) { + showFingerprintError(errString); + } + } + + @Override + public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) { + showFingerprintError(helpString); + } + + @Override + public void onAuthenticationFailed() { + showFingerprintError(LocaleController.getString("FingerprintNotRecognized", R.string.FingerprintNotRecognized)); + } + + @Override + public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) { + try { + if (fingerprintDialog.isShowing()) { + fingerprintDialog.dismiss(); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + fingerprintDialog = null; + processDone(true); + } + }, null); + } + } catch (Throwable e) { + //ignore + } + } } public void onShow() { + Activity parentActivity = (Activity) getContext(); if (UserConfig.passcodeType == 1) { if (passwordEditText != null) { passwordEditText.requestFocus(); AndroidUtilities.showKeyboard(passwordEditText); } } else { - Activity parentActivity = (Activity) getContext(); if (parentActivity != null) { View currentFocus = parentActivity.getCurrentFocus(); if (currentFocus != null) { @@ -834,6 +982,7 @@ public class PasscodeView extends FrameLayout { } } } + checkFingerprint(); if (getVisibility() == View.VISIBLE) { return; } @@ -893,6 +1042,17 @@ public class PasscodeView extends FrameLayout { }); } + private void showFingerprintError(CharSequence error) { + fingerprintImageView.setImageResource(R.drawable.ic_fingerprint_error); + fingerprintStatusTextView.setText(error); + fingerprintStatusTextView.setTextColor(0xfff4511e); + Vibrator v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); + if (v != null) { + v.vibrate(200); + } + AndroidUtilities.shakeView(fingerprintStatusTextView, 2, 0); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int width = MeasureSpec.getSize(widthMeasureSpec); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java index 6ea153f3..f61de026 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoCropView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -348,8 +348,7 @@ public class PhotoCropView extends FrameLayout { private Bitmap createBitmap(int x, int y, int w, int h) { Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); - Paint paint = new Paint(); - paint.setFilterBitmap(true); + Paint paint = new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG); Matrix matrix = new Matrix(); matrix.setTranslate(-bitmapToEdit.getWidth() / 2, -bitmapToEdit.getHeight() / 2); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoEditorSeekBar.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoEditorSeekBar.java index 5258a651..a6bf8443 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoEditorSeekBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoEditorSeekBar.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterBlurControl.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterBlurControl.java index d9309927..137ddc70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterBlurControl.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterBlurControl.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 3007ddb3..0c14662f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoFilterView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 a5055811..9dc34b60 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PhotoViewerCaptionEnterView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Point.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Point.java index f22dde47..7e6fb2ba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Point.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Point.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 be012339..71908c83 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/PopupAudioView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java index 58b52ad5..d5e7f377 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 f9dca6b1..ae01fcf1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RadialProgress.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 558d8404..4f0e6a8c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecordStatusDrawable.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Rect.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Rect.java index 9dde354b..ef88d877 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Rect.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Rect.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java index dc0c32a2..7d29cd0c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -49,7 +49,7 @@ public class RecyclerListView extends RecyclerView { } public interface OnItemLongClickListener { - void onItemClick(View view, int position); + boolean onItemClick(View view, int position); } public interface OnInterceptTouchListener { @@ -97,8 +97,9 @@ public class RecyclerListView extends RecyclerView { @Override public void onLongPress(MotionEvent e) { if (currentChildView != null && onItemLongClickListener != null) { - currentChildView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); - onItemLongClickListener.onItemClick(currentChildView, currentChildPosition); + if (onItemLongClickListener.onItemClick(currentChildView, currentChildPosition)) { + currentChildView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); + } } } }); @@ -164,7 +165,15 @@ public class RecyclerListView extends RecyclerView { @Override public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) { - + if (selectChildRunnable != null) { + AndroidUtilities.cancelRunOnUIThread(selectChildRunnable); + selectChildRunnable = null; + } + if (currentChildView != null) { + currentChildView.setPressed(false); + currentChildView = null; + } + interceptedByChild = false; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java index 93b0feca..f02b4795 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ResourceLoader.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -134,7 +134,15 @@ public class ResourceLoader { 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/Scroller.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Scroller.java index 56890bfb..a4261799 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Scroller.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Scroller.java @@ -369,7 +369,7 @@ public class Scroller { float dx = (float) (mFinalX - mStartX); float dy = (float) (mFinalY - mStartY); - float hyp = FloatMath.sqrt(dx * dx + dy * dy); + float hyp = (float) Math.sqrt(dx * dx + dy * dy); float ndx = dx / hyp; float ndy = dy / hyp; @@ -386,7 +386,7 @@ public class Scroller { mMode = FLING_MODE; mFinished = false; - float velocity = FloatMath.sqrt(velocityX * velocityX + velocityY * velocityY); + float velocity = (float) Math.sqrt(velocityX * velocityX + velocityY * velocityY); mVelocity = velocity; float ALPHA = 800; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SectionsListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SectionsListView.java index 441938c3..b1056474 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SectionsListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SectionsListView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 44764407..9b315e9e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SeekBar.java @@ -3,7 +3,7 @@ * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 7f6de6f7..b74314b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileDrawable.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 f68c73b0..9a6f2857 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileEx2Drawable.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * 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 47a1a8c9..22af5a8b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SendingFileExDrawable.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java index 2a1a0a8a..eaf03eaf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SimpleTextView.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Size.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Size.java index 986c4070..a793a205 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Size.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Size.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java index a1ae84c6..cc27b2e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 8e30cc02..859ee42b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlidingTabView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StaticLayoutEx.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StaticLayoutEx.java index f918c1b3..cd464f6b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StaticLayoutEx.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StaticLayoutEx.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TimerDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TimerDrawable.java index ea98120d..6f363f28 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TimerDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TimerDrawable.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java index 9f86fe3b..c0a4e650 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypefaceSpan.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; 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 21c7468a..d25ca387 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/TypingDotsDrawable.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanNoUnderline.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanNoUnderline.java index 8debb521..b2ff8881 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanNoUnderline.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/URLSpanNoUnderline.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoSeekBarView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoSeekBarView.java index d7ac826c..14c87235 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoSeekBarView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoSeekBarView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java index b4cca99d..3f9ba71c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui.Components; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java index 1aafe718..86c6f781 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -297,8 +297,10 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent } @Override - public void onOpenAnimationEnd() { - firstNameField.requestFocus(); - AndroidUtilities.showKeyboard(firstNameField); + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { + firstNameField.requestFocus(); + AndroidUtilities.showKeyboard(firstNameField); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java index 956390df..6588ba78 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java index b57c3cbe..e34a29da 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java index 93b43bfd..2ec465e5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -14,33 +14,34 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.Configuration; import android.os.Build; import android.os.Environment; import android.os.StatFs; -import android.text.TextUtils; -import android.view.Gravity; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.AbsListView; import android.widget.AdapterView; -import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; +import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; -import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; -import org.telegram.messenger.AnimationCompat.AnimatorSetProxy; -import org.telegram.messenger.AnimationCompat.ObjectAnimatorProxy; +import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BaseFragment; +import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.SharedDocumentCell; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.NumberTextView; import java.io.BufferedReader; import java.io.File; @@ -61,7 +62,7 @@ public class DocumentSelectActivity extends BaseFragment { private ListView listView; private ListAdapter listAdapter; - private TextView selectedMessagesCountTextView; + private NumberTextView selectedMessagesCountTextView; private TextView emptyView; private File currentDir; @@ -148,18 +149,20 @@ public class DocumentSelectActivity extends BaseFragment { ApplicationLoader.applicationContext.registerReceiver(receiver, filter); } - actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackButtonDrawable(new BackDrawable(false)); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { - finishFragment(); - } else if (id == -2) { + if (actionBar.isActionModeShowed()) { selectedFiles.clear(); actionBar.hideActionMode(); listView.invalidateViews(); + } else { + finishFragment(); + } } else if (id == done) { if (delegate != null) { ArrayList files = new ArrayList<>(); @@ -173,29 +176,19 @@ public class DocumentSelectActivity extends BaseFragment { actionModeViews.clear(); final ActionBarMenu actionMode = actionBar.createActionMode(); - actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + //actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - selectedMessagesCountTextView = new TextView(actionMode.getContext()); + selectedMessagesCountTextView = new NumberTextView(actionMode.getContext()); selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); selectedMessagesCountTextView.setTextColor(0xff737373); - selectedMessagesCountTextView.setSingleLine(true); - selectedMessagesCountTextView.setLines(1); - selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); - selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2)); - selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); - actionMode.addView(selectedMessagesCountTextView); - LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams(); - layoutParams.weight = 1; - layoutParams.width = 0; - layoutParams.height = LayoutHelper.MATCH_PARENT; - selectedMessagesCountTextView.setLayoutParams(layoutParams); + 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))); @@ -247,19 +240,15 @@ public class DocumentSelectActivity extends BaseFragment { return false; } selectedFiles.put(file.toString(), item); - selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + selectedMessagesCountTextView.setNumber(1, false); if (Build.VERSION.SDK_INT >= 11) { AnimatorSetProxy animatorSet = new AnimatorSetProxy(); ArrayList animators = new ArrayList<>(); for (int a = 0; a < actionModeViews.size(); a++) { View view2 = actionModeViews.get(a); AndroidUtilities.clearDrawableAnimation(view2); - if (a < 1) { - animators.add(ObjectAnimatorProxy.ofFloat(view2, "translationX", -AndroidUtilities.dp(56), 0)); - } else { animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f)); } - } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); @@ -334,7 +323,7 @@ public class DocumentSelectActivity extends BaseFragment { if (selectedFiles.isEmpty()) { actionBar.hideActionMode(); } else { - selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + selectedMessagesCountTextView.setNumber(selectedFiles.size(), true); } scrolling = false; if (view instanceof SharedDocumentCell) { @@ -362,6 +351,34 @@ public class DocumentSelectActivity extends BaseFragment { if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } + fixLayoutInternal(); + } + + @Override + public void onConfigurationChanged(android.content.res.Configuration newConfig) { + super.onConfigurationChanged(newConfig); + if (listView != null) { + ViewTreeObserver obs = listView.getViewTreeObserver(); + obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + listView.getViewTreeObserver().removeOnPreDrawListener(this); + fixLayoutInternal(); + return true; + } + }); + } + } + + private void fixLayoutInternal() { + if (selectedMessagesCountTextView == null) { + return; + } + if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + selectedMessagesCountTextView.setTextSize(18); + } else { + selectedMessagesCountTextView.setTextSize(20); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index 276323c4..df04f1b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index e9d157b1..67f086d0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -375,9 +375,11 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati } @Override - public void onOpenAnimationEnd() { - nameTextView.requestFocus(); - AndroidUtilities.showKeyboard(nameTextView); + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { + nameTextView.requestFocus(); + AndroidUtilities.showKeyboard(nameTextView); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java index 65af539e..389cb18b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupInviteActivity.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java index f695fda4..61b620d0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java index 65644594..6a8129eb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java index bc256657..45292363 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java index 1aafb3ac..a4578363 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -34,9 +34,9 @@ import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.ApplicationLoader; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; @@ -45,6 +45,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.HeaderCell; +import org.telegram.ui.Cells.LastSeenRadioCell; import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextSettingsCell; import org.telegram.ui.Components.LayoutHelper; @@ -59,6 +60,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter private int currentType = 0; private ArrayList currentPlus; private ArrayList currentMinus; + private int lastCheckedType = -1; private int lastSeenSectionRow; private int everybodyRow; @@ -184,6 +186,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter return; } doneButton.setVisibility(View.VISIBLE); + lastCheckedType = currentType; currentType = newType; updateRows(); } else if (i == neverShareRow || i == alwaysShareRow) { @@ -212,6 +215,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter } } doneButton.setVisibility(View.VISIBLE); + lastCheckedType = -1; listAdapter.notifyDataSetChanged(); } }); @@ -396,6 +400,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter @Override public void onResume() { super.onResume(); + lastCheckedType = -1; if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } @@ -459,20 +464,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter view.setBackgroundColor(0xffffffff); } TextSettingsCell textCell = (TextSettingsCell) view; - Drawable check = mContext.getResources().getDrawable(R.drawable.check_blue); - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int color = preferences.getInt("themeColor", AndroidUtilities.defColor); - check.setColorFilter(color, PorterDuff.Mode.SRC_IN); - if (i == everybodyRow) { - //textCell.setTextAndIcon(LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody), currentType == 0 ? R.drawable.check_blue : 0, true); - textCell.setTextAndIcon(LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody), currentType == 0 ? check : null, true); - } else if (i == myContactsRow) { - //textCell.setTextAndIcon(LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts), currentType == 2 ? R.drawable.check_blue : 0, true); - textCell.setTextAndIcon(LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts), currentType == 2 ? check : null, true); - } else if (i == nobodyRow) { - //textCell.setTextAndIcon(LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody), currentType == 1 ? R.drawable.check_blue : 0, false); - textCell.setTextAndIcon(LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody), currentType == 1 ? check : null, false); - } else if (i == alwaysShareRow) { + if (i == alwaysShareRow) { String value; if (currentPlus.size() != 0) { value = LocaleController.formatPluralString("Users", currentPlus.size()); @@ -511,25 +503,49 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter } else if (i == shareSectionRow) { ((HeaderCell) view).setText(LocaleController.getString("AddExceptions", R.string.AddExceptions)); } + } else if (type == 3) { + if (view == null) { + view = new LastSeenRadioCell(mContext); + view.setBackgroundColor(0xffffffff); + } + LastSeenRadioCell textCell = (LastSeenRadioCell) view; + int checkedType = 0; + if (i == everybodyRow) { + textCell.setText(LocaleController.getString("LastSeenEverybody", R.string.LastSeenEverybody), lastCheckedType == 0, true); + checkedType = 0; + } else if (i == myContactsRow) { + textCell.setText(LocaleController.getString("LastSeenContacts", R.string.LastSeenContacts), lastCheckedType == 2, true); + checkedType = 2; + } else if (i == nobodyRow) { + textCell.setText(LocaleController.getString("LastSeenNobody", R.string.LastSeenNobody), lastCheckedType == 1, false); + checkedType = 1; + } + if (lastCheckedType == checkedType) { + textCell.setChecked(false, true); + } else if (currentType == checkedType) { + textCell.setChecked(true, true); + } } return view; } @Override public int getItemViewType(int i) { - if (i == alwaysShareRow || i == neverShareRow || i == everybodyRow || i == myContactsRow || i == nobodyRow) { + if (i == alwaysShareRow || i == neverShareRow) { return 0; } else if (i == shareDetailRow || i == lastSeenDetailRow) { return 1; } else if (i == lastSeenSectionRow || i == shareSectionRow) { return 2; + } else if (i == everybodyRow || i == myContactsRow || i == nobodyRow) { + return 3; } return 0; } @Override public int getViewTypeCount() { - return 3; + return 4; } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java index 7b4f6d4a..a78e744c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 502663db..d95da0a2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -1,13 +1,14 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; +import android.annotation.TargetApi; import android.app.Activity; import android.app.AlertDialog; import android.app.ProgressDialog; @@ -15,6 +16,7 @@ import android.content.ContentResolver; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.Cursor; import android.graphics.Point; @@ -26,7 +28,6 @@ import android.provider.Browser; import android.provider.ContactsContract; import android.support.annotation.NonNull; import android.view.ActionMode; -import android.view.Gravity; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -47,7 +48,9 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildConfig; import org.telegram.messenger.ChatObject; +import org.telegram.messenger.ContactsController; import org.telegram.messenger.FileLog; +import org.telegram.messenger.ImageLoader; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; @@ -66,7 +69,6 @@ import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.Adapters.DrawerLayoutAdapter; -import org.telegram.ui.Components.DrawerPlayerView; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.PasscodeView; @@ -271,22 +273,24 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa drawerLayoutContainer.addView(actionBarLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } - FrameLayout listViewContainer = new FrameLayout(this); - listViewContainer.setBackgroundColor(0xffffffff); - drawerLayoutContainer.setDrawerLayout(listViewContainer); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listViewContainer.getLayoutParams(); - Point screenSize = AndroidUtilities.getRealScreenSize(); - layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56); - layoutParams.height = LayoutHelper.MATCH_PARENT; - listViewContainer.setLayoutParams(layoutParams); - - ListView listView = new ListView(this); + ListView listView = new ListView(this) { + @Override + public boolean hasOverlappingRendering() { + return false; + } + }; + listView.setBackgroundColor(0xffffffff); listView.setAdapter(drawerLayoutAdapter = new DrawerLayoutAdapter(this)); listView.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); - listViewContainer.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); + drawerLayoutContainer.setDrawerLayout(listView); + FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); + Point screenSize = AndroidUtilities.getRealScreenSize(); + layoutParams.width = AndroidUtilities.isTablet() ? AndroidUtilities.dp(320) : Math.min(screenSize.x, screenSize.y) - AndroidUtilities.dp(56); + layoutParams.height = LayoutHelper.MATCH_PARENT; + listView.setLayoutParams(layoutParams); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override @@ -388,16 +392,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } }); - DrawerPlayerView drawerPlayerView = new DrawerPlayerView(this, listView); - listViewContainer.addView(drawerPlayerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.LEFT | Gravity.BOTTOM)); - drawerPlayerView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - actionBarLayout.presentFragment(new AudioPlayerActivity()); - drawerLayoutContainer.closeDrawer(false); - } - }); - drawerLayoutContainer.setParentActionBarLayout(actionBarLayout); actionBarLayout.setDrawerLayoutContainer(drawerLayoutContainer); actionBarLayout.init(mainFragmentsStack); @@ -511,10 +505,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false); } - /*if (BuildVars.DEBUG_VERSION) { - ViewServer.get(this).addWindow(this); - }*/ - handleIntent(getIntent(), false, savedInstanceState != null, false); needLayout(); } @@ -563,6 +553,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa Integer push_chat_id = 0; Integer push_enc_id = 0; Integer open_settings = 0; + long dialogId = intent != null && intent.getExtras() != null ? intent.getExtras().getLong("dialogId", 0) : 0; boolean showDialogsList = false; boolean showPlayer = false; @@ -784,6 +775,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa String botUser = null; String botChat = null; String message = null; + boolean hasUrl = false; String scheme = data.getScheme(); if (scheme != null) { if ((scheme.equals("http") || scheme.equals("https"))) { @@ -797,8 +789,17 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } else if (path.startsWith("addstickers/")) { sticker = path.replace("addstickers/", ""); } else if (path.startsWith("msg/")) { - message = data.getQueryParameter("text"); - message += " " + data.getQueryParameter("url"); + message = data.getQueryParameter("url"); + if (message == null) { + message = ""; + } + if (data.getQueryParameter("text") != null) { + if (message.length() > 0) { + hasUrl = true; + message += "\n"; + } + message += data.getQueryParameter("text"); + } } else if (path.length() >= 5) { username = data.getLastPathSegment(); botUser = data.getQueryParameter("start"); @@ -825,13 +826,22 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } else if (url.startsWith("tg:msg") || url.startsWith("tg://msg")) { url = url.replace("tg:msg", "tg://telegram.org").replace("tg://msg", "tg://telegram.org"); data = Uri.parse(url); - message = data.getQueryParameter("text"); - message += " " + data.getQueryParameter("url"); + message = data.getQueryParameter("url"); + if (message == null) { + message = ""; + } + if (data.getQueryParameter("text") != null) { + if (message.length() > 0) { + hasUrl = true; + message += "\n"; + } + message += data.getQueryParameter("text"); + } } } } if (username != null || group != null || sticker != null || message != null) { - runLinkRequest(username, group, sticker, botUser, botChat, message, 0); + runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl, 0); } else { try { Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null); @@ -935,6 +945,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (!AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); } + if (dialogId == 0) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); args.putString("selectAlertString", LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo)); @@ -960,6 +971,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } else { drawerLayoutContainer.setAllowOpenDrawer(true, false); } + } else { + didSelectDialog(null, dialogId, false); + } } else if (open_settings != 0) { actionBarLayout.presentFragment(new SettingsActivity(), false, true, true); if (AndroidUtilities.isTablet()) { @@ -1009,7 +1023,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa return false; } - private void runLinkRequest(final String username, final String group, final String sticker, final String botUser, final String botChat, final String message, final int state) { + 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 int state) { final ProgressDialog progressDialog = new ProgressDialog(this); progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); @@ -1129,7 +1143,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - runLinkRequest(username, group, sticker, botUser, botChat, message, 1); + runLinkRequest(username, group, sticker, botUser, botChat, message, hasUrl, 1); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); @@ -1219,6 +1233,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa editor.commit(); Bundle args = new Bundle(); args.putBoolean("scrollToTopOnResume", true); + args.putBoolean("hasUrl", hasUrl); int lower_part = (int) did; int high_id = (int) (did >> 32); if (lower_part != 0) { @@ -1237,7 +1252,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa actionBarLayout.presentFragment(new ChatActivity(args), true, false, true); } }); - presentFragment(fragment); + presentFragment(fragment, false, true); } if (requestId != 0) { @@ -1289,7 +1304,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } @Override - public void didSelectDialog(DialogsActivity messageFragment, long dialog_id, boolean param) { + public void didSelectDialog(DialogsActivity dialogsFragment, long dialog_id, boolean param) { if (dialog_id != 0) { int lower_part = (int)dialog_id; int high_id = (int)(dialog_id >> 32); @@ -1318,24 +1333,21 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if(android.os.Build.VERSION.SDK_INT >= 16) { if (AndroidUtilities.isTablet()) { actionBarLayout.presentFragment(fragment, false, true, true); - } - - if (!AndroidUtilities.isTablet()) { + } else { actionBarLayout.addFragmentToStack(fragment, actionBarLayout.fragmentsStack.size() - 1); } - if (!fragment.openVideoEditor(videoPath, true, false)) { + if (!fragment.openVideoEditor(videoPath, dialogsFragment != null, false) && dialogsFragment != null) { if (!AndroidUtilities.isTablet()) { - messageFragment.finishFragment(true); + dialogsFragment.finishFragment(true); } } } else { - actionBarLayout.presentFragment(fragment, true); + actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true); SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null, true); } } else { - - actionBarLayout.presentFragment(fragment, true); + actionBarLayout.presentFragment(fragment, dialogsFragment != null, dialogsFragment == null, true); if (sendingText != null) { SendMessagesHelper.prepareSendingText(sendingText, dialog_id, true); @@ -1392,13 +1404,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa public void needLayout() { if (AndroidUtilities.isTablet()) { - 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; layersActionBarLayout.setLayoutParams(relativeLayoutParams); + if (!AndroidUtilities.isSmallTablet() || getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { tabletFullSize = false; int leftWidth = AndroidUtilities.displaySize.x / 100 * 35; @@ -1451,7 +1463,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa BaseFragment chatFragment = rightActionBarLayout.fragmentsStack.get(0); chatFragment.onPause(); rightActionBarLayout.fragmentsStack.remove(0); - actionBarLayout.addFragmentToStack(chatFragment); + actionBarLayout.fragmentsStack.add(chatFragment); + //actionBarLayout.addFragmentToStack(chatFragment); if (passcodeView.getVisibility() != View.VISIBLE) { actionBarLayout.showLastFragment(); } @@ -1461,7 +1474,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } public void fixLayout() { - if (AndroidUtilities.isTablet()) { + if (!AndroidUtilities.isTablet()) { + return; + } if (actionBarLayout == null) { return; } @@ -1479,7 +1494,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } }); } - } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { @@ -1504,16 +1518,73 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa } } + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == 3 || requestCode == 4 || requestCode == 5) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + if (requestCode == 4) { + ImageLoader.getInstance().createMediaPaths(); + } else if (requestCode == 5) { + ContactsController.getInstance().readContacts(); + } + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + if (requestCode == 3) { + builder.setMessage(LocaleController.getString("PermissionNoAudio", R.string.PermissionNoAudio)); + } else if (requestCode == 4) { + builder.setMessage(LocaleController.getString("PermissionStorage", R.string.PermissionStorage)); + } else if (requestCode == 5) { + builder.setMessage(LocaleController.getString("PermissionContacts", R.string.PermissionContacts)); + } + builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() { + @TargetApi(Build.VERSION_CODES.GINGERBREAD) + @Override + public void onClick(DialogInterface dialog, int which) { + try { + Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName())); + startActivity(intent); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + builder.show(); + return; + } + if (actionBarLayout.fragmentsStack.size() != 0) { + BaseFragment fragment = actionBarLayout.fragmentsStack.get(actionBarLayout.fragmentsStack.size() - 1); + fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults); + } + if (AndroidUtilities.isTablet()) { + if (rightActionBarLayout.fragmentsStack.size() != 0) { + BaseFragment fragment = rightActionBarLayout.fragmentsStack.get(rightActionBarLayout.fragmentsStack.size() - 1); + fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults); + } + if (layersActionBarLayout.fragmentsStack.size() != 0) { + BaseFragment fragment = layersActionBarLayout.fragmentsStack.get(layersActionBarLayout.fragmentsStack.size() - 1); + fragment.onRequestPermissionsResultFragment(requestCode, permissions, grantResults); + } + } + } + @Override protected void onPause() { super.onPause(); + ApplicationLoader.mainInterfacePaused = true; onPasscodePause(); actionBarLayout.onPause(); if (AndroidUtilities.isTablet()) { rightActionBarLayout.onPause(); layersActionBarLayout.onPause(); } - ApplicationLoader.mainInterfacePaused = true; + if (passcodeView != null) { + passcodeView.onPause(); + } ConnectionsManager.getInstance().setAppPaused(true, false); AndroidUtilities.unregisterUpdates(); } @@ -1538,6 +1609,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override protected void onResume() { super.onResume(); + ApplicationLoader.mainInterfacePaused = false; onPasscodeResume(); if (passcodeView.getVisibility() != View.VISIBLE) { actionBarLayout.onResume(); @@ -1551,7 +1623,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa AndroidUtilities.checkForCrashes(this); AndroidUtilities.checkForUpdates(this); AndroidUtilities.checkForThemes(this); - ApplicationLoader.mainInterfacePaused = false; ConnectionsManager.getInstance().setAppPaused(false, false); updateCurrentConnectionState(); if (PhotoViewer.getInstance().isVisible()) { @@ -1622,7 +1693,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public void onClick(DialogInterface dialogInterface, int i) { try { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://telegram.org/faq#can-39t-send-messages-to-non-contacts")); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(LocaleController.getString("NobodyLikesSpamUrl", R.string.NobodyLikesSpamUrl))); intent.putExtra(Browser.EXTRA_APPLICATION_ID, getPackageName()); startActivity(intent); } catch (Exception e) { @@ -1788,6 +1859,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public void onActionModeStarted(ActionMode mode) { super.onActionModeStarted(mode); + if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) { + return; + } actionBarLayout.onActionModeStarted(mode); if (AndroidUtilities.isTablet()) { rightActionBarLayout.onActionModeStarted(mode); @@ -1798,6 +1872,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public void onActionModeFinished(ActionMode mode) { super.onActionModeFinished(mode); + if (Build.VERSION.SDK_INT >= 23 && mode.getType() == ActionMode.TYPE_FLOATING) { + return; + } actionBarLayout.onActionModeFinished(mode); if (AndroidUtilities.isTablet()) { rightActionBarLayout.onActionModeFinished(mode); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java index c8a8efc7..d3cb2278 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java @@ -1,18 +1,24 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; +import android.Manifest; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.StateListAnimator; +import android.annotation.TargetApi; +import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager; import android.graphics.Outline; import android.location.Location; import android.location.LocationManager; @@ -90,6 +96,8 @@ public class LocationActivity extends BaseFragment implements NotificationCenter private AnimatorSet animatorSet; + private boolean checkPermission = true; + private boolean searching; private boolean searchWas; @@ -117,11 +125,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter void didSelectLocation(TLRPC.MessageMedia location); } - @Override - public boolean needAddActionBar() { - return messageObject != null; - } - @Override public boolean onFragmentCreate() { super.onFragmentCreate(); @@ -156,6 +159,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } + actionBar.setAddToContainer(messageObject != null); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override @@ -293,7 +297,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter if (userLocation != null) { LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude()); if (googleMap != null) { - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); + CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4); googleMap.animateCamera(position); } } @@ -333,7 +337,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter } catch (Exception e) { FileLog.e("tmessages", e); } - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); + CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4); googleMap.moveCamera(position); } @@ -372,8 +376,17 @@ public class LocationActivity extends BaseFragment implements NotificationCenter locationButton.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(); + return; + } + } + } if (myLocation != null && googleMap != null) { - googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()), googleMap.getMaxZoomLevel() - 8)); + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(myLocation.getLatitude(), myLocation.getLongitude()), googleMap.getMaxZoomLevel() - 4)); } } }); @@ -516,6 +529,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter locationButton.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(); + return; + } + } + } if (myLocation != null && googleMap != null) { if (Build.VERSION.SDK_INT >= 11) { AnimatorSet animatorSet = new AnimatorSet(); @@ -614,21 +636,50 @@ public class LocationActivity extends BaseFragment implements NotificationCenter return fragmentView; } - @Override - public void onOpenAnimationEnd() { - try { - if (mapView.getParent() instanceof ViewGroup) { - ViewGroup viewGroup = (ViewGroup) mapView.getParent(); - viewGroup.removeView(mapView); - } - } catch (Exception e) { - FileLog.e("tmessages", e); + private void showPermissionAlert() { + if (getParentActivity() == null) { + return; } - if (mapViewClip != null) { - mapViewClip.addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT)); - updateClipView(listView.getFirstVisiblePosition()); - } else { - ((FrameLayout) fragmentView).addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + 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 + public void onClick(DialogInterface dialog, int which) { + if (getParentActivity() == null) { + return; + } + try { + Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName())); + getParentActivity().startActivity(intent); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + showDialog(builder.create()); + } + + @Override + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen) { + try { + if (mapView.getParent() instanceof ViewGroup) { + ViewGroup viewGroup = (ViewGroup) mapView.getParent(); + viewGroup.removeView(mapView); + } + } catch (Exception e) { + FileLog.e("tmessages", e); + } + if (mapViewClip != null) { + mapViewClip.addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT)); + updateClipView(listView.getFirstVisiblePosition()); + } else { + ((FrameLayout) fragmentView).addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); + } } } @@ -820,7 +871,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter googleMap.animateCamera(position); } else { firstWas = true; - CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8); + CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 4); googleMap.moveCamera(position); } } @@ -864,6 +915,15 @@ public class LocationActivity extends BaseFragment implements NotificationCenter } updateUserData(); fixLayoutInternal(true); + if (checkPermission && Build.VERSION.SDK_INT >= 23) { + Activity activity = getParentActivity(); + if (activity != null) { + checkPermission = false; + if (activity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { + activity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 2); + } + } + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java index c105e5d8..0ba35870 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -35,9 +35,7 @@ import android.text.method.PasswordTransformationMethod; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; -import android.view.LayoutInflater; import android.view.View; -import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.widget.AdapterView; @@ -49,21 +47,22 @@ import android.widget.TextView; import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; +import org.telegram.messenger.BuildConfig; +import org.telegram.messenger.BuildVars; import org.telegram.messenger.ContactsController; +import org.telegram.messenger.FileLog; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.ApplicationLoader; -import org.telegram.messenger.BuildVars; -import org.telegram.messenger.FileLog; -import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; +import org.telegram.messenger.UserConfig; +import org.telegram.messenger.Utilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; -import org.telegram.messenger.UserConfig; -import org.telegram.messenger.Utilities; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.BaseFragment; @@ -761,7 +760,7 @@ public class LoginActivity extends BaseFragment { if (countryState == 1) { needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); return; - } else if (countryState == 2 && !BuildVars.DEBUG_VERSION) { + } else if (countryState == 2 && !BuildConfig.DEBUG){//!BuildVars.DEBUG_VERSION) { needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("WrongCountry", R.string.WrongCountry)); return; } @@ -769,6 +768,7 @@ public class LoginActivity extends BaseFragment { needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber)); return; } + ConnectionsManager.getInstance().cleanUp(); TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode(); String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index ec374ade..66661d85 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -59,6 +59,7 @@ import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; 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.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseSectionsAdapter; @@ -73,6 +74,8 @@ import org.telegram.ui.Cells.SharedPhotoVideoCell; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.NumberTextView; +import org.telegram.ui.Components.PlayerView; import org.telegram.ui.Components.SectionsListView; import org.telegram.ui.Components.WebFrameLayout; @@ -88,7 +91,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No private SharedPhotoVideoAdapter photoVideoAdapter; private SharedLinksAdapter linksAdapter; private SharedDocumentsAdapter documentsAdapter; + private SharedDocumentsAdapter audioAdapter; private MediaSearchAdapter documentsSearchAdapter; + private MediaSearchAdapter audioSearchAdapter; private MediaSearchAdapter linksSearchAdapter; private SectionsListView listView; private LinearLayout progressView; @@ -98,7 +103,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No private TextView dropDown; private ActionBarMenuItem dropDownContainer; private ActionBarMenuItem searchItem; - private TextView selectedMessagesCountTextView; + private NumberTextView selectedMessagesCountTextView; private ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout; private ArrayList cellCache = new ArrayList<>(6); @@ -186,15 +191,17 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } } - private SharedMediaData sharedMediaData[] = new SharedMediaData[4]; + private SharedMediaData sharedMediaData[] = new SharedMediaData[5]; private final static int shared_media_item = 1; private final static int files_item = 2; private final static int links_item = 5; - private final static int quoteforward = 33; + private final static int music_item = 6; private final static int forward = 3; private final static int delete = 4; +private final static int quoteforward = 33; + public MediaActivity(Bundle args) { super(args); } @@ -227,26 +234,29 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public View createView(Context context) { - actionBar.setBackButtonImage(R.drawable.ic_ab_back); + actionBar.setBackButtonDrawable(new BackDrawable(false)); actionBar.setTitle(""); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { + if (actionBar.isActionModeShowed()) { + selectedFiles.clear(); + cantDeleteMessagesCount = 0; + actionBar.hideActionMode(); + listView.invalidateViews(); + } else { if (Build.VERSION.SDK_INT < 11 && listView != null) { listView.setAdapter(null); listView = null; photoVideoAdapter = null; documentsAdapter = null; + audioAdapter = null; linksAdapter = null; } finishFragment(); - } else if (id == -2) { - selectedFiles.clear(); - cantDeleteMessagesCount = 0; - actionBar.hideActionMode(); - listView.invalidateViews(); + } } else if (id == shared_media_item) { if (selectedMode == 0) { return; @@ -265,6 +275,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } selectedMode = 3; switchToCurrentSelectedMode(); + } else if (id == music_item) { + if (selectedMode == 4) { + return; + } + selectedMode = 4; + switchToCurrentSelectedMode(); } else if (id == delete) { if (getParentActivity() == null) { return; @@ -377,6 +393,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No documentsSearchAdapter.search(null); } else if (selectedMode == 3) { linksSearchAdapter.search(null); + } else if (selectedMode == 4) { + audioSearchAdapter.search(null); } searching = false; searchWas = false; @@ -400,6 +418,11 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No return; } linksSearchAdapter.search(text); + } else if (selectedMode == 4) { + if (audioSearchAdapter == null) { + return; + } + audioSearchAdapter.search(text); } } }); @@ -412,8 +435,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0); if ((int) dialog_id != 0) { dropDownContainer.addSubItem(links_item, LocaleController.getString("LinksTitle", R.string.LinksTitle), 0); + dropDownContainer.addSubItem(music_item, LocaleController.getString("AudioTitle", R.string.AudioTitle), 0); } - actionBar.addView(dropDownContainer, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 64 : 56, 0, 40, 0)); + actionBar.addView(dropDownContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 64 : 56, 0, 40, 0)); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -435,24 +459,19 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No dropDownContainer.addView(dropDown, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 16, 0, 0, 0)); final ActionBarMenu actionMode = actionBar.createActionMode(); - actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); + //actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); - selectedMessagesCountTextView = new TextView(actionMode.getContext()); + selectedMessagesCountTextView = new NumberTextView(actionMode.getContext()); selectedMessagesCountTextView.setTextSize(18); selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); selectedMessagesCountTextView.setTextColor(0xff737373); - selectedMessagesCountTextView.setSingleLine(true); - selectedMessagesCountTextView.setLines(1); - selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END); - selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2)); - selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL); selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); - actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f)); + actionMode.addView(selectedMessagesCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 65, 0, 0, 0)); if ((int) dialog_id != 0) { actionModeViews.add(actionMode.addItem(quoteforward, R.drawable.ic_ab_fwd_quoteforward, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); @@ -461,8 +480,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54))); photoVideoAdapter = new SharedPhotoVideoAdapter(context); - documentsAdapter = new SharedDocumentsAdapter(context); + documentsAdapter = new SharedDocumentsAdapter(context, 1); + audioAdapter = new SharedDocumentsAdapter(context, 4); documentsSearchAdapter = new MediaSearchAdapter(context, 1); + audioSearchAdapter = new MediaSearchAdapter(context, 4); linksSearchAdapter = new MediaSearchAdapter(context, 3); linksAdapter = new SharedLinksAdapter(context); @@ -478,7 +499,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, final int i, long l) { - if (selectedMode == 1 && view instanceof SharedDocumentCell) { + if ((selectedMode == 1 || selectedMode == 4) && view instanceof SharedDocumentCell) { MediaActivity.this.onItemClick(i, view, ((SharedDocumentCell) view).getDocument(), 0); } else if (selectedMode == 3 && view instanceof SharedLinkCell) { MediaActivity.this.onItemClick(i, view, ((SharedLinkCell) view).getMessage(), 0); @@ -508,6 +529,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No type = SharedMediaQuery.MEDIA_FILE; } else if (selectedMode == 2) { type = SharedMediaQuery.MEDIA_AUDIO; + } else if (selectedMode == 4) { + type = SharedMediaQuery.MEDIA_MUSIC; } else { type = SharedMediaQuery.MEDIA_URL; } @@ -518,7 +541,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView parent, View view, int i, long id) { - if (selectedMode == 1 && view instanceof SharedDocumentCell) { + if ((selectedMode == 1 || selectedMode == 4) && view instanceof SharedDocumentCell) { SharedDocumentCell cell = (SharedDocumentCell) view; MessageObject message = cell.getDocument(); return MediaActivity.this.onItemLongClick(message, view, 0); @@ -570,6 +593,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No switchToCurrentSelectedMode(); + if (!AndroidUtilities.isTablet()) { + frameLayout.addView(new PlayerView(context, this), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); + } + return fragmentView; } @@ -610,8 +637,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (linksAdapter != null) { linksAdapter.notifyDataSetChanged(); } + } else if (selectedMode == 4 && type == 4) { + if (audioAdapter != null) { + audioAdapter.notifyDataSetChanged(); + } } - if (selectedMode == 1 || selectedMode == 3) { + if (selectedMode == 1 || selectedMode == 3 || selectedMode == 4) { searchItem.setVisibility(!sharedMediaData[selectedMode].messages.isEmpty() && !searching ? View.VISIBLE : View.GONE); } } @@ -648,7 +679,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (linksAdapter != null) { linksAdapter.notifyDataSetChanged(); } - if (selectedMode == 1 || selectedMode == 3) { + if (audioAdapter != null) { + audioAdapter.notifyDataSetChanged(); + } + if (selectedMode == 1 || selectedMode == 3 || selectedMode == 4) { searchItem.setVisibility(!sharedMediaData[selectedMode].messages.isEmpty() && !searching ? View.VISIBLE : View.GONE); } } @@ -681,7 +715,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (linksAdapter != null) { linksAdapter.notifyDataSetChanged(); } - if (selectedMode == 1 || selectedMode == 3) { + if (audioAdapter != null) { + audioAdapter.notifyDataSetChanged(); + } + if (selectedMode == 1 || selectedMode == 3 || selectedMode == 4) { searchItem.setVisibility(!sharedMediaData[selectedMode].messages.isEmpty() && !searching ? View.VISIBLE : View.GONE); } } @@ -792,7 +829,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No public void setPhotoChecked(int index) { } @Override - public void cancelButtonPressed() { } + public boolean cancelButtonPressed() { return true; } @Override public void sendButtonPressed(int index) { } @@ -809,6 +846,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } else if (selectedMode == 3) { listView.setAdapter(linksSearchAdapter); linksSearchAdapter.notifyDataSetChanged(); + } else if (selectedMode == 4) { + listView.setAdapter(audioSearchAdapter); + audioSearchAdapter.notifyDataSetChanged(); } } if (emptyTextView != null) { @@ -835,15 +875,22 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } listView.setVisibility(View.VISIBLE); listView.setPadding(0, 0, 0, AndroidUtilities.dp(4)); - } else if (selectedMode == 1) { + } else if (selectedMode == 1 || selectedMode == 4) { + if (selectedMode == 1) { listView.setAdapter(documentsAdapter); dropDown.setText(LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle)); emptyImageView.setImageResource(R.drawable.tip2); emptyTextView.setText(LocaleController.getString("NoSharedFiles", R.string.NoSharedFiles)); + } else if (selectedMode == 4) { + listView.setAdapter(audioAdapter); + dropDown.setText(LocaleController.getString("AudioTitle", R.string.AudioTitle)); + emptyImageView.setImageResource(R.drawable.tip4); + emptyTextView.setText(LocaleController.getString("NoSharedAudio", R.string.NoSharedAudio)); + } searchItem.setVisibility(!sharedMediaData[selectedMode].messages.isEmpty() ? View.VISIBLE : View.GONE); if (!sharedMediaData[selectedMode].loading && !sharedMediaData[selectedMode].endReached && sharedMediaData[selectedMode].messages.isEmpty()) { sharedMediaData[selectedMode].loading = true; - SharedMediaQuery.loadMedia(dialog_id, 0, 50, 0, SharedMediaQuery.MEDIA_FILE, true, classGuid); + SharedMediaQuery.loadMedia(dialog_id, 0, 50, 0, selectedMode == 1 ? SharedMediaQuery.MEDIA_FILE : SharedMediaQuery.MEDIA_MUSIC, true, classGuid); } listView.setVisibility(View.VISIBLE); if (sharedMediaData[selectedMode].loading && sharedMediaData[selectedMode].messages.isEmpty()) { @@ -888,19 +935,15 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No cantDeleteMessagesCount++; } actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); - selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + selectedMessagesCountTextView.setNumber(1, false); if (Build.VERSION.SDK_INT >= 11) { AnimatorSetProxy animatorSet = new AnimatorSetProxy(); ArrayList animators = new ArrayList<>(); for (int i = 0; i < actionModeViews.size(); i++) { View view2 = actionModeViews.get(i); AndroidUtilities.clearDrawableAnimation(view2); - if (i < 1) { - animators.add(ObjectAnimatorProxy.ofFloat(view2, "translationX", -AndroidUtilities.dp(56), 0)); - } else { animators.add(ObjectAnimatorProxy.ofFloat(view2, "scaleY", 0.1f, 1.0f)); } - } animatorSet.playTogether(animators); animatorSet.setDuration(250); animatorSet.start(); @@ -936,7 +979,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (selectedFiles.isEmpty()) { actionBar.hideActionMode(); } else { - selectedMessagesCountTextView.setText(String.format("%d", selectedFiles.size())); + selectedMessagesCountTextView.setNumber(selectedFiles.size(), true); } actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE); scrolling = false; @@ -951,12 +994,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (selectedMode == 0) { PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(sharedMediaData[selectedMode].messages, index, this); - } else if (selectedMode == 1) { + } else if (selectedMode == 1 || selectedMode == 4) { if (view instanceof SharedDocumentCell) { SharedDocumentCell cell = (SharedDocumentCell) view; if (cell.isLoaded()) { if (message.isMusic()) { - if (MediaController.getInstance().setPlaylist(sharedMediaData[1].messages, message)) { + if (MediaController.getInstance().setPlaylist(sharedMediaData[selectedMode].messages, message)) { return; } } @@ -1062,6 +1105,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); + if (!AndroidUtilities.isTablet() && ApplicationLoader.applicationContext.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { + selectedMessagesCountTextView.setTextSize(18); + } else { + selectedMessagesCountTextView.setTextSize(20); + } + if (AndroidUtilities.isTablet()) { columnsCount = 4; emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128)); @@ -1197,10 +1246,13 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } private class SharedDocumentsAdapter extends BaseSectionsAdapter { - private Context mContext; - public SharedDocumentsAdapter(Context context) { + private Context mContext; + private int currentType; + + public SharedDocumentsAdapter(Context context, int type) { mContext = context; + currentType = type; } @Override @@ -1215,13 +1267,13 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public int getSectionCount() { - return sharedMediaData[1].sections.size() + (sharedMediaData[1].sections.isEmpty() || sharedMediaData[1].endReached ? 0 : 1); + return sharedMediaData[currentType].sections.size() + (sharedMediaData[currentType].sections.isEmpty() || sharedMediaData[currentType].endReached ? 0 : 1); } @Override public int getCountForSection(int section) { - if (section < sharedMediaData[1].sections.size()) { - return sharedMediaData[1].sectionArrays.get(sharedMediaData[1].sections.get(section)).size() + 1; + if (section < sharedMediaData[currentType].sections.size()) { + return sharedMediaData[currentType].sectionArrays.get(sharedMediaData[currentType].sections.get(section)).size() + 1; } return 1; } @@ -1231,9 +1283,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No if (convertView == null) { convertView = new GreySectionCell(mContext); } - if (section < sharedMediaData[1].sections.size()) { - String name = sharedMediaData[1].sections.get(section); - ArrayList messageObjects = sharedMediaData[1].sectionArrays.get(name); + if (section < sharedMediaData[currentType].sections.size()) { + String name = sharedMediaData[currentType].sections.get(section); + ArrayList messageObjects = sharedMediaData[currentType].sectionArrays.get(name); MessageObject messageObject = messageObjects.get(0); ((GreySectionCell) convertView).setText(LocaleController.formatterMonthYear.format((long) messageObject.messageOwner.date * 1000).toUpperCase()); } @@ -1242,9 +1294,9 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public View getItemView(int section, int position, View convertView, ViewGroup parent) { - if (section < sharedMediaData[1].sections.size()) { - String name = sharedMediaData[1].sections.get(section); - ArrayList messageObjects = sharedMediaData[1].sectionArrays.get(name); + if (section < sharedMediaData[currentType].sections.size()) { + String name = sharedMediaData[currentType].sections.get(section); + ArrayList messageObjects = sharedMediaData[currentType].sectionArrays.get(name); if (position == 0) { if (convertView == null) { convertView = new GreySectionCell(mContext); @@ -1257,7 +1309,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No } SharedDocumentCell sharedDocumentCell = (SharedDocumentCell) convertView; MessageObject messageObject = messageObjects.get(position - 1); - sharedDocumentCell.setDocument(messageObject, position != messageObjects.size() || section == sharedMediaData[1].sections.size() - 1 && sharedMediaData[1].loading); + sharedDocumentCell.setDocument(messageObject, position != messageObjects.size() || section == sharedMediaData[currentType].sections.size() - 1 && sharedMediaData[currentType].loading); if (actionBar.isActionModeShowed()) { sharedDocumentCell.setChecked(selectedFiles.containsKey(messageObject.getId()), !scrolling); } else { @@ -1274,7 +1326,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public int getItemViewType(int section, int position) { - if (section < sharedMediaData[1].sections.size()) { + if (section < sharedMediaData[currentType].sections.size()) { if (position == 0) { return 0; } else { @@ -1452,6 +1504,8 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No req.filter = new TLRPC.TL_inputMessagesFilterDocument(); } else if (currentType == 3) { req.filter = new TLRPC.TL_inputMessagesFilterUrl(); + } else if (currentType == 4) { + req.filter = new TLRPC.TL_inputMessagesFilterAudioDocuments(); } req.q = query; req.peer = MessagesController.getInputPeer(uid); @@ -1517,16 +1571,16 @@ 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()); } else if (currentType == 3) { queryServerSearch(query, 0); } } - if (currentType == 1) { + if (currentType == 1 || currentType == 4) { final ArrayList copy = new ArrayList<>(); - copy.addAll(sharedMediaData[1].messages); + copy.addAll(sharedMediaData[currentType].messages); Utilities.searchQueue.postRunnable(new Runnable() { @Override public void run() { @@ -1542,7 +1596,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No String search[] = new String[1 + (search2 != null ? 1 : 0)]; search[0] = search1; if (search2 != null) { - search[1] = search2; + search[currentType] = search2; } ArrayList resultArray = new ArrayList<>(); @@ -1631,7 +1685,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No @Override public View getView(int i, View view, ViewGroup viewGroup) { - if (currentType == 1) { + if (currentType == 1 || currentType == 4) { if (view == null) { view = new SharedDocumentCell(mContext); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java index abe53a11..e6326bcd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -56,6 +56,7 @@ import org.telegram.ui.Components.ColorPickerView; import org.telegram.ui.Components.LayoutHelper; public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { + private ListView listView; private boolean reseting = false; @@ -192,7 +193,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif listView.setAdapter(new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override - public void onItemClick(AdapterView adapterView, View view, final int i, long l) { + public void onItemClick(AdapterView adapterView, final View view, final int i, long l) { boolean enabled = false; if (i == messageAlertRow || i == groupAlertRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); @@ -362,7 +363,12 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif listView.invalidateViews(); } }); - builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ((TextCheckCell) view).setChecked(true); + } + }); showDialog(builder.create()); } } else if (i == messageLedRow || i == groupLedRow) { @@ -390,13 +396,15 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif public void onClick(DialogInterface dialogInterface, int which) { final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); + TextColorCell textCell = (TextColorCell) view; if (i == messageLedRow) { editor.putInt("MessagesLed", colorPickerView.getColor()); + textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), colorPickerView.getColor(), true); } else if (i == groupLedRow) { editor.putInt("GroupLed", colorPickerView.getColor()); + textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), colorPickerView.getColor(), true); } editor.commit(); - listView.invalidateViews(); } }); builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled), new DialogInterface.OnClickListener() { @@ -404,10 +412,13 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif public void onClick(DialogInterface dialog, int which) { final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); + TextColorCell textCell = (TextColorCell) view; if (i == messageLedRow) { editor.putInt("MessagesLed", 0); + textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), 0, true); } else if (i == groupLedRow) { editor.putInt("GroupLed", 0); + textCell.setTextAndColor(LocaleController.getString("LedColor", R.string.LedColor), 0, true); } editor.commit(); listView.invalidateViews(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java index ca7bd147..07dd1a6e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -18,6 +18,7 @@ import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Vibrator; +import android.support.v4.hardware.fingerprint.FingerprintManagerCompat; import android.text.Editable; import android.text.InputFilter; import android.text.InputType; @@ -79,6 +80,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter private int passcodeRow; private int changePasscodeRow; private int passcodeDetailRow; + private int fingerprintRow; private int autoLockRow; private int autoLockDetailRow; private int rowCount; @@ -403,6 +405,10 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter } }); showDialog(builder.create()); + } else if (i == fingerprintRow) { + UserConfig.useFingerprint = !UserConfig.useFingerprint; + UserConfig.saveConfig(false); + ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); @@ -461,9 +467,20 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter changePasscodeRow = rowCount++; passcodeDetailRow = rowCount++; if (UserConfig.passcodeHash.length() > 0) { + try { + if (Build.VERSION.SDK_INT >= 23) { + FingerprintManagerCompat fingerprintManager = FingerprintManagerCompat.from(ApplicationLoader.applicationContext); + if (fingerprintManager.isHardwareDetected()) { + fingerprintRow = rowCount++; + } + } + } catch (Throwable e) { + FileLog.e("tmessages", e); + } autoLockRow = rowCount++; autoLockDetailRow = rowCount++; } else { + fingerprintRow = -1; autoLockRow = -1; autoLockDetailRow = -1; } @@ -486,9 +503,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter } @Override - public void onOpenAnimationEnd() { - super.onOpenAnimationEnd(); - if (type != 0) { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen && type != 0) { AndroidUtilities.showKeyboard(passwordEditText); } } @@ -620,7 +636,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter @Override public boolean isEnabled(int i) { - return i == passcodeRow || i == autoLockRow || UserConfig.passcodeHash.length() != 0 && i == changePasscodeRow; + return i == passcodeRow || i == fingerprintRow || i == autoLockRow || UserConfig.passcodeHash.length() != 0 && i == changePasscodeRow; } @Override @@ -655,6 +671,8 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter if (i == passcodeRow) { textCell.setTextAndCheck(LocaleController.getString("Passcode", R.string.Passcode), UserConfig.passcodeHash.length() > 0, true); + } else if (i == fingerprintRow) { + textCell.setTextAndCheck(LocaleController.getString("UnlockFingerprint", R.string.UnlockFingerprint), UserConfig.useFingerprint, true); } } else if (viewType == 1) { if (view == null) { @@ -700,7 +718,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter @Override public int getItemViewType(int i) { - if (i == passcodeRow) { + if (i == passcodeRow || i == fingerprintRow) { return 0; } else if (i == changePasscodeRow || i == autoLockRow) { return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java index 7a332b9f..fe00f687 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java @@ -3,7 +3,7 @@ * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * - * Copyright Nikolai Kudashov, 2013-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java index 34f2b0b9..b4cc7b0c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java @@ -3,7 +3,7 @@ * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -21,6 +21,7 @@ import android.view.View; import android.widget.FrameLayout; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.Bitmaps; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; @@ -35,7 +36,7 @@ import java.io.File; public class PhotoCropActivity extends BaseFragment { public interface PhotoEditActivityDelegate { - void didFinishEdit(Bitmap bitmap, Bundle args); + void didFinishEdit(Bitmap bitmap); } private class PhotoCropView extends FrameLayout { @@ -315,12 +316,12 @@ public class PhotoCropActivity extends BaseFragment { sizeY = imageToCrop.getHeight() - y; } try { - return Bitmap.createBitmap(imageToCrop, x, y, sizeX, sizeY); + return Bitmaps.createBitmap(imageToCrop, x, y, sizeX, sizeY); } catch (Throwable e) { FileLog.e("tmessags", e); System.gc(); try { - return Bitmap.createBitmap(imageToCrop, x, y, sizeX, sizeY); + return Bitmaps.createBitmap(imageToCrop, x, y, sizeX, sizeY); } catch (Throwable e2) { FileLog.e("tmessages", e2); } @@ -331,8 +332,12 @@ public class PhotoCropActivity extends BaseFragment { @Override protected void onDraw(Canvas canvas) { if (drawable != null) { - drawable.setBounds(bitmapX, bitmapY, bitmapX + bitmapWidth, bitmapY + bitmapHeight); - drawable.draw(canvas); + try { + drawable.setBounds(bitmapX, bitmapY, bitmapX + bitmapWidth, bitmapY + bitmapHeight); + drawable.draw(canvas); + } catch (Throwable e) { + FileLog.e("tmessages", e); + } } canvas.drawRect(bitmapX, bitmapY, bitmapX + bitmapWidth, rectY, halfPaint); canvas.drawRect(bitmapX, rectY, rectX, rectY + rectSizeY, halfPaint); @@ -375,15 +380,6 @@ public class PhotoCropActivity extends BaseFragment { super(args); } - public PhotoCropActivity(Bundle args, Bitmap bitmap, String key) { - super(args); - imageToCrop = bitmap; - bitmapKey = key; - if (imageToCrop != null && key != null) { - ImageLoader.getInstance().incrementUseCount(key); - } - } - @Override public boolean onFragmentCreate() { swipeBackEnabled = false; @@ -418,7 +414,6 @@ public class PhotoCropActivity extends BaseFragment { @Override public void onFragmentDestroy() { super.onFragmentDestroy(); - drawable = null; if (bitmapKey != null) { if (ImageLoader.getInstance().decrementUseCount(bitmapKey) && !ImageLoader.getInstance().isInCache(bitmapKey)) { bitmapKey = null; @@ -428,6 +423,7 @@ public class PhotoCropActivity extends BaseFragment { imageToCrop.recycle(); imageToCrop = null; } + drawable = null; } @Override @@ -448,7 +444,7 @@ public class PhotoCropActivity extends BaseFragment { if (bitmap == imageToCrop) { sameBitmap = true; } - delegate.didFinishEdit(bitmap, getArguments()); + delegate.didFinishEdit(bitmap); doneButtonPressed = true; } finishFragment(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index 984b77f8..3961e1bd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -34,6 +34,7 @@ import android.widget.TextView; import org.json.JSONArray; import org.json.JSONObject; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.AnimationCompat.ViewProxy; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaController; import org.telegram.messenger.MessagesStorage; @@ -294,6 +295,9 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen if (i < 0 || i >= arrayList.size()) { return; } + if (searchItem != null) { + AndroidUtilities.hideKeyboard(searchItem.getSearchField()); + } PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhotoForSelect(arrayList, i, singlePhoto ? 1 : 0, PhotoPickerActivity.this, chatActivity); } @@ -498,9 +502,18 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject(); object.viewX = coords[0]; object.viewY = coords[1] - AndroidUtilities.statusBarHeight; + if (Build.VERSION.SDK_INT < 11) { + float scale = ViewProxy.getScaleX(cell.photoImage); + if (scale != 1) { + int width = cell.photoImage.getMeasuredWidth(); + object.viewX += (width - width * scale) / 2; + object.viewY += (width - width * scale) / 2; + } + } object.parentView = listView; object.imageReceiver = cell.photoImage.getImageReceiver(); object.thumb = object.imageReceiver.getBitmap(); + object.scale = ViewProxy.getScaleX(cell.photoImage); cell.checkBox.setVisibility(View.GONE); return object; } @@ -646,7 +659,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen View view = listView.getChildAt(a); int num = (Integer) view.getTag(); if (num == index) { - ((PhotoPickerPhotoCell) view).checkBox.setChecked(add, false); + ((PhotoPickerPhotoCell) view).setChecked(add, false); break; } } @@ -655,9 +668,10 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } @Override - public void cancelButtonPressed() { + public boolean cancelButtonPressed() { delegate.actionButtonPressed(true); finishFragment(); + return true; } @Override @@ -692,9 +706,8 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } @Override - public void onOpenAnimationEnd() { - super.onOpenAnimationEnd(); - if (searchItem != null) { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen && searchItem != null) { AndroidUtilities.showKeyboard(searchItem.getSearchField()); } } @@ -1016,7 +1029,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { selectedPhotos.put(photoEntry.imageId, photoEntry); } - ((PhotoPickerPhotoCell) v.getParent()).checkBox.setChecked(selectedPhotos.containsKey(photoEntry.imageId), true); + ((PhotoPickerPhotoCell) v.getParent()).setChecked(selectedPhotos.containsKey(photoEntry.imageId), true); } else { AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus()); MediaController.SearchImage photoEntry; @@ -1033,7 +1046,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { selectedWebPhotos.put(photoEntry.id, photoEntry); } - ((PhotoPickerPhotoCell) v.getParent()).checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), true); + ((PhotoPickerPhotoCell) v.getParent()).setChecked(selectedWebPhotos.containsKey(photoEntry.id), true); } pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); delegate.selectedPhotosChanged(); @@ -1062,7 +1075,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { imageView.setImageResource(R.drawable.nophotos); } - cell.checkBox.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false); + cell.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false); showing = PhotoViewer.getInstance().isShowingImage(photoEntry.path); } else { MediaController.SearchImage photoEntry; @@ -1078,7 +1091,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen } else { imageView.setImageResource(R.drawable.nophotos); } - cell.checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false); + cell.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false); showing = PhotoViewer.getInstance().isShowingImage(photoEntry.thumbUrl); } imageView.getImageReceiver().setVisible(!showing, true); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 6f725fed..2337a71b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -1,13 +1,14 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; +import android.Manifest; import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; @@ -15,6 +16,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; @@ -55,7 +57,6 @@ import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.UserObject; import org.telegram.messenger.query.SharedMediaQuery; import org.telegram.messenger.ApplicationLoader; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; @@ -63,6 +64,7 @@ import org.telegram.messenger.MediaController; import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.UserConfig; import org.telegram.messenger.MessageObject; @@ -409,6 +411,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat public int index; public int size; public int radius; + public int clipBottomAddition; + public float scale = 1.0f; } public static class EmptyPhotoViewerProvider implements PhotoViewerProvider { @@ -443,8 +447,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } @Override - public void cancelButtonPressed() { - + public boolean cancelButtonPressed() { + return true; } @Override @@ -476,7 +480,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat void setPhotoChecked(int index); - void cancelButtonPressed(); + boolean cancelButtonPressed(); void sendButtonPressed(int index); @@ -736,7 +740,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (needSearchImageInArr && isFirstLoading) { isFirstLoading = false; loadingMoreImages = true; - SharedMediaQuery.loadMedia(currentDialogId, 0, 100, 0, SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); + SharedMediaQuery.loadMedia(currentDialogId, 0, 80, 0, SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); } else if (!imagesArr.isEmpty()) { if (opennedFromMedia) { actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, totalImagesCount)); @@ -801,9 +805,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (!endReached || !arr.isEmpty() && added != 0) { loadingMoreImages = true; if (opennedFromMedia) { - SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(imagesArrTemp.size() - 1).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); + SharedMediaQuery.loadMedia(currentDialogId, 0, 80, imagesArrTemp.get(imagesArrTemp.size() - 1).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); } else { - SharedMediaQuery.loadMedia(currentDialogId, 0, 100, imagesArrTemp.get(0).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); + SharedMediaQuery.loadMedia(currentDialogId, 0, 80, imagesArrTemp.get(0).getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); } } } @@ -859,6 +863,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat scroller = new Scroller(activity); windowView = new FrameLayoutTouchListener(activity) { + @Override public boolean dispatchKeyEventPreIme(KeyEvent event) { if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) { @@ -941,6 +946,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } closePhoto(true, false); } else if (id == gallery_menu_save) { + if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + parentActivity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4); + return; + } + File f = null; if (currentMessageObject != null) { f = FileLoader.getPathToMessage(currentMessageObject.messageOwner); @@ -1256,8 +1266,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat @Override public void onClick(View view) { if (placeProvider != null) { - placeProvider.cancelButtonPressed(); - closePhoto(false, false); + closePhoto(!placeProvider.cancelButtonPressed(), false); } } }); @@ -2006,7 +2015,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat currentActionBarAnimation.addListener(new AnimatorListenerAdapterProxy() { @Override public void onAnimationEnd(Object animation) { - if (currentActionBarAnimation.equals(animation)) { + if (currentActionBarAnimation != null && currentActionBarAnimation.equals(animation)) { actionBar.setVisibility(View.GONE); if (canShowBottom) { bottomLayout.clearAnimation(); @@ -2420,14 +2429,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (opennedFromMedia) { if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex > imagesArr.size() - 5) { MessageObject lastMessage = imagesArr.get(imagesArr.size() - 1); - SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); + SharedMediaQuery.loadMedia(currentDialogId, 0, 80, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); loadingMoreImages = true; } actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, currentIndex + 1, totalImagesCount)); } else { if (imagesArr.size() < totalImagesCount && !loadingMoreImages && currentIndex < 5) { MessageObject lastMessage = imagesArr.get(0); - SharedMediaQuery.loadMedia(currentDialogId, 0, 100, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); + SharedMediaQuery.loadMedia(currentDialogId, 0, 80, lastMessage.getId(), SharedMediaQuery.MEDIA_PHOTOVIDEO, true, classGuid); loadingMoreImages = true; } actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, (totalImagesCount - imagesArr.size()) + currentIndex + 1, totalImagesCount)); @@ -2841,19 +2850,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } try { - if (photos != null) { - windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; - windowLayoutParams.flags = 0; - windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; - windowView.setFocusable(true); - containerView.setFocusable(true); - } else { windowLayoutParams.type = WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; windowLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED; windowView.setFocusable(false); containerView.setFocusable(false); - } wm.addView(windowView, windowLayoutParams); } catch (Exception e) { FileLog.e("tmessages", e); @@ -2897,13 +2898,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ViewProxy.setAlpha(animatingImageView, 1.0f); ViewProxy.setPivotX(animatingImageView, 0.0f); ViewProxy.setPivotY(animatingImageView, 0.0f); - ViewProxy.setScaleX(animatingImageView, 1.0f); - ViewProxy.setScaleY(animatingImageView, 1.0f); - ViewProxy.setTranslationX(animatingImageView, object.viewX + drawRegion.left); - ViewProxy.setTranslationY(animatingImageView, object.viewY + drawRegion.top); + ViewProxy.setScaleX(animatingImageView, object.scale); + ViewProxy.setScaleY(animatingImageView, object.scale); + ViewProxy.setTranslationX(animatingImageView, object.viewX + drawRegion.left * object.scale); + ViewProxy.setTranslationY(animatingImageView, object.viewY + drawRegion.top * object.scale); final ViewGroup.LayoutParams layoutParams = animatingImageView.getLayoutParams(); - layoutParams.width = drawRegion.right - drawRegion.left; - layoutParams.height = drawRegion.bottom - drawRegion.top; + layoutParams.width = (drawRegion.right - drawRegion.left); + layoutParams.height = (drawRegion.bottom - drawRegion.top); animatingImageView.setLayoutParams(layoutParams); float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width; @@ -2922,7 +2923,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (clipTop < 0) { clipTop = 0; } - int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight); + int clipBottom = (object.viewY + drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } @@ -2933,9 +2934,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animationValues[0][1] = ViewProxy.getScaleY(animatingImageView); animationValues[0][2] = ViewProxy.getTranslationX(animatingImageView); animationValues[0][3] = ViewProxy.getTranslationY(animatingImageView); - animationValues[0][4] = clipHorizontal; - animationValues[0][5] = clipTop; - animationValues[0][6] = clipBottom; + animationValues[0][4] = clipHorizontal * object.scale; + animationValues[0][5] = clipTop * object.scale; + animationValues[0][6] = clipBottom * object.scale; animationValues[0][7] = animatingImageView.getRadius(); animationValues[1][0] = scale; @@ -2978,6 +2979,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (hideAfterAnimation != null) { hideAfterAnimation.imageReceiver.setVisible(false, true); } + if (photos != null) { + windowLayoutParams.flags = 0; + windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; + WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE); + wm.updateViewLayout(windowView, windowLayoutParams); + windowView.setFocusable(true); + containerView.setFocusable(true); + } } }; @@ -3021,6 +3030,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } }; } else { + if (photos != null) { + windowLayoutParams.flags = 0; + windowLayoutParams.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN; + wm.updateViewLayout(windowView, windowLayoutParams); + windowView.setFocusable(true); + containerView.setFocusable(true); + } + backgroundDrawable.setAlpha(255); ViewProxy.setAlpha(containerView, 1.0f); onPhotoShow(messageObject, fileLocation, messages, photos, index, object); @@ -3128,7 +3145,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat if (clipTop < 0) { clipTop = 0; } - int clipBottom = (object.viewY + drawRegion.top + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight); + int clipBottom = (object.viewY + drawRegion.top + (drawRegion.bottom - drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight) + object.clipBottomAddition; if (clipBottom < 0) { clipBottom = 0; } @@ -3145,13 +3162,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat animationValues[0][6] = 0; animationValues[0][7] = 0; - animationValues[1][0] = 1; - animationValues[1][1] = 1; - animationValues[1][2] = object.viewX + drawRegion.left; - animationValues[1][3] = object.viewY + drawRegion.top; - animationValues[1][4] = clipHorizontal; - animationValues[1][5] = clipTop; - animationValues[1][6] = clipBottom; + animationValues[1][0] = object.scale; + animationValues[1][1] = object.scale; + animationValues[1][2] = object.viewX + drawRegion.left * object.scale; + animationValues[1][3] = object.viewY + drawRegion.top * object.scale; + animationValues[1][4] = clipHorizontal * object.scale; + animationValues[1][5] = clipTop * object.scale; + animationValues[1][6] = clipBottom * object.scale; animationValues[1][7] = object.radius; animatorSet.playTogether( diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java index 4ce0a3c6..6c3b97da 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PopupNotificationActivity.java @@ -1,19 +1,25 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; +import android.annotation.TargetApi; import android.app.Activity; +import android.app.AlertDialog; import android.app.KeyguardManager; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; +import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.drawable.Drawable; +import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.PowerManager; import android.text.TextUtils; @@ -40,11 +46,11 @@ import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.messenger.NotificationsController; import org.telegram.messenger.UserObject; import org.telegram.messenger.ApplicationLoader; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.messenger.MessageObject; import org.telegram.ui.ActionBar.ActionBar; @@ -76,6 +82,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC private ViewGroup centerView; private ViewGroup leftView; private ViewGroup rightView; + private RelativeLayout popupContainer; private ArrayList textViews = new ArrayList<>(); private ArrayList imageViews = new ArrayList<>(); private ArrayList audioViews = new ArrayList<>(); @@ -195,6 +202,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC } if (chatActivityEnterView.isPopupView(child)) { child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY)); + } else if (chatActivityEnterView.isRecordCircle(child)) { + measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); } else { child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)), MeasureSpec.EXACTLY)); } @@ -255,6 +264,9 @@ public class PopupNotificationActivity extends Activity implements NotificationC } if (chatActivityEnterView.isPopupView(child)) { childTop = paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight(); + } else if (chatActivityEnterView.isRecordCircle(child)) { + childTop = popupContainer.getTop() + popupContainer.getMeasuredHeight() - child.getMeasuredHeight() - lp.bottomMargin; + childLeft = popupContainer.getLeft() + popupContainer.getMeasuredWidth() - child.getMeasuredWidth() - lp.rightMargin; } child.layout(childLeft, childTop, childLeft + width, childTop + height); } @@ -268,7 +280,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC RelativeLayout relativeLayout = new RelativeLayout(this); contentView.addView(relativeLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); - RelativeLayout popupContainer = new RelativeLayout(this); + popupContainer = new RelativeLayout(this); popupContainer.setBackgroundColor(0xffffffff); relativeLayout.addView(popupContainer, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT)); @@ -427,6 +439,34 @@ public class PopupNotificationActivity extends Activity implements NotificationC handleIntent(intent); } + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if (requestCode == 3) { + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + return; + } + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); + builder.setMessage(LocaleController.getString("PermissionNoAudio", R.string.PermissionNoAudio)); + builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), new DialogInterface.OnClickListener() { + @TargetApi(Build.VERSION_CODES.GINGERBREAD) + @Override + public void onClick(DialogInterface dialog, int which) { + try { + Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); + intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName())); + startActivity(intent); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); + builder.show(); + } + } + private void switchToNextMessage() { if (NotificationsController.getInstance().popupMessages.size() > 1) { if (currentMessageNum < NotificationsController.getInstance().popupMessages.size() - 1) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java index 4057fc16..c5e06c0c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PrivacySettingsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index c5dc7e32..ea8f7974 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -19,7 +19,6 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Bitmap; -import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; @@ -27,21 +26,18 @@ import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.support.annotation.NonNull; 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.view.ViewOutlineProvider; import android.view.ViewTreeObserver; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; -import android.widget.AbsListView; -import android.widget.AdapterView; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; @@ -52,6 +48,7 @@ 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.messenger.BuildConfig; import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; import org.telegram.messenger.FileLog; @@ -68,13 +65,14 @@ import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; import org.telegram.messenger.query.BotQuery; import org.telegram.messenger.query.SharedMediaQuery; +import org.telegram.messenger.support.widget.LinearLayoutManager; +import org.telegram.messenger.support.widget.RecyclerView; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; 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.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.AddMemberCell; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.EmptyCell; @@ -87,6 +85,7 @@ import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.RecyclerListView; import java.util.ArrayList; import java.util.Collections; @@ -96,19 +95,28 @@ import java.util.concurrent.Semaphore; public class ProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider { - private ListView listView; + private RecyclerListView listView; + private LinearLayoutManager layoutManager; private ListAdapter listAdapter; private BackupImageView avatarImage; private TextView nameTextView; private TextView onlineTextView; private ImageView writeButton; private AnimatorSetProxy writeButtonAnimation; + private View extraHeightView; + private View shadowView; private int user_id; private int chat_id; private long dialog_id; private boolean creatingChat; private boolean userBlocked; + private boolean openAnimationInProgress; + private boolean playProfileAnimation; + private int extraHeight; + private int initialAnimationExtraHeight; + private float animationProgress; + private AvatarUpdater avatarUpdater; private TLRPC.ChatFull info; private TLRPC.TL_chatParticipant selectedUser; @@ -182,6 +190,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated); NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded); NotificationCenter.getInstance().addObserver(this, NotificationCenter.botInfoDidLoaded); + if (currentEncryptedChat != null) { + NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedNewMessages); + } userBlocked = MessagesController.getInstance().blockedUsers.contains(user_id); if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) { BotQuery.loadBotInfo(user.id, true, classGuid); @@ -256,6 +267,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.botInfoDidLoaded); MessagesController.getInstance().cancelLoadFullUser(user_id); + if (currentEncryptedChat != null) { + NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedNewMessages); + } } else if (chat_id != 0) { NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded); avatarUpdater.clear(); @@ -264,14 +278,17 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. @Override public View createView(Context context) { + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); - //actionBar.setBackButtonImage(R.drawable.ic_ab_back); - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); Drawable back = context.getResources().getDrawable(R.drawable.ic_ab_back); back.setColorFilter(themePrefs.getInt("profileHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); actionBar.setBackButtonDrawable(back); - actionBar.setExtraHeight(AndroidUtilities.dp(88), false); + //actionBar.setBackButtonDrawable(new BackDrawable(false)); + actionBar.setCastShadows(false); + actionBar.setAddToContainer(false); + hasOwnBackground = true; + extraHeight = 88; if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } @@ -321,11 +338,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. TLRPC.User user = MessagesController.getInstance().getUser(user_id); Bundle args = new Bundle(); args.putInt("user_id", user.id); + args.putBoolean("addContact", true); presentFragment(new ContactAddActivity(args)); } else if (id == share_contact) { Bundle args = new Bundle(); args.putBoolean("onlySelect", true); args.putInt("dialogsType", 1); + args.putString("selectAlertString", LocaleController.getString("SendMessagesTo", R.string.SendMessagesTo)); + args.putString("selectAlertStringGroup", LocaleController.getString("SendMessagesToGroup", R.string.SendMessagesToGroup)); DialogsActivity fragment = new DialogsActivity(args); fragment.setDelegate(ProfileActivity.this); presentFragment(fragment); @@ -428,146 +448,40 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. listAdapter = new ListAdapter(context); - fragmentView = new FrameLayout(context) { - @Override - protected boolean drawChild(@NonNull Canvas canvas, @NonNull View child, long drawingTime) { - if (child == listView) { - boolean result = super.drawChild(canvas, child, drawingTime); - if (parentLayout != null) { - int actionBarHeight = 0; - int childCount = getChildCount(); - for (int a = 0; a < childCount; a++) { - View view = getChildAt(a); - if (view == child) { - continue; - } - if (view instanceof ActionBar && view.getVisibility() == VISIBLE) { - if (((ActionBar) view).getCastShadows()) { - actionBarHeight = view.getMeasuredHeight(); - } - break; - } - } - parentLayout.drawHeaderShadow(canvas, actionBarHeight); - } - return result; - } else { - return super.drawChild(canvas, child, drawingTime); - } - } - }; + fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; - avatarImage = new BackupImageView(context); - avatarImage.setRoundRadius(AndroidUtilities.dp(30)); - //int radius = AndroidUtilities.dp(themePrefs.getInt("profileAvatarRadius", 32)); - //avatarImage.setRoundRadius(radius); - actionBar.addView(avatarImage); - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - layoutParams.width = AndroidUtilities.dp(60); - layoutParams.height = AndroidUtilities.dp(60); - layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(17); - layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(17) : 0; - layoutParams.bottomMargin = AndroidUtilities.dp(22); - avatarImage.setLayoutParams(layoutParams); - avatarImage.setOnClickListener(new View.OnClickListener() { + listView = new RecyclerListView(context) { @Override - public void onClick(View v) { - if (user_id != 0) { - TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user.photo != null && user.photo.photo_big != null) { - PhotoViewer.getInstance().setParentActivity(getParentActivity()); - PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this); - } - } else if (chat_id != 0) { - TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); - if (chat.photo != null && chat.photo.photo_big != null) { - PhotoViewer.getInstance().setParentActivity(getParentActivity()); - PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, ProfileActivity.this); - } - } + public boolean hasOverlappingRendering() { + return false; } - }); + }; + //listView.setBackgroundColor(0xffffffff); - nameTextView = new TextView(context); - nameTextView.setTextColor(0xffffffff); - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); - nameTextView.setLines(1); - nameTextView.setMaxLines(1); - nameTextView.setSingleLine(true); - nameTextView.setEllipsize(TextUtils.TruncateAt.END); - nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - actionBar.addView(nameTextView); - layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.height = LayoutHelper.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); - layoutParams.bottomMargin = AndroidUtilities.dp(51); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - nameTextView.setLayoutParams(layoutParams); - - onlineTextView = new TextView(context); - onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); - onlineTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor", -0x40)); - onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - onlineTextView.setLines(1); - onlineTextView.setMaxLines(1); - onlineTextView.setSingleLine(true); - onlineTextView.setEllipsize(TextUtils.TruncateAt.END); - onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - actionBar.addView(onlineTextView); - layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.height = LayoutHelper.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 97); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 16); - layoutParams.bottomMargin = AndroidUtilities.dp(30); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - onlineTextView.setLayoutParams(layoutParams); - - adminTextView = new TextView(context); - //adminTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? 5 : chat_id)); - adminTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor", -0x40)); - adminTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - adminTextView.setLines(1); - adminTextView.setMaxLines(1); - adminTextView.setSingleLine(true); - adminTextView.setEllipsize(TextUtils.TruncateAt.END); - adminTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - adminTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - actionBar.addView(adminTextView); - layoutParams = (FrameLayout.LayoutParams) adminTextView.getLayoutParams(); - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.height = LayoutHelper.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 75 : 97); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 97 : 75); - layoutParams.bottomMargin = AndroidUtilities.dp(10); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; - adminTextView.setLayoutParams(layoutParams); - - listView = new ListView(context); - listView.setDivider(null); - listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); - AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); - frameLayout.addView(listView); - layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.width = LayoutHelper.MATCH_PARENT; - layoutParams.height = LayoutHelper.MATCH_PARENT; - layoutParams.gravity = Gravity.TOP; - listView.setLayoutParams(layoutParams); + listView.setItemAnimator(null); + listView.setLayoutAnimation(null); + layoutManager = new LinearLayoutManager(context) { + @Override + public boolean supportsPredictiveItemAnimations() { + return false; + } + }; + layoutManager.setOrientation(LinearLayoutManager.VERTICAL); + listView.setLayoutManager(layoutManager); + //listView.setGlowColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); + + frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); listView.setAdapter(listAdapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override - public void onItemClick(AdapterView adapterView, View view, final int i, long l) { + public void onItemClick(View view, final int position) { if (getParentActivity() == null) { return; } - if (i == sharedMediaRow) { + if (position == sharedMediaRow) { Bundle args = new Bundle(); if (user_id != 0) { args.putLong("dialog_id", dialog_id != 0 ? dialog_id : user_id); @@ -575,13 +489,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. args.putLong("dialog_id", -chat_id); } presentFragment(new MediaActivity(args)); - } else if (i == settingsKeyRow) { + } else if (position == settingsKeyRow) { Bundle args = new Bundle(); args.putInt("chat_id", (int) (dialog_id >> 32)); presentFragment(new IdenticonActivity(args)); - } else if (i == settingsTimerRow) { + } else if (position == settingsTimerRow) { showDialog(AndroidUtilities.buildTTLAlert(getParentActivity(), currentEncryptedChat).create()); - } else if (i == settingsNotificationsRow) { + } else if (position == settingsNotificationsRow) { Bundle args = new Bundle(); if (user_id != 0) { args.putLong("dialog_id", dialog_id == 0 ? user_id : dialog_id); @@ -589,7 +503,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. args.putLong("dialog_id", -chat_id); } presentFragment(new ProfileNotificationsActivity(args)); - } else if (i == startSecretChatRow) { + } else if (position == startSecretChatRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("AreYouSureSecretChat", R.string.AreYouSureSecretChat)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); @@ -602,7 +516,47 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); - } else if (i == phoneRow) { + } else if (position == usernameRow) { + final TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user == null || user.username == null) { + return; + } + try { + String text = "@" + user.username; + 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(text); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", text); + clipboard.setPrimaryClip(clip); + } + Toast.makeText(getParentActivity(), LocaleController.formatString("Copied", R.string.Copied, text), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + /*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; @@ -638,36 +592,17 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } }); showDialog(builder.create()); - } else if(i == usernameRow) { - final TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user == null || user.username == null || user.username.length() == 0 || getParentActivity() == null) { - return; - } - try { - String text = "@" + user.username; - 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(text); - } else { - android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); - android.content.ClipData clip = android.content.ClipData.newPlainText("label", text); - clipboard.setPrimaryClip(clip); - } - Toast.makeText(getParentActivity(), LocaleController.formatString("Copied", R.string.Copied, text), Toast.LENGTH_SHORT).show(); - } catch (Exception e) { - FileLog.e("tmessages", e); - } - }else if (i > emptyRowChat2 && i < membersEndRow) { - int user_id = info.participants.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)).user_id; + } else if (position > emptyRowChat2 && position < membersEndRow) { + int user_id = info.participants.participants.get(sortedUsers.get(position - emptyRowChat2 - 1)).user_id; if (user_id == UserConfig.getClientUserId()) { return; } Bundle args = new Bundle(); args.putInt("user_id", user_id); presentFragment(new ProfileActivity(args)); - } else if (i == addMemberRow) { + } else if (position == addMemberRow) { openAddMember(); - } else if (i == channelNameRow) { + } else if (position == channelNameRow) { try { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); @@ -676,7 +611,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } catch (Exception e) { FileLog.e("tmessages", e); } - } else if (i == leaveChannelRow) { + } else if (position == leaveChannelRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(ChatObject.isChannel(chat_id) ? LocaleController.getString("ChannelLeaveAlert", R.string.ChannelLeaveAlert) : LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); @@ -688,18 +623,18 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); - } else if (i == membersRow || i == blockedUsersRow || i == managementRow) { + } else if (position == membersRow || position == blockedUsersRow || position == managementRow) { Bundle args = new Bundle(); args.putInt("chat_id", chat_id); - if (i == blockedUsersRow) { + if (position == blockedUsersRow) { args.putInt("type", 0); - } else if (i == managementRow) { + } else if (position == managementRow) { args.putInt("type", 1); - } else if (i == membersRow) { + } else if (position == membersRow) { args.putInt("type", 2); } presentFragment(new ChannelUsersActivity(args)); - } else if (i == channelInfoRow) { + } 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 @@ -722,16 +657,16 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } } }); + if (chat_id != 0) { - listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { + listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() { @Override - public boolean onItemLongClick(AdapterView adapterView, View view, int i, long l) { - if (i > emptyRowChat2 && i < membersEndRow) { + public boolean onItemClick(View view, int position) { + if (position > emptyRowChat2 && position < membersEndRow) { if (getParentActivity() == null) { return false; } - - TLRPC.TL_chatParticipant user = info.participants.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)); + TLRPC.TL_chatParticipant user = info.participants.participants.get(sortedUsers.get(position - emptyRowChat2 - 1)); if (user.user_id == UserConfig.getClientUserId()) { return false; } @@ -752,7 +687,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } }); showDialog(builder.create()); - return true; } return false; @@ -767,6 +701,77 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. frameLayout.addView(actionBar); + extraHeightView = new View(context); + ViewProxy.setPivotY(extraHeightView, 0); + //extraHeightView.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); + frameLayout.addView(extraHeightView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 88)); + + shadowView = new View(context); + shadowView.setBackgroundResource(R.drawable.header_shadow); + frameLayout.addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3)); + + avatarImage = new BackupImageView(context); + avatarImage.setRoundRadius(AndroidUtilities.dp(21)); + ViewProxy.setPivotX(avatarImage, 0); + ViewProxy.setPivotY(avatarImage, 0); + frameLayout.addView(avatarImage, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0)); + avatarImage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (user_id != 0) { + TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user.photo != null && user.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); + PhotoViewer.getInstance().openPhoto(user.photo.photo_big, ProfileActivity.this); + } + } else if (chat_id != 0) { + TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); + if (chat.photo != null && chat.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); + PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, ProfileActivity.this); + } + } + } + }); + + 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.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); + ViewProxy.setPivotX(nameTextView, 0); + ViewProxy.setPivotY(nameTextView, 0); + frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); + + onlineTextView = new TextView(context); + //onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id)); + 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); + frameLayout.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); + + adminTextView = new TextView(context); + //adminTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? 5 : chat_id)); + adminTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor", -0x40)); + adminTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + adminTextView.setLines(1); + adminTextView.setMaxLines(1); + adminTextView.setSingleLine(true); + adminTextView.setEllipsize(TextUtils.TruncateAt.END); + adminTextView.setGravity(Gravity.LEFT); + adminTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + + frameLayout.addView(adminTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); + + if (user_id != 0 || chat_id >= 0 && !ChatObject.isLeftFromChat(currentChat)) { writeButton = new ImageView(context); //writeButton.setBackgroundResource(R.drawable.floating_user_states); @@ -794,7 +799,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. writeButton.setImageDrawable(camera); } } - frameLayout.addView(writeButton); + frameLayout.addView(writeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0)); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200)); @@ -808,13 +813,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } }); } - layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams.width = LayoutHelper.WRAP_CONTENT; - layoutParams.height = LayoutHelper.WRAP_CONTENT; - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 0); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 16); - layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT); - writeButton.setLayoutParams(layoutParams); writeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -822,6 +820,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return; } if (user_id != 0) { + if (playProfileAnimation && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2) instanceof ChatActivity) { + finishFragment(); + } else { TLRPC.User user = MessagesController.getInstance().getUser(user_id); if (user == null || user instanceof TLRPC.TL_userEmpty) { return; @@ -831,6 +832,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. Bundle args = new Bundle(); args.putInt("user_id", user_id); presentFragment(new ChatActivity(args), true); + } } else if (chat_id != 0) { if (ChatObject.isChannel(currentChat) && (currentChat.flags & TLRPC.CHAT_FLAG_ADMIN) == 0) { NotificationCenter.getInstance().removeObserver(ProfileActivity.this, NotificationCenter.closeChats); @@ -866,19 +868,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } }); } + needLayout(); - listView.setOnScrollListener(new AbsListView.OnScrollListener() { + listView.setOnScrollListener(new RecyclerView.OnScrollListener() { @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - + public void onScrollStateChanged(RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); } @Override - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { + public void onScrolled(RecyclerView recyclerView, int dx, int dy) { checkListViewScroll(); } }); - + updateListBG(); + updateActionBarBG(); return fragmentView; } @@ -938,17 +942,17 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } private void checkListViewScroll() { - if (listView.getChildCount() == 0) { + if (listView.getChildCount() == 0 || openAnimationInProgress) { return; } int height = 0; View child = listView.getChildAt(0); if (child != null) { - if (listView.getFirstVisiblePosition() == 0) { + if (layoutManager.findFirstVisibleItemPosition() == 0) { height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0); } - if (actionBar.getExtraHeight() != height) { - actionBar.setExtraHeight(height, true); + if (extraHeight != height) { + extraHeight = height; needLayout(); } } @@ -956,40 +960,40 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. private void needLayout() { FrameLayout.LayoutParams layoutParams; - if (listView != null) { + int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); + if (listView != null && !openAnimationInProgress) { layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); + if (layoutParams.topMargin != newTop) { + layoutParams.topMargin = newTop; listView.setLayoutParams(layoutParams); + ViewProxy.setTranslationY(extraHeightView, newTop); + } } if (avatarImage != null) { - float diff = actionBar.getExtraHeight() / (float)AndroidUtilities.dp(88); - float diffm = 1.0f - diff; - - int avatarSize = 42 + (int)(18 * diff); - int avatarX = 17 + (int)(47 * diffm); - int avatarY = AndroidUtilities.dp(22) - (int)((AndroidUtilities.dp(22) - (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(42)) / 2) * (1.0f - diff)); - int nameX = 97 + (int)(21 * diffm); - int nameEndX = 16 + (int)(32 * diffm); - int nameY = avatarY + AndroidUtilities.dp(29 - 10 * diffm); - int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm); - float scale = 1.0f - 0.12f * diffm; + float diff = extraHeight / (float) AndroidUtilities.dp(88); + ViewProxy.setScaleY(extraHeightView, diff); + ViewProxy.setTranslationY(shadowView, newTop + extraHeight); + listView.setTopGlowOffset(extraHeight); if (writeButton != null) { + if (Build.VERSION.SDK_INT < 11) { layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f); + layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f); writeButton.setLayoutParams(layoutParams); - /*ViewProxy.setAlpha(writeButton, diff); - writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE); - if (writeButton.getVisibility() == View.GONE) { - writeButton.clearAnimation(); - }*/ + } else { + ViewProxy.setTranslationY(writeButton, (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f)); + } + + if (!openAnimationInProgress) { final boolean setVisible = diff > 0.2f; boolean currentVisible = writeButton.getTag() == null; if (setVisible != currentVisible) { if (setVisible) { writeButton.setTag(null); + if (Build.VERSION.SDK_INT < 11) { writeButton.setVisibility(View.VISIBLE); + } } else { writeButton.setTag(0); } @@ -1020,7 +1024,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. public void onAnimationEnd(Object animation) { if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) { writeButton.clearAnimation(); + if (Build.VERSION.SDK_INT < 11) { writeButton.setVisibility(setVisible ? View.VISIBLE : View.GONE); + } writeButtonAnimation = null; } } @@ -1028,35 +1034,32 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. writeButtonAnimation.start(); } } + } - //avatarImage.setRoundRadius(AndroidUtilities.dp(avatarSize / 2)); - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int radius = AndroidUtilities.dp(themePrefs.getInt("profileAvatarRadius", 32)); - avatarImage.setRoundRadius(radius); + float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density + 27 * AndroidUtilities.density * diff; + if (Build.VERSION.SDK_INT < 11) { layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(avatarSize); - layoutParams.height = AndroidUtilities.dp(avatarSize); - layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(avatarX); - layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(avatarX) : 0; - layoutParams.bottomMargin = avatarY; + layoutParams.height = layoutParams.width = (int) Math.ceil(AndroidUtilities.dp(42) * (42 + 18 * diff) / 42.0f); + layoutParams.leftMargin = (int) Math.ceil(AndroidUtilities.dp(64) - AndroidUtilities.dp(47) * diff); + layoutParams.topMargin = (int) Math.ceil(avatarY); avatarImage.setLayoutParams(layoutParams); + avatarImage.setRoundRadius(layoutParams.height / 2); + } else { + ViewProxy.setScaleX(avatarImage, (42 + 18 * diff) / 42.0f); + ViewProxy.setScaleY(avatarImage, (42 + 18 * diff) / 42.0f); + ViewProxy.setTranslationX(avatarImage, -AndroidUtilities.dp(47) * diff); + ViewProxy.setTranslationY(avatarImage, (float) Math.ceil(avatarY)); + } + ViewProxy.setTranslationX(nameTextView, -21 * AndroidUtilities.density * diff); + ViewProxy.setTranslationY(nameTextView, (float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff)); + ViewProxy.setTranslationX(onlineTextView, -21 * AndroidUtilities.density * diff); + ViewProxy.setTranslationY(onlineTextView, (float) Math.floor(avatarY) + AndroidUtilities.dp(22) + (float )Math.floor(11 * AndroidUtilities.density) * diff); - ViewProxy.setPivotX(nameTextView, 0); - ViewProxy.setPivotY(nameTextView, 0); - ViewProxy.setScaleX(nameTextView, scale); - ViewProxy.setScaleY(nameTextView, scale); - layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX); - layoutParams.bottomMargin = nameY; - nameTextView.setLayoutParams(layoutParams); - - layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX); - layoutParams.bottomMargin = statusY; - onlineTextView.setLayoutParams(layoutParams); + ViewProxy.setTranslationX(adminTextView, -21 * AndroidUtilities.density * diff); + ViewProxy.setTranslationY(adminTextView, (float) Math.floor(avatarY) + AndroidUtilities.dp(32) + (float )Math.floor(22 * AndroidUtilities.density) * diff); + ViewProxy.setScaleX(nameTextView, 1.0f + 0.12f * diff); + ViewProxy.setScaleY(nameTextView, 1.0f + 0.12f * diff); if (diff > 0.85) { adminTextView.setVisibility(View.VISIBLE); } else { @@ -1087,22 +1090,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. fixLayout(); } - @Override - public boolean needAddActionBar() { - return false; - } - + @SuppressWarnings("unchecked") @Override public void didReceivedNotification(int id, final Object... args) { if (id == NotificationCenter.updateInterfaces) { - int mask = (Integer)args[0]; + int mask = (Integer) args[0]; if (user_id != 0) { if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) { updateProfileData(); } if ((mask & MessagesController.UPDATE_MASK_PHONE) != 0) { if (listView != null) { - listView.invalidateViews(); + ListAdapter.Holder holder = (ListAdapter.Holder) listView.findViewHolderForPosition(phoneRow); + if (holder != null) { + listAdapter.onBindViewHolder(holder, phoneRow); + } } } } else if (chat_id != 0) { @@ -1131,20 +1133,14 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else if (id == NotificationCenter.contactsDidLoaded) { createActionBarMenu(); } else if (id == NotificationCenter.mediaCountDidLoaded) { - long uid = (Long)args[0]; - if (user_id != 0) { - if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) { + long uid = (Long) args[0]; + int lower_part = (int) uid; + if (user_id != 0 && (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) || chat_id != 0 && (lower_part < 0 && chat_id == -lower_part)) { totalMediaCount = (Integer) args[1]; if (listView != null) { - listView.invalidateViews(); - } - } - } else if (chat_id != 0) { - int lower_part = (int)uid; - if (lower_part < 0 && chat_id == -lower_part) { - totalMediaCount = (Integer)args[1]; - if (listView != null) { - listView.invalidateViews(); + ListAdapter.Holder holder = (ListAdapter.Holder) listView.findViewHolderForPosition(sharedMediaRow); + if (holder != null) { + listAdapter.onBindViewHolder(holder, sharedMediaRow); } } } @@ -1163,7 +1159,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. }); } } else if (id == NotificationCenter.encryptedChatUpdated) { - TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0]; + TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) args[0]; if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) { currentEncryptedChat = chat; updateRowsIds(); @@ -1197,6 +1193,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. botInfo = info; updateRowsIds(); } + } if (id == NotificationCenter.didReceivedNewMessages) { + long did = (Long) args[0]; + if (did == dialog_id) { + ArrayList arr = (ArrayList) args[1]; + for (int a = 0; a < arr.size(); a++) { + MessageObject obj = arr.get(a); + if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction && obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL) { + TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction; + if (listAdapter != null) { + listAdapter.notifyDataSetChanged(); + checkListViewScroll(); + } + } + } + } } } @@ -1210,6 +1221,115 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. fixLayout(); } + public void setPlayProfileAnimation(boolean value) { + if (!AndroidUtilities.isTablet()) { + playProfileAnimation = value; + } + } + + @Override + protected void onTransitionAnimationStart(boolean isOpen, boolean backward) { + if (!backward && playProfileAnimation) { + openAnimationInProgress = true; + } + NotificationCenter.getInstance().setAnimationInProgress(true); + } + + @Override + protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (!backward && playProfileAnimation) { + openAnimationInProgress = false; + } + NotificationCenter.getInstance().setAnimationInProgress(false); + } + + public float getAnimationProgress() { + return animationProgress; + } + + public void setAnimationProgress(float progress) { + animationProgress = progress; + ViewProxy.setAlpha(listView, progress); + ViewProxy.setTranslationX(listView, AndroidUtilities.dp(48) * (1.0f - progress)); + /*int color = AvatarDrawable.getProfileBackColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 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)); + extraHeightView.setBackgroundColor(color); + color = AvatarDrawable.getProfileTextColorForId(user_id != 0 || ChatObject.isChannel(chat_id) ? 5 : chat_id); + rD = (int) ((Color.red(color) - 0xd7) * progress); + gD = (int) ((Color.green(color) - 0xe8) * progress); + bD = (int) ((Color.blue(color) - 0xf7) * progress); + onlineTextView.setTextColor(Color.rgb(0xd7 + rD, 0xe8 + gD, 0xf7 + bD));*/ + extraHeight = (int) (initialAnimationExtraHeight * progress); + needLayout(); + } + + @Override + protected AnimatorSetProxy onCustomTransitionAnimation(final boolean isOpen, final Runnable callback) { + if (playProfileAnimation) { + final AnimatorSetProxy animatorSet = new AnimatorSetProxy(); + animatorSet.setDuration(150); + if (Build.VERSION.SDK_INT > 15) { + listView.setLayerType(View.LAYER_TYPE_HARDWARE, null); + } + if (isOpen) { + initialAnimationExtraHeight = AndroidUtilities.dp(88); + fragmentView.setBackgroundColor(0); + setAnimationProgress(0); + ArrayList animators = new ArrayList<>(); + animators.add(ObjectAnimatorProxy.ofFloat(this, "animationProgress", 0.0f, 1.0f)); + if (writeButton != null) { + ViewProxy.setScaleX(writeButton, 0.2f); + ViewProxy.setScaleY(writeButton, 0.2f); + ViewProxy.setAlpha(writeButton, 0.0f); + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 1.0f)); + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 1.0f)); + } + animatorSet.playTogether(animators); + } else { + initialAnimationExtraHeight = extraHeight; + ArrayList animators = new ArrayList<>(); + animators.add(ObjectAnimatorProxy.ofFloat(this, "animationProgress", 1.0f, 0.0f)); + if (writeButton != null) { + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 0.2f)); + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 0.2f)); + animators.add(ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 0.0f)); + } + animatorSet.playTogether(animators); + } + animatorSet.addListener(new AnimatorListenerAdapterProxy() { + @Override + public void onAnimationEnd(Object animation) { + if (Build.VERSION.SDK_INT > 15) { + listView.setLayerType(View.LAYER_TYPE_NONE, null); + } + callback.run(); + } + + @Override + public void onAnimationCancel(Object animation) { + if (Build.VERSION.SDK_INT > 15) { + listView.setLayerType(View.LAYER_TYPE_NONE, null); + } + } + }); + animatorSet.setInterpolator(new DecelerateInterpolator()); + + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + animatorSet.start(); + } + }, 20); + return animatorSet; + } + return null; + } + @Override public void updatePhotoAtIndex(int index) { @@ -1247,6 +1367,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. object.thumb = object.imageReceiver.getBitmap(); object.size = -1; object.radius = avatarImage.getImageReceiver().getRoundRadius(); + object.scale = ViewProxy.getScaleX(avatarImage); return object; } return null; @@ -1272,7 +1393,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. public void setPhotoChecked(int index) { } @Override - public void cancelButtonPressed() { } + public boolean cancelButtonPressed() { return true; } @Override public void sendButtonPressed(int index) { } @@ -1281,10 +1402,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. public int getSelectedCount() { return 0; } private void updateOnlineCount() { + onlineCount = 0; if (!(info instanceof TLRPC.TL_chatFull)) { return; } - onlineCount = 0; int currentTime = ConnectionsManager.getInstance().getCurrentTime(); sortedUsers.clear(); int i = 0; @@ -1353,8 +1474,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. FileLog.e("tmessages", e); //TODO find crash } - if (listView != null) { - listView.invalidateViews(); + if (listAdapter != null) { + listAdapter.notifyItemRangeChanged(emptyRowChat2 + 1, sortedUsers.size()); } } @@ -1373,6 +1494,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); } MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info); + playProfileAnimation = false; finishFragment(); } } @@ -1492,6 +1614,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return; } updateTheme(); + int id = 0; SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); if (user_id != 0) { TLRPC.User user = MessagesController.getInstance().getUser(user_id); @@ -1502,20 +1625,31 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. photoBig = user.photo.photo_big; } AvatarDrawable avatarDrawable = new AvatarDrawable(user); - //Profile photo - int radius = AndroidUtilities.dp(themePrefs.getInt("profileAvatarRadius", 32)); - //int radius = AndroidUtilities.dp(32); - avatarImage.getImageReceiver().setRoundRadius(radius); - avatarDrawable.setRadius(radius); avatarImage.setImage(photo, "50_50", avatarDrawable); - - nameTextView.setText(UserObject.getUserName(user)); - if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) { - onlineTextView.setText(LocaleController.getString("Bot", R.string.Bot)); + + String newString; + newString = UserObject.getUserName(user); + if (!nameTextView.getText().equals(newString)) { + nameTextView.setText(newString); + } + if (user.id == 333000 || user.id == 777000) { + newString = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications); + } else if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) { + newString = LocaleController.getString("Bot", R.string.Bot); } else { - onlineTextView.setText(LocaleController.formatUserStatus(user)); + newString = LocaleController.formatUserStatus(user); + } + if (!onlineTextView.getText().equals(newString)) { + onlineTextView.setText(newString); } + int leftIcon = currentEncryptedChat != null ? R.drawable.ic_lock_header : 0; + nameTextView.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, 0, 0); + + if(BuildConfig.DEBUG){ + id = user_id; + adminTextView.setText("id: " + user_id); + } avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); } else if (chat_id != 0) { TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); @@ -1524,20 +1658,36 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } else { chat = currentChat; } + if (chat.title != null && !nameTextView.getText().equals(chat.title)) { nameTextView.setText(chat.title); + } + if ((chat.flags & TLRPC.CHAT_FLAG_IS_VERIFIED) != 0) { + if (nameTextView.getCompoundDrawables()[2] == null) { + nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.check_profile_fixed, 0); + } + } else { + if (nameTextView.getCompoundDrawables()[2] != null) { + nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); + } + } + String newString; if (ChatObject.isChannel(chat)) { if (info == null || info.participants_count == 0 || ((currentChat.flags & TLRPC.CHAT_FLAG_ADMIN) != 0 || (info.flags & 8) != 0)) { if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) { - onlineTextView.setText(LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase()); + newString = LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase(); } else { - onlineTextView.setText(LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase()); + newString = LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase(); } } 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); + newString = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber); + } + + if(BuildConfig.DEBUG){ + id = chat_id; + adminTextView.setText("id: " + chat_id); } } else { int count = chat.participants_count; @@ -1545,12 +1695,15 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. count = info.participants.participants.size(); } if (count != 0 && onlineCount > 1) { - onlineTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount))); + newString = String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount)); } else { - onlineTextView.setText(LocaleController.formatPluralString("Members", count)); + newString = LocaleController.formatPluralString("Members", count); + } + if (!onlineTextView.getText().equals(newString)) { + onlineTextView.setText(newString); } - if (info != null) { + id = chat_id; adminTextView.setText("Admin: " + UserObject.getUserName(MessagesController.getInstance().getUser(info.participants.admin_id))); } @@ -1561,9 +1714,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. photoBig = chat.photo.photo_big; } avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat, true)); - avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); } + if (!onlineTextView.getText().equals(newString)) { + onlineTextView.setText(newString); + } //Plus: Group and channel profile avatar TLRPC.FileLocation photo = null; if (chat.photo != null) { @@ -1574,18 +1729,83 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. avatarImage.getImageReceiver().setRoundRadius(radius); avatarDrawable.setRadius(radius); avatarImage.setImage(photo, "50_50", avatarDrawable); - } + } + if((BuildConfig.DEBUG)){ + final int fId = id; + adminTextView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + 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(""+fId); + } else { + android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); + android.content.ClipData clip = android.content.ClipData.newPlainText("label", ""+fId); + clipboard.setPrimaryClip(clip); + } + Toast.makeText(getParentActivity(), LocaleController.formatString("Copied", R.string.Copied, fId), Toast.LENGTH_SHORT).show(); + } catch (Exception e) { + FileLog.e("tmessages", e); + } + } + }); + } + } private void updateTheme() { SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); + //int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); int dark = themePrefs.getInt("profileStatusColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x40)); - //actionBar.setBackgroundColor(themePrefs.getInt("profileHeaderColor", def)); + nameTextView.setTextColor(themePrefs.getInt("profileNameColor", 0xffffffff)); + nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("profileNameSize", 18)); + onlineTextView.setTextColor(dark); + int oSize = themePrefs.getInt("profileStatusSize", 14); + onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, oSize); + adminTextView.setTextColor(dark); + if (oSize < 14) adminTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, oSize); + } + + private void updateListBG(){ + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int mainColor = themePrefs.getInt("profileRowColor", 0xffffffff); + int value = themePrefs.getInt("profileRowGradient", 0); + boolean b = true;//themePrefs.getBoolean("profileRowGradientListCheck", false); + if(value > 0 && b) { + GradientDrawable.Orientation go; + switch(value) { + case 2: + go = GradientDrawable.Orientation.LEFT_RIGHT; + break; + case 3: + go = GradientDrawable.Orientation.TL_BR; + break; + case 4: + go = GradientDrawable.Orientation.BL_TR; + break; + default: + go = GradientDrawable.Orientation.TOP_BOTTOM; + } + + int gradColor = themePrefs.getInt("profileRowGradientColor", 0xffffffff); + int[] colors = new int[]{mainColor, gradColor}; + GradientDrawable gd = new GradientDrawable(go, colors); + listView.setBackgroundDrawable(gd); + }else{ + listView.setBackgroundColor(mainColor); + } + listView.setGlowColor(mainColor); + } + + private void updateActionBarBG(){ + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); int hColor = themePrefs.getInt("profileHeaderColor", def); actionBar.setBackgroundColor(hColor); + extraHeightView.setBackgroundColor(hColor); int val = themePrefs.getInt("profileHeaderGradient", 0); if (val > 0) { GradientDrawable.Orientation go; @@ -1606,15 +1826,39 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. int[] colors = new int[]{hColor, gradColor}; GradientDrawable gd = new GradientDrawable(go, colors); actionBar.setBackgroundDrawable(gd); + extraHeightView.setBackgroundDrawable(gd); } + } - nameTextView.setTextColor(themePrefs.getInt("profileNameColor", 0xffffffff)); - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("profileNameSize", 18)); - onlineTextView.setTextColor(dark); - int oSize = themePrefs.getInt("profileStatusSize", 14); - onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, oSize); - adminTextView.setTextColor(dark); - if (oSize < 14) adminTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, oSize); + private void updateViewColor(View v){ + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int mainColor = themePrefs.getInt("profileRowColor", 0xffffffff); + int value = themePrefs.getInt("profileRowGradient", 0); + boolean b = true;//themePrefs.getBoolean("profileRowGradientListCheck", false); + if(value > 0 && !b) { + GradientDrawable.Orientation go; + switch(value) { + case 2: + go = GradientDrawable.Orientation.LEFT_RIGHT; + break; + case 3: + go = GradientDrawable.Orientation.TL_BR; + break; + case 4: + go = GradientDrawable.Orientation.BL_TR; + break; + default: + go = GradientDrawable.Orientation.TOP_BOTTOM; + } + + int gradColor = themePrefs.getInt("profileRowGradientColor", 0xffffffff); + int[] colors = new int[]{mainColor, gradColor}; + GradientDrawable gd = new GradientDrawable(go, colors); + v.setBackgroundDrawable(gd); + } else if(b){ + v.setBackgroundColor(0x00000000); + } + if(value > 0)v.setTag("Profile00"); } private void createActionBarMenu() { @@ -1711,235 +1955,260 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } } - private class ListAdapter extends BaseFragmentAdapter { + private class ListAdapter extends RecyclerListView.Adapter { private Context mContext; + private class Holder extends RecyclerView.ViewHolder { + + public Holder(View itemView) { + super(itemView); + } + } + public ListAdapter(Context context) { mContext = context; } @Override - public boolean areAllItemsEnabled() { - return false; - } - - @Override - public boolean isEnabled(int i) { - if (user_id != 0) { - return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow || i == usernameRow; - } else if (chat_id != 0) { - return i == settingsNotificationsRow || i == sharedMediaRow || i > emptyRowChat2 && i < membersEndRow || i == addMemberRow || i == channelNameRow || i == leaveChannelRow || i == membersRow || i == managementRow || i == blockedUsersRow || i == channelInfoRow; - } - return false; - } - - @Override - public int getCount() { - return rowCount; - } - - @Override - public Object getItem(int i) { - return null; - } - - @Override - public long getItemId(int i) { - return i; - } - - @Override - public boolean hasStableIds() { - return false; - } - - @Override - public View getView(int i, View view, ViewGroup viewGroup) { - int type = getItemViewType(i); - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); - int tColor = themePrefs.getInt("profileTitleColor", 0xff212121); - int dColor = themePrefs.getInt("profileIconsColor", 0xff737373); - if (type == 0) { - if (view == null) { + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + View view = null; + switch (viewType) { + case 0: view = new EmptyCell(mContext); - } - if (i == overscrollRow) { - ((EmptyCell) view).setHeight(AndroidUtilities.dp(88)); - } else if (i == emptyRowChat || i == emptyRowChat2) { - ((EmptyCell) view).setHeight(AndroidUtilities.dp(8)); - } else { - ((EmptyCell) view).setHeight(AndroidUtilities.dp(36)); - } - updateViewColor(view); - } else if (type == 1) { - if (view == null) { + break; + case 1: view = new DividerCell(mContext); view.setPadding(AndroidUtilities.dp(72), 0, 0, 0); - view.setTag("profileRowColor"); - } - updateViewColor(view); - } else if (type == 2) { - if (view == null) { - view = new TextDetailCell(mContext); - } - updateViewColor(view); - TextDetailCell textDetailCell = (TextDetailCell) view; - textDetailCell.setTextColor(tColor); - textDetailCell.setValueColor(themePrefs.getInt("profileSummaryColor", 0xff8a8a8a)); - if (i == phoneRow) { - String text; - final TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user.phone != null && user.phone.length() != 0) { - text = PhoneFormat.getInstance().format("+" + user.phone); - } else { - text = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); - } - //textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey); - Drawable ph = mContext.getResources().getDrawable(R.drawable.phone_grey); - ph.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); - textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), ph); - } else if (i == usernameRow) { - String text; - final TLRPC.User user = MessagesController.getInstance().getUser(user_id); - if (user != null && user.username != null && user.username.length() != 0) { - text = "@" + user.username; - } else { - text = "-"; - } - textDetailCell.setTextAndValue(text, LocaleController.getString("Username", R.string.Username)); - } else if (i == channelNameRow) { - String text; - if (currentChat != null && currentChat.username != null && currentChat.username.length() != 0) { - text = "@" + currentChat.username; - } else { - text = "-"; - } - textDetailCell.setTextAndValue(text, "telegram.me/" + currentChat.username); - } - } else if (type == 3) { - if (view == null) { - view = new TextCell(mContext); - } - updateViewColor(view); - TextCell textCell = (TextCell) view; - //textCell.setTextColor(0xff212121); - textCell.setTextColor(tColor); - if (i == sharedMediaRow) { - String value; - if (totalMediaCount == -1) { - value = LocaleController.getString("Loading", R.string.Loading); - } else { - value = String.format("%d", totalMediaCount); - } - textCell.setMultiline(false); - textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value); - textCell.setValueColor(themePrefs.getInt("profileTitleColor", def)); - } else if (i == settingsTimerRow) { - TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); - String value; - if (encryptedChat.ttl == 0) { - value = LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever); - } else { - value = AndroidUtilities.formatTTLString(encryptedChat.ttl); - } - textCell.setMultiline(false); - textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value); - } else if (i == settingsNotificationsRow) { - textCell.setMultiline(false); - //textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list); - Drawable pf = mContext.getResources().getDrawable(R.drawable.profile_list); - pf.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); - textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), pf); - } else if (i == startSecretChatRow) { - textCell.setMultiline(false); - textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); - //textCell.setTextColor(0xff37a919); - textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); - } else if (i == settingsKeyRow) { - IdenticonDrawable identiconDrawable = new IdenticonDrawable(); - TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); - identiconDrawable.setEncryptedChat(encryptedChat); - textCell.setMultiline(false); - textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable); - } else if (i == botInfoRow) { - textCell.setMultiline(true); - //textCell.setTextAndIcon(botInfo.share_text, R.drawable.bot_info); - Drawable bot = mContext.getResources().getDrawable(R.drawable.bot_info); - if(bot!= null)bot.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); - textCell.setTextAndIcon(botInfo.share_text, bot); - } else if (i == channelInfoRow) { - textCell.setMultiline(true); - //textCell.setTextAndIcon(info.about, R.drawable.bot_info); - Drawable bot = mContext.getResources().getDrawable(R.drawable.bot_info); - if(bot!= null)bot.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); - textCell.setTextAndIcon(info.about, bot); - } else if (i == leaveChannelRow) { - //textCell.setTextColor(0xffed3d39); - textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); - textCell.setMultiline(false); - textCell.setText(LocaleController.getString("LeaveChannel", R.string.LeaveChannel)); - } else if (i == membersRow) { - textCell.setMultiline(false); - if (info != null) { - textCell.setTextAndValue(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants_count)); - } else { - textCell.setText(LocaleController.getString("ChannelMembers", R.string.ChannelMembers)); - } - } else if (i == managementRow) { - textCell.setMultiline(false); - if (info != null) { - textCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", info.admins_count)); - } else { - textCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators)); - } - } else if (i == blockedUsersRow) { - textCell.setMultiline(false); - if (info != null) { - textCell.setTextAndValue(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers), String.format("%d", info.kicked_count)); - } else { - textCell.setText(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers)); - } - } - } else if (type == 4) { - if (view == null) { - view = new UserCell(mContext, 61); - view.setTag("Profile"); - } - updateViewColor(view); - TLRPC.TL_chatParticipant part = info.participants.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)); - //((UserCell)view).setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0); - int icon = 0; - if (info.participants.admin_id == part.user_id) { - icon = R.drawable.menu_admin; - } else if (part.user_id == UserConfig.getClientUserId()) { - icon = R.drawable.menu_newgroup; - } - ((UserCell) view).setData(MessagesController.getInstance().getUser(part.user_id), null, null, icon); - - } else if (type == 5) { - if (view == null) { - //view = new ShadowSectionCell(mContext); - view = new ShadowSectionCell(mContext, false); - } - view.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff)); - updateViewColor(view); - } else if (type == 6) { - if (view == null) { + break; + case 2: + view = new TextDetailCell(mContext) { + @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); + } + }; + break; +case 3: + view = new TextCell(mContext) { + @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); + } + }; + break; + case 4: + view = new UserCell(mContext, 61) { + @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); + } + }; + break; + case 5: + view = new ShadowSectionCell(mContext); + break; + case 6: view = new AddMemberCell(mContext); if (chat_id > 0) { ((AddMemberCell) view).setText(LocaleController.getString("AddMember", R.string.AddMember)); } else { ((AddMemberCell) view).setText(LocaleController.getString("AddRecipient", R.string.AddRecipient)); } - } - updateViewColor(view); - ((AddMemberCell) view).setTextColor(tColor); - ((AddMemberCell) view).setDrawableColor(dColor); + break; } - //viewGroup.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff)); - updateListBG(viewGroup); - return view; + return new Holder(view); + } + + @Override + public void onBindViewHolder(RecyclerView.ViewHolder holder, int i) { + boolean checkBackground = true; + SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor); + int tColor = themePrefs.getInt("profileTitleColor", 0xff212121); + int dColor = themePrefs.getInt("profileIconsColor", 0xff737373); + switch (holder.getItemViewType()) { + case 0: + if (i == overscrollRow) { + ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(88)); + } else if (i == emptyRowChat || i == emptyRowChat2) { + ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(8)); + } else { + ((EmptyCell) holder.itemView).setHeight(AndroidUtilities.dp(36)); + } + updateViewColor(holder.itemView); + break; + case 2: + updateViewColor(holder.itemView); + TextDetailCell textDetailCell = (TextDetailCell) holder.itemView; + textDetailCell.setTextColor(tColor); + textDetailCell.setValueColor(themePrefs.getInt("profileSummaryColor", 0xff8a8a8a)); + if (i == phoneRow) { + String text; + final TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user.phone != null && user.phone.length() != 0) { + text = PhoneFormat.getInstance().format("+" + user.phone); + } else { + text = LocaleController.getString("NumberUnknown", R.string.NumberUnknown); + } + //textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey); + Drawable ph = mContext.getResources().getDrawable(R.drawable.phone_grey); + ph.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); + textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), ph); + } else if (i == usernameRow) { + String text; + final TLRPC.User user = MessagesController.getInstance().getUser(user_id); + if (user != null && user.username != null && user.username.length() != 0) { + text = "@" + user.username; + } else { + text = "-"; + } + textDetailCell.setTextAndValue(text, LocaleController.getString("Username", R.string.Username)); + } else if (i == channelNameRow) { + String text; + if (currentChat != null && currentChat.username != null && currentChat.username.length() != 0) { + text = "@" + currentChat.username; + } else { + text = "-"; + } + textDetailCell.setTextAndValue(text, "telegram.me/" + currentChat.username); + } + break; + case 3: + updateViewColor(holder.itemView); + TextCell textCell = (TextCell) holder.itemView; + //textCell.setTextColor(0xff212121); + textCell.setTextColor(tColor); + + if (i == sharedMediaRow) { + String value; + if (totalMediaCount == -1) { + value = LocaleController.getString("Loading", R.string.Loading); + } else { + value = String.format("%d", totalMediaCount); + } + textCell.setMultiline(false); + textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value); + textCell.setValueColor(themePrefs.getInt("profileTitleColor", def)); + } else if (i == settingsTimerRow) { + TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); + String value; + if (encryptedChat.ttl == 0) { + value = LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever); + } else { + value = AndroidUtilities.formatTTLString(encryptedChat.ttl); + } + textCell.setMultiline(false); + textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value); + } else if (i == settingsNotificationsRow) { + textCell.setMultiline(false); + //textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list); + Drawable pf = mContext.getResources().getDrawable(R.drawable.profile_list); + pf.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); + textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), pf); + } else if (i == startSecretChatRow) { + textCell.setMultiline(false); + textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); + //textCell.setTextColor(0xff37a919); + textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); + } else if (i == settingsKeyRow) { + IdenticonDrawable identiconDrawable = new IdenticonDrawable(); + TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); + identiconDrawable.setEncryptedChat(encryptedChat); + textCell.setMultiline(false); + textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable); + } else if (i == botInfoRow) { + textCell.setMultiline(true); + //textCell.setTextAndIcon(botInfo.share_text, R.drawable.bot_info); + Drawable bot = mContext.getResources().getDrawable(R.drawable.bot_info); + if(bot!= null)bot.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); + textCell.setTextAndIcon(botInfo.share_text, bot); + } else if (i == channelInfoRow) { + textCell.setMultiline(true); + //textCell.setTextAndIcon(info.about, R.drawable.bot_info); + Drawable bot = mContext.getResources().getDrawable(R.drawable.bot_info); + if(bot!= null)bot.setColorFilter(dColor, PorterDuff.Mode.SRC_IN); + textCell.setTextAndIcon(info.about, bot); + } else if (i == leaveChannelRow) { + //textCell.setTextColor(0xffed3d39); + textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); + textCell.setMultiline(false); + textCell.setText(LocaleController.getString("LeaveChannel", R.string.LeaveChannel)); + } else if (i == membersRow) { + textCell.setMultiline(false); + if (info != null) { + textCell.setTextAndValue(LocaleController.getString("ChannelMembers", R.string.ChannelMembers), String.format("%d", info.participants_count)); + } else { + textCell.setText(LocaleController.getString("ChannelMembers", R.string.ChannelMembers)); + } + } else if (i == managementRow) { + textCell.setMultiline(false); + if (info != null) { + textCell.setTextAndValue(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators), String.format("%d", info.admins_count)); + } else { + textCell.setText(LocaleController.getString("ChannelAdministrators", R.string.ChannelAdministrators)); + } + } else if (i == blockedUsersRow) { + textCell.setMultiline(false); + if (info != null) { + textCell.setTextAndValue(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers), String.format("%d", info.kicked_count)); + } else { + textCell.setText(LocaleController.getString("ChannelBlockedUsers", R.string.ChannelBlockedUsers)); + } + } + break; + case 4: + updateViewColor(holder.itemView); + TLRPC.TL_chatParticipant part = info.participants.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)); + //((UserCell) holder.itemView).setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0); + int icon = 0; + if (info.participants.admin_id == part.user_id) { + icon = R.drawable.menu_admin; + } else if (part.user_id == UserConfig.getClientUserId()) { + icon = R.drawable.menu_newgroup; + } + ((UserCell) holder.itemView).setData(MessagesController.getInstance().getUser(part.user_id), null, null, icon); + break; + default: + checkBackground = false; + } + if (checkBackground) { + boolean enabled = false; + if (user_id != 0) { + enabled = i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == startSecretChatRow || i == usernameRow; + } else if (chat_id != 0) { + enabled = 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) { + //holder.itemView.setBackgroundResource(R.drawable.list_selector); + holder.itemView.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff)); + } + } else { + if (holder.itemView.getBackground() != null) { + holder.itemView.setBackgroundDrawable(null); + } + } + } + } + + @Override + public int getItemCount() { + return rowCount; } @Override @@ -1962,75 +2231,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. return 0; } - @Override - public int getViewTypeCount() { - return 7; - } + /*@Override + public boolean isEnabled(int i) { - @Override - public boolean isEmpty() { return false; - } - } - - private void updateListBG(ViewGroup vg){ - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int mainColor = themePrefs.getInt("profileRowColor", 0xffffffff); - int value = themePrefs.getInt("profileRowGradient", 0); - boolean b = true;//themePrefs.getBoolean("profileRowGradientListCheck", false); - if(value > 0 && b) { - GradientDrawable.Orientation go; - switch(value) { - case 2: - go = GradientDrawable.Orientation.LEFT_RIGHT; - break; - case 3: - go = GradientDrawable.Orientation.TL_BR; - break; - case 4: - go = GradientDrawable.Orientation.BL_TR; - break; - default: - go = GradientDrawable.Orientation.TOP_BOTTOM; - } - - int gradColor = themePrefs.getInt("profileRowGradientColor", 0xffffffff); - int[] colors = new int[]{mainColor, gradColor}; - GradientDrawable gd = new GradientDrawable(go, colors); - vg.setBackgroundDrawable(gd); - }else{ - vg.setBackgroundColor(mainColor); - } - } - - private void updateViewColor(View v){ - SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - int mainColor = themePrefs.getInt("profileRowColor", 0xffffffff); - int value = themePrefs.getInt("profileRowGradient", 0); - boolean b = true;//themePrefs.getBoolean("profileRowGradientListCheck", false); - if(value > 0 && !b) { - GradientDrawable.Orientation go; - switch(value) { - case 2: - go = GradientDrawable.Orientation.LEFT_RIGHT; - break; - case 3: - go = GradientDrawable.Orientation.TL_BR; - break; - case 4: - go = GradientDrawable.Orientation.BL_TR; - break; - default: - go = GradientDrawable.Orientation.TOP_BOTTOM; - } - - int gradColor = themePrefs.getInt("profileRowGradientColor", 0xffffffff); - int[] colors = new int[]{mainColor, gradColor}; - GradientDrawable gd = new GradientDrawable(go, colors); - v.setBackgroundDrawable(gd); - } else if(b){ - v.setBackgroundColor(0x00000000); - } - if(value > 0)v.setTag("Profile00"); + }*/ } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index 0dd74e78..d6b3eb45 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.4.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -35,11 +35,11 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesStorage; import org.telegram.messenger.NotificationsController; import org.telegram.messenger.ApplicationLoader; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Cells.TextColorCell; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java index 46bdddc1..9ca19d12 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SecretPhotoViewer.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -18,6 +18,7 @@ import android.graphics.PixelFormat; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.os.Build; import android.text.Layout; import android.text.StaticLayout; import android.text.TextPaint; @@ -34,10 +35,10 @@ import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.MessageObject; import org.telegram.messenger.NotificationCenter; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; import org.telegram.ui.Components.LayoutHelper; @@ -257,12 +258,20 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD BitmapDrawable drawable = ImageLoader.getInstance().getImageFromMemory(sizeFull.location, null, null); if (drawable == null) { File file = FileLoader.getPathToAttach(sizeFull); - Bitmap bitmap; + Bitmap bitmap = null; + BitmapFactory.Options options = null; + if (Build.VERSION.SDK_INT >= 14 && Build.VERSION.SDK_INT < 21) { + options = new BitmapFactory.Options(); + options.inDither = true; + options.inPreferredConfig = Bitmap.Config.ARGB_8888; + options.inPurgeable = true; + options.inSampleSize = 1; + options.inMutable = true; + } try { - bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); + bitmap = BitmapFactory.decodeFile(file.getAbsolutePath(), options); } catch (Throwable e) { - ImageLoader.getInstance().clearMemory(); - bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); + FileLog.e("tmessages", e); } if (bitmap != null) { drawable = new BitmapDrawable(bitmap); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java index 37a3d120..229033fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SessionsActivity.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index f07680e5..29212281 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -110,6 +110,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private ImageView writeButton; private AnimatorSetProxy writeButtonAnimation; private AvatarUpdater avatarUpdater = new AvatarUpdater(); + private View extraHeightView; + private View shadowView; + + private int extraHeight; private int overscrollRow; private int emptyRow; @@ -129,7 +133,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private int wifiDownloadRow; private int roamingDownloadRow; private int saveToGalleryRow; - //private int messagesSectionRow; + private int messagesSectionRow; private int messagesSectionRow2; private int textSizeRow; private int stickersRow; @@ -261,7 +265,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter saveToGalleryRow = rowCount++; keepOriginalFilenameRow = rowCount++; keepOriginalFilenameDetailRow = rowCount++; - //messagesSectionRow = rowCount++; + messagesSectionRow = rowCount++; messagesSectionRow2 = rowCount++; textSizeRow = rowCount++; @@ -284,7 +288,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (BuildConfig.DEBUG) { sendLogsRow = rowCount++; clearLogsRow = rowCount++; - //switchBackendButtonRow = rowCount++; + --switchBackendButtonRow; } //versionRow = rowCount++; //contactsSectionRow = rowCount++; @@ -307,21 +311,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter avatarUpdater.clear(); } - @Override - public boolean needAddActionBar() { - return false; - } - @Override public View createView(Context context) { - actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5)); - actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5)); + //actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5)); + //actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5)); actionBar.setBackButtonImage(R.drawable.ic_ab_back); - //Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); - //SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - //back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); - //actionBar.setBackButtonDrawable(back); - actionBar.setExtraHeight(AndroidUtilities.dp(88), false); + actionBar.setAddToContainer(false); + extraHeight = 88; if (AndroidUtilities.isTablet()) { actionBar.setOccupyStatusBar(false); } @@ -391,52 +387,17 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter }; FrameLayout frameLayout = (FrameLayout) fragmentView; - avatarImage = new BackupImageView(context); - avatarImage.setRoundRadius(AndroidUtilities.dp(30)); - actionBar.addView(avatarImage, LayoutHelper.createFrame(60, 60, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 0 : 17, 0, LocaleController.isRTL ? 17 : 0, 22)); - avatarImage.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); - if (user.photo != null && user.photo.photo_big != null) { - PhotoViewer.getInstance().setParentActivity(getParentActivity()); - PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); - } - } - }); - SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); - nameTextView = new TextView(context); - //nameTextView.setTextColor(0xffffffff); - nameTextView.setTextColor(preferences.getInt("prefHeaderTitleColor", 0xffffffff)); - - nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); - nameTextView.setLines(1); - nameTextView.setMaxLines(1); - nameTextView.setSingleLine(true); - nameTextView.setEllipsize(TextUtils.TruncateAt.END); - nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); - actionBar.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 16 : 97, 0, LocaleController.isRTL ? 97 : 16, 51)); - - onlineTextView = new TextView(context); - //onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(5)); - onlineTextView.setTextColor(preferences.getInt("prefHeaderStatusColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x40))); - onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - onlineTextView.setLines(1); - onlineTextView.setMaxLines(1); - onlineTextView.setSingleLine(true); - onlineTextView.setEllipsize(TextUtils.TruncateAt.END); - onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT)); - actionBar.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 16 : 97, 0, LocaleController.isRTL ? 97 : 16, 30)); - listView = new ListView(context); - + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); int bgColor = preferences.getInt("prefBGColor", 0xffffffff); + int def = preferences.getInt("themeColor", AndroidUtilities.defColor); + int hColor = preferences.getInt("prefHeaderColor", def); listView.setBackgroundColor(bgColor); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); - AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); + //AndroidUtilities.setListViewEdgeEffectColor(listView, AvatarDrawable.getProfileBackColorForId(5)); + AndroidUtilities.setListViewEdgeEffectColor(listView, bgColor); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -610,7 +571,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - ConnectionsManager.getInstance().switchBackend(); + //ConnectionsManager.getInstance().switchBackend(); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); @@ -623,7 +584,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter FileLog.e("tmessages", e); } } else if (i == contactsReimportRow) { - //not implemented + //not implemented } else if (i == contactsSortRow) { if (getParentActivity() == null) { return; @@ -787,6 +748,61 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter frameLayout.addView(actionBar); + extraHeightView = new View(context); + ViewProxy.setPivotY(extraHeightView, 0); + //extraHeightView.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5)); + extraHeightView.setBackgroundColor(hColor); + frameLayout.addView(extraHeightView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 88)); + + shadowView = new View(context); + shadowView.setBackgroundResource(R.drawable.header_shadow); + frameLayout.addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 3)); + + avatarImage = new BackupImageView(context); + //avatarImage.setRoundRadius(AndroidUtilities.dp(21)); + int radius = AndroidUtilities.getIntDef("prefAvatarRadius", 32); + avatarImage.setRoundRadius(radius); + ViewProxy.setPivotX(avatarImage, 0); + ViewProxy.setPivotY(avatarImage, 0); + frameLayout.addView(avatarImage, LayoutHelper.createFrame(42, 42, Gravity.TOP | Gravity.LEFT, 64, 0, 0, 0)); + avatarImage.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); + if (user.photo != null && user.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); + PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); + } + } + }); + + SharedPreferences themesPrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); + + nameTextView = new TextView(context); + //nameTextView.setTextColor(0xffffffff); + nameTextView.setTextColor(preferences.getInt("prefHeaderTitleColor", 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.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); + ViewProxy.setPivotX(nameTextView, 0); + ViewProxy.setPivotY(nameTextView, 0); + frameLayout.addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); + + onlineTextView = new TextView(context); + //onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(5)); + onlineTextView.setTextColor(preferences.getInt("prefHeaderStatusColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x40))); + 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); + frameLayout.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 118, 0, 48, 0)); + writeButton = new ImageView(context); writeButton.setBackgroundResource(R.drawable.floating_user_states); if(bgColor != 0xffffffff) { @@ -815,7 +831,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } }); } - frameLayout.addView(writeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, LocaleController.isRTL ? 16 : 0, 0, LocaleController.isRTL ? 0 : 16, 0)); + frameLayout.addView(writeButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0)); writeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -858,6 +874,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } }); + needLayout(); + listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { @@ -875,8 +893,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (firstVisibleItem == 0) { height = AndroidUtilities.dp(88) + (child.getTop() < 0 ? child.getTop() : 0); } - if (actionBar.getExtraHeight() != height) { - actionBar.setExtraHeight(height, true); + if (extraHeight != height) { + extraHeight = height; needLayout(); } } @@ -916,6 +934,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter object.thumb = object.imageReceiver.getBitmap(); object.size = -1; object.radius = avatarImage.getImageReceiver().getRoundRadius(); + object.scale = ViewProxy.getScaleX(avatarImage); return object; } } @@ -946,7 +965,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } @Override - public void cancelButtonPressed() { + public boolean cancelButtonPressed() { + return true; } @Override @@ -1106,32 +1126,30 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter private void needLayout() { FrameLayout.LayoutParams layoutParams; + int newTop = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); if (listView != null) { layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); - layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight(); + if (layoutParams.topMargin != newTop) { + layoutParams.topMargin = newTop; listView.setLayoutParams(layoutParams); + ViewProxy.setTranslationY(extraHeightView, newTop); + } } if (avatarImage != null) { - float diff = actionBar.getExtraHeight() / (float) AndroidUtilities.dp(88); - float diffm = 1.0f - diff; + float diff = extraHeight / (float) AndroidUtilities.dp(88); - int avatarSize = 42 + (int) (18 * diff); - int avatarX = 17 + (int) (47 * diffm); - int avatarY = AndroidUtilities.dp(22) - (int) ((AndroidUtilities.dp(22) - (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(42)) / 2) * (1.0f - diff)); - int nameX = 97 + (int) (21 * diffm); - int nameEndX = 16 + (int) (32 * diffm); - int nameY = avatarY + AndroidUtilities.dp(29 - 13 * diffm); - int statusY = avatarY + AndroidUtilities.dp(8 - 7 * diffm); - float scale = 1.0f - 0.12f * diffm; + ViewProxy.setScaleY(extraHeightView, diff); + ViewProxy.setTranslationY(shadowView, newTop + extraHeight); + if (Build.VERSION.SDK_INT < 11) { layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams(); - layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f); + layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f); writeButton.setLayoutParams(layoutParams); + } else { + ViewProxy.setTranslationY(writeButton, (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() + extraHeight - AndroidUtilities.dp(29.5f)); + } - //ViewProxy.setScaleX(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f); - //ViewProxy.setScaleY(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f); - //ViewProxy.setAlpha(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f); final boolean setVisible = diff > 0.2f; boolean currentVisible = writeButton.getTag() == null; if (setVisible != currentVisible) { @@ -1175,34 +1193,18 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter }); writeButtonAnimation.start(); } - int aSize = AndroidUtilities.getIntDef("prefAvatarSize", 64);//Plus - avatarSize = aSize > 46 ? (aSize - 20) + (int) (18 * diff) : aSize;//Plus - //avatarImage.setRoundRadius(AndroidUtilities.dp(avatarSize / 2)); - int radius = AndroidUtilities.getIntDef("prefAvatarRadius", 32); - avatarImage.setRoundRadius(AndroidUtilities.dp(radius)); - layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); - layoutParams.width = AndroidUtilities.dp(avatarSize); - layoutParams.height = AndroidUtilities.dp(avatarSize); - layoutParams.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(avatarX); - layoutParams.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(avatarX) : 0; - layoutParams.bottomMargin = avatarY; - avatarImage.setLayoutParams(layoutParams); - ViewProxy.setPivotX(nameTextView, 0); - ViewProxy.setPivotY(nameTextView, 0); - ViewProxy.setScaleX(nameTextView, scale); - ViewProxy.setScaleY(nameTextView, scale); - layoutParams = (FrameLayout.LayoutParams) nameTextView.getLayoutParams(); - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX); - layoutParams.bottomMargin = nameY; - nameTextView.setLayoutParams(layoutParams); - - layoutParams = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams(); - layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameEndX : nameX); - layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? nameX : nameEndX); - layoutParams.bottomMargin = statusY; - onlineTextView.setLayoutParams(layoutParams); + ViewProxy.setScaleX(avatarImage, (42 + 18 * diff) / 42.0f); + ViewProxy.setScaleY(avatarImage, (42 + 18 * diff) / 42.0f); + float avatarY = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + ActionBar.getCurrentActionBarHeight() / 2.0f * (1.0f + diff) - 21 * AndroidUtilities.density + 27 * AndroidUtilities.density * diff; + ViewProxy.setTranslationX(avatarImage, -AndroidUtilities.dp(47) * diff); + ViewProxy.setTranslationY(avatarImage, (float) Math.ceil(avatarY)); + ViewProxy.setTranslationX(nameTextView, -21 * AndroidUtilities.density * diff); + ViewProxy.setTranslationY(nameTextView, (float) Math.floor(avatarY) - (float) Math.ceil(AndroidUtilities.density) + (float) Math.floor(7 * AndroidUtilities.density * diff)); + ViewProxy.setTranslationX(onlineTextView, -21 * AndroidUtilities.density * diff); + ViewProxy.setTranslationY(onlineTextView, (float) Math.floor(avatarY) + AndroidUtilities.dp(22) + (float )Math.floor(11 * AndroidUtilities.density) * diff); + ViewProxy.setScaleX(nameTextView, 1.0f + 0.12f * diff); + ViewProxy.setScaleY(nameTextView, 1.0f + 0.12f * diff); } } @@ -1258,6 +1260,15 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter } if (uris.isEmpty()) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + if (getParentActivity() != null) { + Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("SendLogsEmpty", R.string.SendLogsEmpty), Toast.LENGTH_SHORT); + toast.show(); + } + } + }); return; } Intent i = new Intent(Intent.ACTION_SEND_MULTIPLE); @@ -1544,7 +1555,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (i == emptyRow || i == overscrollRow) { return 0; } - if (i == settingsSectionRow || i == supportSectionRow /*|| i == messagesSectionRow*/ || i == mediaDownloadSection || i == contactsSectionRow || i == dialogsSectionRow) { + if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow || i == dialogsSectionRow) { return 1; } else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == disableAudioStopRow || i == disableMessageClickRow || i == showAndroidEmojiRow || i == useDeviceFontRow || i == keepOriginalFilenameRow ) { return 3; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java index 73fc4edb..9039c319 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java index e0dbeb15..4075d356 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java index 92894326..080e359a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingChatsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java index 93684dc0..5542cdd6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingContactsActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingDrawerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingDrawerActivity.java index 2c28240d..aecb2386 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingDrawerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingDrawerActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ThemingProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ThemingProfileActivity.java index 1c87726f..ae4e5855 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ThemingProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ThemingProfileActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java index 53f8b4bc..214a2c65 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java @@ -1,5 +1,5 @@ /* - * This is the source code of Telegram for Android v. 2.x + * 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). * @@ -44,9 +44,9 @@ import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.ApplicationLoader; -import org.telegram.tgnet.ConnectionsManager; import org.telegram.messenger.FileLog; import org.telegram.messenger.R; +import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.RequestDelegate; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; @@ -469,9 +469,8 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific } @Override - public void onOpenAnimationEnd() { - super.onOpenAnimationEnd(); - if (type == 1) { + public void onTransitionAnimationEnd(boolean isOpen, boolean backward) { + if (isOpen && type == 1) { AndroidUtilities.showKeyboard(passwordEditText); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java index cb02531e..fe59e10b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/VideoEditorActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.7.x. + * 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-2014. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java index fcfab8d4..83b13fe4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/WallpapersActivity.java @@ -1,9 +1,9 @@ /* - * This is the source code of Telegram for Android v. 1.3.2. + * 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. + * Copyright Nikolai Kudashov, 2013-2015. */ package org.telegram.ui; @@ -87,7 +87,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent selectedBackground = preferences.getInt("selectedBackground", 1000001); selectedColor = preferences.getInt("selectedColor", 0); MessagesStorage.getInstance().getWallpapers(); - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); toFile.delete(); return true; } @@ -125,7 +125,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height)); String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg"; File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg"); try { done = AndroidUtilities.copyFile(f, toFile); } catch (Exception e) { @@ -134,8 +134,8 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent } } else { if (selectedBackground == -1) { - File fromFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg"); - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); + File fromFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg"); done = fromFile.renameTo(toFile); } else { done = true; @@ -266,11 +266,12 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent try { Point screenSize = AndroidUtilities.getRealScreenSize(); Bitmap bitmap = ImageLoader.loadBitmap(currentPicturePath, null, screenSize.x, screenSize.y, true); - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); stream = new FileOutputStream(toFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream); selectedBackground = -1; selectedColor = 0; + Drawable drawable = backgroundImage.getDrawable(); backgroundImage.setImageBitmap(bitmap); } catch (Exception e) { FileLog.e("tmessages", e); @@ -291,11 +292,12 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent try { Point screenSize = AndroidUtilities.getRealScreenSize(); Bitmap bitmap = ImageLoader.loadBitmap(null, data.getData(), screenSize.x, screenSize.y, true); - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); FileOutputStream stream = new FileOutputStream(toFile); bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream); selectedBackground = -1; selectedColor = 0; + Drawable drawable = backgroundImage.getDrawable(); backgroundImage.setImageBitmap(bitmap); } catch (Exception e) { FileLog.e("tmessages", e); @@ -365,9 +367,9 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent backgroundImage.setBackgroundColor(0); selectedColor = 0; } else if (selectedBackground == -1) { - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg"); + File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); if (!toFile.exists()) { - toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); + toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg"); } if (toFile.exists()) { backgroundImage.setImageURI(Uri.fromFile(toFile)); @@ -380,6 +382,7 @@ public class WallpapersActivity extends BaseFragment implements NotificationCent return; } if (wallPaper instanceof TLRPC.TL_wallPaperSolid) { + Drawable drawable = backgroundImage.getDrawable(); backgroundImage.setImageBitmap(null); selectedColor = 0xff000000 | wallPaper.bg_color; backgroundImage.setBackgroundColor(selectedColor); diff --git a/TMessagesProj/src/main/res/drawable-hdpi/Thumbs.db b/TMessagesProj/src/main/res/drawable-hdpi/Thumbs.db deleted file mode 100644 index 44ad831b..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/Thumbs.db and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/editheader.9.png b/TMessagesProj/src/main/res/drawable-hdpi/editheader.9.png deleted file mode 100644 index 00240da6..00000000 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/editheader.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-hdpi/mic_pressed.png b/TMessagesProj/src/main/res/drawable-hdpi/mic_pressed.png index 3cf43e04..ae9ea3bf 100644 Binary files a/TMessagesProj/src/main/res/drawable-hdpi/mic_pressed.png and b/TMessagesProj/src/main/res/drawable-hdpi/mic_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/Thumbs.db b/TMessagesProj/src/main/res/drawable-mdpi/Thumbs.db deleted file mode 100644 index 48830ca3..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/Thumbs.db and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/editheader.9.png b/TMessagesProj/src/main/res/drawable-mdpi/editheader.9.png deleted file mode 100644 index e7f67fe0..00000000 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/editheader.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/mic_pressed.png b/TMessagesProj/src/main/res/drawable-mdpi/mic_pressed.png index e1b29c5b..ed471652 100644 Binary files a/TMessagesProj/src/main/res/drawable-mdpi/mic_pressed.png and b/TMessagesProj/src/main/res/drawable-mdpi/mic_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml b/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml index 7c7941ef..1d5c6abe 100644 --- a/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml +++ b/TMessagesProj/src/main/res/drawable-v21/bar_selector.xml @@ -1,4 +1,5 @@ + android:color="#ff00796B"> + diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/Thumbs.db b/TMessagesProj/src/main/res/drawable-xhdpi/Thumbs.db deleted file mode 100644 index 8087e90e..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/Thumbs.db and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/editheader.9.png b/TMessagesProj/src/main/res/drawable-xhdpi/editheader.9.png deleted file mode 100644 index 50261891..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/editheader.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xhdpi/mic_pressed.png b/TMessagesProj/src/main/res/drawable-xhdpi/mic_pressed.png index 62e655be..bebe9361 100644 Binary files a/TMessagesProj/src/main/res/drawable-xhdpi/mic_pressed.png and b/TMessagesProj/src/main/res/drawable-xhdpi/mic_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/Thumbs.db b/TMessagesProj/src/main/res/drawable-xxhdpi/Thumbs.db index dac9f88d..c082d314 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/Thumbs.db and b/TMessagesProj/src/main/res/drawable-xxhdpi/Thumbs.db differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/editheader.9.png b/TMessagesProj/src/main/res/drawable-xxhdpi/editheader.9.png deleted file mode 100644 index a58727f9..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/editheader.9.png and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable-xxhdpi/mic_pressed.png b/TMessagesProj/src/main/res/drawable-xxhdpi/mic_pressed.png index c972af2b..e7ca0042 100644 Binary files a/TMessagesProj/src/main/res/drawable-xxhdpi/mic_pressed.png and b/TMessagesProj/src/main/res/drawable-xxhdpi/mic_pressed.png differ diff --git a/TMessagesProj/src/main/res/drawable-xxxhdpi/Thumbs.db b/TMessagesProj/src/main/res/drawable-xxxhdpi/Thumbs.db deleted file mode 100644 index 3c563db4..00000000 Binary files a/TMessagesProj/src/main/res/drawable-xxxhdpi/Thumbs.db and /dev/null differ diff --git a/TMessagesProj/src/main/res/drawable/bar_selector.xml b/TMessagesProj/src/main/res/drawable/bar_selector.xml index 961d245f..e7f8b624 100644 --- a/TMessagesProj/src/main/res/drawable/bar_selector.xml +++ b/TMessagesProj/src/main/res/drawable/bar_selector.xml @@ -2,17 +2,20 @@ xmlns:android="http://schemas.android.com/apk/res/android"> - + + - + + - + + diff --git a/TMessagesProj/src/main/res/drawable/bar_selector_lock.xml b/TMessagesProj/src/main/res/drawable/bar_selector_lock.xml index ad45bba6..ea81ccde 100644 --- a/TMessagesProj/src/main/res/drawable/bar_selector_lock.xml +++ b/TMessagesProj/src/main/res/drawable/bar_selector_lock.xml @@ -1,5 +1,5 @@ diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml index 41ea5b77..51a217e2 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_backspace.xml @@ -1,7 +1,7 @@ + android:enterFadeDuration="1" + android:exitFadeDuration="200"> diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml index 17b59fd6..22447457 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_bell.xml @@ -1,8 +1,8 @@ + android:enterFadeDuration="1" + android:exitFadeDuration="200"> diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_car.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_car.xml index 30c4baa2..464dc434 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_car.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_car.xml @@ -1,8 +1,8 @@ + android:enterFadeDuration="1" + android:exitFadeDuration="200"> diff --git a/TMessagesProj/src/main/res/drawable/ic_emoji_symbol.xml b/TMessagesProj/src/main/res/drawable/ic_emoji_symbol.xml index 63a97e2f..e3b405a7 100644 --- a/TMessagesProj/src/main/res/drawable/ic_emoji_symbol.xml +++ b/TMessagesProj/src/main/res/drawable/ic_emoji_symbol.xml @@ -1,8 +1,8 @@ + android:enterFadeDuration="1" + android:exitFadeDuration="200"> diff --git a/TMessagesProj/src/main/res/drawable/mic_button_states.xml b/TMessagesProj/src/main/res/drawable/mic_button_states.xml deleted file mode 100644 index 791017ed..00000000 --- a/TMessagesProj/src/main/res/drawable/mic_button_states.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index e345fd6b..c9c4ee8b 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -81,7 +81,7 @@ غادر القناة غادر القناة الإعدادات - دخول + اشترك معلومات القناة رسالة جماعية تعليق @@ -132,6 +132,7 @@ هل ترغب بإضافة %1$s للقناة؟ المعذرة, هذا المستخدم قرر مغادرة المجموعة, لا يمكنك دعوته مرة أخرى للمجموعة. المعذرة، لا يمكنك إضافة هذا المستخدم للقنوات. + المعذرة، يوجد الكثير من الإداريين في هذه القناة. المعذرة، يمكنك إضافة أول ٢٠٠ عضو للقناة فقط. يمكن لعدد غير محدود من الأعضاء الدخول للقناة عن طريق رابط القناة. un1 قام بإضافتك لهذه القناة لقد قمت بالدخول للقناة. @@ -147,14 +148,14 @@ %1$s قام بإرسال ملف للقناة %2$s %1$s قام بإرسال مقطع صوتي للقناة %2$s %1$s قام بإرسال ملصق للقناة %2$s - رسالة جديدة في القناة %1$s - صورة جديدة في القناة %1$s - مقطع مرئي جديد في القناة %1$s - تم مشاركة جهة اتصال في القناة %1$s - تم مشاركة مكان في القناة %1$s - ملف جديد في القناة %1$s - ملاحظة صوتية جديدة في القناة %1$s - ملصق جديد في القناة %1$s + %1$s أرسل رسالة + %1$s أرسل صورة + %1$s أرسل مقطع مرئي + %1$s أرسل جهة اتصال + %1$s قام بإرسال موقع + %1$s أرسل ملف + %1$s أرسل رسالة صوتية + %1$s أرسل ملصق رسالة جماعية جديدة أدخل اسم القائمة @@ -239,6 +240,7 @@ هل أنت متأكد من رغبتك في الإبلاغ عن هذه المجموعة كغير مرغوب بها؟ المعذرة، يمكنك فقط إرسال رسائل لمن يمتلك رقمك وتمتلك رقمه في الوقت الحالي. المعذرة، يمكنك فقط إضافة من يمتلك رقمك وتمتلك رقمه للمجموعة في الوقت الحالي. + https://telegram.org/faq/can-39t-send-messages-to-non-contacts ملعومات إضافية %1$s قام بتعيين عداد التدمير الذاتي إلى to %2$s @@ -289,6 +291,7 @@ متصل آخر ظهور آخر ظهور + آخر ظهور قبل قليل قم بدعوة صديق بحث شامل آخر ظهور كان قريب @@ -493,11 +496,17 @@ اطلب رمز المرور إذا غبت فترة محددة من الزمن. خلال %1$s معطّل + قم بالفتح بالبصمة + قم بتأكيد البصمة للإستمرار + حساس اللمس + لم يتم التعرف على البصمة. حاول مرة أخرى شارك المقاطع المرئية والصور في هذه المحادثة لتستطيع الوصول إليها من أية جهاز من أجهزتك الملفات المشاركة الوسائط المشتركة الروابط المشاركة + الموسيقى المشتركة + قم بإرسال مقاطع موسيقية لهذه المحادثة ليمكنك الوصول إليها من أجهزتك الأخرى. شارك الملفات والمستندات في هذه المحادثة لتستطيع الوصول إليها من أية جهاز من أجهزتك شارك الروابط في هذه المحادثة لتستطيع الوصول إليها من أية جهاز من أجهزتك @@ -745,6 +754,12 @@ .Sorry, this feature is currently not available in your country لا يوجد حساب تيليجرام بهذا الاسم. هذا البوت لا يستطيع الدخول للمجموعات. + + تيليجرام يحتاج للسماح له بالوصول لجهات الاتصال الخاصة بك لتتمكن من محادثة أصدقائك من كافة أجهزتك. + تيليجرام يحتاج للسماح له بالوصول للذاكرة الخاصة بك لتتمكن من إرسال وحفظ الصور، المقاطع المرئية، الموسيقى وغيرها من الوسائط. + تيليجرام يحتاج للسماح له بالوصول للمايكروفون الخاص بك لتتمكن من إرسال رسائل صوتية. + تيليجرام يحتاج للسماح له بالوصول لمكانك لتتمكن من مشاركته مع أصدقائك من خلاله. + الإعدادات تيليجرام سريع @@ -882,6 +897,18 @@ %1$d صور %1$d صور %1$d صور + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d دقيقة + آخر ظهور قبل %1$d ساعة + آخر ظهور قبل %1$d ساعة + آخر ظهور قبل %1$d ساعة + آخر ظهور قبل %1$d ساعة + آخر ظهور قبل %1$d ساعة + آخر ظهور قبل %1$d ساعة %1$d رسالة معاد توجيهها الرسالة المعاد توجيهها @@ -949,8 +976,8 @@ h:mm a %1$s الساعة %2$s -تم تحديث تيليجرام نسخة الآندرويد. الجديد في نسخة 3.2.0:\n\n- إضافة خدمة القنوات - وسيلة جديدة رائعة لإرسال الرسائل الجماعية لعدد لا محدود من الجماهير (تستبدل الرسائل الجماعية القديمة). \n\n- اللاستزادة، اقرأ هنا: https://telegram.org/blog/channels - 632 + تم تحديث تيليجرام على الأندرويد. الجديد في النسخة رقم 3.2.6:\n\n- تحسين للواجهة البصرية للتطبيق\n- دعم للإيموجي الجديدة\n- تحسينات أخرى وإصلاح للثغرات + 655 بلاس مسنجر للأندرويد diff --git a/TMessagesProj/src/main/res/values-ca/strings.xml b/TMessagesProj/src/main/res/values-ca/strings.xml index 166652c1..7748360f 100644 --- a/TMessagesProj/src/main/res/values-ca/strings.xml +++ b/TMessagesProj/src/main/res/values-ca/strings.xml @@ -63,21 +63,22 @@ Comentaris Si habiliteu els comentaris, qualsevol membre podrà comentar el vostre missatge al canal. Afegeix contactes al canal - La gent pot compartir aquest enllaç amb els altres i trobar el canal mitjançant el cercador. + Qualsevol pot compartir aquest enllaç amb els altres i trobar el canal mitjançant el cercador. enllaç - La gent pot unir-se al canal accedint a aquest enllaç. Podeu revocar l\'enllaç en qualsevol moment. + Qualsevol pot afegir-se al canal a través d\'aquest enllaç. Podeu revocar l\'enllaç quan vulgueu. Descripció Podeu establir una descripció opcional per al vostre canal. Canal públic - Els canals públics es poden trobar a la cerca i tothom pot unir-s\'hi. + Els canals públics es poden trobar a la cerca i qualsevol pot afegir-s\'hi. Canal privat - Només es pot accedir als canals privats a través d\'un enllaç de convit. + Només es pot accedir als canals privats a través d\'un enllaç d\'invitació. Enllaç - Enllaç de convit + Enllaç d\'invitació Afegeix membres - Deixa el canal - Deixa el canal + Abandona el canal + Abandona el canal Configuració + AFEGEIX-M\'HI Informació del canal Difusió Comentari @@ -86,18 +87,22 @@ Els canals són una nova eina per difondre els vostres missatges a grans audiències. CREA UN CANAL Aquest nom ja es troba en ús. + Aquest nom no és vàlid. + El nom del canal ha de tenir com a mínim 5 caràcters. + El nom no pot excedir els 32 caràcters. + Els noms dels canals no poden començar amb un nombre. S\'està comprovant el nom... %1$s es troba disponible. Membres - Usuaris bloquejats + Usuaris blocats Administradors Elimina el canal Elimina el canal - En eliminar el canal es suprimiran tots els membres i els missatges es perdran. Segur que voleu eliminar-lo? + En eliminar el canal se suprimiran tots els membres i els missatges es perdran. Esteu segur de voler eliminar-lo? Segur que voleu deixar el canal? - Hi perdreu tots els missatges. + Perdreu tots els missatges d\'aquest canal. Edita - Tingueu en compte que si trieu un enllaç públic per al vostre canal, tothom serà capaç de cercar-lo i unir-s\'hi. + Tingueu en compte que si trieu un enllaç públic per al vostre canal, qualsevol podrà cercar-lo i afegir-s\'hi. Si voleu que el vostre canal romangui privat, no creeu l\'enllaç. Seleccioneu un enllaç per al vostre canal public perquè la gent el pugui trobar i compartir. @@ -108,23 +113,50 @@ Si no us interessa, us suggerim crear un canal privat. S\'ha eliminat la foto del canal S\'ha canviat el nom del canal a un2 un1 us ha afegit al canal un2 - Heu creat massa canals públics. Us suggerim crear un canal privat o bé eliminar, primerament, un dels vostres canals existents. + Heu assolit el nombre màxim de canals públics. Suprimiu els existents o creeu-ne un privat. Moderador Creador Administrador SILENCIA - HABILITA EL SO - Afegeix administrador + NO SILENCIÏS + Afegeix un administrador Convida amb un enllaç Segur que voleu fer %1$s administrador? Elimina Només els administradors poden veure aquesta llista. - Aquest usuari encara no s\'ha unit al canal. Voleu enviar-li una invitació? - Qualsevol que tingui el Telegram instal·lat podrà unir-se al canal tot seguint l\'enllaç. + Aquest usuari encara no s\'ha afegit al canal. Voleu convidar-lo? + Qualsevol que tingui el Telegram instal·lat podrà afegir-se al canal a través de l\'enllaç. Podeu afegir administradors perquè us ajudin a gestionar el canal. Mantingueu premut per eliminar-los. - Voleu unir-vos al canal «%1$s»? + Voleu afegir-vos al canal «%1$s»? Aquest canal ja no és accessible. + Voleu afegir %1$s al canal %2$s? + Voleu afegir %1$s al canal? + L\'usuari ha decidit abandonar aquest grup, no podeu tornar a convidar-lo. + No podeu afegir aquest usuari als canals. + Hi ha massa administradors en aquest canal. Només hi podeu afegir els primers 200 membres. Per a nombres majors, l\'adhesió s\'ha de fer a través dels enllaços del canal. + un1 us ha afegit a aquest canal + Us heu afegit al canal + Treu del canal + No podeu enviar missatges a aquest canal. + %1$s us ha afegit al canal %2$s + S\'ha actualitzat la fotografia del canal %1$s + %1$s ha enviat un missatge al canal %2$s + %1$s ha enviat una fotografia al canal %2$s + %1$s ha enviat un vídeo al canal %2$s + %1$s ha compartit un contacte al canal %2$s + %1$s ha enviat una ubicació al canal %2$s + %1$s ha enviat un fitxer al canal %2$s + %1$s ha enviat un àudio al canal %2$s + %1$s ha enviat un adhesiu al canal %2$s + %1$s ha publicat un missatge + %1$s ha publicat una fotografia + %1$s ha publicat un vídeo + %1$s ha publicat un contacte + %1$s ha publicat una ubicació + %1$s ha publicat un fitxer + %1$s ha publicat un missatge de veu + %1$s ha publicat un adhesiu Llista de difusió nova Introduïu el nom de la llista @@ -200,9 +232,17 @@ Si no us interessa, us suggerim crear un canal privat. Notificacions del servei S\'està obtenint la informació de l\'enllaç... Obre al navegador - Copia la URL + Copia l\'URL Envia %1$s - Voleu obrir la url %1$s? + Voleu obrir l\'URL %1$s? + MARCA COM A BROSSA + AFEGEIX EL CONTACTE + Segur que voleu denunciar rebre brossa d\'aquest usuari? + Segur que voleu denunciar rebre brossa d\'aquest grup? + Ho sentim, per ara només podeu enviar missatges a contactes mutus. + Ho sentim, per ara només podeu afegir contactes mutus als grups. + https://telegram.org/faq#can-39t-send-messages-to-non-contacts + Més informació %1$s ha definit l\'autodestrucció en %2$s Heu definit l\'autodestrucció en %1$s @@ -238,7 +278,7 @@ Si no us interessa, us suggerim crear un canal privat. %1$s s\'ha unit al Telegram. %1$s,\nHem detectat un inici de sessió al vostre compte en un dispositiu nou el %2$s\n\nDispositiu: %3$s\nUbicació: %4$s\n\nSi no sou vós, aneu a Configuració - Privadesa i seguretat - Sessions i finalitzeu aquesta sessió.\n\nSi penseu que algú altre ha iniciat sessió en el vostre compte contra la vostra voluntat, podeu activar la Verificació en dos passos a la configuració de Privadesa i seguretat.\n\nAtentament,\nL\'equip del Telegram %1$s ha actualitzat la foto del perfil - %1$s s\'ha unit al grup %2$s via enllaç d\'invitació + %1$s s\'ha afegit al grup %2$s via enllaç d\'invitació Respon Respon a %1$s Respon a %1$s @@ -252,6 +292,7 @@ Si no us interessa, us suggerim crear un canal privat. en línia vist: vist: + vist fa poc Convida els contactes CERCA GLOBAL vist fa poc @@ -264,16 +305,19 @@ Si no us interessa, us suggerim crear un canal privat. Introduïu el nom del grup Nom del grup %1$d/%2$d membres + Voleu unir-vos al xat \'%1$s\'? El grup ja està ple. + Aquest xat sembla que no existeix. S\'ha copiat l\'enllaç al porta-retalls Convida al grup amb un enllaç Enllaç d\'invitació + Esteu segur que voleu revocar l\'enllaç? Quan ho feu ningú podrà afegir-se al grup utilitzant-lo. L\'enllaç d\'invitació anterior no està actiu. S\'ha generat un enllaç nou. Revoca Revoca l\'enllaç Copia l\'enllaç Comparteix l\'enllaç - Qualsevol qui tingui Telegram instal·lat serà capaç d\'unir-se al grup tot seguint l\'enllaç. + Qualsevol qui tingui Telegram instal·lat serà capaç d\'afegir-se al grup a través de l\'enllaç. Elements compartits Configuració @@ -365,13 +409,13 @@ Si no us interessa, us suggerim crear un canal privat. En unir-se un contacte al Telegram PEBBLE Llengua - Tingueu present que el suport del Telegram és ofert per voluntaris. Intentem respondre tan ràpid com ens és possible, però podem trigar una mica.
]]>Sisplau, feu una ullada a les PMF del Telegram]]>. Tenen la resposta a la majoria de preguntes i també consells importants per a la resolució de problemes]]>.
+ Tingueu present que el suport del Telegram és ofert per voluntaris. Intentem respondre tan ràpid com ens és possible, però podem trigar una mica.
]]>Feu una ullada a les PMF del Telegram]]>. Tenen la resposta a la majoria de preguntes i també consells importants per a la resolució de problemes]]>.
Pregunta-ho a un voluntari PMF del Telegram https://telegram.org/faq Voleu eliminar la localització? El fitxer de localització no és vàlid - Activat + Activades Inhabilitat Servei de notificacions Si Google Play Services us és suficient per rebre notificacions, podeu desactivar el Servei de Notificacions aquí. De totes maneres recomanem deixar-lo activat per mantenir l\'app en segon pla i rebre notificacions a l\'instant. @@ -404,7 +448,7 @@ Si no us interessa, us suggerim crear un canal privat. Màxima Mai Repetició de notificacions - Aquí podeu canviar el vostre número del Telegram. El vostre compte i les dades al núvol —missatges, fitxers, contactes, etc.— es mouran al nou número.\n\nImportant:]]> El número nou]]> s\'afegirà a l\'agenda de tots els vostres contactes del Telegram que tinguin el número vell i que no hàgiu blocat al Telegram. + Aquí podeu canviar el vostre número de telèfon del Telegram. El vostre compte i les dades al núvol (missatges, fitxers, contactes, etc.) es mouran al número nou.\n\nImportant:]]> el número nou]]> s\'afegirà a l\'agenda de tots els vostres contactes del Telegram que tinguin el número antic i que no hàgiu blocat al Telegram. El número nou s\'afegirà a l\'agenda de tots els vostres contactes del Telegram que tinguin el número vell i que no hàgiu blocat al Telegram. CANVI DE NÚMERO Número nou @@ -439,7 +483,7 @@ Si no us interessa, us suggerim crear un canal privat. Codi d\'accés Canvia el codi d\'accés En introduir un codi d\'accés addicional, apareixerà la icona d\'un cadenat a la pàgina de xats. Toqueu-la per blocar i desblocar l\'aplicació.\n\nNota: Si oblideu el codi d\'accés haureu d\'eliminar i reinstal·lar l\'aplicació. Es perdran tots els xats secrets. - Ara es mostrarà la icona d\'un cadenat a la pàgina de xats. Toqueu-la per bloquejar Telegram amb el nou codi d\'accés. + Ara es mostrarà la icona d\'un cadenat a la pàgina de xats. Toqueu-la per blocar Telegram amb el nou codi d\'accés. PIN Contrasenya Introduïu el codi d\'accés actual @@ -453,13 +497,19 @@ Si no us interessa, us suggerim crear un canal privat. Demana el codi d\'accés en absentar-me. en %1$s Inhabilitat + Desbloca amb empremta + Confirma l\'empremta per continuar + Sensor tàctil + L\'empremta no s\'ha reconegut. Torneu-ho a provar. - Compartiu fotos i vídeos a aquest xat i accediu-hi des de qualsevol dispositiu. + Compartiu fotos i vídeos en aquest xat i accediu-hi des de qualsevol dispositiu. Fitxers Multimèdia Enllaços - Compartiu fitxers i documents a aquí i accediu-hi des de qualsevol dels vostres dispositiu. - Compartiu enllaços aquí i accediu-hi des de qualsevol dels vostres dispositius. + Música compartida + Compartiu música en aquest xat i accediu-hi des de qualsevol dispositiu. + Compartiu fitxers i documents en aquest xat i accediu-hi des de qualsevol dispositiu. + Compartiu enllaços en aquest xat i accediu-hi des de qualsevol dispositiu. Mapa Satèl·lit @@ -547,7 +597,7 @@ Si no us interessa, us suggerim crear un canal privat. Correu electrònic no vàlid Ho sentim Atès que no heu proporcionat una adreça electrònica de recuperació en establir la contrasenya, les opcions disponibles són recordar la contrasenya o restablir el compte. - Us hem enviat un codi de recuperació a l\'adreça de correu electrònic proporcionada:\n\n%1$s + Us hem enviat un codi de recuperació a l\'adreça electrònica que heu indicat:\n\n%1$s Reviseu la bústia de correu electrònic i introduïu el codi de 6 dígits que us hem enviat. Teniu dificultats per accedir al vostre correu electrònic %1$s? Si no podeu recuperar l\'accés al vostre correu electrònic, les opcions disponibles són recordar la contrasenya o restablir el compte. @@ -705,6 +755,12 @@ Si no us interessa, us suggerim crear un canal privat. Aquesta característica no es troba disponible al teu país. No hi ha cap compte de Telegram amb aquest nom d\'usuari. Aquest bot no pot unir-se a grups. + + Telegram necessita accés als teus contactes així que podràs connectar amb els teus amics des de qualsevol dispotiu que utilitzeu. + Telegram necessita accés a l\'emmagatzematge del teu dispositiu per poder enviar i guardar fotos, vídeos, música i altres continguts. + Telegram necessita accés al micròfon per enviar missatges de veu. + Telegram necessita accés a la teva localització per a que la puguis compartir amb els teus amics. + CONFIGURACIÓ Plus Messenger Ràpid @@ -728,6 +784,7 @@ Si no us interessa, us suggerim crear un canal privat. %1$d en línia %1$d en línia %1$d en línia + %1$d membres %1$d membre %1$d membres %1$d membres @@ -751,6 +808,12 @@ Si no us interessa, us suggerim crear un canal privat. %1$d missatges %1$d missatges %1$d missatges + %1$d comentaris + %1$d comentari + %1$d comentaris + %1$d comentaris + %1$d comentaris + %1$d comentaris cap element %1$d element %1$d elements @@ -835,6 +898,18 @@ Si no us interessa, us suggerim crear un canal privat. %1$d fotos %1$d fotos %1$d fotos + vist fa %1$d minuts + vist fa %1$d minut + vist fa %1$d minuts + vist fa %1$d minuts + vist fa %1$d minuts + vist fa %1$d minuts + vist fa %1$d hores + vist fa %1$d hora + vist fa %1$d hores + vist fa %1$d hores + vist fa %1$d hores + vist fa %1$d hores %1$d missatges a reenviar Missatge a reenviar @@ -902,10 +977,18 @@ Si no us interessa, us suggerim crear un canal privat. h:mm a %1$s a les %2$s - S\'ha actualitzat el Telegram per a l\'Android. Novetats a la versió 3.1.3:\n\n- Nova secció \'Enllaços compartits\' a la informació del xat\n- Previsualització, dins de l\'aplicació, per a enllaços a fotos - 632 - + El Telegram per a Android s\'ha actualitzat. Novetats a la versió 3.2.6: + +- Animacions noves i moltes millores visuals +- Compatibilitat amb els emojis nous +- Altres millores i correcció d\'errors +655 + + + +Novetats a la versió 3.2.6.0: + +- Correcció d\'errors Plus Messenger per Android Aparença Codi de color hexadecimal no vàlid. @@ -1057,4 +1140,11 @@ Si no us interessa, us suggerim crear un canal privat. Afegiu-vos al canal oficial del Plus Messenger: https://telegram.me/plusmsnes + Baixa nous temes + Canal oficial + Diàlegs + En tocar la imatge d\'un contacte + En tocar la imatge d\'un grup + Perfil + Fotos de perfil diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 70101279..6eacd811 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -129,6 +129,7 @@ %1$s zum Kanal hinzufügen? Dieser Nutzer hat sich entschieden die Gruppe zu verlassen, deshalb kannst du ihn nicht wieder einladen. Du kannst diesen Nutzer nicht einladen. + Es gibt bereits zu viele Administratoren in diesem Kanal. Du kannst nur die ersten 200 Leute einladen, aber unbegrenzt viele können dem Kanal über den Einladungslink beitreten. un1 hat dich hinzugefügt Du bist dem Kanal beigetreten @@ -144,14 +145,14 @@ %1$s hat eine Datei an den Kanal %2$s gesendet %1$s hat eine Sprachnachricht an den Kanal %2$s gesendet %1$s hat einen Sticker an den Kanal %2$s gesendet - Neue Nachricht im Kanal %1$s - Neues Bild im Kanal %1$s - Neues Video im Kanal %1$s - Kontakt im Kanal %1$s geteilt - Neuer Standort im Kanal %1$s - Neue Datei im Kanal %1$s - Neue Sprachnachricht im Kanal %1$s - Neuer Sticker im Kanal %1$s + %1$s hat eine Nachricht gesendet + %1$s hat ein Bild gesendet + %1$s hat ein Video gesendet + %1$s hat einen Kontakt gesendet + %1$s hat einen Standort gesendet + %1$s hat eine Datei gesendet + %1$s hat eine Sprachnachricht gesendet + %1$s hat einen Sticker gesendet Neue Broadcast Liste Listenname @@ -236,6 +237,7 @@ Sicher, dass du Spam von dieser Gruppe melden willst? Derzeit kannst du nur Kontakten schreiben, die auch deine Nummer haben. Derzeit kannst du nur Kontakte hinzufügen, die auch deine Nummer haben. + https://telegram.org/faq/de#kann-keine-nachrichten-an-nicht-kontakte-senden Mehr Infos %1$s hat den Selbstzerstörungs-Timer auf %2$s gesetzt @@ -286,6 +288,7 @@ online zul. online zul. online + zul. online gerade eben Freunde einladen GLOBALE SUCHE zuletzt kürzlich gesehen @@ -490,11 +493,17 @@ Sperrt App bei Inaktivität automatisch. in %1$s Deaktiviert + Per Fingerabdruck entsperren + Fingerabdruck bestätigen + Berührungssensor + Abdruck nicht erkannt; erneut versuchen Die hier geteilten Bilder und Videos kannst du von jedem deiner Geräte aufrufen. Geteilte Dateien Geteilte Medien Geteilte Links + Geteilte Musik + Die hier geteilten Lieder kannst du von jedem deiner Geräte aufrufen. Die hier geteilten Dateien kannst du von jedem deiner Geräte aufrufen. Die hier geteilten Links kannst du von jedem deiner Geräte aufrufen. @@ -727,7 +736,7 @@ Nachricht an %1$s senden? Wirklich abmelden?\n\nDu kannst Telegram von all deinen Geräten gleichzeitig nutzen.\n\nWichtig: Abmelden löscht deine Geheimen Chats. Sicher, dass du alle anderen Geräte abmelden möchtest? - Diese Gruppe wirklich löschen und verlassen? + Gruppe löschen und verlassen? Möchtest du wirklich diesen Chat löschen? Wirklich die eigenen Kontaktinformationen teilen? Diesen Kontakt wirklich blockieren? @@ -742,6 +751,12 @@ Verzeihung, diese Funktion ist derzeit in deinem Land nicht verfügbar. Kein Konto mit diesem Benutzernamen Keine Gruppen mit diesem Bot möglich + + 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. + EINSTELLUNGEN Plus Messenger Schnell @@ -879,6 +894,18 @@ %1$d Bilder %1$d Bilder %1$d Bilder + zul. online vor %1$d Minuten + zul. online vor %1$d Minute + zul. online vor %1$d Minuten + zul. online vor %1$d Minuten + zul. online vor %1$d Minuten + zul. online vor %1$d Minuten + zul. online vor %1$d Stunden + zul. online vor %1$d Stunde + zul. online vor %1$d Stunden + zul. online vor %1$d Stunden + zul. online vor %1$d Stunden + zul. online vor %1$d Stunden %1$d angehängten Nachrichten Angehängte Nachricht @@ -946,11 +973,10 @@ h:mm a %1$s um %2$s -Telegram für Android wurde aktualisiert. Neu in Version 3.2.0:\n\n- Kanäle: Du kannst nun Nachrichten an eine unbegrenzte Anzahl von Leuten schicken (ersetzen die Verteilerlisten).\n\n Mehr Infos über dieses Update: https://telegram.org/blog/channels - 632 - +Plus Messenger für Android wurde aktualisiert. Neu in Version 3.2.6:\n\n- Neue Animationen und optische Verbesserungen\n- Neue Emoji\n- Sonstige Verbesserungen und Fehlerbehebungen + 655 + + \n\nNeues in Version 3.2.6.0:\n\n- Fehlerbeseitigung Plus Messenger für Android Themen bearbeiten Ungültiger Hex-Code! @@ -1101,4 +1127,11 @@ %s in die Zwischenablage kopiert \n\nPlus Messenger Mitglied werden im offiziellen Kanal: https://telegram.me/plusmsn + Themen herunterladen + Offizieller Kanal + Dialoge + Zeige bei Tip auf Kontaktbild + Zeige bei Tip auf Gruppenbild + Profil + Profilbilder \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index ff12a4a2..64d25b6c 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -129,6 +129,7 @@ ¿Añadir a %1$s al canal? Lo sentimos, este usuario decidió dejar el grupo, así que no puedes invitarlo otra vez. Lo sentimos, no puedes añadir a este usuario a canales. + Lo sentimos, hay demasiados administradores en el canal. Lo sentimos, sólo puedes añadir a los primeros 200 miembros a un canal. Sin embargo, una cantidad ilimitada de personas pueden unirse por el enlace del canal. un1 te añadió a este canal Te uniste al canal @@ -144,14 +145,14 @@ %1$s envió un archivo al canal %2$s %1$s envió un audio al canal %2$s %1$s envió un sticker al canal %2$s - Nuevo mensaje en el canal %1$s - Nueva foto en el canal %1$s - Nuevo vídeo en el canal %1$s - Contacto compartido en el canal %1$s - Nueva ubicación compartida en el canal %1$s - Nuevo archivo compartido en el canal %1$s - Nueva nota de voz compartida en el canal %1$s - Nuevo sticker compartido en el canal %1$s + %1$s publicó un mensaje + %1$s publicó una foto + %1$s publicó un vídeo + %1$s publicó un contacto + %1$s publicó una ubicación + %1$s publicó un archivo + %1$s publicó un mensaje de voz + %1$s publicó un sticker Nueva difusión Nombre de la lista @@ -235,7 +236,8 @@ ¿Quieres reportar a este usuario como spam? ¿Quieres reportar a este grupo como spam? Lo sentimos, por ahora puedes enviar mensajes sólo a contactos mutuos. - Lo sentimos, por ahora sólo puedes añadir a contactos mutuos a un grupo. + Lo sentimos, por ahora sólo puedes añadir contactos mutuos a un grupo. + https://telegram.org/faq/es#no-puedo-enviar-mensajes-a-quienes-no-son-mis-contactos Más información %1$s activó la autodestrucción en %2$s @@ -286,6 +288,7 @@ en línea últ. vez últ. vez el + últ. vez hace un momento Invitar a amigos BÚSQUEDA GLOBAL últ. vez recientemente @@ -312,7 +315,7 @@ Compartir enlace Cualquiera que tenga Telegram instalada podrá unirse a tu grupo siguiendo este enlace. - Todos los archivos + Multimedia Ajustes Añadir miembro Eliminar y dejar el grupo @@ -490,11 +493,17 @@ El bloqueo se activará transcurrido este tiempo. en %1$s Desactivado + Desbloquear con la huella digital + Confirma la huella digital para continuar + Sensor táctil + Huella digital no reconocida. Reinténtalo Comparte fotos y vídeos en este chat y accede a ellos desde cualquier dispositivo. Archivos Multimedia Enlaces + Música + Comparte música en este chat y accede a ella desde cualquier dispositivo. Comparte archivos en este chat y accede a ellos desde cualquier dispositivo. Comparte enlaces en este chat y accede a ellos desde cualquiera de tus dispositivos. @@ -742,6 +751,12 @@ Lo sentimos, esta característica no está disponible en tu país actualmente. No hay ninguna cuenta de Telegram con este alias. Este bot no puede unirse a grupos. + + 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. + AJUSTES Plus Messenger Rápida @@ -879,6 +894,18 @@ %1$d fotos %1$d fotos %1$d fotos + últ. vez hace %1$d minutos + últ. vez hace %1$d minuto + últ. vez hace %1$d minutos + últ. vez hace %1$d minutos + últ. vez hace %1$d minutos + últ. vez hace %1$d minutos + últ. vez hace %1$d horas + últ. vez hace %1$d hora + últ. vez hace %1$d horas + últ. vez hace %1$d horas + últ. vez hace %1$d horas + últ. vez hace %1$d horas %1$d mensajes adjuntos Mensaje adjunto @@ -946,10 +973,10 @@ h:mm a %1$s a las %2$s - Plus Messenger para Android ha sido actualizada. Novedades en la versión 3.2.0\n\n- Presentamos los Canales - una nueva gran forma de difundir tus mensajes a audiencias ilimitadas (reemplaza a las antiguas difusiones).\n\n Conoce más: https://telegram.org/blog/channels - 632 + Plus Messenger para Android ha sido actualizada. Novedades en la versión 3.2.6:\n\n- Nuevas animaciones y muchas mejoras visuales\n- Soporte para los nuevos emojis\n- Soporte para Android 6.0 (Now on Tap - Direct Share - Soporte para huella digital en el código de acceso)\n- Otras mejoras y correcciones de errores + 655 - \n\nNovedades en 3.2.2.2:\n\n- Opción en ajustes para abrir perfil/fotos de perfil de usuario/grupo al hacer click en foto en pantalla principal\n- Opción de gradiente en fondo de chat\n- Añadida opción de reenviar link sin citar\n- Añadido enlace a canal oficial en menú\n- Corrección de errores + \n\nNovedades en 3.2.6.0:\n\n- Corrección de errores Plus Messenger para Android Tematización ¡Color hexadecimal inválido! diff --git a/TMessagesProj/src/main/res/values-fr/strings.xml b/TMessagesProj/src/main/res/values-fr/strings.xml index 1ddd5db2..f01c90ad 100644 --- a/TMessagesProj/src/main/res/values-fr/strings.xml +++ b/TMessagesProj/src/main/res/values-fr/strings.xml @@ -129,6 +129,7 @@ Ajouter %1$s à la chaîne ? Désolé, %@ a décidé de quitter ce groupe, vous ne pouvez donc plus l\'inviter ici. Désolé, vous ne pouvez pas ajouter cet utilisateur dans des groupes. + Désolé, il y a trop d\'admins pour cette chaîne. Désolé, Vous pouvez seulement ajouter les 200 premiers membres à la chaîne. Notez qu\'un nombre illimité de personnes peuvent rejoindre la chaîne via le liens d\'invitation. un1 vous a ajouté à la chaîne Vous avez rejoint la chaîne @@ -144,14 +145,14 @@ %1$s a envoyé un fichier à la chaine %2$s %1$s a envoyé une note vocal à la chaine %2$s %1$s a envoyé un autocolant à la chaine %2$s - Nouveau message dans la chaîne %1$s - Nouvelle photo dans la chaîne %1$s - Nouvelle vidéo dans la chaîne %1$s - Contact partagé dans la chaîne %1$s - Nouvelle localisation partagée dans la chaîne %1$s - Nouveau fichier partagé dans la chaîne %1$s - Nouvelle note vocale partagée dans la chaîne %1$s - Nouveau autocollant partagé dans la chaîne %1$s + %1$s a envoyé un message + %1$s a envoyé une photo + %1$s a envoyé une vidéo + %1$s a envoyé un contact + %1$s a envoyé une position + %1$s a envoyé un fichier + %1$s a envoyé un message vocal + %1$s a envoyé une vignette Nv. liste de diffusion Saisissez le nom de la liste @@ -287,6 +288,7 @@ en ligne vu vu + vu juste maintenant Inviter des amis RECHERCHE GÉNÉRALE vu récemment @@ -491,11 +493,17 @@ Code d\'accès requis en cas d\'absence après %1$s Désactivé + Débloquer avec l\'empreinte digitale + Confirmer l\'empreinte digitale pour continuer + Capteur de toucher + Empreinte digitale non reconnue. Essayez à nouveau Partager des photos et des vidéos dans cette conversation et y accéder sur chacun de vos appareils. Fichiers partagés Médias partagés Liens Partagés + Musique partagée + Partager de la musique dans cette conversation et accédez-y sur tous vos appareils. Partager des fichiers et des documents dans cette conversation et y accéder sur chacun de vos appareils. Partager des liens dans cette discussion et y accéder sur n\'importe lequel de vos appareils . @@ -743,6 +751,12 @@ Désolé, cette option n\'est actuellement pas disponible dans votre pays. Il n\'y a pas de compte Telegram associé à cet utilisateur. Ce bot ne peut pas rejoindre des groupes. + + Telegram a besoin d\'accéder à vos contacts pour que vous puissiez être en lien avec vos amis à travers tous vos périphériques. + Telegram a besoin d\'accéder à votre espace de stockage pour que vous puissiez envoyer et sauvegarder des photos, vidéos, musiques et autres médias. + Telegram a besoin d\'accéder à votre microphone pour que vous puissiez envoyer des messages vocaux. + Telegram a besoin d\'accéder à votre position pour que vous puissiez la partager avec vos amis. + PARAMÈTRES Plus Messenger Rapide @@ -880,6 +894,18 @@ %1$d photos %1$d photos %1$d photos + vu il y a %1$d minutes + vu il y a %1$d minute + vu il y a %1$d minutes + vu il y a %1$d minutes + vu il y a %1$d minutes + vu il y a %1$d minutes + vu il y a %1$d heures + vu il y a %1$d heure + vu il y a %1$d heures + vu il y a %1$d heures + vu il y a %1$d heures + vu il y a %1$d heures %1$d messages transférés Message transféré @@ -947,9 +973,8 @@ h:mm a %1$s à %2$s - Plus Messenger pour Android a été mis à jour. Nouveautés de la version 3.1.3:\n\n- Nouvelle section \"Liens partagés\" dans les informations de la conversation\n -- Prévisualistaion In-app pour les liens des images - 632 + Telegram pour Android a été mis à jour. Nouveau dans la version 3.2.6:\n\n- De nouvelles animations et de nombreuses améliorations visuelles.\n- Support pour de nouveaux emoji\n- Autres améliorations et corrections de bogues. + 655 Plus Messenger pour Android Thème diff --git a/TMessagesProj/src/main/res/values-gl/strings.xml b/TMessagesProj/src/main/res/values-gl/strings.xml index 5872e02e..ce4d4d7f 100644 --- a/TMessagesProj/src/main/res/values-gl/strings.xml +++ b/TMessagesProj/src/main/res/values-gl/strings.xml @@ -130,6 +130,7 @@ e introduce o teu número. Engadir a %1$s á canle? Sentímolo, este usuario decidiu deixar o grupo, así que non podes volver a invitalo. Sentímolo, non podes engadir este usuario a canles. + Sentímolo, demasiados administradores na canle. Sentímolo, tan só podes engadir aos primeiros 200 membros a unha canle. Sen embargo, unha cantidade ilimitada de persoas poden unirse coa ligazón da canle. un1 engadiute a esta canle Unícheste á canle @@ -145,14 +146,14 @@ e introduce o teu número. %1$s enviou un ficheiro á canle %2$s %1$s enviou un son á canle %2$s %1$s enviou un sticker á canle %2$s - Nova mensaxe na canle %1$s - Nova foto na canle %1$s - Novo vídeo na canle %1$s - Contacto compartido na canle %1$s - Nova localización compartida na canle %1$s - Novo ficheiro compartido na canle %1$s - Nova nota de voz compartida na canle %1$s - Novo sticker compartido na canle %1$s + %1$s publicou unha mensaxe + %1$s publicou unha foto + %1$s publicou un vídeo + %1$s publicou un contacto + %1$s publicou unha localización + %1$s publicou un ficheiro + %1$s publicou unha mensaxe de voz + %1$s publicou un sticker Nova difusión Introduce o nome do listado @@ -237,6 +238,7 @@ e introduce o teu número. Queres reportar este grupo como spam? Sentímolo, polo momento só podes enviar mensaxes a contactos mutuos. Sentímolo, polo momento só podes engadir a contactos mutuos a grupos. + https://telegram.org/faq/es#no-puedo-enviar-mensajes-a-quienes-no-son-mis-contactos Máis información %1$s puxo o temporizador para a autodestrución en %2$s @@ -287,6 +289,7 @@ e introduce o teu número. en liña últ. vez últ. vez + últ. vez hai un intre Invitar amigos BUSCA GLOBAL últ. vez recentemente @@ -334,8 +337,8 @@ e introduce o teu número. Comezar un chat secreto Produciuse un erro. Clave de cifrado - Temporizador da autodestrución - Desactivado + Autodestrución + Desactivada Esta imaxe é unha visualización da clave de cifrado para a conversa secreta con ]]>%1$s]]>.
]]>Se é a mesma que aparece no teléfono de ]]>%2$s]]>, a vosa conversa é 200%% segura.
]]>Máis información en telegram.org
Descoñecido Información @@ -410,7 +413,7 @@ e introduce o teu número. Queres eliminar a tradución? Ficheiro de tradución incorrecto Activadas - Desactivado + Desactivadas Servizo de notificacións Se os servizos de notificacións de Google Play son suficientes para ti, podes desactivar o Servizo de notificacións. Con todo recomendámosche que o deixes activado para manter a aplicación executándose en segundo plano e recibir notificacións ao momento. Ordenar por @@ -457,7 +460,7 @@ e introduce o teu número. Predeterminado Predeterminada Notificacións intelixentes - Desactivado + Desactivadas Soar como máximo %1$s en %2$s Soar como máximo veces @@ -491,11 +494,17 @@ e introduce o teu número. O bloqueo activarase transcorrido este tempo. en %1$s Desactivado + Desbloquear coa pegada dactilar + Confirma a pegada para continuar + Sensor táctil + Pegada non recoñecida. Téntao de novo. Comparte fotos e vídeos nesta conversa e accede a eles dende calquera dos teus dispositivos. Ficheiros compartidos Multimedia Ligazóns compartidas + Música + Comparte música nesta conversa e accede a ela dende calquera dispositivo. Comparte ficheiros e documentos nesta conversa e accede a eles dende calquera dos teus dispositivos. Comparte ligazóns nesta conversa e accede a elas dende calquera dos teus dispositivos. @@ -743,6 +752,12 @@ e introduce o teu número. Sentímolo, esta funcionalidade non está dispoñíbel no teu país. Non hai unha conta en Telegram con este alias. Este bot non pode unirse a grupos. + + Telegram necesita acceso aos teus contactos para que poidas conectar con eles en tódolos teus dispositivos. + Telegram necesita acceso ao teu almacenamento para que poidas enviar e gardar fotos, vídeos, música e demais. + Telegram necesita acceso ao teu micrófono para que poidas enviar mensaxes de voz. + Telegram necesita acceso á túa localización para que a poidas compartir cos teus amigos. + AXUSTES Plus Messenger Rápido @@ -880,6 +895,18 @@ e introduce o teu número. %1$d fotos %1$d fotos %1$d fotos + últ. vez hai %1$d minutos + últ. vez hai %1$d minuto + últ. vez hai %1$d minutos + últ. vez hai %1$d minutos + últ. vez hai %1$d minutos + últ. vez hai %1$d minutos + últ. vez hai %1$d horas + últ. vez hai %1$d hora + últ. vez hai %1$d horas + últ. vez hai %1$d horas + últ. vez hai %1$d horas + últ. vez hai %1$d horas %1$d mensaxes reenviadas Mensaxe adxunta @@ -947,10 +974,10 @@ e introduce o teu número. h:mm a %1$s ás %2$s - Telegram para Android foi actualizada. Novidades na versión 3.2.0:\n\n- Presentamos as Canles – unha nova gran forma de difundir as túas mensaxes a audiencias ilimitadas (substitúe ás antigas difusións).\n\n Coñece máis: https://telegram.org/blog/channels - 632 - + Telegram para Android foi actualizada. Novidades na versión 3.2.6:\n\n- Novas animacións e moitas melloras visuais\n- Soporte para os novos emoji\n- Outras melloras e correccións de erros + 655 + + \n\nNovidades na versión 3.2.6.0:\n\n- Corrección de erros Plus Messenger para Android Tematización Cor hexadecimal inválida! @@ -961,8 +988,8 @@ e introduce o teu número. Xeral Pantallas Pantalla principal - Pantalla de conversas - Pantalla de contactos + Pantalla das conversas + Pantalla dos contactos Cabeceira Listado Listado de conversa @@ -1003,7 +1030,7 @@ e introduce o teu número. Gardar o tema na carpeta Telegram/Themes Tema gardado! %1$s gardado en %2$s - Tema aínda sen crear. Aplica primeiro algún MOD, por favor + Tema aínda sen crear. Aplica primeiro algún MOD, por favor. Tema cargado dende a SD Non se atopou ningún ficheiro de preferencias en %s Non se atopou tarxeta SD @@ -1046,8 +1073,8 @@ e introduce o teu número. Desactivar pop-up ao tocar Perfil do grupo/contacto Ocultar fondo personalizado - Cor do enlace dereito - Cor do enlace esquerdo + Cor da ligazón dereita + Cor da ligazón esquerda Tema aplicado! Preme OK para reiniciar a app Mostrar emoticonas do sistema @@ -1062,24 +1089,24 @@ e introduce o teu número. Cor do nome (número descoñecido) Ocultar sombra de fondo personalizada Poñer cor de fondo - Cor de fondo - Tamaño do popup das emoticonas + Cor do fondo + Tamaño do pop-up das emoticonas Cor do nome da burbulla de reenvío der. Cor do nome da burbulla de reenvío esq. Cor das iconas Pantalla de Axustes/Tematización - Cor de fondo + Cor do fondo Cor da sombra Cor da sección Cor do título Cor do resumo/subtítulo Cor do texto \'Foto/Sticker\' Gustaríache ver algún dos temas creados por outros usuarios de Plus Messenger? - Empregar fonte do dispositivo + Empregar a fonte do dispositivo Plus Messenger reiniciarase Cor do icono do grupo Cor do nome do contacto compartido - Cor de fondo de adxuntar + Cor do fondo de adxuntar Cor do texto de adxuntar Mostrar foto de contacto na conversa Mostrar a miña foto na conversa @@ -1100,4 +1127,11 @@ e introduce o teu número. Aplicar gradiente ao fondo do listado %s copiado ao portapapeis \n\nÚnete á canle oficial de Plus Messenger: https://telegram.me/plusmsnes + Descargar temas + Canle oficial + Conversas + Clic na foto do contacto + Clic na foto do grupo + Perfil + Fotos do perfil diff --git a/TMessagesProj/src/main/res/values-hi/strings.xml b/TMessagesProj/src/main/res/values-hi/strings.xml index 0a141232..e66040ed 100644 --- a/TMessagesProj/src/main/res/values-hi/strings.xml +++ b/TMessagesProj/src/main/res/values-hi/strings.xml @@ -515,7 +515,7 @@ %1$s पर %2$s - 632 + 655 Android के लिए प्लस मैसेंजर diff --git a/TMessagesProj/src/main/res/values-hr/strings.xml b/TMessagesProj/src/main/res/values-hr/strings.xml index 337f3b69..0443a881 100644 --- a/TMessagesProj/src/main/res/values-hr/strings.xml +++ b/TMessagesProj/src/main/res/values-hr/strings.xml @@ -750,7 +750,7 @@ h:mm a %1$s u %2$s - 632 + 655 Plus Messenger za Android Izrada teme diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 6ecb4e0b..4c18a999 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -109,7 +109,7 @@ Foto del canale rimossa Nome del canale cambiato in un2 un1 ti ha aggiunto al canale un2 - Spiacenti, hai creato troppi canali pubblici. Puoi o creare un canale privato o eliminare uno dei tuoi precedenti canali per poi crearne un altro. + Spiacenti, hai creato troppi canali pubblici. Puoi creare un canale privato o eliminare un tuo canale pubblico. Moderatore Creatore Amministratore @@ -129,6 +129,7 @@ Aggiungere %1$s al canale? Spiacenti, questo utente ha deciso di lasciare il gruppo, quindi non puoi reinvitarlo. Spiacenti, non puoi aggiungere questo utente ai canali. + Spiacenti, troppi amministratori in questo canale. Spiacenti, puoi aggiungere solo i primi 200 membri a un canale. Ricorda che un numero illimitato di persone potrebbe unirsi tramite il link del canale. un1 ti ha aggiunto a questo canale Ti sei unito al canale @@ -144,14 +145,14 @@ %1$s ha inviato un file al canale %2$s %1$s ha inviato un audio al canale %2$s %1$s ha inviato uno sticker al canale %2$s - Nuovo messaggio nel canale %1$s - Nuova foto nel canale %1$s - Nuovo video nel canale %1$s - Contatto condiviso nel canale %1$s - Nuova posizione condivisa nel canale %1$s - Nuovo file condiviso nel canale %1$s - Nuova nota vocale condivisa nel canale %1$s - Nuovo sticker condiviso nel canale %1$s + %1$s ha pubblicato un messaggio + %1$s ha pubblicato una foto + %1$s ha pubblicato un video + %1$s ha pubblicato un contatto + %1$s ha pubblicato una posizione + %1$s ha pubblicato un file + %1$s ha pubblicato un messaggio vocale + %1$s ha pubblicato uno sticker Nuova lista broadcast Inserisci il nome della lista @@ -236,6 +237,7 @@ Sei sicuro di voler segnalare dello spam in questo gruppo? Spiacenti, ma al momento puoi scrivere solo a contatti in comune. Spiacenti, ma al momento puoi aggiungere ai gruppi solo a contatti in comune. + https://telegram.org/faq/it#non-posso-inviare-messaggi-a-chi-non-far-parte-dei-miei-contatti Più info %1$s ha impostato il timer di autodistruzione a %2$s @@ -286,6 +288,7 @@ in linea ultimo accesso ultimo accesso + ultimo accesso adesso Invita amici RICERCA GLOBALE ultimo accesso di recente @@ -490,11 +493,17 @@ Richiede il codice se lontano per del tempo. tra %1$s Disabilitato + Sblocca con impronta digitale + Conferma impronta digitale per continuare + Sensore touch + Impronta digitale non riconosciuta. Riprova Condividi foto e video in questa chat e accedi ad essi da ogni tuo dispositivo. File condivisi Media condivisi Link condivisi + Musica condivisa + Condividi musica in questa chat e accedi ad essa da ogni tuo dispositivo. Condividi file e documenti in questa chat e accedi ad essi da ogni tuo dispositivo. Condividi link in questa chat ed accedi ad essi da ogni tuo dispositivo. @@ -742,6 +751,12 @@ Spiacenti, questa funzione non è disponibile nel tuo paese. Non esiste alcun account Telegram con questo username. Questo bot non può unirsi ai gruppi. + + 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. + IMPOSTAZIONI Plus Messenger Veloce @@ -755,7 +770,7 @@ Plus Messenger]]> sarà sempre gratuito.]]>Nessuna pubblicità. Nessun abbonamento. Plus Messenger]]> protegge i tuoi messaggi]]>dagli attacchi degli hacker. Plus Messenger]]> non ha limiti di dimensione]]>per le tue chat e i file multimediali. - Plus Messenger]]> ti consente di accedere]]>ai messaggi da più dispositivi. + Plus Messenger]]> ti consente di accedere]]>ai tuoi messaggi da più dispositivi. I messaggi diPlus Messenger]]> sono fortemente]]>criptati e possono autodistruggersi. Inizia a inviare messaggi @@ -879,6 +894,18 @@ %1$d foto %1$d foto %1$d foto + ultimo accesso %1$d minuti fa + ultimo accesso %1$d minuto fa + ultimo accesso %1$d minuti fa + ultimo accesso %1$d minuti fa + ultimo accesso %1$d minuti fa + ultimo accesso %1$d minuti fa + ultimo accesso %1$d ore fa + ultimo accesso %1$d ora fa + ultimo accesso %1$d ore fa + ultimo accesso %1$d ore fa + ultimo accesso %1$d ore fa + ultimo accesso %1$d ore fa %1$d messaggi inoltrati Messaggio inoltrato @@ -946,11 +973,10 @@ h:mm a %1$s alle %2$s - Plus Messenger per Android si è aggiornato. Nuovo nella versione 3.2.0:\n\n- Nuovi Canali - una nuova modalità per diffondere i tuoi messaggi ad un pubblico infinito (rimpiazzano le vecchie liste broadcast).\n\nPiù info: https://telegram.org/blog/channels - 632 + Plus Messenger per Android si è aggiornato. Nuovo nella versione 3.2.6:\n\n- Nuove animazioni e miglioramenti di interfaccia\n- Supporto per le nuove emoji\n- Altri miglioramenti e risoluzione di problemi + 655 - -\n\nNovità nella versione 3.2.2.2:\n\n- Nuova opzione nelle impostazioni per aprire il profilo/le immagini del profilo quando si preme l\'utente o l\'immagine del gruppo nella schermata principale\n- Aggiunta opzione per il colore gradiente di sfondo\n- Aggiunta opzione per inoltrare i link senza quotare\n- Aggiunto link al canale ufficiale nel menu\n- Correzioni bug + \n\nNovità nella versione 3.2.6.0:\n\n- Correzioni bug Plus Messenger per Android Personalizzazione Codice del colore esadecimale non valido! diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index 38c0f7c1..b4dc2add 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -105,10 +105,8 @@ 채널에서 나가시겠습니까? 채널에 있는 모든 메시지가 삭제됩니다. 편집 - 채널에 대한 공개링크를 선택하신 경우, 누구나 검색을 통하여 입장 가능합니다.\n\n -비공개 채널로 유지를 하시고 싶으실 경우 링크 생성을 하지 말아주세요 - 유저들이 공개 채널에 대하여 검색 및 공유가 가능하도록 링크를 선택하여 주세요.\n\n -채널을 공개하시지 싫으실 경우, 비공개 채널을 추천드립니다. + 채널에 대한 공개링크를 선택하신 경우, 누구나 검색을 통하여 입장 가능합니다.\n\n비공개 채널로 유지를 하시고 싶으실 경우 링크 생성을 하지 말아주세요 + 유저들이 공개 채널에 대하여 검색 및 공유가 가능하도록 링크를 선택하여 주세요.\n\n채널을 공개하시지 싫으실 경우, 비공개 채널을 추천드립니다. 채널 생성됨 채널 사진 업데이트됨 채널 사진 삭제됨 @@ -134,6 +132,7 @@ %1$s 님을 이 채널에 추가할까요 해당 유저가 스스로 채널에서 퇴장을 하여 다시 초대할 수 없습니다. 죄송합니다, 이 유저를 채널에 추가 할 수 없습니다. + 죄송합니다, 채널에 너무 많은 관리자가 있습니다. 죄송합니다, 채널에는 첫 200명까지만 초대가 가능합니다. 채널 링크를 통하여 무제한 입장이 가능합니다. 이 채널에 un1님이 초대하였습니다. 채널에 참여하였습니다. @@ -149,14 +148,14 @@ %1$s님이 %2$s 채널에 파일을 보냈습니다 %1$s님이 %2$s 채널에 오디오를 보냈습니다 %1$s님이 %2$s 채널에 스티커를 보냈습니다 - %1$s채널에 새 메시지가 있습니다. - %1$s채널에 새 사진이 있습니다. - %1$s채널에 새 비디오가 있습니다. - %1$s채널에 새 연락처가 있습니다. - %1$s채널에 새 위치가 있습니다. - %1$s채널에 새 파일이 있습니다. - %1$s채널에 새 음성 메시지가 있습니다. - %1$s채널에 새 스티커가 있습니다. + %1$s 님이 메시지를 보냈습니다 + %1$s 님이 사진을 보냈습니다 + %1$s 님이 동영상을 보냈습니다 + %1$s님이 연락처를 공유했습니다 + %1$s님이 위치를 보냈습니다 + %1$s 님이 파일을 보냈습니다 + %1$s님이 음성메시지를 보냈습니다 + %1$s님이 스티커를 보냈습니다 새 단체 메시지 리스트 리스트 이름을 입력하세요 @@ -241,6 +240,7 @@ 이 그룹 메시지를 스팸신고 하시겠습니까? 죄송합니다, 서로 연락처가 추가된 경우에만 메시지 전송이 가능합니다. 죄송합니다, 서로 연락처가 추가된 경우에만 그룹에 구성원을 추가 할 수 있습니다. + https://telegram.org/faq#can-39t-send-messages-to-non-contacts 더 보기 %1$s님이 자동삭제를 %2$s 후로 설정했습니다 @@ -291,6 +291,7 @@ 온라인 마지막 접속: 마지막 접속: + 방금 전에 확인 친구 초대 전체 검색 최근에 접속 @@ -495,11 +496,17 @@ 일정 시간 후에 잠금코드 활성화 %1$s 후에 비활성화됨 + 지문으로 언락하기 + 지문인식 후 진행해주세요 + 터치 센서 + 지문인식이 실패하였습니다. 다시 시도해주세요. 이 채팅방에서 사진이나 동영상을 공유하면 다른 기기에서도 보실 수 있습니다. 공유한 파일 공유된 미디어 공유한 링크 + 공유된 음악 + 이 채팅방에서 음악을 공유하면 다른 기기에서도 보실 수 있습니다. 이 채팅방에서 파일이나 문서를 공유하면 다른 기기에서도 보실 수 있습니다. 이 채팅방에서 파일이나 문서를 공유하면 다른 기기에서도 보실 수 있습니다. @@ -747,6 +754,12 @@ 이 기능은 회원님의 국가에서는 사용할 수 없습니다. 입력된 아이디와 일치하는 텔레그램 계정이 없습니다. 이 봇은 그룹에 참여 할 수 없습니다. + + Telegram은 여러 기기에서 친구와 메시지를 주고받을 수 있도록 회원님의 연락처 접근이 필요합니다. + Telegram은 사진, 비디오, 음악 및 다양한 미디어를 공유 및 저장하기 위하여 스토리지 접근이 필요합니다. + Telegram이 음성 메시지를 보내기 위하여 마이크에 대한 접근이 필요합니다. + Telegram이 위치를 친구분들과 공유하기 위해 위치에 대한 접근 권한을 필요로 합니다. + 설정 텔레그램 눈부신 속도 @@ -884,6 +897,18 @@ %1$d 개의 사진 %1$d 개의 사진 %1$d 개의 사진 + %1$d 분 전에 확인 + %1$d 분 전에 확인 + %1$d 분 전에 확인 + %1$d 분 전에 확인 + %1$d 분 전에 확인 + %1$d 분 전에 확인 + %1$d 시간 전에 확인 + %1$d 시간 전에 확인 + %1$d 시간 전에 확인 + %1$d 시간 전에 확인 + %1$d 시간 전에 확인 + %1$d 시간 전에 확인 %1$d 개의 전달된 메시지 전달된 메시지 @@ -951,6 +976,6 @@ a h:mm %1$s %2$s - 텔레그램 안드로이드 버전이 업데이트 되었습니다. 새로운 버전은 3.2.0 입니다:\n\n-- 채널을 소개합니다. - 인원제한 없이 단체 메시지를 보낼 수 있는 새롭고 멋진 기능입니다. (기존 단체 메시지 대체)\n\nhttps://telegram.org/blog/channels에서 자세한 사항을 알아보세요. - 614 + 텔레그램 안드로이드 버전이 업데이트 되었습니다. 새로운 버전은 3.2.6 입니다:\n\n- 새로운 애니메이션 및 다양한 비쥬얼 향상\n- 신규 이모티콘 지원\n- 기타 기능 향상 및 버그 수정 + 655 \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index 325ed7f5..4787dd4c 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -100,7 +100,7 @@ Kanaal verwijderen Kanaal echt verwijderen? Berichten worden gewist en alle deelnemers verwijderd. Kanaal echt verlaten? - Je raakt alle berichten in de kanaal kwijt. + Je raakt alle berichten in dit kanaal kwijt. Wijzig Als je een publieke link voor je kanaal instelt kan iedereen deze vinden en deelnemen via de zoekfunctie.\n\nStel geen link in als je je kanaal privé wilt houden. Stel een link in voor je publieke kanaal, om deze vindbaar te maken via de zoekfunctie en te delen met anderen.\n\nWil je dit niet dan kun je een privé-kanaal aanmaken. @@ -108,7 +108,7 @@ Kanaalfoto bijgewerkt Kanaalfoto verwijderd Kanaalnaam gewijzigd naar un2 - un1 heeft je toegevoegd aan kanaal un2 + un1 heeft je toegevoegd aan het kanaal un2 Het maximale aantal publieke kanalen is bereikt. Je kunt een privé-kanaal maken of een kanaal verwijderen om een nieuwe te maken. Moderator Maker @@ -129,12 +129,13 @@ %1$s toevoegen aan het kanaal? Deze gebruiker heeft de groep verlaten. Je kunt hem/haar niet meer uitnodigen. Je kunt deze gebruiker niet toevoegen aan kanalen. + Maximaal aantal administrators bereikt. Je kunt 200 deelnemers handmatig toevoegen aan een kanaal. Een ongelimiteerd aantal mensen kan deelnemen via de link van het kanaal. un1 heeft je toegevoegd aan dit kanaal Je neemt deel aan het kanaal Verwijderen uit kanaal Je hebt alleen leesrechten in dit kanaal. - %1$s heeft je toegevoegd aan het kanaall %2$s + %1$s heeft je toegevoegd aan het kanaal %2$s Kanaalfoto van %1$s bijgewerkt %1$s heeft een bericht gestuurd naar het kanaal %2$s %1$s heeft een foto gestuurd naar het kanaal %2$s @@ -144,14 +145,14 @@ %1$s heeft een bestand gestuurd naar het kanaal %2$s %1$s heeft een geluidsbestand gestuurd naar het kanaal %2$s %1$s heeft een sticker gestuurd naar het kanaal %2$s - Nieuw bericht in het kanaal %1$s - Nieuwe foto in het kanaal %1$s - Nieuwe video in het kanaal %1$s - Contact gedeeld in het kanaal %1$s - Nieuwe locatie gedeeld in het kanaal %1$s - Nieuw bestand gedeeld in het kanaal %1$s - Nieuw geluidsbestand gedeeld in het kanaal %1$s - Nieuwe sticker gedeeld in het kanaal %1$s + %1$s plaatste een bericht + %1$s plaatste een foto + %1$s plaatste een video + %1$s plaatste een contact + %1$s plaatste een locatie + %1$s plaatste een bestand + %1$s plaatste een spraakbericht + %1$s plaatste een sticker Nieuwe verzendlijst Naam van lijst @@ -236,6 +237,7 @@ Spam van deze groep echt melden? Je kunt momenteel alleen berichten sturen aan onderlingen contacten. Je kunt momenteel alleen onderlinge contacten aan groepen toevoegen + https://telegram.org/faq#can-39t-send-messages-to-non-contacts Meer informatie %1$s heeft de zelfvernietigingstimer ingesteld op %2$s @@ -286,6 +288,7 @@ online gezien gezien + laatst gezien zojuist Vrienden uitnodigen WERELDWIJD ZOEKEN recent gezien @@ -402,7 +405,7 @@ Contact lid van Telegram PEBBLE Taal - De ondersteuning van Telegram wordt gedaan door vrijwilligers. We doen ons best om zo snel mogelijk te antwoorden.
]]>Bekijk ook de veelgestelde vragen]]>: Hierhier staan de antwoorden op de meeste vragen en belangrijke tips voor het oplossen van problemen]]>.
+ 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 Veelgestelde vragen https://telegram.org/faq @@ -490,11 +493,17 @@ Vraag om toegangscode indien afwezig over %1$s Uitgeschakeld + Ontgrendel met vingerafdruk + Vingerafdruk bevestigen + Vingerafdruksensor + Vingerafdruk niet herkend, probeer opnieuw Deel foto\'s en video\'s in deze chat om ze op al je apparaten te kunnen benaderen. Gedeelde bestanden Gedeelde media Gedeelde links + Gedeelde muziek + Deel muziek in deze chat om ze op al je apparaten te kunnen benaderen. Deel bestanden en documenten in deze chat om ze op al je apparaten te kunnen benaderen. Deel links in deze chat om ze op al je apparaten te kunnen benaderen. @@ -742,6 +751,12 @@ Sorry, deze functie is momenteel niet beschikbaar in jouw land. Er is geen Telegram-account met deze gebruikersnaam. Deze bot kan geen groepslid worden. + + 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. + INSTELLINGEN Plus Messenger Snel @@ -879,6 +894,18 @@ %1$d foto\'s %1$d foto\'s %1$d foto\'s + laatst gezien %1$d minuten geleden + laatst gezien %1$d minuut geleden + laatst gezien %1$d minuten geleden + laatst gezien %1$d minuten geleden + laatst gezien %1$d minuten geleden + laatst gezien %1$d minuten geleden + laatst gezien %1$d uur geleden + laatst gezien %1$d uur geleden + laatst gezien %1$d uur geleden + laatst gezien %1$d uur geleden + laatst gezien %1$d uur geleden + laatst gezien %1$d uur geleden Bijlage: %1$d berichten Bijlage: 1 bericht @@ -946,8 +973,8 @@ h:mm a %1$s om %2$s - Plus Messenger voor Android is bijgewerkt. Nieuw in versie 3.2.0:\n\n- Nieuw, kanalen - een perfecte manier om berichten naar een ongelimiteerd publiek te versturen (vervangt de oude verzendlijsten).\n\nMeer over deze update: https://telegram.org/blog/channels - 632 + Plus Messenger voor Android is bijgewerkt. Nieuw in versie 3.2.6:\n\n- Nieuwe animaties en andere visuele verbeteringen\n- Ondersteuning voor nieuwe Emoji\n-Tijdsaanduiding voor laatst gezien gelijk aan iOS\n-Probleemoplossing en andere verbeteringen + 655 Plus Messenger voor Android diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 14514e90..0f329535 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -129,6 +129,7 @@ Adicionar %1$s ao canal? Desculpe, esse usuário decidiu sair do grupo, você não pode adicioná-lo novamente. Desculpe, você não pode adicionar esse usuário em canais. + Desculpe, muitos administradores nesse canal. Desculpe, você só pode adicionar os primeiros 200 membros ao canal. Note que um número ilimitado de pessoas podem entrar via link do canal. un1 adicionou você ao canal Você entrou no canal @@ -144,14 +145,14 @@ %1$s enviou um arquivo ao canal %2$s %1$s enviou um áudio ao canal %2$s %1$s enviou um sticker ao canal %2$s - Nova mensagem no canal %1$s - Nova foto no canal %1$s - Novo vídeo no canal %1$s - Contato compartilhado no canal %1$s - Nova localização compartilhada no canal %1$s - Novo arquivo compartilhado no canal %1$s - Nova mensagem de voz compartilhada no canal %1$s - Novo sticker compartilhado no canal %1$s + %1$s postou uma mensagem + %1$s postou uma foto + %1$s postou um vídeo + %1$s postou um contato + %1$s postou uma foto + %1$s postou um arquivo + %1$s postou uma mensagem de voz + %1$s postou um sticker Nova Lista de Transmissão Digite o nome da lista @@ -236,6 +237,7 @@ Você tem certeza que deseja reportar esse grupo por spam? Desculpe, você pode enviar mensagens somente para contatos mútuos no momento. Desculpe, você só pode adicionar contatos mútuos à grupos no momento. + https://telegram.org/faq/br#no-consigo-enviar-mensagens-para-no-contatos Mais informações %1$s estabeleceu o tempo de autodestruição para %2$s @@ -286,6 +288,7 @@ online visto visto + visto agora mesmo Convidar Amigos BUSCA GLOBAL visto recentemente @@ -298,7 +301,7 @@ Digite o nome do grupo Nome do grupo %1$d/%2$d membros - Você deseja entrar no chat \'%1$s1? + Você deseja entrar no chat \'%1$s\'? Desculpe, este grupo já está lotado. Desculpe, esse chat não existe. Link copiado para área de transferência @@ -490,11 +493,17 @@ Requisitar senha se estiver ausente por muito tempo. em %1$s Desativado + Desbloquear com Impressão Digital + Confirme a impressão digital para continuar + Toque o sensor + Impressão digital não reconhecida. Compartilhar fotos e vídeos no chat e acessá-los em qualquer um de seus dispositivos. Arquivos Compartilhados Mídia Compartilhada Links Compartilhados + Música Compartilhada + Compartilhe músicas nesse chat e os acesse de qualquer um de seus dispositivos. Compartilhar arquivos e documentos no chat e acessá-los de qualquer um de seus dispositivos. Compartilhe links nesse chat e os acesse de qualquer um de seus dispositivos @@ -742,6 +751,12 @@ Desculpe, esta funcionalidade não está disponível para seu país. Não há conta do Telegram com esse nome de usuário Esse bot não pode entrar em grupos. + + 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. + CONFIGURAÇÕES Plus Messenger Rápido @@ -879,6 +894,18 @@ %1$d fotos %1$d fotos %1$d fotos + visto há %1$d minutos + visto há %1$d minuto + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d horas + visto há %1$d hora + visto há %1$d horas + visto há %1$d horas + visto há %1$d horas + visto há %1$d horas %1$d mensagens encaminhadas Mensagem encaminhada @@ -946,11 +973,11 @@ h:mm a %1$s às %2$s - Plus Messenger para Android foi atualizado. Novidade na versão 3.2.0:\n\n- Introduzindo Canais – Uma grande nova maneira de transmitir suas mensagens, com audiência ilimitada (substitui as antigas Transmissões).\n\nMais sobre a atualização: https://telegram.org/blog/channels - 632 - -\n\nNovidades ne versão 3.2.2.1:\n\n- Agora o papel de parede pode ser alterado pela tela de chat\n- Melhorias no método de aplicação do papel de parede\n- Nome de usuário é copiado para o clipboard se clicado na tela de perfil\n- Correções de erros--> +\n\nNovidades na versão 3.2.6.0:\n\n- Correções de erros Plus Messenger para Android Personalização Código de cor HEX inválido! @@ -1101,4 +1128,11 @@ %s copiado para o clipboard \n\nJunte-se ao canal oficial do Plus Messenger: https://telegram.me/plusmsn + Baixar Temas + Canal Oficial + Diálogos + Clique na foto do contato + Clique na foto do grupo + Perfil + Fotos de Perfil \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 55254e05..57eddce4 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -132,6 +132,7 @@ Adicionar %1$s ao canal? Desculpe, esse usuário decidiu sair do grupo, você não pode adicioná-lo novamente. Desculpe, você não pode adicionar esse usuário em canais. + Desculpe, muitos administradores nesse canal. Desculpe, você só pode adicionar os primeiros 200 membros ao canal. Note que um número ilimitado de pessoas podem entrar via link do canal. un1 adicionou você ao canal Você entrou no canal @@ -147,14 +148,14 @@ %1$s enviou um arquivo ao canal %2$s %1$s enviou um áudio ao canal %2$s %1$s enviou um sticker ao canal %2$s - Nova mensagem no canal %1$s - Nova foto no canal %1$s - Novo vídeo no canal %1$s - Contato compartilhado no canal %1$s - Nova localização compartilhada no canal %1$s - Novo arquivo compartilhado no canal %1$s - Nova mensagem de voz compartilhada no canal %1$s - Novo sticker compartilhado no canal %1$s + %1$s postou uma mensagem + %1$s postou uma foto + %1$s postou um vídeo + %1$s postou um contato + %1$s postou uma foto + %1$s postou um arquivo + %1$s postou uma mensagem de voz + %1$s postou um sticker Nova Lista de Transmissão Digite o nome da lista @@ -239,6 +240,7 @@ Você tem certeza que deseja reportar esse grupo por spam? Desculpe, você pode enviar mensagens somente para contatos mútuos no momento. Desculpe, você só pode adicionar contatos mútuos à grupos no momento. + https://telegram.org/faq/br#no-consigo-enviar-mensagens-para-no-contatos Mais informações %1$s estabeleceu o tempo de autodestruição para %2$s @@ -289,6 +291,7 @@ online visto visto + visto agora mesmo Convidar Amigos BUSCA GLOBAL visto recentemente @@ -301,7 +304,7 @@ Digite o nome do grupo Nome do grupo %1$d/%2$d membros - Você deseja entrar no chat \'%1$s1? + Você deseja entrar no chat \'%1$s\'? Desculpe, este grupo já está lotado. Desculpe, esse chat não existe. Link copiado para área de transferência @@ -493,11 +496,17 @@ Requisitar senha se estiver ausente por muito tempo. em %1$s Desativado + Desbloquear com Impressão Digital + Confirme a impressão digital para continuar + Toque o sensor + Impressão digital não reconhecida. Compartilhar fotos e vídeos no chat e acessá-los em qualquer um de seus dispositivos. Arquivos Compartilhados Mídia Compartilhada Links Compartilhados + Música Compartilhada + Compartilhe músicas nesse chat e os acesse de qualquer um de seus dispositivos. Compartilhar arquivos e documentos no chat e acessá-los de qualquer um de seus dispositivos. Compartilhe links nesse chat e os acesse de qualquer um de seus dispositivos @@ -745,6 +754,12 @@ Desculpe, esta funcionalidade não está disponível para seu país. Não há conta do Telegram com esse nome de usuário Esse bot não pode entrar em grupos. + + 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. + CONFIGURAÇÕES Plus Messenger Rápido @@ -882,6 +897,18 @@ %1$d fotos %1$d fotos %1$d fotos + visto há %1$d minutos + visto há %1$d minuto + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d minutos + visto há %1$d horas + visto há %1$d hora + visto há %1$d horas + visto há %1$d horas + visto há %1$d horas + visto há %1$d horas %1$d mensagens encaminhadas Mensagem encaminhada @@ -949,8 +976,8 @@ h:mm a %1$s às %2$s - Plus Messenger para Android foi atualizado. Novidade na versão 3.2.0:\n\n- Introduzindo Canais – Uma grande nova maneira de transmitir suas mensagens, com audiência ilimitada (substitui as antigas Transmissões).\n\nMais sobre a atualização: https://telegram.org/blog/channels - 632 + Plus Messenger para Android foi atualizado. Novidades na versão 3.2.6:\n\n- Novas animações e melhorias no visual\n- Suporte para novos emojis\n- Outras melhorias e resoluções de bugs + 655 Plus Messenger para Android Temas diff --git a/TMessagesProj/src/main/res/values-ru/strings.xml b/TMessagesProj/src/main/res/values-ru/strings.xml index 3e503089..21c56f99 100644 --- a/TMessagesProj/src/main/res/values-ru/strings.xml +++ b/TMessagesProj/src/main/res/values-ru/strings.xml @@ -129,6 +129,7 @@ Добавить пользователя %1$s на канал? Извините, этот пользователь решил покинуть данную группу, поэтому вы не можете пригласить его обратно. Извините, вы не можете добавить этого пользователя на каналы. + Извините, у этого канала слишком много администраторов. Извините, вы можете добавлять только первых 200 участников на канал. Заметьте, что неограниченное количество людей может присоединиться по ссылке канала. un1 добавил(а) вас на этот канал Вы присоединились к этому каналу @@ -144,14 +145,14 @@ %1$s опубликовал(а) файл на канале %2$s %1$s опубликовал(а) аудио на канале %2$s %1$s опубликовал(а) стикер на канале %2$s - Новое сообщение на канале %1$s - Новое фото на канале %1$s - Новое видео на канале %1$s - На канале %1$s поделились контактом - На канале %1$s поделились новым расположением - На канале %1$s поделились новым файлом - На канале %1$s поделились новым голосовым сообщением - На канале %1$s поделились новым стикером + %1$s опубликовал сообщение + %1$s опубликовал фото + %1$s опубликовал видео + %1$s опубликовал контакт + %1$s опубликовал расположение + %1$s опубликовал файл + %1$s опубликовал голосовое сообщение + %1$s опубликовал стикер Новый список рассылки Введите имя списка @@ -236,6 +237,7 @@ Уверены, что хотите сообщить о спаме от этой группы? Извините, в данный момент вы можете отправлять сообщения только взаимным контактам. Извините, в данный момент вы можете добавлять в группы только взаимные контакты. + https://telegram.org/faq#can-39t-send-messages-to-non-contacts Больше информации %1$s поставил(а) таймер самоуничтожения на %2$s @@ -286,6 +288,7 @@ в сети заходил(а) заходил(а) + заходил(а) только что Пригласить друзей ГЛОБАЛЬНЫЙ ПОИСК заходил(а) недавно @@ -490,13 +493,19 @@ Запрашивать код доступа при отсутствии в течение определённого времени. через %1$s Отключена + Разблокируйте отпечатком пальца + Подтвердите отпечаток пальца для продолжения + Сканер отпечатков пальцев + Отпечаток пальца не распознан. Попробуйте снова Поделитесь фото и видео в этом чате и получите доступ к ним на любом из ваших устройств. Общие файлы Общие медиа Общие ссылки - Поделитесь файлами и документами в этом чате и получите доступ к ним на любом из ваших устройств. - Делитесь ссылками в этом чате и получайте к ним доступ с любого из ваших устройств. + Общая музыка + Делитесь музыкой в этом чате и получайте доступ к ней с любого из ваших устройств. + Делитесь файлами и документами в этом чате и получайте доступ к ним с любого из ваших устройств. + Делитесь ссылками в этом чате и получайте доступ к ним с любого из ваших устройств. Карта Спутник @@ -742,6 +751,12 @@ Извините, эта возможность пока не доступна в вашей стране. Нет аккаунта Telegram с таким именем. Этот бот не может вступать в группы. + + Telegram необходим доступ к вашим контактам, чтобы вы могли оставаться на связи с вашими друзьями с любого устройства. + Telegram необходим доступ к вашему хранилищу файлов, чтобы вы могли отправлять и сохранять фото, видео, музыку и прочее медиа. + Telegram необходим доступ к вашему микрофону, чтобы вы могли отправлять голосовые сообщения + Telegram необходим доступ к вашему расположению, чтобы вы могли делиться им со своими друзьями. + НАСТРОЙКИ Plus Messenger Быстрый @@ -879,6 +894,18 @@ %1$d фото %1$d фото %1$d фото + заходил(а) %1$d минут назад + заходил(а) %1$d минуту назад + заходил(а) %1$d минуты назад + заходил(а) %1$d минуты назад + заходил(а) %1$d минут назад + заходил(а) %1$d минут назад + заходил(а) %1$d часов назад + заходил(а) %1$d час назад + заходил(а) %1$d часа назад + заходил(а) %1$d часа назад + заходил(а) %1$d часов назад + заходил(а) %1$d часов назад %1$d пересланных сообщений Пересланное сообщение @@ -946,11 +973,11 @@ h:mm a %1$s в %2$s - Telegram для Android обновлён. Новое в версии 3.2.0:\n\n- Представляем Каналы – новый отличный способ транслировать свои сообщения неограниченной аудитории (заменяют старые списки рассылок).\n\nЧитать больше: https://telegram.org/blog/channels - 632 - -\n\nНовое в версии 3.2.2.2:\n\n- Обои можно изменить не покидая экран чата\n- Улучшен способ использования обоев из тем\n- Имя пользователя копируется в буфер обмена при касании на экране профиля\n- Исправление ошибок--> +\n\nНовое в версииn 3.2.6.0:\n\n- Исправление ошибок Plus Messenger для Android Кастомизация Неверный hex-код цвета! @@ -1101,4 +1128,11 @@ %s скопировано в буфер обмена \n\nПрисоединяйтесь к официальному каналу Plus Messenger: https://telegram.me/plusmsn + Загрузить темы + Официальный канал + Диалоги + Касание аватарки контакта + Касание аватарки группы + Профиль + Аватарки diff --git a/TMessagesProj/src/main/res/values-tr/strings.xml b/TMessagesProj/src/main/res/values-tr/strings.xml index 1e3f15a8..27f8e93b 100644 --- a/TMessagesProj/src/main/res/values-tr/strings.xml +++ b/TMessagesProj/src/main/res/values-tr/strings.xml @@ -830,7 +830,7 @@ %1$s %2$s - 632 + 655 diff --git a/TMessagesProj/src/main/res/values-v21/styles.xml b/TMessagesProj/src/main/res/values-v21/styles.xml index 9f447594..73fcd609 100644 --- a/TMessagesProj/src/main/res/values-v21/styles.xml +++ b/TMessagesProj/src/main/res/values-v21/styles.xml @@ -1,9 +1,9 @@ %1$s 的 %2$s - 632 + 655 Plus Messenger for Android @@ -1050,4 +1050,11 @@ %s 已复制到剪贴板 \n\n加入 Plus Messenger 官方频道: https://telegram.me/plusmsn + 下载主题 + 官方频道 + 对话框 + 点击联系人图片 + 点击群组图片 + 个人资料 + 个人资料图片 diff --git a/TMessagesProj/src/main/res/values-zh-rTW/strings.xml b/TMessagesProj/src/main/res/values-zh-rTW/strings.xml index 84815e9b..b438eb2c 100644 --- a/TMessagesProj/src/main/res/values-zh-rTW/strings.xml +++ b/TMessagesProj/src/main/res/values-zh-rTW/strings.xml @@ -945,9 +945,9 @@ HH:mm a h:mm 於時間 %1$s %2$s - + diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index f605a5a4..d9c5d2de 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -1,4 +1,7 @@ - + + + + Plus Messenger Plus @@ -130,6 +133,7 @@ Add %1$s to the channel? Sorry, this user decided to leave this group, so you cannot invite them back here. Sorry, you can\'t add this user to channels. + Sorry, too many admins in this channel. Sorry, you can only add the first 200 members to a channel. Note that an unlimited number of people may join via the channel\'s link. un1 added you to this channel You joined the channel @@ -145,14 +149,14 @@ %1$s sent a file to the channel %2$s %1$s sent an audio to the channel %2$s %1$s sent a sticker to the channel %2$s - New message in the channel %1$s - New photo in the channel %1$s - New video in the channel %1$s - Contact shared in the channel %1$s - New location shared in the channel %1$s - New file shared in the channel %1$s - New voice note shared in the channel %1$s - New sticker shared in the channel %1$s + %1$s posted a message + %1$s posted a photo + %1$s posted a video + %1$s posted a contact + %1$s posted a location + %1$s posted a file + %1$s posted a voice message + %1$s posted a sticker New Broadcast List Enter list name @@ -237,6 +241,7 @@ Are you sure you want to report spam from this group? Sorry, you can only send messages to mutual contacts at the moment. Sorry, you can only add mutual contacts to groups at the moment. + https://telegram.org/faq#can-39t-send-messages-to-non-contacts More info %1$s set the self-destruct timer to %2$s @@ -287,6 +292,7 @@ online last seen last seen + last seen just now Invite Friends GLOBAL SEARCH last seen recently @@ -491,11 +497,17 @@ Require passcode if away for a time. in %1$s Disabled + Unlock with Fingerprint + Confirm fingerprint to continue + Touch sensor + Fingerprint not recognized. Try again Share photos and videos in this chat and access them on any of your devices. Shared Files Shared Media Shared Links + Shared Music + Share music in this chat and access them on any of your devices. Share files and documents in this chat and access them on any of your devices. Share links in this chat and access them on any of your devices. @@ -743,6 +755,12 @@ Sorry, this feature is currently not available in your country. There is no Telegram account with this username. This bot can\'t join groups. + + 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. + SETTINGS Plus Messenger Fast @@ -880,6 +898,18 @@ %1$d photos %1$d photos %1$d photos + last seen %1$d minutes ago + last seen %1$d minute ago + last seen %1$d minutes ago + last seen %1$d minutes ago + last seen %1$d minutes ago + last seen %1$d minutes ago + last seen %1$d hours ago + last seen %1$d hour ago + last seen %1$d hours ago + last seen %1$d hours ago + last seen %1$d hours ago + last seen %1$d hours ago %1$d forwarded messages Forwarded message @@ -947,10 +977,10 @@ h:mm a %1$s at %2$s - Telegram for Android has been updated. New in version 3.2.0:\n\n- Introducing Channels – a great new way to broadcast your messages to unlimited audiences (replaces old Broadcasts).\n\nRead more: https://telegram.org/blog/channels - 632 + Plus Messenger for Android has been updated. New in version 3.2.6:\n\n- New animations and many visual improvements\n- Support for new emoji\n- Android 6.0 support (Now on Tap - Direct Share - Fingerprint support for Passcodes)\n- Other improvements and bug fixes + 655 - \n\nNew in version 3.2.2.2:\n\n- New option in settings to open profile/profile pics when clicking user/group pic in main screen\n- Added gradient option to chat background color\n- Added option to forward link without quoting\n- Added link to official channel in menu\n- Bug fixes + \n\nNew in version 3.2.6.0:\n\n- Bug fixes Plus Messenger for Android Theming Invalid color hex code!