Commit 8233e89d authored by DrKLO's avatar DrKLO

Perfect forward secrecy in secret chats, phone change, telegram.me links support

parent 95de265e
......@@ -80,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 397
versionName "2.0.5"
versionCode 403
versionName "2.1.0"
}
}
......@@ -23,7 +23,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">
......
......@@ -8,7 +8,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">
......
......@@ -23,7 +23,7 @@
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:name=".ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">
......
......@@ -2,7 +2,7 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := tmessages.3
LOCAL_MODULE := tmessages.4
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0
......
......@@ -589,7 +589,7 @@ static jint open(GifFileType *GifFileIn, int Error, int startPos, JNIEnv *env, j
return (jint)(Error == 0 ? info : NULL);
}
JNIEXPORT jlong JNICALL Java_org_telegram_ui_Views_GifDrawable_getAllocationByteCount(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jlong JNICALL Java_org_telegram_ui_Components_GifDrawable_getAllocationByteCount(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
......@@ -602,7 +602,7 @@ JNIEXPORT jlong JNICALL Java_org_telegram_ui_Views_GifDrawable_getAllocationByte
return sum;
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_reset(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
......@@ -610,7 +610,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_reset(JNIEnv *env,
reset(info);
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_setSpeedFactor(JNIEnv *env, jclass class, jobject gifInfo, jfloat factor) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_setSpeedFactor(JNIEnv *env, jclass class, jobject gifInfo, jfloat factor) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
......@@ -618,7 +618,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_setSpeedFactor(JNI
info->speedFactor = factor;
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv *env, jclass class, jobject gifInfo, jint desiredPos, jintArray jPixels) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_seekToTime(JNIEnv *env, jclass class, jobject gifInfo, jint desiredPos, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || jPixels == NULL) {
return;
......@@ -665,7 +665,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToTime(JNIEnv
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv *env, jclass class, jobject gifInfo, jint desiredIdx, jintArray jPixels) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_seekToFrame(JNIEnv *env, jclass class, jobject gifInfo, jint desiredIdx, jintArray jPixels) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL|| jPixels==NULL) {
return;
......@@ -701,7 +701,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_seekToFrame(JNIEnv
}
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv *env, jclass class, jintArray jPixels, jobject gifInfo, jintArray metaData) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_renderFrame(JNIEnv *env, jclass class, jintArray jPixels, jobject gifInfo, jintArray metaData) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || jPixels == NULL) {
return;
......@@ -752,7 +752,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_renderFrame(JNIEnv
(*env)->ReleaseIntArrayElements(env, metaData, rawMetaData, 0);
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_free(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_free(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return;
}
......@@ -765,7 +765,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_free(JNIEnv *env,
cleanUp(info);
}
JNIEXPORT jstring JNICALL Java_org_telegram_ui_Views_GifDrawable_getComment(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jstring JNICALL Java_org_telegram_ui_Components_GifDrawable_getComment(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return NULL;
}
......@@ -773,14 +773,14 @@ JNIEXPORT jstring JNICALL Java_org_telegram_ui_Views_GifDrawable_getComment(JNIE
return (*env)->NewStringUTF(env, info->comment);
}
JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getLoopCount(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getLoopCount(JNIEnv *env, jclass class, jobject gifInfo) {
if (gifInfo == NULL) {
return 0;
}
return ((GifInfo *)gifInfo)->loopCount;
}
JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getDuration(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getDuration(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
......@@ -793,7 +793,7 @@ JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getDuration(JNIEnv
return sum;
}
JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getCurrentPosition(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_getCurrentPosition(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return 0;
......@@ -811,7 +811,7 @@ JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_getCurrentPosition
return (int) (sum + remainder);
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_saveRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL) {
return;
......@@ -819,7 +819,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_saveRemainder(JNIE
info->lastFrameReaminder = getRealTime() - info->nextStartTime;
}
JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
JNIEXPORT void JNICALL Java_org_telegram_ui_Components_GifDrawable_restoreRemainder(JNIEnv *env, jclass class, jobject gifInfo) {
GifInfo *info = (GifInfo *)gifInfo;
if (info == NULL || info->lastFrameReaminder == ULONG_MAX) {
return;
......@@ -828,7 +828,7 @@ JNIEXPORT void JNICALL Java_org_telegram_ui_Views_GifDrawable_restoreRemainder(J
info->lastFrameReaminder = ULONG_MAX;
}
JNIEXPORT jint JNICALL Java_org_telegram_ui_Views_GifDrawable_openFile(JNIEnv *env, jclass class, jintArray metaData, jstring jfname) {
JNIEXPORT jint JNICALL Java_org_telegram_ui_Components_GifDrawable_openFile(JNIEnv *env, jclass class, jintArray metaData, jstring jfname) {
if (jfname == NULL) {
setMetaData(0, 0, 0, D_GIF_ERR_OPEN_FAILED, env, metaData);
return (jint) NULL;
......
......@@ -4,10 +4,10 @@
android:installLocation="auto">
<supports-screens android:anyDensity="true"
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="true"/>
<uses-feature android:glEsVersion="0x00020000" android:required="false"/>
......@@ -41,20 +41,20 @@
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<application
android:name=".ApplicationLoader"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@drawable/ic_launcher"
android:label="@string/AppName"
android:theme="@style/Theme.TMessages.Start"
android:name="org.telegram.ui.ApplicationLoader"
android:hardwareAccelerated="true"
android:largeHeap="true">
android:largeHeap="true"
android:theme="@style/Theme.TMessages.Start">
<activity
android:name="org.telegram.ui.LaunchActivity"
android:windowSoftInputMode="adjustPan"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:hardwareAccelerated="true"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
......@@ -95,6 +95,19 @@
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.item/vnd.org.telegram.messenger.android.profile"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="telegram.me" android:scheme="http" />
<data android:host="telegram.me" android:scheme="https" />
</intent-filter>
<intent-filter android:icon="@drawable/ic_launcher" android:priority="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tg" />
</intent-filter>
</activity>
<activity
android:name="org.telegram.ui.IntroActivity"
......@@ -105,9 +118,9 @@
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">
android:theme="@style/Theme.TMessages.PopupNotification"
android:windowSoftInputMode="adjustResize|stateHidden">
</activity>
<receiver android:name="org.telegram.android.SmsListener">
......@@ -116,8 +129,7 @@
</intent-filter>
</receiver>
<service android:name="org.telegram.android.AuthenticatorService"
android:exported="true">
<service android:name="org.telegram.android.AuthenticatorService" android:exported="true">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator"/>
</intent-filter>
......@@ -125,8 +137,7 @@
android:resource="@xml/auth"/>
</service>
<service android:name="org.telegram.android.ContactsSyncAdapterService"
android:exported="true">
<service android:name="org.telegram.android.ContactsSyncAdapterService" android:exported="true">
<intent-filter>
<action android:name="android.content.SyncAdapter" />
</intent-filter>
......
......@@ -24,7 +24,7 @@
package org.telegram.PhoneFormat;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
......
......@@ -9,7 +9,7 @@
package org.telegram.SQLite;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class SQLiteDatabase {
private final int sqliteHandle;
......
......@@ -20,6 +20,9 @@ import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.util.StateSet;
import android.view.Display;
import android.view.Surface;
......@@ -35,12 +38,14 @@ import android.widget.TextView;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ApplicationLoader;
import org.telegram.ui.Views.NumberPicker;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.Components.NumberPicker;
import org.telegram.ui.Components.TypefaceSpan;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Hashtable;
public class AndroidUtilities {
......@@ -389,7 +394,7 @@ public class AndroidUtilities {
encryptedChat.ttl = 60 * 60 * 24 * 7;
}
if (oldValue != encryptedChat.ttl) {
SendMessagesHelper.getInstance().sendTTLMessage(encryptedChat, null);
SecretChatHelper.getInstance().sendTTLMessage(encryptedChat, null);
MessagesStorage.getInstance().updateEncryptedChatTTL(encryptedChat);
}
}
......@@ -502,4 +507,21 @@ public class AndroidUtilities {
}
}
}
public static Spannable replaceBold(String str) {
int start;
ArrayList<Integer> bolds = new ArrayList<Integer>();
while ((start = str.indexOf("<b>")) != -1) {
int end = str.indexOf("</b>") - 3;
str = str.replaceFirst("<b>", "").replaceFirst("</b>", "");
bolds.add(start);
bolds.add(end);
}
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str);
for (int a = 0; a < bolds.size() / 2; a++) {
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
stringBuilder.setSpan(span, bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
}
return stringBuilder;
}
}
......@@ -12,7 +12,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class AppStartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
......
......@@ -31,7 +31,7 @@ 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 org.telegram.messenger.ApplicationLoader;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -29,7 +29,7 @@ import android.widget.TextView;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class Emoji {
private static HashMap<Long, DrawableInfo> rects = new HashMap<Long, DrawableInfo>();
......
......@@ -16,7 +16,7 @@ import android.content.Intent;
import org.json.JSONObject;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class GcmBroadcastReceiver extends BroadcastReceiver {
......
......@@ -31,7 +31,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import java.io.ByteArrayOutputStream;
import java.io.File;
......
......@@ -24,7 +24,7 @@ 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.telegram.messenger.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser;
import java.io.File;
......
......@@ -52,9 +52,9 @@ import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Views.GifDrawable;
import org.telegram.ui.Components.GifDrawable;
import java.io.File;
import java.io.FileInputStream;
......@@ -809,7 +809,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
}
}
if (send) {
SendMessagesHelper.getInstance().sendScreenshotMessage(lastSecretChat, lastSecretChatVisibleMessages, null);
SecretChatHelper.getInstance().sendScreenshotMessage(lastSecretChat, lastSecretChatVisibleMessages, null);
}
}
......
......@@ -25,7 +25,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Views.URLSpanNoUnderline;
import org.telegram.ui.Components.URLSpanNoUnderline;
import java.util.AbstractMap;
import java.util.ArrayList;
......@@ -452,6 +452,60 @@ public class MessageObject {
return "";
}
private boolean containsUrls(String message) {
if (message == null || message.length() < 3 || message.length() > 1024 * 20) {
return false;
}
boolean containsSomething = false;
int length = message.length();
int digitsInRow = 0;
int schemeSequence = 0;
int dotSequence = 0;
char lastChar = 0;
for (int i = 0; i < length; i++) {
char c = message.charAt(i);
if (c >= '0' && c <= '9') {
digitsInRow++;
if (digitsInRow >= 6) {
return true;
}
schemeSequence = 0;
dotSequence = 0;
} else if (c == ':') {
if (schemeSequence == 0) {
schemeSequence = 1;
} else {
schemeSequence = 0;
}
} else if (c == '/') {
if (schemeSequence == 2) {
return true;
}
if (schemeSequence == 1) {
schemeSequence++;
} else {
schemeSequence = 0;
}
} else if (c == '.') {
if (dotSequence == 0 && lastChar != ' ') {
dotSequence++;
} else {
dotSequence = 0;
}
} else if (c != ' ' && lastChar == '.' && dotSequence == 1) {
return true;
}
lastChar = c;
}
return false;
}
private void generateLayout() {
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
return;
......@@ -459,11 +513,11 @@ public class MessageObject {
textLayoutBlocks = new ArrayList<TextLayoutBlock>();
if (messageText instanceof Spannable) {
if (messageOwner.message != null && messageOwner.message.contains(".") && (messageOwner.message.contains(".com") || messageOwner.message.contains("http") || messageOwner.message.contains(".ru") || messageOwner.message.contains(".org") || messageOwner.message.contains(".net"))) {
Linkify.addLinks((Spannable)messageText, Linkify.WEB_URLS);
} else if (messageText.length() < 100) {
Linkify.addLinks((Spannable)messageText, Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
if (messageText instanceof Spannable && containsUrls(messageOwner.message)) {
if (messageOwner.message.length() < 100) {
Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS | Linkify.PHONE_NUMBERS);
} else {
Linkify.addLinks((Spannable) messageText, Linkify.WEB_URLS);
}
}
......@@ -576,10 +630,7 @@ public class MessageObject {
}
if (lineWidth > maxWidth + 100) {
int start = block.textLayout.getLineStart(n);
int end = block.textLayout.getLineEnd(n);
CharSequence text = block.textLayout.getText().subSequence(start, end);
continue;
lineWidth = maxWidth;
}
try {
......
......@@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader {
private final static int LIB_VERSION = 3;
private final static int LIB_VERSION = 4;
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
......
......@@ -33,7 +33,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PopupNotificationActivity;
......
......@@ -14,7 +14,7 @@ import android.content.SharedPreferences;
import android.os.IBinder;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class NotificationsService extends Service {
......
......@@ -14,7 +14,7 @@ import android.content.Intent;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class ScreenReceiver extends BroadcastReceiver {
@Override
......
......@@ -16,7 +16,7 @@ import android.support.v4.app.NotificationManagerCompat;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
public class VideoEncodingService extends Service implements NotificationCenter.NotificationCenterDelegate {
......
......@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.ui;
package org.telegram.messenger;
import android.app.AlarmManager;
import android.app.Application;
......@@ -34,15 +34,10 @@ import org.telegram.android.ContactsController;
import org.telegram.android.MediaController;
import org.telegram.android.NotificationsService;
import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
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;
import java.util.concurrent.atomic.AtomicInteger;
......
......@@ -21,7 +21,6 @@ import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
import java.util.ArrayList;
......@@ -418,7 +417,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
pushSessionId = Utilities.random.nextLong();
}
if (currentDatacenterId == 0) {
currentDatacenterId = 1;
currentDatacenterId = 2;
}
saveSession();
}
......@@ -432,12 +431,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (isTestBackend == 0) {
Datacenter datacenter = new Datacenter();
datacenter.datacenterId = 1;
datacenter.addAddressAndPort("173.240.5.1", 443);
datacenter.addAddressAndPort("149.154.175.50", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
datacenter.datacenterId = 2;
datacenter.addAddressAndPort("149.154.167.50", 443);
datacenter.addAddressAndPort("149.154.167.51", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
......@@ -447,7 +446,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter();
datacenter.datacenterId = 4;
datacenter.addAddressAndPort("149.154.167.90", 443);
datacenter.addAddressAndPort("149.154.167.91", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
......@@ -473,7 +472,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} else if (datacenters.size() == 1) {
Datacenter datacenter = new Datacenter();
datacenter.datacenterId = 2;
datacenter.addAddressAndPort("149.154.167.50", 443);
datacenter.addAddressAndPort("149.154.167.51", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
......@@ -483,12 +482,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter();
datacenter.datacenterId = 4;
datacenter.addAddressAndPort("31.210.235.12", 443);
datacenter.addAddressAndPort("149.154.167.91", 443);
datacenters.put(datacenter.datacenterId, datacenter);
datacenter = new Datacenter();
datacenter.datacenterId = 5;
datacenter.addAddressAndPort("116.51.22.2", 443);
datacenter.addAddressAndPort("149.154.171.5", 443);
datacenters.put(datacenter.datacenterId, datacenter);
}
}
......@@ -1113,13 +1112,13 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
request.retryCount++;
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) {
if (!request.salt && (request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0) {
int retryMax = 10;
if ((request.flags & RPCRequest.RPCRequestClassForceDownload) == 0) {
if (request.wait) {
retryMax = 1;
} else {
retryMax = 3;
retryMax = 6;
}
}
if (request.retryCount >= retryMax) {
......@@ -2244,6 +2243,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
if (request.respondsToMessageId(resultMid)) {
request.retryCount = 0;
request.salt = true;
break;
}
}
}
......@@ -2568,7 +2569,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (message == null) {
FileLog.e("tmessages", "***** Error parsing message: " + constructor);
} else {
FileLog.e("tmessages", "received object " + message);
FileLog.d("tmessages", "received object " + message);
processMessage(message, messageId, messageSeqNo, messageServerSalt, connection, 0, 0);
connection.addProcessedMessageId(messageId);
......
......@@ -11,8 +11,6 @@ package org.telegram.messenger;
import android.content.Context;
import android.content.SharedPreferences;
import org.telegram.ui.ApplicationLoader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
......
......@@ -12,7 +12,6 @@ import android.net.Uri;
import android.util.Log;
import org.telegram.android.time.FastDateFormat;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
import java.io.FileOutputStream;
......
......@@ -11,8 +11,6 @@ package org.telegram.messenger;
import android.app.Activity;
import android.content.SharedPreferences;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
import java.io.FileInputStream;
import java.math.BigInteger;
......
......@@ -37,6 +37,7 @@ public class RPCRequest {
int serverFailureCount;
int flags;
boolean wait = false;
boolean salt = false;
protected int retryCount = 0;
protected int lastResendTime = 0;
protected boolean completed = false;
......
......@@ -359,6 +359,13 @@ public class TLClassStore {
classStore.put(TLRPC.TL_inputPhotoCrop.constructor, TLRPC.TL_inputPhotoCrop.class);
classStore.put(TLRPC.TL_messages_dialogs.constructor, TLRPC.TL_messages_dialogs.class);
classStore.put(TLRPC.TL_messages_dialogsSlice.constructor, TLRPC.TL_messages_dialogsSlice.class);
classStore.put(TLRPC.TL_account_sentChangePhoneCode.constructor, TLRPC.TL_account_sentChangePhoneCode.class);
classStore.put(TLRPC.TL_updateUserPhone.constructor, TLRPC.TL_updateUserPhone.class);
classStore.put(TLRPC.TL_decryptedMessageActionRequestKey.constructor, TLRPC.TL_decryptedMessageActionRequestKey.class);
classStore.put(TLRPC.TL_decryptedMessageActionAcceptKey.constructor, TLRPC.TL_decryptedMessageActionAcceptKey.class);
classStore.put(TLRPC.TL_decryptedMessageActionCommitKey.constructor, TLRPC.TL_decryptedMessageActionCommitKey.class);
classStore.put(TLRPC.TL_decryptedMessageActionAbortKey.constructor, TLRPC.TL_decryptedMessageActionAbortKey.class);
classStore.put(TLRPC.TL_decryptedMessageActionNoop.constructor, TLRPC.TL_decryptedMessageActionNoop.class);
classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class);
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);
......
......@@ -3675,6 +3675,7 @@ public class TLRPC {
public long random_id;
public ArrayList<TL_dcOption> dc_options = new ArrayList<TL_dcOption>();
public ChatParticipants participants;
public String phone;
public TL_privacyKeyStatusTimestamp key;
public ArrayList<PrivacyRule> rules = new ArrayList<PrivacyRule>();
public EncryptedChat chat;
......@@ -4009,6 +4010,22 @@ public class TLRPC {
}
}
public static class TL_updateUserPhone extends Update {
public static int constructor = 0x12b9417b;
public void readParams(AbsSerializedData stream) {
user_id = stream.readInt32();
phone = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(user_id);
stream.writeString(phone);
}
}
public static class TL_updatePrivacy extends Update {
public static int constructor = 0xee3b272a;
......@@ -4329,10 +4346,14 @@ public class TLRPC {
public static class DecryptedMessageAction extends TLObject {
public int start_seq_no;
public int end_seq_no;
public int layer;
public int ttl_seconds;
public int layer;
public ArrayList<Long> random_ids = new ArrayList<Long>();
public long exchange_id;
public long key_fingerprint;
public byte[] g_b;
public SendMessageAction action;
public byte[] g_a;
}
public static class TL_decryptedMessageActionSetMessageTTL extends DecryptedMessageAction {
......@@ -4356,6 +4377,24 @@ public class TLRPC {
}
}
public static class TL_decryptedMessageActionAcceptKey extends DecryptedMessageAction {
public static int constructor = 0x6fe1735b;
public void readParams(AbsSerializedData stream) {
exchange_id = stream.readInt64();
g_b = stream.readByteArray();
key_fingerprint = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(exchange_id);
stream.writeByteArray(g_b);
stream.writeInt64(key_fingerprint);
}
}
public static class TL_decryptedMessageActionResend extends DecryptedMessageAction {
public static int constructor = 0x511110b0;
......@@ -4409,6 +4448,22 @@ public class TLRPC {
}
}
public static class TL_decryptedMessageActionRequestKey extends DecryptedMessageAction {
public static int constructor = 0xf3c9611b;
public void readParams(AbsSerializedData stream) {
exchange_id = stream.readInt64();
g_a = stream.readByteArray();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(exchange_id);
stream.writeByteArray(g_a);
}
}
public static class TL_decryptedMessageActionTyping extends DecryptedMessageAction {
public static int constructor = 0xccb27641;
......@@ -5019,6 +5074,69 @@ public class TLRPC {
}
}
public static class TL_contacts_resolveUsername extends TLObject {
public static int constructor = 0xbf0131c;
public String username;
public Class responseClass () {
return User.class;
}
public void readParams(AbsSerializedData stream) {
username = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(username);
}
}
public static class TL_account_sendChangePhoneCode extends TLObject {
public static int constructor = 0xa407a8f4;
public String phone_number;
public Class responseClass () {
return TL_account_sentChangePhoneCode.class;
}
public void readParams(AbsSerializedData stream) {
phone_number = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(phone_number);
}
}
public static class TL_account_changePhone extends TLObject {
public static int constructor = 0x70c32edb;
public String phone_number;
public String phone_code_hash;
public String phone_code;
public Class responseClass () {
return User.class;
}
public void readParams(AbsSerializedData stream) {
phone_number = stream.readString();
phone_code_hash = stream.readString();
phone_code = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(phone_number);
stream.writeString(phone_code_hash);
stream.writeString(phone_code);
}
}
public static class InputAudio extends TLObject {
public long id;
public long access_hash;
......@@ -5900,6 +6018,24 @@ public class TLRPC {
}
}
public static class TL_account_sentChangePhoneCode extends TLObject {
public static int constructor = 0xa4f58c4c;
public String phone_code_hash;
public int send_call_timeout;
public void readParams(AbsSerializedData stream) {
phone_code_hash = stream.readString();
send_call_timeout = stream.readInt32();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeString(phone_code_hash);
stream.writeInt32(send_call_timeout);
}
}
public static class InputFile extends TLObject {
public long id;
public int parts;
......@@ -8819,6 +8955,7 @@ public class TLRPC {
public int date;
public TL_decryptedMessageLayer layer;
public EncryptedFile file;
public boolean new_key_used;
public void readParams(AbsSerializedData stream) {
random_id = stream.readInt64();
......@@ -8827,6 +8964,7 @@ public class TLRPC {
if (stream.readBool()) {
file = (EncryptedFile) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
}
new_key_used = stream.readBool();
}
public void serializeToStream(AbsSerializedData stream) {
......@@ -8838,6 +8976,7 @@ public class TLRPC {
if (file != null) {
file.serializeToStream(stream);
}
stream.writeBool(new_key_used);
}
}
......@@ -9990,6 +10129,13 @@ public class TLRPC {
public int layer;
public int seq_in;
public int seq_out;
public byte[] key_hash;
public short key_use_count_in;
public short key_use_count_out;
public long exchange_id;
public int key_create_date;
public long future_key_fingerprint;
public byte[] future_auth_key;
}
public static class FileLocation extends TLObject {
......@@ -10290,7 +10436,7 @@ public class TLRPC {
public static class invokeWithLayer extends TLObject {
public static int constructor = 0xda9b0d0d;
public int layer = 19;
public int layer = 20;
public TLObject query;
public void serializeToStream(AbsSerializedData stream) {
......@@ -10406,6 +10552,45 @@ public class TLRPC {
}
}
public static class TL_decryptedMessageActionCommitKey extends DecryptedMessageAction {
public static int constructor = 0xec2e0b9b;
public void readParams(AbsSerializedData stream) {
exchange_id = stream.readInt64();
key_fingerprint = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(exchange_id);
stream.writeInt64(key_fingerprint);
}
}
public static class TL_decryptedMessageActionAbortKey extends DecryptedMessageAction {
public static int constructor = 0xdd05ec6b;
public void readParams(AbsSerializedData stream) {
exchange_id = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt64(exchange_id);
}
}
public static class TL_decryptedMessageActionNoop extends DecryptedMessageAction {
public static int constructor = 0xa82fdd63;
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
}
}
public static class TL_decryptedMessageActionScreenshotMessages extends DecryptedMessageAction {
public static int constructor = 0x8ac1f475;
......
......@@ -13,7 +13,6 @@ import android.content.SharedPreferences;
import android.util.Base64;
import org.telegram.android.MessagesStorage;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
......
......@@ -28,8 +28,6 @@ import net.hockeyapp.android.CrashManager;
import net.hockeyapp.android.CrashManagerListener;
import net.hockeyapp.android.UpdateManager;
import org.telegram.ui.ApplicationLoader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
......
......@@ -55,6 +55,7 @@ public class ActionBarMenuItem extends ImageView {
private Runnable showMenuRunnable;
private boolean showFromBottom;
private int menuHeight = AndroidUtilities.dp(16);
private boolean needOffset = Build.VERSION.SDK_INT >= 21;
public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) {
super(context);
......@@ -135,6 +136,10 @@ public class ActionBarMenuItem extends ImageView {
showFromBottom = value;
}
public void setNeedOffset(boolean value) {
needOffset = Build.VERSION.SDK_INT >= 21 && value;
}
public TextView addSubItem(int id, String text, int icon) {
if (popupLayout == null) {
rect = new Rect();
......@@ -247,29 +252,33 @@ public class ActionBarMenuItem extends ImageView {
popupWindow.setFocusable(true);
if (popupLayout.getMeasuredWidth() == 0) {
if (showFromBottom) {
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY(), -1, -1);
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getOffsetY());
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getOffsetY(), -1, -1);
} else {
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight());
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY());
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY(), -1, -1);
}
} else {
if (showFromBottom) {
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY());
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getOffsetY());
} else {
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight());
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY());
}
}
}
private int getBottomOffsetY() {
private int getOffsetY() {
if (showFromBottom) {
getLocationOnScreen(location);
int diff = location[1] - AndroidUtilities.statusBarHeight + getMeasuredHeight() - menuHeight;
int y = AndroidUtilities.dp(8) - menuHeight;
if (diff < 0) {
y -= diff;
}
return y;
return y - (needOffset ? AndroidUtilities.statusBarHeight : 0);
} else {
return -getMeasuredHeight() - (needOffset ? AndroidUtilities.statusBarHeight : 0);
}
}
public boolean toggleSearch() {
......@@ -415,9 +424,9 @@ public class ActionBarMenuItem extends ImageView {
super.onLayout(changed, left, top, right, bottom);
if (popupWindow != null && popupWindow.isShowing()) {
if (showFromBottom) {
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getBottomOffsetY(), -1, -1);
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth() + AndroidUtilities.dp(14), getOffsetY(), -1, -1);
} else {
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), -getMeasuredHeight(), -1, -1);
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY(), -1, -1);
}
}
}
......
......@@ -11,10 +11,12 @@
package org.telegram.ui.ActionBar;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
......@@ -23,6 +25,7 @@ import org.telegram.messenger.FileLog;
import java.lang.reflect.Field;
public class ActionBarPopupWindow extends PopupWindow {
private static final Field superListenerField;
static {
Field f = null;
......@@ -132,6 +135,15 @@ public class ActionBarPopupWindow extends PopupWindow {
mSuperScrollListener = null;
}
}
if (Build.VERSION.SDK_INT >= 21) {
try {
Field field = PopupWindow.class.getDeclaredField("mWindowLayoutType");
field.setAccessible(true);
field.set(this, WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
} catch (Exception e) {
/* ignored */
}
}
}
private void unregisterListener() {
......
......@@ -34,7 +34,7 @@ public class DrawerLayoutContainer extends FrameLayout {
private static final int MIN_DRAWER_MARGIN = 64;
private View drawerLayout;
private ViewGroup drawerLayout;
private ActionBarLayout parentActionBarLayout;
private boolean maybeStartTracking = false;
......@@ -55,7 +55,7 @@ public class DrawerLayoutContainer extends FrameLayout {
private Drawable shadowLeft;
private boolean allowOpenDrawer;
private int drawerPosition = 0;
private float drawerPosition = 0;
private boolean drawerOpened = false;
public DrawerLayoutContainer(Context context) {
......@@ -125,7 +125,7 @@ public class DrawerLayoutContainer extends FrameLayout {
requestLayout();
}
public void setDrawerLayout(View layout) {
public void setDrawerLayout(ViewGroup layout) {
drawerLayout = layout;
addView(drawerLayout);
if (Build.VERSION.SDK_INT >= 21) {
......@@ -133,11 +133,11 @@ public class DrawerLayoutContainer extends FrameLayout {
}
}
public void moveDrawerByX(int dx) {
public void moveDrawerByX(float dx) {
setDrawerPosition(drawerPosition + dx);
}
public void setDrawerPosition(int value) {
public void setDrawerPosition(float value) {
drawerPosition = value;
if (drawerPosition > drawerLayout.getMeasuredWidth()) {
drawerPosition = drawerLayout.getMeasuredWidth();
......@@ -150,10 +150,10 @@ public class DrawerLayoutContainer extends FrameLayout {
if (drawerLayout.getVisibility() != newVisibility) {
drawerLayout.setVisibility(newVisibility);
}
setScrimOpacity((float)drawerPosition / (float)drawerLayout.getMeasuredWidth());
setScrimOpacity(drawerPosition / (float)drawerLayout.getMeasuredWidth());
}
public int getDrawerPosition() {
public float getDrawerPosition() {
return drawerPosition;
}
......@@ -171,7 +171,7 @@ public class DrawerLayoutContainer extends FrameLayout {
cancelCurrentAnimation();
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
animatorSet.playTogether(
ObjectAnimatorProxy.ofInt(this, "drawerPosition", drawerLayout.getMeasuredWidth())
ObjectAnimatorProxy.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth())
);
animatorSet.setInterpolator(new DecelerateInterpolator());
if (fast) {
......@@ -198,7 +198,7 @@ public class DrawerLayoutContainer extends FrameLayout {
cancelCurrentAnimation();
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
animatorSet.playTogether(
ObjectAnimatorProxy.ofInt(this, "drawerPosition", 0)
ObjectAnimatorProxy.ofFloat(this, "drawerPosition", 0)
);
animatorSet.setInterpolator(new DecelerateInterpolator());
if (fast) {
......@@ -291,12 +291,13 @@ public class DrawerLayoutContainer extends FrameLayout {
if (velocityTracker == null) {
velocityTracker = VelocityTracker.obtain();
}
int dx = (int) (ev.getX() - startedTrackingX);
int dy = Math.abs((int) ev.getY() - startedTrackingY);
float dx = (int) (ev.getX() - startedTrackingX);
float dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev);
if (maybeStartTracking && !startedTracking && Math.abs(dx) / 3 > Math.abs(dy) && (dx < 0 || dx > 0 && dx > AndroidUtilities.dp(10))) {
if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.dp(10))) {
prepareForDrawerOpen(ev);
startedTrackingX = (int) ev.getX();
requestDisallowInterceptTouchEvent(true);
} else if (startedTracking) {
if (!beginTrackingSent) {
if (((Activity)getContext()).getCurrentFocus() != null) {
......@@ -312,10 +313,10 @@ public class DrawerLayoutContainer extends FrameLayout {
velocityTracker = VelocityTracker.obtain();
}
velocityTracker.computeCurrentVelocity(1000);
if (!startedTracking) {
/*if (!startedTracking) {
float velX = velocityTracker.getXVelocity();
float velY = velocityTracker.getYVelocity();
if (Math.abs(velX) >= 1500 && Math.abs(velX) > Math.abs(velY)) {
if (Math.abs(velX) >= 3500 && Math.abs(velX) > Math.abs(velY)) {
prepareForDrawerOpen(ev);
if (!beginTrackingSent) {
if (((Activity)getContext()).getCurrentFocus() != null) {
......@@ -324,15 +325,15 @@ public class DrawerLayoutContainer extends FrameLayout {
beginTrackingSent = true;
}
}
}
}*/
if (startedTracking || drawerPosition != 0 && drawerPosition != drawerLayout.getMeasuredWidth()) {
float velX = velocityTracker.getXVelocity();
float velY = velocityTracker.getYVelocity();
boolean backAnimation = drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f && (velX < 1500 || Math.abs(velX) < Math.abs(velY)) || velX < 0 && Math.abs(velX) >= 1500;
boolean backAnimation = drawerPosition < drawerLayout.getMeasuredWidth() / 2.0f && (velX < 3500 || Math.abs(velX) < Math.abs(velY)) || velX < 0 && Math.abs(velX) >= 3500;
if (!backAnimation) {
openDrawer(!drawerOpened && Math.abs(velX) >= 1500);
openDrawer(!drawerOpened && Math.abs(velX) >= 3500);
} else {
closeDrawer(drawerOpened && Math.abs(velX) >= 1500);
closeDrawer(drawerOpened && Math.abs(velX) >= 3500);
}
startedTracking = false;
} else {
......@@ -357,7 +358,9 @@ public class DrawerLayoutContainer extends FrameLayout {
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
if (maybeStartTracking && !startedTracking) {
onTouchEvent(null);
}
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
......@@ -378,7 +381,7 @@ public class DrawerLayoutContainer extends FrameLayout {
if (drawerLayout != child) {
child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight());
} else {
child.layout(-child.getMeasuredWidth() + drawerPosition, lp.topMargin, drawerPosition, lp.topMargin + child.getMeasuredHeight());
child.layout(-child.getMeasuredWidth() + (int)drawerPosition, lp.topMargin, (int)drawerPosition, lp.topMargin + child.getMeasuredHeight());
}
}
inLayout = false;
......@@ -462,9 +465,9 @@ public class DrawerLayoutContainer extends FrameLayout {
scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * scrimOpacity) << 24);
canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
} else if (shadowLeft != null) {
final float alpha = Math.max(0, Math.min((float) drawerPosition / AndroidUtilities.dp(20), 1.0f));
final float alpha = Math.max(0, Math.min(drawerPosition / AndroidUtilities.dp(20), 1.0f));
if (alpha != 0) {
shadowLeft.setBounds(drawerPosition, child.getTop(), drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom());
shadowLeft.setBounds((int)drawerPosition, child.getTop(), (int)drawerPosition + shadowLeft.getIntrinsicWidth(), child.getBottom());
shadowLeft.setAlpha((int) (0xff * alpha));
shadowLeft.draw(canvas);
}
......
......@@ -15,7 +15,7 @@ import android.view.ViewGroup;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.ui.ApplicationLoader;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.Cells.DividerCell;
import org.telegram.ui.Cells.LetterSectionCell;
import org.telegram.ui.Cells.TextSettingsCell;
......
......@@ -31,7 +31,7 @@ import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Components.AvatarDrawable;
public class ChatActionCell extends BaseCell {
......
......@@ -25,9 +25,9 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.ProgressView;
import org.telegram.ui.Views.SeekBar;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.ProgressView;
import org.telegram.ui.Components.SeekBar;
import java.io.File;
......
......@@ -28,7 +28,7 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Components.AvatarDrawable;
public class ChatBaseCell extends BaseCell {
......@@ -482,7 +482,7 @@ public class ChatBaseCell extends BaseCell {
if (drawName && nameLayout != null) {
canvas.save();
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
namePaint.setColor(AvatarDrawable.getColorForId(currentUser.id));
namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id));
nameLayout.draw(canvas);
canvas.restore();
}
......
......@@ -28,7 +28,7 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Components.AvatarDrawable;
public class ChatContactCell extends ChatBaseCell {
......
......@@ -147,10 +147,10 @@ public class ChatMessageCell extends ChatBaseCell {
}
} else {
if (isChat && !messageObject.isOut()) {
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(122);
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
drawName = true;
} else {
maxWidth = AndroidUtilities.displaySize.x - AndroidUtilities.dp(80);
maxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80);
drawName = false;
}
}
......
......@@ -30,7 +30,7 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Components.AvatarDrawable;
public class DialogCell extends BaseCell {
......
......@@ -19,8 +19,8 @@ import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
public class DrawerProfileCell extends FrameLayout {
......
......@@ -27,7 +27,7 @@ import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Components.AvatarDrawable;
public class ProfileSearchCell extends BaseCell {
private static TextPaint namePaint;
......
......@@ -18,8 +18,8 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Views.Switch;
import org.telegram.ui.Components.FrameLayoutFixed;
import org.telegram.ui.Components.Switch;
public class TextCheckCell extends FrameLayoutFixed {
......
......@@ -18,8 +18,8 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.CheckBox;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CheckBox;
public class TextDetailDocumentsCell extends FrameLayout {
......
......@@ -17,7 +17,7 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.ui.Views.FrameLayoutFixed;
import org.telegram.ui.Components.FrameLayoutFixed;
public class TextDetailSettingsCell extends FrameLayoutFixed {
......
......@@ -24,9 +24,9 @@ import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Views.AvatarDrawable;
import org.telegram.ui.Views.BackupImageView;
import org.telegram.ui.Views.CheckBox;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.CheckBox;
public class UserCell extends FrameLayout {
......
......@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.ui.Views;
package org.telegram.ui.Components;
import android.app.Activity;
import android.content.Intent;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment