- New animations and many visual improvements

- Support for new emoji
- Android 6.0 support
- Now on Tap
- Direct Share
- Fingerprint support for Passcodes (Android 6.0 only)
- Other improvements and bug fixes
This commit is contained in:
rafalense 2015-10-31 12:17:00 +01:00
parent 6b94e8d180
commit 5f5081ce7c
247 changed files with 4442 additions and 2223 deletions

View File

@ -5,19 +5,20 @@ repositories {
} }
dependencies { 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:3.2.+'
//compile 'com.google.android.gms:play-services:7.5.0' //compile 'com.google.android.gms:play-services:7.5.0'
compile 'net.hockeyapp.android:HockeySDK:3.5.+' compile 'net.hockeyapp.android:HockeySDK:3.5.+'
compile 'com.googlecode.mp4parser:isoparser:1.0.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+'
compile 'org.apache.httpcomponents:httpmime:4.2.1' compile 'org.apache.httpcomponents:httpmime:4.2.1'
//compile 'com.android.support:multidex:1.0.1'
} }
android { android {
compileSdkVersion 22 compileSdkVersion 23
buildToolsVersion '23.0.1' buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
packagingOptions { packagingOptions {
exclude 'META-INF/NOTICE.txt' exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt' exclude 'META-INF/LICENSE.txt'
@ -87,9 +88,8 @@ android {
defaultConfig { defaultConfig {
applicationId "org.telegram.plus" applicationId "org.telegram.plus"
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 22 targetSdkVersion 23
versionCode 632 versionCode 655
versionName "3.2.2.2" versionName "3.2.6.0"
//multiDexEnabled true
} }
} }

View File

@ -34,7 +34,7 @@
<activity android:name="net.hockeyapp.android.UpdateActivity" /> <activity android:name="net.hockeyapp.android.UpdateActivity" />
<receiver <receiver
android:name="org.telegram.messenger.GcmBroadcastReceiver" android:name=".GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" > android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter> <intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" /> <action android:name="com.google.android.c2dm.intent.RECEIVE" />

View File

@ -187,7 +187,7 @@ include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_STATIC_LIBRARIES := webp sqlite tgnet breakpad 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 := -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 += -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 LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math

View File

@ -16,11 +16,6 @@ jfieldID jclass_Options_inJustDecodeBounds;
jfieldID jclass_Options_outHeight; jfieldID jclass_Options_outHeight;
jfieldID jclass_Options_outWidth; 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 PGPhotoEnhanceHistogramBins = 256;
const uint32_t PGPhotoEnhanceSegments = 4; const uint32_t PGPhotoEnhanceSegments = 4;
@ -58,24 +53,6 @@ jint imageOnJNILoad(JavaVM *vm, void *reserved, JNIEnv *env) {
return -1; 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; 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) { if (!buffer) {
(*env)->ThrowNew(env, jclass_NullPointerException, "Input buffer can not be null"); (*env)->ThrowNew(env, jclass_NullPointerException, "Input buffer can not be null");
return 0; 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) { 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_outWidth, bitmapWidth);
(*env)->SetIntField(env, options, jclass_Options_outHeight, bitmapHeight); (*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) { if (!outputBitmap) {
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to allocate Bitmap"); (*env)->ThrowNew(env, jclass_NullPointerException, "output bitmap can not be null");
return 0; return 0;
} }
outputBitmap = (*env)->NewLocalRef(env, outputBitmap);
AndroidBitmapInfo bitmapInfo; AndroidBitmapInfo bitmapInfo;
if (AndroidBitmap_getInfo(env, outputBitmap, &bitmapInfo) != ANDROID_BITMAP_RESUT_SUCCESS) { if (AndroidBitmap_getInfo(env, outputBitmap, &bitmapInfo) != ANDROID_BITMAP_RESUT_SUCCESS) {
(*env)->DeleteLocalRef(env, outputBitmap);
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to get Bitmap information"); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to get Bitmap information");
return 0; return 0;
} }
void *bitmapPixels = 0; void *bitmapPixels = 0;
if (AndroidBitmap_lockPixels(env, outputBitmap, &bitmapPixels) != ANDROID_BITMAP_RESUT_SUCCESS) { if (AndroidBitmap_lockPixels(env, outputBitmap, &bitmapPixels) != ANDROID_BITMAP_RESUT_SUCCESS) {
(*env)->DeleteLocalRef(env, outputBitmap);
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to lock Bitmap pixels"); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to lock Bitmap pixels");
return 0; return 0;
} }
if (!WebPDecodeRGBAInto((uint8_t*)inputBuffer, len, (uint8_t*)bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) { if (!WebPDecodeRGBAInto((uint8_t*)inputBuffer, len, (uint8_t*)bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) {
AndroidBitmap_unlockPixels(env, outputBitmap); AndroidBitmap_unlockPixels(env, outputBitmap);
(*env)->DeleteLocalRef(env, outputBitmap);
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to decode webp image"); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to decode webp image");
return 0; return 0;
} }
if (AndroidBitmap_unlockPixels(env, outputBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) { if (unpin && AndroidBitmap_unlockPixels(env, outputBitmap) != ANDROID_BITMAP_RESUT_SUCCESS) {
(*env)->DeleteLocalRef(env, outputBitmap);
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to unlock Bitmap pixels"); (*env)->ThrowNew(env, jclass_RuntimeException, "Failed to unlock Bitmap pixels");
return 0; return 0;
} }
return outputBitmap; return 1;
} }

View File

@ -12,8 +12,6 @@
<uses-feature android:glEsVersion="0x00020000" android:required="false"/> <uses-feature android:glEsVersion="0x00020000" android:required="false"/>
<uses-feature android:name="android.hardware.telephony" android:required="false" /> <uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" /> <uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" /> <uses-feature android:name="android.hardware.screen.PORTRAIT" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" /> <uses-feature android:name="android.hardware.microphone" android:required="false" />
@ -26,7 +24,6 @@
<uses-permission android:name="android.permission.WAKE_LOCK" /> <uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" /> <uses-permission android:name="android.permission.WRITE_CONTACTS" />
@ -39,6 +36,7 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<application <application
android:name=".ApplicationLoader" android:name=".ApplicationLoader"
@ -108,6 +106,7 @@
<category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tg" /> <data android:scheme="tg" />
</intent-filter> </intent-filter>
<meta-data android:name="android.service.chooser.chooser_target_service" android:value=".TgChooserTargetService" />
</activity> </activity>
<activity <activity
android:name="org.telegram.ui.IntroActivity" android:name="org.telegram.ui.IntroActivity"
@ -159,6 +158,15 @@
android:resource="@xml/contacts" /> android:resource="@xml/contacts" />
</service> </service>
<service
android:name=".TgChooserTargetService"
android:label="@string/AppName"
android:permission="android.permission.BIND_CHOOSER_TARGET_SERVICE">
<intent-filter>
<action android:name="android.service.chooser.ChooserTargetService" />
</intent-filter>
</service>
<service android:name=".NotificationsService" android:enabled="true"/> <service android:name=".NotificationsService" android:enabled="true"/>
<service android:name=".NotificationRepeat" android:exported="false"/> <service android:name=".NotificationRepeat" android:exported="false"/>
<service android:name=".VideoEncodingService" android:enabled="true"/> <service android:name=".VideoEncodingService" android:enabled="true"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 280 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.SQLite;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.SQLite;
@ -22,7 +22,7 @@ public class SQLiteDatabase {
} }
public SQLiteDatabase(String fileName) throws SQLiteException { public SQLiteDatabase(String fileName) throws SQLiteException {
sqliteHandle = opendb(fileName, ApplicationLoader.applicationContext.getFilesDir().getPath()); sqliteHandle = opendb(fileName, ApplicationLoader.getFilesDirFixed().getPath());
isOpen = true; isOpen = true;
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.SQLite;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.SQLite;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.SQLite;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
@ -96,7 +97,7 @@ public class ApplicationLoader extends Application {
cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd); cachedWallpaper = applicationContext.getResources().getDrawable(R.drawable.background_hd);
isCustomTheme = false; isCustomTheme = false;
} else { } else {
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); File toFile = new File(getFilesDirFixed(), "wallpaper.jpg");
if (toFile.exists()) { if (toFile.exists()) {
cachedWallpaper = Drawable.createFromPath(toFile.getAbsolutePath()); cachedWallpaper = Drawable.createFromPath(toFile.getAbsolutePath());
isCustomTheme = true; isCustomTheme = true;
@ -155,7 +156,7 @@ public class ApplicationLoader extends Application {
} }
try { try {
File file = new File(ApplicationLoader.applicationContext.getFilesDir(), "tgnet.dat"); File file = new File(getFilesDirFixed(), "tgnet.dat");
RandomAccessFile fileOutputStream = new RandomAccessFile(file, "rws"); RandomAccessFile fileOutputStream = new RandomAccessFile(file, "rws");
byte[] bytes = buffer.toByteArray(); byte[] bytes = buffer.toByteArray();
fileOutputStream.writeInt(Integer.reverseBytes(bytes.length)); 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() { public static void postInitApplication() {
if (applicationInited) { if (applicationInited) {
return; return;
@ -205,7 +224,7 @@ public class ApplicationLoader extends Application {
String langCode; String langCode;
String appVersion; String appVersion;
String systemVersion; String systemVersion;
String configPath = ApplicationLoader.applicationContext.getFilesDir().toString(); String configPath = getFilesDirFixed().toString();
try { try {
langCode = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale()); langCode = LocaleController.getLocaleString(LocaleController.getInstance().getSystemDefaultLocale());
@ -233,7 +252,7 @@ public class ApplicationLoader extends Application {
} }
MessagesController.getInstance(); 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) { if (UserConfig.getCurrentUser() != null) {
MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true); MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true);
ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone); ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone);

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; 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); FileLog.d("tmessages", "start loading file to temp = " + cacheFileTemp + " final = " + cacheFileFinal);
} }
@ -377,13 +378,15 @@ public class FileLoadOperation {
} }
if (cacheFileTemp != null) { if (cacheFileTemp != null) {
if (!cacheFileTemp.renameTo(cacheFileFinal)) { 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); FileLog.e("tmessages", "unable to rename temp = " + cacheFileTemp + " to final = " + cacheFileFinal);
} }
cacheFileFinal = cacheFileTemp; cacheFileFinal = cacheFileTemp;
} }
} }
if (BuildVars.DEBUG_VERSION) { //if (BuildVars.DEBUG_VERSION) {
if (BuildConfig.DEBUG) {
FileLog.e("tmessages", "finished downloading file to " + cacheFileFinal); FileLog.e("tmessages", "finished downloading file to " + cacheFileFinal);
} }
delegate.didFinishLoadingFile(FileLoadOperation.this, cacheFileFinal); delegate.didFinishLoadingFile(FileLoadOperation.this, cacheFileFinal);

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *
@ -8,7 +8,6 @@
package org.telegram.messenger; package org.telegram.messenger;
import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
@ -27,7 +26,7 @@ public class FileLoader {
public interface FileLoaderDelegate { public interface FileLoaderDelegate {
void fileUploadProgressChanged(String location, float progress, boolean isEncrypted); 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); void fileDidFailedUpload(String location, boolean isEncrypted);
@ -112,6 +111,7 @@ public class FileLoader {
} }
uploadSizes.remove(location); uploadSizes.remove(location);
if (operation != null) { if (operation != null) {
uploadOperationPathsEnc.remove(location);
uploadOperationQueue.remove(operation); uploadOperationQueue.remove(operation);
uploadSmallOperationQueue.remove(operation); uploadSmallOperationQueue.remove(operation);
operation.cancel(); operation.cancel();
@ -175,7 +175,7 @@ public class FileLoader {
} }
operation.delegate = new FileUploadOperation.FileUploadOperationDelegate() { operation.delegate = new FileUploadOperation.FileUploadOperationDelegate() {
@Override @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() { fileLoaderQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -204,7 +204,7 @@ public class FileLoader {
} }
} }
if (delegate != null) { if (delegate != null) {
delegate.fileDidUploaded(location, inputFile, inputEncryptedFile, key, iv); delegate.fileDidUploaded(location, inputFile, inputEncryptedFile, key, iv, operation.getTotalFileSize());
} }
} }
}); });

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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 FastDateFormat dateFormat = null;
private DispatchQueue logQueue = null; private DispatchQueue logQueue = null;
private File currentFile = null; private File currentFile = null;
private File networkFile = null;
private static volatile FileLog Instance = null; private static volatile FileLog Instance = null;
public static FileLog getInstance() { 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) { public static void e(final String tag, final String message, final Throwable exception) {
//if (!BuildVars.DEBUG_VERSION) { //if (!BuildVars.DEBUG_VERSION) {
if (!BuildConfig.DEBUG) { if (!BuildConfig.DEBUG) {
@ -186,6 +203,9 @@ public class FileLog {
if (getInstance().currentFile != null && file.getAbsolutePath().equals(getInstance().currentFile.getAbsolutePath())) { if (getInstance().currentFile != null && file.getAbsolutePath().equals(getInstance().currentFile.getAbsolutePath())) {
continue; continue;
} }
if (getInstance().networkFile != null && file.getAbsolutePath().equals(getInstance().networkFile.getAbsolutePath())) {
continue;
}
file.delete(); file.delete();
} }
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *
@ -63,6 +63,10 @@ public class FileUploadOperation {
estimatedSize = estimated; estimatedSize = estimated;
} }
public long getTotalFileSize() {
return totalFileSize;
}
public void start() { public void start() {
if (state != 0) { if (state != 0) {
return; return;
@ -77,7 +81,7 @@ public class FileUploadOperation {
} }
public void cancel() { public void cancel() {
if (state != 1) { if (state == 3) {
return; return;
} }
state = 2; state = 2;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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 autoLockIn = 60 * 60;
public static int lastPauseTime = 0; public static int lastPauseTime = 0;
public static boolean isWaitingForPasscodeEnter = false; public static boolean isWaitingForPasscodeEnter = false;
public static boolean useFingerprint = true;
public static int lastUpdateVersion; public static int lastUpdateVersion;
public static int lastContactsSyncTime; public static int lastContactsSyncTime;
public static boolean channelsLoaded = false; public static boolean channelsLoaded = false;
@ -79,6 +80,7 @@ public class UserConfig {
editor.putInt("lastUpdateVersion", lastUpdateVersion); editor.putInt("lastUpdateVersion", lastUpdateVersion);
editor.putInt("lastContactsSyncTime", lastContactsSyncTime); editor.putInt("lastContactsSyncTime", lastContactsSyncTime);
editor.putBoolean("channelsLoaded", channelsLoaded); editor.putBoolean("channelsLoaded", channelsLoaded);
editor.putBoolean("useFingerprint", useFingerprint);
if (currentUser != null) { if (currentUser != null) {
if (withFile) { if (withFile) {
@ -128,7 +130,7 @@ public class UserConfig {
public static void loadConfig() { public static void loadConfig() {
synchronized (sync) { synchronized (sync) {
final File configFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "user.dat"); final File configFile = new File(ApplicationLoader.getFilesDirFixed(), "user.dat");
if (configFile.exists()) { if (configFile.exists()) {
try { try {
SerializedData data = new SerializedData(configFile); SerializedData data = new SerializedData(configFile);
@ -207,6 +209,7 @@ public class UserConfig {
passcodeType = preferences.getInt("passcodeType", 0); passcodeType = preferences.getInt("passcodeType", 0);
autoLockIn = preferences.getInt("autoLockIn", 60 * 60); autoLockIn = preferences.getInt("autoLockIn", 60 * 60);
lastPauseTime = preferences.getInt("lastPauseTime", 0); lastPauseTime = preferences.getInt("lastPauseTime", 0);
useFingerprint = preferences.getBoolean("useFingerprint", true);
lastUpdateVersion = preferences.getInt("lastUpdateVersion", 511); lastUpdateVersion = preferences.getInt("lastUpdateVersion", 511);
lastContactsSyncTime = preferences.getInt("lastContactsSyncTime", (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60); lastContactsSyncTime = preferences.getInt("lastContactsSyncTime", (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60);
channelsLoaded = preferences.getBoolean("channelsLoaded", false); channelsLoaded = preferences.getBoolean("channelsLoaded", false);
@ -281,6 +284,7 @@ public class UserConfig {
passcodeSalt = new byte[0]; passcodeSalt = new byte[0];
autoLockIn = 60 * 60; autoLockIn = 60 * 60;
lastPauseTime = 0; lastPauseTime = 0;
useFingerprint = true;
isWaitingForPasscodeEnter = false; isWaitingForPasscodeEnter = false;
lastUpdateVersion = BuildVars.BUILD_VERSION; lastUpdateVersion = BuildVars.BUILD_VERSION;
lastContactsSyncTime = (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60; lastContactsSyncTime = (int) (System.currentTimeMillis() / 1000) - 23 * 60 * 60;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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 void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride);
public native static int pinBitmap(Bitmap bitmap); public native static int pinBitmap(Bitmap bitmap);
public native static void blurBitmap(Object bitmap, int radius, int unpin); 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 void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer);
public native static boolean loadWebpImage(Bitmap bitmap, ByteBuffer buffer, int len, BitmapFactory.Options options, boolean unpin);
public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options);
public native static int convertVideoFrame(ByteBuffer src, ByteBuffer dest, int destFormat, int width, int height, int padding, int swap); 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); private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);
public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) { public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) {
@ -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)); BigInteger dhBI2 = dhBI.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(2));
return !(!dhBI.isProbablePrime(30) || !dhBI2.isProbablePrime(30)); return !(!dhBI.isProbablePrime(30) || !dhBI2.isProbablePrime(30));
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;
@ -22,10 +22,15 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; 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.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
import java.util.ArrayList;
public class ActionBar extends FrameLayout { public class ActionBar extends FrameLayout {
public static class ActionBarMenuOnItemClick { public static class ActionBarMenuOnItemClick {
@ -45,6 +50,8 @@ public class ActionBar extends FrameLayout {
private ActionBarMenu menu; private ActionBarMenu menu;
private ActionBarMenu actionMode; private ActionBarMenu actionMode;
private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21; private boolean occupyStatusBar = Build.VERSION.SDK_INT >= 21;
private boolean actionModeVisible;
private boolean addToContainer = true;
private boolean allowOverlayTitle; private boolean allowOverlayTitle;
private CharSequence lastTitle; private CharSequence lastTitle;
@ -55,7 +62,6 @@ public class ActionBar extends FrameLayout {
private boolean isBackOverlayVisible; private boolean isBackOverlayVisible;
protected BaseFragment parentFragment; protected BaseFragment parentFragment;
public ActionBarMenuOnItemClick actionBarMenuOnItemClick; public ActionBarMenuOnItemClick actionBarMenuOnItemClick;
private int extraHeight;
public ActionBar(Context context) { public ActionBar(Context context) {
super(context); super(context);
@ -68,6 +74,7 @@ public class ActionBar extends FrameLayout {
backButtonImageView = new ImageView(getContext()); backButtonImageView = new ImageView(getContext());
backButtonImageView.setScaleType(ImageView.ScaleType.CENTER); backButtonImageView.setScaleType(ImageView.ScaleType.CENTER);
backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); backButtonImageView.setBackgroundResource(itemsBackgroundResourceId);
backButtonImageView.setPadding(AndroidUtilities.dp(1), 0, 0, 0);
addView(backButtonImageView, LayoutHelper.createFrame(54, 54, Gravity.LEFT | Gravity.TOP)); addView(backButtonImageView, LayoutHelper.createFrame(54, 54, Gravity.LEFT | Gravity.TOP));
backButtonImageView.setOnClickListener(new OnClickListener() { backButtonImageView.setOnClickListener(new OnClickListener() {
@ -90,6 +97,9 @@ public class ActionBar extends FrameLayout {
} }
backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE); backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE);
backButtonImageView.setImageDrawable(drawable); backButtonImageView.setImageDrawable(drawable);
if (drawable instanceof BackDrawable) {
((BackDrawable) drawable).setRotation(isActionModeShowed() ? 1 : 0, false);
}
} }
public void setBackButtonImage(int resource) { public void setBackButtonImage(int resource) {
@ -111,7 +121,15 @@ public class ActionBar extends FrameLayout {
subTitleTextView.setLines(1); subTitleTextView.setLines(1);
subTitleTextView.setMaxLines(1); subTitleTextView.setMaxLines(1);
subTitleTextView.setEllipsize(TextUtils.TruncateAt.END); 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) { public void setSubtitle(CharSequence value) {
@ -136,7 +154,7 @@ public class ActionBar extends FrameLayout {
titleTextView.setEllipsize(TextUtils.TruncateAt.END); titleTextView.setEllipsize(TextUtils.TruncateAt.END);
titleTextView.setTextColor(0xffffffff); titleTextView.setTextColor(0xffffffff);
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); 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) { public void setTitle(CharSequence value) {
@ -183,12 +201,7 @@ public class ActionBar extends FrameLayout {
return menu; return menu;
} }
menu = new ActionBarMenu(getContext(), this); menu = new ActionBarMenu(getContext(), this);
addView(menu); addView(menu, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT));
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams();
layoutParams.height = LayoutHelper.MATCH_PARENT;
layoutParams.width = LayoutHelper.WRAP_CONTENT;
layoutParams.gravity = Gravity.RIGHT;
menu.setLayoutParams(layoutParams);
return menu; return menu;
} }
@ -201,8 +214,8 @@ public class ActionBar extends FrameLayout {
return actionMode; return actionMode;
} }
actionMode = new ActionBarMenu(getContext(), this); actionMode = new ActionBarMenu(getContext(), this);
actionMode.setBackgroundResource(R.drawable.editheader); actionMode.setBackgroundColor(0xffffffff);
addView(actionMode); addView(actionMode, indexOfChild(backButtonImageView));
actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0); actionMode.setPadding(0, occupyStatusBar ? AndroidUtilities.statusBarHeight : 0, 0, 0);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)actionMode.getLayoutParams();
layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT;
@ -227,34 +240,95 @@ public class ActionBar extends FrameLayout {
} }
public void showActionMode() { public void showActionMode() {
if (actionMode == null) { if (actionMode == null || actionModeVisible) {
return; return;
} }
actionModeVisible = true;
if (Build.VERSION.SDK_INT >= 14) {
ArrayList<Object> 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); actionMode.setVisibility(VISIBLE);
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null) {
actionModeTop.setVisibility(VISIBLE); actionModeTop.setVisibility(VISIBLE);
} }
}
@Override
public void onAnimationEnd(Object animation) {
if (titleTextView != null) { if (titleTextView != null) {
titleTextView.setVisibility(INVISIBLE); titleTextView.setVisibility(INVISIBLE);
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(INVISIBLE); subTitleTextView.setVisibility(INVISIBLE);
} }
if (backButtonImageView != null) {
backButtonImageView.setVisibility(INVISIBLE);
}
if (menu != null) { if (menu != null) {
menu.setVisibility(INVISIBLE); 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() { public void hideActionMode() {
if (actionMode == null) { if (actionMode == null || !actionModeVisible) {
return; return;
} }
actionMode.setVisibility(INVISIBLE); actionModeVisible = false;
if (occupyStatusBar && actionModeTop != null) { if (Build.VERSION.SDK_INT >= 14) {
actionModeTop.setVisibility(INVISIBLE); ArrayList<Object> 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) { if (titleTextView != null) {
titleTextView.setVisibility(VISIBLE); titleTextView.setVisibility(VISIBLE);
@ -262,12 +336,16 @@ public class ActionBar extends FrameLayout {
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(VISIBLE); subTitleTextView.setVisibility(VISIBLE);
} }
if (backButtonImageView != null) {
backButtonImageView.setVisibility(VISIBLE);
}
if (menu != null) { if (menu != null) {
menu.setVisibility(VISIBLE); 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() { public void showActionModeTop() {
@ -284,7 +362,7 @@ public class ActionBar extends FrameLayout {
} }
public boolean isActionModeShowed() { public boolean isActionModeShowed() {
return actionMode != null && actionMode.getVisibility() == VISIBLE; return actionMode != null && actionModeVisible;
} }
protected void onSearchFieldVisibilityChanged(boolean visible) { protected void onSearchFieldVisibilityChanged(boolean visible) {
@ -297,7 +375,7 @@ public class ActionBar extends FrameLayout {
} }
Drawable drawable = backButtonImageView.getDrawable(); Drawable drawable = backButtonImageView.getDrawable();
if (drawable != null && drawable instanceof MenuDrawable) { 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 actionBarHeight = getCurrentActionBarHeight();
int actionBarHeightSpec = MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.EXACTLY); int actionBarHeightSpec = MeasureSpec.makeMeasureSpec(actionBarHeight, MeasureSpec.EXACTLY);
setMeasuredDimension(width, actionBarHeight + extraHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0)); setMeasuredDimension(width, actionBarHeight + (occupyStatusBar ? AndroidUtilities.statusBarHeight : 0));
int textLeft; int textLeft;
if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) { if (backButtonImageView != null && backButtonImageView.getVisibility() != GONE) {
@ -483,17 +561,6 @@ public class ActionBar extends FrameLayout {
return isSearchFieldVisible; return isSearchFieldVisible;
} }
public void setExtraHeight(int value, boolean layout) {
extraHeight = value;
if (layout) {
requestLayout();
}
}
public int getExtraHeight() {
return extraHeight;
}
public void setOccupyStatusBar(boolean value) { public void setOccupyStatusBar(boolean value) {
occupyStatusBar = value; occupyStatusBar = value;
if (actionMode != null) { if (actionMode != null) {
@ -510,7 +577,7 @@ public class ActionBar extends FrameLayout {
if (backButtonImageView != null) { if (backButtonImageView != null) {
backButtonImageView.setBackgroundResource(itemsBackgroundResourceId); backButtonImageView.setBackgroundResource(itemsBackgroundResourceId);
} }
setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); //Plus setBackgroundColor(AndroidUtilities.getIntColor("themeColor")); //Plus
} }
public void setCastShadows(boolean value) { public void setCastShadows(boolean value) {
@ -536,4 +603,9 @@ public class ActionBar extends FrameLayout {
return AndroidUtilities.dp(56); return AndroidUtilities.dp(56);
} }
} }
@Override
public boolean hasOverlappingRendering() {
return false;
}
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;
@ -59,7 +59,6 @@ public class ActionBarLayout extends FrameLayout {
if (child instanceof ActionBar) { if (child instanceof ActionBar) {
return super.drawChild(canvas, child, drawingTime); return super.drawChild(canvas, child, drawingTime);
} else { } else {
//boolean wasActionBar = false;
int actionBarHeight = 0; int actionBarHeight = 0;
int childCount = getChildCount(); int childCount = getChildCount();
for (int a = 0; a < childCount; a++) { for (int a = 0; a < childCount; a++) {
@ -70,24 +69,10 @@ public class ActionBarLayout extends FrameLayout {
if (view instanceof ActionBar && view.getVisibility() == VISIBLE) { if (view instanceof ActionBar && view.getVisibility() == VISIBLE) {
if (((ActionBar) view).getCastShadows()) { if (((ActionBar) view).getCastShadows()) {
actionBarHeight = view.getMeasuredHeight(); actionBarHeight = view.getMeasuredHeight();
//wasActionBar = true;
} }
break; 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); boolean result = super.drawChild(canvas, child, drawingTime);
if (actionBarHeight != 0 && headerShadowDrawable != null) { if (actionBarHeight != 0 && headerShadowDrawable != null) {
headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight()); headerShadowDrawable.setBounds(0, actionBarHeight, getMeasuredWidth(), actionBarHeight + headerShadowDrawable.getIntrinsicHeight());
@ -96,6 +81,11 @@ public class ActionBarLayout extends FrameLayout {
return result; return result;
} }
} }
@Override
public boolean hasOverlappingRendering() {
return false;
}
} }
private static Drawable headerShadowDrawable; private static Drawable headerShadowDrawable;
@ -129,6 +119,7 @@ public class ActionBarLayout extends FrameLayout {
private boolean useAlphaAnimations; private boolean useAlphaAnimations;
private View backgroundView; private View backgroundView;
private boolean removeActionBarExtraHeight; private boolean removeActionBarExtraHeight;
private Runnable animationRunnable;
private float animationProgress = 0.0f; private float animationProgress = 0.0f;
private long lastFrameTime; private long lastFrameTime;
@ -257,7 +248,7 @@ public class ActionBarLayout extends FrameLayout {
} }
final int restoreCount = canvas.save(); final int restoreCount = canvas.save();
if (!transitionAnimationInProgress) { if (!transitionAnimationInProgress && clipLeft != 0 && clipRight != 0) {
canvas.clipRect(clipLeft, 0, clipRight, getHeight()); canvas.clipRect(clipLeft, 0, clipRight, getHeight());
} }
final boolean result = super.drawChild(canvas, child, drawingTime); final boolean result = super.drawChild(canvas, child, drawingTime);
@ -312,7 +303,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(lastFragment.fragmentView); parent.removeView(lastFragment.fragmentView);
} }
} }
if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) {
ViewGroup parent = (ViewGroup) lastFragment.actionBar.getParent(); ViewGroup parent = (ViewGroup) lastFragment.actionBar.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(lastFragment.actionBar); parent.removeView(lastFragment.actionBar);
@ -320,7 +311,6 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.GONE);
//AndroidUtilities.unlockOrientation(parentActivity);
startedTracking = false; startedTracking = false;
animationInProgress = false; animationInProgress = false;
@ -350,7 +340,7 @@ public class ActionBarLayout extends FrameLayout {
if (parent != null) { if (parent != null) {
parent.removeView(fragmentView); parent.removeView(fragmentView);
} }
if (lastFragment.needAddActionBar() && lastFragment.actionBar != null) { if (lastFragment.actionBar != null && lastFragment.actionBar.getAddToContainer()) {
parent = (ViewGroup) lastFragment.actionBar.getParent(); parent = (ViewGroup) lastFragment.actionBar.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(lastFragment.actionBar); parent.removeView(lastFragment.actionBar);
@ -370,8 +360,6 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
lastFragment.onResume(); lastFragment.onResume();
//AndroidUtilities.lockOrientation(parentActivity);
} }
public boolean onTouchEvent(MotionEvent ev) { public boolean onTouchEvent(MotionEvent ev) {
@ -516,6 +504,10 @@ public class ActionBarLayout extends FrameLayout {
} }
currentAnimation = null; currentAnimation = null;
} }
if (animationRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(animationRunnable);
animationRunnable = null;
}
ViewProxy.setAlpha(this, 1.0f); ViewProxy.setAlpha(this, 1.0f);
ViewProxy.setAlpha(containerView, 1.0f); ViewProxy.setAlpha(containerView, 1.0f);
ViewProxy.setScaleX(containerView, 1.0f); ViewProxy.setScaleX(containerView, 1.0f);
@ -548,7 +540,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragment.fragmentView); parent.removeView(fragment.fragmentView);
} }
} }
if (fragment.needAddActionBar() && fragment.actionBar != null) { if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) {
ViewGroup parent = (ViewGroup) fragment.actionBar.getParent(); ViewGroup parent = (ViewGroup) fragment.actionBar.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(fragment.actionBar); parent.removeView(fragment.actionBar);
@ -570,17 +562,18 @@ public class ActionBarLayout extends FrameLayout {
if (first) { if (first) {
animationProgress = 0.0f; animationProgress = 0.0f;
lastFrameTime = System.nanoTime() / 1000000; lastFrameTime = System.nanoTime() / 1000000;
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT > 15) {
if (open) { containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
containerView.setLayerType(LAYER_TYPE_HARDWARE, null); containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null);
} else {
containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null);
}
} }
} }
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(animationRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
if (animationRunnable != this) {
return;
}
animationRunnable = null;
if (first) { if (first) {
transitionAnimationStartTime = System.currentTimeMillis(); transitionAnimationStartTime = System.currentTimeMillis();
} }
@ -632,7 +625,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView); parent.removeView(fragmentView);
} }
} }
if (fragment.needAddActionBar() && fragment.actionBar != null) { if (fragment.actionBar != null && fragment.actionBar.getAddToContainer()) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false); fragment.actionBar.setOccupyStatusBar(false);
} }
@ -663,7 +656,6 @@ public class ActionBarLayout extends FrameLayout {
setInnerTranslationX(0); setInnerTranslationX(0);
bringChildToFront(containerView); bringChildToFront(containerView);
if (!needAnimation) { if (!needAnimation) {
presentFragmentInternalRemoveOld(removeLast, currentFragment); presentFragmentInternalRemoveOld(removeLast, currentFragment);
if (backgroundView != null) { if (backgroundView != null) {
@ -680,7 +672,7 @@ public class ActionBarLayout extends FrameLayout {
onOpenAnimationEndRunnable = new Runnable() { onOpenAnimationEndRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
fragment.onOpenAnimationEnd(); fragment.onTransitionAnimationEnd(true, false);
fragment.onBecomeFullyVisible(); fragment.onBecomeFullyVisible();
} }
}; };
@ -691,7 +683,7 @@ public class ActionBarLayout extends FrameLayout {
animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f)); animators.add(ObjectAnimatorProxy.ofFloat(backgroundView, "alpha", 0.0f, 1.0f));
} }
fragment.onOpenAnimationStart(); fragment.onTransitionAnimationStart(true, false);
currentAnimation = new AnimatorSetProxy(); currentAnimation = new AnimatorSetProxy();
currentAnimation.playTogether(animators); currentAnimation.playTogether(animators);
currentAnimation.setInterpolator(accelerateDecelerateInterpolator); currentAnimation.setInterpolator(accelerateDecelerateInterpolator);
@ -714,50 +706,44 @@ public class ActionBarLayout extends FrameLayout {
onOpenAnimationEndRunnable = new Runnable() { onOpenAnimationEndRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
if (Build.VERSION.SDK_INT >= 18) { if (Build.VERSION.SDK_INT > 15) {
containerView.setLayerType(LAYER_TYPE_NONE, null); containerView.setLayerType(LAYER_TYPE_NONE, null);
containerViewBack.setLayerType(LAYER_TYPE_NONE, null);
} }
presentFragmentInternalRemoveOld(removeLast, currentFragment); presentFragmentInternalRemoveOld(removeLast, currentFragment);
fragment.onOpenAnimationEnd(); fragment.onTransitionAnimationEnd(true, false);
fragment.onBecomeFullyVisible(); fragment.onBecomeFullyVisible();
ViewProxy.setTranslationX(containerView, 0); ViewProxy.setTranslationX(containerView, 0);
} }
}; };
ViewProxy.setAlpha(containerView, 0.0f); fragment.onTransitionAnimationStart(true, false);
ViewProxy.setTranslationX(containerView, 48.0f); AnimatorSetProxy animation = fragment.onCustomTransitionAnimation(true, new Runnable() {
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() {
@Override @Override
public void onAnimationStart(Object animation) { public void run() {
transitionAnimationStartTime = System.currentTimeMillis();
}
@Override
public void onAnimationEnd(Object animation) {
onAnimationEndCheck(false);
}
@Override
public void onAnimationCancel(Object animation) {
onAnimationEndCheck(false); 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 { } else {
if (backgroundView != null) { if (backgroundView != null) {
ViewProxy.setAlpha(backgroundView, 1.0f); ViewProxy.setAlpha(backgroundView, 1.0f);
backgroundView.setVisibility(VISIBLE); backgroundView.setVisibility(VISIBLE);
} }
fragment.onOpenAnimationStart(); fragment.onTransitionAnimationStart(true, false);
fragment.onOpenAnimationEnd(); fragment.onTransitionAnimationEnd(true, false);
fragment.onBecomeFullyVisible(); fragment.onBecomeFullyVisible();
} }
return true; return true;
@ -836,7 +822,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView); parent.removeView(fragmentView);
} }
} }
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
} }
@ -852,7 +838,8 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.MATCH_PARENT;
layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT;
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
previousFragment.onOpenAnimationStart(); previousFragment.onTransitionAnimationStart(true, true);
currentFragment.onTransitionAnimationStart(false, false);
previousFragment.onResume(); previousFragment.onResume();
currentActionBar = previousFragment.actionBar; currentActionBar = previousFragment.actionBar;
if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) { if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
@ -870,42 +857,35 @@ public class ActionBarLayout extends FrameLayout {
onCloseAnimationEndRunnable = new Runnable() { onCloseAnimationEndRunnable = new Runnable() {
@Override @Override
public void run() { 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); containerViewBack.setLayerType(LAYER_TYPE_NONE, null);
} }
closeLastFragmentInternalRemoveOld(currentFragment); closeLastFragmentInternalRemoveOld(currentFragment);
ViewProxy.setTranslationX(containerViewBack, 0); ViewProxy.setTranslationX(containerViewBack, 0);
previousFragmentFinal.onOpenAnimationEnd(); currentFragment.onTransitionAnimationEnd(false, false);
previousFragmentFinal.onTransitionAnimationEnd(true, true);
previousFragmentFinal.onBecomeFullyVisible(); previousFragmentFinal.onBecomeFullyVisible();
} }
}; };
startLayoutAnimation(false, true); AnimatorSetProxy animation = currentFragment.onCustomTransitionAnimation(false, new Runnable() {
/*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() {
@Override @Override
public void onAnimationStart(Object animation) { public void run() {
transitionAnimationStartTime = System.currentTimeMillis();
}
@Override
public void onAnimationEnd(Object animation) {
onAnimationEndCheck(false);
}
@Override
public void onAnimationCancel(Object animation) {
onAnimationEndCheck(false); 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 { } else {
previousFragment.onOpenAnimationEnd(); currentFragment.onTransitionAnimationEnd(false, false);
previousFragment.onTransitionAnimationEnd(true, true);
previousFragment.onBecomeFullyVisible(); previousFragment.onBecomeFullyVisible();
} }
} else { } else {
@ -968,6 +948,22 @@ public class ActionBarLayout extends FrameLayout {
if (fragmentsStack.isEmpty()) { if (fragmentsStack.isEmpty()) {
return; 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); BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
previousFragment.setParentLayout(this); previousFragment.setParentLayout(this);
View fragmentView = previousFragment.fragmentView; View fragmentView = previousFragment.fragmentView;
@ -979,7 +975,7 @@ public class ActionBarLayout extends FrameLayout {
parent.removeView(fragmentView); parent.removeView(fragmentView);
} }
} }
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) { if (previousFragment.actionBar != null && previousFragment.actionBar.getAddToContainer()) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
} }
@ -1136,4 +1132,9 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
} }
@Override
public boolean hasOverlappingRendering() {
return false;
}
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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/ //Thanks to https://github.com/JakeWharton/ActionBarSherlock/

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;
@ -21,6 +21,7 @@ import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.AnimationCompat.AnimatorSetProxy;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
@ -49,6 +50,14 @@ public class BaseFragment {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
} }
public ActionBar getActionBar() {
return actionBar;
}
public View getFragmentView() {
return fragmentView;
}
public View createView(Context context) { public View createView(Context context) {
return null; return null;
} }
@ -164,7 +173,7 @@ public class BaseFragment {
actionBar.onPause(); actionBar.onPause();
} }
try { try {
if (visibleDialog != null && visibleDialog.isShowing()) { if (visibleDialog != null && visibleDialog.isShowing() && dismissDialogOnPause(visibleDialog)) {
visibleDialog.dismiss(); visibleDialog.dismiss();
visibleDialog = null; visibleDialog = null;
} }
@ -185,6 +194,10 @@ public class BaseFragment {
} }
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
}
public void saveSelfArgs(Bundle args) { public void saveSelfArgs(Bundle args) {
} }
@ -218,6 +231,10 @@ public class BaseFragment {
} }
} }
public boolean dismissDialogOnPause(Dialog dialog) {
return true;
}
public void onBeginSlide() { public void onBeginSlide() {
try { try {
if (visibleDialog != null && visibleDialog.isShowing()) { 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() { public void onLowMemory() {
return true;
} }
public Dialog showDialog(Dialog dialog) { public Dialog showDialog(Dialog dialog) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -72,12 +73,14 @@ public class DrawerLayoutContainer extends FrameLayout {
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
setFitsSystemWindows(true); 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); shadowLeft = getResources().getDrawable(R.drawable.menu_shadow);
} }
@SuppressLint("NewApi")
private class InsetsListener implements View.OnApplyWindowInsetsListener { private class InsetsListener implements View.OnApplyWindowInsetsListener {
@Override @Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
@ -87,13 +90,7 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
} }
private void configureApplyInsets(View drawerLayout) { @SuppressLint("NewApi")
if (Build.VERSION.SDK_INT >= 21) {
drawerLayout.setOnApplyWindowInsetsListener(new InsetsListener());
drawerLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
private void dispatchChildInsets(View child, Object insets, int drawerGravity) { private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
WindowInsets wi = (WindowInsets) insets; WindowInsets wi = (WindowInsets) insets;
if (drawerGravity == Gravity.LEFT) { if (drawerGravity == Gravity.LEFT) {
@ -104,6 +101,7 @@ public class DrawerLayoutContainer extends FrameLayout {
child.dispatchApplyWindowInsets(wi); child.dispatchApplyWindowInsets(wi);
} }
@SuppressLint("NewApi")
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) { private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
WindowInsets wi = (WindowInsets) insets; WindowInsets wi = (WindowInsets) insets;
if (drawerGravity == Gravity.LEFT) { if (drawerGravity == Gravity.LEFT) {
@ -416,6 +414,7 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
} }
@SuppressLint("NewApi")
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec);
@ -438,7 +437,7 @@ public class DrawerLayoutContainer extends FrameLayout {
if (applyInsets) { if (applyInsets) {
if (child.getFitsSystemWindows()) { if (child.getFitsSystemWindows()) {
dispatchChildInsets(child, lastInsets, lp.gravity); dispatchChildInsets(child, lastInsets, lp.gravity);
} else { } else if (child.getTag() == null) {
applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21); applyMarginInsets(lp, lastInsets, lp.gravity, Build.VERSION.SDK_INT >= 21);
} }
} }
@ -495,6 +494,7 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
final int height = getHeight(); final int height = getHeight();
final boolean drawingContent = child != drawerLayout; final boolean drawingContent = child != drawerLayout;
int lastVisibleChild = 0;
int clipLeft = 0, clipRight = getWidth(); int clipLeft = 0, clipRight = getWidth();
final int restoreCount = canvas.save(); final int restoreCount = canvas.save();
@ -502,6 +502,9 @@ public class DrawerLayoutContainer extends FrameLayout {
final int childCount = getChildCount(); final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) { for (int i = 0; i < childCount; i++) {
final View v = getChildAt(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) { if (v == child || v.getVisibility() != VISIBLE || v != drawerLayout || v.getHeight() < height) {
continue; continue;
} }
@ -511,14 +514,18 @@ public class DrawerLayoutContainer extends FrameLayout {
clipLeft = vright; clipLeft = vright;
} }
} }
if (clipLeft != 0) {
canvas.clipRect(clipLeft, 0, clipRight, getHeight()); canvas.clipRect(clipLeft, 0, clipRight, getHeight());
} }
}
final boolean result = super.drawChild(canvas, child, drawingTime); final boolean result = super.drawChild(canvas, child, drawingTime);
canvas.restoreToCount(restoreCount); canvas.restoreToCount(restoreCount);
if (scrimOpacity > 0 && drawingContent) { if (scrimOpacity > 0 && drawingContent) {
if (indexOfChild(child) == lastVisibleChild) {
scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24); scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24);
canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint); canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
}
} else if (shadowLeft != null) { } else if (shadowLeft != null) {
final float alpha = Math.max(0, Math.min(drawerPosition / AndroidUtilities.dp(20), 1.0f)); final float alpha = Math.max(0, Math.min(drawerPosition / AndroidUtilities.dp(20), 1.0f));
if (alpha != 0) { if (alpha != 0) {
@ -529,4 +536,9 @@ public class DrawerLayoutContainer extends FrameLayout {
} }
return result; return result;
} }
@Override
public boolean hasOverlappingRendering() {
return false;
}
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.ActionBar;
@ -11,6 +11,7 @@ package org.telegram.ui.ActionBar;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.animation.DecelerateInterpolator; import android.view.animation.DecelerateInterpolator;
@ -80,11 +81,11 @@ public class MenuDrawable extends Drawable {
canvas.save(); canvas.save();
canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2); canvas.translate(getIntrinsicWidth() / 2, getIntrinsicHeight() / 2);
canvas.rotate(currentRotation * (reverseAngle ? -180 : 180)); 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 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 endXDiff = AndroidUtilities.dp(9) - AndroidUtilities.dp(2.5f) * Math.abs(currentRotation);
float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(3.5f) * Math.abs(currentRotation); float startYDiff = AndroidUtilities.dp(5) + AndroidUtilities.dp(2.0f) * Math.abs(currentRotation);
float startXDiff = -AndroidUtilities.dp(9) + AndroidUtilities.dp(8.5f) * 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.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint); canvas.drawLine(startXDiff, startYDiff, endXDiff, endYDiff, paint);
canvas.restore(); canvas.restore();
@ -103,7 +104,7 @@ public class MenuDrawable extends Drawable {
@Override @Override
public int getOpacity() { public int getOpacity() {
return 0; return PixelFormat.TRANSPARENT;
} }
@Override @Override

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;
@ -18,15 +18,13 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.AnimationCompat.ViewProxy;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.ContactsController; import org.telegram.messenger.ContactsController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.DividerCell;
import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.LetterSectionCell; import org.telegram.ui.Cells.LetterSectionCell;
@ -298,12 +296,6 @@ public class ContactsAdapter extends BaseSectionsAdapter {
ViewProxy.setAlpha(convertView, 1.0f); 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 //parent.setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff)); //Plus
updateListBG(parent); updateListBG(parent);

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;
@ -180,7 +180,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
} }
public boolean isRecentSearchDisplayed() { public boolean isRecentSearchDisplayed() {
return (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty(); return needMessagesSearch != 2 && (lastSearchText == null || lastSearchText.length() == 0) && !recentSearchObjects.isEmpty();
} }
public void loadRecentSearch() { public void loadRecentSearch() {
@ -778,7 +778,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
@Override @Override
public int getItemCount() { 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; return recentSearchObjects.size() + 1;
} }
if (!searchResultHashtags.isEmpty()) { if (!searchResultHashtags.isEmpty()) {
@ -797,7 +797,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
} }
public Object getItem(int i) { 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()) { if (i > 0 && i - 1 < recentSearchObjects.size()) {
return recentSearchObjects.get(i - 1).object; return recentSearchObjects.get(i - 1).object;
} else { } else {
@ -868,7 +868,6 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
boolean isRecent = false; boolean isRecent = false;
String un = null; String un = null;
String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
Object obj = getItem(position); Object obj = getItem(position);
if (obj instanceof TLRPC.User) { if (obj instanceof TLRPC.User) {
@ -885,7 +884,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
user = MessagesController.getInstance().getUser(encryptedChat.user_id); 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; isRecent = true;
cell.useSeparator = position != getItemCount() - 1; cell.useSeparator = position != getItemCount() - 1;
} else { } else {
@ -922,7 +921,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
GreySectionCell cell = (GreySectionCell) holder.itemView; GreySectionCell cell = (GreySectionCell) holder.itemView;
cell.setBackgroundColor(themePrefs.getInt("chatsRowColor", 0xfff2f2f2)); cell.setBackgroundColor(themePrefs.getInt("chatsRowColor", 0xfff2f2f2));
cell.setTextColor(themePrefs.getInt("chatsNameColor", 0xff8a8a8a)); 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()); cell.setText(LocaleController.getString("Recent", R.string.Recent).toUpperCase());
} else if (!searchResultHashtags.isEmpty()) { } else if (!searchResultHashtags.isEmpty()) {
cell.setText(LocaleController.getString("Hashtags", R.string.Hashtags).toUpperCase()); cell.setText(LocaleController.getString("Hashtags", R.string.Hashtags).toUpperCase());
@ -957,7 +956,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
@Override @Override
public int getItemViewType(int i) { 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; return i == 0 ? 1 : 0;
} }
if (!searchResultHashtags.isEmpty()) { if (!searchResultHashtags.isEmpty()) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;

View File

@ -3,12 +3,13 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Adapters;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -87,8 +88,18 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
} }
public void loadStikersForEmoji(CharSequence emoji) { 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) { 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(); lastSticker = emoji.toString();
HashMap<String, ArrayList<TLRPC.Document>> allStickers = StickersQuery.getAllStickers(); HashMap<String, ArrayList<TLRPC.Document>> allStickers = StickersQuery.getAllStickers();
if (allStickers != null) { if (allStickers != null) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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.content.Context;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; 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)); 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 @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 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) { public void setTextColor(int color) {

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -33,11 +33,11 @@ public class BaseCell extends View {
public void run() { public void run() {
if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) { if (checkingForLongPress && getParent() != null && currentPressCount == pressCount) {
checkingForLongPress = false; checkingForLongPress = false;
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
onLongPress();
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0); MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
onTouchEvent(event); onTouchEvent(event);
event.recycle(); event.recycle();
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
onLongPress();
} }
} }
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -19,14 +19,14 @@ import android.view.MotionEvent;
import android.view.SoundEffectConstants; import android.view.SoundEffectConstants;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ImageLoader; import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLoader;
import org.telegram.messenger.MediaController; import org.telegram.messenger.MediaController;
import org.telegram.messenger.MessageObject; 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.RadialProgress;
import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.ResourceLoader;
import org.telegram.ui.Components.SeekBar; import org.telegram.ui.Components.SeekBar;
@ -149,6 +149,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate(); invalidate();
} }
} else if (buttonState == 2) { } else if (buttonState == 2) {
radialProgress.setProgress(0, false);
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true);
buttonState = 3; buttonState = 3;
radialProgress.setBackground(getDrawableForCurrentState(), true, false); radialProgress.setBackground(getDrawableForCurrentState(), true, false);
@ -223,7 +224,8 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if (cacheFile == null) { if (cacheFile == null) {
cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner); cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
} }
if (BuildVars.DEBUG_VERSION) { //if (BuildVars.DEBUG_VERSION) {
if (BuildConfig.DEBUG) {
FileLog.d("tmessages", "looking for audio in " + cacheFile); FileLog.d("tmessages", "looking for audio in " + cacheFile);
} }
if (cacheFile.exists()) { 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); 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); timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(66) - (((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) ? AndroidUtilities.dp(leftBound) : 0);
} else { } else {
//if (isChat && currentMessageObject.messageOwner.from_id > 0) {
if ((isChat || showAvatar) && currentMessageObject.messageOwner.from_id > 0) { if ((isChat || showAvatar) && currentMessageObject.messageOwner.from_id > 0) {
//seekBarX = AndroidUtilities.dp(116); //seekBarX = AndroidUtilities.dp(116);
//buttonX = AndroidUtilities.dp(74); //buttonX = AndroidUtilities.dp(74);
@ -336,7 +339,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
boolean dataChanged = currentMessageObject == messageObject && isUserDataChanged(); boolean dataChanged = currentMessageObject == messageObject && isUserDataChanged();
if (currentMessageObject != messageObject || dataChanged) { if (currentMessageObject != messageObject || dataChanged) {
if (AndroidUtilities.isTablet()) { 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)); 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 { } else {
//backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.messageOwner.from_id > 0 ? 102 : 50), AndroidUtilities.dp(300)); //backgroundWidth = Math.min(AndroidUtilities.displaySize.x - AndroidUtilities.dp(isChat && messageObject.messageOwner.from_id > 0 ? 102 : 50), AndroidUtilities.dp(300));

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -50,7 +50,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
void didPressedCancelSendButton(ChatBaseCell cell); void didPressedCancelSendButton(ChatBaseCell cell);
void didLongPressed(ChatBaseCell cell); void didLongPressed(ChatBaseCell cell);
void didPressReplyMessage(ChatBaseCell cell, int id); 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 needOpenWebView(String url, String title, String originalUrl, int w, int h);
void didClickedImage(ChatBaseCell cell); void didClickedImage(ChatBaseCell cell);
boolean canPerformActions(); boolean canPerformActions();
@ -71,6 +71,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
private boolean wasLayout = false; private boolean wasLayout = false;
protected boolean isAvatarVisible = false; protected boolean isAvatarVisible = false;
protected boolean drawBackground = true; protected boolean drawBackground = true;
protected boolean allowAssistant = false;
protected MessageObject currentMessageObject; protected MessageObject currentMessageObject;
private static TextPaint timePaintIn; private static TextPaint timePaintIn;
@ -119,11 +120,16 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
private StaticLayout timeLayout; private StaticLayout timeLayout;
protected int timeWidth; protected int timeWidth;
private int timeTextWidth;
private int timeX; private int timeX;
private TextPaint currentTimePaint; private TextPaint currentTimePaint;
private String currentTimeString; private String currentTimeString;
protected boolean drawTime = true; protected boolean drawTime = true;
private StaticLayout viewsLayout;
private int viewsTextWidth;
private String currentViewsString;
private TLRPC.User currentUser; private TLRPC.User currentUser;
private TLRPC.Chat currentChat; private TLRPC.Chat currentChat;
private TLRPC.FileLocation currentPhoto; private TLRPC.FileLocation currentPhoto;
@ -301,6 +307,10 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
invalidate(); invalidate();
} }
public void setAllowAssistant(boolean value) {
allowAssistant = value;
}
protected boolean isUserDataChanged() { protected boolean isUserDataChanged() {
if (currentMessageObject == null || currentUser == null && currentChat == null) { if (currentMessageObject == null || currentUser == null && currentChat == null) {
return false; return false;
@ -371,27 +381,11 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
} }
protected void measureTime(MessageObject messageObject) { protected void measureTime(MessageObject messageObject) {
if (!media) { currentTimeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
if (messageObject.isOutOwner()) { timeTextWidth = timeWidth = (int) Math.ceil(timeMediaPaint.measureText(currentTimeString));
currentTimePaint = timePaintOut;
} else {
currentTimePaint = timePaintIn;
}
} else {
currentTimePaint = timeMediaPaint;
}
String timeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
currentTimeString = String.format("%s ", LocaleController.formatShortNumber(messageObject.messageOwner.views, null)) + timeString; currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null));
} else { timeWidth += (int) Math.ceil(timeMediaPaint.measureText(currentViewsString)) + ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10);
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;
} }
} }
@ -462,18 +456,12 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
currentTimePaint = timeMediaPaint; currentTimePaint = timeMediaPaint;
} }
String timeString = LocaleController.formatterDay.format((long) (currentMessageObject.messageOwner.date) * 1000); currentTimeString = LocaleController.formatterDay.format((long) (messageObject.messageOwner.date) * 1000);
if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { timeTextWidth = timeWidth = (int)Math.ceil(currentTimePaint.measureText(currentTimeString));
currentTimeString = String.format("%s ", LocaleController.formatShortNumber(currentMessageObject.messageOwner.views, null)) + timeString; if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) {
} else { currentViewsString = String.format("%s", LocaleController.formatShortNumber(Math.max(1, messageObject.messageOwner.views), null));
currentTimeString = timeString; viewsTextWidth = (int) Math.ceil(currentTimePaint.measureText(currentViewsString));
} timeWidth += viewsTextWidth + ResourceLoader.viewsCountDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10);
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;
} }
namesOffset = 0; namesOffset = 0;
@ -493,8 +481,6 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
} }
nameWidth = getMaxNameWidth(); nameWidth = getMaxNameWidth();
CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END); CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); nameLayout = new StaticLayout(nameStringFinal, namePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (nameLayout.getLineCount() > 0) { if (nameLayout.getLineCount() > 0) {
@ -764,7 +750,7 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
layoutWidth = getMeasuredWidth(); layoutWidth = getMeasuredWidth();
layoutHeight = getMeasuredHeight(); 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 (!media) {
if (!currentMessageObject.isOutOwner()) { if (!currentMessageObject.isOutOwner()) {
//timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat && currentMessageObject.messageOwner.from_id > 0 ? AndroidUtilities.dp(52) : 0); //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) { if (isAvatarVisible) {
//avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42)); //avatarImage.setImageCoords(AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42));
if(((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && currentMessageObject.isOutOwner()){ if(((showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && currentMessageObject.isOutOwner()){
@ -1036,6 +1028,13 @@ public class ChatBaseCell extends BaseCell implements MediaController.FileDownlo
} else { } else {
setDrawableBounds(ResourceLoader.viewsMediaCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(10) - timeLayout.getHeight()); setDrawableBounds(ResourceLoader.viewsMediaCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(10) - timeLayout.getHeight());
ResourceLoader.viewsMediaCountDrawable.draw(canvas); 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()); setDrawableBounds(ResourceLoader.viewsOutCountDrawable, timeX, layoutHeight - AndroidUtilities.dp(4.5f) - timeLayout.getHeight());
ResourceLoader.viewsOutCountDrawable.draw(canvas); 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();
}
} }
} }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -28,8 +28,8 @@ import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.tgnet.TLRPC; import org.telegram.tgnet.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
public class ChatContactCell extends ChatBaseCell { public class ChatContactCell extends ChatBaseCell {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; 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.RadialProgress;
import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.ResourceLoader;
import org.telegram.ui.Components.StaticLayoutEx; import org.telegram.ui.Components.StaticLayoutEx;
import org.telegram.ui.Components.URLSpanBotCommand;
import org.telegram.ui.PhotoViewer; import org.telegram.ui.PhotoViewer;
import java.io.File; import java.io.File;
@ -100,6 +101,7 @@ public class ChatMediaCell extends ChatBaseCell {
// //
private StaticLayout nameLayout; private StaticLayout nameLayout;
private int nameWidth = 0; private int nameWidth = 0;
private int nameOffsetX = 0;
private String currentNameString; private String currentNameString;
private ChatMediaCellDelegate mediaDelegate = null; private ChatMediaCellDelegate mediaDelegate = null;
@ -196,7 +198,11 @@ public class ChatMediaCell extends ChatBaseCell {
if (left <= x2 && left + nameLayout.getLineWidth(line) >= x2) { if (left <= x2 && left + nameLayout.getLineWidth(line) >= x2) {
Spannable buffer = (Spannable) currentMessageObject.caption; Spannable buffer = (Spannable) currentMessageObject.caption;
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); 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(); resetPressedLink();
pressedLink = link[0]; pressedLink = link[0];
linkPreviewPressed = true; linkPreviewPressed = true;
@ -220,7 +226,7 @@ public class ChatMediaCell extends ChatBaseCell {
} }
} else if (linkPreviewPressed) { } else if (linkPreviewPressed) {
try { try {
delegate.didPressUrl(currentMessageObject, pressedLink); delegate.didPressUrl(currentMessageObject, pressedLink, false);
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
@ -460,7 +466,7 @@ public class ChatMediaCell extends ChatBaseCell {
} }
double lat = object.messageOwner.media.geo.lat; double lat = object.messageOwner.media.geo.lat;
double lon = object.messageOwner.media.geo._long; 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)) { if (!url.equals(currentUrl)) {
return true; return true;
} }
@ -504,6 +510,7 @@ public class ChatMediaCell extends ChatBaseCell {
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet);
if (currentMessageObject != messageObject || isPhotoDataChanged(messageObject) || dataChanged) { 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; media = messageObject.type != 9;
cancelLoading = false; cancelLoading = false;
additionHeight = 0; additionHeight = 0;
@ -518,7 +525,6 @@ public class ChatMediaCell extends ChatBaseCell {
drawBackground = true; drawBackground = true;
photoImage.setForcePreview(messageObject.isSecretPhoto()); photoImage.setForcePreview(messageObject.isSecretPhoto());
if (messageObject.type == 9) { if (messageObject.type == 9) {
String name = messageObject.getDocumentName(); String name = messageObject.getDocumentName();
if (name == null || name.length() == 0) { 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); nameLayout = StaticLayoutEx.createStaticLayout(currentNameString, namePaint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false, TextUtils.TruncateAt.END, maxWidth, 1);
if (nameLayout.getLineCount() > 0) { if (nameLayout.getLineCount() > 0) {
nameWidth = Math.min(maxWidth, (int) Math.ceil(nameLayout.getLineWidth(0))); nameWidth = Math.min(maxWidth, (int) Math.ceil(nameLayout.getLineWidth(0)));
nameOffsetX = (int) Math.ceil(-nameLayout.getLineLeft(0));
} else { } else {
nameWidth = maxWidth; nameWidth = maxWidth;
} }
@ -554,7 +561,7 @@ public class ChatMediaCell extends ChatBaseCell {
} }
ext = ext.toUpperCase(); 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)) { if (currentInfoString == null || !currentInfoString.equals(str)) {
currentInfoString = str; currentInfoString = str;
@ -641,7 +648,7 @@ public class ChatMediaCell extends ChatBaseCell {
currentNameString = null; currentNameString = null;
infoLayout = null; infoLayout = null;
nameLayout = null; nameLayout = null;
updateSecretTimeText(); updateSecretTimeText(messageObject);
infoLayout2 = null; //Plus infoLayout2 = null; //Plus
} }
if (messageObject.type == 9) { //doc if (messageObject.type == 9) { //doc
@ -663,7 +670,7 @@ public class ChatMediaCell extends ChatBaseCell {
double lon = messageObject.messageOwner.media.geo._long; double lon = messageObject.messageOwner.media.geo._long;
if (messageObject.messageOwner.media.title != null && messageObject.messageOwner.media.title.length() > 0) { 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); 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); 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(); int lineCount = nameLayout.getLineCount();
@ -687,12 +694,12 @@ public class ChatMediaCell extends ChatBaseCell {
} }
} }
backgroundWidth = photoWidth + AndroidUtilities.dp(21) + maxWidth; 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 { } else {
photoWidth = AndroidUtilities.dp(200); photoWidth = AndroidUtilities.dp(200);
photoHeight = AndroidUtilities.dp(100); photoHeight = AndroidUtilities.dp(100);
backgroundWidth = photoWidth + AndroidUtilities.dp(12); 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); photoImage.setNeedsQualityThumb(false);
@ -914,11 +921,20 @@ public class ChatMediaCell extends ChatBaseCell {
} }
super.setMessageObject(messageObject); super.setMessageObject(messageObject);
if (drawForwardedName) {
namesOffset += AndroidUtilities.dp(5);
}
invalidate(); invalidate();
} }
updateButtonState(dataChanged); updateButtonState(dataChanged);
} }
@Override
protected int getMaxNameWidth() {
return backgroundWidth - AndroidUtilities.dp(14);
}
@Override @Override
public ImageReceiver getPhotoImage() { public ImageReceiver getPhotoImage() {
return photoImage; 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)); deleteProgressRect.set(buttonX + AndroidUtilities.dp(3), buttonY + AndroidUtilities.dp(3), buttonX + AndroidUtilities.dp(45), buttonY + AndroidUtilities.dp(45));
} }
private void updateSecretTimeText() { private void updateSecretTimeText(MessageObject messageObject) {
if (currentMessageObject == null || currentMessageObject.isOut()) { if (messageObject == null || messageObject.isOut()) {
return; return;
} }
String str = currentMessageObject.getSecretTimeString(); String str = messageObject.getSecretTimeString();
if (str == null) { if (str == null) {
infoLayout = null;
return; return;
} }
if (currentInfoString == null || !currentInfoString.equals(str)) { if (currentInfoString == null || !currentInfoString.equals(str)) {
@ -1166,7 +1183,7 @@ public class ChatMediaCell extends ChatBaseCell {
int offset = AndroidUtilities.dp(2); int offset = AndroidUtilities.dp(2);
invalidate((int) deleteProgressRect.left - offset, (int) deleteProgressRect.top - offset, (int) deleteProgressRect.right + offset * 2, (int) deleteProgressRect.bottom + offset * 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) { if (pressedLink != null) {
canvas.drawPath(urlPath, urlPaint); canvas.drawPath(urlPath, urlPaint);
} }
nameLayout.draw(canvas); try {
nameLayout.draw(canvas);
} catch (Exception e) {
FileLog.e("tmessages", e);
}
canvas.restore(); canvas.restore();
} }
//if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto())) { //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); locationAddressPaint.setColor(currentMessageObject.isOutOwner() ? 0xff70b15c : 0xff999999);
canvas.save(); 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); nameLayout.draw(canvas);
canvas.restore(); canvas.restore();
@ -1260,7 +1281,7 @@ public class ChatMediaCell extends ChatBaseCell {
} }
} else if (nameLayout != null) { } else if (nameLayout != null) {
canvas.save(); 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); nameLayout.draw(canvas);
canvas.restore(); canvas.restore();

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -26,6 +26,7 @@ import android.text.TextUtils;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.SoundEffectConstants; import android.view.SoundEffectConstants;
import android.view.ViewStructure;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; 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.RadialProgress;
import org.telegram.ui.Components.ResourceLoader; import org.telegram.ui.Components.ResourceLoader;
import org.telegram.ui.Components.StaticLayoutEx; import org.telegram.ui.Components.StaticLayoutEx;
import org.telegram.ui.Components.URLSpanBotCommand;
import org.telegram.ui.Components.URLSpanNoUnderline;
import java.io.File; import java.io.File;
import java.util.Locale; import java.util.Locale;
@ -116,7 +119,11 @@ public class ChatMessageCell extends ChatBaseCell {
if (left <= x && left + block.textLayout.getLineWidth(line) >= x) { if (left <= x && left + block.textLayout.getLineWidth(line) >= x) {
Spannable buffer = (Spannable) currentMessageObject.messageText; Spannable buffer = (Spannable) currentMessageObject.messageText;
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); 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) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
resetPressedLink(); resetPressedLink();
pressedLink = link[0]; pressedLink = link[0];
@ -132,7 +139,7 @@ public class ChatMessageCell extends ChatBaseCell {
} else { } else {
if (link[0] == pressedLink) { if (link[0] == pressedLink) {
try { try {
delegate.didPressUrl(currentMessageObject, pressedLink); delegate.didPressUrl(currentMessageObject, pressedLink, false);
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
@ -176,7 +183,11 @@ public class ChatMessageCell extends ChatBaseCell {
if (left <= x && left + descriptionLayout.getLineWidth(line) >= x) { if (left <= x && left + descriptionLayout.getLineWidth(line) >= x) {
Spannable buffer = (Spannable) currentMessageObject.linkDescription; Spannable buffer = (Spannable) currentMessageObject.linkDescription;
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); 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(); resetPressedLink();
pressedLink = link[0]; pressedLink = link[0];
linkPreviewPressed = true; 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 @Override
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet); boolean dataChanged = currentMessageObject == messageObject && (isUserDataChanged() || photoNotSet);
@ -379,23 +402,25 @@ public class ChatMessageCell extends ChatBaseCell {
int maxWidth; int maxWidth;
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
//if (isChat && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0) {
if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0
|| ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) { || ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) {
//maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122); //maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122);
maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(leftBound + 70); maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(leftBound + 70);
drawName = true; drawName = true;
} else { } 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); maxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(80);
} }
} else { } else {
//if (isChat && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0) {
if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0 if ((isChat || showAvatar) && !messageObject.isOutOwner() && messageObject.messageOwner.from_id > 0
|| ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) { || ( (showMyAvatar && !isChat) || (showMyAvatarGroup && isChat)) && messageObject.isOutOwner()) {
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122); maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
drawName = true; drawName = true;
} else { } else {
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80); 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; totalHeight += height;
for (int a = 0; a < descriptionLayout.getLineCount(); a++) { for (int a = 0; a < descriptionLayout.getLineCount(); a++) {
int lineLeft = (int) Math.ceil(descriptionLayout.getLineLeft(a)); int lineLeft = (int) Math.ceil(descriptionLayout.getLineLeft(a));
if (descriptionX == 0) { if (a == 0 && descriptionX == 0) {
descriptionX = -lineLeft; descriptionX = -lineLeft;
} else { } else {
descriptionX = Math.max(descriptionX, -lineLeft); descriptionX = Math.max(descriptionX, -lineLeft);
@ -990,4 +1015,12 @@ public class ChatMessageCell extends ChatBaseCell {
updateButtonState(false); updateButtonState(false);
} }
} }
@Override
public void onProvideStructure(ViewStructure structure) {
super.onProvideStructure(structure);
if (allowAssistant && Build.VERSION.SDK_INT >= 23) {
structure.setText(currentMessageObject.messageText);
}
}
} }

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -23,23 +23,18 @@ import android.view.MotionEvent;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ContactsController; import org.telegram.messenger.ContactsController;
import org.telegram.messenger.Emoji; import org.telegram.messenger.Emoji;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; 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.R;
import org.telegram.messenger.UserConfig; 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 org.telegram.ui.Components.AvatarDrawable;
import java.util.ArrayList; import java.util.ArrayList;
@ -64,9 +59,11 @@ public class DialogCell extends BaseCell {
private static Drawable errorDrawable; private static Drawable errorDrawable;
private static Drawable lockDrawable; private static Drawable lockDrawable;
private static Drawable countDrawable; private static Drawable countDrawable;
private static Drawable countDrawableGrey;
private static Drawable groupDrawable; private static Drawable groupDrawable;
private static Drawable broadcastDrawable; private static Drawable broadcastDrawable;
private static Drawable muteDrawable; private static Drawable muteDrawable;
private static Drawable verifiedDrawable;
private static Paint linePaint; private static Paint linePaint;
private static Paint backPaint; private static Paint backPaint;
@ -126,6 +123,8 @@ public class DialogCell extends BaseCell {
private int countWidth; private int countWidth;
private StaticLayout countLayout; private StaticLayout countLayout;
private boolean drawVerified;
private int avatarTop = AndroidUtilities.dp(10); private int avatarTop = AndroidUtilities.dp(10);
private boolean isSelected; private boolean isSelected;
@ -196,11 +195,11 @@ public class DialogCell extends BaseCell {
clockDrawable = getResources().getDrawable(R.drawable.msg_clock); clockDrawable = getResources().getDrawable(R.drawable.msg_clock);
errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning); errorDrawable = getResources().getDrawable(R.drawable.dialogs_warning);
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
countDrawableGrey = getResources().getDrawable(R.drawable.dialogs_badge2);
groupDrawable = getResources().getDrawable(R.drawable.list_group); groupDrawable = getResources().getDrawable(R.drawable.list_group);
broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast); broadcastDrawable = getResources().getDrawable(R.drawable.list_broadcast);
muteDrawable = getResources().getDrawable(R.drawable.mute_grey); muteDrawable = getResources().getDrawable(R.drawable.mute_grey);
verifiedDrawable = getResources().getDrawable(R.drawable.check_list);
updateTheme();
} }
setBackgroundResource(R.drawable.list_selector); setBackgroundResource(R.drawable.list_selector);
@ -289,6 +288,7 @@ public class DialogCell extends BaseCell {
drawNameGroup = false; drawNameGroup = false;
drawNameBroadcast = false; drawNameBroadcast = false;
drawNameLock = false; drawNameLock = false;
drawVerified = false;
if (encryptedChat != null) { if (encryptedChat != null) {
drawNameLock = true; drawNameLock = true;
@ -309,6 +309,7 @@ public class DialogCell extends BaseCell {
drawNameGroup = true; drawNameGroup = true;
nameLockTop = AndroidUtilities.dp(17.5f); nameLockTop = AndroidUtilities.dp(17.5f);
} }
drawVerified = (chat.flags & TLRPC.CHAT_FLAG_IS_VERIFIED) != 0;
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
@ -390,7 +391,7 @@ public class DialogCell extends BaseCell {
messageString = message.messageText; messageString = message.messageText;
currentMessagePaint = messagePrintingPaint; currentMessagePaint = messagePrintingPaint;
} else { } else {
if (chat != null && chat.id > 0) { if (chat != null && chat.id > 0 && fromChat == null) {
String name; String name;
if (message.isOutOwner()) { if (message.isOutOwner()) {
name = LocaleController.getString("FromYou", R.string.FromYou); 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(); int w = AndroidUtilities.dp(6) + muteDrawable.getIntrinsicWidth();
nameWidth -= w; nameWidth -= w;
if (LocaleController.isRTL) { if (LocaleController.isRTL) {
nameLeft += w; 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); nameWidth = Math.max(AndroidUtilities.dp(12), nameWidth);
@ -647,8 +654,10 @@ public class DialogCell extends BaseCell {
if (nameLayout != null && nameLayout.getLineCount() > 0) { if (nameLayout != null && nameLayout.getLineCount() > 0) {
left = nameLayout.getLineLeft(0); left = nameLayout.getLineLeft(0);
widthpx = Math.ceil(nameLayout.getLineWidth(0)); widthpx = Math.ceil(nameLayout.getLineWidth(0));
if (dialogMuted) { if (dialogMuted && !drawVerified) {
nameMuteLeft = (int) (nameLeft + (nameWidth - widthpx) - AndroidUtilities.dp(6) - muteDrawable.getIntrinsicWidth()); 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 (left == 0) {
if (widthpx < nameWidth) { if (widthpx < nameWidth) {
@ -674,7 +683,7 @@ public class DialogCell extends BaseCell {
nameLeft -= (nameWidth - widthpx); nameLeft -= (nameWidth - widthpx);
} }
} }
if (dialogMuted) { if (dialogMuted || drawVerified) {
nameMuteLeft = (int) (nameLeft + left + AndroidUtilities.dp(6)); 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); clockDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN);
countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", 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)); nColor = themePrefs.getInt("chatsGroupIconColor", themePrefs.getInt("chatsGroupNameColor", 0xff000000));
groupDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN); 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)); setDrawableBounds(muteDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
muteDrawable.draw(canvas); muteDrawable.draw(canvas);
} else if (drawVerified) {
setDrawableBounds(verifiedDrawable, nameMuteLeft, AndroidUtilities.dp(16.5f));
verifiedDrawable.draw(canvas);
} }
if (drawError) { if (drawError) {
setDrawableBounds(errorDrawable, errorLeft, errorTop); setDrawableBounds(errorDrawable, errorLeft, errorTop);
errorDrawable.draw(canvas); errorDrawable.draw(canvas);
} else if (drawCount) { } else if (drawCount) {
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); if (dialogMuted) {
int size = themePrefs.getInt("chatsCountSize", 13); setDrawableBounds(countDrawableGrey, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
size = size > 13 ? (size - 13) / 2 : 0; countDrawableGrey.draw(canvas);
//setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); } else {
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop + AndroidUtilities.dp(size), countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight()); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
countDrawable.draw(canvas); 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.save();
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4)); canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
countLayout.draw(canvas); countLayout.draw(canvas);

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -17,6 +17,7 @@ import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.LayoutHelper;
public class DrawerActionCell extends FrameLayout { public class DrawerActionCell extends FrameLayout {
@ -36,7 +37,6 @@ public class DrawerActionCell extends FrameLayout {
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
textView.setCompoundDrawablePadding(AndroidUtilities.dp(34)); textView.setCompoundDrawablePadding(AndroidUtilities.dp(34));
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 14, 0, 16, 0)); addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 14, 0, 16, 0));
//updateTheme();
} }
@Override @Override
@ -49,9 +49,14 @@ public class DrawerActionCell extends FrameLayout {
textView.setText(text); textView.setText(text);
//textView.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0); //textView.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
int color = AndroidUtilities.getIntDef("drawerIconColor", 0xff737373); int color = AndroidUtilities.getIntDef("drawerIconColor", 0xff737373);
Drawable d = getResources().getDrawable(resId); try{
d.setColorFilter(color, PorterDuff.Mode.SRC_IN); Drawable d = getResources().getDrawable(resId);
textView.setCompoundDrawablesWithIntrinsicBounds(d, null, null, null); 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) { public void setTextAndIcon(String text, Drawable drawable) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -260,7 +260,9 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
public void setPhotoChecked(int index) { } public void setPhotoChecked(int index) { }
@Override @Override
public void cancelButtonPressed() { } public boolean cancelButtonPressed() {
return true;
}
@Override @Override
public void sendButtonPressed(int index) { } public void sendButtonPressed(int index) { }

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -13,6 +13,10 @@ import android.view.Gravity;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.telegram.messenger.AndroidUtilities; 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.messenger.R;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CheckBox; import org.telegram.ui.Components.CheckBox;
@ -23,6 +27,7 @@ public class PhotoPickerPhotoCell extends FrameLayout {
public BackupImageView photoImage; public BackupImageView photoImage;
public FrameLayout checkFrame; public FrameLayout checkFrame;
public CheckBox checkBox; public CheckBox checkBox;
private AnimatorSetProxy animator;
public int itemWidth; public int itemWidth;
public PhotoPickerPhotoCell(Context context) { public PhotoPickerPhotoCell(Context context) {
@ -39,11 +44,44 @@ public class PhotoPickerPhotoCell extends FrameLayout {
checkBox.setCheckOffset(AndroidUtilities.dp(1)); checkBox.setCheckOffset(AndroidUtilities.dp(1));
checkBox.setDrawBackground(true); checkBox.setDrawBackground(true);
checkBox.setColor(0xff3ccaef); 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 @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemWidth, MeasureSpec.EXACTLY)); 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);
}
}
} }

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -24,6 +24,7 @@ import android.view.MotionEvent;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ChatObject;
import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
@ -46,6 +47,7 @@ public class ProfileSearchCell extends BaseCell {
private static Drawable broadcastDrawable; private static Drawable broadcastDrawable;
private static Drawable groupDrawable; private static Drawable groupDrawable;
private static Drawable countDrawable; private static Drawable countDrawable;
private static Drawable checkDrawable;
private static Paint linePaint; private static Paint linePaint;
private CharSequence currentName; private CharSequence currentName;
@ -81,6 +83,8 @@ public class ProfileSearchCell extends BaseCell {
private int countWidth; private int countWidth;
private StaticLayout countLayout; private StaticLayout countLayout;
private boolean drawCheck;
private int onlineLeft; private int onlineLeft;
private StaticLayout onlineLayout; private StaticLayout onlineLayout;
@ -120,7 +124,7 @@ public class ProfileSearchCell extends BaseCell {
lockDrawable = getResources().getDrawable(R.drawable.list_secret); lockDrawable = getResources().getDrawable(R.drawable.list_secret);
groupDrawable = getResources().getDrawable(R.drawable.list_group); groupDrawable = getResources().getDrawable(R.drawable.list_group);
countDrawable = getResources().getDrawable(R.drawable.dialogs_badge); countDrawable = getResources().getDrawable(R.drawable.dialogs_badge);
checkDrawable = getResources().getDrawable(R.drawable.check_list);
updateTheme(); updateTheme();
} }
@ -132,11 +136,9 @@ public class ProfileSearchCell extends BaseCell {
private void updateTheme(){ private void updateTheme(){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor); int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13))); countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13)));
countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff)); countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff));
countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN); countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN);
} }
@Override @Override
@ -199,6 +201,7 @@ public class ProfileSearchCell extends BaseCell {
drawNameBroadcast = false; drawNameBroadcast = false;
drawNameLock = false; drawNameLock = false;
drawNameGroup = false; drawNameGroup = false;
drawCheck = false;
if (encryptedChat != null) { if (encryptedChat != null) {
drawNameLock = true; drawNameLock = true;
@ -219,9 +222,15 @@ public class ProfileSearchCell extends BaseCell {
nameLockTop = AndroidUtilities.dp(28.5f); nameLockTop = AndroidUtilities.dp(28.5f);
} else { } else {
dialog_id = -chat.id; dialog_id = -chat.id;
if (ChatObject.isChannel(chat)) {
drawNameBroadcast = true;
nameLockTop = AndroidUtilities.dp(28.5f);
} else {
drawNameGroup = true; drawNameGroup = true;
nameLockTop = AndroidUtilities.dp(30); nameLockTop = AndroidUtilities.dp(30);
} }
}
drawCheck = (chat.flags & TLRPC.CHAT_FLAG_IS_VERIFIED) != 0;
if (!LocaleController.isRTL) { if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline); nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth()); nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + (drawNameGroup ? groupDrawable.getIntrinsicWidth() : broadcastDrawable.getIntrinsicWidth());
@ -504,6 +513,14 @@ public class ProfileSearchCell extends BaseCell {
canvas.translate(nameLeft, nameTop); canvas.translate(nameLeft, nameTop);
nameLayout.draw(canvas); nameLayout.draw(canvas);
canvas.restore(); 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) { if (onlineLayout != null) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -33,7 +33,7 @@ public class ShadowSectionCell extends View {
@Override @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 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(); if(bTheme)setTheme();
} }

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -204,8 +204,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F
loaded = false; loaded = false;
loading = false; loading = false;
//if (document != null && document.messageOwner.media != null) { if (document != null && document.messageOwner.media != null && document.messageOwner.media.document != 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
int idx; int idx;
String name = FileLoader.getDocumentFileName(document.messageOwner.media.document); String name = FileLoader.getDocumentFileName(document.messageOwner.media.document);
placeholderImabeView.setVisibility(VISIBLE); placeholderImabeView.setVisibility(VISIBLE);

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * You should have received a copy of the license in this archive (see LICENSE).
* *

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -19,6 +19,10 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.AndroidUtilities; 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.MessageObject;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
@ -51,21 +55,26 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
private LinearLayout videoInfoContainer; private LinearLayout videoInfoContainer;
private View selector; private View selector;
private CheckBox checkBox; private CheckBox checkBox;
private FrameLayoutFixed container;
private AnimatorSetProxy animator;
public PhotoVideoView(Context context) { public PhotoVideoView(Context context) {
super(context); super(context);
container = new FrameLayoutFixed(context);
addView(container, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.getImageReceiver().setNeedsQualityThumb(true); imageView.getImageReceiver().setNeedsQualityThumb(true);
imageView.getImageReceiver().setShouldGenerateQualityThumb(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 = new LinearLayout(context);
videoInfoContainer.setOrientation(LinearLayout.HORIZONTAL); videoInfoContainer.setOrientation(LinearLayout.HORIZONTAL);
videoInfoContainer.setBackgroundResource(R.drawable.phototime); videoInfoContainer.setBackgroundResource(R.drawable.phototime);
videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0); videoInfoContainer.setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0);
videoInfoContainer.setGravity(Gravity.CENTER_VERTICAL); 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); ImageView imageView1 = new ImageView(context);
imageView1.setImageResource(R.drawable.ic_video); imageView1.setImageResource(R.drawable.ic_video);
@ -83,7 +92,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
checkBox = new CheckBox(context, R.drawable.round_check2); checkBox = new CheckBox(context, R.drawable.round_check2);
checkBox.setVisibility(INVISIBLE); 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 @Override
@ -93,6 +102,51 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
} }
return super.onTouchEvent(event); 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) { public SharedPhotoVideoCell(Context context) {
@ -134,6 +188,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
public void setItemsCount(int count) { public void setItemsCount(int count) {
for (int a = 0; a < photoVideoViews.length; a++) { for (int a = 0; a < photoVideoViews.length; a++) {
photoVideoViews[a].clearAnimation();
photoVideoViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE); photoVideoViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE);
} }
itemsCount = count; itemsCount = count;
@ -158,10 +213,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
} }
public void setChecked(int a, boolean checked, boolean animated) { public void setChecked(int a, boolean checked, boolean animated) {
if (photoVideoViews[a].checkBox.getVisibility() != VISIBLE) { photoVideoViews[a].setChecked(checked, animated);
photoVideoViews[a].checkBox.setVisibility(VISIBLE);
}
photoVideoViews[a].checkBox.setChecked(checked, animated);
} }
public void setItem(int a, int index, MessageObject messageObject) { 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); photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in);
} }
} else { } else {
photoVideoViews[a].clearAnimation();
photoVideoViews[a].setVisibility(INVISIBLE); photoVideoViews[a].setVisibility(INVISIBLE);
messageObjects[a] = null; messageObjects[a] = null;
} }

View File

@ -3,7 +3,7 @@
* It is licensed under GNU GPL v. 2 or later. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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; package org.telegram.ui.Cells;
@ -45,7 +45,7 @@ public class StickerCell extends FrameLayoutFixed {
} }
public void setSticker(TLRPC.Document document, int side) { 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); imageView.setImage(document.thumb.location, null, "webp", null);
} }
if (side == -1) { if (side == -1) {

View File

@ -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. * It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE). * 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) { public void setSticker(TLRPC.Document document, boolean showEmoji) {
if (document != null) { if (document != null) {
sticker = document; sticker = document;
imageView.setImage(document.thumb.location, null, "webp", null); if (document.thumb != null) {
imageView.setImage(document.thumb.location, null, "webp", null);
}
if (showEmoji) { if (showEmoji) {
boolean set = false; boolean set = false;

Some files were not shown because too many files have changed in this diff Show More