Popup notifications (not finished), removed in-app notifications, DB performance optimisations (fixes for Android L), separate app logic from network logic (not finished)
Note: don’t upload to any markets, it’s may be unstable
This commit is contained in:
parent
91f2073780
commit
d29eabd163
@ -3,10 +3,10 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.11.+'
|
||||
classpath 'com.android.tools.build:gradle:0.12.+'
|
||||
}
|
||||
}
|
||||
apply plugin: 'android'
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@ -26,7 +26,8 @@ android {
|
||||
compileSdkVersion 19
|
||||
buildToolsVersion '19.1.0'
|
||||
|
||||
aaptOptions.useAaptPngCruncher = true
|
||||
useAaptPngCruncher = true
|
||||
useOldManifestMerger true
|
||||
|
||||
signingConfigs {
|
||||
debug {
|
||||
@ -81,7 +82,7 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 268
|
||||
versionName "1.5.7"
|
||||
versionCode 269
|
||||
versionName "1.5.8"
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<activity android:name="net.hockeyapp.android.UpdateActivity" />
|
||||
|
||||
<receiver
|
||||
android:name="org.telegram.messenger.GcmBroadcastReceiver"
|
||||
android:name="org.telegram.android.GcmBroadcastReceiver"
|
||||
android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
|
@ -33,7 +33,7 @@
|
||||
<activity android:name="net.hockeyapp.android.UpdateActivity" />
|
||||
|
||||
<receiver
|
||||
android:name="org.telegram.messenger.GcmBroadcastReceiver"
|
||||
android:name="org.telegram.android.GcmBroadcastReceiver"
|
||||
android:permission="com.google.android.c2dm.permission.SEND" >
|
||||
<intent-filter>
|
||||
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||
|
@ -504,7 +504,7 @@ int writeFrame(uint8_t *framePcmBytes, unsigned int frameByteCount) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
JNIEXPORT int Java_org_telegram_messenger_MediaController_startRecord(JNIEnv *env, jclass class, jstring path) {
|
||||
JNIEXPORT int Java_org_telegram_android_MediaController_startRecord(JNIEnv *env, jclass class, jstring path) {
|
||||
const char *pathStr = (*env)->GetStringUTFChars(env, path, 0);
|
||||
|
||||
int result = initRecorder(pathStr);
|
||||
@ -516,12 +516,12 @@ JNIEXPORT int Java_org_telegram_messenger_MediaController_startRecord(JNIEnv *en
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT int Java_org_telegram_messenger_MediaController_writeFrame(JNIEnv *env, jclass class, jobject frame, jint len) {
|
||||
JNIEXPORT int Java_org_telegram_android_MediaController_writeFrame(JNIEnv *env, jclass class, jobject frame, jint len) {
|
||||
jbyte *frameBytes = (*env)->GetDirectBufferAddress(env, frame);
|
||||
return writeFrame(frameBytes, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_telegram_messenger_MediaController_stopRecord(JNIEnv *env, jclass class) {
|
||||
JNIEXPORT void Java_org_telegram_android_MediaController_stopRecord(JNIEnv *env, jclass class) {
|
||||
cleanupRecorder();
|
||||
}
|
||||
|
||||
@ -618,22 +618,22 @@ void fillBuffer(uint8_t *buffer, int capacity, int *args) {
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jlong Java_org_telegram_messenger_MediaController_getTotalPcmDuration(JNIEnv *env, jclass class) {
|
||||
JNIEXPORT jlong Java_org_telegram_android_MediaController_getTotalPcmDuration(JNIEnv *env, jclass class) {
|
||||
return _totalPcmDuration;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_telegram_messenger_MediaController_readOpusFile(JNIEnv *env, jclass class, jobject buffer, jint capacity, jintArray args) {
|
||||
JNIEXPORT void Java_org_telegram_android_MediaController_readOpusFile(JNIEnv *env, jclass class, jobject buffer, jint capacity, jintArray args) {
|
||||
jint *argsArr = (*env)->GetIntArrayElements(env, args, 0);
|
||||
jbyte *bufferBytes = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
fillBuffer(bufferBytes, capacity, argsArr);
|
||||
(*env)->ReleaseIntArrayElements(env, args, argsArr, 0);
|
||||
}
|
||||
|
||||
JNIEXPORT int Java_org_telegram_messenger_MediaController_seekOpusFile(JNIEnv *env, jclass class, jfloat position) {
|
||||
JNIEXPORT int Java_org_telegram_android_MediaController_seekOpusFile(JNIEnv *env, jclass class, jfloat position) {
|
||||
return seekPlayer(position);
|
||||
}
|
||||
|
||||
JNIEXPORT int Java_org_telegram_messenger_MediaController_openOpusFile(JNIEnv *env, jclass class, jstring path) {
|
||||
JNIEXPORT int Java_org_telegram_android_MediaController_openOpusFile(JNIEnv *env, jclass class, jstring path) {
|
||||
const char *pathStr = (*env)->GetStringUTFChars(env, path, 0);
|
||||
|
||||
int result = initPlayer(pathStr);
|
||||
@ -645,11 +645,11 @@ JNIEXPORT int Java_org_telegram_messenger_MediaController_openOpusFile(JNIEnv *e
|
||||
return result;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_telegram_messenger_MediaController_closeOpusFile(JNIEnv *env, jclass class) {
|
||||
JNIEXPORT void Java_org_telegram_android_MediaController_closeOpusFile(JNIEnv *env, jclass class) {
|
||||
cleanupPlayer();
|
||||
}
|
||||
|
||||
JNIEXPORT int Java_org_telegram_messenger_MediaController_isOpusFile(JNIEnv *env, jclass class, jstring path) {
|
||||
JNIEXPORT int Java_org_telegram_android_MediaController_isOpusFile(JNIEnv *env, jclass class, jstring path) {
|
||||
const char *pathStr = (*env)->GetStringUTFChars(env, path, 0);
|
||||
|
||||
int result = 0;
|
||||
|
@ -30,67 +30,21 @@ void JNI_OnUnload(JavaVM *vm, void *reserved) {
|
||||
gifOnJNIUnload(vm, reserved);
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray Java_org_telegram_messenger_Utilities_aesIgeEncryption(JNIEnv *env, jclass class, jbyteArray _what, jbyteArray _key, jbyteArray _iv, jboolean encrypt, jboolean changeIv, jint l) {
|
||||
unsigned char *what = (unsigned char *)(*env)->GetByteArrayElements(env, _what, NULL);
|
||||
unsigned char *key = (unsigned char *)(*env)->GetByteArrayElements(env, _key, NULL);
|
||||
unsigned char *__iv = (unsigned char *)(*env)->GetByteArrayElements(env, _iv, NULL);
|
||||
unsigned char *iv = 0;
|
||||
|
||||
if (!changeIv) {
|
||||
iv = (unsigned char *)malloc((*env)->GetArrayLength(env, _iv));
|
||||
memcpy(iv, __iv, (*env)->GetArrayLength(env, _iv));
|
||||
} else {
|
||||
iv = __iv;
|
||||
}
|
||||
|
||||
int len = l == 0 ? (*env)->GetArrayLength(env, _what) : l;
|
||||
AES_KEY akey;
|
||||
if (!encrypt) {
|
||||
AES_set_decrypt_key(key, (*env)->GetArrayLength(env, _key) * 8, &akey);
|
||||
AES_ige_encrypt(what, what, len, &akey, iv, AES_DECRYPT);
|
||||
} else {
|
||||
AES_set_encrypt_key(key, (*env)->GetArrayLength(env, _key) * 8, &akey);
|
||||
AES_ige_encrypt(what, what, len, &akey, iv, AES_ENCRYPT);
|
||||
}
|
||||
(*env)->ReleaseByteArrayElements(env, _what, what, 0);
|
||||
(*env)->ReleaseByteArrayElements(env, _key, key, JNI_ABORT);
|
||||
if (!changeIv) {
|
||||
(*env)->ReleaseByteArrayElements(env, _iv, __iv, JNI_ABORT);
|
||||
free(iv);
|
||||
} else {
|
||||
(*env)->ReleaseByteArrayElements(env, _iv, __iv, 0);
|
||||
}
|
||||
return _what;
|
||||
}
|
||||
|
||||
JNIEXPORT void Java_org_telegram_messenger_Utilities_aesIgeEncryption2(JNIEnv *env, jclass class, jobject _what, jbyteArray _key, jbyteArray _iv, jboolean encrypt, jboolean changeIv, jint l) {
|
||||
jbyte *what = (*env)->GetDirectBufferAddress(env, _what);
|
||||
unsigned char *key = (unsigned char *)(*env)->GetByteArrayElements(env, _key, NULL);
|
||||
unsigned char *__iv = (unsigned char *)(*env)->GetByteArrayElements(env, _iv, NULL);
|
||||
unsigned char *iv = 0;
|
||||
|
||||
if (!changeIv) {
|
||||
iv = (unsigned char *)malloc((*env)->GetArrayLength(env, _iv));
|
||||
memcpy(iv, __iv, (*env)->GetArrayLength(env, _iv));
|
||||
} else {
|
||||
iv = __iv;
|
||||
}
|
||||
JNIEXPORT void Java_org_telegram_messenger_Utilities_aesIgeEncryption(JNIEnv *env, jclass class, jobject buffer, jbyteArray key, jbyteArray iv, jboolean encrypt, int offset, int length) {
|
||||
jbyte *what = (*env)->GetDirectBufferAddress(env, buffer) + offset;
|
||||
unsigned char *keyBuff = (unsigned char *)(*env)->GetByteArrayElements(env, key, NULL);
|
||||
unsigned char *ivBuff = (unsigned char *)(*env)->GetByteArrayElements(env, iv, NULL);
|
||||
|
||||
AES_KEY akey;
|
||||
if (!encrypt) {
|
||||
AES_set_decrypt_key(key, (*env)->GetArrayLength(env, _key) * 8, &akey);
|
||||
AES_ige_encrypt(what, what, l, &akey, iv, AES_DECRYPT);
|
||||
AES_set_decrypt_key(keyBuff, 32 * 8, &akey);
|
||||
AES_ige_encrypt(what, what, length, &akey, ivBuff, AES_DECRYPT);
|
||||
} else {
|
||||
AES_set_encrypt_key(key, (*env)->GetArrayLength(env, _key) * 8, &akey);
|
||||
AES_ige_encrypt(what, what, l, &akey, iv, AES_ENCRYPT);
|
||||
}
|
||||
(*env)->ReleaseByteArrayElements(env, _key, key, JNI_ABORT);
|
||||
if (!changeIv) {
|
||||
(*env)->ReleaseByteArrayElements(env, _iv, __iv, JNI_ABORT);
|
||||
free(iv);
|
||||
} else {
|
||||
(*env)->ReleaseByteArrayElements(env, _iv, __iv, 0);
|
||||
AES_set_encrypt_key(keyBuff, 32 * 8, &akey);
|
||||
AES_ige_encrypt(what, what, length, &akey, ivBuff, AES_ENCRYPT);
|
||||
}
|
||||
(*env)->ReleaseByteArrayElements(env, key, keyBuff, JNI_ABORT);
|
||||
(*env)->ReleaseByteArrayElements(env, iv, ivBuff, 0);
|
||||
}
|
||||
|
||||
uint64_t gcd(uint64_t a, uint64_t b){
|
||||
|
@ -48,7 +48,7 @@ jstring Java_org_telegram_SQLite_SQLiteCursor_columnStringValue(JNIEnv *env, job
|
||||
}
|
||||
|
||||
jbyteArray Java_org_telegram_SQLite_SQLiteCursor_columnByteArrayValue(JNIEnv *env, jobject object, int statementHandle, int columnIndex) {
|
||||
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
|
||||
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
|
||||
void *buf = sqlite3_column_blob(handle, columnIndex);
|
||||
int length = sqlite3_column_bytes(handle, columnIndex);
|
||||
if (buf != 0 && length > 0) {
|
||||
@ -58,3 +58,22 @@ jbyteArray Java_org_telegram_SQLite_SQLiteCursor_columnByteArrayValue(JNIEnv *en
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Java_org_telegram_SQLite_SQLiteCursor_columnByteArrayLength(JNIEnv *env, jobject object, int statementHandle, int columnIndex) {
|
||||
return sqlite3_column_bytes((sqlite3_stmt *)statementHandle, columnIndex);
|
||||
}
|
||||
|
||||
int Java_org_telegram_SQLite_SQLiteCursor_columnByteBufferValue(JNIEnv *env, jobject object, int statementHandle, int columnIndex, jobject buffer) {
|
||||
if (!buffer) {
|
||||
return 0;
|
||||
}
|
||||
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
|
||||
void *buf = sqlite3_column_blob(handle, columnIndex);
|
||||
int length = sqlite3_column_bytes(handle, columnIndex);
|
||||
if (buf != 0 && length > 0) {
|
||||
jbyte *byteBuff = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
memcpy(byteBuff, buf, length);
|
||||
return length;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,20 +62,14 @@ void Java_org_telegram_SQLite_SQLitePreparedStatement_finalize(JNIEnv *env, jobj
|
||||
}
|
||||
}
|
||||
|
||||
void Java_org_telegram_SQLite_SQLitePreparedStatement_bindByteArray(JNIEnv *env, jobject object, int statementHandle, int index, jbyteArray value) {
|
||||
void Java_org_telegram_SQLite_SQLitePreparedStatement_bindByteBuffer(JNIEnv *env, jobject object, int statementHandle, int index, jobject value, int length) {
|
||||
sqlite3_stmt *handle = (sqlite3_stmt *)statementHandle;
|
||||
|
||||
const void *buf = (*env)->GetByteArrayElements(env, value, 0);
|
||||
int length = (*env)->GetArrayLength(env, value);
|
||||
|
||||
jbyte *buf = (*env)->GetDirectBufferAddress(env, value);
|
||||
|
||||
int errcode = sqlite3_bind_blob(handle, index, buf, length, SQLITE_STATIC);
|
||||
if (SQLITE_OK != errcode) {
|
||||
throw_sqlite3_exception(env, sqlite3_db_handle(handle), errcode);
|
||||
}
|
||||
|
||||
if (buf != 0) {
|
||||
(*env)->ReleaseByteArrayElements(env, value, buf, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Java_org_telegram_SQLite_SQLitePreparedStatement_bindString(JNIEnv *env, jobject object, int statementHandle, int index, jstring value) {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -58,6 +58,7 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND"/>
|
||||
@ -100,14 +101,23 @@
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.PopupNotificationActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
|
||||
android:excludeFromRecents="true"
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize|stateHidden"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/Theme.TMessages.PopupNotification">
|
||||
</activity>
|
||||
|
||||
<receiver android:name="org.telegram.messenger.SmsListener">
|
||||
<receiver android:name="org.telegram.android.SmsListener">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<service android:name="org.telegram.messenger.AuthenticatorService"
|
||||
<service android:name="org.telegram.android.AuthenticatorService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.AccountAuthenticator"/>
|
||||
@ -116,7 +126,7 @@
|
||||
android:resource="@xml/auth"/>
|
||||
</service>
|
||||
|
||||
<service android:name="org.telegram.messenger.ContactsSyncAdapterService"
|
||||
<service android:name="org.telegram.android.ContactsSyncAdapterService"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.content.SyncAdapter" />
|
||||
@ -127,15 +137,22 @@
|
||||
android:resource="@xml/contacts" />
|
||||
</service>
|
||||
|
||||
<service android:name="org.telegram.messenger.NotificationsService" android:enabled="true"/>
|
||||
<service android:name="org.telegram.android.NotificationsService" android:enabled="true"/>
|
||||
|
||||
<receiver android:name="org.telegram.messenger.AppStartReceiver" android:enabled="true">
|
||||
<receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true">
|
||||
<intent-filter>
|
||||
<action android:name="org.telegram.start" />
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<uses-library android:name="com.sec.android.app.multiwindow" android:required="false" />
|
||||
<meta-data android:name="com.sec.android.support.multiwindow" android:value="true" />
|
||||
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_W" android:value="632dp" />
|
||||
<meta-data android:name="com.sec.android.multiwindow.DEFAULT_SIZE_H" android:value="598dp" />
|
||||
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_W" android:value="632dp" />
|
||||
<meta-data android:name="com.sec.android.multiwindow.MINIMUM_SIZE_H" android:value="598dp" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -10,6 +10,8 @@ package org.telegram.SQLite;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SQLiteCursor {
|
||||
|
||||
public static final int FIELD_TYPE_INT = 1;
|
||||
@ -55,28 +57,21 @@ public class SQLiteCursor {
|
||||
return columnByteArrayValue(preparedStatement.getStatementHandle(), columnIndex);
|
||||
}
|
||||
|
||||
public int byteArrayLength(int columnIndex) throws SQLiteException {
|
||||
checkRow();
|
||||
return columnByteArrayLength(preparedStatement.getStatementHandle(), columnIndex);
|
||||
}
|
||||
|
||||
public int byteBufferValue(int columnIndex, ByteBuffer buffer) throws SQLiteException {
|
||||
checkRow();
|
||||
return columnByteBufferValue(preparedStatement.getStatementHandle(), columnIndex, buffer);
|
||||
}
|
||||
|
||||
public int getTypeOf(int columnIndex) throws SQLiteException {
|
||||
checkRow();
|
||||
return columnType(preparedStatement.getStatementHandle(), columnIndex);
|
||||
}
|
||||
|
||||
public Object objectValue(int columnIndex) throws SQLiteException {
|
||||
checkRow();
|
||||
|
||||
int type = columnType(preparedStatement.getStatementHandle(), columnIndex);
|
||||
switch (type) {
|
||||
case FIELD_TYPE_INT:
|
||||
return intValue(columnIndex);
|
||||
case FIELD_TYPE_BYTEARRAY:
|
||||
return byteArrayValue(columnIndex);
|
||||
case FIELD_TYPE_FLOAT:
|
||||
return doubleValue(columnIndex);
|
||||
case FIELD_TYPE_STRING:
|
||||
return stringValue(columnIndex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean next() throws SQLiteException {
|
||||
int res = preparedStatement.step(preparedStatement.getStatementHandle());
|
||||
if(res == -1) {
|
||||
@ -122,4 +117,6 @@ public class SQLiteCursor {
|
||||
native double columnDoubleValue(int statementHandle, int columnIndex);
|
||||
native String columnStringValue(int statementHandle, int columnIndex);
|
||||
native byte[] columnByteArrayValue(int statementHandle, int columnIndex);
|
||||
native int columnByteArrayLength(int statementHandle, int columnIndex);
|
||||
native int columnByteBufferValue(int statementHandle, int columnIndex, ByteBuffer buffer);
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ package org.telegram.SQLite;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class SQLitePreparedStatement {
|
||||
private boolean isFinalized = false;
|
||||
private int sqliteStatementHandle;
|
||||
@ -26,35 +28,34 @@ public class SQLitePreparedStatement {
|
||||
sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql);
|
||||
}
|
||||
|
||||
public SQLiteCursor query(Object[] args) throws SQLiteException {
|
||||
if (args == null || args.length != queryArgsCount) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
checkFinalized();
|
||||
public SQLiteCursor query(Object[] args) throws SQLiteException {
|
||||
if (args == null || args.length != queryArgsCount) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
reset(sqliteStatementHandle);
|
||||
checkFinalized();
|
||||
|
||||
int i = 1;
|
||||
for (Object obj : args) {
|
||||
if (obj == null) {
|
||||
bindNull(sqliteStatementHandle, i);
|
||||
} else if (obj instanceof Integer) {
|
||||
bindInt(sqliteStatementHandle, i, (Integer)obj);
|
||||
} else if (obj instanceof Double) {
|
||||
bindDouble(sqliteStatementHandle, i, (Double)obj);
|
||||
} else if (obj instanceof String) {
|
||||
bindString(sqliteStatementHandle, i, (String)obj);
|
||||
} else if (obj instanceof byte[]) {
|
||||
bindByteArray(sqliteStatementHandle, i, (byte[])obj);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
reset(sqliteStatementHandle);
|
||||
|
||||
return new SQLiteCursor(this);
|
||||
}
|
||||
int i = 1;
|
||||
for (Object obj : args) {
|
||||
if (obj == null) {
|
||||
bindNull(sqliteStatementHandle, i);
|
||||
} else if (obj instanceof Integer) {
|
||||
bindInt(sqliteStatementHandle, i, (Integer)obj);
|
||||
} else if (obj instanceof Double) {
|
||||
bindDouble(sqliteStatementHandle, i, (Double)obj);
|
||||
} else if (obj instanceof String) {
|
||||
bindString(sqliteStatementHandle, i, (String)obj);
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return new SQLiteCursor(this);
|
||||
}
|
||||
|
||||
public int step() throws SQLiteException {
|
||||
return step(sqliteStatementHandle);
|
||||
@ -102,8 +103,8 @@ public class SQLitePreparedStatement {
|
||||
bindDouble(sqliteStatementHandle, index, value);
|
||||
}
|
||||
|
||||
public void bindByteArray(int index, byte[] value) throws SQLiteException {
|
||||
bindByteArray(sqliteStatementHandle, index, value);
|
||||
public void bindByteBuffer(int index, ByteBuffer value) throws SQLiteException {
|
||||
bindByteBuffer(sqliteStatementHandle, index, value, value.limit());
|
||||
}
|
||||
|
||||
public void bindString(int index, String value) throws SQLiteException {
|
||||
@ -114,7 +115,7 @@ public class SQLitePreparedStatement {
|
||||
bindLong(sqliteStatementHandle, index, value);
|
||||
}
|
||||
|
||||
native void bindByteArray(int statementHandle, int index, byte[] value) throws SQLiteException;
|
||||
native void bindByteBuffer(int statementHandle, int index, ByteBuffer value, int length) throws SQLiteException;
|
||||
native void bindString(int statementHandle, int index, String value) throws SQLiteException;
|
||||
native void bindInt(int statementHandle, int index, int value) throws SQLiteException;
|
||||
native void bindLong(int statementHandle, int index, long value) throws SQLiteException;
|
||||
|
@ -0,0 +1,216 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class AndroidUtilities {
|
||||
private static final Hashtable<String, Typeface> typefaceCache = new Hashtable<String, Typeface>();
|
||||
private static int prevOrientation = -10;
|
||||
private static boolean waitingForSms = false;
|
||||
private static final Integer smsLock = 2;
|
||||
public static int externalCacheNotAvailableState = 0;
|
||||
|
||||
public static int statusBarHeight = 0;
|
||||
public static float density = 1;
|
||||
public static Point displaySize = new Point();
|
||||
|
||||
static {
|
||||
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
|
||||
checkDisplaySize();
|
||||
}
|
||||
|
||||
public static void lockOrientation(Activity activity) {
|
||||
if (prevOrientation != -10) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
prevOrientation = activity.getRequestedOrientation();
|
||||
WindowManager manager = (WindowManager)activity.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
int orientation = activity.getResources().getConfiguration().orientation;
|
||||
|
||||
if (rotation == Surface.ROTATION_270) {
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_0) {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
} else {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unlockOrientation(Activity activity) {
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
activity.setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Typeface getTypeface(String assetPath) {
|
||||
synchronized (typefaceCache) {
|
||||
if (!typefaceCache.containsKey(assetPath)) {
|
||||
try {
|
||||
Typeface t = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(), assetPath);
|
||||
typefaceCache.put(assetPath, t);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("Typefaces", "Could not get typeface '" + assetPath + "' because " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return typefaceCache.get(assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWaitingForSms() {
|
||||
boolean value = false;
|
||||
synchronized (smsLock) {
|
||||
value = waitingForSms;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void setWaitingForSms(boolean value) {
|
||||
synchronized (smsLock) {
|
||||
waitingForSms = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void showKeyboard(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
((InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
|
||||
}
|
||||
|
||||
public static boolean isKeyboardShowed(View view) {
|
||||
if (view == null) {
|
||||
return false;
|
||||
}
|
||||
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
return inputManager.isActive(view);
|
||||
}
|
||||
|
||||
public static void hideKeyboard(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (!imm.isActive()) {
|
||||
return;
|
||||
}
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
public static File getCacheDir() {
|
||||
if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) {
|
||||
externalCacheNotAvailableState = 1;
|
||||
File file = ApplicationLoader.applicationContext.getExternalCacheDir();
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
externalCacheNotAvailableState = 2;
|
||||
File file = ApplicationLoader.applicationContext.getCacheDir();
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
return new File("");
|
||||
}
|
||||
|
||||
public static int dp(int value) {
|
||||
return (int)(Math.max(1, density * value));
|
||||
}
|
||||
|
||||
public static int dpf(float value) {
|
||||
return (int)Math.ceil(density * value);
|
||||
}
|
||||
|
||||
public static void checkDisplaySize() {
|
||||
try {
|
||||
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (manager != null) {
|
||||
Display display = manager.getDefaultDisplay();
|
||||
if (display != null) {
|
||||
if(android.os.Build.VERSION.SDK_INT < 13) {
|
||||
displaySize.set(display.getWidth(), display.getHeight());
|
||||
} else {
|
||||
display.getSize(displaySize);
|
||||
}
|
||||
FileLog.e("tmessages", "display size = " + displaySize.x + " " + displaySize.y);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -6,12 +6,13 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class AppStartReceiver extends BroadcastReceiver {
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.accounts.AbstractAccountAuthenticator;
|
||||
import android.accounts.Account;
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
@ -20,6 +20,16 @@ import android.provider.ContactsContract;
|
||||
import android.util.SparseArray;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -151,6 +161,18 @@ public class ContactsController {
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteAllAppAccounts() {
|
||||
try {
|
||||
AccountManager am = AccountManager.get(ApplicationLoader.applicationContext);
|
||||
Account[] accounts = am.getAccountsByType("org.telegram.account");
|
||||
for (Account c : accounts) {
|
||||
am.removeAccount(c, null, null);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkContacts() {
|
||||
Utilities.globalQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
@ -720,7 +742,7 @@ public class ContactsController {
|
||||
});
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassCanCompress);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassCanCompress);
|
||||
}
|
||||
} else {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@ -815,7 +837,7 @@ public class ContactsController {
|
||||
processLoadedContacts(res.contacts, res.users, 0);
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1540,7 +1562,7 @@ public class ContactsController {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassCanCompress);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassCanCompress);
|
||||
}
|
||||
|
||||
public void deleteContact(final ArrayList<TLRPC.User> users) {
|
||||
@ -1607,6 +1629,6 @@ public class ContactsController {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.OperationCanceledException;
|
||||
@ -19,6 +19,8 @@ import android.content.SyncResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
public class ContactsSyncAdapterService extends Service {
|
||||
private static SyncAdapterImpl sSyncAdapter = null;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
@ -26,6 +26,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class Emoji {
|
||||
@ -202,17 +205,17 @@ public class Emoji {
|
||||
0x00000000D83DDD34L, 0x00000000D83DDD35L, 0x00000000D83DDD3BL, 0x00000000D83DDD36L, 0x00000000D83DDD37L, 0x00000000D83DDD38L, 0x00000000D83DDD39L}};
|
||||
|
||||
static {
|
||||
if (Utilities.density <= 1.0f) {
|
||||
if (AndroidUtilities.density <= 1.0f) {
|
||||
emojiFullSize = 30;
|
||||
} else if (Utilities.density <= 1.5f) {
|
||||
} else if (AndroidUtilities.density <= 1.5f) {
|
||||
emojiFullSize = 45;
|
||||
} else if (Utilities.density <= 2.0f) {
|
||||
} else if (AndroidUtilities.density <= 2.0f) {
|
||||
emojiFullSize = 60;
|
||||
} else {
|
||||
emojiFullSize = 90;
|
||||
}
|
||||
drawImgSize = Utilities.dp(20);
|
||||
bigImgSize = Utilities.dp(30);
|
||||
drawImgSize = AndroidUtilities.dp(20);
|
||||
bigImgSize = AndroidUtilities.dp(30);
|
||||
|
||||
for (int j = 1; j < data.length; j++) {
|
||||
for (int i = 0; i < data[j].length; i++) {
|
||||
@ -228,13 +231,13 @@ public class Emoji {
|
||||
try {
|
||||
float scale = 1.0f;
|
||||
int imageResize = 1;
|
||||
if (Utilities.density <= 1.0f) {
|
||||
if (AndroidUtilities.density <= 1.0f) {
|
||||
scale = 2.0f;
|
||||
imageResize = 2;
|
||||
} else if (Utilities.density <= 1.5f) {
|
||||
} else if (AndroidUtilities.density <= 1.5f) {
|
||||
scale = 3.0f;
|
||||
imageResize = 2;
|
||||
} else if (Utilities.density <= 2.0f) {
|
||||
} else if (AndroidUtilities.density <= 2.0f) {
|
||||
scale = 2.0f;
|
||||
} else {
|
||||
scale = 3.0f;
|
||||
@ -466,7 +469,7 @@ public class Emoji {
|
||||
|
||||
public static class EmojiSpan extends ImageSpan {
|
||||
private Paint.FontMetricsInt fontMetrics = null;
|
||||
int size = Utilities.dp(20);
|
||||
int size = AndroidUtilities.dp(20);
|
||||
|
||||
public EmojiSpan(Drawable d, int verticalAlignment, int s, Paint.FontMetricsInt original) {
|
||||
super(d, verticalAlignment);
|
||||
@ -474,7 +477,7 @@ public class Emoji {
|
||||
if (original != null) {
|
||||
size = Math.abs(fontMetrics.descent) + Math.abs(fontMetrics.ascent);
|
||||
if (size == 0) {
|
||||
size = Utilities.dp(20);
|
||||
size = AndroidUtilities.dp(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -488,8 +491,8 @@ public class Emoji {
|
||||
if (fontMetrics == null) {
|
||||
int sz = super.getSize(paint, text, start, end, fm);
|
||||
|
||||
int offset = Utilities.dp(8);
|
||||
int w = Utilities.dp(10);
|
||||
int offset = AndroidUtilities.dp(8);
|
||||
int w = AndroidUtilities.dp(10);
|
||||
fm.top = -w - offset;
|
||||
fm.bottom = w - offset;
|
||||
fm.ascent = -w - offset;
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
@ -14,6 +14,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class GcmBroadcastReceiver extends BroadcastReceiver {
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
@ -18,6 +18,11 @@ import android.content.res.Configuration;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Xml;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
@ -215,6 +220,9 @@ public class LocaleController {
|
||||
if (currentInfo == null && systemDefaultLocale.getLanguage() != null) {
|
||||
currentInfo = languagesDict.get(systemDefaultLocale.getLanguage());
|
||||
}
|
||||
if (currentInfo == null) {
|
||||
currentInfo = languagesDict.get(getLocaleString(systemDefaultLocale));
|
||||
}
|
||||
if (currentInfo == null) {
|
||||
currentInfo = languagesDict.get("en");
|
||||
}
|
||||
@ -231,6 +239,29 @@ public class LocaleController {
|
||||
}
|
||||
}
|
||||
|
||||
private String getLocaleString(Locale locale) {
|
||||
if (locale == null) {
|
||||
return "";
|
||||
}
|
||||
String languageCode = locale.getLanguage();
|
||||
String countryCode = locale.getCountry();
|
||||
String variantCode = locale.getVariant();
|
||||
if (languageCode.length() == 0 && countryCode.length() == 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder result = new StringBuilder(11);
|
||||
result.append(languageCode);
|
||||
if (countryCode.length() > 0 || variantCode.length() > 0) {
|
||||
result.append('_');
|
||||
}
|
||||
result.append(countryCode);
|
||||
if (variantCode.length() > 0) {
|
||||
result.append('_');
|
||||
}
|
||||
result.append(variantCode);
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public boolean applyLanguageFile(File file) {
|
||||
try {
|
||||
HashMap<String, String> stringMap = getLocaleFileStrings(file);
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
@ -26,6 +26,15 @@ import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.DispatchQueue;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.telegram.ui.Cells.ChatMediaCell;
|
||||
@ -129,6 +138,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
public final static int recordStopped = 50006;
|
||||
public final static int screenshotTook = 50007;
|
||||
public final static int albumsDidLoaded = 50008;
|
||||
public final static int audioDidSent = 50009;
|
||||
|
||||
private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>>();
|
||||
private HashMap<Integer, String> observersByTag = new HashMap<Integer, String>();
|
||||
@ -497,7 +507,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
if (bitmapRegionDecoder != null) {
|
||||
Bitmap bitmap = bitmapRegionDecoder.decodeRegion(new Rect(0, 0, Utilities.dp(44), Utilities.dp(44)), null);
|
||||
Bitmap bitmap = bitmapRegionDecoder.decodeRegion(new Rect(0, 0, AndroidUtilities.dp(44), AndroidUtilities.dp(44)), null);
|
||||
int w = bitmap.getWidth();
|
||||
int h = bitmap.getHeight();
|
||||
for (int y = 0; y < h; y++) {
|
||||
@ -926,7 +936,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
return true;
|
||||
}
|
||||
clenupPlayer(true);
|
||||
final File cacheFile = new File(Utilities.getCacheDir(), messageObject.getFileName());
|
||||
final File cacheFile = new File(AndroidUtilities.getCacheDir(), messageObject.getFileName());
|
||||
|
||||
if (isOpusFile(cacheFile.getAbsolutePath()) == 1) {
|
||||
synchronized (playerObjectSync) {
|
||||
@ -1144,10 +1154,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
recordingAudio.dc_id = Integer.MIN_VALUE;
|
||||
recordingAudio.id = UserConfig.lastLocalId;
|
||||
recordingAudio.user_id = UserConfig.getClientUserId();
|
||||
recordingAudio.mime_type = "audio/ogg";
|
||||
UserConfig.lastLocalId--;
|
||||
UserConfig.saveConfig(false);
|
||||
|
||||
recordingAudioFile = new File(Utilities.getCacheDir(), MessageObject.getAttachFileName(recordingAudio));
|
||||
recordingAudioFile = new File(AndroidUtilities.getCacheDir(), MessageObject.getAttachFileName(recordingAudio));
|
||||
|
||||
try {
|
||||
if (startRecord(recordingAudioFile.getAbsolutePath()) == 0) {
|
||||
@ -1257,6 +1268,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
} else {
|
||||
recordingAudioFileToSend.delete();
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(audioDidSent);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1292,7 +1304,6 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
if (audioRecorder == null) {
|
||||
return;
|
||||
}
|
||||
//recordTimeCount = System.currentTimeMillis() - recordStartTime;
|
||||
try {
|
||||
sendAfterDone = send;
|
||||
audioRecorder.stop();
|
||||
@ -1334,7 +1345,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
}
|
||||
}
|
||||
if (file == null) {
|
||||
file = new File(Utilities.getCacheDir(), path);
|
||||
file = new File(AndroidUtilities.getCacheDir(), path);
|
||||
}
|
||||
|
||||
final File sourceFile = file;
|
||||
@ -1466,7 +1477,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
}
|
||||
}
|
||||
if (cacheFile == null) {
|
||||
cacheFile = new File(Utilities.getCacheDir(), messageObject.getFileName());
|
||||
cacheFile = new File(AndroidUtilities.getCacheDir(), messageObject.getFileName());
|
||||
}
|
||||
try {
|
||||
currentGifDrawable = new GifDrawable(cacheFile);
|
||||
@ -1545,7 +1556,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
UserConfig.lastLocalId--;
|
||||
parcelFD = ApplicationLoader.applicationContext.getContentResolver().openFileDescriptor(uri, "r");
|
||||
input = new FileInputStream(parcelFD.getFileDescriptor());
|
||||
File f = new File(Utilities.getCacheDir(), String.format(Locale.US, "%d.%s", id, ext));
|
||||
File f = new File(AndroidUtilities.getCacheDir(), String.format(Locale.US, "%d.%s", id, ext));
|
||||
output = new FileOutputStream(f);
|
||||
input.getChannel().transferTo(0, input.getChannel().size(), output.getChannel());
|
||||
UserConfig.saveConfig(false);
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,14 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Build;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
@ -6,13 +6,14 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.IBinder;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class NotificationsService extends Service {
|
@ -6,12 +6,14 @@
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class ScreenReceiver extends BroadcastReceiver {
|
||||
@ -19,13 +21,11 @@ public class ScreenReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
|
||||
FileLog.e("tmessages", "screen off");
|
||||
if (ConnectionsManager.lastPauseTime == 0) {
|
||||
ConnectionsManager.lastPauseTime = System.currentTimeMillis();
|
||||
}
|
||||
ConnectionsManager.getInstance().setAppPaused(true, true);
|
||||
ApplicationLoader.isScreenOn = false;
|
||||
} else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
|
||||
FileLog.e("tmessages", "screen on");
|
||||
ConnectionsManager.resetLastPauseTime();
|
||||
ConnectionsManager.getInstance().setAppPaused(false, true);
|
||||
ApplicationLoader.isScreenOn = true;
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.messenger;
|
||||
package org.telegram.android;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
@ -15,6 +15,9 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.SmsMessage;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -25,7 +28,7 @@ public class SmsListener extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if(intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
|
||||
if (!Utilities.isWaitingForSms()) {
|
||||
if (!AndroidUtilities.isWaitingForSms()) {
|
||||
return;
|
||||
}
|
||||
Bundle bundle = intent.getExtras();
|
@ -25,6 +25,4 @@ public class Action {
|
||||
public void cancel() {
|
||||
|
||||
}
|
||||
|
||||
public int state;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public class BuffersStorage {
|
||||
private final ArrayList<ByteBufferDesc> freeBuffers16384;
|
||||
private final ArrayList<ByteBufferDesc> freeBuffers32768;
|
||||
private final ArrayList<ByteBufferDesc> freeBuffersBig;
|
||||
private boolean isThreadSafe;
|
||||
private final static Integer sync = 1;
|
||||
|
||||
private static volatile BuffersStorage Instance = null;
|
||||
public static BuffersStorage getInstance() {
|
||||
@ -26,14 +28,15 @@ public class BuffersStorage {
|
||||
synchronized (BuffersStorage.class) {
|
||||
localInstance = Instance;
|
||||
if (localInstance == null) {
|
||||
Instance = localInstance = new BuffersStorage();
|
||||
Instance = localInstance = new BuffersStorage(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return localInstance;
|
||||
}
|
||||
|
||||
public BuffersStorage() {
|
||||
public BuffersStorage(boolean threadSafe) {
|
||||
isThreadSafe = threadSafe;
|
||||
freeBuffers128 = new ArrayList<ByteBufferDesc>();
|
||||
freeBuffers1024 = new ArrayList<ByteBufferDesc>();
|
||||
freeBuffers4096 = new ArrayList<ByteBufferDesc>();
|
||||
@ -44,91 +47,58 @@ public class BuffersStorage {
|
||||
for (int a = 0; a < 5; a++) {
|
||||
freeBuffers128.add(new ByteBufferDesc(128));
|
||||
}
|
||||
// for (int a = 0; a < 5; a++) {
|
||||
// freeBuffers1024.add(new ByteBufferDesc(1024 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers4096.add(new ByteBufferDesc(4096 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers16384.add(new ByteBufferDesc(16384 + 200));
|
||||
// }
|
||||
// for (int a = 0; a < 2; a++) {
|
||||
// freeBuffers32768.add(new ByteBufferDesc(40000));
|
||||
// }
|
||||
}
|
||||
|
||||
public ByteBufferDesc getFreeBuffer(int size) {
|
||||
if (size <= 0) {
|
||||
return null;
|
||||
}
|
||||
int byteCount = 0;
|
||||
ArrayList<ByteBufferDesc> arrayToGetFrom = null;
|
||||
ByteBufferDesc buffer = null;
|
||||
if (size <= 128) {
|
||||
synchronized (freeBuffers128) {
|
||||
if (freeBuffers128.size() > 0) {
|
||||
buffer = freeBuffers128.get(0);
|
||||
freeBuffers128.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(128);
|
||||
FileLog.e("tmessages", "create new 128 buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffers128;
|
||||
byteCount = 128;
|
||||
} else if (size <= 1024 + 200) {
|
||||
synchronized (freeBuffers1024) {
|
||||
if (freeBuffers1024.size() > 0) {
|
||||
buffer = freeBuffers1024.get(0);
|
||||
freeBuffers1024.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(1024 + 200);
|
||||
FileLog.e("tmessages", "create new 1024 buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffers1024;
|
||||
byteCount = 1024 + 200;
|
||||
} else if (size <= 4096 + 200) {
|
||||
synchronized (freeBuffers4096) {
|
||||
if (freeBuffers4096.size() > 0) {
|
||||
buffer = freeBuffers4096.get(0);
|
||||
freeBuffers4096.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(4096 + 200);
|
||||
FileLog.e("tmessages", "create new 4096 buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffers4096;
|
||||
byteCount = 4096 + 200;
|
||||
} else if (size <= 16384 + 200) {
|
||||
synchronized (freeBuffers16384) {
|
||||
if (freeBuffers16384.size() > 0) {
|
||||
buffer = freeBuffers16384.get(0);
|
||||
freeBuffers16384.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(16384 + 200);
|
||||
FileLog.e("tmessages", "create new 16384 buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffers16384;
|
||||
byteCount = 16384 + 200;
|
||||
} else if (size <= 40000) {
|
||||
synchronized (freeBuffers32768) {
|
||||
if (freeBuffers32768.size() > 0) {
|
||||
buffer = freeBuffers32768.get(0);
|
||||
freeBuffers32768.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(40000);
|
||||
FileLog.e("tmessages", "create new 40000 buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffers32768;
|
||||
byteCount = 40000;
|
||||
} else if (size <= 280000) {
|
||||
synchronized (freeBuffersBig) {
|
||||
if (freeBuffersBig.size() > 0) {
|
||||
buffer = freeBuffersBig.get(0);
|
||||
freeBuffersBig.remove(0);
|
||||
}
|
||||
}
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(280000);
|
||||
FileLog.e("tmessages", "create new big buffer");
|
||||
}
|
||||
arrayToGetFrom = freeBuffersBig;
|
||||
byteCount = 280000;
|
||||
} else {
|
||||
buffer = new ByteBufferDesc(size);
|
||||
}
|
||||
|
||||
if (arrayToGetFrom != null) {
|
||||
if (isThreadSafe) {
|
||||
synchronized (sync) {
|
||||
if (arrayToGetFrom.size() > 0) {
|
||||
buffer = arrayToGetFrom.get(0);
|
||||
arrayToGetFrom.remove(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arrayToGetFrom.size() > 0) {
|
||||
buffer = arrayToGetFrom.get(0);
|
||||
arrayToGetFrom.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (buffer == null) {
|
||||
buffer = new ByteBufferDesc(byteCount);
|
||||
FileLog.e("tmessages", "create new " + byteCount + " buffer");
|
||||
}
|
||||
}
|
||||
|
||||
buffer.buffer.limit(size).rewind();
|
||||
return buffer;
|
||||
}
|
||||
@ -137,40 +107,34 @@ public class BuffersStorage {
|
||||
if (buffer == null) {
|
||||
return;
|
||||
}
|
||||
int maxCount = 10;
|
||||
ArrayList<ByteBufferDesc> arrayToReuse = null;
|
||||
if (buffer.buffer.capacity() == 128) {
|
||||
synchronized (freeBuffers128) {
|
||||
if (freeBuffers128.size() < 10) {
|
||||
freeBuffers128.add(buffer);
|
||||
}
|
||||
}
|
||||
arrayToReuse = freeBuffers128;
|
||||
} else if (buffer.buffer.capacity() == 1024 + 200) {
|
||||
synchronized (freeBuffers1024) {
|
||||
if (freeBuffers1024.size() < 10) {
|
||||
freeBuffers1024.add(buffer);
|
||||
}
|
||||
}
|
||||
} else if (buffer.buffer.capacity() == 4096 + 200) {
|
||||
synchronized (freeBuffers4096) {
|
||||
if (freeBuffers4096.size() < 10) {
|
||||
freeBuffers4096.add(buffer);
|
||||
}
|
||||
}
|
||||
arrayToReuse = freeBuffers1024;
|
||||
} if (buffer.buffer.capacity() == 4096 + 200) {
|
||||
arrayToReuse = freeBuffers4096;
|
||||
} else if (buffer.buffer.capacity() == 16384 + 200) {
|
||||
synchronized (freeBuffers16384) {
|
||||
if (freeBuffers16384.size() < 10) {
|
||||
freeBuffers16384.add(buffer);
|
||||
}
|
||||
}
|
||||
arrayToReuse = freeBuffers16384;
|
||||
} else if (buffer.buffer.capacity() == 40000) {
|
||||
synchronized (freeBuffers32768) {
|
||||
if (freeBuffers32768.size() < 10) {
|
||||
freeBuffers32768.add(buffer);
|
||||
}
|
||||
}
|
||||
arrayToReuse = freeBuffers32768;
|
||||
} else if (buffer.buffer.capacity() == 280000) {
|
||||
synchronized (freeBuffersBig) {
|
||||
if (freeBuffersBig.size() < 4) {
|
||||
freeBuffersBig.add(buffer);
|
||||
arrayToReuse = freeBuffersBig;
|
||||
maxCount = 10;
|
||||
}
|
||||
if (arrayToReuse != null) {
|
||||
if (isThreadSafe) {
|
||||
synchronized (sync) {
|
||||
if (arrayToReuse.size() < maxCount) {
|
||||
arrayToReuse.add(buffer);
|
||||
} else {
|
||||
FileLog.e("tmessages", "too more");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (arrayToReuse.size() < maxCount) {
|
||||
arrayToReuse.add(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,11 @@ public class ByteBufferDesc extends AbsSerializedData {
|
||||
justCalc = calculate;
|
||||
}
|
||||
|
||||
public ByteBufferDesc(byte[] bytes) {
|
||||
buffer = ByteBuffer.wrap(bytes);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return buffer.position();
|
||||
}
|
||||
@ -397,11 +402,13 @@ public class ByteBufferDesc extends AbsSerializedData {
|
||||
sl = 4;
|
||||
}
|
||||
ByteBufferDesc b = BuffersStorage.getInstance().getFreeBuffer(l);
|
||||
int old = buffer.limit();
|
||||
buffer.limit(buffer.position() + l);
|
||||
b.buffer.put(buffer);
|
||||
buffer.limit(old);
|
||||
b.buffer.position(0);
|
||||
if (b != null) {
|
||||
int old = buffer.limit();
|
||||
buffer.limit(buffer.position() + l);
|
||||
b.buffer.put(buffer);
|
||||
buffer.limit(old);
|
||||
b.buffer.position(0);
|
||||
}
|
||||
int i = sl;
|
||||
while((l + i) % 4 != 0) {
|
||||
buffer.get();
|
||||
|
@ -14,13 +14,15 @@ import android.content.pm.PackageInfo;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -34,11 +36,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
private ArrayList<Long> destroyingSessions = new ArrayList<Long>();
|
||||
private HashMap<Integer, ArrayList<Long>> quickAckIdToRequestIds = new HashMap<Integer, ArrayList<Long>>();
|
||||
|
||||
|
||||
private HashMap<Long, Integer> pingIdToDate = new HashMap<Long, Integer>();
|
||||
private ConcurrentHashMap<Integer, ArrayList<Long>> requestsByGuids = new ConcurrentHashMap<Integer, ArrayList<Long>>(100, 1.0f, 2);
|
||||
private ConcurrentHashMap<Long, Integer> requestsByClass = new ConcurrentHashMap<Long, Integer>(100, 1.0f, 2);
|
||||
public volatile int connectionState = 2;
|
||||
private volatile int connectionState = 2;
|
||||
|
||||
private ArrayList<RPCRequest> requestQueue = new ArrayList<RPCRequest>();
|
||||
private ArrayList<RPCRequest> runningRequests = new ArrayList<RPCRequest>();
|
||||
@ -47,17 +48,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
private ArrayList<Integer> unknownDatacenterIds = new ArrayList<Integer>();
|
||||
private ArrayList<Integer> neededDatacenterIds = new ArrayList<Integer>();
|
||||
private ArrayList<Integer> unauthorizedDatacenterIds = new ArrayList<Integer>();
|
||||
final HashMap<Integer, ArrayList<NetworkMessage>> genericMessagesToDatacenters = new HashMap<Integer, ArrayList<NetworkMessage>>();
|
||||
private final HashMap<Integer, ArrayList<NetworkMessage>> genericMessagesToDatacenters = new HashMap<Integer, ArrayList<NetworkMessage>>();
|
||||
|
||||
private TLRPC.TL_auth_exportedAuthorization movingAuthorization;
|
||||
public static final int DEFAULT_DATACENTER_ID = Integer.MAX_VALUE;
|
||||
public static final int DC_UPDATE_TIME = 60 * 60;
|
||||
public int currentDatacenterId;
|
||||
public int movingToDatacenterId;
|
||||
private static final int DC_UPDATE_TIME = 60 * 60;
|
||||
protected int currentDatacenterId;
|
||||
protected int movingToDatacenterId;
|
||||
private long lastOutgoingMessageId = 0;
|
||||
private int isTestBackend = 0;
|
||||
public int timeDifference = 0;
|
||||
public int currentPingTime;
|
||||
private int timeDifference = 0;
|
||||
private int currentPingTime;
|
||||
private int lastDestroySessionRequestTime;
|
||||
private boolean updatingDcSettings = false;
|
||||
private int updatingDcStartTime = 0;
|
||||
@ -69,12 +70,17 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
private boolean paused = false;
|
||||
private long lastPingTime = System.currentTimeMillis();
|
||||
private long lastPushPingTime = 0;
|
||||
private boolean pushMessagesReceived = true;
|
||||
private boolean sendingPushPing = false;
|
||||
private int nextSleepTimeout = 30000;
|
||||
private long nextPingId = 0;
|
||||
|
||||
public static long lastPauseTime = System.currentTimeMillis();
|
||||
public static boolean appPaused = true;
|
||||
private long lastPauseTime = System.currentTimeMillis();
|
||||
private boolean appPaused = true;
|
||||
|
||||
private volatile long nextCallToken = 1;
|
||||
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
|
||||
private static volatile ConnectionsManager Instance = null;
|
||||
public static ConnectionsManager getInstance() {
|
||||
@ -90,18 +96,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
return localInstance;
|
||||
}
|
||||
|
||||
static long t = System.currentTimeMillis();
|
||||
private Runnable stageRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.stageQueue.handler.removeCallbacks(stageRunnable);
|
||||
t = System.currentTimeMillis();
|
||||
if (datacenters != null) {
|
||||
if (sendingPushPing && lastPushPingTime < System.currentTimeMillis() - 30000 || Math.abs(lastPushPingTime - System.currentTimeMillis()) > 60000 * 4) {
|
||||
if (sendingPushPing && lastPushPingTime < System.currentTimeMillis() - 30000 || Math.abs(lastPushPingTime - System.currentTimeMillis()) > 60000 * 3 + 10000) {
|
||||
lastPushPingTime = 0;
|
||||
sendingPushPing = false;
|
||||
FileLog.e("tmessages", "push ping timeout");
|
||||
}
|
||||
if (lastPushPingTime < System.currentTimeMillis() - 60000 * 3) {
|
||||
FileLog.e("tmessages", "time for push ping");
|
||||
lastPushPingTime = System.currentTimeMillis();
|
||||
Datacenter datacenter = datacenterWithId(currentDatacenterId);
|
||||
if (datacenter != null) {
|
||||
@ -112,16 +118,22 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (lastPauseTime != 0 && lastPauseTime < currentTime - nextSleepTimeout) {
|
||||
boolean dontSleep = false;
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.retryCount < 10 && (request.runningStartTime + 60 > (int)(currentTime / 1000)) && ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0)) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
boolean dontSleep = !pushMessagesReceived;
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
dontSleep = true;
|
||||
} else if (request.retryCount < 10 && (request.runningStartTime + 60 > (int) (currentTime / 1000)) && ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0)) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
dontSleep = true;
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
dontSleep = true;
|
||||
break;
|
||||
}
|
||||
@ -143,7 +155,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
} else {
|
||||
lastPauseTime += 30 * 1000;
|
||||
FileLog.e("tmessages", "don't sleep 30 seconds because of upload or download request");
|
||||
FileLog.e("tmessages", "don't sleep 30 seconds because of salt, upload or download request");
|
||||
}
|
||||
}
|
||||
if (paused) {
|
||||
@ -199,20 +211,35 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
|
||||
Utilities.stageQueue.postRunnable(stageRunnable, 1000);
|
||||
|
||||
PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
|
||||
}
|
||||
|
||||
public int getConnectionState() {
|
||||
return connectionState;
|
||||
}
|
||||
|
||||
public void setConnectionState(int state) {
|
||||
connectionState = state;
|
||||
}
|
||||
|
||||
private void resumeNetworkInternal() {
|
||||
if (paused) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
FileLog.e("tmessages", "wakeup network in background");
|
||||
} else if (lastPauseTime != 0) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "reset sleep timeout");
|
||||
}
|
||||
}
|
||||
|
||||
public void resumeNetworkMaybe() {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (paused) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
FileLog.e("tmessages", "wakeup network in background");
|
||||
} else if (lastPauseTime != 0) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "reset sleep timeout");
|
||||
}
|
||||
resumeNetworkInternal();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -230,26 +257,39 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
});
|
||||
}
|
||||
|
||||
public static void resetLastPauseTime() {
|
||||
if (appPaused) {
|
||||
return;
|
||||
}
|
||||
FileLog.e("tmessages", "reset app pause time");
|
||||
if (lastPauseTime != 0 && System.currentTimeMillis() - lastPauseTime > 5000) {
|
||||
ContactsController.getInstance().checkContacts();
|
||||
}
|
||||
lastPauseTime = 0;
|
||||
ConnectionsManager.getInstance().applicationMovedToForeground();
|
||||
public void setAppPaused(final boolean value, final boolean byScreenState) {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!byScreenState) {
|
||||
appPaused = value;
|
||||
FileLog.e("tmessages", "app paused = " + value);
|
||||
}
|
||||
if (value) {
|
||||
if (byScreenState) {
|
||||
if (lastPauseTime == 0) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
}
|
||||
} else {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
}
|
||||
} else {
|
||||
if (appPaused) {
|
||||
return;
|
||||
}
|
||||
FileLog.e("tmessages", "reset app pause time");
|
||||
if (lastPauseTime != 0 && System.currentTimeMillis() - lastPauseTime > 5000) {
|
||||
ContactsController.getInstance().checkContacts();
|
||||
}
|
||||
lastPauseTime = 0;
|
||||
ConnectionsManager.getInstance().applicationMovedToForeground();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void setAppPaused(boolean value) {
|
||||
appPaused = value;
|
||||
FileLog.e("tmessages", "app paused = " + value);
|
||||
if (!appPaused) {
|
||||
resetLastPauseTime();
|
||||
} else {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
}
|
||||
public long getPauseTime() {
|
||||
return lastPauseTime;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -743,15 +783,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}, null, true, RPCRequest.RPCRequestClassEnableUnauthorized | RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin, dcNum == 0 ? currentDatacenterId : dcNum);
|
||||
}
|
||||
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, boolean requiresCompletion, int requestClass) {
|
||||
return performRpc(rpc, completionBlock, progressBlock, requiresCompletion, requestClass, DEFAULT_DATACENTER_ID);
|
||||
}
|
||||
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, boolean requiresCompletion, int requestClass, int datacenterId) {
|
||||
return performRpc(rpc, completionBlock, progressBlock, null, requiresCompletion, requestClass, datacenterId);
|
||||
}
|
||||
|
||||
TLObject wrapInLayer(TLObject object, int datacenterId, RPCRequest request) {
|
||||
private TLObject wrapInLayer(TLObject object, int datacenterId, RPCRequest request) {
|
||||
if (object.layer() > 0) {
|
||||
Datacenter datacenter = datacenterWithId(datacenterId);
|
||||
if (datacenter == null || datacenter.lastInitVersion != currentAppVersion) {
|
||||
@ -792,7 +824,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
object = invoke;
|
||||
}
|
||||
TLRPC.invokeWithLayer12 invoke = new TLRPC.invokeWithLayer12();
|
||||
TLRPC.invokeWithLayer14 invoke = new TLRPC.invokeWithLayer14();
|
||||
invoke.query = object;
|
||||
FileLog.d("wrap in layer", "" + object);
|
||||
return invoke;
|
||||
@ -800,8 +832,19 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
return object;
|
||||
}
|
||||
|
||||
public static volatile long nextCallToken = 1;
|
||||
long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCProgressDelegate progressBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId) {
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock) {
|
||||
return performRpc(rpc, completionBlock, null, true, RPCRequest.RPCRequestClassGeneric, DEFAULT_DATACENTER_ID);
|
||||
}
|
||||
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, boolean requiresCompletion, int requestClass) {
|
||||
return performRpc(rpc, completionBlock, null, requiresCompletion, requestClass, DEFAULT_DATACENTER_ID, true);
|
||||
}
|
||||
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId) {
|
||||
return performRpc(rpc, completionBlock, quickAckBlock, requiresCompletion, requestClass, datacenterId, true);
|
||||
}
|
||||
|
||||
public long performRpc(final TLObject rpc, final RPCRequest.RPCRequestDelegate completionBlock, final RPCRequest.RPCQuickAckDelegate quickAckBlock, final boolean requiresCompletion, final int requestClass, final int datacenterId, final boolean runQueue) {
|
||||
if (!UserConfig.isClientActivated() && (requestClass & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
|
||||
FileLog.e("tmessages", "can't do request without login " + rpc);
|
||||
return 0;
|
||||
@ -821,19 +864,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
request.rawRequest = rpc;
|
||||
request.rpcRequest = wrapInLayer(rpc, datacenterId, request);
|
||||
request.completionBlock = completionBlock;
|
||||
request.progressBlock = progressBlock;
|
||||
request.quickAckBlock = quickAckBlock;
|
||||
request.requiresCompletion = requiresCompletion;
|
||||
|
||||
requestQueue.add(request);
|
||||
|
||||
if (paused && ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0)) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
FileLog.e("tmessages", "wakeup by download or upload request");
|
||||
if (runQueue) {
|
||||
processRequestQueue(0, 0);
|
||||
}
|
||||
|
||||
processRequestQueue(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
@ -876,7 +914,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (notifyServer) {
|
||||
TLRPC.TL_rpc_drop_answer dropAnswer = new TLRPC.TL_rpc_drop_answer();
|
||||
dropAnswer.req_msg_id = request.runningMessageId;
|
||||
performRpc(dropAnswer, null, null, false, request.flags);
|
||||
performRpc(dropAnswer, null, false, request.flags);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1009,8 +1047,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
connection = requestDatacenter.getGenericConnection(this);
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) {
|
||||
int num = (request.flags & RPCRequest.RPCRequestClassDownloadMedia2) != 0 ? 1 : 0;
|
||||
connection = requestDatacenter.getDownloadConnection(num, this);
|
||||
connection = requestDatacenter.getDownloadConnection(this);
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0 ) {
|
||||
connection = requestDatacenter.getUploadConnection(this);
|
||||
}
|
||||
@ -1026,7 +1063,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
maxTimeout = 30.0f;
|
||||
}
|
||||
|
||||
boolean forceThisRequest = (request.flags & requestClass) != 0 && (_datacenterId == Integer.MIN_VALUE || requestDatacenter.datacenterId == _datacenterId);
|
||||
boolean forceThisRequest = (request.flags & requestClass) != 0 && requestDatacenter.datacenterId == _datacenterId;
|
||||
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts || request.rawRequest instanceof TLRPC.TL_destroy_session) {
|
||||
if (request.runningMessageId != 0) {
|
||||
@ -1177,8 +1214,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
connection = requestDatacenter.getGenericConnection(this);
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) {
|
||||
int num = (request.flags & RPCRequest.RPCRequestClassDownloadMedia2) != 0 ? 1 : 0;
|
||||
connection = requestDatacenter.getDownloadConnection(num, this);
|
||||
connection = requestDatacenter.getDownloadConnection(this);
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
connection = requestDatacenter.getUploadConnection(this);
|
||||
}
|
||||
@ -1341,29 +1377,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
}
|
||||
|
||||
if (datacenter.connection == null) {
|
||||
datacenter.connection = new TcpConnection(datacenter.datacenterId);
|
||||
datacenter.connection.delegate = this;
|
||||
datacenter.connection.transportRequestClass = RPCRequest.RPCRequestClassGeneric;
|
||||
}
|
||||
|
||||
proceedToSendingMessages(arr, datacenter.connection, hasSendMessage);
|
||||
proceedToSendingMessages(arr, datacenter.getGenericConnection(this), hasSendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
if ((requestClass & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
if (_datacenterId == Integer.MIN_VALUE) {
|
||||
for (Datacenter datacenter : datacenters.values()) {
|
||||
ArrayList<NetworkMessage> messagesIt = genericMessagesToDatacenters.get(datacenter.datacenterId);
|
||||
if (messagesIt == null || messagesIt.size() == 0) {
|
||||
generatePing(datacenter, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<NetworkMessage> messagesIt = genericMessagesToDatacenters.get(_datacenterId);
|
||||
if (messagesIt == null || messagesIt.size() == 0) {
|
||||
generatePing();
|
||||
}
|
||||
ArrayList<NetworkMessage> messagesIt = genericMessagesToDatacenters.get(_datacenterId);
|
||||
if (messagesIt == null || messagesIt.size() == 0) {
|
||||
generatePing();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1501,7 +1522,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
}
|
||||
|
||||
connection.sendData(null, transportData, reportAck);
|
||||
connection.sendData(transportData, true, reportAck);
|
||||
} else {
|
||||
FileLog.e("tmessages", "***** Transport data is nil");
|
||||
}
|
||||
@ -1527,12 +1548,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
TLRPC.TL_protoMessage message = networkMessage.protoMessage;
|
||||
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
if (message.body instanceof TLRPC.invokeWithLayer12) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)message.body).query);
|
||||
if (message.body instanceof TLRPC.invokeWithLayer14) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)message.body).query);
|
||||
} else if (message.body instanceof TLRPC.initConnection) {
|
||||
TLRPC.initConnection r = (TLRPC.initConnection)message.body;
|
||||
if (r.query instanceof TLRPC.invokeWithLayer12) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)r.query).query);
|
||||
if (r.query instanceof TLRPC.invokeWithLayer14) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)r.query).query);
|
||||
} else {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query);
|
||||
}
|
||||
@ -1567,12 +1588,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
TLRPC.TL_protoMessage message = networkMessage.protoMessage;
|
||||
containerMessages.add(message);
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
if (message.body instanceof TLRPC.invokeWithLayer12) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)message.body).query);
|
||||
if (message.body instanceof TLRPC.invokeWithLayer14) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)message.body).query);
|
||||
} else if (message.body instanceof TLRPC.initConnection) {
|
||||
TLRPC.initConnection r = (TLRPC.initConnection)message.body;
|
||||
if (r.query instanceof TLRPC.invokeWithLayer12) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer12)r.query).query);
|
||||
if (r.query instanceof TLRPC.invokeWithLayer14) {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + ((TLRPC.invokeWithLayer14)r.query).query);
|
||||
} else {
|
||||
FileLog.d("tmessages", connection.getSissionId() + ":DC" + datacenter.datacenterId + "> Send message (" + message.seqno + ", " + message.msg_id + "): " + r.query);
|
||||
}
|
||||
@ -1625,13 +1646,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
ByteBufferDesc dataForEncryption = BuffersStorage.getInstance().getFreeBuffer(innerOs.limit() + zeroCount);
|
||||
dataForEncryption.writeRaw(innerOs);
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(innerOs);
|
||||
byte[] b = new byte[1];
|
||||
for (int a = 0; a < zeroCount; a++) {
|
||||
|
||||
if (zeroCount != 0) {
|
||||
byte[] b = new byte[zeroCount];
|
||||
Utilities.random.nextBytes(b);
|
||||
dataForEncryption.writeByte(b[0]);
|
||||
dataForEncryption.writeRaw(b);
|
||||
}
|
||||
|
||||
Utilities.aesIgeEncryption2(dataForEncryption.buffer, keyData.aesKey, keyData.aesIv, true, false, dataForEncryption.limit());
|
||||
Utilities.aesIgeEncryption(dataForEncryption.buffer, keyData.aesKey, keyData.aesIv, true, false, 0, dataForEncryption.limit());
|
||||
|
||||
ByteBufferDesc data = BuffersStorage.getInstance().getFreeBuffer(8 + messageKey.length + dataForEncryption.limit());
|
||||
data.writeInt64(datacenter.authKeyId);
|
||||
@ -1645,18 +1667,24 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
void refillSaltSet(final Datacenter datacenter) {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
return;
|
||||
Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId);
|
||||
if (requestDatacenter.datacenterId == datacenter.datacenterId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
return;
|
||||
Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId);
|
||||
if (requestDatacenter.datacenterId == datacenter.datacenterId) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TLRPC.TL_get_future_salts getFutureSalts = new TLRPC.TL_get_future_salts();
|
||||
getFutureSalts.num = 64;
|
||||
getFutureSalts.num = 32;
|
||||
|
||||
performRpc(getFutureSalts, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
@ -1759,7 +1787,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
registeringForPush = false;
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1860,6 +1888,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
pingIdToDate.remove(pid);
|
||||
}
|
||||
} else {
|
||||
FileLog.e("tmessages", "received push ping");
|
||||
sendingPushPing = false;
|
||||
}
|
||||
} else if (message instanceof TLRPC.TL_futuresalts) {
|
||||
@ -2038,6 +2067,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
isError = true;
|
||||
request.completionBlock.run(null, implicitError != null ? implicitError : (TLRPC.TL_error) resultContainer.result);
|
||||
} else {
|
||||
if (resultContainer.result instanceof TLRPC.updates_Difference) {
|
||||
pushMessagesReceived = true;
|
||||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
}
|
||||
request.completionBlock.run(resultContainer.result, null);
|
||||
}
|
||||
}
|
||||
@ -2195,8 +2230,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
} else if (message instanceof TLRPC.Updates) {
|
||||
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
||||
FileLog.e("tmessages", "received internal push");
|
||||
resumeNetworkMaybe();
|
||||
if (paused) {
|
||||
pushMessagesReceived = false;
|
||||
}
|
||||
if (!wakeLock.isHeld()) {
|
||||
wakeLock.acquire(20000);
|
||||
}
|
||||
resumeNetworkInternal();
|
||||
} else {
|
||||
pushMessagesReceived = true;
|
||||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
MessagesController.getInstance().processUpdates((TLRPC.Updates) message, false);
|
||||
}
|
||||
} else {
|
||||
@ -2255,156 +2300,18 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
ByteBufferDesc transportData = generatePingData(connection);
|
||||
if (transportData != null) {
|
||||
if (push) {
|
||||
FileLog.e("tmessages", "send push ping");
|
||||
sendingPushPing = true;
|
||||
}
|
||||
connection.sendData(null, transportData, false);
|
||||
connection.sendData(transportData, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long needsToDecodeMessageIdFromPartialData(TcpConnection connection, byte[] data) {
|
||||
if (data == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Datacenter datacenter = datacenters.get(connection.getDatacenterId());
|
||||
SerializedData is = new SerializedData(data);
|
||||
|
||||
byte[] keyId = is.readData(8);
|
||||
SerializedData keyIdData = new SerializedData(keyId);
|
||||
long key = keyIdData.readInt64();
|
||||
if (key == 0) {
|
||||
return -1;
|
||||
} else {
|
||||
if (datacenter.authKeyId == 0 || key != datacenter.authKeyId) {
|
||||
FileLog.e("tmessages", "Error: invalid auth key id " + connection);
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] messageKey = is.readData(16);
|
||||
MessageKeyData keyData = Utilities.generateMessageKeyData(datacenter.authKey, messageKey, true);
|
||||
|
||||
byte[] messageData = is.readData(data.length - 24);
|
||||
messageData = Utilities.aesIgeEncryption(messageData, keyData.aesKey, keyData.aesIv, false, false, 0);
|
||||
|
||||
if (messageData == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SerializedData messageIs = new SerializedData(messageData);
|
||||
long messageServerSalt = messageIs.readInt64();
|
||||
long messageSessionId = messageIs.readInt64();
|
||||
|
||||
if (messageSessionId != connection.getSissionId()) {
|
||||
FileLog.e("tmessages", String.format("***** Error: invalid message session ID (%d instead of %d)", messageSessionId, connection.getSissionId()));
|
||||
finishUpdatingState(connection);
|
||||
return -1;
|
||||
}
|
||||
|
||||
long messageId = messageIs.readInt64();
|
||||
int messageSeqNo = messageIs.readInt32();
|
||||
int messageLength = messageIs.readInt32();
|
||||
|
||||
boolean[] stop = new boolean[1];
|
||||
long[] reqMsgId = new long[1];
|
||||
stop[0] = false;
|
||||
reqMsgId[0] = 0;
|
||||
|
||||
while (!stop[0] && reqMsgId[0] == 0) {
|
||||
int signature = messageIs.readInt32(stop);
|
||||
if (stop[0]) {
|
||||
break;
|
||||
}
|
||||
findReqMsgId(messageIs, signature, reqMsgId, stop);
|
||||
}
|
||||
|
||||
return reqMsgId[0];
|
||||
}
|
||||
}
|
||||
|
||||
private void findReqMsgId(SerializedData is, int signature, long[] reqMsgId, boolean[] failed) {
|
||||
if (signature == 0x73f1f8dc) {
|
||||
if (is.length() < 4) {
|
||||
failed[0] = true;
|
||||
return;
|
||||
}
|
||||
int count = is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
is.readInt64(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
int innerSignature = is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
findReqMsgId(is, innerSignature, reqMsgId, failed);
|
||||
if (failed[0] || reqMsgId[0] != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (signature == 0xf35c6d01) {
|
||||
long value = is.readInt64(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
reqMsgId[0] = value;
|
||||
} else if (signature == 0x62d6b459) {
|
||||
is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
int count = is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
is.readInt32(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (signature == 0x347773c5) {
|
||||
is.readInt64(failed);
|
||||
if (failed[0]) {
|
||||
return;
|
||||
}
|
||||
is.readInt64(failed);
|
||||
}
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// TCPConnection delegate
|
||||
//================================================================================
|
||||
|
||||
@Override
|
||||
public void tcpConnectionProgressChanged(TcpConnection connection, long messageId, int currentSize, int length) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
if (request.respondsToMessageId(messageId)) {
|
||||
if (request.progressBlock != null) {
|
||||
request.progressBlock.progress(length, currentSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tcpConnectionClosed(TcpConnection connection) {
|
||||
if (connection.getDatacenterId() == currentDatacenterId && (connection.transportRequestClass & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
@ -2440,7 +2347,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
});
|
||||
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
||||
sendingPushPing = false;
|
||||
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 5000;
|
||||
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 4000;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2450,10 +2357,11 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (datacenter.authKey != null) {
|
||||
if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
||||
sendingPushPing = false;
|
||||
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 10000;
|
||||
lastPushPingTime = System.currentTimeMillis() - 60000 * 3 + 4000;
|
||||
} else {
|
||||
if (paused && connection.getDatacenterId() == currentDatacenterId && (connection.transportRequestClass & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
resumeNetworkMaybe();
|
||||
if (paused && lastPauseTime != 0) {
|
||||
lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
}
|
||||
processRequestQueue(connection.transportRequestClass, connection.getDatacenterId());
|
||||
}
|
||||
@ -2541,11 +2449,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
|
||||
byte[] messageKey = data.readData(16);
|
||||
MessageKeyData keyData = Utilities.generateMessageKeyData(datacenter.authKey, messageKey, true);
|
||||
data.compact();
|
||||
data.limit(data.position());
|
||||
data.position(0);
|
||||
|
||||
Utilities.aesIgeEncryption2(data.buffer, keyData.aesKey, keyData.aesIv, false, false, length - 24);
|
||||
Utilities.aesIgeEncryption(data.buffer, keyData.aesKey, keyData.aesIv, false, false, data.position(), length - 24);
|
||||
|
||||
long messageServerSalt = data.readInt64();
|
||||
long messageSessionId = data.readInt64();
|
||||
@ -2570,14 +2475,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
connection.addMessageToConfirm(messageId);
|
||||
}
|
||||
|
||||
byte[] realMessageKeyFull = Utilities.computeSHA1(data.buffer, 0, Math.min(messageLength + 32, data.limit()));
|
||||
byte[] realMessageKeyFull = Utilities.computeSHA1(data.buffer, 24, Math.min(messageLength + 32 + 24, data.limit()));
|
||||
if (realMessageKeyFull == null) {
|
||||
return;
|
||||
}
|
||||
byte[] realMessageKey = new byte[16];
|
||||
System.arraycopy(realMessageKeyFull, realMessageKeyFull.length - 16, realMessageKey, 0, 16);
|
||||
|
||||
if (!Arrays.equals(messageKey, realMessageKey)) {
|
||||
if (!Utilities.arraysEquals(messageKey, 0, realMessageKeyFull, realMessageKeyFull.length - 16)) {
|
||||
FileLog.e("tmessages", "***** Error: invalid message key");
|
||||
connection.suspendConnection(true);
|
||||
connection.connect();
|
||||
|
@ -35,7 +35,7 @@ public class Datacenter {
|
||||
private volatile int currentAddressNum = 0;
|
||||
|
||||
public TcpConnection connection;
|
||||
private ArrayList<TcpConnection> downloadConnections = new ArrayList<TcpConnection>();
|
||||
private TcpConnection downloadConnection;
|
||||
private TcpConnection uploadConnection;
|
||||
public TcpConnection pushConnection;
|
||||
|
||||
@ -327,7 +327,7 @@ public class Datacenter {
|
||||
if (uploadConnection != null) {
|
||||
uploadConnection.suspendConnection(true);
|
||||
}
|
||||
for (TcpConnection downloadConnection : downloadConnections) {
|
||||
if (downloadConnection != null) {
|
||||
downloadConnection.suspendConnection(true);
|
||||
}
|
||||
}
|
||||
@ -339,7 +339,7 @@ public class Datacenter {
|
||||
if (uploadConnection != null) {
|
||||
sessions.add(uploadConnection.getSissionId());
|
||||
}
|
||||
for (TcpConnection downloadConnection : downloadConnections) {
|
||||
if (downloadConnection != null) {
|
||||
sessions.add(downloadConnection.getSissionId());
|
||||
}
|
||||
}
|
||||
@ -351,26 +351,21 @@ public class Datacenter {
|
||||
if (uploadConnection != null) {
|
||||
uploadConnection.recreateSession();
|
||||
}
|
||||
for (TcpConnection downloadConnection : downloadConnections) {
|
||||
if (downloadConnection != null) {
|
||||
downloadConnection.recreateSession();
|
||||
}
|
||||
}
|
||||
|
||||
public TcpConnection getDownloadConnection(int num, TcpConnection.TcpConnectionDelegate delegate) {
|
||||
if (num >= 0 && authKey != null) {
|
||||
TcpConnection downloadConnection = null;
|
||||
if (num < downloadConnections.size()) {
|
||||
downloadConnection = downloadConnections.get(num);
|
||||
} else {
|
||||
public TcpConnection getDownloadConnection(TcpConnection.TcpConnectionDelegate delegate) {
|
||||
if (authKey != null) {
|
||||
if (downloadConnection == null) {
|
||||
downloadConnection = new TcpConnection(datacenterId);
|
||||
downloadConnection.delegate = delegate;
|
||||
downloadConnection.transportRequestClass = RPCRequest.RPCRequestClassDownloadMedia;
|
||||
downloadConnections.add(downloadConnection);
|
||||
}
|
||||
downloadConnection.connect();
|
||||
return downloadConnection;
|
||||
}
|
||||
return null;
|
||||
return downloadConnection;
|
||||
}
|
||||
|
||||
public TcpConnection getUploadConnection(TcpConnection.TcpConnectionDelegate delegate) {
|
||||
|
@ -54,7 +54,7 @@ public class ExportAuthorizationAction extends Action {
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
|
||||
void beginImport() {
|
||||
|
@ -10,9 +10,9 @@ package org.telegram.messenger;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.RandomAccessFile;
|
||||
@ -22,10 +22,19 @@ import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class FileLoadOperation {
|
||||
private int downloadChunkSize = 1024 * 256;
|
||||
|
||||
private static class RequestInfo {
|
||||
private long requestToken = 0;
|
||||
private int offset = 0;
|
||||
private TLRPC.TL_upload_file response = null;
|
||||
}
|
||||
|
||||
private final static int downloadChunkSize = 1024 * 32;
|
||||
private final static int maxDownloadRequests = 3;
|
||||
|
||||
public int datacenter_id;
|
||||
public TLRPC.InputFileLocation location;
|
||||
@ -37,14 +46,10 @@ public class FileLoadOperation {
|
||||
public String filter;
|
||||
private byte[] key;
|
||||
private byte[] iv;
|
||||
private long requestToken = 0;
|
||||
private long requestToken2 = 0;
|
||||
private int requestProgress = 0;
|
||||
private int requestProgress2 = 0;
|
||||
|
||||
private int nextDownloadOffset = 0;
|
||||
private TLRPC.TL_upload_file delayedRes = null;
|
||||
private int delayedResOffset = 0;
|
||||
private int delayedResTokenNum = 0;
|
||||
private ArrayList<RequestInfo> requestInfos = new ArrayList<RequestInfo>(maxDownloadRequests);
|
||||
private ArrayList<RequestInfo> delayedRequestInfos = new ArrayList<RequestInfo>(maxDownloadRequests - 1);
|
||||
|
||||
private File cacheFileTemp;
|
||||
private File cacheFileFinal;
|
||||
@ -56,7 +61,7 @@ public class FileLoadOperation {
|
||||
public boolean needBitmapCreate = true;
|
||||
private InputStream httpConnectionStream;
|
||||
private RandomAccessFile fileOutputStream;
|
||||
RandomAccessFile fiv;
|
||||
private RandomAccessFile fiv;
|
||||
|
||||
public static interface FileLoadOperationDelegate {
|
||||
public abstract void didFinishLoadingFile(FileLoadOperation operation);
|
||||
@ -214,7 +219,7 @@ public class FileLoadOperation {
|
||||
if (isLocalFile) {
|
||||
cacheFileFinal = new File(fileNameFinal);
|
||||
} else {
|
||||
cacheFileFinal = new File(Utilities.getCacheDir(), fileNameFinal);
|
||||
cacheFileFinal = new File(AndroidUtilities.getCacheDir(), fileNameFinal);
|
||||
}
|
||||
final boolean dontDelete = isLocalFile;
|
||||
final Long mediaIdFinal = mediaId;
|
||||
@ -245,8 +250,8 @@ public class FileLoadOperation {
|
||||
float h_filter = 0;
|
||||
if (filter != null) {
|
||||
String args[] = filter.split("_");
|
||||
w_filter = Float.parseFloat(args[0]) * Utilities.density;
|
||||
h_filter = Float.parseFloat(args[1]) * Utilities.density;
|
||||
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
|
||||
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
|
||||
opts.inJustDecodeBounds = true;
|
||||
|
||||
if (mediaIdFinal != null) {
|
||||
@ -289,11 +294,9 @@ public class FileLoadOperation {
|
||||
float bitmapH = image.getHeight();
|
||||
if (bitmapW != w_filter && bitmapW > w_filter) {
|
||||
float scaleFactor = bitmapW / w_filter;
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int)w_filter, (int)(bitmapH / scaleFactor), false);
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int)w_filter, (int)(bitmapH / scaleFactor), true);
|
||||
if (image != scaledBitmap) {
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
image.recycle();
|
||||
}
|
||||
image.recycle();
|
||||
image = scaledBitmap;
|
||||
}
|
||||
}
|
||||
@ -339,13 +342,13 @@ public class FileLoadOperation {
|
||||
});
|
||||
return;
|
||||
}
|
||||
cacheFileTemp = new File(Utilities.getCacheDir(), fileNameTemp);
|
||||
cacheFileTemp = new File(AndroidUtilities.getCacheDir(), fileNameTemp);
|
||||
if (cacheFileTemp.exists()) {
|
||||
downloadedBytes = (int)cacheFileTemp.length();
|
||||
nextDownloadOffset = downloadedBytes = downloadedBytes / 1024 * 1024;
|
||||
}
|
||||
if (fileNameIv != null) {
|
||||
cacheIvTemp = new File(Utilities.getCacheDir(), fileNameIv);
|
||||
cacheIvTemp = new File(AndroidUtilities.getCacheDir(), fileNameIv);
|
||||
try {
|
||||
fiv = new RandomAccessFile(cacheIvTemp, "rws");
|
||||
long len = cacheIvTemp.length();
|
||||
@ -383,27 +386,44 @@ public class FileLoadOperation {
|
||||
if (httpUrl != null) {
|
||||
startDownloadHTTPRequest();
|
||||
} else {
|
||||
if (totalBytesCount >= 1024 * 1024) {
|
||||
downloadChunkSize = 1024 * 256;
|
||||
} else {
|
||||
downloadChunkSize = 1024 * 32;
|
||||
}
|
||||
startDownloadRequest();
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (totalBytesCount != 0 && downloadedBytes == totalBytesCount) {
|
||||
try {
|
||||
onFinishLoadingFile();
|
||||
} catch (Exception e) {
|
||||
delegate.didFailedLoadingFile(FileLoadOperation.this);
|
||||
}
|
||||
} else {
|
||||
startDownloadRequest();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
if (state != 1) {
|
||||
return;
|
||||
}
|
||||
state = 2;
|
||||
cleanup();
|
||||
if (httpUrl == null) {
|
||||
ConnectionsManager.getInstance().cancelRpc(requestToken, true);
|
||||
ConnectionsManager.getInstance().cancelRpc(requestToken2, true);
|
||||
}
|
||||
delegate.didFailedLoadingFile(FileLoadOperation.this);
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (state != 1) {
|
||||
return;
|
||||
}
|
||||
state = 2;
|
||||
cleanup();
|
||||
if (httpUrl == null) {
|
||||
for (RequestInfo requestInfo : requestInfos) {
|
||||
if (requestInfo.requestToken != 0) {
|
||||
ConnectionsManager.getInstance().cancelRpc(requestInfo.requestToken, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
delegate.didFailedLoadingFile(FileLoadOperation.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
@ -435,11 +455,12 @@ public class FileLoadOperation {
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
if (delayedRes != null) {
|
||||
delayedRes.disableFree = false;
|
||||
delayedRes.freeResources();
|
||||
delayedRes = null;
|
||||
for (RequestInfo requestInfo : delayedRequestInfos) {
|
||||
if (requestInfo.response != null) {
|
||||
requestInfo.response.disableFree = false;
|
||||
requestInfo.response.freeResources();
|
||||
requestInfo.response = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -454,7 +475,6 @@ public class FileLoadOperation {
|
||||
cacheIvTemp.delete();
|
||||
}
|
||||
final boolean renamed = cacheFileTemp.renameTo(cacheFileFinal);
|
||||
|
||||
if (needBitmapCreate) {
|
||||
FileLoader.cacheOutQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
@ -476,8 +496,8 @@ public class FileLoadOperation {
|
||||
float h_filter;
|
||||
if (filter != null) {
|
||||
String args[] = filter.split("_");
|
||||
w_filter = Float.parseFloat(args[0]) * Utilities.density;
|
||||
h_filter = Float.parseFloat(args[1]) * Utilities.density;
|
||||
w_filter = Float.parseFloat(args[0]) * AndroidUtilities.density;
|
||||
h_filter = Float.parseFloat(args[1]) * AndroidUtilities.density;
|
||||
|
||||
opts.inJustDecodeBounds = true;
|
||||
BitmapFactory.decodeFile(cacheFileFinal.getAbsolutePath(), opts);
|
||||
@ -514,11 +534,9 @@ public class FileLoadOperation {
|
||||
float bitmapH = image.getHeight();
|
||||
if (bitmapW != w_filter && bitmapW > w_filter) {
|
||||
float scaleFactor = bitmapW / w_filter;
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int) w_filter, (int) (bitmapH / scaleFactor), false);
|
||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(image, (int) w_filter, (int) (bitmapH / scaleFactor), true);
|
||||
if (image != scaledBitmap) {
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
image.recycle();
|
||||
}
|
||||
image.recycle();
|
||||
image = scaledBitmap;
|
||||
}
|
||||
}
|
||||
@ -612,57 +630,49 @@ public class FileLoadOperation {
|
||||
}
|
||||
}
|
||||
|
||||
private void processRequestResult(TLRPC.TL_upload_file res, TLRPC.TL_error error, int dowloadOffset, int tokenNum) {
|
||||
private void processRequestResult(RequestInfo requestInfo, TLRPC.TL_error error) {
|
||||
requestInfos.remove(requestInfo);
|
||||
if (error == null) {
|
||||
try {
|
||||
if (downloadedBytes != dowloadOffset) {
|
||||
if (delayedRes != null) {
|
||||
FileLog.e("tmessages", "something went wrong!");
|
||||
}
|
||||
delayedRes = res;
|
||||
delayedRes.disableFree = true;
|
||||
delayedResOffset = dowloadOffset;
|
||||
delayedResTokenNum = tokenNum;
|
||||
if (downloadedBytes != requestInfo.offset) {
|
||||
delayedRequestInfos.add(requestInfo);
|
||||
requestInfo.response.disableFree = true;
|
||||
return;
|
||||
} else {
|
||||
if (tokenNum == 0) {
|
||||
requestToken = 0;
|
||||
} else if (tokenNum == 1) {
|
||||
requestToken2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (res.bytes.limit() == 0) {
|
||||
if (requestInfo.response.bytes.limit() == 0) {
|
||||
onFinishLoadingFile();
|
||||
return;
|
||||
}
|
||||
if (key != null) {
|
||||
Utilities.aesIgeEncryption2(res.bytes.buffer, key, iv, false, true, res.bytes.limit());
|
||||
Utilities.aesIgeEncryption(requestInfo.response.bytes.buffer, key, iv, false, true, 0, requestInfo.response.bytes.limit());
|
||||
}
|
||||
if (fileOutputStream != null) {
|
||||
FileChannel channel = fileOutputStream.getChannel();
|
||||
channel.write(res.bytes.buffer);
|
||||
channel.write(requestInfo.response.bytes.buffer);
|
||||
}
|
||||
if (fiv != null) {
|
||||
fiv.seek(0);
|
||||
fiv.write(iv);
|
||||
}
|
||||
downloadedBytes += res.bytes.limit();
|
||||
downloadedBytes += requestInfo.response.bytes.limit();
|
||||
if (totalBytesCount > 0 && state == 1) {
|
||||
delegate.didChangedLoadProgress(FileLoadOperation.this, Math.min(1.0f, (float)downloadedBytes / (float)totalBytesCount));
|
||||
}
|
||||
|
||||
if(delayedRes != null && res != delayedRes) {
|
||||
TLRPC.TL_upload_file temp = delayedRes;
|
||||
processRequestResult(temp, null, delayedResOffset, delayedResTokenNum);
|
||||
if (delayedRes != null) {
|
||||
delayedRes.disableFree = false;
|
||||
delayedRes.freeResources();
|
||||
delayedRes = null;
|
||||
for (int a = 0; a < delayedRequestInfos.size(); a++) {
|
||||
RequestInfo delayedRequestInfo = delayedRequestInfos.get(a);
|
||||
if (downloadedBytes == delayedRequestInfo.offset) {
|
||||
delayedRequestInfos.remove(a);
|
||||
processRequestResult(delayedRequestInfo, null);
|
||||
delayedRequestInfo.response.disableFree = false;
|
||||
delayedRequestInfo.response.freeResources();
|
||||
delayedRequestInfo = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (downloadedBytes % downloadChunkSize == 0 || totalBytesCount > 0 && totalBytesCount != downloadedBytes) {
|
||||
if (downloadedBytes % downloadChunkSize == 0 || totalBytesCount > 0 && totalBytesCount > downloadedBytes) {
|
||||
startDownloadRequest();
|
||||
} else {
|
||||
onFinishLoadingFile();
|
||||
@ -714,69 +724,36 @@ public class FileLoadOperation {
|
||||
}
|
||||
}
|
||||
|
||||
private void processRequestProgress() {
|
||||
delegate.didChangedLoadProgress(FileLoadOperation.this, Math.min(1.0f, (float) (downloadedBytes + requestProgress + requestProgress2) / (float) totalBytesCount));
|
||||
}
|
||||
|
||||
private void startDownloadRequest() {
|
||||
if (state != 1) {
|
||||
if (state != 1 || totalBytesCount > 0 && nextDownloadOffset >= totalBytesCount || requestInfos.size() + delayedRequestInfos.size() >= maxDownloadRequests) {
|
||||
return;
|
||||
}
|
||||
if (requestToken == 0) {
|
||||
requestProgress = 0;
|
||||
if (totalBytesCount > 0 && nextDownloadOffset >= totalBytesCount) {
|
||||
return;
|
||||
}
|
||||
final TLRPC.TL_upload_getFile req = new TLRPC.TL_upload_getFile();
|
||||
req.location = location;
|
||||
req.offset = nextDownloadOffset;
|
||||
req.limit = downloadChunkSize;
|
||||
nextDownloadOffset += downloadChunkSize;
|
||||
final long time = System.currentTimeMillis();
|
||||
requestToken = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
processRequestResult((TLRPC.TL_upload_file) response, error, req.offset, 0);
|
||||
}
|
||||
}, new RPCRequest.RPCProgressDelegate() {
|
||||
@Override
|
||||
public void progress(int length, int progress) {
|
||||
if (state == 1) {
|
||||
requestProgress = progress;
|
||||
if (totalBytesCount == -1) {
|
||||
delegate.didChangedLoadProgress(FileLoadOperation.this, Math.min(1.0f, (float) (progress) / (float) length));
|
||||
} else if (totalBytesCount > 0) {
|
||||
processRequestProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassDownloadMedia, datacenter_id);
|
||||
int count = 1;
|
||||
if (totalBytesCount > 0) {
|
||||
count = Math.max(0, maxDownloadRequests - requestInfos.size() - delayedRequestInfos.size());
|
||||
}
|
||||
if (totalBytesCount > 0 && requestToken2 == 0) {
|
||||
requestProgress2 = 0;
|
||||
|
||||
for (int a = 0; a < count; a++) {
|
||||
if (totalBytesCount > 0 && nextDownloadOffset >= totalBytesCount) {
|
||||
return;
|
||||
break;
|
||||
}
|
||||
final long time = System.currentTimeMillis();
|
||||
final TLRPC.TL_upload_getFile req = new TLRPC.TL_upload_getFile();
|
||||
boolean isLast = totalBytesCount <= 0 || a == count - 1 || totalBytesCount > 0 && nextDownloadOffset + downloadChunkSize >= totalBytesCount;
|
||||
TLRPC.TL_upload_getFile req = new TLRPC.TL_upload_getFile();
|
||||
req.location = location;
|
||||
req.offset = nextDownloadOffset;
|
||||
req.limit = downloadChunkSize;
|
||||
nextDownloadOffset += downloadChunkSize;
|
||||
requestToken2 = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
|
||||
final RequestInfo requestInfo = new RequestInfo();
|
||||
requestInfos.add(requestInfo);
|
||||
requestInfo.offset = req.offset;
|
||||
requestInfo.requestToken = ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
processRequestResult((TLRPC.TL_upload_file) response, error, req.offset, 1);
|
||||
requestInfo.response = (TLRPC.TL_upload_file) response;
|
||||
processRequestResult(requestInfo, error);
|
||||
}
|
||||
}, new RPCRequest.RPCProgressDelegate() {
|
||||
@Override
|
||||
public void progress(int length, int progress) {
|
||||
if (state == 1) {
|
||||
requestProgress2 = progress;
|
||||
processRequestProgress();
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassDownloadMedia | RPCRequest.RPCRequestClassDownloadMedia2, datacenter_id);
|
||||
}, null, true, RPCRequest.RPCRequestClassDownloadMedia, datacenter_id, isLast);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.telegram.ui.Views.ImageReceiver;
|
||||
@ -291,10 +292,8 @@ public class FileLoader {
|
||||
if (runtimeHack != null) {
|
||||
runtimeHack.trackAlloc(oldBitmap.getRowBytes() * oldBitmap.getHeight());
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
if (!oldBitmap.isRecycled()) {
|
||||
oldBitmap.recycle();
|
||||
}
|
||||
if (!oldBitmap.isRecycled()) {
|
||||
oldBitmap.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -466,6 +465,7 @@ public class FileLoader {
|
||||
}
|
||||
FileLoadOperation operation = loadOperationPaths.get(fileName);
|
||||
if (operation != null) {
|
||||
loadOperationPaths.remove(fileName);
|
||||
if (audio != null) {
|
||||
audioLoadOperationQueue.remove(operation);
|
||||
} else if (photo != null) {
|
||||
@ -1119,7 +1119,7 @@ public class FileLoader {
|
||||
try {
|
||||
if (!cache) {
|
||||
String fileName = location.volume_id + "_" + location.local_id + ".jpg";
|
||||
final File cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
final File cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
FileOutputStream stream = new FileOutputStream(cacheFile);
|
||||
scaledBitmap.compress(Bitmap.CompressFormat.JPEG, quality, stream);
|
||||
size.size = (int)stream.getChannel().size();
|
||||
@ -1129,10 +1129,8 @@ public class FileLoader {
|
||||
size.bytes = stream.toByteArray();
|
||||
size.size = size.bytes.length;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
if (scaledBitmap != bitmap) {
|
||||
scaledBitmap.recycle();
|
||||
}
|
||||
if (scaledBitmap != bitmap) {
|
||||
scaledBitmap.recycle();
|
||||
}
|
||||
return size;
|
||||
} catch (Exception e) {
|
||||
|
@ -11,6 +11,7 @@ package org.telegram.messenger;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import org.telegram.android.FastDateFormat;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -31,7 +31,7 @@ public class FileUploadOperation {
|
||||
private byte[] key;
|
||||
private byte[] iv;
|
||||
private byte[] ivChange;
|
||||
private int fingerprint;
|
||||
private int fingerprint = 0;
|
||||
private boolean isBigFile = false;
|
||||
FileInputStream stream;
|
||||
MessageDigest mdEnc = null;
|
||||
@ -57,11 +57,9 @@ public class FileUploadOperation {
|
||||
System.arraycopy(key, 0, arr, 0, 32);
|
||||
System.arraycopy(iv, 0, arr, 32, 32);
|
||||
byte[] digest = md.digest(arr);
|
||||
byte[] fingerprintBytes = new byte[4];
|
||||
for (int a = 0; a < 4; a++) {
|
||||
fingerprintBytes[a] = (byte)(digest[a] ^ digest[a + 4]);
|
||||
fingerprint |= ((digest[a] ^ digest[a + 4]) & 0xFF) << (a * 8);
|
||||
}
|
||||
fingerprint = Utilities.bytesToInt(fingerprintBytes);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -138,7 +136,7 @@ public class FileUploadOperation {
|
||||
for (int a = 0; a < toAdd; a++) {
|
||||
sendBuffer.writeByte(0);
|
||||
}
|
||||
Utilities.aesIgeEncryption2(sendBuffer.buffer, key, ivChange, true, true, readed + toAdd);
|
||||
Utilities.aesIgeEncryption(sendBuffer.buffer, key, ivChange, true, true, 0, readed + toAdd);
|
||||
}
|
||||
sendBuffer.rewind();
|
||||
if (!isBigFile) {
|
||||
@ -211,11 +209,6 @@ public class FileUploadOperation {
|
||||
delegate.didFailedUploadingFile(FileUploadOperation.this);
|
||||
}
|
||||
}
|
||||
}, new RPCRequest.RPCProgressDelegate() {
|
||||
@Override
|
||||
public void progress(int length, int progress) {
|
||||
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassUploadMedia, ConnectionsManager.DEFAULT_DATACENTER_ID);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
@ -29,9 +28,9 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
|
||||
private boolean processedPQRes;
|
||||
|
||||
private byte[] reqPQMsgData;
|
||||
private byte[] reqDHMsgData;
|
||||
private byte[] setClientDHParamsMsgData;
|
||||
private ByteBufferDesc reqPQMsgData;
|
||||
private ByteBufferDesc reqDHMsgData;
|
||||
private ByteBufferDesc setClientDHParamsMsgData;
|
||||
private boolean wasDisconnect = false;
|
||||
|
||||
private long lastOutgoingMessageId;
|
||||
@ -63,9 +62,18 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
authKey = null;
|
||||
authKeyId = 0;
|
||||
processedPQRes = false;
|
||||
reqPQMsgData = null;
|
||||
reqDHMsgData = null;
|
||||
setClientDHParamsMsgData = null;
|
||||
if (reqPQMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(reqPQMsgData);
|
||||
reqPQMsgData = null;
|
||||
}
|
||||
if (reqDHMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(reqDHMsgData);
|
||||
reqDHMsgData = null;
|
||||
}
|
||||
if (setClientDHParamsMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(setClientDHParamsMsgData);
|
||||
setClientDHParamsMsgData = null;
|
||||
}
|
||||
|
||||
if (dropConnection) {
|
||||
datacenter.connection.suspendConnection(true);
|
||||
@ -165,23 +173,21 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
return messageId;
|
||||
}
|
||||
|
||||
byte[] sendMessageData(TLObject message, long messageId) {
|
||||
byte[] messageData;
|
||||
SerializedData innerOs = new SerializedData();
|
||||
ByteBufferDesc sendMessageData(TLObject message, long messageId) {
|
||||
ByteBufferDesc innerOs = BuffersStorage.getInstance().getFreeBuffer(message.getObjectSize());
|
||||
message.serializeToStream(innerOs);
|
||||
messageData = innerOs.toByteArray();
|
||||
message.freeResources();
|
||||
|
||||
SerializedData messageOs = new SerializedData();
|
||||
ByteBufferDesc messageOs = BuffersStorage.getInstance().getFreeBuffer(8 + 8 + 4 + innerOs.length());
|
||||
messageOs.writeInt64(0);
|
||||
messageOs.writeInt64(messageId);
|
||||
messageOs.writeInt32(messageData.length);
|
||||
messageOs.writeRaw(messageData);
|
||||
messageOs.writeInt32(innerOs.length());
|
||||
innerOs.position(0);
|
||||
messageOs.writeRaw(innerOs);
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(innerOs);
|
||||
|
||||
byte[] transportData = messageOs.toByteArray();
|
||||
|
||||
datacenter.connection.sendData(transportData, null, false);
|
||||
|
||||
return transportData;
|
||||
datacenter.connection.sendData(messageOs, false, false);
|
||||
return messageOs;
|
||||
}
|
||||
|
||||
void processMessage(TLObject message, long messageId) {
|
||||
@ -196,7 +202,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
|
||||
processedPQRes = true;
|
||||
final TLRPC.TL_resPQ resPq = (TLRPC.TL_resPQ)message;
|
||||
if (Arrays.equals(authNonce, resPq.nonce)) {
|
||||
if (Utilities.arraysEquals(authNonce, 0, resPq.nonce, 0)) {
|
||||
final HashMap<String, Object> publicKey = selectPublicKey(resPq.server_public_key_fingerprints);
|
||||
if (publicKey == null) {
|
||||
FileLog.e("tmessages", "***** Couldn't find valid server public key");
|
||||
@ -276,7 +282,10 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
msgsAck.msg_ids.add(messageIdf);
|
||||
sendMessageData(msgsAck, generateMessageId());
|
||||
|
||||
reqPQMsgData = null;
|
||||
if (reqPQMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(reqPQMsgData);
|
||||
reqPQMsgData = null;
|
||||
}
|
||||
reqDHMsgData = sendMessageData(reqDH, generateMessageId());
|
||||
}
|
||||
});
|
||||
@ -322,33 +331,33 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
System.arraycopy(authNewNonce, 0, newNonce0_4, 0, 4);
|
||||
tmpAesIv.writeRaw(newNonce0_4);
|
||||
|
||||
byte[] answerWithHash = Utilities.aesIgeEncryption(serverDhParams.encrypted_answer, tmpAesKey.toByteArray(), tmpAesIv.toByteArray(), false, false, 0);
|
||||
byte[] answerHash = new byte[20];
|
||||
System.arraycopy(answerWithHash, 0, answerHash, 0, 20);
|
||||
ByteBufferDesc answerWithHash = BuffersStorage.getInstance().getFreeBuffer(serverDhParams.encrypted_answer.length);
|
||||
answerWithHash.writeRaw(serverDhParams.encrypted_answer);
|
||||
answerWithHash.position(0);
|
||||
|
||||
Utilities.aesIgeEncryption(answerWithHash.buffer, tmpAesKey.toByteArray(), tmpAesIv.toByteArray(), false, false, 0, serverDhParams.encrypted_answer.length);
|
||||
byte[] answerHash = new byte[20];
|
||||
answerWithHash.readRaw(answerHash);
|
||||
|
||||
byte[] answerData = new byte[answerWithHash.length - 20];
|
||||
System.arraycopy(answerWithHash, 20, answerData, 0, answerWithHash.length - 20);
|
||||
boolean hashVerified = false;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
byte[] computedAnswerHash = Utilities.computeSHA1(answerData);
|
||||
if (Arrays.equals(computedAnswerHash, answerHash)) {
|
||||
byte[] computedAnswerHash = Utilities.computeSHA1(answerWithHash.buffer, 20, answerWithHash.limit() - i);
|
||||
if (Utilities.arraysEquals(computedAnswerHash, 0, answerHash, 0)) {
|
||||
hashVerified = true;
|
||||
break;
|
||||
}
|
||||
byte[] answerData2 = new byte[answerData.length - 1];
|
||||
System.arraycopy(answerData, 0, answerData2, 0, answerData.length - 1);
|
||||
answerData = answerData2;
|
||||
}
|
||||
|
||||
if (!hashVerified) {
|
||||
FileLog.e("tmessages", "***** Couldn't decode DH params");
|
||||
beginHandshake(false);
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(answerWithHash);
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedData answerIs = new SerializedData(answerData);
|
||||
int constructor = answerIs.readInt32();
|
||||
TLRPC.TL_server_DH_inner_data dhInnerData = (TLRPC.TL_server_DH_inner_data)TLClassStore.Instance().TLdeserialize(answerIs, constructor);
|
||||
int constructor = answerWithHash.readInt32();
|
||||
TLRPC.TL_server_DH_inner_data dhInnerData = (TLRPC.TL_server_DH_inner_data)TLClassStore.Instance().TLdeserialize(answerWithHash, constructor);
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(answerWithHash);
|
||||
|
||||
if (!(dhInnerData instanceof TLRPC.TL_server_DH_inner_data)) {
|
||||
FileLog.e("tmessages", "***** Couldn't parse decoded DH params");
|
||||
@ -360,12 +369,12 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
throw new RuntimeException("bad prime");
|
||||
}
|
||||
|
||||
if (!Arrays.equals(authNonce, dhInnerData.nonce)) {
|
||||
if (!Utilities.arraysEquals(authNonce, 0, dhInnerData.nonce, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH nonce");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
}
|
||||
if (!Arrays.equals(authServerNonce, dhInnerData.server_nonce)) {
|
||||
if (!Utilities.arraysEquals(authServerNonce, 0, dhInnerData.server_nonce, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH server nonce");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
@ -427,50 +436,66 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
clientInnerData.server_nonce = authServerNonce;
|
||||
clientInnerData.g_b = g_b.toByteArray();
|
||||
clientInnerData.retry_id = 0;
|
||||
SerializedData os = new SerializedData();
|
||||
clientInnerData.serializeToStream(os);
|
||||
byte[] clientInnerDataBytes = os.toByteArray();
|
||||
|
||||
SerializedData clientDataWithHash = new SerializedData();
|
||||
clientDataWithHash.writeRaw(Utilities.computeSHA1(clientInnerDataBytes));
|
||||
clientDataWithHash.writeRaw(clientInnerDataBytes);
|
||||
byte[] bb = new byte[1];
|
||||
while (clientDataWithHash.length() % 16 != 0) {
|
||||
ByteBufferDesc os = BuffersStorage.getInstance().getFreeBuffer(clientInnerData.getObjectSize());
|
||||
clientInnerData.serializeToStream(os);
|
||||
|
||||
int len = os.length() + 20;
|
||||
int extraLen = len % 16 != 0 ? 16 - len % 16 : 0;
|
||||
ByteBufferDesc clientDataWithHash = BuffersStorage.getInstance().getFreeBuffer(len + extraLen);
|
||||
clientDataWithHash.writeRaw(Utilities.computeSHA1(os.buffer));
|
||||
os.position(0);
|
||||
clientDataWithHash.writeRaw(os);
|
||||
if (extraLen != 0) {
|
||||
byte[] bb = new byte[extraLen];
|
||||
Utilities.random.nextBytes(bb);
|
||||
clientDataWithHash.writeByte(bb[0]);
|
||||
clientDataWithHash.writeRaw(bb);
|
||||
}
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(os);
|
||||
|
||||
TLRPC.TL_set_client_DH_params setClientDhParams = new TLRPC.TL_set_client_DH_params();
|
||||
setClientDhParams.nonce = authNonce;
|
||||
setClientDhParams.server_nonce = authServerNonce;
|
||||
setClientDhParams.encrypted_data = Utilities.aesIgeEncryption(clientDataWithHash.toByteArray(), tmpAesKey.toByteArray(), tmpAesIv.toByteArray(), true, false, 0);
|
||||
Utilities.aesIgeEncryption(clientDataWithHash.buffer, tmpAesKey.toByteArray(), tmpAesIv.toByteArray(), true, false, 0, clientDataWithHash.length());
|
||||
setClientDhParams.encrypted_data = clientDataWithHash;
|
||||
|
||||
TLRPC.TL_msgs_ack msgsAck = new TLRPC.TL_msgs_ack();
|
||||
msgsAck.msg_ids = new ArrayList<Long>();
|
||||
msgsAck.msg_ids.add(messageId);
|
||||
sendMessageData(msgsAck, generateMessageId());
|
||||
|
||||
reqDHMsgData = null;
|
||||
if (reqDHMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(reqDHMsgData);
|
||||
reqDHMsgData = null;
|
||||
}
|
||||
setClientDHParamsMsgData = sendMessageData(setClientDhParams, generateMessageId());
|
||||
} else {
|
||||
FileLog.e("tmessages", "***** Couldn't set DH params");
|
||||
beginHandshake(false);
|
||||
}
|
||||
} else if (message instanceof TLRPC.Set_client_DH_params_answer) {
|
||||
if (setClientDHParamsMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(setClientDHParamsMsgData);
|
||||
setClientDHParamsMsgData = null;
|
||||
}
|
||||
|
||||
TLRPC.Set_client_DH_params_answer dhAnswer = (TLRPC.Set_client_DH_params_answer)message;
|
||||
|
||||
if (!Arrays.equals(authNonce, dhAnswer.nonce)) {
|
||||
if (!Utilities.arraysEquals(authNonce, 0, dhAnswer.nonce, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH answer nonce");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
}
|
||||
if (!Arrays.equals(authServerNonce, dhAnswer.server_nonce)) {
|
||||
if (!Utilities.arraysEquals(authServerNonce, 0, dhAnswer.server_nonce, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH answer server nonce");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
}
|
||||
|
||||
reqDHMsgData = null;
|
||||
if (reqDHMsgData != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(reqDHMsgData);
|
||||
reqDHMsgData = null;
|
||||
}
|
||||
|
||||
TLRPC.TL_msgs_ack msgsAck = new TLRPC.TL_msgs_ack();
|
||||
msgsAck.msg_ids = new ArrayList<Long>();
|
||||
@ -507,7 +532,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
|
||||
if (message instanceof TLRPC.TL_dh_gen_ok) {
|
||||
TLRPC.TL_dh_gen_ok dhGenOk = (TLRPC.TL_dh_gen_ok)message;
|
||||
if (!Arrays.equals(newNonceHash1, dhGenOk.new_nonce_hash1)) {
|
||||
if (!Utilities.arraysEquals(newNonceHash1, 0, dhGenOk.new_nonce_hash1, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH answer nonce hash 1");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
@ -532,7 +557,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
});
|
||||
} else if (message instanceof TLRPC.TL_dh_gen_retry) {
|
||||
TLRPC.TL_dh_gen_retry dhRetry = (TLRPC.TL_dh_gen_retry)message;
|
||||
if (!Arrays.equals(newNonceHash2, dhRetry.new_nonce_hash2)) {
|
||||
if (!Utilities.arraysEquals(newNonceHash2, 0, dhRetry.new_nonce_hash2, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH answer nonce hash 2");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
@ -541,7 +566,7 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
beginHandshake(false);
|
||||
} else if (message instanceof TLRPC.TL_dh_gen_fail) {
|
||||
TLRPC.TL_dh_gen_fail dhFail = (TLRPC.TL_dh_gen_fail)message;
|
||||
if (!Arrays.equals(newNonceHash3, dhFail.new_nonce_hash3)) {
|
||||
if (!Utilities.arraysEquals(newNonceHash3, 0, dhFail.new_nonce_hash3, 0)) {
|
||||
FileLog.e("tmessages", "***** Invalid DH answer nonce hash 3");
|
||||
beginHandshake(false);
|
||||
return;
|
||||
@ -560,11 +585,6 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tcpConnectionProgressChanged(TcpConnection connection, long messageId, int currentSize, int length) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tcpConnectionClosed(final TcpConnection connection) {
|
||||
wasDisconnect = true;
|
||||
@ -582,11 +602,11 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
return;
|
||||
}
|
||||
if (reqPQMsgData != null) {
|
||||
datacenter.connection.sendData(reqPQMsgData, null, false);
|
||||
datacenter.connection.sendData(reqPQMsgData, false, false);
|
||||
} else if (reqDHMsgData != null) {
|
||||
datacenter.connection.sendData(reqDHMsgData, null, false);
|
||||
datacenter.connection.sendData(reqDHMsgData, false, false);
|
||||
} else if (setClientDHParamsMsgData != null) {
|
||||
datacenter.connection.sendData(setClientDHParamsMsgData, null, false);
|
||||
datacenter.connection.sendData(setClientDHParamsMsgData, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,6 @@ public class RPCRequest {
|
||||
public interface RPCRequestDelegate {
|
||||
void run(TLObject response, TLRPC.TL_error error);
|
||||
}
|
||||
public interface RPCProgressDelegate {
|
||||
void progress(int length, int progress);
|
||||
}
|
||||
public interface RPCQuickAckDelegate {
|
||||
void quickAck();
|
||||
}
|
||||
@ -29,7 +26,6 @@ public class RPCRequest {
|
||||
public static int RPCRequestClassCanCompress = 32;
|
||||
public static int RPCRequestClassPush = 64;
|
||||
public static int RPCRequestClassWithoutLogin = 128;
|
||||
public static int RPCRequestClassDownloadMedia2 = 256;
|
||||
|
||||
static int RPCRequestClassTransportMask = (RPCRequestClassGeneric | RPCRequestClassDownloadMedia | RPCRequestClassUploadMedia);
|
||||
|
||||
@ -45,7 +41,6 @@ public class RPCRequest {
|
||||
int serializedLength;
|
||||
|
||||
RPCRequestDelegate completionBlock;
|
||||
RPCProgressDelegate progressBlock;
|
||||
RPCQuickAckDelegate quickAckBlock;
|
||||
|
||||
boolean requiresCompletion;
|
||||
|
@ -412,6 +412,14 @@ public class TLClassStore {
|
||||
classStore.put(TLRPC.TL_decryptedMessageActionFlushHistory.constructor, TLRPC.TL_decryptedMessageActionFlushHistory.class);
|
||||
classStore.put(TLRPC.TL_decryptedMessageActionScreenshotMessages.constructor, TLRPC.TL_decryptedMessageActionScreenshotMessages.class);
|
||||
classStore.put(TLRPC.TL_messageEcryptedAction.constructor, TLRPC.TL_messageEcryptedAction.class);
|
||||
classStore.put(TLRPC.TL_decryptedMessageActionNotifyLayer.constructor, TLRPC.TL_decryptedMessageActionNotifyLayer.class);
|
||||
classStore.put(TLRPC.TL_decryptedMessageActionReadMessages.constructor, TLRPC.TL_decryptedMessageActionReadMessages.class);
|
||||
classStore.put(TLRPC.TL_updateNotifySettings.constructor, TLRPC.TL_updateNotifySettings.class);
|
||||
classStore.put(TLRPC.TL_updateUserBlocked.constructor, TLRPC.TL_updateUserBlocked.class);
|
||||
classStore.put(TLRPC.TL_notifyAll.constructor, TLRPC.TL_notifyAll.class);
|
||||
classStore.put(TLRPC.TL_notifyChats.constructor, TLRPC.TL_notifyChats.class);
|
||||
classStore.put(TLRPC.TL_notifyUsers.constructor, TLRPC.TL_notifyUsers.class);
|
||||
classStore.put(TLRPC.TL_notifyPeer.constructor, TLRPC.TL_notifyPeer.class);
|
||||
|
||||
classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class);
|
||||
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);
|
||||
@ -427,6 +435,10 @@ public class TLClassStore {
|
||||
classStore.put(TLRPC.TL_messageActionLoginUnknownLocation.constructor, TLRPC.TL_messageActionLoginUnknownLocation.class);
|
||||
classStore.put(TLRPC.TL_encryptedChat_old.constructor, TLRPC.TL_encryptedChat_old.class);
|
||||
classStore.put(TLRPC.TL_encryptedChatRequested_old.constructor, TLRPC.TL_encryptedChatRequested_old.class);
|
||||
classStore.put(TLRPC.TL_decryptedMessageMediaVideo_old.constructor, TLRPC.TL_decryptedMessageMediaVideo_old.class);
|
||||
classStore.put(TLRPC.TL_decryptedMessageMediaAudio_old.constructor, TLRPC.TL_decryptedMessageMediaAudio_old.class);
|
||||
classStore.put(TLRPC.TL_audio_old.constructor, TLRPC.TL_audio_old.class);
|
||||
classStore.put(TLRPC.TL_video_old.constructor, TLRPC.TL_video_old.class);
|
||||
}
|
||||
|
||||
static TLClassStore store = null;
|
||||
|
@ -42,4 +42,10 @@ public class TLObject {
|
||||
public void freeResources() {
|
||||
|
||||
}
|
||||
|
||||
public int getObjectSize() {
|
||||
ByteBufferDesc bufferDesc = new ByteBufferDesc(true);
|
||||
serializeToStream(bufferDesc);
|
||||
return bufferDesc.length();
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,51 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class NotifyPeer extends TLObject {
|
||||
public Peer peer;
|
||||
}
|
||||
|
||||
public static class TL_notifyAll extends NotifyPeer {
|
||||
public static int constructor = 0x74d07c60;
|
||||
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_notifyChats extends NotifyPeer {
|
||||
public static int constructor = 0xc007cec3;
|
||||
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_notifyUsers extends NotifyPeer {
|
||||
public static int constructor = 0xb4c83b4c;
|
||||
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_notifyPeer extends NotifyPeer {
|
||||
public static int constructor = 0x9fd40bd8;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_auth_checkedPhone extends TLObject {
|
||||
public static int constructor = 0xe300cc3b;
|
||||
|
||||
@ -1245,7 +1290,7 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_audio extends Audio {
|
||||
public static int constructor = 0x427425e7;
|
||||
public static int constructor = 0xc7ac6496;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -1254,6 +1299,7 @@ public class TLRPC {
|
||||
user_id = stream.readInt32();
|
||||
date = stream.readInt32();
|
||||
duration = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
size = stream.readInt32();
|
||||
dc_id = stream.readInt32();
|
||||
}
|
||||
@ -1265,6 +1311,7 @@ public class TLRPC {
|
||||
stream.writeInt32(user_id);
|
||||
stream.writeInt32(date);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeString(mime_type);
|
||||
stream.writeInt32(size);
|
||||
stream.writeInt32(dc_id);
|
||||
}
|
||||
@ -2515,7 +2562,7 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_video extends Video {
|
||||
public static int constructor = 0x5a04a49f;
|
||||
public static int constructor = 0x388fa391;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -2525,6 +2572,7 @@ public class TLRPC {
|
||||
date = stream.readInt32();
|
||||
caption = stream.readString();
|
||||
duration = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
size = stream.readInt32();
|
||||
thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
dc_id = stream.readInt32();
|
||||
@ -2540,6 +2588,7 @@ public class TLRPC {
|
||||
stream.writeInt32(date);
|
||||
stream.writeString(caption);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeString(mime_type);
|
||||
stream.writeInt32(size);
|
||||
thumb.serializeToStream(stream);
|
||||
stream.writeInt32(dc_id);
|
||||
@ -2820,7 +2869,7 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_inputMediaUploadedThumbVideo extends InputMedia {
|
||||
public static int constructor = 0xe628a145;
|
||||
public static int constructor = 0x9912dabf;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -2829,6 +2878,7 @@ public class TLRPC {
|
||||
duration = stream.readInt32();
|
||||
w = stream.readInt32();
|
||||
h = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
@ -2838,6 +2888,7 @@ public class TLRPC {
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(w);
|
||||
stream.writeInt32(h);
|
||||
stream.writeString(mime_type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2856,23 +2907,25 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_inputMediaUploadedAudio extends InputMedia {
|
||||
public static int constructor = 0x61a6d436;
|
||||
public static int constructor = 0x4e498cab;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
file = (InputFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
duration = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
file.serializeToStream(stream);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeString(mime_type);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_inputMediaUploadedVideo extends InputMedia {
|
||||
public static int constructor = 0x4847d92a;
|
||||
public static int constructor = 0x133ad6f6;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -2880,6 +2933,7 @@ public class TLRPC {
|
||||
duration = stream.readInt32();
|
||||
w = stream.readInt32();
|
||||
h = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
@ -2888,6 +2942,7 @@ public class TLRPC {
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(w);
|
||||
stream.writeInt32(h);
|
||||
stream.writeString(mime_type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3209,9 +3264,10 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_contacts_importedContacts extends TLObject {
|
||||
public static int constructor = 0xd1cd0a4c;
|
||||
public static int constructor = 0xad524315;
|
||||
|
||||
public ArrayList<TL_importedContact> imported = new ArrayList<TL_importedContact>();
|
||||
public ArrayList<Long> retry_contacts = new ArrayList<Long>();
|
||||
public ArrayList<User> users = new ArrayList<User>();
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -3222,6 +3278,11 @@ public class TLRPC {
|
||||
}
|
||||
stream.readInt32();
|
||||
count = stream.readInt32();
|
||||
for (int a = 0; a < count; a++) {
|
||||
retry_contacts.add(stream.readInt64());
|
||||
}
|
||||
stream.readInt32();
|
||||
count = stream.readInt32();
|
||||
for (int a = 0; a < count; a++) {
|
||||
users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
|
||||
}
|
||||
@ -3236,6 +3297,12 @@ public class TLRPC {
|
||||
imported.get(a).serializeToStream(stream);
|
||||
}
|
||||
stream.writeInt32(0x1cb5c415);
|
||||
count = retry_contacts.size();
|
||||
stream.writeInt32(count);
|
||||
for (int a = 0; a < count; a++) {
|
||||
stream.writeInt64(retry_contacts.get(a));
|
||||
}
|
||||
stream.writeInt32(0x1cb5c415);
|
||||
count = users.size();
|
||||
stream.writeInt32(count);
|
||||
for (int a = 0; a < count; a++) {
|
||||
@ -3275,6 +3342,8 @@ public class TLRPC {
|
||||
public ArrayList<Integer> messages = new ArrayList<Integer>();
|
||||
public int pts;
|
||||
public int version;
|
||||
public NotifyPeer peer;
|
||||
public PeerNotifySettings notify_settings;
|
||||
public String first_name;
|
||||
public String last_name;
|
||||
public int qts;
|
||||
@ -3283,6 +3352,7 @@ public class TLRPC {
|
||||
public ArrayList<TL_dcOption> dc_options = new ArrayList<TL_dcOption>();
|
||||
public ChatParticipants participants;
|
||||
public EncryptedChat chat;
|
||||
public boolean blocked;
|
||||
public long auth_key_id;
|
||||
public String device;
|
||||
public String location;
|
||||
@ -3396,6 +3466,22 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_updateNotifySettings extends Update {
|
||||
public static int constructor = 0xbec268ef;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
peer = (NotifyPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
notify_settings.serializeToStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_updateUserTyping extends Update {
|
||||
public static int constructor = 0x6baa8508;
|
||||
|
||||
@ -3586,6 +3672,22 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_updateUserBlocked extends Update {
|
||||
public static int constructor = 0x80ece81a;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
user_id = stream.readInt32();
|
||||
blocked = stream.readBool();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt32(user_id);
|
||||
stream.writeBool(blocked);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_updateActivation extends Update {
|
||||
public static int constructor = 0x6f690963;
|
||||
|
||||
@ -3847,6 +3949,7 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class DecryptedMessageAction extends TLObject {
|
||||
public int layer;
|
||||
public int ttl_seconds;
|
||||
public ArrayList<Long> random_ids = new ArrayList<Long>();
|
||||
}
|
||||
@ -3872,6 +3975,43 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageActionNotifyLayer extends DecryptedMessageAction {
|
||||
public static int constructor = 0xf3048883;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
layer = stream.readInt32();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt32(layer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageActionReadMessages extends DecryptedMessageAction {
|
||||
public static int constructor = 0xc4f40be;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
stream.readInt32();
|
||||
int count = stream.readInt32();
|
||||
for (int a = 0; a < count; a++) {
|
||||
random_ids.add(stream.readInt64());
|
||||
}
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt32(0x1cb5c415);
|
||||
int count = random_ids.size();
|
||||
stream.writeInt32(count);
|
||||
for (Long random_id : random_ids) {
|
||||
stream.writeInt64(random_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class contacts_MyLink extends TLObject {
|
||||
public boolean contact;
|
||||
}
|
||||
@ -4497,11 +4637,12 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageMediaAudio extends DecryptedMessageMedia {
|
||||
public static int constructor = 0x6080758f;
|
||||
public static int constructor = 0x57e0a9cb;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
duration = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
size = stream.readInt32();
|
||||
key = stream.readByteArray();
|
||||
iv = stream.readByteArray();
|
||||
@ -4510,6 +4651,7 @@ public class TLRPC {
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeString(mime_type);
|
||||
stream.writeInt32(size);
|
||||
stream.writeByteArray(key);
|
||||
stream.writeByteArray(iv);
|
||||
@ -4517,7 +4659,7 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageMediaVideo extends DecryptedMessageMedia {
|
||||
public static int constructor = 0x4cee6ef3;
|
||||
public static int constructor = 0x524a415d;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
@ -4525,6 +4667,7 @@ public class TLRPC {
|
||||
thumb_w = stream.readInt32();
|
||||
thumb_h = stream.readInt32();
|
||||
duration = stream.readInt32();
|
||||
mime_type = stream.readString();
|
||||
w = stream.readInt32();
|
||||
h = stream.readInt32();
|
||||
size = stream.readInt32();
|
||||
@ -4538,6 +4681,7 @@ public class TLRPC {
|
||||
stream.writeInt32(thumb_w);
|
||||
stream.writeInt32(thumb_h);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeString(mime_type);
|
||||
stream.writeInt32(w);
|
||||
stream.writeInt32(h);
|
||||
stream.writeInt32(size);
|
||||
@ -6169,31 +6313,6 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_set_client_DH_params extends TLObject {
|
||||
public static int constructor = 0xf5045f1f;
|
||||
|
||||
public byte[] nonce;
|
||||
public byte[] server_nonce;
|
||||
public byte[] encrypted_data;
|
||||
|
||||
public Class responseClass () {
|
||||
return Set_client_DH_params_answer.class;
|
||||
}
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
nonce = stream.readData(16);
|
||||
server_nonce = stream.readData(16);
|
||||
encrypted_data = stream.readByteArray();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeRaw(nonce);
|
||||
stream.writeRaw(server_nonce);
|
||||
stream.writeByteArray(encrypted_data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_auth_checkPhone extends TLObject {
|
||||
public static int constructor = 0x6fe51dfb;
|
||||
|
||||
@ -8000,59 +8119,6 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_messages_sendEncrypted extends TLObject {
|
||||
public static int constructor = 0xa9776773;
|
||||
|
||||
public TL_inputEncryptedChat peer;
|
||||
public long random_id;
|
||||
public byte[] data;
|
||||
|
||||
public Class responseClass () {
|
||||
return messages_SentEncryptedMessage.class;
|
||||
}
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
peer = (TL_inputEncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
random_id = stream.readInt64();
|
||||
data = stream.readByteArray();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
stream.writeInt64(random_id);
|
||||
stream.writeByteArray(data);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_messages_sendEncryptedFile extends TLObject {
|
||||
public static int constructor = 0x9a901b66;
|
||||
|
||||
public TL_inputEncryptedChat peer;
|
||||
public long random_id;
|
||||
public byte[] data;
|
||||
public InputEncryptedFile file;
|
||||
|
||||
public Class responseClass () {
|
||||
return messages_SentEncryptedMessage.class;
|
||||
}
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
peer = (TL_inputEncryptedChat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
random_id = stream.readInt64();
|
||||
data = stream.readByteArray();
|
||||
file = (InputEncryptedFile)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
stream.writeInt64(random_id);
|
||||
stream.writeByteArray(data);
|
||||
file.serializeToStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_messages_sendEncryptedService extends TLObject {
|
||||
public static int constructor = 0x32d439a4;
|
||||
|
||||
@ -8080,6 +8146,98 @@ public class TLRPC {
|
||||
|
||||
//manually created
|
||||
|
||||
public static class TL_set_client_DH_params extends TLObject {
|
||||
public static int constructor = 0xf5045f1f;
|
||||
|
||||
public byte[] nonce;
|
||||
public byte[] server_nonce;
|
||||
public ByteBufferDesc encrypted_data;
|
||||
|
||||
public Class responseClass () {
|
||||
return Set_client_DH_params_answer.class;
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeRaw(nonce);
|
||||
stream.writeRaw(server_nonce);
|
||||
stream.writeByteBuffer(encrypted_data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeResources() {
|
||||
if (disableFree) {
|
||||
return;
|
||||
}
|
||||
if (encrypted_data != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(encrypted_data);
|
||||
encrypted_data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_messages_sendEncrypted extends TLObject {
|
||||
public static int constructor = 0xa9776773;
|
||||
|
||||
public TL_inputEncryptedChat peer;
|
||||
public long random_id;
|
||||
public ByteBufferDesc data;
|
||||
|
||||
public Class responseClass () {
|
||||
return messages_SentEncryptedMessage.class;
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
stream.writeInt64(random_id);
|
||||
stream.writeByteBuffer(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeResources() {
|
||||
if (disableFree) {
|
||||
return;
|
||||
}
|
||||
if (data != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(data);
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_messages_sendEncryptedFile extends TLObject {
|
||||
public static int constructor = 0x9a901b66;
|
||||
|
||||
public TL_inputEncryptedChat peer;
|
||||
public long random_id;
|
||||
public ByteBufferDesc data;
|
||||
public InputEncryptedFile file;
|
||||
|
||||
public Class responseClass () {
|
||||
return messages_SentEncryptedMessage.class;
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
peer.serializeToStream(stream);
|
||||
stream.writeInt64(random_id);
|
||||
stream.writeByteBuffer(data);
|
||||
file.serializeToStream(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void freeResources() {
|
||||
if (disableFree) {
|
||||
return;
|
||||
}
|
||||
if (data != null) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(data);
|
||||
data = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class UserStatus extends TLObject {
|
||||
public int expires;
|
||||
}
|
||||
@ -8313,6 +8471,7 @@ public class TLRPC {
|
||||
for (int a = 0; a < count; a++) {
|
||||
TL_futureSalt salt = new TL_futureSalt();
|
||||
salt.readParams(stream);
|
||||
salts.add(salt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8692,11 +8851,12 @@ public class TLRPC {
|
||||
}
|
||||
|
||||
public static class TL_dialog extends TLObject {
|
||||
public static int constructor = 0x214a8cdf;
|
||||
public static int constructor = 0xab3a99ac;
|
||||
|
||||
public Peer peer;
|
||||
public int top_message;
|
||||
public int unread_count;
|
||||
public PeerNotifySettings notify_settings;
|
||||
public int last_message_date;
|
||||
public long id;
|
||||
public int last_read;
|
||||
@ -8705,6 +8865,7 @@ public class TLRPC {
|
||||
peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
top_message = stream.readInt32();
|
||||
unread_count = stream.readInt32();
|
||||
notify_settings = (PeerNotifySettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
@ -8712,6 +8873,7 @@ public class TLRPC {
|
||||
peer.serializeToStream(stream);
|
||||
stream.writeInt32(top_message);
|
||||
stream.writeInt32(unread_count);
|
||||
notify_settings.serializeToStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8770,6 +8932,7 @@ public class TLRPC {
|
||||
public int date;
|
||||
public String caption;
|
||||
public int duration;
|
||||
public String mime_type;
|
||||
public int size;
|
||||
public PhotoSize thumb;
|
||||
public int dc_id;
|
||||
@ -8801,6 +8964,7 @@ public class TLRPC {
|
||||
public int user_id;
|
||||
public int date;
|
||||
public int duration;
|
||||
public String mime_type;
|
||||
public int size;
|
||||
public int dc_id;
|
||||
public String path;
|
||||
@ -8974,8 +9138,8 @@ public class TLRPC {
|
||||
}
|
||||
}
|
||||
|
||||
public static class invokeWithLayer12 extends TLObject {
|
||||
public static int constructor = 0xdda60d3c;
|
||||
public static class invokeWithLayer14 extends TLObject {
|
||||
public static int constructor = 0x2b9b08fa;
|
||||
|
||||
public TLObject query;
|
||||
|
||||
@ -9226,4 +9390,114 @@ public class TLRPC {
|
||||
public byte[] key;
|
||||
public byte[] iv;
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageMediaVideo_old extends TL_decryptedMessageMediaVideo {
|
||||
public static int constructor = 0x4cee6ef3;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
thumb = stream.readByteArray();
|
||||
thumb_w = stream.readInt32();
|
||||
thumb_h = stream.readInt32();
|
||||
duration = stream.readInt32();
|
||||
w = stream.readInt32();
|
||||
h = stream.readInt32();
|
||||
size = stream.readInt32();
|
||||
key = stream.readByteArray();
|
||||
iv = stream.readByteArray();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeByteArray(thumb);
|
||||
stream.writeInt32(thumb_w);
|
||||
stream.writeInt32(thumb_h);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(w);
|
||||
stream.writeInt32(h);
|
||||
stream.writeInt32(size);
|
||||
stream.writeByteArray(key);
|
||||
stream.writeByteArray(iv);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_decryptedMessageMediaAudio_old extends TL_decryptedMessageMediaAudio {
|
||||
public static int constructor = 0x6080758f;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
duration = stream.readInt32();
|
||||
size = stream.readInt32();
|
||||
key = stream.readByteArray();
|
||||
iv = stream.readByteArray();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(size);
|
||||
stream.writeByteArray(key);
|
||||
stream.writeByteArray(iv);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_audio_old extends TL_audio {
|
||||
public static int constructor = 0x427425e7;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
id = stream.readInt64();
|
||||
access_hash = stream.readInt64();
|
||||
user_id = stream.readInt32();
|
||||
date = stream.readInt32();
|
||||
duration = stream.readInt32();
|
||||
size = stream.readInt32();
|
||||
dc_id = stream.readInt32();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt64(id);
|
||||
stream.writeInt64(access_hash);
|
||||
stream.writeInt32(user_id);
|
||||
stream.writeInt32(date);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(size);
|
||||
stream.writeInt32(dc_id);
|
||||
}
|
||||
}
|
||||
|
||||
public static class TL_video_old extends TL_video {
|
||||
public static int constructor = 0x5a04a49f;
|
||||
|
||||
|
||||
public void readParams(AbsSerializedData stream) {
|
||||
id = stream.readInt64();
|
||||
access_hash = stream.readInt64();
|
||||
user_id = stream.readInt32();
|
||||
date = stream.readInt32();
|
||||
caption = stream.readString();
|
||||
duration = stream.readInt32();
|
||||
size = stream.readInt32();
|
||||
thumb = (PhotoSize)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
|
||||
dc_id = stream.readInt32();
|
||||
w = stream.readInt32();
|
||||
h = stream.readInt32();
|
||||
}
|
||||
|
||||
public void serializeToStream(AbsSerializedData stream) {
|
||||
stream.writeInt32(constructor);
|
||||
stream.writeInt64(id);
|
||||
stream.writeInt64(access_hash);
|
||||
stream.writeInt32(user_id);
|
||||
stream.writeInt32(date);
|
||||
stream.writeString(caption);
|
||||
stream.writeInt32(duration);
|
||||
stream.writeInt32(size);
|
||||
thumb.serializeToStream(stream);
|
||||
stream.writeInt32(dc_id);
|
||||
stream.writeInt32(w);
|
||||
stream.writeInt32(h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ public class TcpConnection extends ConnectionContext {
|
||||
public abstract void tcpConnectionConnected(TcpConnection connection);
|
||||
public abstract void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack);
|
||||
public abstract void tcpConnectionReceivedData(TcpConnection connection, ByteBufferDesc data, int length);
|
||||
public abstract void tcpConnectionProgressChanged(TcpConnection connection, long messageId, int currentSize, int length);
|
||||
}
|
||||
|
||||
private static PyroSelector selector;
|
||||
@ -46,7 +45,6 @@ public class TcpConnection extends ConnectionContext {
|
||||
private int failedConnectionCount;
|
||||
public TcpConnectionDelegate delegate;
|
||||
private ByteBufferDesc restOfTheData;
|
||||
private long lastMessageId = 0;
|
||||
private boolean hasSomeDataSinceLastConnect = false;
|
||||
private int willRetryConnectCount = 5;
|
||||
private boolean isNextPort = false;
|
||||
@ -284,8 +282,8 @@ public class TcpConnection extends ConnectionContext {
|
||||
connect();
|
||||
}
|
||||
|
||||
public void sendData(final byte[] data, final ByteBufferDesc buff, final boolean reportAck) {
|
||||
if (data == null && buff == null) {
|
||||
public void sendData(final ByteBufferDesc buff, final boolean canReuse, final boolean reportAck) {
|
||||
if (buff == null) {
|
||||
return;
|
||||
}
|
||||
selector.scheduleTask(new Runnable() {
|
||||
@ -298,16 +296,13 @@ public class TcpConnection extends ConnectionContext {
|
||||
}
|
||||
|
||||
if (client == null || client.isDisconnected()) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(buff);
|
||||
if (canReuse) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(buff);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int bufferLen = 0;
|
||||
if (data != null) {
|
||||
bufferLen = data.length;
|
||||
} else if (buff != null) {
|
||||
bufferLen = buff.limit();
|
||||
}
|
||||
int bufferLen = buff.limit();
|
||||
int packetLength = bufferLen / 4;
|
||||
|
||||
if (packetLength < 0x7f) {
|
||||
@ -336,10 +331,9 @@ public class TcpConnection extends ConnectionContext {
|
||||
}
|
||||
buffer.writeInt32(packetLength);
|
||||
}
|
||||
if (data != null) {
|
||||
buffer.writeRaw(data);
|
||||
} else {
|
||||
buffer.writeRaw(buff);
|
||||
|
||||
buffer.writeRaw(buff);
|
||||
if (canReuse) {
|
||||
BuffersStorage.getInstance().reuseFreeBuffer(buff);
|
||||
}
|
||||
|
||||
@ -389,19 +383,6 @@ public class TcpConnection extends ConnectionContext {
|
||||
buffer.limit(oldLimit);
|
||||
if (restOfTheData.position() != lastPacketLength) {
|
||||
//FileLog.e("tmessages", this + " don't get much data to restOfTheData");
|
||||
if (lastMessageId != -1 && lastMessageId != 0) {
|
||||
if (delegate != null) {
|
||||
final TcpConnectionDelegate finalDelegate = delegate;
|
||||
final int arg2 = restOfTheData.position();
|
||||
final int arg3 = lastPacketLength;
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalDelegate.tcpConnectionProgressChanged(TcpConnection.this, lastMessageId, arg2, arg3);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
//FileLog.e("tmessages", this + " get much data to restOfTheData - OK!");
|
||||
@ -424,7 +405,7 @@ public class TcpConnection extends ConnectionContext {
|
||||
datacenter.storeCurrentAddressAndPortNum();
|
||||
isNextPort = false;
|
||||
if ((transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
|
||||
client.setTimeout(60000 * 3 + 20000);
|
||||
client.setTimeout(60000 * 15);
|
||||
} else {
|
||||
client.setTimeout(25000);
|
||||
}
|
||||
@ -497,32 +478,10 @@ public class TcpConnection extends ConnectionContext {
|
||||
|
||||
if (currentPacketLength < buffer.remaining()) {
|
||||
FileLog.d("tmessages", TcpConnection.this + " Received message len " + currentPacketLength + " but packet larger " + buffer.remaining());
|
||||
lastMessageId = 0;
|
||||
} else if (currentPacketLength == buffer.remaining()) {
|
||||
FileLog.d("tmessages", TcpConnection.this + " Received message len " + currentPacketLength + " equal to packet size");
|
||||
lastMessageId = 0;
|
||||
} else {
|
||||
FileLog.d("tmessages", TcpConnection.this + " Received packet size less(" + buffer.remaining() + ") then message size(" + currentPacketLength + ")");
|
||||
if (buffer.remaining() >= 152 && (transportRequestClass & RPCRequest.RPCRequestClassDownloadMedia) != 0) {
|
||||
if (lastMessageId == 0) {
|
||||
byte[] temp = new byte[152];
|
||||
buffer.get(temp);
|
||||
lastMessageId = ConnectionsManager.getInstance().needsToDecodeMessageIdFromPartialData(TcpConnection.this, temp);
|
||||
}
|
||||
if (lastMessageId != -1 && lastMessageId != 0) {
|
||||
if (delegate != null) {
|
||||
final TcpConnectionDelegate finalDelegate = delegate;
|
||||
final int arg2 = buffer.remaining();
|
||||
final int arg3 = currentPacketLength;
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalDelegate.tcpConnectionProgressChanged(TcpConnection.this, lastMessageId, arg2, arg3);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByteBufferDesc reuseLater = null;
|
||||
int len = currentPacketLength + (fByte != 0x7f ? 1 : 4);
|
||||
|
@ -12,6 +12,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Base64;
|
||||
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
@ -197,6 +198,5 @@ public class UserConfig {
|
||||
contactsVersion = 1;
|
||||
saveIncomingPhotos = false;
|
||||
saveConfig(true);
|
||||
MessagesController.getInstance().deleteAllAppAccounts();
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,8 @@ import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
@ -27,16 +24,12 @@ import android.provider.MediaStore;
|
||||
import android.text.Html;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.util.Base64;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import net.hockeyapp.android.CrashManager;
|
||||
import net.hockeyapp.android.CrashManagerListener;
|
||||
import net.hockeyapp.android.UpdateManager;
|
||||
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -49,7 +42,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.MessageDigest;
|
||||
@ -59,7 +51,6 @@ import java.security.spec.RSAPublicKeySpec;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -69,16 +60,9 @@ import java.util.zip.GZIPOutputStream;
|
||||
import javax.crypto.Cipher;
|
||||
|
||||
public class Utilities {
|
||||
public static int statusBarHeight = 0;
|
||||
public static float density = 1;
|
||||
public static Point displaySize = new Point();
|
||||
public static Pattern pattern = Pattern.compile("[0-9]+");
|
||||
public static SecureRandom random = new SecureRandom();
|
||||
private final static Integer lock = 1;
|
||||
private static int prevOrientation = -10;
|
||||
|
||||
private static boolean waitingForSms = false;
|
||||
private static final Integer smsLock = 2;
|
||||
|
||||
public static ArrayList<String> goodPrimes = new ArrayList<String>();
|
||||
|
||||
@ -108,12 +92,8 @@ public class Utilities {
|
||||
R.drawable.group_blue,
|
||||
R.drawable.group_yellow};
|
||||
|
||||
public static int externalCacheNotAvailableState = 0;
|
||||
|
||||
final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
|
||||
|
||||
private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();
|
||||
|
||||
public static ProgressDialog progressDialog;
|
||||
|
||||
static {
|
||||
@ -128,7 +108,6 @@ public class Utilities {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
density = ApplicationLoader.applicationContext.getResources().getDisplayMetrics().density;
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("primes", Context.MODE_PRIVATE);
|
||||
String primes = preferences.getString("primes", null);
|
||||
if (primes == null) {
|
||||
@ -149,96 +128,14 @@ public class Utilities {
|
||||
goodPrimes.add("C71CAEB9C6B1C9048E6C522F70F13F73980D40238E3E21C14934D037563D930F48198A0AA7C14058229493D22530F4DBFA336F6E0AC925139543AED44CCE7C3720FD51F69458705AC68CD4FE6B6B13ABDC9746512969328454F18FAF8C595F642477FE96BB2A941D5BCD1D4AC8CC49880708FA9B378E3C4F3A9060BEE67CF9A4A4A695811051907E162753B56B0F6B410DBA74D8A84B2A14B3144E0EF1284754FD17ED950D5965B4B9DD46582DB1178D169C6BC465B0D6FF9CA3928FEF5B9AE4E418FC15E83EBEA0F87FA9FF5EED70050DED2849F47BF959D956850CE929851F0D8115F635B105EE2E4E15D04B2454BF6F4FADF034B10403119CD8E3B92FCC5B");
|
||||
}
|
||||
}
|
||||
|
||||
checkDisplaySize();
|
||||
}
|
||||
|
||||
public native static long doPQNative(long _what);
|
||||
public native static byte[] aesIgeEncryption(byte[] _what, byte[] _key, byte[] _iv, boolean encrypt, boolean changeIv, int len);
|
||||
public native static void aesIgeEncryption2(ByteBuffer _what, byte[] _key, byte[] _iv, boolean encrypt, boolean changeIv, int len);
|
||||
public native static void loadBitmap(String path, int[] bitmap, int scale, int format, int width, int height);
|
||||
private native static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, int offset, int length);
|
||||
|
||||
public static void lockOrientation(Activity activity) {
|
||||
if (prevOrientation != -10) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
prevOrientation = activity.getRequestedOrientation();
|
||||
WindowManager manager = (WindowManager)activity.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
int orientation = activity.getResources().getConfiguration().orientation;
|
||||
|
||||
if (rotation == Surface.ROTATION_270) {
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
if (orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_0) {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
} else {
|
||||
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unlockOrientation(Activity activity) {
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
activity.setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWaitingForSms() {
|
||||
boolean value = false;
|
||||
synchronized (smsLock) {
|
||||
value = waitingForSms;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void setWaitingForSms(boolean value) {
|
||||
synchronized (smsLock) {
|
||||
waitingForSms = value;
|
||||
}
|
||||
public static void aesIgeEncryption(ByteBuffer buffer, byte[] key, byte[] iv, boolean encrypt, boolean changeIv, int offset, int length) {
|
||||
aesIgeEncryption(buffer, key, changeIv ? iv : iv.clone(), encrypt, offset, length);
|
||||
}
|
||||
|
||||
public static Integer parseInt(String value) {
|
||||
@ -259,22 +156,6 @@ public class Utilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static File getCacheDir() {
|
||||
if (externalCacheNotAvailableState == 1 || externalCacheNotAvailableState == 0 && Environment.getExternalStorageState().startsWith(Environment.MEDIA_MOUNTED)) {
|
||||
externalCacheNotAvailableState = 1;
|
||||
File file = ApplicationLoader.applicationContext.getExternalCacheDir();
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
externalCacheNotAvailableState = 2;
|
||||
File file = ApplicationLoader.applicationContext.getCacheDir();
|
||||
if (file != null) {
|
||||
return file;
|
||||
}
|
||||
return new File("");
|
||||
}
|
||||
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
int v;
|
||||
@ -286,14 +167,6 @@ public class Utilities {
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static int dp(int value) {
|
||||
return (int)(Math.max(1, density * value));
|
||||
}
|
||||
|
||||
public static int dpf(float value) {
|
||||
return (int)Math.ceil(density * value);
|
||||
}
|
||||
|
||||
public static boolean isGoodPrime(byte[] prime, int g) {
|
||||
if (!(g >= 2 && g <= 7)) {
|
||||
return false;
|
||||
@ -401,6 +274,18 @@ public class Utilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean arraysEquals(byte[] arr1, int offset1, byte[] arr2, int offset2) {
|
||||
if (arr1 == null || arr2 == null || arr1.length - offset1 != arr2.length - offset2 || arr1.length - offset1 < 0) {
|
||||
return false;
|
||||
}
|
||||
for (int a = offset1; a < arr1.length; a++) {
|
||||
if (arr1[a + offset1] != arr2[a + offset2]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static byte[] computeSHA1(byte[] convertme, int offset, int len) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
@ -413,30 +298,29 @@ public class Utilities {
|
||||
}
|
||||
|
||||
public static byte[] computeSHA1(ByteBuffer convertme, int offset, int len) {
|
||||
int oldp = convertme.position();
|
||||
int oldl = convertme.limit();
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
int oldp = convertme.position();
|
||||
int oldl = convertme.limit();
|
||||
convertme.position(offset);
|
||||
convertme.limit(len);
|
||||
md.update(convertme);
|
||||
convertme.position(oldp);
|
||||
convertme.limit(oldl);
|
||||
return md.digest();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
} finally {
|
||||
convertme.limit(oldl);
|
||||
convertme.position(oldp);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] computeSHA1(ByteBuffer convertme) {
|
||||
return computeSHA1(convertme, 0, convertme.limit());
|
||||
}
|
||||
|
||||
public static byte[] computeSHA1(byte[] convertme) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-1");
|
||||
return md.digest(convertme);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return null;
|
||||
return computeSHA1(convertme, 0, convertme.length);
|
||||
}
|
||||
|
||||
public static byte[] encryptWithRSA(BigInteger[] key, byte[] data) {
|
||||
@ -453,26 +337,9 @@ public class Utilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static byte[] longToBytes(long x) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.putLong(x);
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
public static long bytesToLong(byte[] bytes) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(8);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put(bytes);
|
||||
buffer.flip();
|
||||
return buffer.getLong();
|
||||
}
|
||||
|
||||
public static int bytesToInt(byte[] bytes) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(4);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer.put(bytes);
|
||||
buffer.flip();
|
||||
return buffer.getInt();
|
||||
return ((long) bytes[7] << 56) + (((long) bytes[6] & 0xFF) << 48) + (((long) bytes[5] & 0xFF) << 40) + (((long) bytes[4] & 0xFF) << 32)
|
||||
+ (((long) bytes[3] & 0xFF) << 24) + (((long) bytes[2] & 0xFF) << 16) + (((long) bytes[1] & 0xFF) << 8) + ((long) bytes[0] & 0xFF);
|
||||
}
|
||||
|
||||
public static MessageKeyData generateMessageKeyData(byte[] authKey, byte[] messageKey, boolean incoming) {
|
||||
@ -562,51 +429,6 @@ public class Utilities {
|
||||
return packedData;
|
||||
}
|
||||
|
||||
public static Typeface getTypeface(String assetPath) {
|
||||
synchronized (cache) {
|
||||
if (!cache.containsKey(assetPath)) {
|
||||
try {
|
||||
Typeface t = Typeface.createFromAsset(ApplicationLoader.applicationContext.getAssets(),
|
||||
assetPath);
|
||||
cache.put(assetPath, t);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("Typefaces", "Could not get typeface '" + assetPath + "' because " + e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return cache.get(assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showKeyboard(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
InputMethodManager inputManager = (InputMethodManager)view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
|
||||
|
||||
((InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE)).showSoftInput(view, 0);
|
||||
}
|
||||
|
||||
public static boolean isKeyboardShowed(View view) {
|
||||
if (view == null) {
|
||||
return false;
|
||||
}
|
||||
InputMethodManager inputManager = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
return inputManager.isActive(view);
|
||||
}
|
||||
|
||||
public static void hideKeyboard(View view) {
|
||||
if (view == null) {
|
||||
return;
|
||||
}
|
||||
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (!imm.isActive()) {
|
||||
return;
|
||||
}
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
|
||||
public static void ShowProgressDialog(final Activity activity, final String message) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -624,25 +446,6 @@ public class Utilities {
|
||||
});
|
||||
}
|
||||
|
||||
public static void checkDisplaySize() {
|
||||
try {
|
||||
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
if (manager != null) {
|
||||
Display display = manager.getDefaultDisplay();
|
||||
if (display != null) {
|
||||
if(android.os.Build.VERSION.SDK_INT < 13) {
|
||||
displaySize.set(display.getWidth(), display.getHeight());
|
||||
} else {
|
||||
display.getSize(displaySize);
|
||||
}
|
||||
FileLog.e("tmessages", "display size = " + displaySize.x + " " + displaySize.y);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void HideProgressDialog(Activity activity) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
|
@ -16,12 +16,13 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.util.Linkify;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -68,7 +69,7 @@ public class MessageObject {
|
||||
textPaint.linkColor = 0xff316f9f;
|
||||
}
|
||||
|
||||
textPaint.setTextSize(Utilities.dp(MessagesController.getInstance().fontSize));
|
||||
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
|
||||
|
||||
messageOwner = message;
|
||||
|
||||
@ -271,7 +272,7 @@ public class MessageObject {
|
||||
} else {
|
||||
messageText = message.message;
|
||||
}
|
||||
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), Utilities.dp(20));
|
||||
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
|
||||
if (message instanceof TLRPC.TL_message || (message instanceof TLRPC.TL_messageForwarded && (message.media == null || !(message.media instanceof TLRPC.TL_messageMediaEmpty)))) {
|
||||
if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) {
|
||||
@ -397,9 +398,9 @@ public class MessageObject {
|
||||
|
||||
int maxWidth;
|
||||
if (messageOwner.to_id.chat_id != 0) {
|
||||
maxWidth = Math.min(Utilities.displaySize.x, Utilities.displaySize.y) - Utilities.dp(122);
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
|
||||
} else {
|
||||
maxWidth = Math.min(Utilities.displaySize.x, Utilities.displaySize.y) - Utilities.dp(80);
|
||||
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80);
|
||||
}
|
||||
|
||||
StaticLayout textLayout = null;
|
||||
@ -539,4 +540,18 @@ public class MessageObject {
|
||||
public boolean isFromMe() {
|
||||
return messageOwner.from_id == UserConfig.getClientUserId();
|
||||
}
|
||||
|
||||
public long getDialogId() {
|
||||
if (messageOwner.dialog_id != 0) {
|
||||
return messageOwner.dialog_id;
|
||||
} else {
|
||||
if (messageOwner.to_id.chat_id != 0) {
|
||||
return -messageOwner.to_id.chat_id;
|
||||
} else if (isFromMe()) {
|
||||
return messageOwner.to_id.user_id;
|
||||
} else {
|
||||
return messageOwner.from_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.SectionedBaseAdapter;
|
||||
|
@ -13,9 +13,9 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
|
@ -29,14 +29,15 @@ import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
||||
import com.google.android.gms.gcm.GoogleCloudMessaging;
|
||||
|
||||
import org.telegram.messenger.NotificationsService;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.NotificationsService;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NativeLoader;
|
||||
import org.telegram.messenger.ScreenReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NativeLoader;
|
||||
import org.telegram.android.ScreenReceiver;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
@ -57,6 +58,7 @@ public class ApplicationLoader extends Application {
|
||||
private static volatile boolean applicationInited = false;
|
||||
|
||||
public static volatile boolean isScreenOn = false;
|
||||
public static volatile boolean mainInterfacePaused = true;
|
||||
|
||||
public static void postInitApplication() {
|
||||
if (applicationInited) {
|
||||
@ -65,8 +67,6 @@ public class ApplicationLoader extends Application {
|
||||
|
||||
applicationInited = true;
|
||||
|
||||
NativeLoader.initNativeLibs(applicationContext);
|
||||
|
||||
try {
|
||||
LocaleController.getInstance();
|
||||
} catch (Exception e) {
|
||||
@ -134,6 +134,7 @@ public class ApplicationLoader extends Application {
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
applicationContext = getApplicationContext();
|
||||
NativeLoader.initNativeLibs(ApplicationLoader.applicationContext);
|
||||
|
||||
applicationHandler = new Handler(applicationContext.getMainLooper());
|
||||
|
||||
@ -177,7 +178,7 @@ public class ApplicationLoader extends Application {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
try {
|
||||
LocaleController.getInstance().onDeviceConfigurationChange(newConfig);
|
||||
Utilities.checkDisplaySize();
|
||||
AndroidUtilities.checkDisplaySize();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
@ -30,7 +30,6 @@ import org.telegram.ui.Views.ProgressView;
|
||||
import org.telegram.ui.Views.SeekBar;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelegate, MediaController.FileDownloadProgressListener {
|
||||
|
||||
@ -90,7 +89,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
statesDrawable[7][1] = getResources().getDrawable(R.drawable.audiocancel2_pressed);
|
||||
|
||||
timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
timePaint.setTextSize(Utilities.dp(12));
|
||||
timePaint.setTextSize(AndroidUtilities.dp(12));
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +114,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
}
|
||||
invalidate();
|
||||
} else {
|
||||
int side = Utilities.dp(36);
|
||||
int side = AndroidUtilities.dp(36);
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) {
|
||||
buttonPressed = 1;
|
||||
@ -220,7 +219,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
|
||||
public void updateButtonState() {
|
||||
String fileName = currentMessageObject.getFileName();
|
||||
File cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
File cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
if (cacheFile.exists()) {
|
||||
MediaController.getInstance().removeLoadingFileObserver(this);
|
||||
boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject);
|
||||
@ -286,11 +285,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
setMeasuredDimension(width, Utilities.dp(68));
|
||||
setMeasuredDimension(width, AndroidUtilities.dp(68));
|
||||
if (isChat) {
|
||||
backgroundWidth = Math.min(width - Utilities.dp(102), Utilities.dp(300));
|
||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(102), AndroidUtilities.dp(300));
|
||||
} else {
|
||||
backgroundWidth = Math.min(width - Utilities.dp(50), Utilities.dp(300));
|
||||
backgroundWidth = Math.min(width - AndroidUtilities.dp(50), AndroidUtilities.dp(300));
|
||||
}
|
||||
}
|
||||
|
||||
@ -299,33 +298,33 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (currentMessageObject.isOut()) {
|
||||
avatarImage.imageX = layoutWidth - backgroundWidth + Utilities.dp(9);
|
||||
seekBarX = layoutWidth - backgroundWidth + Utilities.dp(97);
|
||||
buttonX = layoutWidth - backgroundWidth + Utilities.dp(67);
|
||||
timeX = layoutWidth - backgroundWidth + Utilities.dp(71);
|
||||
avatarImage.imageX = layoutWidth - backgroundWidth + AndroidUtilities.dp(9);
|
||||
seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(97);
|
||||
buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67);
|
||||
timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(71);
|
||||
} else {
|
||||
if (isChat) {
|
||||
avatarImage.imageX = Utilities.dp(69);
|
||||
seekBarX = Utilities.dp(158);
|
||||
buttonX = Utilities.dp(128);
|
||||
timeX = Utilities.dp(132);
|
||||
avatarImage.imageX = AndroidUtilities.dp(69);
|
||||
seekBarX = AndroidUtilities.dp(158);
|
||||
buttonX = AndroidUtilities.dp(128);
|
||||
timeX = AndroidUtilities.dp(132);
|
||||
} else {
|
||||
avatarImage.imageX = Utilities.dp(16);
|
||||
seekBarX = Utilities.dp(106);
|
||||
buttonX = Utilities.dp(76);
|
||||
timeX = Utilities.dp(80);
|
||||
avatarImage.imageX = AndroidUtilities.dp(16);
|
||||
seekBarX = AndroidUtilities.dp(106);
|
||||
buttonX = AndroidUtilities.dp(76);
|
||||
timeX = AndroidUtilities.dp(80);
|
||||
}
|
||||
}
|
||||
avatarImage.imageY = Utilities.dp(9);
|
||||
avatarImage.imageW = Utilities.dp(50);
|
||||
avatarImage.imageH = Utilities.dp(50);
|
||||
avatarImage.imageY = AndroidUtilities.dp(9);
|
||||
avatarImage.imageW = AndroidUtilities.dp(50);
|
||||
avatarImage.imageH = AndroidUtilities.dp(50);
|
||||
|
||||
seekBar.width = backgroundWidth - Utilities.dp(112);
|
||||
seekBar.height = Utilities.dp(30);
|
||||
progressView.width = backgroundWidth - Utilities.dp(136);
|
||||
progressView.height = Utilities.dp(30);
|
||||
seekBarY = Utilities.dp(13);
|
||||
buttonY = Utilities.dp(10);
|
||||
seekBar.width = backgroundWidth - AndroidUtilities.dp(112);
|
||||
seekBar.height = AndroidUtilities.dp(30);
|
||||
progressView.width = backgroundWidth - AndroidUtilities.dp(136);
|
||||
progressView.height = AndroidUtilities.dp(30);
|
||||
seekBarY = AndroidUtilities.dp(13);
|
||||
buttonY = AndroidUtilities.dp(10);
|
||||
|
||||
updateProgress();
|
||||
}
|
||||
@ -380,14 +379,14 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
return;
|
||||
}
|
||||
|
||||
avatarImage.draw(canvas, avatarImage.imageX, avatarImage.imageY, Utilities.dp(50), Utilities.dp(50));
|
||||
avatarImage.draw(canvas, avatarImage.imageX, avatarImage.imageY, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
||||
|
||||
canvas.save();
|
||||
if (buttonState == 0 || buttonState == 1) {
|
||||
canvas.translate(seekBarX, seekBarY);
|
||||
seekBar.draw(canvas);
|
||||
} else {
|
||||
canvas.translate(seekBarX + Utilities.dp(12), seekBarY);
|
||||
canvas.translate(seekBarX + AndroidUtilities.dp(12), seekBarY);
|
||||
progressView.draw(canvas);
|
||||
}
|
||||
canvas.restore();
|
||||
@ -400,14 +399,14 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
timePaint.setColor(0xff70b15c);
|
||||
}
|
||||
Drawable buttonDrawable = statesDrawable[state][buttonPressed];
|
||||
int side = Utilities.dp(36);
|
||||
int side = AndroidUtilities.dp(36);
|
||||
int x = (side - buttonDrawable.getIntrinsicWidth()) / 2;
|
||||
int y = (side - buttonDrawable.getIntrinsicHeight()) / 2;
|
||||
setDrawableBounds(buttonDrawable, x + buttonX, y + buttonY);
|
||||
buttonDrawable.draw(canvas);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX, Utilities.dp(45));
|
||||
canvas.translate(timeX, AndroidUtilities.dp(45));
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -22,9 +22,10 @@ import android.view.MotionEvent;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.ViewConfiguration;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
@ -176,22 +177,22 @@ public class ChatBaseCell extends BaseCell {
|
||||
mediaBackgroundDrawable = getResources().getDrawable(R.drawable.phototime);
|
||||
|
||||
timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
timePaintIn.setTextSize(Utilities.dp(12));
|
||||
timePaintIn.setTextSize(AndroidUtilities.dp(12));
|
||||
timePaintIn.setColor(0xffa1aab3);
|
||||
|
||||
timePaintOut = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
timePaintOut.setTextSize(Utilities.dp(12));
|
||||
timePaintOut.setTextSize(AndroidUtilities.dp(12));
|
||||
timePaintOut.setColor(0xff70b15c);
|
||||
|
||||
timeMediaPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
timeMediaPaint.setTextSize(Utilities.dp(12));
|
||||
timeMediaPaint.setTextSize(AndroidUtilities.dp(12));
|
||||
timeMediaPaint.setColor(0xffffffff);
|
||||
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(Utilities.dp(15));
|
||||
namePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
|
||||
forwardNamePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
forwardNamePaint.setTextSize(Utilities.dp(14));
|
||||
forwardNamePaint.setTextSize(AndroidUtilities.dp(14));
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,11 +287,11 @@ public class ChatBaseCell extends BaseCell {
|
||||
currentNameString = Utilities.formatName(currentUser.first_name, currentUser.last_name);
|
||||
nameWidth = getMaxNameWidth();
|
||||
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - Utilities.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);
|
||||
if (nameLayout.getLineCount() > 0) {
|
||||
nameWidth = (int)Math.ceil(nameLayout.getLineWidth(0));
|
||||
namesOffset += Utilities.dp(18);
|
||||
namesOffset += AndroidUtilities.dp(18);
|
||||
nameOffsetX = nameLayout.getLineLeft(0);
|
||||
} else {
|
||||
nameWidth = 0;
|
||||
@ -308,12 +309,12 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
forwardedNameWidth = getMaxNameWidth();
|
||||
|
||||
CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - Utilities.dp(40), TextUtils.TruncateAt.END);
|
||||
CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END);
|
||||
str = Html.fromHtml(String.format("%s<br>%s <b>%s</b>", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str));
|
||||
forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (forwardedNameLayout.getLineCount() > 1) {
|
||||
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1)));
|
||||
namesOffset += Utilities.dp(36);
|
||||
namesOffset += AndroidUtilities.dp(36);
|
||||
forwardNameOffsetX = Math.min(forwardedNameLayout.getLineLeft(0), forwardedNameLayout.getLineLeft(1));
|
||||
} else {
|
||||
forwardedNameWidth = 0;
|
||||
@ -337,7 +338,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
|
||||
protected int getMaxNameWidth() {
|
||||
return backgroundWidth - Utilities.dp(8);
|
||||
return backgroundWidth - AndroidUtilities.dp(8);
|
||||
}
|
||||
|
||||
protected void startCheckLongPress() {
|
||||
@ -372,7 +373,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
avatarPressed = true;
|
||||
result = true;
|
||||
} else if (drawForwardedName && forwardedNameLayout != null) {
|
||||
if (x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + Utilities.dp(32)) {
|
||||
if (x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + AndroidUtilities.dp(32)) {
|
||||
forwardNamePressed = true;
|
||||
result = true;
|
||||
}
|
||||
@ -409,7 +410,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
forwardNamePressed = false;
|
||||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (!(x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + Utilities.dp(32))) {
|
||||
if (!(x >= forwardNameX && x <= forwardNameX + forwardedNameWidth && y >= forwardNameY && y <= forwardNameY + AndroidUtilities.dp(32))) {
|
||||
forwardNamePressed = false;
|
||||
}
|
||||
}
|
||||
@ -433,23 +434,23 @@ public class ChatBaseCell extends BaseCell {
|
||||
timeLayout = new StaticLayout(currentTimeString, currentTimePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (!media) {
|
||||
if (!currentMessageObject.isOut()) {
|
||||
timeX = backgroundWidth - Utilities.dp(9) - timeWidth + (isChat ? Utilities.dp(52) : 0);
|
||||
timeX = backgroundWidth - AndroidUtilities.dp(9) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
} else {
|
||||
timeX = layoutWidth - timeWidth - Utilities.dpf(38.5f);
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dpf(38.5f);
|
||||
}
|
||||
} else {
|
||||
if (!currentMessageObject.isOut()) {
|
||||
timeX = backgroundWidth - Utilities.dp(4) - timeWidth + (isChat ? Utilities.dp(52) : 0);
|
||||
timeX = backgroundWidth - AndroidUtilities.dp(4) - timeWidth + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
} else {
|
||||
timeX = layoutWidth - timeWidth - Utilities.dpf(42.0f);
|
||||
timeX = layoutWidth - timeWidth - AndroidUtilities.dpf(42.0f);
|
||||
}
|
||||
}
|
||||
|
||||
if (isAvatarVisible) {
|
||||
avatarImage.imageX = Utilities.dp(6);
|
||||
avatarImage.imageY = layoutHeight - Utilities.dp(45);
|
||||
avatarImage.imageW = Utilities.dp(42);
|
||||
avatarImage.imageH = Utilities.dp(42);
|
||||
avatarImage.imageX = AndroidUtilities.dp(6);
|
||||
avatarImage.imageY = layoutHeight - AndroidUtilities.dp(45);
|
||||
avatarImage.imageW = AndroidUtilities.dp(42);
|
||||
avatarImage.imageH = AndroidUtilities.dp(42);
|
||||
}
|
||||
|
||||
wasLayout = true;
|
||||
@ -473,7 +474,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (isAvatarVisible) {
|
||||
avatarImage.draw(canvas, Utilities.dp(6), layoutHeight - Utilities.dp(45), Utilities.dp(42), Utilities.dp(42));
|
||||
avatarImage.draw(canvas, AndroidUtilities.dp(6), layoutHeight - AndroidUtilities.dp(45), AndroidUtilities.dp(42), AndroidUtilities.dp(42));
|
||||
}
|
||||
|
||||
Drawable currentBackgroundDrawable = null;
|
||||
@ -491,7 +492,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
currentBackgroundDrawable = backgroundMediaDrawableOut;
|
||||
}
|
||||
}
|
||||
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : Utilities.dp(9)), Utilities.dp(1), backgroundWidth, layoutHeight - Utilities.dp(2));
|
||||
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
||||
} else {
|
||||
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed) {
|
||||
if (!media) {
|
||||
@ -507,9 +508,9 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
if (isChat) {
|
||||
setDrawableBounds(currentBackgroundDrawable, Utilities.dp(52 + (!media ? 0 : 9)), Utilities.dp(1), backgroundWidth, layoutHeight - Utilities.dp(2));
|
||||
setDrawableBounds(currentBackgroundDrawable, AndroidUtilities.dp(52 + (!media ? 0 : 9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
||||
} else {
|
||||
setDrawableBounds(currentBackgroundDrawable, (!media ? 0 : Utilities.dp(9)), Utilities.dp(1), backgroundWidth, layoutHeight - Utilities.dp(2));
|
||||
setDrawableBounds(currentBackgroundDrawable, (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
|
||||
}
|
||||
}
|
||||
currentBackgroundDrawable.draw(canvas);
|
||||
@ -518,7 +519,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
if (drawName && nameLayout != null) {
|
||||
canvas.save();
|
||||
canvas.translate(currentBackgroundDrawable.getBounds().left + Utilities.dp(19) - nameOffsetX, Utilities.dp(10));
|
||||
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
|
||||
namePaint.setColor(Utilities.getColorForId(currentUser.id));
|
||||
nameLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
@ -528,12 +529,12 @@ public class ChatBaseCell extends BaseCell {
|
||||
canvas.save();
|
||||
if (currentMessageObject.isOut()) {
|
||||
forwardNamePaint.setColor(0xff4a923c);
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + Utilities.dp(10);
|
||||
forwardNameY = Utilities.dp(10 + (drawName ? 18 : 0));
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
|
||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
||||
} else {
|
||||
forwardNamePaint.setColor(0xff006fc8);
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + Utilities.dp(19);
|
||||
forwardNameY = Utilities.dp(10 + (drawName ? 18 : 0));
|
||||
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
|
||||
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 18 : 0));
|
||||
}
|
||||
canvas.translate(forwardNameX - forwardNameOffsetX, forwardNameY);
|
||||
forwardedNameLayout.draw(canvas);
|
||||
@ -542,16 +543,16 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
if (drawTime) {
|
||||
if (media) {
|
||||
setDrawableBounds(mediaBackgroundDrawable, timeX - Utilities.dp(3), layoutHeight - Utilities.dpf(27.5f), timeWidth + Utilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), Utilities.dpf(16.5f));
|
||||
setDrawableBounds(mediaBackgroundDrawable, timeX - AndroidUtilities.dp(3), layoutHeight - AndroidUtilities.dpf(27.5f), timeWidth + AndroidUtilities.dp(6 + (currentMessageObject.isOut() ? 20 : 0)), AndroidUtilities.dpf(16.5f));
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(timeX, layoutHeight - Utilities.dpf(12.0f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dpf(12.0f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
canvas.save();
|
||||
canvas.translate(timeX, layoutHeight - Utilities.dpf(6.5f) - timeLayout.getHeight());
|
||||
canvas.translate(timeX, layoutHeight - AndroidUtilities.dpf(6.5f) - timeLayout.getHeight());
|
||||
timeLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
@ -586,45 +587,45 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
if (drawClock) {
|
||||
if (!media) {
|
||||
setDrawableBounds(clockDrawable, layoutWidth - Utilities.dpf(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(8.5f) - clockDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - clockDrawable.getIntrinsicHeight());
|
||||
clockDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(clockMediaDrawable, layoutWidth - Utilities.dpf(22.0f) - clockMediaDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(13.0f) - clockMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(clockMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - clockMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - clockMediaDrawable.getIntrinsicHeight());
|
||||
clockMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
if (drawCheck2) {
|
||||
if (!media) {
|
||||
if (drawCheck1) {
|
||||
setDrawableBounds(checkDrawable, layoutWidth - Utilities.dpf(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
} else {
|
||||
setDrawableBounds(checkDrawable, layoutWidth - Utilities.dpf(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dpf(18.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - checkDrawable.getIntrinsicHeight());
|
||||
}
|
||||
checkDrawable.draw(canvas);
|
||||
} else {
|
||||
if (drawCheck1) {
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - Utilities.dpf(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(26.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
} else {
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - Utilities.dpf(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(checkMediaDrawable, layoutWidth - AndroidUtilities.dpf(22.0f) - checkMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - checkMediaDrawable.getIntrinsicHeight());
|
||||
}
|
||||
checkMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
if (drawCheck1) {
|
||||
if (!media) {
|
||||
setDrawableBounds(halfCheckDrawable, layoutWidth - Utilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(8.5f) - halfCheckDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(8.5f) - halfCheckDrawable.getIntrinsicHeight());
|
||||
halfCheckDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - Utilities.dpf(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(halfCheckMediaDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - halfCheckMediaDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(13.0f) - halfCheckMediaDrawable.getIntrinsicHeight());
|
||||
halfCheckMediaDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
if (drawError) {
|
||||
if (!media) {
|
||||
setDrawableBounds(errorDrawable, layoutWidth - Utilities.dp(18) - errorDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(6.5f) - errorDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dp(18) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(6.5f) - errorDrawable.getIntrinsicHeight());
|
||||
errorDrawable.draw(canvas);
|
||||
} else {
|
||||
setDrawableBounds(errorDrawable, layoutWidth - Utilities.dpf(20.5f) - errorDrawable.getIntrinsicWidth(), layoutHeight - Utilities.dpf(12.5f) - errorDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(errorDrawable, layoutWidth - AndroidUtilities.dpf(20.5f) - errorDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dpf(12.5f) - errorDrawable.getIntrinsicHeight());
|
||||
errorDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,12 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
@ -34,7 +34,6 @@ import org.telegram.ui.Views.ImageReceiver;
|
||||
import org.telegram.ui.Views.ProgressView;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
||||
@ -96,7 +95,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
infoPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
infoPaint.setColor(0xffffffff);
|
||||
infoPaint.setTextSize(Utilities.dp(12));
|
||||
infoPaint.setTextSize(AndroidUtilities.dp(12));
|
||||
}
|
||||
|
||||
TAG = MediaController.getInstance().generateObserverTag();
|
||||
@ -136,7 +135,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
float y = event.getY();
|
||||
|
||||
boolean result = false;
|
||||
int side = Utilities.dp(44);
|
||||
int side = AndroidUtilities.dp(44);
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (delegate == null || delegate.canPerformActions()) {
|
||||
if (buttonState != -1 && x >= buttonX && x <= buttonX + side && y >= buttonY && y <= buttonY + side) {
|
||||
@ -285,7 +284,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
double lat = object.messageOwner.media.geo.lat;
|
||||
double lon = object.messageOwner.media.geo._long;
|
||||
String url = String.format(Locale.US, "https://maps.googleapis.com/maps/api/staticmap?center=%f,%f&zoom=13&size=100x100&maptype=roadmap&scale=%d&markers=color:red|size:big|%f,%f&sensor=false", lat, lon, Math.min(2, (int)Math.ceil(Utilities.density)), lat, lon);
|
||||
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);
|
||||
if (!url.equals(currentUrl)) {
|
||||
return true;
|
||||
}
|
||||
@ -293,7 +292,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
return true;
|
||||
} else if (currentPhotoObject != null && photoNotSet) {
|
||||
String fileName = MessageObject.getAttachFileName(currentPhotoObject.photoOwner);
|
||||
File cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
File cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
if (cacheFile.exists()) {
|
||||
return true;
|
||||
}
|
||||
@ -330,7 +329,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
String str = String.format("%d:%02d, %s", minutes, seconds, Utilities.formatFileSize(messageObject.messageOwner.media.video.size));
|
||||
if (currentInfoString == null || !currentInfoString.equals(str)) {
|
||||
currentInfoString = str;
|
||||
infoOffset = videoIconDrawable.getIntrinsicWidth() + Utilities.dp(4);
|
||||
infoOffset = videoIconDrawable.getIntrinsicWidth() + AndroidUtilities.dp(4);
|
||||
infoWidth = (int) Math.ceil(infoPaint.measureText(currentInfoString));
|
||||
infoLayout = new StaticLayout(currentInfoString, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
}
|
||||
@ -340,17 +339,17 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
|
||||
if (messageObject.type == 4) {
|
||||
photoWidth = Utilities.dp(100);
|
||||
photoHeight = Utilities.dp(100);
|
||||
backgroundWidth = photoWidth + Utilities.dp(12);
|
||||
photoWidth = AndroidUtilities.dp(100);
|
||||
photoHeight = AndroidUtilities.dp(100);
|
||||
backgroundWidth = photoWidth + AndroidUtilities.dp(12);
|
||||
|
||||
double lat = messageObject.messageOwner.media.geo.lat;
|
||||
double lon = messageObject.messageOwner.media.geo._long;
|
||||
currentUrl = 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(Utilities.density)), lat, lon);
|
||||
currentUrl = 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);
|
||||
photoImage.setImage(currentUrl, null, messageObject.isOut() ? placeholderOutDrawable : placeholderInDrawable);
|
||||
} else {
|
||||
photoWidth = (int) (Math.min(Utilities.displaySize.x, Utilities.displaySize.y) * 0.7f);
|
||||
photoHeight = photoWidth + Utilities.dp(100);
|
||||
photoWidth = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.7f);
|
||||
photoHeight = photoWidth + AndroidUtilities.dp(100);
|
||||
|
||||
if (photoWidth > 800) {
|
||||
photoWidth = 800;
|
||||
@ -367,35 +366,35 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
int h = (int) (currentPhotoObject.photoOwner.h / scale);
|
||||
if (w == 0) {
|
||||
if (messageObject.type == 3) {
|
||||
w = infoWidth + infoOffset + Utilities.dp(16);
|
||||
w = infoWidth + infoOffset + AndroidUtilities.dp(16);
|
||||
} else {
|
||||
w = Utilities.dp(100);
|
||||
w = AndroidUtilities.dp(100);
|
||||
}
|
||||
}
|
||||
if (h == 0) {
|
||||
h = Utilities.dp(100);
|
||||
h = AndroidUtilities.dp(100);
|
||||
}
|
||||
if (h > photoHeight) {
|
||||
float scale2 = h;
|
||||
h = photoHeight;
|
||||
scale2 /= h;
|
||||
w = (int) (w / scale2);
|
||||
} else if (h < Utilities.dp(120)) {
|
||||
h = Utilities.dp(120);
|
||||
} else if (h < AndroidUtilities.dp(120)) {
|
||||
h = AndroidUtilities.dp(120);
|
||||
float hScale = (float) currentPhotoObject.photoOwner.h / h;
|
||||
if (currentPhotoObject.photoOwner.w / hScale < photoWidth) {
|
||||
w = (int) (currentPhotoObject.photoOwner.w / hScale);
|
||||
}
|
||||
}
|
||||
int timeWidthTotal = timeWidth + Utilities.dp(14 + (currentMessageObject.isOut() ? 20 : 0));
|
||||
int timeWidthTotal = timeWidth + AndroidUtilities.dp(14 + (currentMessageObject.isOut() ? 20 : 0));
|
||||
if (w < timeWidthTotal) {
|
||||
w = timeWidthTotal;
|
||||
}
|
||||
|
||||
photoWidth = w;
|
||||
photoHeight = h;
|
||||
backgroundWidth = w + Utilities.dp(12);
|
||||
currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / Utilities.density), (int) (h / Utilities.density));
|
||||
backgroundWidth = w + AndroidUtilities.dp(12);
|
||||
currentPhotoFilter = String.format(Locale.US, "%d_%d", (int) (w / AndroidUtilities.density), (int) (h / AndroidUtilities.density));
|
||||
|
||||
if (currentPhotoObject.image != null) {
|
||||
photoImage.setImageBitmap(currentPhotoObject.image);
|
||||
@ -403,7 +402,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
boolean photoExist = true;
|
||||
String fileName = MessageObject.getAttachFileName(currentPhotoObject.photoOwner);
|
||||
if (messageObject.type == 1) {
|
||||
File cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
File cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
if (!cacheFile.exists()) {
|
||||
photoExist = false;
|
||||
} else {
|
||||
@ -447,7 +446,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
return;
|
||||
}
|
||||
fileName = MessageObject.getAttachFileName(currentPhotoObject.photoOwner);
|
||||
cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
} else if (currentMessageObject.type == 8 || currentMessageObject.type == 3) {
|
||||
if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() != 0) {
|
||||
File f = new File(currentMessageObject.messageOwner.attachPath);
|
||||
@ -458,7 +457,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
if (fileName == null) {
|
||||
fileName = currentMessageObject.getFileName();
|
||||
cacheFile = new File(Utilities.getCacheDir(), fileName);
|
||||
cacheFile = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
}
|
||||
}
|
||||
if (fileName == null) {
|
||||
@ -525,7 +524,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + Utilities.dp(14));
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), photoHeight + AndroidUtilities.dp(14));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -533,23 +532,23 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (currentMessageObject.isOut()) {
|
||||
photoImage.imageX = layoutWidth - backgroundWidth - Utilities.dp(3);
|
||||
photoImage.imageX = layoutWidth - backgroundWidth - AndroidUtilities.dp(3);
|
||||
} else {
|
||||
if (isChat) {
|
||||
photoImage.imageX = Utilities.dp(67);
|
||||
photoImage.imageX = AndroidUtilities.dp(67);
|
||||
} else {
|
||||
photoImage.imageX = Utilities.dp(15);
|
||||
photoImage.imageX = AndroidUtilities.dp(15);
|
||||
}
|
||||
}
|
||||
photoImage.imageY = Utilities.dp(7);
|
||||
photoImage.imageY = AndroidUtilities.dp(7);
|
||||
photoImage.imageW = photoWidth;
|
||||
photoImage.imageH = photoHeight;
|
||||
|
||||
progressView.width = timeX - photoImage.imageX - Utilities.dpf(23.0f);
|
||||
progressView.height = Utilities.dp(3);
|
||||
progressView.progressHeight = Utilities.dp(3);
|
||||
progressView.width = timeX - photoImage.imageX - AndroidUtilities.dpf(23.0f);
|
||||
progressView.height = AndroidUtilities.dp(3);
|
||||
progressView.progressHeight = AndroidUtilities.dp(3);
|
||||
|
||||
int size = Utilities.dp(44);
|
||||
int size = AndroidUtilities.dp(44);
|
||||
buttonX = (int)(photoImage.imageX + (photoWidth - size) / 2.0f);
|
||||
buttonY = (int)(photoImage.imageY + (photoHeight - size) / 2.0f);
|
||||
}
|
||||
@ -568,11 +567,11 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
|
||||
if (progressVisible) {
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + Utilities.dp(4), layoutHeight - Utilities.dpf(27.5f), progressView.width + Utilities.dp(12), Utilities.dpf(16.5f));
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), layoutHeight - AndroidUtilities.dpf(27.5f), progressView.width + AndroidUtilities.dp(12), AndroidUtilities.dpf(16.5f));
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.imageX + Utilities.dp(10), layoutHeight - Utilities.dpf(21.0f));
|
||||
canvas.translate(photoImage.imageX + AndroidUtilities.dp(10), layoutHeight - AndroidUtilities.dpf(21.0f));
|
||||
progressView.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
@ -584,16 +583,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}
|
||||
|
||||
if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3)) {
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + Utilities.dp(4), photoImage.imageY + Utilities.dp(4), infoWidth + Utilities.dp(8) + infoOffset, Utilities.dpf(16.5f));
|
||||
setDrawableBounds(mediaBackgroundDrawable, photoImage.imageX + AndroidUtilities.dp(4), photoImage.imageY + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dpf(16.5f));
|
||||
mediaBackgroundDrawable.draw(canvas);
|
||||
|
||||
if (currentMessageObject.type == 3) {
|
||||
setDrawableBounds(videoIconDrawable, photoImage.imageX + Utilities.dp(8), photoImage.imageY + Utilities.dpf(7.5f));
|
||||
setDrawableBounds(videoIconDrawable, photoImage.imageX + AndroidUtilities.dp(8), photoImage.imageY + AndroidUtilities.dpf(7.5f));
|
||||
videoIconDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.save();
|
||||
canvas.translate(photoImage.imageX + Utilities.dp(8) + infoOffset, photoImage.imageY + Utilities.dpf(5.5f));
|
||||
canvas.translate(photoImage.imageX + AndroidUtilities.dp(8) + infoOffset, photoImage.imageY + AndroidUtilities.dpf(5.5f));
|
||||
infoLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
@ -14,8 +14,8 @@ import android.text.Spannable;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
|
||||
public class ChatMessageCell extends ChatBaseCell {
|
||||
@ -132,10 +132,10 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
pressedLink = null;
|
||||
int maxWidth;
|
||||
if (isChat && !messageObject.isOut()) {
|
||||
maxWidth = Utilities.displaySize.x - Utilities.dp(122);
|
||||
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(122);
|
||||
drawName = true;
|
||||
} else {
|
||||
maxWidth = Utilities.displaySize.x - Utilities.dp(80);
|
||||
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(80);
|
||||
drawName = false;
|
||||
}
|
||||
|
||||
@ -144,25 +144,25 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
super.setMessageObject(messageObject);
|
||||
|
||||
backgroundWidth = messageObject.textWidth;
|
||||
totalHeight = messageObject.textHeight + Utilities.dpf(19.5f) + namesOffset;
|
||||
totalHeight = messageObject.textHeight + AndroidUtilities.dpf(19.5f) + namesOffset;
|
||||
|
||||
int maxChildWidth = Math.max(backgroundWidth, nameWidth);
|
||||
maxChildWidth = Math.max(maxChildWidth, forwardedNameWidth);
|
||||
|
||||
int timeMore = timeWidth + Utilities.dp(6);
|
||||
int timeMore = timeWidth + AndroidUtilities.dp(6);
|
||||
if (messageObject.isOut()) {
|
||||
timeMore += Utilities.dpf(20.5f);
|
||||
timeMore += AndroidUtilities.dpf(20.5f);
|
||||
}
|
||||
|
||||
if (maxWidth - messageObject.lastLineWidth < timeMore) {
|
||||
totalHeight += Utilities.dp(14);
|
||||
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth) + Utilities.dp(29);
|
||||
totalHeight += AndroidUtilities.dp(14);
|
||||
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth) + AndroidUtilities.dp(29);
|
||||
} else {
|
||||
int diff = maxChildWidth - messageObject.lastLineWidth;
|
||||
if (diff >= 0 && diff <= timeMore) {
|
||||
backgroundWidth = maxChildWidth + timeMore - diff + Utilities.dp(29);
|
||||
backgroundWidth = maxChildWidth + timeMore - diff + AndroidUtilities.dp(29);
|
||||
} else {
|
||||
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth + timeMore) + Utilities.dp(29);
|
||||
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth + timeMore) + AndroidUtilities.dp(29);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -178,11 +178,11 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
|
||||
if (currentMessageObject.isOut()) {
|
||||
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
textX = layoutWidth - backgroundWidth + AndroidUtilities.dp(10);
|
||||
textY = AndroidUtilities.dp(10) + namesOffset;
|
||||
} else {
|
||||
textX = Utilities.dp(19) + (isChat ? Utilities.dp(52) : 0);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
textX = AndroidUtilities.dp(19) + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
textY = AndroidUtilities.dp(10) + namesOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,11 +194,11 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
}
|
||||
|
||||
if (currentMessageObject.isOut()) {
|
||||
textX = layoutWidth - backgroundWidth + Utilities.dp(10);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
textX = layoutWidth - backgroundWidth + AndroidUtilities.dp(10);
|
||||
textY = AndroidUtilities.dp(10) + namesOffset;
|
||||
} else {
|
||||
textX = Utilities.dp(19) + (isChat ? Utilities.dp(52) : 0);
|
||||
textY = Utilities.dp(10) + namesOffset;
|
||||
textX = AndroidUtilities.dp(19) + (isChat ? AndroidUtilities.dp(52) : 0);
|
||||
textY = AndroidUtilities.dp(10) + namesOffset;
|
||||
}
|
||||
|
||||
for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
|
||||
|
@ -17,11 +17,12 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -61,25 +62,25 @@ public class ChatOrUserCell extends BaseCell {
|
||||
private void init() {
|
||||
if (namePaint == null) {
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(Utilities.dp(18));
|
||||
namePaint.setTextSize(AndroidUtilities.dp(18));
|
||||
namePaint.setColor(0xff222222);
|
||||
}
|
||||
|
||||
if (nameEncryptedPaint == null) {
|
||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
nameEncryptedPaint.setTextSize(Utilities.dp(18));
|
||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(18));
|
||||
nameEncryptedPaint.setColor(0xff00a60e);
|
||||
}
|
||||
|
||||
if (onlinePaint == null) {
|
||||
onlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
onlinePaint.setTextSize(Utilities.dp(15));
|
||||
onlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
onlinePaint.setColor(0xff316f9f);
|
||||
}
|
||||
|
||||
if (offlinePaint == null) {
|
||||
offlinePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
offlinePaint.setTextSize(Utilities.dp(15));
|
||||
offlinePaint.setTextSize(AndroidUtilities.dp(15));
|
||||
offlinePaint.setColor(0xff999999);
|
||||
}
|
||||
|
||||
@ -122,7 +123,7 @@ public class ChatOrUserCell extends BaseCell {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), Utilities.dp(64));
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(64));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -243,14 +244,14 @@ public class ChatOrUserCell extends BaseCell {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
avatarImage.draw(canvas, cellLayout.avatarLeft, cellLayout.avatarTop, Utilities.dp(50), Utilities.dp(50));
|
||||
avatarImage.draw(canvas, cellLayout.avatarLeft, cellLayout.avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
|
||||
|
||||
if (useSeparator) {
|
||||
int h = getMeasuredHeight();
|
||||
if (!usePadding) {
|
||||
canvas.drawLine(0, h - 1, getMeasuredWidth(), h, linePaint);
|
||||
} else {
|
||||
canvas.drawLine(Utilities.dp(11), h - 1, getMeasuredWidth() - Utilities.dp(11), h, linePaint);
|
||||
canvas.drawLine(AndroidUtilities.dp(11), h - 1, getMeasuredWidth() - AndroidUtilities.dp(11), h, linePaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,14 +263,14 @@ public class ChatOrUserCell extends BaseCell {
|
||||
private StaticLayout nameLayout;
|
||||
private boolean drawNameLock;
|
||||
private int nameLockLeft;
|
||||
private int nameLockTop = Utilities.dp(15);
|
||||
private int nameLockTop = AndroidUtilities.dp(15);
|
||||
|
||||
private int onlineLeft;
|
||||
private int onlineTop = Utilities.dp(36);
|
||||
private int onlineTop = AndroidUtilities.dp(36);
|
||||
private int onlineWidth;
|
||||
private StaticLayout onlineLayout;
|
||||
|
||||
private int avatarTop = Utilities.dp(7);
|
||||
private int avatarTop = AndroidUtilities.dp(7);
|
||||
private int avatarLeft;
|
||||
|
||||
public void build(int width, int height) {
|
||||
@ -279,18 +280,18 @@ public class ChatOrUserCell extends BaseCell {
|
||||
if (encryptedChat != null) {
|
||||
drawNameLock = true;
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = Utilities.dp(61 + (usePadding ? 11 : 0));
|
||||
nameLeft = Utilities.dp(65 + (usePadding ? 11 : 0)) + lockDrawable.getIntrinsicWidth();
|
||||
nameLockLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
nameLeft = AndroidUtilities.dp(65 + (usePadding ? 11 : 0)) + lockDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
nameLockLeft = width - Utilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = usePadding ? Utilities.dp(11) : 0;
|
||||
nameLockLeft = width - AndroidUtilities.dp(63 + (usePadding ? 11 : 0)) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
} else {
|
||||
drawNameLock = false;
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLeft = Utilities.dp(61 + (usePadding ? 11 : 0));
|
||||
nameLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
nameLeft = usePadding ? Utilities.dp(11) : 0;
|
||||
nameLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,22 +320,22 @@ public class ChatOrUserCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineWidth = nameWidth = width - nameLeft - Utilities.dp(3 + (usePadding ? 11 : 0));
|
||||
onlineWidth = nameWidth = width - nameLeft - AndroidUtilities.dp(3 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineWidth = nameWidth = width - nameLeft - Utilities.dp(61 + (usePadding ? 11 : 0));
|
||||
onlineWidth = nameWidth = width - nameLeft - AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
}
|
||||
if (drawNameLock) {
|
||||
nameWidth -= Utilities.dp(6) + lockDrawable.getIntrinsicWidth();
|
||||
nameWidth -= AndroidUtilities.dp(6) + lockDrawable.getIntrinsicWidth();
|
||||
}
|
||||
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, currentNamePaint, nameWidth - Utilities.dp(12), TextUtils.TruncateAt.END);
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(nameString, currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
if (chat == null) {
|
||||
if (!LocaleController.isRTL) {
|
||||
onlineLeft = Utilities.dp(61 + (usePadding ? 11 : 0));
|
||||
onlineLeft = AndroidUtilities.dp(61 + (usePadding ? 11 : 0));
|
||||
} else {
|
||||
onlineLeft = usePadding ? Utilities.dp(11) : 0;
|
||||
onlineLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
}
|
||||
|
||||
String onlineString = "";
|
||||
@ -350,23 +351,23 @@ public class ChatOrUserCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - Utilities.dp(12), TextUtils.TruncateAt.END);
|
||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
nameTop = Utilities.dp(12);
|
||||
nameTop = AndroidUtilities.dp(12);
|
||||
} else {
|
||||
onlineLayout = null;
|
||||
nameTop = Utilities.dp(22);
|
||||
nameTop = AndroidUtilities.dp(22);
|
||||
}
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
avatarLeft = usePadding ? Utilities.dp(11) : 0;
|
||||
avatarLeft = usePadding ? AndroidUtilities.dp(11) : 0;
|
||||
} else {
|
||||
avatarLeft = width - Utilities.dp(50 + (usePadding ? 11 : 0));
|
||||
avatarLeft = width - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
|
||||
}
|
||||
avatarImage.imageX = avatarLeft;
|
||||
avatarImage.imageY = avatarTop;
|
||||
avatarImage.imageW = Utilities.dp(50);
|
||||
avatarImage.imageH = Utilities.dp(50);
|
||||
avatarImage.imageW = AndroidUtilities.dp(50);
|
||||
avatarImage.imageH = AndroidUtilities.dp(50);
|
||||
|
||||
double widthpx = 0;
|
||||
float left = 0;
|
||||
|
@ -17,12 +17,13 @@ import android.text.StaticLayout;
|
||||
import android.text.TextPaint;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -58,46 +59,46 @@ public class DialogCell extends BaseCell {
|
||||
private void init() {
|
||||
if (namePaint == null) {
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(Utilities.dp(19));
|
||||
namePaint.setTextSize(AndroidUtilities.dp(19));
|
||||
namePaint.setColor(0xff222222);
|
||||
namePaint.setTypeface(Utilities.getTypeface("fonts/rmedium.ttf"));
|
||||
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
}
|
||||
|
||||
if (nameEncryptedPaint == null) {
|
||||
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
nameEncryptedPaint.setTextSize(Utilities.dp(19));
|
||||
nameEncryptedPaint.setTextSize(AndroidUtilities.dp(19));
|
||||
nameEncryptedPaint.setColor(0xff00a60e);
|
||||
nameEncryptedPaint.setTypeface(Utilities.getTypeface("fonts/rmedium.ttf"));
|
||||
nameEncryptedPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
}
|
||||
|
||||
if (nameUnknownPaint == null) {
|
||||
nameUnknownPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
nameUnknownPaint.setTextSize(Utilities.dp(19));
|
||||
nameUnknownPaint.setTextSize(AndroidUtilities.dp(19));
|
||||
nameUnknownPaint.setColor(0xff316f9f);
|
||||
nameUnknownPaint.setTypeface(Utilities.getTypeface("fonts/rmedium.ttf"));
|
||||
nameUnknownPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
}
|
||||
|
||||
if (messagePaint == null) {
|
||||
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
messagePaint.setTextSize(Utilities.dp(16));
|
||||
messagePaint.setTextSize(AndroidUtilities.dp(16));
|
||||
messagePaint.setColor(0xff808080);
|
||||
}
|
||||
|
||||
if (messagePrintingPaint == null) {
|
||||
messagePrintingPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
messagePrintingPaint.setTextSize(Utilities.dp(16));
|
||||
messagePrintingPaint.setTextSize(AndroidUtilities.dp(16));
|
||||
messagePrintingPaint.setColor(0xff316f9f);
|
||||
}
|
||||
|
||||
if (timePaint == null) {
|
||||
timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
timePaint.setTextSize(Utilities.dp(14));
|
||||
timePaint.setTextSize(AndroidUtilities.dp(14));
|
||||
timePaint.setColor(0xff9e9e9e);
|
||||
}
|
||||
|
||||
if (countPaint == null) {
|
||||
countPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
countPaint.setTextSize(Utilities.dp(13));
|
||||
countPaint.setTextSize(AndroidUtilities.dp(13));
|
||||
countPaint.setColor(0xffffffff);
|
||||
}
|
||||
|
||||
@ -159,7 +160,7 @@ public class DialogCell extends BaseCell {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), Utilities.dp(70));
|
||||
setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(70));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -309,20 +310,20 @@ public class DialogCell extends BaseCell {
|
||||
setDrawableBounds(errorDrawable, cellLayout.errorLeft, cellLayout.errorTop);
|
||||
errorDrawable.draw(canvas);
|
||||
} else if (cellLayout.drawCount) {
|
||||
setDrawableBounds(countDrawable, cellLayout.countLeft - Utilities.dp(5), cellLayout.countTop, cellLayout.countWidth + Utilities.dp(10), countDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(countDrawable, cellLayout.countLeft - AndroidUtilities.dp(5), cellLayout.countTop, cellLayout.countWidth + AndroidUtilities.dp(10), countDrawable.getIntrinsicHeight());
|
||||
countDrawable.draw(canvas);
|
||||
canvas.save();
|
||||
canvas.translate(cellLayout.countLeft, cellLayout.countTop + Utilities.dp(3));
|
||||
canvas.translate(cellLayout.countLeft, cellLayout.countTop + AndroidUtilities.dp(3));
|
||||
cellLayout.countLayout.draw(canvas);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
avatarImage.draw(canvas, cellLayout.avatarLeft, cellLayout.avatarTop, Utilities.dp(54), Utilities.dp(54));
|
||||
avatarImage.draw(canvas, cellLayout.avatarLeft, cellLayout.avatarTop, AndroidUtilities.dp(54), AndroidUtilities.dp(54));
|
||||
}
|
||||
|
||||
private class DialogCellLayout {
|
||||
private int nameLeft;
|
||||
private int nameTop = Utilities.dp(10);
|
||||
private int nameTop = AndroidUtilities.dp(10);
|
||||
private int nameWidth;
|
||||
private StaticLayout nameLayout;
|
||||
private boolean drawNameLock;
|
||||
@ -331,7 +332,7 @@ public class DialogCell extends BaseCell {
|
||||
private int nameLockTop;
|
||||
|
||||
private int timeLeft;
|
||||
private int timeTop = Utilities.dp(13);
|
||||
private int timeTop = AndroidUtilities.dp(13);
|
||||
private int timeWidth;
|
||||
private StaticLayout timeLayout;
|
||||
|
||||
@ -339,25 +340,25 @@ public class DialogCell extends BaseCell {
|
||||
private boolean drawCheck2;
|
||||
private boolean drawClock;
|
||||
private int checkDrawLeft;
|
||||
private int checkDrawTop = Utilities.dp(15);
|
||||
private int checkDrawTop = AndroidUtilities.dp(15);
|
||||
private int halfCheckDrawLeft;
|
||||
|
||||
private int messageTop = Utilities.dp(40);
|
||||
private int messageTop = AndroidUtilities.dp(40);
|
||||
private int messageLeft;
|
||||
private int messageWidth;
|
||||
private StaticLayout messageLayout;
|
||||
|
||||
private boolean drawError;
|
||||
private int errorTop = Utilities.dp(37);
|
||||
private int errorTop = AndroidUtilities.dp(37);
|
||||
private int errorLeft;
|
||||
|
||||
private boolean drawCount;
|
||||
private int countTop = Utilities.dp(37);
|
||||
private int countTop = AndroidUtilities.dp(37);
|
||||
private int countLeft;
|
||||
private int countWidth;
|
||||
private StaticLayout countLayout;
|
||||
|
||||
private int avatarTop = Utilities.dp(8);
|
||||
private int avatarTop = AndroidUtilities.dp(8);
|
||||
private int avatarLeft;
|
||||
|
||||
public void build(int width, int height) {
|
||||
@ -374,32 +375,32 @@ public class DialogCell extends BaseCell {
|
||||
if (encryptedChat != null) {
|
||||
drawNameLock = true;
|
||||
drawNameGroup = false;
|
||||
nameLockTop = Utilities.dp(13);
|
||||
nameLockTop = AndroidUtilities.dp(13);
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = Utilities.dp(77);
|
||||
nameLeft = Utilities.dp(81) + lockDrawable.getIntrinsicWidth();
|
||||
nameLockLeft = AndroidUtilities.dp(77);
|
||||
nameLeft = AndroidUtilities.dp(81) + lockDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
nameLockLeft = width - Utilities.dp(77) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = Utilities.dp(14);
|
||||
nameLockLeft = width - AndroidUtilities.dp(77) - lockDrawable.getIntrinsicWidth();
|
||||
nameLeft = AndroidUtilities.dp(14);
|
||||
}
|
||||
} else {
|
||||
drawNameLock = false;
|
||||
if (chat != null) {
|
||||
drawNameGroup = true;
|
||||
nameLockTop = Utilities.dp(14);
|
||||
nameLockTop = AndroidUtilities.dp(14);
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLockLeft = Utilities.dp(77);
|
||||
nameLeft = Utilities.dp(81) + groupDrawable.getIntrinsicWidth();
|
||||
nameLockLeft = AndroidUtilities.dp(77);
|
||||
nameLeft = AndroidUtilities.dp(81) + groupDrawable.getIntrinsicWidth();
|
||||
} else {
|
||||
nameLockLeft = width - Utilities.dp(77) - groupDrawable.getIntrinsicWidth();
|
||||
nameLeft = Utilities.dp(14);
|
||||
nameLockLeft = width - AndroidUtilities.dp(77) - groupDrawable.getIntrinsicWidth();
|
||||
nameLeft = AndroidUtilities.dp(14);
|
||||
}
|
||||
} else {
|
||||
drawNameGroup = false;
|
||||
if (!LocaleController.isRTL) {
|
||||
nameLeft = Utilities.dp(77);
|
||||
nameLeft = AndroidUtilities.dp(77);
|
||||
} else {
|
||||
nameLeft = Utilities.dp(14);
|
||||
nameLeft = AndroidUtilities.dp(14);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,10 +477,10 @@ public class DialogCell extends BaseCell {
|
||||
checkMessage = false;
|
||||
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
|
||||
currentMessagePaint = messagePrintingPaint;
|
||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#316f9f>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#316f9f>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
} else {
|
||||
if (message.messageOwner.message != null) {
|
||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
||||
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#316f9f>%s:</font> <font color=#808080>%s</font>", name, message.messageOwner.message.replace("\n", " ").replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -538,9 +539,9 @@ public class DialogCell extends BaseCell {
|
||||
timeWidth = (int)Math.ceil(timePaint.measureText(timeString));
|
||||
timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
if (!LocaleController.isRTL) {
|
||||
timeLeft = width - Utilities.dp(11) - timeWidth;
|
||||
timeLeft = width - AndroidUtilities.dp(11) - timeWidth;
|
||||
} else {
|
||||
timeLeft = Utilities.dp(11);
|
||||
timeLeft = AndroidUtilities.dp(11);
|
||||
}
|
||||
|
||||
if (chat != null) {
|
||||
@ -569,81 +570,81 @@ public class DialogCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (!LocaleController.isRTL) {
|
||||
nameWidth = width - nameLeft - Utilities.dp(14) - timeWidth;
|
||||
nameWidth = width - nameLeft - AndroidUtilities.dp(14) - timeWidth;
|
||||
} else {
|
||||
nameWidth = width - nameLeft - Utilities.dp(77) - timeWidth;
|
||||
nameWidth = width - nameLeft - AndroidUtilities.dp(77) - timeWidth;
|
||||
nameLeft += timeWidth;
|
||||
}
|
||||
if (drawNameLock) {
|
||||
nameWidth -= Utilities.dp(4) + lockDrawable.getIntrinsicWidth();
|
||||
nameWidth -= AndroidUtilities.dp(4) + lockDrawable.getIntrinsicWidth();
|
||||
} else if (drawNameGroup) {
|
||||
nameWidth -= Utilities.dp(4) + groupDrawable.getIntrinsicWidth();
|
||||
nameWidth -= AndroidUtilities.dp(4) + groupDrawable.getIntrinsicWidth();
|
||||
}
|
||||
if (drawClock) {
|
||||
int w = clockDrawable.getIntrinsicWidth() + Utilities.dp(2);
|
||||
int w = clockDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);
|
||||
nameWidth -= w;
|
||||
if (!LocaleController.isRTL) {
|
||||
checkDrawLeft = timeLeft - w;
|
||||
} else {
|
||||
checkDrawLeft = timeLeft + timeWidth + Utilities.dp(2);
|
||||
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
||||
nameLeft += w;
|
||||
}
|
||||
} else if (drawCheck2) {
|
||||
int w = checkDrawable.getIntrinsicWidth() + Utilities.dp(2);
|
||||
int w = checkDrawable.getIntrinsicWidth() + AndroidUtilities.dp(2);
|
||||
nameWidth -= w;
|
||||
if (drawCheck1) {
|
||||
nameWidth -= halfCheckDrawable.getIntrinsicWidth() - Utilities.dp(5);
|
||||
nameWidth -= halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5);
|
||||
if (!LocaleController.isRTL) {
|
||||
halfCheckDrawLeft = timeLeft - w;
|
||||
checkDrawLeft = halfCheckDrawLeft - Utilities.dp(5);
|
||||
checkDrawLeft = halfCheckDrawLeft - AndroidUtilities.dp(5);
|
||||
} else {
|
||||
checkDrawLeft = timeLeft + timeWidth + Utilities.dp(2);
|
||||
halfCheckDrawLeft = checkDrawLeft + Utilities.dp(5);
|
||||
nameLeft += w + halfCheckDrawable.getIntrinsicWidth() - Utilities.dp(5);
|
||||
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
||||
halfCheckDrawLeft = checkDrawLeft + AndroidUtilities.dp(5);
|
||||
nameLeft += w + halfCheckDrawable.getIntrinsicWidth() - AndroidUtilities.dp(5);
|
||||
}
|
||||
} else {
|
||||
if (!LocaleController.isRTL) {
|
||||
checkDrawLeft = timeLeft - w;
|
||||
} else {
|
||||
checkDrawLeft = timeLeft + timeWidth + Utilities.dp(2);
|
||||
checkDrawLeft = timeLeft + timeWidth + AndroidUtilities.dp(2);
|
||||
nameLeft += w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - Utilities.dp(12), TextUtils.TruncateAt.END);
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(nameString.replace("\n", " "), currentNamePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
nameLayout = new StaticLayout(nameStringFinal, currentNamePaint, nameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
messageWidth = width - Utilities.dp(88);
|
||||
messageWidth = width - AndroidUtilities.dp(88);
|
||||
if (!LocaleController.isRTL) {
|
||||
messageLeft = Utilities.dp(77);
|
||||
avatarLeft = Utilities.dp(11);
|
||||
messageLeft = AndroidUtilities.dp(77);
|
||||
avatarLeft = AndroidUtilities.dp(11);
|
||||
} else {
|
||||
messageLeft = Utilities.dp(11);
|
||||
avatarLeft = width - Utilities.dp(65);
|
||||
messageLeft = AndroidUtilities.dp(11);
|
||||
avatarLeft = width - AndroidUtilities.dp(65);
|
||||
}
|
||||
avatarImage.imageX = avatarLeft;
|
||||
avatarImage.imageY = avatarTop;
|
||||
avatarImage.imageW = Utilities.dp(54);
|
||||
avatarImage.imageH = Utilities.dp(54);
|
||||
avatarImage.imageW = AndroidUtilities.dp(54);
|
||||
avatarImage.imageH = AndroidUtilities.dp(54);
|
||||
if (drawError) {
|
||||
int w = errorDrawable.getIntrinsicWidth() + Utilities.dp(8);
|
||||
int w = errorDrawable.getIntrinsicWidth() + AndroidUtilities.dp(8);
|
||||
messageWidth -= w;
|
||||
if (!LocaleController.isRTL) {
|
||||
errorLeft = width - errorDrawable.getIntrinsicWidth() - Utilities.dp(11);
|
||||
errorLeft = width - errorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(11);
|
||||
} else {
|
||||
errorLeft = Utilities.dp(11);
|
||||
errorLeft = AndroidUtilities.dp(11);
|
||||
messageLeft += w;
|
||||
}
|
||||
} else if (countString != null) {
|
||||
countWidth = Math.max(Utilities.dp(12), (int)Math.ceil(countPaint.measureText(countString)));
|
||||
countWidth = Math.max(AndroidUtilities.dp(12), (int)Math.ceil(countPaint.measureText(countString)));
|
||||
countLayout = new StaticLayout(countString, countPaint, countWidth, Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||
int w = countWidth + Utilities.dp(18);
|
||||
int w = countWidth + AndroidUtilities.dp(18);
|
||||
messageWidth -= w;
|
||||
if (!LocaleController.isRTL) {
|
||||
countLeft = width - countWidth - Utilities.dp(16);
|
||||
countLeft = width - countWidth - AndroidUtilities.dp(16);
|
||||
} else {
|
||||
countLeft = Utilities.dp(16);
|
||||
countLeft = AndroidUtilities.dp(16);
|
||||
messageLeft += w;
|
||||
}
|
||||
drawCount = true;
|
||||
@ -659,10 +660,10 @@ public class DialogCell extends BaseCell {
|
||||
if (mess.length() > 150) {
|
||||
mess = mess.substring(0, 150);
|
||||
}
|
||||
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), Utilities.dp(20));
|
||||
messageString = Emoji.replaceEmoji(mess, messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
}
|
||||
|
||||
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - Utilities.dp(12), TextUtils.TruncateAt.END);
|
||||
CharSequence messageStringFinal = TextUtils.ellipsize(messageString, currentMessagePaint, messageWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
messageLayout = new StaticLayout(messageStringFinal, currentMessagePaint, messageWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
||||
double widthpx = 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,12 +23,13 @@ import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -299,7 +300,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
@ -596,7 +597,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
||||
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||
avatarImage.processDetach = false;
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
||||
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
||||
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
|
||||
textView.setTypeface(typeface);
|
||||
|
||||
textView.setText(chat.title);
|
||||
|
@ -20,11 +20,11 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
||||
public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||
@ -108,14 +108,14 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenAnimationEnd() {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
|
||||
private void saveName() {
|
||||
|
@ -21,11 +21,12 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -104,7 +105,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
avatarImage = (BackupImageView)fragmentView.findViewById(R.id.settings_avatar_image);
|
||||
avatarImage.processDetach = false;
|
||||
phoneText = (TextView)fragmentView.findViewById(R.id.settings_name);
|
||||
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
||||
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
|
||||
phoneText.setTypeface(typeface);
|
||||
|
||||
firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
|
||||
@ -183,13 +184,13 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenAnimationEnd() {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,14 @@ import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -148,9 +149,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
listView.setAdapter(listViewAdapter);
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
if (!LocaleController.isRTL) {
|
||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(30), listView.getPaddingBottom());
|
||||
} else {
|
||||
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(30), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
listView.setFastScrollAlwaysVisible(true);
|
||||
@ -170,7 +171,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
if (text.length() != 0) {
|
||||
searchWas = true;
|
||||
if (listView != null) {
|
||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setAdapter(searchListViewAdapter);
|
||||
searchListViewAdapter.notifyDataSetChanged();
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
@ -320,7 +321,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,7 +420,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,8 +18,9 @@ import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
@ -147,9 +148,9 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
ViewGroup group = (ViewGroup) listView.getParent();
|
||||
listView.setAdapter(listViewAdapter);
|
||||
if (!LocaleController.isRTL) {
|
||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(30), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(30), listView.getPaddingBottom());
|
||||
} else {
|
||||
listView.setPadding(Utilities.dp(30), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(30), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
listView.setFastScrollAlwaysVisible(true);
|
||||
@ -167,7 +168,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
if (text.length() != 0) {
|
||||
searchWas = true;
|
||||
if (listView != null) {
|
||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setAdapter(searchListViewAdapter);
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
listView.setFastScrollAlwaysVisible(false);
|
||||
@ -228,7 +229,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
|
@ -32,13 +32,14 @@ import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -72,7 +73,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||
|
||||
int sz = super.getSize(paint, text, start, end, fm);
|
||||
|
||||
int offset = Utilities.dp(6);
|
||||
int offset = AndroidUtilities.dp(6);
|
||||
int w = (fm.bottom - fm.top) / 2;
|
||||
fm.top = -w - offset;
|
||||
fm.bottom = w - offset;
|
||||
@ -293,7 +294,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL) {
|
||||
Utilities.hideKeyboard(userSelectEditText);
|
||||
AndroidUtilities.hideKeyboard(userSelectEditText);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,11 @@ import android.widget.ImageButton;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
@ -20,11 +20,11 @@ import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.IdenticonView;
|
||||
@ -48,7 +48,7 @@ public class IdenticonActivity extends BaseFragment {
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
actionBarLayer.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
|
||||
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
|
@ -24,7 +24,7 @@ import android.view.animation.AnimationUtils;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
|
@ -20,8 +20,9 @@ import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
@ -86,7 +87,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
if (text.length() != 0) {
|
||||
searchWas = true;
|
||||
if (listView != null) {
|
||||
listView.setPadding(Utilities.dp(16), listView.getPaddingTop(), Utilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setPadding(AndroidUtilities.dp(16), listView.getPaddingTop(), AndroidUtilities.dp(16), listView.getPaddingBottom());
|
||||
listView.setAdapter(searchListViewAdapter);
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
listView.setFastScrollAlwaysVisible(false);
|
||||
@ -176,7 +177,7 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,38 +8,31 @@
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.ContactsContract;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarActivity;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.NotificationView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
@ -49,7 +42,6 @@ import java.util.Map;
|
||||
|
||||
public class LaunchActivity extends ActionBarActivity implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate {
|
||||
private boolean finished = false;
|
||||
private NotificationView notificationView;
|
||||
private String videoPath = null;
|
||||
private String sendingText = null;
|
||||
private ArrayList<Uri> photoPathsArray = null;
|
||||
@ -86,11 +78,11 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
|
||||
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
if (resourceId > 0) {
|
||||
Utilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||
AndroidUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId);
|
||||
}
|
||||
|
||||
NotificationCenter.getInstance().postNotificationName(702, this);
|
||||
currentConnectionState = ConnectionsManager.getInstance().connectionState;
|
||||
currentConnectionState = ConnectionsManager.getInstance().getConnectionState();
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, 1234);
|
||||
NotificationCenter.getInstance().addObserver(this, 658);
|
||||
@ -504,14 +496,8 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
ConnectionsManager.setAppPaused(true);
|
||||
if (notificationView != null) {
|
||||
notificationView.hide(false);
|
||||
}
|
||||
View focusView = getCurrentFocus();
|
||||
if (focusView instanceof EditText) {
|
||||
focusView.clearFocus();
|
||||
}
|
||||
ApplicationLoader.mainInterfacePaused = true;
|
||||
ConnectionsManager.getInstance().setAppPaused(true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -523,20 +509,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (notificationView == null && getLayoutInflater() != null) {
|
||||
notificationView = (NotificationView) getLayoutInflater().inflate(R.layout.notification_layout, null);
|
||||
}
|
||||
Utilities.checkForCrashes(this);
|
||||
Utilities.checkForUpdates(this);
|
||||
ConnectionsManager.setAppPaused(false);
|
||||
ApplicationLoader.mainInterfacePaused = false;
|
||||
ConnectionsManager.getInstance().setAppPaused(false, false);
|
||||
actionBar.setBackOverlayVisible(currentConnectionState != 0);
|
||||
try {
|
||||
NotificationManager mNotificationManager = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
mNotificationManager.cancel(1);
|
||||
MessagesController.getInstance().currentPushMessage = null;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
MessagesController.getInstance().dismissNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -550,32 +528,12 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
NotificationCenter.getInstance().removeObserver(this, 701);
|
||||
NotificationCenter.getInstance().removeObserver(this, 702);
|
||||
NotificationCenter.getInstance().removeObserver(this, 703);
|
||||
if (notificationView != null) {
|
||||
notificationView.hide(false);
|
||||
notificationView.destroy();
|
||||
notificationView = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(android.content.res.Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Utilities.checkDisplaySize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void needLayout() {
|
||||
super.needLayout();
|
||||
if (notificationView != null) {
|
||||
WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
|
||||
int height = Utilities.dp(48);
|
||||
if (!Utilities.isTablet(this) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = Utilities.dp(40);
|
||||
}
|
||||
notificationView.applyOrientationPaddings(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90, height);
|
||||
}
|
||||
AndroidUtilities.checkDisplaySize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -614,11 +572,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
||||
args2.putInt("enc_id", push_enc_id);
|
||||
presentFragment(new ChatActivity(args2), false, true);
|
||||
}
|
||||
} else if (id == 701) {
|
||||
if (notificationView != null) {
|
||||
MessageObject message = (MessageObject)args[0];
|
||||
notificationView.show(message);
|
||||
}
|
||||
} else if (id == 702) {
|
||||
if (args[0] != this) {
|
||||
onFinish();
|
||||
|
@ -26,10 +26,10 @@ import com.google.android.gms.maps.model.Marker;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
@ -22,8 +22,9 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
@ -265,7 +266,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
|
||||
newView.setParams(params);
|
||||
actionBarLayer.setTitle(newView.getHeaderName());
|
||||
newView.onShow();
|
||||
newView.setX(back ? -Utilities.displaySize.x : Utilities.displaySize.x);
|
||||
newView.setX(back ? -AndroidUtilities.displaySize.x : AndroidUtilities.displaySize.x);
|
||||
outView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
@ -284,7 +285,7 @@ public class LoginActivity extends BaseFragment implements SlideView.SlideViewDe
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
}
|
||||
}).setDuration(300).translationX(back ? Utilities.displaySize.x : -Utilities.displaySize.x).start();
|
||||
}).setDuration(300).translationX(back ? AndroidUtilities.displaySize.x : -AndroidUtilities.displaySize.x).start();
|
||||
newView.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
|
@ -21,9 +21,10 @@ import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
@ -250,10 +251,10 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
|
||||
}
|
||||
|
||||
if (codeField.length() != 0) {
|
||||
Utilities.showKeyboard(phoneField);
|
||||
AndroidUtilities.showKeyboard(phoneField);
|
||||
phoneField.requestFocus();
|
||||
} else {
|
||||
Utilities.showKeyboard(codeField);
|
||||
AndroidUtilities.showKeyboard(codeField);
|
||||
codeField.requestFocus();
|
||||
}
|
||||
phoneField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@ -389,7 +390,7 @@ public class LoginActivityPhoneView extends SlideView implements AdapterView.OnI
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,13 +17,13 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -184,7 +184,7 @@ public class LoginActivityRegisterView extends SlideView {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,15 +18,16 @@ import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -110,7 +111,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
return;
|
||||
}
|
||||
codeField.setText("");
|
||||
Utilities.setWaitingForSms(true);
|
||||
AndroidUtilities.setWaitingForSms(true);
|
||||
NotificationCenter.getInstance().addObserver(this, 998);
|
||||
currentParams = params;
|
||||
waitingForSms = true;
|
||||
@ -127,7 +128,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
String number = PhoneFormat.getInstance().format(phone);
|
||||
confirmTextView.setText(Html.fromHtml(String.format(LocaleController.getString("SentSmsCode", R.string.SentSmsCode) + " <b>%s</b>", number)));
|
||||
|
||||
Utilities.showKeyboard(codeField);
|
||||
AndroidUtilities.showKeyboard(codeField);
|
||||
codeField.requestFocus();
|
||||
|
||||
destroyTimer();
|
||||
@ -166,7 +167,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -194,7 +195,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
}
|
||||
nextPressed = true;
|
||||
waitingForSms = false;
|
||||
Utilities.setWaitingForSms(false);
|
||||
AndroidUtilities.setWaitingForSms(false);
|
||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
||||
final TLRPC.TL_auth_signIn req = new TLRPC.TL_auth_signIn();
|
||||
req.phone_number = requestPhone;
|
||||
@ -256,14 +257,14 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
destroyTimer();
|
||||
currentParams = null;
|
||||
Utilities.setWaitingForSms(false);
|
||||
AndroidUtilities.setWaitingForSms(false);
|
||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
||||
waitingForSms = false;
|
||||
}
|
||||
@ -271,7 +272,7 @@ public class LoginActivitySmsView extends SlideView implements NotificationCente
|
||||
@Override
|
||||
public void onDestroyActivity() {
|
||||
super.onDestroyActivity();
|
||||
Utilities.setWaitingForSms(false);
|
||||
AndroidUtilities.setWaitingForSms(false);
|
||||
NotificationCenter.getInstance().removeObserver(this, 998);
|
||||
destroyTimer();
|
||||
waitingForSms = false;
|
||||
|
@ -23,11 +23,11 @@ import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
@ -284,7 +284,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
imageView.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = imageView.imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
@ -327,14 +327,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
listView.setNumColumns(6);
|
||||
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - Utilities.dp(2) * 5;
|
||||
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 6 - AndroidUtilities.dp(2) * 5;
|
||||
listView.setColumnWidth(itemWidth);
|
||||
} else {
|
||||
listView.setNumColumns(4);
|
||||
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - Utilities.dp(2) * 3;
|
||||
itemWidth = getParentActivity().getResources().getDisplayMetrics().widthPixels / 4 - AndroidUtilities.dp(2) * 3;
|
||||
listView.setColumnWidth(itemWidth);
|
||||
}
|
||||
listView.setPadding(listView.getPaddingLeft(), Utilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
|
||||
listView.setPadding(listView.getPaddingLeft(), AndroidUtilities.dp(4), listView.getPaddingRight(), listView.getPaddingBottom());
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
||||
if (listView != null) {
|
||||
|
@ -21,13 +21,14 @@ import android.widget.EditText;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -347,7 +348,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView absListView, int i) {
|
||||
if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
|
||||
Utilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,11 @@ import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
||||
import java.io.File;
|
||||
@ -72,7 +72,7 @@ public class PhotoCropActivity extends BaseFragment {
|
||||
private void init() {
|
||||
rectPaint = new Paint();
|
||||
rectPaint.setColor(0xfffafafa);
|
||||
rectPaint.setStrokeWidth(Utilities.dp(2));
|
||||
rectPaint.setStrokeWidth(AndroidUtilities.dp(2));
|
||||
rectPaint.setStyle(Paint.Style.STROKE);
|
||||
circlePaint = new Paint();
|
||||
circlePaint.setColor(0x7fffffff);
|
||||
@ -85,7 +85,7 @@ public class PhotoCropActivity extends BaseFragment {
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
float x = motionEvent.getX();
|
||||
float y = motionEvent.getY();
|
||||
int cornerSide = Utilities.dp(14);
|
||||
int cornerSide = AndroidUtilities.dp(14);
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
if (rectX - cornerSide < x && rectX + cornerSide > x && rectY - cornerSide < y && rectY + cornerSide > y) {
|
||||
draggingState = 1;
|
||||
@ -270,7 +270,7 @@ public class PhotoCropActivity extends BaseFragment {
|
||||
|
||||
canvas.drawRect(rectX, rectY, rectX + rectSize, rectY + rectSize, rectPaint);
|
||||
|
||||
int side = Utilities.dp(7);
|
||||
int side = AndroidUtilities.dp(7);
|
||||
canvas.drawRect(rectX - side, rectY - side, rectX + side, rectY + side, circlePaint);
|
||||
canvas.drawRect(rectX + rectSize - side, rectY - side, rectX + rectSize + side, rectY + side, circlePaint);
|
||||
canvas.drawRect(rectX - side, rectY + rectSize - side, rectX + side, rectY + rectSize + side, circlePaint);
|
||||
|
@ -23,13 +23,13 @@ import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
@ -252,7 +252,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
imageView.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = imageView.imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
@ -405,7 +405,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
}
|
||||
listView.setNumColumns(columnsCount);
|
||||
itemWidth = (getParentActivity().getResources().getDisplayMetrics().widthPixels - ((columnsCount + 1) * Utilities.dp(4))) / columnsCount;
|
||||
itemWidth = (getParentActivity().getResources().getDisplayMetrics().widthPixels - ((columnsCount + 1) * AndroidUtilities.dp(4))) / columnsCount;
|
||||
listView.setColumnWidth(itemWidth);
|
||||
|
||||
listAdapter.notifyDataSetChanged();
|
||||
|
@ -45,12 +45,13 @@ import android.widget.ProgressBar;
|
||||
import android.widget.Scroller;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MediaController;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
@ -102,6 +103,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
private boolean overlayViewVisible = true;
|
||||
|
||||
private int animationInProgress = 0;
|
||||
private long transitionAnimationStartTime = 0;
|
||||
private Runnable animationEndRunnable = null;
|
||||
private PlaceProviderObject showAfterAnimation;
|
||||
private PlaceProviderObject hideAfterAnimation;
|
||||
private boolean disableShowCheck = false;
|
||||
@ -175,7 +178,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
private final static int gallery_menu_showall = 2;
|
||||
private final static int gallery_menu_send = 3;
|
||||
|
||||
private final static int PAGE_SPACING = Utilities.dp(30);
|
||||
private final static int PAGE_SPACING = AndroidUtilities.dp(30);
|
||||
|
||||
private static class OverlayView extends FrameLayout {
|
||||
|
||||
@ -186,7 +189,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
actionButton = new TextView(context);
|
||||
actionButton.setBackgroundResource(R.drawable.system_black);
|
||||
actionButton.setPadding(Utilities.dp(8), Utilities.dp(2), Utilities.dp(8), Utilities.dp(2));
|
||||
actionButton.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(2), AndroidUtilities.dp(8), AndroidUtilities.dp(2));
|
||||
actionButton.setTextColor(0xffffffff);
|
||||
actionButton.setTextSize(26);
|
||||
actionButton.setGravity(Gravity.CENTER);
|
||||
@ -298,7 +301,17 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (currentFileName != null && currentFileName.equals(location)) {
|
||||
Float progress = (Float)args[1];
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setProgress((int)(progress * 100));
|
||||
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
progressBar.setProgress((int) (progress * 100));
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofInt(progressBar, "progress", (int) (progress * 100))
|
||||
);
|
||||
animatorSet.setDuration(400);
|
||||
animatorSet.start();
|
||||
} else {
|
||||
progressBar.setProgress((int) (progress * 100));
|
||||
}
|
||||
}
|
||||
} else if (id == MessagesController.userPhotosLoaded) {
|
||||
int guid = (Integer)args[4];
|
||||
@ -530,7 +543,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
@Override
|
||||
public boolean canOpenMenu() {
|
||||
if (currentFileName != null) {
|
||||
File f = new File(Utilities.getCacheDir(), currentFileName);
|
||||
File f = new File(AndroidUtilities.getCacheDir(), currentFileName);
|
||||
if (f.exists()) {
|
||||
return true;
|
||||
}
|
||||
@ -548,7 +561,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
containerView.addView(bottomLayout);
|
||||
layoutParams = (FrameLayout.LayoutParams)bottomLayout.getLayoutParams();
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = Utilities.dp(48);
|
||||
layoutParams.height = AndroidUtilities.dp(48);
|
||||
layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
|
||||
bottomLayout.setLayoutParams(layoutParams);
|
||||
bottomLayout.setBackgroundColor(0x7F000000);
|
||||
@ -559,7 +572,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
shareButton.setBackgroundResource(R.drawable.bar_selector_white);
|
||||
bottomLayout.addView(shareButton);
|
||||
layoutParams = (FrameLayout.LayoutParams) shareButton.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(50);
|
||||
layoutParams.width = AndroidUtilities.dp(50);
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
shareButton.setLayoutParams(layoutParams);
|
||||
shareButton.setOnClickListener(new View.OnClickListener() {
|
||||
@ -573,7 +586,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (fileName == null) {
|
||||
return;
|
||||
}
|
||||
File f = new File(Utilities.getCacheDir(), fileName);
|
||||
File f = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
if (f.exists()) {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
if (fileName.endsWith("mp4")) {
|
||||
@ -596,7 +609,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
deleteButton.setBackgroundResource(R.drawable.bar_selector_white);
|
||||
bottomLayout.addView(deleteButton);
|
||||
layoutParams = (FrameLayout.LayoutParams) deleteButton.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(50);
|
||||
layoutParams.width = AndroidUtilities.dp(50);
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.gravity = Gravity.RIGHT;
|
||||
deleteButton.setLayoutParams(layoutParams);
|
||||
@ -628,9 +641,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP;
|
||||
layoutParams.leftMargin = Utilities.dp(60);
|
||||
layoutParams.rightMargin = Utilities.dp(60);
|
||||
layoutParams.topMargin = Utilities.dp(2);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(60);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(60);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(2);
|
||||
nameTextView.setLayoutParams(layoutParams);
|
||||
|
||||
dateTextView = new TextView(containerView.getContext());
|
||||
@ -645,9 +658,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP;
|
||||
layoutParams.leftMargin = Utilities.dp(60);
|
||||
layoutParams.rightMargin = Utilities.dp(60);
|
||||
layoutParams.topMargin = Utilities.dp(26);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(60);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(60);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(26);
|
||||
dateTextView.setLayoutParams(layoutParams);
|
||||
|
||||
pickerView = parentActivity.getLayoutInflater().inflate(R.layout.photo_picker_bottom_layout, null);
|
||||
@ -675,7 +688,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
layoutParams = (FrameLayout.LayoutParams)pickerView.getLayoutParams();
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = Utilities.dp(48);
|
||||
layoutParams.height = AndroidUtilities.dp(48);
|
||||
layoutParams.gravity = Gravity.BOTTOM;
|
||||
pickerView.setLayoutParams(layoutParams);
|
||||
|
||||
@ -691,11 +704,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
containerView.addView(progressBar);
|
||||
layoutParams = (FrameLayout.LayoutParams)progressBar.getLayoutParams();
|
||||
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = Utilities.dp(3);
|
||||
layoutParams.height = AndroidUtilities.dp(3);
|
||||
layoutParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
|
||||
layoutParams.leftMargin = Utilities.dp(6);
|
||||
layoutParams.rightMargin = Utilities.dp(6);
|
||||
layoutParams.bottomMargin = Utilities.dp(48);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(6);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(6);
|
||||
layoutParams.bottomMargin = AndroidUtilities.dp(48);
|
||||
progressBar.setLayoutParams(layoutParams);
|
||||
|
||||
gestureDetector = new GestureDetector(containerView.getContext(), this);
|
||||
@ -715,16 +728,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
checkImageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
checkImageView.setImageResource(R.drawable.selectphoto_large);
|
||||
layoutParams = (FrameLayout.LayoutParams)checkImageView.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(46);
|
||||
layoutParams.height = Utilities.dp(46);
|
||||
layoutParams.width = AndroidUtilities.dp(46);
|
||||
layoutParams.height = AndroidUtilities.dp(46);
|
||||
layoutParams.gravity = Gravity.RIGHT;
|
||||
layoutParams.rightMargin = Utilities.dp(10);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(10);
|
||||
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
layoutParams.topMargin = Utilities.dp(48);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(48);
|
||||
} else {
|
||||
layoutParams.topMargin = Utilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(58);
|
||||
}
|
||||
checkImageView.setLayoutParams(layoutParams);
|
||||
checkImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@ -988,7 +1001,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
load = true;
|
||||
}
|
||||
} else {
|
||||
File cacheFile = new File(Utilities.getCacheDir(), currentFileName);
|
||||
File cacheFile = new File(AndroidUtilities.getCacheDir(), currentFileName);
|
||||
if (cacheFile.exists()) {
|
||||
currentOverlay.actionButton.setText(LocaleController.getString("ViewVideo", R.string.ViewVideo));
|
||||
} else {
|
||||
@ -996,10 +1009,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
}
|
||||
if (load) {
|
||||
Float progress = FileLoader.getInstance().fileProgresses.get(currentFileName);
|
||||
if (FileLoader.getInstance().isLoadingFile(currentFileName)) {
|
||||
Float progress = FileLoader.getInstance().fileProgresses.get(currentFileName);
|
||||
currentOverlay.actionButton.setText(LocaleController.getString("CancelDownload", R.string.CancelDownload));
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
if (progress != null) {
|
||||
progressBar.setProgress((int)(progress * 100));
|
||||
}
|
||||
} else {
|
||||
currentOverlay.actionButton.setText(String.format("%s %s", LocaleController.getString("DOWNLOAD", R.string.DOWNLOAD), Utilities.formatFileSize(currentMessageObject.messageOwner.media.video.size)));
|
||||
progressBar.setVisibility(View.GONE);
|
||||
@ -1226,7 +1242,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
|
||||
if (currentFileName != null) {
|
||||
File f = new File(Utilities.getCacheDir(), currentFileName);
|
||||
File f = new File(AndroidUtilities.getCacheDir(), currentFileName);
|
||||
if (f.exists()) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
} else {
|
||||
@ -1260,7 +1276,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (currentThumb != null && imageReceiver == centerImage) {
|
||||
placeHolder = currentThumb;
|
||||
}
|
||||
int size = (int)(800 / Utilities.density);
|
||||
int size = (int)(800 / AndroidUtilities.density);
|
||||
imageReceiver.setImage(photoEntry.path, String.format(Locale.US, "%d_%d", size, size), placeHolder != null ? new BitmapDrawable(null, placeHolder) : null);
|
||||
} else {
|
||||
imageReceiver.setImageBitmap((Bitmap) null);
|
||||
@ -1335,8 +1351,21 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
openPhoto(null, null, null, photos, index, provider);
|
||||
}
|
||||
|
||||
private boolean checkAnimation() {
|
||||
if (animationInProgress != 0) {
|
||||
if (Math.abs(transitionAnimationStartTime - System.currentTimeMillis()) >= 500) {
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
animationInProgress = 0;
|
||||
}
|
||||
}
|
||||
return animationInProgress != 0;
|
||||
}
|
||||
|
||||
public void openPhoto(final MessageObject messageObject, final TLRPC.FileLocation fileLocation, final ArrayList<MessageObject> messages, final ArrayList<MediaController.PhotoEntry> photos, final int index, final PhotoViewerProvider provider) {
|
||||
if (parentActivity == null || isVisible || provider == null || animationInProgress != 0 || messageObject == null && fileLocation == null && messages == null && photos == null) {
|
||||
if (parentActivity == null || isVisible || provider == null || checkAnimation() || messageObject == null && fileLocation == null && messages == null && photos == null) {
|
||||
return;
|
||||
}
|
||||
final PlaceProviderObject object = provider.getPlaceForPhoto(messageObject, fileLocation, index);
|
||||
@ -1369,7 +1398,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
overlayViewVisible = true;
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11) {
|
||||
Utilities.lockOrientation(parentActivity);
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
|
||||
animatingImageView.setVisibility(View.VISIBLE);
|
||||
animatingImageView.setImageBitmap(object.thumb);
|
||||
@ -1391,23 +1420,23 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
public boolean onPreDraw() {
|
||||
containerView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
|
||||
float scaleX = (float) Utilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (Utilities.displaySize.y - Utilities.statusBarHeight) / layoutParams.height;
|
||||
float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height;
|
||||
float scale = scaleX > scaleY ? scaleY : scaleX;
|
||||
float width = layoutParams.width * scale;
|
||||
float height = layoutParams.height * scale;
|
||||
float xPos = (Utilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (Utilities.displaySize.y - Utilities.statusBarHeight - height) / 2.0f;
|
||||
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f;
|
||||
int clipHorizontal = Math.abs(object.imageReceiver.drawRegion.left - object.imageReceiver.imageX);
|
||||
int clipVertical = Math.abs(object.imageReceiver.drawRegion.top - object.imageReceiver.imageY);
|
||||
|
||||
int coords2[] = new int[2];
|
||||
object.parentView.getLocationInWindow(coords2);
|
||||
int clipTop = coords2[1] - Utilities.statusBarHeight - (object.viewY + object.imageReceiver.drawRegion.top);
|
||||
int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + object.imageReceiver.drawRegion.top);
|
||||
if (clipTop < 0) {
|
||||
clipTop = 0;
|
||||
}
|
||||
int clipBottom = (object.viewY + object.imageReceiver.drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - Utilities.statusBarHeight);
|
||||
int clipBottom = (object.viewY + object.imageReceiver.drawRegion.top + layoutParams.height) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight);
|
||||
if (clipBottom < 0) {
|
||||
clipBottom = 0;
|
||||
}
|
||||
@ -1428,14 +1457,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
ObjectAnimator.ofFloat(currentOverlay, "alpha", 1.0f)
|
||||
);
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
public void run() {
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
containerView.invalidate();
|
||||
animatingImageView.setVisibility(View.GONE);
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
if (showAfterAnimation != null) {
|
||||
showAfterAnimation.imageReceiver.setVisible(true, true);
|
||||
}
|
||||
@ -1443,7 +1472,24 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
hideAfterAnimation.imageReceiver.setVisible(false, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
animatorSet.start();
|
||||
|
||||
animatingImageView.setOnDrawListener(new ClippingImageView.onDrawListener() {
|
||||
@ -1461,6 +1507,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
});
|
||||
} else {
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
containerView.invalidate();
|
||||
AnimationSet animationSet = new AnimationSet(true);
|
||||
AlphaAnimation animation = new AlphaAnimation(0.0f, 1.0f);
|
||||
@ -1478,7 +1525,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
|
||||
public void closePhoto(boolean animated) {
|
||||
if (parentActivity == null || !isVisible || animationInProgress != 0) {
|
||||
if (parentActivity == null || !isVisible || checkAnimation()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1502,7 +1549,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
final PlaceProviderObject object = placeProvider.getPlaceForPhoto(currentMessageObject, currentFileLocation, currentIndex);
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT >= 11 && animated) {
|
||||
Utilities.lockOrientation(parentActivity);
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
|
||||
animationInProgress = 1;
|
||||
animatingImageView.setVisibility(View.VISIBLE);
|
||||
@ -1522,13 +1569,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
animatingImageView.setLayoutParams(layoutParams);
|
||||
|
||||
float scaleX = (float) Utilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (Utilities.displaySize.y - Utilities.statusBarHeight) / layoutParams.height;
|
||||
float scaleX = (float) AndroidUtilities.displaySize.x / layoutParams.width;
|
||||
float scaleY = (float) (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight) / layoutParams.height;
|
||||
float scale2 = scaleX > scaleY ? scaleY : scaleX;
|
||||
float width = layoutParams.width * scale * scale2;
|
||||
float height = layoutParams.height * scale * scale2;
|
||||
float xPos = (Utilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (Utilities.displaySize.y - Utilities.statusBarHeight - height) / 2.0f;
|
||||
float xPos = (AndroidUtilities.displaySize.x - width) / 2.0f;
|
||||
float yPos = (AndroidUtilities.displaySize.y - AndroidUtilities.statusBarHeight - height) / 2.0f;
|
||||
animatingImageView.setTranslationX(xPos + translationX);
|
||||
animatingImageView.setTranslationY(yPos + translationY);
|
||||
animatingImageView.setScaleX(scale * scale2);
|
||||
@ -1543,11 +1590,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
int coords2[] = new int[2];
|
||||
object.parentView.getLocationInWindow(coords2);
|
||||
int clipTop = coords2[1] - Utilities.statusBarHeight - (object.viewY + object.imageReceiver.drawRegion.top);
|
||||
int clipTop = coords2[1] - AndroidUtilities.statusBarHeight - (object.viewY + object.imageReceiver.drawRegion.top);
|
||||
if (clipTop < 0) {
|
||||
clipTop = 0;
|
||||
}
|
||||
int clipBottom = (object.viewY + object.imageReceiver.drawRegion.top + (object.imageReceiver.drawRegion.bottom - object.imageReceiver.drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - Utilities.statusBarHeight);
|
||||
int clipBottom = (object.viewY + object.imageReceiver.drawRegion.top + (object.imageReceiver.drawRegion.bottom - object.imageReceiver.drawRegion.top)) - (coords2[1] + object.parentView.getHeight() - AndroidUtilities.statusBarHeight);
|
||||
if (clipBottom < 0) {
|
||||
clipBottom = 0;
|
||||
}
|
||||
@ -1570,20 +1617,36 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofInt(backgroundDrawable, "alpha", 0),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "alpha", 0.0f),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? Utilities.displaySize.y : -Utilities.displaySize.y),
|
||||
ObjectAnimator.ofFloat(animatingImageView, "translationY", translationY >= 0 ? AndroidUtilities.displaySize.y : -AndroidUtilities.displaySize.y),
|
||||
ObjectAnimator.ofFloat(containerView, "alpha", 0.0f)
|
||||
);
|
||||
}
|
||||
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
}
|
||||
};
|
||||
|
||||
animatorSet.setDuration(250);
|
||||
animatorSet.addListener(new AnimatorListenerAdapter() {
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
animatorSet.start();
|
||||
} else {
|
||||
AnimationSet animationSet = new AnimationSet(true);
|
||||
@ -1597,6 +1660,16 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
animationSet.addAnimation(scaleAnimation);
|
||||
animationSet.setDuration(150);
|
||||
animationInProgress = 2;
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (animationListener != null) {
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
animationListener = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
animationSet.setAnimationListener(animationListener = new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animation animation) {
|
||||
@ -1605,10 +1678,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animation animation) {
|
||||
if (animationListener != null) {
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
animationListener = null;
|
||||
if (animationEndRunnable != null) {
|
||||
animationEndRunnable.run();
|
||||
animationEndRunnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1617,6 +1689,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
containerView.startAnimation(animationSet);
|
||||
}
|
||||
}
|
||||
@ -1678,7 +1751,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
private boolean onTouchEvent(MotionEvent ev) {
|
||||
if (animationInProgress != 0 || animationStartTime != 0) {
|
||||
if (animationStartTime == 0) {
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -1713,7 +1786,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
dragY = moveStartY = ev.getY();
|
||||
draggingDown = false;
|
||||
canDragDown = true;
|
||||
Utilities.lockOrientation(parentActivity);
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
if (velocityTracker != null) {
|
||||
velocityTracker.clear();
|
||||
}
|
||||
@ -1732,7 +1805,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
float dx = Math.abs(ev.getX() - moveStartX);
|
||||
float dy = Math.abs(ev.getY() - dragY);
|
||||
if (canDragDown && !draggingDown && scale == 1 && dy >= Utilities.dp(30) && dy / 2 > dx) {
|
||||
if (canDragDown && !draggingDown && scale == 1 && dy >= AndroidUtilities.dp(30) && dy / 2 > dx) {
|
||||
draggingDown = true;
|
||||
moving = false;
|
||||
dragY = ev.getY();
|
||||
@ -1747,7 +1820,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
} else if (!invalidCoords && animationStartTime == 0) {
|
||||
float moveDx = moveStartX - ev.getX();
|
||||
float moveDy = moveStartY - ev.getY();
|
||||
if (moving || scale == 1 && Math.abs(moveDy) + Utilities.dp(12) < Math.abs(moveDx) || scale != 1) {
|
||||
if (moving || scale == 1 && Math.abs(moveDy) + AndroidUtilities.dp(12) < Math.abs(moveDx) || scale != 1) {
|
||||
if (!moving) {
|
||||
moveDx = 0;
|
||||
moveDy = 0;
|
||||
@ -1834,11 +1907,11 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
velocity = velocityTracker.getXVelocity();
|
||||
}
|
||||
|
||||
if((translationX < minX - containerView.getWidth() / 3 || velocity < -Utilities.dp(650)) && rightImage.hasImage()){
|
||||
if((translationX < minX - containerView.getWidth() / 3 || velocity < -AndroidUtilities.dp(650)) && rightImage.hasImage()){
|
||||
goToNext();
|
||||
return true;
|
||||
}
|
||||
if((translationX > maxX + containerView.getWidth() / 3 || velocity > Utilities.dp(650)) && leftImage.hasImage()){
|
||||
if((translationX > maxX + containerView.getWidth() / 3 || velocity > AndroidUtilities.dp(650)) && leftImage.hasImage()){
|
||||
goToPrev();
|
||||
return true;
|
||||
}
|
||||
@ -1855,7 +1928,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
animateTo(scale, moveToX, moveToY);
|
||||
} else {
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -1905,7 +1978,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
toggleOverlayView(true);
|
||||
}
|
||||
if (scale == newScale && translationX == newTx && translationY == newTy) {
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
return;
|
||||
}
|
||||
zoomAnimation = isZoom;
|
||||
@ -1915,7 +1988,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
animationStartTime = System.currentTimeMillis();
|
||||
animationDuration = 250;
|
||||
containerView.postInvalidate();
|
||||
Utilities.lockOrientation(parentActivity);
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
}
|
||||
|
||||
private void onDraw(Canvas canvas) {
|
||||
@ -1962,7 +2035,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
scale = animateToScale;
|
||||
animationStartTime = 0;
|
||||
updateMinMax(scale);
|
||||
Utilities.unlockOrientation(parentActivity);
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
zoomAnimation = false;
|
||||
}
|
||||
if (!scroller.isFinished()) {
|
||||
@ -2023,10 +2096,10 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (scale >= 1.0f) {
|
||||
ImageReceiver sideImage = null;
|
||||
float k = 1;
|
||||
if (currentTranslationX > maxX + Utilities.dp(20)) {
|
||||
if (currentTranslationX > maxX + AndroidUtilities.dp(20)) {
|
||||
k = -1;
|
||||
sideImage = leftImage;
|
||||
} else if (currentTranslationX < minX - Utilities.dp(20)) {
|
||||
} else if (currentTranslationX < minX - AndroidUtilities.dp(20)) {
|
||||
sideImage = rightImage;
|
||||
}
|
||||
|
||||
@ -2078,9 +2151,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
layoutParams.topMargin = Utilities.dp(48);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(48);
|
||||
} else {
|
||||
layoutParams.topMargin = Utilities.dp(58);
|
||||
layoutParams.topMargin = AndroidUtilities.dp(58);
|
||||
}
|
||||
checkImageView.setLayoutParams(layoutParams);
|
||||
return false;
|
||||
@ -2105,7 +2178,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
loadFile = true;
|
||||
}
|
||||
} else {
|
||||
File cacheFile = new File(Utilities.getCacheDir(), currentFileName);
|
||||
File cacheFile = new File(AndroidUtilities.getCacheDir(), currentFileName);
|
||||
if (cacheFile.exists()) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.fromFile(cacheFile), "video/mp4");
|
||||
|
@ -0,0 +1,418 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.AnimationDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBar;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ChatActivityEnterView;
|
||||
|
||||
public class PopupNotificationActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private ActionBarLayer actionBarLayer;
|
||||
private ChatActivityEnterView chatActivityEnterView;
|
||||
private BackupImageView avatarImageView;
|
||||
private TextView messageText;
|
||||
private TextView countText;
|
||||
private View textScroll;
|
||||
|
||||
private int classGuid;
|
||||
private TLRPC.User currentUser;
|
||||
private TLRPC.Chat currentChat;
|
||||
private boolean finished = false;
|
||||
private CharSequence lastPrintString;
|
||||
private MessageObject currentMessageObject = null;
|
||||
private int currentMessageNum = 0;
|
||||
private PowerManager.WakeLock wakeLock = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
classGuid = ConnectionsManager.getInstance().generateClassGuid();
|
||||
NotificationCenter.getInstance().addObserver(this, 1234);
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.pushMessagesUpdated);
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||
|
||||
chatActivityEnterView = new ChatActivityEnterView();
|
||||
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
|
||||
@Override
|
||||
public void onMessageSend() {
|
||||
MessagesController.getInstance().pushMessages.remove(0);
|
||||
currentMessageObject = null;
|
||||
getNewMessage();
|
||||
//MessagesController.getInstance().markDialogAsRead(dialog_id, messages.get(0).messageOwner.id, minMessageId, 0, maxDate, wasUnread);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void needSendTyping() {
|
||||
if (currentMessageObject != null) {
|
||||
MessagesController.getInstance().sendTyping(currentMessageObject.getDialogId(), classGuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setContentView(R.layout.popup_notification_layout);
|
||||
RelativeLayout popupContainer = (RelativeLayout) findViewById(R.id.popup_container);
|
||||
messageText = (TextView)findViewById(R.id.message_text);
|
||||
View messageContainer = findViewById(R.id.text_container);
|
||||
messageContainer.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openCurrentMessage();
|
||||
}
|
||||
});
|
||||
|
||||
ActionBar actionBar = new ActionBar(this);
|
||||
popupContainer.addView(actionBar);
|
||||
ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
|
||||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
actionBar.setLayoutParams(layoutParams);
|
||||
|
||||
actionBarLayer = actionBar.createLayer();
|
||||
actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back);
|
||||
actionBarLayer.setBackgroundResource(R.color.header);
|
||||
actionBarLayer.setItemsBackground(R.drawable.bar_selector);
|
||||
actionBar.setCurrentActionBarLayer(actionBarLayer);
|
||||
|
||||
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||
View view = menu.addItemResource(2, R.layout.popup_count_layout);
|
||||
countText = (TextView) view.findViewById(R.id.count_text);
|
||||
|
||||
view = menu.addItemResource(1, R.layout.chat_header_layout);
|
||||
avatarImageView = (BackupImageView)view.findViewById(R.id.chat_avatar_image);
|
||||
avatarImageView.processDetach = false;
|
||||
|
||||
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finish();
|
||||
} else if (id == 1) {
|
||||
openCurrentMessage();
|
||||
} else if (id == 2) {
|
||||
if (MessagesController.getInstance().pushMessages.size() > 1) {
|
||||
if (currentMessageNum < MessagesController.getInstance().pushMessages.size() - 1) {
|
||||
currentMessageNum++;
|
||||
} else {
|
||||
currentMessageNum = 0;
|
||||
}
|
||||
currentMessageObject = MessagesController.getInstance().pushMessages.get(currentMessageNum);
|
||||
updateInterfaceForCurrentMessage();
|
||||
countText.setText(String.format("%d/%d", currentMessageNum + 1, MessagesController.getInstance().pushMessages.size()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
chatActivityEnterView.setContainerView(this, findViewById(R.id.chat_layout));
|
||||
|
||||
PowerManager pm = (PowerManager)ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
|
||||
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
handleIntent(intent);
|
||||
}
|
||||
|
||||
public void handleIntent(Intent intent) {
|
||||
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
||||
if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) {
|
||||
getWindow().addFlags(
|
||||
WindowManager.LayoutParams.FLAG_DIM_BEHIND |
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
|
||||
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
} else {
|
||||
getWindow().addFlags(
|
||||
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
|
||||
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
|
||||
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
}
|
||||
|
||||
if (currentMessageObject == null) {
|
||||
currentMessageNum = 0;
|
||||
getNewMessage();
|
||||
}
|
||||
wakeLock.acquire(7000);
|
||||
}
|
||||
|
||||
private void getNewMessage() {
|
||||
if (MessagesController.getInstance().pushMessages.isEmpty()) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
if ((currentMessageNum != 0 || chatActivityEnterView.hasText()) && currentMessageObject != null) {
|
||||
for (int a = 0; a < MessagesController.getInstance().pushMessages.size(); a++) {
|
||||
if (MessagesController.getInstance().pushMessages.get(a).messageOwner.id == currentMessageObject.messageOwner.id) {
|
||||
currentMessageNum = a;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
currentMessageObject = MessagesController.getInstance().pushMessages.get(0);
|
||||
updateInterfaceForCurrentMessage();
|
||||
}
|
||||
countText.setText(String.format("%d/%d", currentMessageNum + 1, MessagesController.getInstance().pushMessages.size()));
|
||||
}
|
||||
|
||||
private void openCurrentMessage() {
|
||||
if (currentMessageObject == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
long dialog_id = currentMessageObject.getDialogId();
|
||||
if ((int)dialog_id != 0) {
|
||||
int lower_id = (int)dialog_id;
|
||||
if (lower_id < 0) {
|
||||
intent.putExtra("chatId", -lower_id);
|
||||
} else {
|
||||
intent.putExtra("userId", lower_id);
|
||||
}
|
||||
} else {
|
||||
intent.putExtra("encId", (int)(dialog_id >> 32));
|
||||
}
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
intent.setFlags(0x00008000);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
private void updateInterfaceForCurrentMessage() {
|
||||
if (actionBarLayer == null) {
|
||||
return;
|
||||
}
|
||||
currentChat = null;
|
||||
currentUser = null;
|
||||
long dialog_id = currentMessageObject.getDialogId();
|
||||
chatActivityEnterView.setDialogId(dialog_id);
|
||||
if ((int)dialog_id != 0) {
|
||||
int lower_id = (int)dialog_id;
|
||||
if (lower_id > 0) {
|
||||
currentUser = MessagesController.getInstance().users.get(lower_id);
|
||||
} else {
|
||||
currentChat = MessagesController.getInstance().chats.get(-lower_id);
|
||||
currentUser = MessagesController.getInstance().users.get(currentMessageObject.messageOwner.from_id);
|
||||
}
|
||||
} else {
|
||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
||||
currentUser = MessagesController.getInstance().users.get(encryptedChat.user_id);
|
||||
}
|
||||
|
||||
if (currentChat != null && currentUser != null) {
|
||||
actionBarLayer.setTitle(currentChat.title);
|
||||
actionBarLayer.setSubtitle(Utilities.formatName(currentUser.first_name, currentUser.last_name));
|
||||
} else if (currentUser != null) {
|
||||
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name));
|
||||
if ((int)dialog_id == 0) {
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
|
||||
} else {
|
||||
actionBarLayer.setTitleIcon(0, 0);
|
||||
}
|
||||
}
|
||||
messageText.setTextSize(TypedValue.COMPLEX_UNIT_SP, MessagesController.getInstance().fontSize);
|
||||
messageText.setText(currentMessageObject.messageText);
|
||||
updateSubtitle();
|
||||
checkAndUpdateAvatar();
|
||||
}
|
||||
|
||||
private void updateSubtitle() {
|
||||
if (actionBarLayer == null) {
|
||||
return;
|
||||
}
|
||||
if (currentChat != null || currentUser == null) {
|
||||
return;
|
||||
}
|
||||
if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) {
|
||||
if (currentUser.phone != null && currentUser.phone.length() != 0) {
|
||||
actionBarLayer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
|
||||
} else {
|
||||
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name));
|
||||
}
|
||||
} else {
|
||||
actionBarLayer.setTitle(Utilities.formatName(currentUser.first_name, currentUser.last_name));
|
||||
}
|
||||
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
|
||||
if (printString == null || printString.length() == 0) {
|
||||
lastPrintString = null;
|
||||
setTypingAnimation(false);
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(currentUser.id);
|
||||
if (user != null) {
|
||||
currentUser = user;
|
||||
}
|
||||
actionBarLayer.setSubtitle(LocaleController.formatUserStatus(currentUser));
|
||||
} else {
|
||||
lastPrintString = printString;
|
||||
actionBarLayer.setSubtitle(printString);
|
||||
setTypingAnimation(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAndUpdateAvatar() {
|
||||
TLRPC.FileLocation newPhoto = null;
|
||||
int placeHolderId = 0;
|
||||
if (currentChat != null) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(currentChat.id);
|
||||
if (chat == null) {
|
||||
return;
|
||||
}
|
||||
currentChat = chat;
|
||||
if (currentChat.photo != null) {
|
||||
newPhoto = currentChat.photo.photo_small;
|
||||
}
|
||||
placeHolderId = Utilities.getGroupAvatarForId(currentChat.id);
|
||||
} else if (currentUser != null) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(currentUser.id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
currentUser = user;
|
||||
if (currentUser.photo != null) {
|
||||
newPhoto = currentUser.photo.photo_small;
|
||||
}
|
||||
placeHolderId = Utilities.getUserAvatarForId(currentUser.id);
|
||||
}
|
||||
if (avatarImageView != null) {
|
||||
avatarImageView.setImage(newPhoto, "50_50", placeHolderId);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTypingAnimation(boolean start) {
|
||||
if (actionBarLayer == null) {
|
||||
return;
|
||||
}
|
||||
if (start) {
|
||||
try {
|
||||
actionBarLayer.setSubTitleIcon(R.drawable.typing_dots, AndroidUtilities.dp(4));
|
||||
AnimationDrawable mAnim = (AnimationDrawable)actionBarLayer.getSubTitleIcon();
|
||||
mAnim.setAlpha(200);
|
||||
mAnim.start();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else {
|
||||
actionBarLayer.setSubTitleIcon(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (chatActivityEnterView.isEmojiPopupShowing()) {
|
||||
chatActivityEnterView.hideEmojiPopup();
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.setFieldFocused(true);
|
||||
}
|
||||
ConnectionsManager.getInstance().setAppPaused(false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
overridePendingTransition(0, 0);
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.hideEmojiPopup();
|
||||
chatActivityEnterView.setFieldFocused(false);
|
||||
}
|
||||
ConnectionsManager.getInstance().setAppPaused(true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == 1234) {
|
||||
onFinish();
|
||||
finish();
|
||||
} else if (id == MessagesController.pushMessagesUpdated) {
|
||||
getNewMessage();
|
||||
} else if (id == MessagesController.updateInterfaces) {
|
||||
if (currentMessageObject == null) {
|
||||
return;
|
||||
}
|
||||
int updateMask = (Integer)args[0];
|
||||
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0) {
|
||||
updateSubtitle();
|
||||
}
|
||||
if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
|
||||
checkAndUpdateAvatar();
|
||||
}
|
||||
if ((updateMask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) {
|
||||
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
|
||||
if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) {
|
||||
updateSubtitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
onFinish();
|
||||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onFinish() {
|
||||
if (finished) {
|
||||
return;
|
||||
}
|
||||
finished = true;
|
||||
NotificationCenter.getInstance().removeObserver(this, 1234);
|
||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.pushMessagesUpdated);
|
||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.onDestroy();
|
||||
}
|
||||
if (wakeLock.isHeld()) {
|
||||
wakeLock.release();
|
||||
}
|
||||
}
|
||||
}
|
@ -26,15 +26,21 @@ import android.widget.AdapterView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
|
||||
public class ProfileNotificationsActivity extends BaseFragment {
|
||||
public class ProfileNotificationsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private ListView listView;
|
||||
private long dialog_id;
|
||||
@ -50,20 +56,22 @@ public class ProfileNotificationsActivity extends BaseFragment {
|
||||
dialog_id = args.getLong("dialog_id");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
settingsNotificationsRow = rowCount++;
|
||||
settingsVibrateRow = rowCount++;
|
||||
settingsLedRow = rowCount++;
|
||||
settingsSoundRow = rowCount++;
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.notificationsSettingsUpdated);
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.notificationsSettingsUpdated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
@ -112,6 +120,9 @@ public class ProfileNotificationsActivity extends BaseFragment {
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
if (i == settingsNotificationsRow) {
|
||||
updateServerNotificationsSettings();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
@ -211,6 +222,45 @@ public class ProfileNotificationsActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public void updateServerNotificationsSettings() {
|
||||
if ((int)dialog_id == 0) {
|
||||
return;
|
||||
}
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
|
||||
req.settings = new TLRPC.TL_inputPeerNotifySettings();
|
||||
req.settings.sound = "default";
|
||||
req.settings.events_mask = 0;
|
||||
req.settings.mute_until = preferences.getInt("notify2_" + dialog_id, 0) != 2 ? 0 : Integer.MAX_VALUE;
|
||||
req.settings.show_previews = preferences.getBoolean("preview_" + dialog_id, true);
|
||||
|
||||
req.peer = new TLRPC.TL_inputNotifyPeer();
|
||||
|
||||
if ((int)dialog_id < 0) {
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer = new TLRPC.TL_inputPeerChat();
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer.chat_id = -(int)dialog_id;
|
||||
} else {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get((int)dialog_id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer = new TLRPC.TL_inputPeerForeign();
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer = new TLRPC.TL_inputPeerContact();
|
||||
}
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer.user_id = (int)dialog_id;
|
||||
}
|
||||
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
@ -248,6 +298,13 @@ public class ProfileNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.notificationsSettingsUpdated) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
|
@ -34,17 +34,19 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.SerializedData;
|
||||
import org.telegram.messenger.TLClassStore;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -167,7 +169,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
};
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||
@ -301,7 +303,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
final TextView message = new TextView(getParentActivity());
|
||||
message.setText(Html.fromHtml(LocaleController.getString("AskAQuestionInfo", R.string.AskAQuestionInfo)));
|
||||
message.setTextSize(18);
|
||||
message.setPadding(Utilities.dp(8), Utilities.dp(5), Utilities.dp(8), Utilities.dp(6));
|
||||
message.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(5), AndroidUtilities.dp(8), AndroidUtilities.dp(6));
|
||||
message.setMovementMethod(new LinkMovementMethodMy());
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
@ -362,7 +364,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
MessagesController.getInstance().registerForPush(UserConfig.pushString);
|
||||
ConnectionsManager.getInstance().initPushConnection();
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
@ -479,7 +481,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.user_id = UserConfig.getClientUserId();
|
||||
@ -528,7 +530,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
if (datacentersBytes != null) {
|
||||
SerializedData data = new SerializedData(datacentersBytes);
|
||||
supportUser = (TLRPC.User)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
|
||||
|
||||
if (supportUser != null && supportUser.id == 333000) {
|
||||
supportUser = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -583,7 +587,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
} else {
|
||||
MessagesController.getInstance().users.putIfAbsent(supportUser.id, supportUser);
|
||||
Bundle args = new Bundle();
|
||||
@ -794,7 +798,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
}
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -806,7 +810,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
textView.setText(LocaleController.getString("Online", R.string.Online));
|
||||
|
||||
textView = (TextView)view.findViewById(R.id.settings_name);
|
||||
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
||||
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
|
||||
textView.setTypeface(typeface);
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId());
|
||||
if (user == null) {
|
||||
@ -950,12 +954,16 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.clear().commit();
|
||||
NotificationCenter.getInstance().postNotificationName(1234);
|
||||
MessagesController.getInstance().unregistedPush();
|
||||
MessagesController.getInstance().logOut();
|
||||
UserConfig.clearConfig();
|
||||
MessagesStorage.getInstance().cleanUp();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
ContactsController.getInstance().deleteAllAppAccounts();
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
|
@ -20,11 +20,11 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -148,7 +148,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -220,7 +220,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
ConnectionsManager.getInstance().bindRequestToGuid(requestId, classGuid);
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
|
@ -19,16 +19,16 @@ import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
||||
public class SettingsChangeNameActivity extends BaseFragment {
|
||||
@ -120,7 +120,7 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,12 +143,12 @@ public class SettingsChangeNameActivity extends BaseFragment {
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenAnimationEnd() {
|
||||
firstNameField.requestFocus();
|
||||
Utilities.showKeyboard(firstNameField);
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
}
|
||||
|
@ -27,12 +27,13 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -41,7 +42,7 @@ import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Views.ColorPickerView;
|
||||
|
||||
public class SettingsNotificationsActivity extends BaseFragment {
|
||||
public class SettingsNotificationsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
private ListView listView;
|
||||
private boolean reseting = false;
|
||||
|
||||
@ -52,12 +53,14 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
private int messageVibrateRow;
|
||||
private int messageSoundRow;
|
||||
private int messageLedRow;
|
||||
private int messagePopupNotificationRow;
|
||||
private int groupSectionRow;
|
||||
private int groupAlertRow;
|
||||
private int groupPreviewRow;
|
||||
private int groupVibrateRow;
|
||||
private int groupSoundRow;
|
||||
private int groupLedRow;
|
||||
private int groupPopupNotificationRow;
|
||||
private int inappSectionRow;
|
||||
private int inappSoundRow;
|
||||
private int inappVibrateRow;
|
||||
@ -78,12 +81,14 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
messagePreviewRow = rowCount++;
|
||||
messageVibrateRow = rowCount++;
|
||||
messageLedRow = rowCount++;
|
||||
messagePopupNotificationRow = rowCount++;
|
||||
messageSoundRow = rowCount++;
|
||||
groupSectionRow = rowCount++;
|
||||
groupAlertRow = rowCount++;
|
||||
groupPreviewRow = rowCount++;
|
||||
groupVibrateRow = rowCount++;
|
||||
groupLedRow = rowCount++;
|
||||
groupPopupNotificationRow = rowCount++;
|
||||
groupSoundRow = rowCount++;
|
||||
inappSectionRow = rowCount++;
|
||||
inappSoundRow = rowCount++;
|
||||
@ -96,9 +101,17 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
resetSectionRow = rowCount++;
|
||||
resetNotificationsRow = rowCount++;
|
||||
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.notificationsSettingsUpdated);
|
||||
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.notificationsSettingsUpdated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(LayoutInflater inflater, ViewGroup container) {
|
||||
if (fragmentView == null) {
|
||||
@ -134,10 +147,10 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
updateServerNotificationsSettings(i == groupAlertRow);
|
||||
} else if (i == messagePreviewRow || i == groupPreviewRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
boolean enabledAll = true;
|
||||
boolean enabled;
|
||||
if (i == messagePreviewRow) {
|
||||
enabled = preferences.getBoolean("EnablePreviewAll", true);
|
||||
@ -148,6 +161,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
updateServerNotificationsSettings(i == groupPreviewRow);
|
||||
} else if (i == messageVibrateRow || i == groupVibrateRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -228,7 +242,7 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
} else if (i == inappSoundRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -342,6 +356,32 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
});
|
||||
showAlertDialog(builder);
|
||||
} else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
|
||||
builder.setItems(new CharSequence[] {
|
||||
LocaleController.getString("NoPopup", R.string.NoPopup),
|
||||
LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
|
||||
LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
|
||||
LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup)
|
||||
}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
if (i == messagePopupNotificationRow) {
|
||||
editor.putInt("popupAll", which);
|
||||
} else if (i == groupPopupNotificationRow) {
|
||||
editor.putInt("popupGroup", which);
|
||||
}
|
||||
editor.commit();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showAlertDialog(builder);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -354,6 +394,29 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
public void updateServerNotificationsSettings(boolean group) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
TLRPC.TL_account_updateNotifySettings req = new TLRPC.TL_account_updateNotifySettings();
|
||||
req.settings = new TLRPC.TL_inputPeerNotifySettings();
|
||||
req.settings.sound = "default";
|
||||
req.settings.events_mask = 0;
|
||||
if (!group) {
|
||||
req.peer = new TLRPC.TL_inputNotifyUsers();
|
||||
req.settings.mute_until = preferences.getBoolean("EnableAll", true) ? 0 : Integer.MAX_VALUE;
|
||||
req.settings.show_previews = preferences.getBoolean("EnablePreviewAll", true);
|
||||
} else {
|
||||
req.peer = new TLRPC.TL_inputNotifyChats();
|
||||
req.settings.mute_until = preferences.getBoolean("EnableGroup", true) ? 0 : Integer.MAX_VALUE;
|
||||
req.settings.show_previews = preferences.getBoolean("EnablePreviewGroup", true);
|
||||
}
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
@ -396,6 +459,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.notificationsSettingsUpdated) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
@ -553,6 +623,24 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
||||
textView.setText(LocaleController.getString("ResetAllNotifications", R.string.ResetAllNotifications));
|
||||
textViewDetail.setText(LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom));
|
||||
divider.setVisibility(View.INVISIBLE);
|
||||
} else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
|
||||
textView.setText(LocaleController.getString("PopupNotification", R.string.PopupNotification));
|
||||
int option = 0;
|
||||
if (i == messagePopupNotificationRow) {
|
||||
option = preferences.getInt("popupAll", 0);
|
||||
} else if (i == groupPopupNotificationRow) {
|
||||
option = preferences.getInt("popupGroup", 0);
|
||||
}
|
||||
if (option == 0) {
|
||||
textViewDetail.setText(LocaleController.getString("NoPopup", R.string.NoPopup));
|
||||
} else if (option == 1) {
|
||||
textViewDetail.setText(LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn));
|
||||
} else if (option == 2) {
|
||||
textViewDetail.setText(LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff));
|
||||
} else if (option == 3) {
|
||||
textViewDetail.setText(LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup));
|
||||
}
|
||||
divider.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else if (type == 3) {
|
||||
if (view == null) {
|
||||
|
@ -29,13 +29,14 @@ import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -111,8 +112,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
boolean done;
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
int width = Utilities.displaySize.x;
|
||||
int height = Utilities.displaySize.y;
|
||||
int width = AndroidUtilities.displaySize.x;
|
||||
int height = AndroidUtilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
@ -120,7 +121,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
}
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(Utilities.getCacheDir(), fileName);
|
||||
File f = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
|
||||
try {
|
||||
done = Utilities.copyFile(f, toFile);
|
||||
@ -216,7 +217,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
if (requestCode == 10) {
|
||||
Utilities.addMediaToGallery(currentPicturePath);
|
||||
try {
|
||||
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, null, Utilities.dp(320), Utilities.dp(480));
|
||||
Bitmap bitmap = FileLoader.loadBitmap(currentPicturePath, null, AndroidUtilities.dp(320), AndroidUtilities.dp(480));
|
||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
||||
FileOutputStream stream = new FileOutputStream(toFile);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
|
||||
@ -232,7 +233,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Bitmap bitmap = FileLoader.loadBitmap(null, data.getData(), Utilities.dp(320), Utilities.dp(480));
|
||||
Bitmap bitmap = FileLoader.loadBitmap(null, data.getData(), AndroidUtilities.dp(320), AndroidUtilities.dp(480));
|
||||
File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper-temp.jpg");
|
||||
FileOutputStream stream = new FileOutputStream(toFile);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
|
||||
@ -261,8 +262,8 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
private void processSelectedBackground() {
|
||||
TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground);
|
||||
if (selectedBackground != -1 && selectedBackground != 1000001 && wallPaper != null && wallPaper instanceof TLRPC.TL_wallPaper) {
|
||||
int width = Utilities.displaySize.x;
|
||||
int height = Utilities.displaySize.y;
|
||||
int width = AndroidUtilities.displaySize.x;
|
||||
int height = AndroidUtilities.displaySize.y;
|
||||
if (width > height) {
|
||||
int temp = width;
|
||||
width = height;
|
||||
@ -270,7 +271,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
}
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, width, height);
|
||||
String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg";
|
||||
File f = new File(Utilities.getCacheDir(), fileName);
|
||||
File f = new File(AndroidUtilities.getCacheDir(), fileName);
|
||||
if (!f.exists()) {
|
||||
progressBar.setProgress(0);
|
||||
loadingFile = fileName;
|
||||
@ -413,7 +414,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
}
|
||||
});
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
|
||||
}
|
||||
|
||||
@ -528,7 +529,7 @@ public class SettingsWallpapersActivity extends BaseFragment implements Notifica
|
||||
BackupImageView image = (BackupImageView)view.findViewById(R.id.image);
|
||||
View selection = view.findViewById(R.id.selection);
|
||||
TLRPC.WallPaper wallPaper = wallPapers.get(i - 1);
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, Utilities.dp(100), Utilities.dp(100));
|
||||
TLRPC.PhotoSize size = PhotoObject.getClosestPhotoSizeWithSize(wallPaper.sizes, AndroidUtilities.dp(100), AndroidUtilities.dp(100));
|
||||
if (size != null && size.location != null) {
|
||||
image.setImage(size.location, "100_100", 0);
|
||||
}
|
||||
|
@ -23,15 +23,16 @@ import android.widget.ImageButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.MessagesStorage;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
@ -51,7 +52,6 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
private ListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private int user_id;
|
||||
private String selectedPhone;
|
||||
private int totalMediaCount = -1;
|
||||
private boolean creatingChat = false;
|
||||
private long dialog_id;
|
||||
@ -129,7 +129,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
actionBarLayer.setBackOverlay(R.layout.updating_state_layout);
|
||||
if (dialog_id != 0) {
|
||||
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
||||
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, AndroidUtilities.dp(4));
|
||||
} else {
|
||||
actionBarLayer.setTitle(LocaleController.getString("ContactInfo", R.string.ContactInfo));
|
||||
}
|
||||
@ -159,7 +159,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
|
||||
}
|
||||
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
||||
});
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
@ -384,7 +384,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.user_id = user_id;
|
||||
@ -533,7 +533,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
||||
}
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
||||
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
||||
Typeface typeface = AndroidUtilities.getTypeface("fonts/rmedium.ttf");
|
||||
textView.setTypeface(typeface);
|
||||
|
||||
textView.setText(Utilities.formatName(user.first_name, user.last_name));
|
||||
@ -572,29 +572,20 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
if (user.phone == null || user.phone.length() == 0 || getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
selectedPhone = user.phone;
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
|
||||
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 1) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + selectedPhone));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getParentActivity().startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == 0) {
|
||||
if (i == 0) {
|
||||
int sdk = android.os.Build.VERSION.SDK_INT;
|
||||
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setText(selectedPhone);
|
||||
clipboard.setText(user.phone);
|
||||
} else {
|
||||
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedPhone);
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", user.phone);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
}
|
||||
@ -603,21 +594,37 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
||||
showAlertDialog(builder);
|
||||
}
|
||||
});
|
||||
}
|
||||
ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
||||
return;
|
||||
ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
||||
return;
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user_id);
|
||||
presentFragment(new ChatActivity(args), true);
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user_id);
|
||||
presentFragment(new ChatActivity(args), true);
|
||||
}
|
||||
});
|
||||
});
|
||||
button = (ImageButton)view.findViewById(R.id.settings_call_phone);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + user.phone));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getParentActivity().startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
ImageButton button = (ImageButton)view.findViewById(R.id.settings_call_phone);
|
||||
button.setVisibility(user.phone == null || user.phone.length() == 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
||||
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
||||
View divider = view.findViewById(R.id.settings_row_divider);
|
||||
|
@ -19,6 +19,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
@ -52,7 +53,7 @@ public class ActionBar extends FrameLayout {
|
||||
addView(shadowView);
|
||||
shadowView.setVisibility(INVISIBLE);
|
||||
ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(2);
|
||||
layoutParams.width = AndroidUtilities.dp(2);
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
shadowView.setLayoutParams(layoutParams);
|
||||
shadowView.setBackgroundResource(R.drawable.shadow);
|
||||
@ -116,7 +117,7 @@ public class ActionBar extends FrameLayout {
|
||||
layoutParams.width = LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
layer.setLayoutParams(layoutParams);
|
||||
shadowView.setX(-Utilities.dp(2));
|
||||
shadowView.setX(-AndroidUtilities.dp(2));
|
||||
shadowView.setVisibility(VISIBLE);
|
||||
previousLayer.setBackOverlayVisible(isBackOverlayVisible);
|
||||
}
|
||||
@ -143,7 +144,7 @@ public class ActionBar extends FrameLayout {
|
||||
return;
|
||||
}
|
||||
currentLayer.setX(dx);
|
||||
shadowView.setX(dx - Utilities.dp(2));
|
||||
shadowView.setX(dx - AndroidUtilities.dp(2));
|
||||
if (dx != 0) {
|
||||
if (previousLayer != null) {
|
||||
previousLayer.setAlpha(Math.min(1, (float) dx / (float) currentLayer.getMeasuredWidth()));
|
||||
@ -159,11 +160,11 @@ public class ActionBar extends FrameLayout {
|
||||
public void setupAnimations(ArrayList<Animator> animators, boolean back) {
|
||||
if (back) {
|
||||
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", 0));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -Utilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 0));
|
||||
} else {
|
||||
animators.add(ObjectAnimator.ofFloat(currentLayer, "x", getMeasuredWidth()));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", getMeasuredWidth() - Utilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", getMeasuredWidth() - AndroidUtilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(previousLayer, "alpha", 1.0f));
|
||||
}
|
||||
}
|
||||
@ -171,9 +172,9 @@ public class ActionBar extends FrameLayout {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(40), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(40), MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Utilities.dp(48), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
@ -139,7 +140,7 @@ public class ActionBarActivity extends Activity {
|
||||
contentView.addView(shadowView);
|
||||
shadowView.setBackgroundResource(R.drawable.shadow);
|
||||
ViewGroup.LayoutParams layoutParams = shadowView.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(2);
|
||||
layoutParams.width = AndroidUtilities.dp(2);
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
shadowView.setLayoutParams(layoutParams);
|
||||
shadowView.setVisibility(View.INVISIBLE);
|
||||
@ -202,7 +203,7 @@ public class ActionBarActivity extends Activity {
|
||||
containerViewBack.setX(0);
|
||||
actionBar.stopMoving(backAnimation);
|
||||
shadowView.setVisibility(View.INVISIBLE);
|
||||
shadowView.setX(-Utilities.dp(2));
|
||||
shadowView.setX(-AndroidUtilities.dp(2));
|
||||
if (!backAnimation) {
|
||||
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
lastFragment.onPause();
|
||||
@ -229,7 +230,7 @@ public class ActionBarActivity extends Activity {
|
||||
}
|
||||
}
|
||||
containerViewBack.setVisibility(View.GONE);
|
||||
Utilities.unlockOrientation(this);
|
||||
AndroidUtilities.unlockOrientation(this);
|
||||
startedTracking = false;
|
||||
animationInProgress = false;
|
||||
}
|
||||
@ -239,7 +240,7 @@ public class ActionBarActivity extends Activity {
|
||||
startedTracking = true;
|
||||
startedTrackingX = (int) ev.getX();
|
||||
shadowView.setVisibility(View.VISIBLE);
|
||||
shadowView.setX(-Utilities.dp(2));
|
||||
shadowView.setX(-AndroidUtilities.dp(2));
|
||||
containerViewBack.setVisibility(View.VISIBLE);
|
||||
beginTrackingSent = false;
|
||||
|
||||
@ -260,7 +261,7 @@ public class ActionBarActivity extends Activity {
|
||||
}
|
||||
lastFragment.onResume();
|
||||
|
||||
Utilities.lockOrientation(this);
|
||||
AndroidUtilities.lockOrientation(this);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
@ -284,12 +285,12 @@ public class ActionBarActivity extends Activity {
|
||||
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
|
||||
int dy = Math.abs((int)ev.getY() - startedTrackingY);
|
||||
velocityTracker.addMovement(ev);
|
||||
if (maybeStartTracking && !startedTracking && dx >= Utilities.dp(10) && Math.abs(dx) / 3 > dy) {
|
||||
if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.dp(10) && Math.abs(dx) / 3 > dy) {
|
||||
prepareForMoving(ev);
|
||||
} else if (startedTracking) {
|
||||
if (!beginTrackingSent) {
|
||||
if (getCurrentFocus() != null) {
|
||||
Utilities.hideKeyboard(getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
||||
}
|
||||
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
currentFragment.onBeginSlide();
|
||||
@ -297,7 +298,7 @@ public class ActionBarActivity extends Activity {
|
||||
}
|
||||
actionBar.moveActionBarByX(dx);
|
||||
containerView.setX(dx);
|
||||
shadowView.setX(dx - Utilities.dp(2));
|
||||
shadowView.setX(dx - AndroidUtilities.dp(2));
|
||||
}
|
||||
} else if (ev != null && ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
|
||||
if (velocityTracker == null) {
|
||||
@ -321,11 +322,11 @@ public class ActionBarActivity extends Activity {
|
||||
if (!backAnimation) {
|
||||
distToMove = containerView.getMeasuredWidth() - x;
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, "x", containerView.getMeasuredWidth()));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - Utilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", containerView.getMeasuredWidth() - AndroidUtilities.dp(2)));
|
||||
} else {
|
||||
distToMove = x;
|
||||
animators.add(ObjectAnimator.ofFloat(containerView, "x", 0));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -Utilities.dp(2)));
|
||||
animators.add(ObjectAnimator.ofFloat(shadowView, "x", -AndroidUtilities.dp(2)));
|
||||
}
|
||||
actionBar.setupAnimations(animators, backAnimation);
|
||||
|
||||
@ -439,9 +440,9 @@ public class ActionBarActivity extends Activity {
|
||||
int height = 0;
|
||||
if (actionBar.getVisibility() == View.VISIBLE) {
|
||||
if (!Utilities.isTablet(this) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
height = Utilities.dp(40);
|
||||
height = AndroidUtilities.dp(40);
|
||||
} else {
|
||||
height = Utilities.dp(48);
|
||||
height = AndroidUtilities.dp(48);
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,7 +501,7 @@ public class ActionBarActivity extends Activity {
|
||||
return false;
|
||||
}
|
||||
if (getCurrentFocus() != null) {
|
||||
Utilities.hideKeyboard(getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
||||
}
|
||||
boolean needAnimation = openAnimation != null && !forceWithoutAnimation && getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true);
|
||||
|
||||
@ -575,7 +576,7 @@ public class ActionBarActivity extends Activity {
|
||||
return;
|
||||
}
|
||||
if (getCurrentFocus() != null) {
|
||||
Utilities.hideKeyboard(getCurrentFocus());
|
||||
AndroidUtilities.hideKeyboard(getCurrentFocus());
|
||||
}
|
||||
boolean needAnimation = animated && closeAnimation != null && getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true);
|
||||
final BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
@ -634,6 +635,7 @@ public class ActionBarActivity extends Activity {
|
||||
}
|
||||
|
||||
public void removeFragmentFromStack(BaseFragment fragment) {
|
||||
fragment.onPause();
|
||||
fragment.onFragmentDestroy();
|
||||
fragment.setParentActivity(null);
|
||||
fragmentsStack.remove(fragment);
|
||||
|
@ -21,6 +21,7 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
@ -65,7 +66,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
layoutParams.height = LayoutParams.FILL_PARENT;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
backButtonFrameLayout.setLayoutParams(layoutParams);
|
||||
backButtonFrameLayout.setPadding(0, 0, Utilities.dp(4), 0);
|
||||
backButtonFrameLayout.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
||||
backButtonFrameLayout.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@ -99,7 +100,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
layoutParams.setMargins(Utilities.dp(3), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0);
|
||||
layoutParams.setMargins(AndroidUtilities.dp(3), (height - backButtonImageView.getDrawable().getIntrinsicHeight()) / 2, 0, 0);
|
||||
backButtonImageView.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
@ -110,11 +111,11 @@ public class ActionBarLayer extends FrameLayout {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
layoutParams.width = (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
layoutParams.height = (int)(logoImageView.getDrawable().getIntrinsicHeight() / 1.3f);
|
||||
layoutParams.setMargins(Utilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
|
||||
layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.height) / 2, 0, 0);
|
||||
} else {
|
||||
layoutParams.width = logoImageView.getDrawable().getIntrinsicWidth();
|
||||
layoutParams.height = logoImageView.getDrawable().getIntrinsicHeight();
|
||||
layoutParams.setMargins(Utilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
|
||||
layoutParams.setMargins(AndroidUtilities.dp(12), (height - layoutParams.width) / 2, 0, 0);
|
||||
}
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
logoImageView.setLayoutParams(layoutParams);
|
||||
@ -122,9 +123,9 @@ public class ActionBarLayer extends FrameLayout {
|
||||
}
|
||||
|
||||
private void positionTitle(int width, int height) {
|
||||
int offset = Utilities.dp(2);
|
||||
int offset = AndroidUtilities.dp(2);
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
offset = Utilities.dp(1);
|
||||
offset = AndroidUtilities.dp(1);
|
||||
}
|
||||
int maxTextWidth = 0;
|
||||
|
||||
@ -163,17 +164,17 @@ public class ActionBarLayer extends FrameLayout {
|
||||
|
||||
int x = 0;
|
||||
if (logoImageView == null || logoImageView.getVisibility() == GONE) {
|
||||
x = Utilities.dp(16);
|
||||
x = AndroidUtilities.dp(16);
|
||||
} else {
|
||||
if (!Utilities.isTablet(getContext()) && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
x = Utilities.dp(22) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
x = AndroidUtilities.dp(22) + (int)(logoImageView.getDrawable().getIntrinsicWidth() / 1.3f);
|
||||
} else {
|
||||
x = Utilities.dp(22) + logoImageView.getDrawable().getIntrinsicWidth();
|
||||
x = AndroidUtilities.dp(22) + logoImageView.getDrawable().getIntrinsicWidth();
|
||||
}
|
||||
}
|
||||
|
||||
if (menu != null) {
|
||||
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - Utilities.dp(16));
|
||||
maxTextWidth = Math.min(maxTextWidth, width - menu.getMeasuredWidth() - AndroidUtilities.dp(16));
|
||||
}
|
||||
|
||||
if (titleTextView != null && titleTextView.getVisibility() == VISIBLE) {
|
||||
@ -196,7 +197,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
}
|
||||
|
||||
ViewGroup.LayoutParams layoutParams1 = backButtonFrameLayout.getLayoutParams();
|
||||
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : Utilities.dp(6));
|
||||
layoutParams1.width = x + maxTextWidth + (isSearchFieldVisible ? 0 : AndroidUtilities.dp(6));
|
||||
backButtonFrameLayout.setLayoutParams(layoutParams1);
|
||||
}
|
||||
|
||||
@ -206,7 +207,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
}
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)menu.getLayoutParams();
|
||||
layoutParams.width = isSearchFieldVisible ? LayoutParams.MATCH_PARENT : LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.leftMargin = isSearchFieldVisible ? Utilities.dp(26) + logoImageView.getDrawable().getIntrinsicWidth() : 0;
|
||||
layoutParams.leftMargin = isSearchFieldVisible ? AndroidUtilities.dp(26) + logoImageView.getDrawable().getIntrinsicWidth() : 0;
|
||||
menu.setLayoutParams(layoutParams);
|
||||
menu.measure(width, height);
|
||||
}
|
||||
@ -402,7 +403,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
if (subTitleTextView != null) {
|
||||
subTitleTextView.setVisibility(visible ? GONE : VISIBLE);
|
||||
}
|
||||
backButtonFrameLayout.setPadding(0, 0, visible ? 0 : Utilities.dp(4), 0);
|
||||
backButtonFrameLayout.setPadding(0, 0, visible ? 0 : AndroidUtilities.dp(4), 0);
|
||||
if (visible) {
|
||||
oldUseLogo = logoImageView != null && logoImageView.getVisibility() == VISIBLE;
|
||||
setDisplayUseLogoEnabled(true, R.drawable.ic_ab_search);
|
||||
@ -495,7 +496,7 @@ public class ActionBarLayer extends FrameLayout {
|
||||
layoutParams.height = LayoutParams.MATCH_PARENT;
|
||||
actionOverlay.setLayoutParams(layoutParams);
|
||||
actionOverlay.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + Utilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0));
|
||||
layoutParams.width = Math.min(actionOverlay.getMeasuredWidth() + AndroidUtilities.dp(4), widthMeasureSpec - (menu != null ? menu.getMeasuredWidth() : 0));
|
||||
actionOverlay.setLayoutParams(layoutParams);
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
public class ActionBarMenu extends LinearLayout {
|
||||
|
||||
@ -68,7 +68,7 @@ public class ActionBarMenu extends LinearLayout {
|
||||
addView(menuItem);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)menuItem.getLayoutParams();
|
||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.width = Utilities.dp(56);
|
||||
layoutParams.width = AndroidUtilities.dp(56);
|
||||
menuItem.setLayoutParams(layoutParams);
|
||||
menuItem.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
@ -151,8 +152,8 @@ public class ActionBarMenuItem extends ImageView {
|
||||
delimeter.setBackgroundColor(0xffdcdcdc);
|
||||
popupLayout.addView(delimeter);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)delimeter.getLayoutParams();
|
||||
layoutParams.width = Utilities.dp(196);
|
||||
layoutParams.height = Utilities.density >= 3 ? 2 : 1;
|
||||
layoutParams.width = AndroidUtilities.dp(196);
|
||||
layoutParams.height = AndroidUtilities.density >= 3 ? 2 : 1;
|
||||
delimeter.setLayoutParams(layoutParams);
|
||||
delimeter.setTag(100 + id);
|
||||
}
|
||||
@ -160,19 +161,19 @@ public class ActionBarMenuItem extends ImageView {
|
||||
textView.setTextColor(0xff000000);
|
||||
textView.setBackgroundResource(R.drawable.list_selector);
|
||||
textView.setGravity(Gravity.CENTER_VERTICAL);
|
||||
textView.setPadding(Utilities.dp(16), 0, Utilities.dp(16), 0);
|
||||
textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0);
|
||||
textView.setTextSize(18);
|
||||
textView.setMinWidth(Utilities.dp(196));
|
||||
textView.setMinWidth(AndroidUtilities.dp(196));
|
||||
textView.setTag(id);
|
||||
textView.setText(text);
|
||||
if (icon != 0) {
|
||||
textView.setCompoundDrawablePadding(Utilities.dp(12));
|
||||
textView.setCompoundDrawablePadding(AndroidUtilities.dp(12));
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(icon), null, null, null);
|
||||
}
|
||||
popupLayout.addView(textView);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)textView.getLayoutParams();
|
||||
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
|
||||
layoutParams.height = Utilities.dp(48);
|
||||
layoutParams.height = AndroidUtilities.dp(48);
|
||||
textView.setLayoutParams(layoutParams);
|
||||
textView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
@ -201,7 +202,7 @@ public class ActionBarMenuItem extends ImageView {
|
||||
popupWindow.setClippingEnabled(true);
|
||||
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
popupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
||||
popupLayout.measure(MeasureSpec.makeMeasureSpec(Utilities.dp(1000), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(Utilities.dp(1000), MeasureSpec.AT_MOST));
|
||||
popupLayout.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST));
|
||||
}
|
||||
popupWindow.setFocusable(true);
|
||||
if (popupLayout.getMeasuredWidth() == 0) {
|
||||
@ -219,7 +220,7 @@ public class ActionBarMenuItem extends ImageView {
|
||||
if (searchField.getVisibility() == VISIBLE) {
|
||||
searchField.setVisibility(GONE);
|
||||
setVisibility(VISIBLE);
|
||||
Utilities.hideKeyboard(searchField);
|
||||
AndroidUtilities.hideKeyboard(searchField);
|
||||
if (listener != null) {
|
||||
listener.onSearchCollapse();
|
||||
}
|
||||
@ -229,7 +230,7 @@ public class ActionBarMenuItem extends ImageView {
|
||||
setVisibility(GONE);
|
||||
searchField.setText("");
|
||||
searchField.requestFocus();
|
||||
Utilities.showKeyboard(searchField);
|
||||
AndroidUtilities.showKeyboard(searchField);
|
||||
if (listener != null) {
|
||||
listener.onSearchExpand();
|
||||
}
|
||||
@ -254,13 +255,13 @@ public class ActionBarMenuItem extends ImageView {
|
||||
searchField.setTextColor(0xffffffff);
|
||||
searchField.setSingleLine(true);
|
||||
searchField.setBackgroundResource(R.drawable.search_light_states);
|
||||
searchField.setPadding(Utilities.dp(6), 0, Utilities.dp(6), 0);
|
||||
searchField.setPadding(AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6), 0);
|
||||
searchField.setInputType(EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
searchField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH || event != null && event.getAction() == KeyEvent.ACTION_UP && event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
|
||||
Utilities.hideKeyboard(searchField);
|
||||
AndroidUtilities.hideKeyboard(searchField);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -308,8 +309,8 @@ public class ActionBarMenuItem extends ImageView {
|
||||
layoutParams.weight = 1;
|
||||
layoutParams.width = 0;
|
||||
layoutParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
layoutParams.height = Utilities.dp(36);
|
||||
layoutParams.rightMargin = Utilities.dp(4);
|
||||
layoutParams.height = AndroidUtilities.dp(36);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(4);
|
||||
searchField.setLayoutParams(layoutParams);
|
||||
searchField.setVisibility(GONE);
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
@ -126,7 +127,7 @@ public class AvatarUpdater implements NotificationCenter.NotificationCenterDeleg
|
||||
}
|
||||
} else {
|
||||
UserConfig.saveConfig(false);
|
||||
uploadingAvatar = Utilities.getCacheDir() + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg";
|
||||
uploadingAvatar = AndroidUtilities.getCacheDir() + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg";
|
||||
NotificationCenter.getInstance().addObserver(AvatarUpdater.this, FileLoader.FileDidUpload);
|
||||
NotificationCenter.getInstance().addObserver(AvatarUpdater.this, FileLoader.FileDidFailUpload);
|
||||
FileLoader.getInstance().uploadFile(uploadingAvatar, false);
|
||||
|
@ -18,8 +18,6 @@ import android.view.View;
|
||||
|
||||
import org.telegram.messenger.TLRPC;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class BackupImageView extends View {
|
||||
public ImageReceiver imageReceiver;
|
||||
public boolean processDetach = true;
|
||||
|
@ -0,0 +1,643 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Rect;
|
||||
import android.os.PowerManager;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class ChatActivityEnterView implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate {
|
||||
|
||||
public static interface ChatActivityEnterViewDelegate {
|
||||
public abstract void onMessageSend();
|
||||
public abstract void needSendTyping();
|
||||
}
|
||||
|
||||
private EditText messsageEditText;
|
||||
private ImageButton sendButton;
|
||||
private PopupWindow emojiPopup;
|
||||
private ImageView emojiButton;
|
||||
private EmojiView emojiView;
|
||||
private TextView recordTimeText;
|
||||
private ImageButton audioSendButton;
|
||||
private View recordPanel;
|
||||
private View slideText;
|
||||
private PowerManager.WakeLock mWakeLock = null;
|
||||
private SizeNotifierRelativeLayout sizeNotifierRelativeLayout;
|
||||
|
||||
private int keyboardHeight = 0;
|
||||
private int keyboardHeightLand = 0;
|
||||
private boolean keyboardVisible;
|
||||
private boolean sendByEnter = false;
|
||||
private long lastTypingTimeSend = 0;
|
||||
private String lastTimeString = null;
|
||||
private float startedDraggingX = -1;
|
||||
private float distCanMove = AndroidUtilities.dp(80);
|
||||
private boolean recordingAudio = false;
|
||||
|
||||
private Activity parentActivity;
|
||||
private long dialog_id;
|
||||
private boolean ignoreTextChange = false;
|
||||
private ChatActivityEnterViewDelegate delegate;
|
||||
|
||||
public ChatActivityEnterView() {
|
||||
NotificationCenter.getInstance().addObserver(this, MediaController.recordStarted);
|
||||
NotificationCenter.getInstance().addObserver(this, MediaController.recordStartError);
|
||||
NotificationCenter.getInstance().addObserver(this, MediaController.recordStopped);
|
||||
NotificationCenter.getInstance().addObserver(this, MediaController.recordProgressChanged);
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.closeChats);
|
||||
NotificationCenter.getInstance().addObserver(this, MediaController.audioDidSent);
|
||||
NotificationCenter.getInstance().addObserver(this, 999);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
sendByEnter = preferences.getBoolean("send_by_enter", false);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStarted);
|
||||
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStartError);
|
||||
NotificationCenter.getInstance().removeObserver(this, MediaController.recordStopped);
|
||||
NotificationCenter.getInstance().removeObserver(this, MediaController.recordProgressChanged);
|
||||
NotificationCenter.getInstance().removeObserver(this, MessagesController.closeChats);
|
||||
NotificationCenter.getInstance().removeObserver(this, 999);
|
||||
if (mWakeLock != null) {
|
||||
try {
|
||||
mWakeLock.release();
|
||||
mWakeLock = null;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.delegate = null;
|
||||
sizeNotifierRelativeLayout = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContainerView(Activity activity, View containerView) {
|
||||
parentActivity = activity;
|
||||
|
||||
sizeNotifierRelativeLayout = (SizeNotifierRelativeLayout)containerView.findViewById(R.id.chat_layout);
|
||||
sizeNotifierRelativeLayout.delegate = this;
|
||||
|
||||
messsageEditText = (EditText)containerView.findViewById(R.id.chat_text_edit);
|
||||
messsageEditText.setHint(LocaleController.getString("TypeMessage", R.string.TypeMessage));
|
||||
|
||||
sendButton = (ImageButton)containerView.findViewById(R.id.chat_send_button);
|
||||
sendButton.setEnabled(false);
|
||||
sendButton.setVisibility(View.INVISIBLE);
|
||||
emojiButton = (ImageView)containerView.findViewById(R.id.chat_smile_button);
|
||||
audioSendButton = (ImageButton)containerView.findViewById(R.id.chat_audio_send_button);
|
||||
recordPanel = containerView.findViewById(R.id.record_panel);
|
||||
recordTimeText = (TextView)containerView.findViewById(R.id.recording_time_text);
|
||||
slideText = containerView.findViewById(R.id.slideText);
|
||||
TextView textView = (TextView)containerView.findViewById(R.id.slideToCancelTextView);
|
||||
textView.setText(LocaleController.getString("SlideToCancel", R.string.SlideToCancel));
|
||||
|
||||
emojiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (emojiPopup == null) {
|
||||
showEmojiPopup(true);
|
||||
} else {
|
||||
showEmojiPopup(!emojiPopup.isShowing());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messsageEditText.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
||||
if (i == 4 && !keyboardVisible && emojiPopup != null && emojiPopup.isShowing()) {
|
||||
if (keyEvent.getAction() == 1) {
|
||||
showEmojiPopup(false);
|
||||
}
|
||||
return true;
|
||||
} else if (i == KeyEvent.KEYCODE_ENTER && sendByEnter && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
sendMessage();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
messsageEditText.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messsageEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_SEND) {
|
||||
sendMessage();
|
||||
return true;
|
||||
} else if (sendByEnter) {
|
||||
if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
sendMessage();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
sendButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
sendMessage();
|
||||
}
|
||||
});
|
||||
|
||||
audioSendButton.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
startedDraggingX = -1;
|
||||
MediaController.getInstance().startRecording(dialog_id);
|
||||
updateAudioRecordIntefrace();
|
||||
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||
startedDraggingX = -1;
|
||||
MediaController.getInstance().stopRecording(true);
|
||||
recordingAudio = false;
|
||||
updateAudioRecordIntefrace();
|
||||
} else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && recordingAudio) {
|
||||
float x = motionEvent.getX();
|
||||
if (x < -distCanMove) {
|
||||
MediaController.getInstance().stopRecording(false);
|
||||
recordingAudio = false;
|
||||
updateAudioRecordIntefrace();
|
||||
}
|
||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||
x = x + audioSendButton.getX();
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams();
|
||||
if (startedDraggingX != -1) {
|
||||
float dist = (x - startedDraggingX);
|
||||
params.leftMargin = AndroidUtilities.dp(30) + (int)dist;
|
||||
slideText.setLayoutParams(params);
|
||||
float alpha = 1.0f + dist / distCanMove;
|
||||
if (alpha > 1) {
|
||||
alpha = 1;
|
||||
} else if (alpha < 0) {
|
||||
alpha = 0;
|
||||
}
|
||||
slideText.setAlpha(alpha);
|
||||
}
|
||||
if (x <= slideText.getX() + slideText.getWidth() + AndroidUtilities.dp(30)) {
|
||||
if (startedDraggingX == -1) {
|
||||
startedDraggingX = x;
|
||||
distCanMove = (recordPanel.getMeasuredWidth() - slideText.getMeasuredWidth() - AndroidUtilities.dp(48)) / 2.0f;
|
||||
if (distCanMove <= 0) {
|
||||
distCanMove = AndroidUtilities.dp(80);
|
||||
} else if (distCanMove > AndroidUtilities.dp(80)) {
|
||||
distCanMove = AndroidUtilities.dp(80);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (params.leftMargin > AndroidUtilities.dp(30)) {
|
||||
params.leftMargin = AndroidUtilities.dp(30);
|
||||
slideText.setLayoutParams(params);
|
||||
slideText.setAlpha(1);
|
||||
startedDraggingX = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
view.onTouchEvent(motionEvent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
messsageEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
String message = getTrimmedString(charSequence.toString());
|
||||
sendButton.setEnabled(message.length() != 0);
|
||||
checkSendButton();
|
||||
|
||||
if (message.length() != 0 && lastTypingTimeSend < System.currentTimeMillis() - 5000 && !ignoreTextChange) {
|
||||
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
|
||||
TLRPC.User currentUser = null;
|
||||
if ((int)dialog_id > 0) {
|
||||
currentUser = MessagesController.getInstance().users.get((int)dialog_id);
|
||||
}
|
||||
if (currentUser != null && currentUser.status != null && currentUser.status.expires < currentTime) {
|
||||
return;
|
||||
}
|
||||
lastTypingTimeSend = System.currentTimeMillis();
|
||||
if (delegate != null) {
|
||||
delegate.needSendTyping();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
if (sendByEnter && editable.length() > 0 && editable.charAt(editable.length() - 1) == '\n') {
|
||||
sendMessage();
|
||||
}
|
||||
int i = 0;
|
||||
ImageSpan[] arrayOfImageSpan = editable.getSpans(0, editable.length(), ImageSpan.class);
|
||||
int j = arrayOfImageSpan.length;
|
||||
while (true) {
|
||||
if (i >= j) {
|
||||
Emoji.replaceEmoji(editable, messsageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
return;
|
||||
}
|
||||
editable.removeSpan(arrayOfImageSpan[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
checkSendButton();
|
||||
}
|
||||
|
||||
private void sendMessage() {
|
||||
if (processSendingText(messsageEditText.getText().toString())) {
|
||||
messsageEditText.setText("");
|
||||
lastTypingTimeSend = 0;
|
||||
if (delegate != null) {
|
||||
delegate.onMessageSend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean processSendingText(String text) {
|
||||
text = getTrimmedString(text);
|
||||
if (text.length() != 0) {
|
||||
int count = (int)Math.ceil(text.length() / 2048.0f);
|
||||
for (int a = 0; a < count; a++) {
|
||||
String mess = text.substring(a * 2048, Math.min((a + 1) * 2048, text.length()));
|
||||
MessagesController.getInstance().sendMessage(mess, dialog_id);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getTrimmedString(String src) {
|
||||
String result = src.trim();
|
||||
if (result.length() == 0) {
|
||||
return result;
|
||||
}
|
||||
while (src.startsWith("\n")) {
|
||||
src = src.substring(1);
|
||||
}
|
||||
while (src.endsWith("\n")) {
|
||||
src = src.substring(0, src.length() - 1);
|
||||
}
|
||||
return src;
|
||||
}
|
||||
|
||||
private void checkSendButton() {
|
||||
String message = getTrimmedString(messsageEditText.getText().toString());
|
||||
if (message.length() > 0) {
|
||||
sendButton.setVisibility(View.VISIBLE);
|
||||
audioSendButton.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
sendButton.setVisibility(View.INVISIBLE);
|
||||
audioSendButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAudioRecordIntefrace() {
|
||||
if (recordingAudio) {
|
||||
try {
|
||||
if (mWakeLock == null) {
|
||||
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "audio record lock");
|
||||
mWakeLock.acquire();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
AndroidUtilities.lockOrientation(parentActivity);
|
||||
|
||||
recordPanel.setVisibility(View.VISIBLE);
|
||||
recordTimeText.setText("00:00");
|
||||
lastTimeString = null;
|
||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams();
|
||||
params.leftMargin = AndroidUtilities.dp(30);
|
||||
slideText.setLayoutParams(params);
|
||||
slideText.setAlpha(1);
|
||||
recordPanel.setX(AndroidUtilities.displaySize.x);
|
||||
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
recordPanel.setX(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
}
|
||||
}).setDuration(300).translationX(0).start();
|
||||
}
|
||||
} else {
|
||||
if (mWakeLock != null) {
|
||||
try {
|
||||
mWakeLock.release();
|
||||
mWakeLock = null;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
AndroidUtilities.unlockOrientation(parentActivity);
|
||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animator) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animator) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams)slideText.getLayoutParams();
|
||||
params.leftMargin = AndroidUtilities.dp(30);
|
||||
slideText.setLayoutParams(params);
|
||||
slideText.setAlpha(1);
|
||||
recordPanel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animator) {
|
||||
}
|
||||
}).setDuration(300).translationX(AndroidUtilities.displaySize.x).start();
|
||||
} else {
|
||||
recordPanel.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showEmojiPopup(boolean show) {
|
||||
InputMethodManager localInputMethodManager = (InputMethodManager)ApplicationLoader.applicationContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (show) {
|
||||
if (emojiPopup == null) {
|
||||
createEmojiPopup();
|
||||
}
|
||||
int currentHeight;
|
||||
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (keyboardHeight <= 0) {
|
||||
keyboardHeight = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height", AndroidUtilities.dp(200));
|
||||
}
|
||||
if (keyboardHeightLand <= 0) {
|
||||
keyboardHeightLand = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).getInt("kbd_height_land3", AndroidUtilities.dp(200));
|
||||
}
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
currentHeight = keyboardHeightLand;
|
||||
} else {
|
||||
currentHeight = keyboardHeight;
|
||||
}
|
||||
emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
|
||||
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(sizeNotifierRelativeLayout.getWidth(), View.MeasureSpec.EXACTLY));
|
||||
|
||||
emojiPopup.showAtLocation(parentActivity.getWindow().getDecorView(), 83, 0, 0);
|
||||
if (!keyboardVisible) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
|
||||
emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
|
||||
return;
|
||||
}
|
||||
emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
|
||||
return;
|
||||
}
|
||||
if (emojiButton != null) {
|
||||
emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
|
||||
}
|
||||
if (emojiPopup != null) {
|
||||
emojiPopup.dismiss();
|
||||
}
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.post(new Runnable() {
|
||||
public void run() {
|
||||
if (sizeNotifierRelativeLayout != null) {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void hideEmojiPopup() {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void createEmojiPopup() {
|
||||
if (parentActivity == null) {
|
||||
return;
|
||||
}
|
||||
emojiView = new EmojiView(parentActivity);
|
||||
emojiView.setListener(new EmojiView.Listener() {
|
||||
public void onBackspace() {
|
||||
messsageEditText.dispatchKeyEvent(new KeyEvent(0, 67));
|
||||
}
|
||||
|
||||
public void onEmojiSelected(String paramAnonymousString) {
|
||||
int i = messsageEditText.getSelectionEnd();
|
||||
CharSequence localCharSequence = Emoji.replaceEmoji(paramAnonymousString, messsageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
messsageEditText.setText(messsageEditText.getText().insert(i, localCharSequence));
|
||||
int j = i + localCharSequence.length();
|
||||
messsageEditText.setSelection(j, j);
|
||||
}
|
||||
});
|
||||
emojiPopup = new PopupWindow(emojiView);
|
||||
}
|
||||
|
||||
public void setDelegate(ChatActivityEnterViewDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void setDialogId(long id) {
|
||||
dialog_id = id;
|
||||
}
|
||||
|
||||
public void setFieldText(String text) {
|
||||
ignoreTextChange = true;
|
||||
messsageEditText.setText(text);
|
||||
messsageEditText.setSelection(messsageEditText.getText().length());
|
||||
ignoreTextChange = false;
|
||||
}
|
||||
|
||||
public void setFieldFocused(boolean focus) {
|
||||
if (messsageEditText == null) {
|
||||
return;
|
||||
}
|
||||
if (focus) {
|
||||
if (!messsageEditText.isFocused()) {
|
||||
messsageEditText.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (messsageEditText != null) {
|
||||
messsageEditText.requestFocus();
|
||||
}
|
||||
}
|
||||
}, 600);
|
||||
}
|
||||
} else {
|
||||
if (messsageEditText.isFocused() && !keyboardVisible) {
|
||||
messsageEditText.clearFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasText() {
|
||||
return messsageEditText != null && messsageEditText.length() > 0;
|
||||
}
|
||||
|
||||
public String getFieldText() {
|
||||
if (messsageEditText != null && messsageEditText.length() > 0) {
|
||||
return messsageEditText.getText().toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEmojiPopupShowing() {
|
||||
return emojiPopup != null && emojiPopup.isShowing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSizeChanged(int height) {
|
||||
Rect localRect = new Rect();
|
||||
parentActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect);
|
||||
|
||||
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager == null || manager.getDefaultDisplay() == null) {
|
||||
return;
|
||||
}
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
|
||||
if (height > AndroidUtilities.dp(50)) {
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
keyboardHeightLand = height;
|
||||
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
|
||||
} else {
|
||||
keyboardHeight = height;
|
||||
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height", keyboardHeight).commit();
|
||||
}
|
||||
}
|
||||
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
final WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams)emojiPopup.getContentView().getLayoutParams();
|
||||
layoutParams.width = sizeNotifierRelativeLayout.getWidth();
|
||||
if (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90) {
|
||||
layoutParams.height = keyboardHeightLand;
|
||||
} else {
|
||||
layoutParams.height = keyboardHeight;
|
||||
}
|
||||
wm.updateViewLayout(emojiPopup.getContentView(), layoutParams);
|
||||
if (!keyboardVisible) {
|
||||
sizeNotifierRelativeLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sizeNotifierRelativeLayout.setPadding(0, 0, 0, layoutParams.height);
|
||||
sizeNotifierRelativeLayout.requestLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
boolean oldValue = keyboardVisible;
|
||||
keyboardVisible = height > 0;
|
||||
if (keyboardVisible && sizeNotifierRelativeLayout.getPaddingBottom() > 0) {
|
||||
showEmojiPopup(false);
|
||||
} else if (!keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == 999) {
|
||||
if (emojiView != null) {
|
||||
emojiView.invalidateViews();
|
||||
}
|
||||
} else if (id == MediaController.recordProgressChanged) {
|
||||
Long time = (Long)args[0] / 1000;
|
||||
String str = String.format("%02d:%02d", time / 60, time % 60);
|
||||
if (lastTimeString == null || !lastTimeString.equals(str)) {
|
||||
if (recordTimeText != null) {
|
||||
recordTimeText.setText(str);
|
||||
}
|
||||
}
|
||||
} else if (id == MessagesController.closeChats) {
|
||||
if (messsageEditText != null && messsageEditText.isFocused()) {
|
||||
AndroidUtilities.hideKeyboard(messsageEditText);
|
||||
}
|
||||
} else if (id == MediaController.recordStartError || id == MediaController.recordStopped) {
|
||||
if (recordingAudio) {
|
||||
recordingAudio = false;
|
||||
updateAudioRecordIntefrace();
|
||||
}
|
||||
} else if (id == MediaController.recordStarted) {
|
||||
if (!recordingAudio) {
|
||||
recordingAudio = true;
|
||||
updateAudioRecordIntefrace();
|
||||
}
|
||||
} else if (id == MediaController.audioDidSent) {
|
||||
if (delegate != null) {
|
||||
delegate.onMessageSend();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
public class ColorPickerView extends View {
|
||||
|
||||
@ -105,15 +105,15 @@ public class ColorPickerView extends View {
|
||||
}
|
||||
|
||||
private void init(AttributeSet attrs, int defStyle) {
|
||||
mColorWheelThickness = Utilities.dp(8);
|
||||
mColorWheelRadius = Utilities.dp(124);
|
||||
mColorWheelThickness = AndroidUtilities.dp(8);
|
||||
mColorWheelRadius = AndroidUtilities.dp(124);
|
||||
mPreferredColorWheelRadius = mColorWheelRadius;
|
||||
mColorCenterRadius = Utilities.dp(54);
|
||||
mColorCenterRadius = AndroidUtilities.dp(54);
|
||||
mPreferredColorCenterRadius = mColorCenterRadius;
|
||||
mColorCenterHaloRadius = Utilities.dp(60);
|
||||
mColorCenterHaloRadius = AndroidUtilities.dp(60);
|
||||
mPreferredColorCenterHaloRadius = mColorCenterHaloRadius;
|
||||
mColorPointerRadius = Utilities.dp(14);
|
||||
mColorPointerHaloRadius = Utilities.dp(18);
|
||||
mColorPointerRadius = AndroidUtilities.dp(14);
|
||||
mColorPointerHaloRadius = AndroidUtilities.dp(18);
|
||||
|
||||
mAngle = (float) (-Math.PI / 2);
|
||||
|
||||
|
@ -24,10 +24,10 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.Emoji;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -104,7 +104,7 @@ public class EmojiView extends LinearLayout {
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
for (int i = 0; i < Emoji.data.length; i++) {
|
||||
GridView gridView = new GridView(getContext());
|
||||
gridView.setColumnWidth(Utilities.dpf(45.0f));
|
||||
gridView.setColumnWidth(AndroidUtilities.dpf(45.0f));
|
||||
gridView.setNumColumns(-1);
|
||||
views.add(gridView);
|
||||
|
||||
@ -120,8 +120,8 @@ public class EmojiView extends LinearLayout {
|
||||
tabs.setViewPager(pager);
|
||||
tabs.setShouldExpand(true);
|
||||
tabs.setIndicatorColor(0xff33b5e5);
|
||||
tabs.setIndicatorHeight(Utilities.dpf(2.0f));
|
||||
tabs.setUnderlineHeight(Utilities.dpf(2.0f));
|
||||
tabs.setIndicatorHeight(AndroidUtilities.dpf(2.0f));
|
||||
tabs.setUnderlineHeight(AndroidUtilities.dpf(2.0f));
|
||||
tabs.setUnderlineColor(1711276032);
|
||||
tabs.setTabBackground(0);
|
||||
LinearLayout localLinearLayout = new LinearLayout(getContext());
|
||||
@ -138,7 +138,7 @@ public class EmojiView extends LinearLayout {
|
||||
}
|
||||
}
|
||||
});
|
||||
localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(Utilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
|
||||
localLinearLayout.addView(localImageView, new LinearLayout.LayoutParams(AndroidUtilities.dpf(61.0f), LayoutParams.MATCH_PARENT));
|
||||
recentsWrap = new FrameLayout(getContext());
|
||||
recentsWrap.addView(views.get(0));
|
||||
TextView localTextView = new TextView(getContext());
|
||||
@ -148,7 +148,7 @@ public class EmojiView extends LinearLayout {
|
||||
localTextView.setGravity(17);
|
||||
recentsWrap.addView(localTextView);
|
||||
views.get(0).setEmptyView(localTextView);
|
||||
addView(localLinearLayout, new LinearLayout.LayoutParams(-1, Utilities.dpf(48.0f)));
|
||||
addView(localLinearLayout, new LinearLayout.LayoutParams(-1, AndroidUtilities.dpf(48.0f)));
|
||||
addView(pager);
|
||||
loadRecents();
|
||||
if (Emoji.data[0] == null || Emoji.data[0].length == 0) {
|
||||
|
@ -13,7 +13,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.TLRPC;
|
||||
@ -61,6 +60,9 @@ public class ImageReceiver {
|
||||
last_size = 0;
|
||||
currentImage = null;
|
||||
FileLoader.getInstance().cancelLoadingForImageView(this);
|
||||
if (parentView != null) {
|
||||
parentView.invalidate();
|
||||
}
|
||||
return;
|
||||
}
|
||||
String key;
|
||||
@ -92,16 +94,13 @@ public class ImageReceiver {
|
||||
if (img == null) {
|
||||
isPlaceholder = true;
|
||||
FileLoader.getInstance().loadImage(path, httpUrl, this, filter, true, size);
|
||||
if (parentView != null) {
|
||||
parentView.invalidate();
|
||||
}
|
||||
} else {
|
||||
selfSetting = true;
|
||||
setImageBitmap(img, currentPath);
|
||||
selfSetting = false;
|
||||
if (parentView != null) {
|
||||
parentView.invalidate();
|
||||
}
|
||||
}
|
||||
if (parentView != null) {
|
||||
parentView.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,9 +165,7 @@ public class ImageReceiver {
|
||||
}
|
||||
if (canDelete) {
|
||||
currentImage = null;
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
bitmap.recycle();
|
||||
}
|
||||
} else {
|
||||
currentImage = null;
|
||||
|
@ -10,8 +10,8 @@ package org.telegram.ui.Views;
|
||||
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
public class MessageActionLayout extends FrameLayout {
|
||||
public TightTextView messageTextView;
|
||||
@ -31,7 +31,7 @@ public class MessageActionLayout extends FrameLayout {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
setMeasuredDimension(messageTextView.linesMaxWidth + Utilities.dp(14), getMeasuredHeight());
|
||||
setMeasuredDimension(messageTextView.linesMaxWidth + AndroidUtilities.dp(14), getMeasuredHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user