Update to 3.0.1.6 (576):
- Fixed options to share music and stickers - Added option to share contact number - Added option to add member directly from group options - Added option to mute or activate notifications from main screen - Bug fixes
This commit is contained in:
parent
4834528f60
commit
c32089f5eb
@ -1,11 +1,4 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
repositories {
|
||||
@ -13,8 +6,9 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:22.1.+'
|
||||
compile 'com.android.support:support-v4:22.2.+'
|
||||
compile 'com.google.android.gms:play-services:3.2.+'
|
||||
//compile 'com.google.android.gms:play-services:7.5.0'
|
||||
compile 'net.hockeyapp.android:HockeySDK:3.5.+'
|
||||
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
|
||||
}
|
||||
@ -88,7 +82,7 @@ android {
|
||||
applicationId "org.telegram.plus"
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 22
|
||||
versionCode 546
|
||||
versionName "2.9.1.4"
|
||||
versionCode 576
|
||||
versionName "3.0.1.5"
|
||||
}
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ JNIEXPORT jobject Java_org_telegram_messenger_Utilities_loadWebpImage(JNIEnv *en
|
||||
if (!WebPDecodeRGBAInto((uint8_t*)inputBuffer, len, (uint8_t*)bitmapPixels, bitmapInfo.height * bitmapInfo.stride, bitmapInfo.stride)) {
|
||||
AndroidBitmap_unlockPixels(env, outputBitmap);
|
||||
(*env)->DeleteLocalRef(env, outputBitmap);
|
||||
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to unlock Bitmap pixels");
|
||||
(*env)->ThrowNew(env, jclass_RuntimeException, "Failed to decode webp image");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,9 +8,11 @@
|
||||
|
||||
package org.telegram.SQLite;
|
||||
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class SQLitePreparedStatement {
|
||||
private boolean isFinalized = false;
|
||||
@ -19,6 +21,8 @@ public class SQLitePreparedStatement {
|
||||
private int queryArgsCount;
|
||||
private boolean finalizeAfterQuery = false;
|
||||
|
||||
private static HashMap<SQLitePreparedStatement, String> hashMap;
|
||||
|
||||
public int getStatementHandle() {
|
||||
return sqliteStatementHandle;
|
||||
}
|
||||
@ -26,6 +30,16 @@ public class SQLitePreparedStatement {
|
||||
public SQLitePreparedStatement(SQLiteDatabase db, String sql, boolean finalize) throws SQLiteException {
|
||||
finalizeAfterQuery = finalize;
|
||||
sqliteStatementHandle = prepare(db.getSQLiteHandle(), sql);
|
||||
//if (BuildVars.DEBUG_VERSION) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
if (hashMap == null) {
|
||||
hashMap = new HashMap<>();
|
||||
}
|
||||
hashMap.put(this, sql);
|
||||
for (HashMap.Entry<SQLitePreparedStatement, String> entry : hashMap.entrySet()) {
|
||||
FileLog.d("tmessages", "exist entry = " + entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -88,6 +102,10 @@ public class SQLitePreparedStatement {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
//if (BuildVars.DEBUG_VERSION) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
hashMap.remove(this);
|
||||
}
|
||||
isFinalized = true;
|
||||
finalize(sqliteStatementHandle);
|
||||
} catch (SQLiteException e) {
|
||||
|
@ -36,6 +36,7 @@ import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.util.StateSet;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
@ -108,7 +109,6 @@ public class AndroidUtilities {
|
||||
|
||||
public static boolean needRestart = false;
|
||||
|
||||
static final long delay = 7 * 24 * 60 * 60 * 1000;
|
||||
static long lastCheck = -1;
|
||||
|
||||
static {
|
||||
@ -190,6 +190,7 @@ public class AndroidUtilities {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(ApplicationLoader.USE_DEVICE_FONT)return null;
|
||||
return typefaceCache.get(assetPath);
|
||||
}
|
||||
}
|
||||
@ -631,22 +632,31 @@ public class AndroidUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
public static final int FLAG_TAG_BR = 1;
|
||||
public static final int FLAG_TAG_BOLD = 2;
|
||||
public static final int FLAG_TAG_COLOR = 4;
|
||||
public static final int FLAG_TAG_ALL = FLAG_TAG_BR | FLAG_TAG_BOLD | FLAG_TAG_COLOR;
|
||||
|
||||
public static Spannable replaceTags(String str) {
|
||||
return replaceTags(str, FLAG_TAG_ALL);
|
||||
}
|
||||
|
||||
public static Spannable replaceTags(String str, int flag) {
|
||||
try {
|
||||
int start;
|
||||
int startColor = -1;
|
||||
int end;
|
||||
StringBuilder stringBuilder = new StringBuilder(str);
|
||||
if ((flag & FLAG_TAG_BR) != 0) {
|
||||
while ((start = stringBuilder.indexOf("<br>")) != -1) {
|
||||
stringBuilder.replace(start, start + 4, "\n");
|
||||
}
|
||||
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
|
||||
stringBuilder.replace(start, start + 5, "\n");
|
||||
}
|
||||
}
|
||||
ArrayList<Integer> bolds = new ArrayList<>();
|
||||
ArrayList<Integer> colors = new ArrayList<>();
|
||||
while ((start = stringBuilder.indexOf("<b>")) != -1 || (startColor = stringBuilder.indexOf("<c#")) != -1) {
|
||||
if (start != -1) {
|
||||
if ((flag & FLAG_TAG_BOLD) != 0) {
|
||||
while ((start = stringBuilder.indexOf("<b>")) != -1) {
|
||||
stringBuilder.replace(start, start + 3, "");
|
||||
end = stringBuilder.indexOf("</b>");
|
||||
if (end == -1) {
|
||||
@ -655,17 +665,20 @@ public class AndroidUtilities {
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
bolds.add(start);
|
||||
bolds.add(end);
|
||||
} else if (startColor != -1) {
|
||||
stringBuilder.replace(startColor, startColor + 2, "");
|
||||
end = stringBuilder.indexOf(">", startColor);
|
||||
int color = Color.parseColor(stringBuilder.substring(startColor, end));
|
||||
stringBuilder.replace(startColor, end + 1, "");
|
||||
}
|
||||
}
|
||||
ArrayList<Integer> colors = new ArrayList<>();
|
||||
if ((flag & FLAG_TAG_COLOR) != 0) {
|
||||
while ((start = stringBuilder.indexOf("<c#")) != -1) {
|
||||
stringBuilder.replace(start, start + 2, "");
|
||||
end = stringBuilder.indexOf(">", start);
|
||||
int color = Color.parseColor(stringBuilder.substring(start, end));
|
||||
stringBuilder.replace(start, end + 1, "");
|
||||
end = stringBuilder.indexOf("</c>");
|
||||
stringBuilder.replace(end, end + 4, "");
|
||||
colors.add(startColor);
|
||||
colors.add(start);
|
||||
colors.add(end);
|
||||
colors.add(color);
|
||||
startColor = -1;
|
||||
}
|
||||
}
|
||||
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
|
||||
@ -1222,6 +1235,7 @@ public class AndroidUtilities {
|
||||
//if (!BuildConfig.DEBUG) {
|
||||
//}
|
||||
try {
|
||||
long myDelay = (30L * 24L * 60L * 60L * 1000L);
|
||||
String packageName = "es.rafalense.themes";
|
||||
if(BuildConfig.DEBUG)packageName = "es.rafalense.themes.beta";
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
@ -1230,11 +1244,12 @@ public class AndroidUtilities {
|
||||
} else {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
//long last = preferences.getLong("lastTimeActionDone", 0);
|
||||
//Log.e("checkForThemes",":lastCheck:"+lastCheck);
|
||||
//Log.e("checkForThemes", System.currentTimeMillis() - lastCheck + ":");
|
||||
if (lastCheck < 0 || ( System.currentTimeMillis() - lastCheck < delay && lastCheck > 0 ) ) {
|
||||
//Log.e("checkForThemes0", ":lastCheck:" + lastCheck);
|
||||
//Log.e("checkForThemes0", System.currentTimeMillis() - lastCheck + ":" + myDelay);
|
||||
if (lastCheck < 0 || ( System.currentTimeMillis() - lastCheck < myDelay && lastCheck > 0 ) ) {
|
||||
//lastCheck++;
|
||||
lastCheck = preferences.getLong("lastTime", 0);
|
||||
//Log.e("checkForThemes1", ":lastCheck:" + lastCheck);
|
||||
return;
|
||||
} else {
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -1250,9 +1265,15 @@ public class AndroidUtilities {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pck));
|
||||
if (BuildConfig.DEBUG)in = new Intent(Intent.ACTION_VIEW, Uri.parse("https://rink.hockeyapp.net/apps/b5860b775ca122d3335685f39917e68f"));
|
||||
context.startActivityForResult(in, 503);
|
||||
} catch (Exception e) {
|
||||
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=es.rafalense.themes"));
|
||||
context.startActivityForResult(in, 503);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1260,6 +1281,7 @@ public class AndroidUtilities {
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.create().show();
|
||||
lastCheck = preferences.getLong("lastTime", 0);
|
||||
//Log.e("checkForThemes2", ":lastCheck:" + lastCheck);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,6 +89,15 @@ public class AnimatorSetProxy {
|
||||
return this;
|
||||
}
|
||||
|
||||
public AnimatorSetProxy setStartDelay(long delay) {
|
||||
if (View10.NEED_PROXY) {
|
||||
((AnimatorSet10) animatorSet).setStartDelay(delay);
|
||||
} else {
|
||||
((AnimatorSet) animatorSet).setStartDelay(delay);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (View10.NEED_PROXY) {
|
||||
((AnimatorSet10) animatorSet).start();
|
||||
|
@ -957,14 +957,8 @@ public class ContactsController {
|
||||
public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
|
||||
TLRPC.User user1 = usersDict.get(tl_contact.user_id);
|
||||
TLRPC.User user2 = usersDict.get(tl_contact2.user_id);
|
||||
String name1 = user1.first_name;
|
||||
if (name1 == null || name1.length() == 0) {
|
||||
name1 = user1.last_name;
|
||||
}
|
||||
String name2 = user2.first_name;
|
||||
if (name2 == null || name2.length() == 0) {
|
||||
name2 = user2.last_name;
|
||||
}
|
||||
String name1 = UserObject.getFirstName(user1);
|
||||
String name2 = UserObject.getFirstName(user2);
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
@ -990,10 +984,7 @@ public class ContactsController {
|
||||
contactsByPhonesDict.put(user.phone, value);
|
||||
}
|
||||
|
||||
String key = user.first_name;
|
||||
if (key == null || key.length() == 0) {
|
||||
key = user.last_name;
|
||||
}
|
||||
String key = UserObject.getFirstName(user);
|
||||
if (key.length() > 1) {
|
||||
key = key.substring(0, 1);
|
||||
}
|
||||
@ -1161,14 +1152,8 @@ public class ContactsController {
|
||||
public int compare(TLRPC.TL_contact tl_contact, TLRPC.TL_contact tl_contact2) {
|
||||
TLRPC.User user1 = MessagesController.getInstance().getUser(tl_contact.user_id);
|
||||
TLRPC.User user2 = MessagesController.getInstance().getUser(tl_contact2.user_id);
|
||||
String name1 = user1.first_name;
|
||||
if (name1 == null || name1.length() == 0) {
|
||||
name1 = user1.last_name;
|
||||
}
|
||||
String name2 = user2.first_name;
|
||||
if (name2 == null || name2.length() == 0) {
|
||||
name2 = user2.last_name;
|
||||
}
|
||||
String name1 = UserObject.getFirstName(user1);
|
||||
String name2 = UserObject.getFirstName(user2);
|
||||
return name1.compareTo(name2);
|
||||
}
|
||||
});
|
||||
@ -1184,10 +1169,7 @@ public class ContactsController {
|
||||
continue;
|
||||
}
|
||||
|
||||
String key = user.first_name;
|
||||
if (key == null || key.length() == 0) {
|
||||
key = user.last_name;
|
||||
}
|
||||
String key = UserObject.getFirstName(user);
|
||||
if (key.length() > 1) {
|
||||
key = key.substring(0, 1);
|
||||
}
|
||||
@ -1639,7 +1621,7 @@ public class ContactsController {
|
||||
|
||||
for (TLRPC.User user : users) {
|
||||
if (user.phone != null && user.phone.length() > 0) {
|
||||
CharSequence name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
CharSequence name = UserObject.getUserName(user);
|
||||
MessagesStorage.getInstance().applyPhoneBookUpdates(user.phone, "");
|
||||
Contact contact = contactsBookSPhones.get(user.phone);
|
||||
if (contact != null) {
|
||||
|
@ -16,6 +16,7 @@ import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Spannable;
|
||||
import android.text.Spanned;
|
||||
import android.text.style.DynamicDrawableSpan;
|
||||
import android.text.style.ImageSpan;
|
||||
import android.view.View;
|
||||
@ -416,6 +417,14 @@ public class Emoji {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean isNextCharIsColor(CharSequence cs, int i) {
|
||||
if (i + 2 >= cs.length()) {
|
||||
return false;
|
||||
}
|
||||
int value = cs.charAt(i + 1) << 16 | cs.charAt(i + 2);
|
||||
return value == 0xd83cdffb || value == 0xd83cdffc || value == 0xd83cdffd || value == 0xd83cdffe || value == 0xd83cdfff;
|
||||
}
|
||||
|
||||
public static CharSequence replaceEmoji(CharSequence cs, Paint.FontMetricsInt fontMetrics, int size) {
|
||||
if (cs == null || cs.length() == 0) {
|
||||
return cs;
|
||||
@ -443,12 +452,16 @@ public class Emoji {
|
||||
buf |= c;
|
||||
EmojiDrawable d = Emoji.getEmojiDrawable(buf);
|
||||
if (d != null) {
|
||||
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
|
||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
|
||||
emojiCount++;
|
||||
if (c >= 0xDDE6 && c <= 0xDDFA) {
|
||||
s.setSpan(span, i - 3, i + 1, 0);
|
||||
s.setSpan(span, i - 3, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
} else {
|
||||
s.setSpan(span, i - 1, i + 1, 0);
|
||||
s.setSpan(span, i - 1, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
}
|
||||
if (nextIsSkinTone) {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
buf = 0;
|
||||
@ -461,9 +474,13 @@ public class Emoji {
|
||||
buf |= c;
|
||||
EmojiDrawable d = Emoji.getEmojiDrawable(buf);
|
||||
if (d != null) {
|
||||
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
|
||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
|
||||
emojiCount++;
|
||||
s.setSpan(span, i - 1, i + 1, 0);
|
||||
s.setSpan(span, i - 1, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
if (nextIsSkinTone) {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
buf = 0;
|
||||
}
|
||||
@ -471,9 +488,13 @@ public class Emoji {
|
||||
} else if (inArray(c, emojiChars)) {
|
||||
EmojiDrawable d = Emoji.getEmojiDrawable(c);
|
||||
if (d != null) {
|
||||
boolean nextIsSkinTone = isNextCharIsColor(cs, i);
|
||||
EmojiSpan span = new EmojiSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM, size, fontMetrics);
|
||||
emojiCount++;
|
||||
s.setSpan(span, i, i + 1, 0);
|
||||
s.setSpan(span, i, i + (nextIsSkinTone ? 3 : 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
if (nextIsSkinTone) {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (emojiCount >= 50) {
|
||||
|
@ -26,7 +26,6 @@ import android.os.Environment;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.provider.MediaStore;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.DispatchQueue;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
@ -34,6 +33,7 @@ import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
@ -46,6 +46,7 @@ import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
@ -140,9 +141,13 @@ public class ImageLoader {
|
||||
|
||||
fileOutputStream = new RandomAccessFile(tempFile, "rws");
|
||||
} catch (Throwable e) {
|
||||
if (e instanceof UnknownHostException) {
|
||||
canRetry = false;
|
||||
}
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
if (canRetry) {
|
||||
try {
|
||||
if (httpConnection != null && httpConnection instanceof HttpURLConnection) {
|
||||
int code = ((HttpURLConnection) httpConnection).getResponseCode();
|
||||
@ -197,6 +202,7 @@ public class ImageLoader {
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
@ -537,7 +543,7 @@ public class ImageLoader {
|
||||
boolean canDeleteFile = true;
|
||||
boolean useNativeWebpLoaded = false;
|
||||
|
||||
if (Build.VERSION.SDK_INT < 18) {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
RandomAccessFile randomAccessFile = null;
|
||||
try {
|
||||
randomAccessFile = new RandomAccessFile(cacheFileFinal, "r");
|
||||
@ -1905,13 +1911,6 @@ public class ImageLoader {
|
||||
BitmapFactory.decodeFileDescriptor(fileDescriptor, null, bmOptions);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
try {
|
||||
if (parcelFD != null) {
|
||||
parcelFD.close();
|
||||
}
|
||||
} catch (Throwable e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -23,9 +23,9 @@ import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
@ -19,11 +19,11 @@ import android.text.format.DateFormat;
|
||||
import android.util.Xml;
|
||||
|
||||
import org.telegram.android.time.FastDateFormat;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
import java.io.File;
|
||||
@ -203,6 +203,22 @@ public class LocaleController {
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "پارسی";
|
||||
localeInfo.nameEnglish = "Parsi";
|
||||
localeInfo.shortName = "fa_IR";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "अंग्रेजी";
|
||||
localeInfo.nameEnglish = "Hindi";
|
||||
localeInfo.shortName = "hi";
|
||||
localeInfo.pathToFile = null;
|
||||
sortedLanguages.add(localeInfo);
|
||||
languagesDict.put(localeInfo.shortName, localeInfo);
|
||||
|
||||
localeInfo = new LocaleInfo();
|
||||
localeInfo.name = "Català";
|
||||
localeInfo.nameEnglish = "Catalan";
|
||||
@ -883,7 +899,7 @@ public class LocaleController {
|
||||
return getString("Online", R.string.Online);
|
||||
}
|
||||
}
|
||||
if (user == null || user.status == null || user.status.expires == 0 || user instanceof TLRPC.TL_userDeleted || user instanceof TLRPC.TL_userEmpty) {
|
||||
if (user == null || user.status == null || user.status.expires == 0 || UserObject.isDeleted(user) || user instanceof TLRPC.TL_userEmpty) {
|
||||
return getString("ALongTimeAgo", R.string.ALongTimeAgo);
|
||||
} else {
|
||||
int currentTime = ConnectionsManager.getInstance().getCurrentTime();
|
||||
|
@ -41,6 +41,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.provider.MediaStore;
|
||||
import android.view.View;
|
||||
@ -49,7 +50,6 @@ import org.telegram.android.video.InputSurface;
|
||||
import org.telegram.android.video.MP4Builder;
|
||||
import org.telegram.android.video.Mp4Movie;
|
||||
import org.telegram.android.video.OutputSurface;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.DispatchQueue;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
@ -58,6 +58,7 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.ui.Cells.ChatMediaCell;
|
||||
import org.telegram.ui.Components.GifDrawable;
|
||||
|
||||
@ -200,6 +201,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
private SensorManager sensorManager;
|
||||
private Sensor proximitySensor;
|
||||
private boolean ignoreProximity;
|
||||
private PowerManager.WakeLock proximityWakeLock;
|
||||
|
||||
private ArrayList<MessageObject> videoConvertQueue = new ArrayList<>();
|
||||
private final Object videoQueueSync = new Object();
|
||||
@ -222,6 +224,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
private boolean saveToGallery = true;
|
||||
|
||||
public static AlbumEntry allPhotosAlbumEntry;
|
||||
|
||||
private HashMap<String, ArrayList<WeakReference<FileDownloadProgressListener>>> loadingFileObservers = new HashMap<>();
|
||||
private HashMap<Integer, String> observersByTag = new HashMap<>();
|
||||
private boolean listenerInProgress = false;
|
||||
@ -357,6 +361,40 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
}
|
||||
}
|
||||
|
||||
/*private class GalleryObserverInternal extends ContentObserver {
|
||||
public GalleryObserverInternal() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadGalleryPhotosAlbums(0);
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryObserverExternal extends ContentObserver {
|
||||
public GalleryObserverExternal() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(boolean selfChange) {
|
||||
super.onChange(selfChange);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadGalleryPhotosAlbums(0);
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
}*/
|
||||
|
||||
private ExternalObserver externalObserver = null;
|
||||
private InternalObserver internalObserver = null;
|
||||
private long lastSecretChatEnterTime = 0;
|
||||
@ -430,6 +468,8 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
try {
|
||||
sensorManager = (SensorManager) ApplicationLoader.applicationContext.getSystemService(Context.SENSOR_SERVICE);
|
||||
proximitySensor = sensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||
PowerManager powerManager = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
proximityWakeLock = powerManager.newWakeLock(0x00000020, "proximity");
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -486,6 +526,17 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
MediaStore.Images.ImageColumns.TITLE
|
||||
};
|
||||
}
|
||||
|
||||
/*try {
|
||||
ApplicationLoader.applicationContext.getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, false, new GalleryObserverExternal());
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
ApplicationLoader.applicationContext.getContentResolver().registerContentObserver(MediaStore.Images.Media.INTERNAL_CONTENT_URI, false, new GalleryObserverInternal());
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}*/
|
||||
}
|
||||
|
||||
private void startProgressTimer() {
|
||||
@ -1193,7 +1244,10 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
if (sensorManager != null && proximitySensor != null) {
|
||||
sensorManager.unregisterListener(this);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (proximityWakeLock != null && proximityWakeLock.isHeld()) {
|
||||
proximityWakeLock.release();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
@ -1206,6 +1260,9 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
if (sensorManager != null && proximitySensor != null) {
|
||||
sensorManager.registerListener(this, proximitySensor, SensorManager.SENSOR_DELAY_NORMAL);
|
||||
}
|
||||
if (!NotificationsController.getInstance().audioManager.isWiredHeadsetOn() && proximityWakeLock != null && !proximityWakeLock.isHeld()) {
|
||||
proximityWakeLock.acquire();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -1321,7 +1378,14 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioDidStarted, messageObject);
|
||||
clenupPlayer(true);
|
||||
final File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
|
||||
File file = null;
|
||||
if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() > 0) {
|
||||
file = new File(messageObject.messageOwner.attachPath);
|
||||
if (!file.exists()) {
|
||||
file = null;
|
||||
}
|
||||
}
|
||||
final File cacheFile = file != null ? file : FileLoader.getPathToMessage(messageObject.messageOwner);
|
||||
|
||||
if (isOpusFile(cacheFile.getAbsolutePath()) == 1) {
|
||||
synchronized (playerObjectSync) {
|
||||
@ -2096,7 +2160,7 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
try {
|
||||
albums.clear();
|
||||
allPhotosAlbum = null;
|
||||
AlbumEntry allVideosAlbum = null;
|
||||
cursor = MediaStore.Images.Media.query(ApplicationLoader.applicationContext.getContentResolver(), MediaStore.Video.Media.EXTERNAL_CONTENT_URI, projectionVideo, "", null, MediaStore.Video.Media.DATE_TAKEN + " DESC");
|
||||
if (cursor != null) {
|
||||
int imageIdColumn = cursor.getColumnIndex(MediaStore.Video.Media._ID);
|
||||
@ -2118,12 +2182,12 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
PhotoEntry photoEntry = new PhotoEntry(bucketId, imageId, dateTaken, path, 0, true);
|
||||
|
||||
if (allPhotosAlbum == null) {
|
||||
allPhotosAlbum = new AlbumEntry(0, LocaleController.getString("AllVideo", R.string.AllVideo), photoEntry, true);
|
||||
videoAlbumsSorted.add(0, allPhotosAlbum);
|
||||
if (allVideosAlbum == null) {
|
||||
allVideosAlbum = new AlbumEntry(0, LocaleController.getString("AllVideo", R.string.AllVideo), photoEntry, true);
|
||||
videoAlbumsSorted.add(0, allVideosAlbum);
|
||||
}
|
||||
if (allPhotosAlbum != null) {
|
||||
allPhotosAlbum.addPhoto(photoEntry);
|
||||
if (allVideosAlbum != null) {
|
||||
allVideosAlbum.addPhoto(photoEntry);
|
||||
}
|
||||
|
||||
AlbumEntry albumEntry = albums.get(bucketId);
|
||||
@ -2155,9 +2219,11 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
|
||||
|
||||
final Integer cameraAlbumIdFinal = cameraAlbumId;
|
||||
final Integer cameraAlbumVideoIdFinal = cameraAlbumVideoId;
|
||||
final AlbumEntry allPhotosAlbumFinal = allPhotosAlbum;
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
allPhotosAlbumEntry = allPhotosAlbumFinal;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.albumsDidLoaded, guid, albumsSorted, cameraAlbumIdFinal, videoAlbumsSorted, cameraAlbumVideoIdFinal);
|
||||
}
|
||||
});
|
||||
|
@ -23,8 +23,8 @@ import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderline;
|
||||
import org.telegram.ui.Components.URLSpanNoUnderlineBold;
|
||||
@ -65,6 +65,8 @@ public class MessageObject {
|
||||
public int textHeight;
|
||||
public int blockHeight = Integer.MAX_VALUE;
|
||||
|
||||
public static Pattern urlPattern;
|
||||
|
||||
public static class TextLayoutBlock {
|
||||
public StaticLayout textLayout;
|
||||
public float textXOffset = 0;
|
||||
@ -237,7 +239,7 @@ public class MessageObject {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChangedOutgoing", R.string.MessageLifetimeChangedOutgoing, AndroidUtilities.formatTTLString(message.action.ttl));
|
||||
} else {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, fromUser.first_name, AndroidUtilities.formatTTLString(message.action.ttl));
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, UserObject.getFirstName(fromUser), AndroidUtilities.formatTTLString(message.action.ttl));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, "", AndroidUtilities.formatTTLString(message.action.ttl));
|
||||
}
|
||||
@ -247,7 +249,7 @@ public class MessageObject {
|
||||
messageText = LocaleController.getString("MessageLifetimeYouRemoved", R.string.MessageLifetimeYouRemoved);
|
||||
} else {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, fromUser.first_name);
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(fromUser));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, "");
|
||||
}
|
||||
@ -264,20 +266,17 @@ public class MessageObject {
|
||||
to_user = MessagesController.getInstance().getUser(messageOwner.to_id.user_id);
|
||||
}
|
||||
}
|
||||
String name = "";
|
||||
if (to_user != null) {
|
||||
name = to_user.first_name;
|
||||
}
|
||||
String name = to_user != null ? UserObject.getFirstName(to_user) : "";
|
||||
messageText = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, name, date, message.action.title, message.action.address);
|
||||
} else if (message.action instanceof TLRPC.TL_messageActionUserJoined) {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, ContactsController.formatName(fromUser.first_name, fromUser.last_name));
|
||||
messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, UserObject.getUserName(fromUser));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, "");
|
||||
}
|
||||
} else if (message.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, ContactsController.formatName(fromUser.first_name, fromUser.last_name));
|
||||
messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, UserObject.getUserName(fromUser));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, "");
|
||||
}
|
||||
@ -299,7 +298,7 @@ public class MessageObject {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChangedOutgoing", R.string.MessageLifetimeChangedOutgoing, AndroidUtilities.formatTTLString(action.ttl_seconds));
|
||||
} else {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, fromUser.first_name, AndroidUtilities.formatTTLString(action.ttl_seconds));
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, UserObject.getFirstName(fromUser), AndroidUtilities.formatTTLString(action.ttl_seconds));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("MessageLifetimeChanged", R.string.MessageLifetimeChanged, "", AndroidUtilities.formatTTLString(action.ttl_seconds));
|
||||
}
|
||||
@ -309,7 +308,7 @@ public class MessageObject {
|
||||
messageText = LocaleController.getString("MessageLifetimeYouRemoved", R.string.MessageLifetimeYouRemoved);
|
||||
} else {
|
||||
if (fromUser != null) {
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, fromUser.first_name);
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, UserObject.getFirstName(fromUser));
|
||||
} else {
|
||||
messageText = LocaleController.formatString("MessageLifetimeRemoved", R.string.MessageLifetimeRemoved, "");
|
||||
}
|
||||
@ -509,7 +508,7 @@ public class MessageObject {
|
||||
}
|
||||
|
||||
public CharSequence replaceWithLink(CharSequence source, String param, TLRPC.User user) {
|
||||
String name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
String name = UserObject.getUserName(user);
|
||||
int start = TextUtils.indexOf(source, param);
|
||||
URLSpanNoUnderlineBold span = new URLSpanNoUnderlineBold("" + user.id);
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(TextUtils.replace(source, new String[]{param}, new String[]{name}));
|
||||
@ -549,8 +548,8 @@ public class MessageObject {
|
||||
return FileLoader.MEDIA_DIR_CACHE;
|
||||
}
|
||||
|
||||
private boolean containsUrls(CharSequence message) {
|
||||
if (message == null || message.length() < 3 || message.length() > 1024 * 20) {
|
||||
private static boolean containsUrls(CharSequence message) {
|
||||
if (message == null || message.length() < 2 || message.length() > 1024 * 20) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -575,7 +574,7 @@ public class MessageObject {
|
||||
} else if (!(c != ' ' && digitsInRow > 0)) {
|
||||
digitsInRow = 0;
|
||||
}
|
||||
if ((c == '@' || c == '#') && i == 0 || i != 0 && (message.charAt(i - 1) == ' ' || message.charAt(i - 1) == '\n')) {
|
||||
if ((c == '@' || c == '#' || c == '/') && i == 0 || i != 0 && (message.charAt(i - 1) == ' ' || message.charAt(i - 1) == '\n')) {
|
||||
return true;
|
||||
}
|
||||
if (c == ':') {
|
||||
@ -638,14 +637,16 @@ public class MessageObject {
|
||||
}
|
||||
}
|
||||
|
||||
private void addUsernamesAndHashtags(CharSequence charSequence) {
|
||||
private static void addUsernamesAndHashtags(CharSequence charSequence) {
|
||||
try {
|
||||
Pattern pattern = Pattern.compile("(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w\\.]+");
|
||||
Matcher matcher = pattern.matcher(charSequence);
|
||||
if (urlPattern == null) {
|
||||
urlPattern = Pattern.compile("(^|\\s)/[a-zA-Z@\\d_]{1,255}|(^|\\s)@[a-zA-Z\\d_]{5,32}|(^|\\s)#[\\w\\.]+");
|
||||
}
|
||||
Matcher matcher = urlPattern.matcher(charSequence);
|
||||
while (matcher.find()) {
|
||||
int start = matcher.start();
|
||||
int end = matcher.end();
|
||||
if (charSequence.charAt(start) != '@' && charSequence.charAt(start) != '#') {
|
||||
if (charSequence.charAt(start) != '@' && charSequence.charAt(start) != '#' && charSequence.charAt(start) != '/') {
|
||||
start++;
|
||||
}
|
||||
URLSpanNoUnderline url = new URLSpanNoUnderline(charSequence.subSequence(start, end).toString());
|
||||
@ -656,14 +657,7 @@ public class MessageObject {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateLayout() {
|
||||
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
generateLinkDescription();
|
||||
textLayoutBlocks = new ArrayList<>();
|
||||
|
||||
public static void addLinks(CharSequence messageText) {
|
||||
if (messageText instanceof Spannable && containsUrls(messageText)) {
|
||||
if (messageText.length() < 100) {
|
||||
try {
|
||||
@ -680,6 +674,17 @@ public class MessageObject {
|
||||
}
|
||||
addUsernamesAndHashtags(messageText);
|
||||
}
|
||||
}
|
||||
|
||||
private void generateLayout() {
|
||||
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
generateLinkDescription();
|
||||
textLayoutBlocks = new ArrayList<>();
|
||||
|
||||
addLinks(messageText);
|
||||
|
||||
int maxWidth;
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
@ -928,7 +933,7 @@ public class MessageObject {
|
||||
}
|
||||
|
||||
public boolean isSendError() {
|
||||
return messageOwner.send_state == MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
return messageOwner.send_state == MESSAGE_SEND_STATE_SEND_ERROR && messageOwner.id < 0;
|
||||
}
|
||||
|
||||
public boolean isSent() {
|
||||
|
@ -18,8 +18,10 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Base64;
|
||||
import android.util.SparseArray;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.android.query.BotQuery;
|
||||
import org.telegram.android.query.StickersQuery;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
@ -30,6 +32,7 @@ import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.ProfileActivity;
|
||||
@ -52,6 +55,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
public ArrayList<TLRPC.TL_dialog> dialogs = new ArrayList<>();
|
||||
public ArrayList<TLRPC.TL_dialog> dialogsServerOnly = new ArrayList<>();
|
||||
public ArrayList<TLRPC.TL_dialog> dialogsGroupsOnly = new ArrayList<>();
|
||||
public ConcurrentHashMap<Long, TLRPC.TL_dialog> dialogs_dict = new ConcurrentHashMap<>(100, 1.0f, 2);
|
||||
public HashMap<Integer, MessageObject> dialogMessage = new HashMap<>();
|
||||
public ConcurrentHashMap<Long, ArrayList<PrintingUser>> printingUsers = new ConcurrentHashMap<>(20, 1.0f, 2);
|
||||
@ -240,7 +244,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
|
||||
public void addSupportUser() {
|
||||
TLRPC.TL_userForeign user = new TLRPC.TL_userForeign();
|
||||
TLRPC.TL_userForeign_old2 user = new TLRPC.TL_userForeign_old2();
|
||||
user.phone = "333";
|
||||
user.id = 333000;
|
||||
user.first_name = "Telegram";
|
||||
@ -249,7 +253,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
user.photo = new TLRPC.TL_userProfilePhotoEmpty();
|
||||
putUser(user, true);
|
||||
|
||||
user = new TLRPC.TL_userForeign();
|
||||
user = new TLRPC.TL_userForeign_old2();
|
||||
user.phone = "42777";
|
||||
user.id = 777000;
|
||||
user.first_name = "Telegram";
|
||||
@ -266,7 +270,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
TLRPC.InputUser inputUser;
|
||||
if (user.id == UserConfig.getClientUserId()) {
|
||||
inputUser = new TLRPC.TL_inputUserSelf();
|
||||
} else if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
} else if (user.access_hash != 0) {
|
||||
inputUser = new TLRPC.TL_inputUserForeign();
|
||||
inputUser.user_id = user.id;
|
||||
inputUser.access_hash = user.access_hash;
|
||||
@ -374,11 +378,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
NotificationsController.getInstance().cleanup();
|
||||
SendMessagesHelper.getInstance().cleanUp();
|
||||
SecretChatHelper.getInstance().cleanUp();
|
||||
StickersQuery.cleanup();
|
||||
|
||||
dialogs_dict.clear();
|
||||
exportedChats.clear();
|
||||
dialogs.clear();
|
||||
dialogsServerOnly.clear();
|
||||
dialogsGroupsOnly.clear();
|
||||
users.clear();
|
||||
usersByUsernames.clear();
|
||||
chats.clear();
|
||||
@ -597,6 +603,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int a = 0; a < res.full_chat.bot_info.size(); a++) {
|
||||
TLRPC.BotInfo botInfo = res.full_chat.bot_info.get(a);
|
||||
BotQuery.putBotInfo(botInfo);
|
||||
}
|
||||
exportedChats.put(chat_id, res.full_chat.exported_invite);
|
||||
loadingFullChats.remove((Integer) chat_id);
|
||||
loadedFullChats.add(chat_id);
|
||||
@ -635,10 +645,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.TL_userFull userFull = (TLRPC.TL_userFull) response;
|
||||
if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
|
||||
BotQuery.putBotInfo(userFull.bot_info);
|
||||
}
|
||||
loadingFullUsers.remove((Integer) user.id);
|
||||
loadedFullUsers.add(user.id);
|
||||
String names = user.first_name + user.last_name + user.username;
|
||||
TLRPC.TL_userFull userFull = (TLRPC.TL_userFull) response;
|
||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
users.add(userFull.user);
|
||||
putUsers(users, false);
|
||||
@ -646,6 +659,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (!names.equals(userFull.user.first_name + userFull.user.last_name + userFull.user.username)) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_NAME);
|
||||
}
|
||||
if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.botInfoDidLoaded, userFull.bot_info, classGuid);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -1085,6 +1101,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (!onlyHistory) {
|
||||
dialogs.remove(dialog);
|
||||
dialogsServerOnly.remove(dialog);
|
||||
dialogsGroupsOnly.remove(dialog);
|
||||
dialogs_dict.remove(did);
|
||||
totalDialogsCount--;
|
||||
} else {
|
||||
@ -1120,12 +1137,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (lower_part != 0) {
|
||||
TLRPC.TL_messages_deleteHistory req = new TLRPC.TL_messages_deleteHistory();
|
||||
req.offset = offset;
|
||||
if (did < 0) {
|
||||
if (lower_part < 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerChat();
|
||||
req.peer.chat_id = -lower_part;
|
||||
} else {
|
||||
TLRPC.User user = getUser(lower_part);
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
@ -1426,8 +1446,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
req.peer.chat_id = -lower_part;
|
||||
} else {
|
||||
TLRPC.User user = getUser(lower_part);
|
||||
if (user != null) {
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.user_id = user.id;
|
||||
req.peer.access_hash = user.access_hash;
|
||||
@ -1435,9 +1457,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
req.peer = new TLRPC.TL_inputPeerContact();
|
||||
req.peer.user_id = user.id;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (action == 0) {
|
||||
req.action = new TLRPC.TL_sendMessageTypingAction();
|
||||
@ -1517,7 +1536,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.user_id = user.id;
|
||||
req.peer.access_hash = user.access_hash;
|
||||
@ -1558,9 +1577,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (!isCache) {
|
||||
ImageLoader.saveMessagesThumbs(messagesRes.messages);
|
||||
}
|
||||
if (!isCache && allowCache) {
|
||||
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
|
||||
}
|
||||
if (high_id != 1 && lower_id != 0 && isCache && messagesRes.messages.size() == 0 && (load_type == 0 || load_type == 2 || load_type == 3)) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@ -1570,15 +1586,27 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
});
|
||||
return;
|
||||
}
|
||||
final HashMap<Integer, TLRPC.User> usersLocal = new HashMap<>();
|
||||
final HashMap<Integer, TLRPC.User> usersDict = new HashMap<>();
|
||||
for (TLRPC.User u : messagesRes.users) {
|
||||
usersLocal.put(u.id, u);
|
||||
usersDict.put(u.id, u);
|
||||
}
|
||||
if (!isCache && allowCache) {
|
||||
for (int a = 0; a < messagesRes.messages.size(); a++) {
|
||||
TLRPC.Message message = messagesRes.messages.get(a);
|
||||
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
|
||||
TLRPC.User user = usersDict.get(message.action.user_id);
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
|
||||
}
|
||||
}
|
||||
}
|
||||
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
|
||||
}
|
||||
final ArrayList<MessageObject> objects = new ArrayList<>();
|
||||
ArrayList<Integer> messagesToReload = null;
|
||||
for (TLRPC.Message message : messagesRes.messages) {
|
||||
message.dialog_id = dialog_id;
|
||||
objects.add(new MessageObject(message, usersLocal, true));
|
||||
objects.add(new MessageObject(message, usersDict, true));
|
||||
if (isCache) {
|
||||
if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
|
||||
if (message.media.bytes.length == 0 || message.media.bytes.length == 1 && message.media.bytes[0] < TLRPC.LAYER) {
|
||||
@ -1752,6 +1780,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
dialogs.clear();
|
||||
dialogsServerOnly.clear();
|
||||
dialogsGroupsOnly.clear();
|
||||
dialogs.addAll(dialogs_dict.values());
|
||||
Collections.sort(dialogs, new Comparator<TLRPC.TL_dialog>() {
|
||||
@Override
|
||||
@ -1769,6 +1798,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
int high_id = (int) (d.id >> 32);
|
||||
if ((int) d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
if (d.id < 0) {
|
||||
dialogsGroupsOnly.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
|
||||
@ -1800,11 +1832,26 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
final HashMap<Long, TLRPC.TL_dialog> new_dialogs_dict = new HashMap<>();
|
||||
final HashMap<Integer, MessageObject> new_dialogMessage = new HashMap<>();
|
||||
final HashMap<Integer, TLRPC.User> usersLocal = new HashMap<>();
|
||||
final HashMap<Integer, TLRPC.User> usersDict = new HashMap<>();
|
||||
int new_totalDialogsCount;
|
||||
|
||||
for (TLRPC.User u : dialogsRes.users) {
|
||||
usersDict.put(u.id, u);
|
||||
}
|
||||
|
||||
if (!isCache) {
|
||||
ImageLoader.saveMessagesThumbs(dialogsRes.messages);
|
||||
|
||||
for (int a = 0; a < dialogsRes.messages.size(); a++) {
|
||||
TLRPC.Message message = dialogsRes.messages.get(a);
|
||||
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
|
||||
TLRPC.User user = usersDict.get(message.action.user_id);
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessagesStorage.getInstance().putDialogs(dialogsRes);
|
||||
}
|
||||
|
||||
@ -1815,12 +1862,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
new_totalDialogsCount = dialogsRes.dialogs.size();
|
||||
}
|
||||
|
||||
for (TLRPC.User u : dialogsRes.users) {
|
||||
usersLocal.put(u.id, u);
|
||||
}
|
||||
|
||||
for (TLRPC.Message m : dialogsRes.messages) {
|
||||
new_dialogMessage.put(m.id, new MessageObject(m, usersLocal, false));
|
||||
new_dialogMessage.put(m.id, new MessageObject(m, usersDict, false));
|
||||
}
|
||||
for (TLRPC.TL_dialog d : dialogsRes.dialogs) {
|
||||
if (d.last_message_date == 0) {
|
||||
@ -1889,6 +1932,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
dialogs.clear();
|
||||
dialogsServerOnly.clear();
|
||||
dialogsGroupsOnly.clear();
|
||||
dialogs.addAll(dialogs_dict.values());
|
||||
Collections.sort(dialogs, new Comparator<TLRPC.TL_dialog>() {
|
||||
@Override
|
||||
@ -1906,6 +1950,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
int high_id = (int) (d.id >> 32);
|
||||
if ((int) d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
if (d.id < 0) {
|
||||
dialogsGroupsOnly.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1971,7 +2018,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.user_id = user.id;
|
||||
req.peer.access_hash = user.access_hash;
|
||||
@ -2167,18 +2214,47 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
public void addUserToChat(int chat_id, final TLRPC.User user, final TLRPC.ChatParticipants info, int count_fwd) {
|
||||
public void sendBotStart(final TLRPC.User user, String botHash) {
|
||||
TLRPC.TL_messages_startBot req = new TLRPC.TL_messages_startBot();
|
||||
req.bot = getInputUser(user);
|
||||
req.chat_id = 0;
|
||||
req.start_param = botHash;
|
||||
req.random_id = Utilities.random.nextLong();
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (error != null) {
|
||||
return;
|
||||
}
|
||||
processUpdates((TLRPC.Updates) response, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addUserToChat(int chat_id, final TLRPC.User user, final TLRPC.ChatParticipants info, int count_fwd, String botHash) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (chat_id > 0) {
|
||||
TLObject request;
|
||||
|
||||
if (botHash == null) {
|
||||
TLRPC.TL_messages_addChatUser req = new TLRPC.TL_messages_addChatUser();
|
||||
req.chat_id = chat_id;
|
||||
req.fwd_limit = count_fwd;
|
||||
req.user_id = getInputUser(user);
|
||||
request = req;
|
||||
} else {
|
||||
TLRPC.TL_messages_startBot req = new TLRPC.TL_messages_startBot();
|
||||
req.bot = getInputUser(user);
|
||||
req.chat_id = chat_id;
|
||||
req.start_param = botHash;
|
||||
req.random_id = Utilities.random.nextLong();
|
||||
request = req;
|
||||
}
|
||||
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
ConnectionsManager.getInstance().performRpc(request, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, TLRPC.TL_error error) {
|
||||
if (error != null) {
|
||||
@ -2713,7 +2789,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
ImageLoader.saveMessagesThumbs(res.new_messages);
|
||||
|
||||
final ArrayList<MessageObject> pushMessages = new ArrayList<>();
|
||||
for (TLRPC.Message message : res.new_messages) {
|
||||
for (int a = 0; a < res.new_messages.size(); a++) {
|
||||
TLRPC.Message message = res.new_messages.get(a);
|
||||
|
||||
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
|
||||
TLRPC.User user = usersDict.get(message.action.user_id);
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
|
||||
}
|
||||
}
|
||||
|
||||
MessageObject obj = new MessageObject(message, usersDict, true);
|
||||
|
||||
if (!obj.isOut() && obj.isUnread()) {
|
||||
@ -3313,6 +3398,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
if (u.userId == update.user_id) {
|
||||
exist = true;
|
||||
u.lastTime = currentTime;
|
||||
if (u.action.getClass() != update.action.getClass()) {
|
||||
printChanged = true;
|
||||
}
|
||||
u.action = update.action;
|
||||
break;
|
||||
}
|
||||
@ -3567,6 +3655,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
});
|
||||
|
||||
if (!messagesArr.isEmpty()) {
|
||||
for (int a = 0; a < messagesArr.size(); a++) {
|
||||
TLRPC.Message message = messagesArr.get(a);
|
||||
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
|
||||
TLRPC.User user = usersDict.get(message.action.user_id);
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
|
||||
}
|
||||
}
|
||||
}
|
||||
MessagesStorage.getInstance().putMessages(messagesArr, true, true, false, MediaController.getInstance().getAutodownloadMask());
|
||||
}
|
||||
|
||||
@ -3606,7 +3703,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
} else if (update instanceof TLRPC.TL_updateUserName) {
|
||||
if (currentUser != null) {
|
||||
if (!(currentUser instanceof TLRPC.TL_userContact)) {
|
||||
if (!UserObject.isContact(currentUser)) {
|
||||
currentUser.first_name = update.first_name;
|
||||
currentUser.last_name = update.last_name;
|
||||
}
|
||||
@ -3814,8 +3911,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
if (!deletedMessages.isEmpty()) {
|
||||
MessagesStorage.getInstance().markMessagesAsDeleted(deletedMessages, true);
|
||||
}
|
||||
if (!deletedMessages.isEmpty()) {
|
||||
MessagesStorage.getInstance().updateDialogsWithDeletedMessages(deletedMessages, true);
|
||||
}
|
||||
if (!tasks.isEmpty()) {
|
||||
@ -3950,6 +4045,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
|
||||
if (changed) {
|
||||
dialogsServerOnly.clear();
|
||||
dialogsGroupsOnly.clear();
|
||||
Collections.sort(dialogs, new Comparator<TLRPC.TL_dialog>() {
|
||||
@Override
|
||||
public int compare(TLRPC.TL_dialog tl_dialog, TLRPC.TL_dialog tl_dialog2) {
|
||||
@ -3966,6 +4062,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
int high_id = (int) (d.id >> 32);
|
||||
if ((int) d.id != 0 && high_id != 1) {
|
||||
dialogsServerOnly.add(d);
|
||||
if (d.id < 0) {
|
||||
dialogsGroupsOnly.add(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4024,6 +4123,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||
fragment.presentFragment(new ChatActivity(args));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (fragment != null && fragment.getParentActivity() != null) {
|
||||
try {
|
||||
Toast.makeText(fragment.getParentActivity(), LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -17,8 +17,8 @@ import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.SQLite.SQLiteDatabase;
|
||||
import org.telegram.SQLite.SQLitePreparedStatement;
|
||||
import org.telegram.android.query.BotQuery;
|
||||
import org.telegram.android.query.SharedMediaQuery;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuffersStorage;
|
||||
import org.telegram.messenger.ByteBufferDesc;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
@ -30,6 +30,7 @@ import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
@ -121,7 +122,7 @@ public class MessagesStorage {
|
||||
database.executeFast("CREATE TABLE dialog_settings(did INTEGER PRIMARY KEY, flags INTEGER);").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE messages_seq(mid INTEGER PRIMARY KEY, seq_in INTEGER, seq_out INTEGER);").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE web_recent_v3(id TEXT, type INTEGER, image_url TEXT, thumb_url TEXT, local_url TEXT, width INTEGER, height INTEGER, size INTEGER, date INTEGER, PRIMARY KEY (id, type));").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE stickers(id INTEGER PRIMARY KEY, data BLOB, date INTEGER);").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE stickers_v2(id INTEGER PRIMARY KEY, data BLOB, date INTEGER, hash TEXT);").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE hashtag_recent_v2(id TEXT PRIMARY KEY, date INTEGER);").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE webpage_pending(id INTEGER, mid INTEGER, PRIMARY KEY (id, mid));").stepThis().dispose();
|
||||
|
||||
@ -163,8 +164,13 @@ public class MessagesStorage {
|
||||
//kev-value
|
||||
database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
|
||||
|
||||
//bots
|
||||
database.executeFast("CREATE TABLE bot_info(uid INTEGER PRIMARY KEY, info BLOB)").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE bot_keyboard(uid INTEGER PRIMARY KEY, mid INTEGER, info BLOB)").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS bot_keyboard_idx_mid ON bot_keyboard(mid);").stepThis().dispose();
|
||||
|
||||
//version
|
||||
database.executeFast("PRAGMA user_version = 17").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 20").stepThis().dispose();
|
||||
} else {
|
||||
try {
|
||||
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
|
||||
@ -195,7 +201,7 @@ public class MessagesStorage {
|
||||
}
|
||||
}
|
||||
int version = database.executeInt("PRAGMA user_version");
|
||||
if (version < 17) {
|
||||
if (version < 20) {
|
||||
updateDbToLastVersion(version);
|
||||
}
|
||||
}
|
||||
@ -349,8 +355,6 @@ public class MessagesStorage {
|
||||
version = 11;
|
||||
}
|
||||
if (version == 11) {
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS stickers(id INTEGER PRIMARY KEY, data BLOB, date INTEGER);").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 12").stepThis().dispose();
|
||||
version = 12;
|
||||
}
|
||||
if (version == 12) {
|
||||
@ -389,7 +393,24 @@ public class MessagesStorage {
|
||||
database.executeFast("ALTER TABLE dialogs ADD COLUMN inbox_max INTEGER default 0").stepThis().dispose();
|
||||
database.executeFast("ALTER TABLE dialogs ADD COLUMN outbox_max INTEGER default 0").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 17").stepThis().dispose();
|
||||
//version = 17;
|
||||
version = 17;
|
||||
}
|
||||
if (version == 17) {
|
||||
database.executeFast("CREATE TABLE bot_info(uid INTEGER PRIMARY KEY, info BLOB)").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 18").stepThis().dispose();
|
||||
version = 18;
|
||||
}
|
||||
if (version == 18) {
|
||||
database.executeFast("DROP TABLE IF EXISTS stickers;").stepThis().dispose();
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS stickers_v2(id INTEGER PRIMARY KEY, data BLOB, date INTEGER, hash TEXT);").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 19").stepThis().dispose();
|
||||
version = 19;
|
||||
}
|
||||
if (version == 19) {
|
||||
database.executeFast("CREATE TABLE IF NOT EXISTS bot_keyboard(uid INTEGER PRIMARY KEY, mid INTEGER, info BLOB)").stepThis().dispose();
|
||||
database.executeFast("CREATE INDEX IF NOT EXISTS bot_keyboard_idx_mid ON bot_keyboard(mid);").stepThis().dispose();
|
||||
database.executeFast("PRAGMA user_version = 20").stepThis().dispose();
|
||||
//version = 20;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -934,8 +955,10 @@ public class MessagesStorage {
|
||||
|
||||
database.executeFast("UPDATE dialogs SET unread_count = 0 WHERE did = " + did).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM messages WHERE uid = " + did).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM bot_keyboard WHERE uid = " + did).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM media_counts_v2 WHERE uid = " + did).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM media_v2 WHERE uid = " + did).stepThis().dispose();
|
||||
BotQuery.clearBotKeyboard(did, null);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -2762,6 +2785,7 @@ public class MessagesStorage {
|
||||
HashMap<Integer, Integer> mediaTypes = new HashMap<>();
|
||||
HashMap<Integer, Long> messagesIdsMap = new HashMap<>();
|
||||
HashMap<Integer, Long> messagesMediaIdsMap = new HashMap<>();
|
||||
HashMap<Long, TLRPC.Message> botKeyboards = new HashMap<>();
|
||||
StringBuilder messageIds = new StringBuilder();
|
||||
StringBuilder messageMediaIds = new StringBuilder();
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
|
||||
@ -2796,6 +2820,17 @@ public class MessagesStorage {
|
||||
messagesMediaIdsMap.put(message.id, dialog_id);
|
||||
mediaTypes.put(message.id, SharedMediaQuery.getMediaType(message));
|
||||
}
|
||||
|
||||
if (message.reply_markup != null && ((message.reply_markup.flags & 4) == 0 || (message.flags & 16) != 0)) {
|
||||
TLRPC.Message oldMessage = botKeyboards.get(dialog_id);
|
||||
if (oldMessage == null || oldMessage.id < message.id) {
|
||||
botKeyboards.put(dialog_id, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (HashMap.Entry<Long, TLRPC.Message> entry : botKeyboards.entrySet()) {
|
||||
BotQuery.putBotKeyboard(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
if (messageMediaIds.length() > 0) {
|
||||
@ -2842,7 +2877,8 @@ public class MessagesStorage {
|
||||
}
|
||||
|
||||
int downloadMediaMask = 0;
|
||||
for (TLRPC.Message message : messages) {
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
TLRPC.Message message = messages.get(a);
|
||||
fixUnsupportedMedia(message);
|
||||
|
||||
long dialog_id = message.dialog_id;
|
||||
@ -3307,7 +3343,7 @@ public class MessagesStorage {
|
||||
TLRPC.User updateUser = usersDict.get(user.id);
|
||||
if (updateUser != null) {
|
||||
if (updateUser.first_name != null && updateUser.last_name != null) {
|
||||
if (!(user instanceof TLRPC.TL_userContact)) {
|
||||
if (!UserObject.isContact(user)) {
|
||||
user.first_name = updateUser.first_name;
|
||||
user.last_name = updateUser.last_name;
|
||||
}
|
||||
@ -3505,9 +3541,11 @@ public class MessagesStorage {
|
||||
cursor.dispose();
|
||||
FileLoader.getInstance().deleteFiles(filesToDelete);
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM messages WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM bot_keyboard WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM messages_seq WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
database.executeFast(String.format(Locale.US, "DELETE FROM media_v2 WHERE mid IN(%s)", ids)).stepThis().dispose();
|
||||
database.executeFast("DELETE FROM media_counts_v2 WHERE 1").stepThis().dispose();
|
||||
BotQuery.clearBotKeyboard(0, messages);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -3526,7 +3564,7 @@ public class MessagesStorage {
|
||||
}
|
||||
cursor.dispose();
|
||||
database.beginTransaction();
|
||||
SQLitePreparedStatement state = database.executeFast("UPDATE dialogs SET last_mid = (SELECT mid FROM messages WHERE uid = ? AND date = (SELECT MAX(date) FROM messages WHERE uid = ? )) WHERE did = ?");
|
||||
SQLitePreparedStatement state = database.executeFast("UPDATE dialogs SET unread_count = 0, last_mid = (SELECT mid FROM messages WHERE uid = ? AND date = (SELECT MAX(date) FROM messages WHERE uid = ? )) WHERE did = ?");
|
||||
for (long did : dialogsToUpdate) {
|
||||
state.requery();
|
||||
state.bindLong(1, did);
|
||||
@ -3688,7 +3726,9 @@ public class MessagesStorage {
|
||||
if (!messages.messages.isEmpty()) {
|
||||
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)");
|
||||
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||
for (TLRPC.Message message : messages.messages) {
|
||||
TLRPC.Message botKeyboard = null;
|
||||
for (int a = 0; a < messages.messages.size(); a++) {
|
||||
TLRPC.Message message = messages.messages.get(a);
|
||||
fixUnsupportedMedia(message);
|
||||
state.requery();
|
||||
ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
|
||||
@ -3714,9 +3754,18 @@ public class MessagesStorage {
|
||||
state2.step();
|
||||
}
|
||||
buffersStorage.reuseFreeBuffer(data);
|
||||
|
||||
if (message.reply_markup != null && ((message.reply_markup.flags & 4) == 0 || (message.flags & 16) != 0)) {
|
||||
if (botKeyboard == null || botKeyboard.id < message.id) {
|
||||
botKeyboard = message;
|
||||
}
|
||||
}
|
||||
}
|
||||
state.dispose();
|
||||
state2.dispose();
|
||||
if (botKeyboard != null) {
|
||||
BotQuery.putBotKeyboard(dialog_id, botKeyboard);
|
||||
}
|
||||
}
|
||||
putUsersInternal(messages.users);
|
||||
putChatsInternal(messages.chats);
|
||||
@ -3853,7 +3902,8 @@ public class MessagesStorage {
|
||||
try {
|
||||
database.beginTransaction();
|
||||
final HashMap<Integer, TLRPC.Message> new_dialogMessage = new HashMap<>();
|
||||
for (TLRPC.Message message : dialogs.messages) {
|
||||
for (int a = 0; a < dialogs.messages.size(); a++) {
|
||||
TLRPC.Message message = dialogs.messages.get(a);
|
||||
new_dialogMessage.put(message.id, message);
|
||||
}
|
||||
|
||||
@ -3863,7 +3913,9 @@ public class MessagesStorage {
|
||||
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
|
||||
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO dialog_settings VALUES(?, ?)");
|
||||
|
||||
for (TLRPC.TL_dialog dialog : dialogs.dialogs) {
|
||||
for (int a = 0; a < dialogs.dialogs.size(); a++) {
|
||||
TLRPC.TL_dialog dialog = dialogs.dialogs.get(a);
|
||||
|
||||
state.requery();
|
||||
state2.requery();
|
||||
state4.requery();
|
||||
@ -3872,6 +3924,12 @@ public class MessagesStorage {
|
||||
uid = -dialog.peer.chat_id;
|
||||
}
|
||||
TLRPC.Message message = new_dialogMessage.get(dialog.top_message);
|
||||
|
||||
if (message != null) {
|
||||
if (message.reply_markup != null && ((message.reply_markup.flags & 4) == 0 || (message.flags & 16) != 0)) {
|
||||
BotQuery.putBotKeyboard(uid, message);
|
||||
}
|
||||
|
||||
fixUnsupportedMedia(message);
|
||||
ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
|
||||
message.serializeToStream(data);
|
||||
@ -3887,18 +3945,6 @@ public class MessagesStorage {
|
||||
state.bindInteger(9, 0);
|
||||
state.step();
|
||||
|
||||
state2.bindLong(1, uid);
|
||||
state2.bindInteger(2, message.date);
|
||||
state2.bindInteger(3, dialog.unread_count);
|
||||
state2.bindInteger(4, dialog.top_message);
|
||||
state2.bindInteger(5, dialog.read_inbox_max_id);
|
||||
state2.bindInteger(6, 0);
|
||||
state2.step();
|
||||
|
||||
state4.bindLong(1, uid);
|
||||
state4.bindInteger(2, dialog.notify_settings.mute_until != 0 ? 1 : 0);
|
||||
state4.step();
|
||||
|
||||
if (SharedMediaQuery.canAddMessageToMedia(message)) {
|
||||
state3.requery();
|
||||
state3.bindLong(1, message.id);
|
||||
@ -3910,6 +3956,19 @@ public class MessagesStorage {
|
||||
}
|
||||
buffersStorage.reuseFreeBuffer(data);
|
||||
}
|
||||
|
||||
state2.bindLong(1, uid);
|
||||
state2.bindInteger(2, message != null ? message.date : 0);
|
||||
state2.bindInteger(3, dialog.unread_count);
|
||||
state2.bindInteger(4, dialog.top_message);
|
||||
state2.bindInteger(5, dialog.read_inbox_max_id);
|
||||
state2.bindInteger(6, 0);
|
||||
state2.step();
|
||||
|
||||
state4.bindLong(1, uid);
|
||||
state4.bindInteger(2, dialog.notify_settings.mute_until != 0 ? 1 : 0);
|
||||
state4.step();
|
||||
}
|
||||
state.dispose();
|
||||
state2.dispose();
|
||||
state3.dispose();
|
||||
|
@ -44,7 +44,6 @@ public class NotificationCenter {
|
||||
public static final int pushMessagesUpdated = totalEvents++;
|
||||
public static final int blockedUsersDidLoaded = totalEvents++;
|
||||
public static final int openedChatChanged = totalEvents++;
|
||||
public static final int hideEmojiKeyboard = totalEvents++;
|
||||
public static final int stopEncodingService = totalEvents++;
|
||||
public static final int didCreatedNewDeleteTask = totalEvents++;
|
||||
public static final int mainUserInfoChanged = totalEvents++;
|
||||
@ -62,6 +61,9 @@ public class NotificationCenter {
|
||||
public static final int stickersDidLoaded = totalEvents++;
|
||||
public static final int didReplacedPhotoInMemCache = totalEvents++;
|
||||
public static final int messagesReadContent = totalEvents++;
|
||||
public static final int botInfoDidLoaded = totalEvents++;
|
||||
public static final int botKeyboardDidLoaded = totalEvents++;
|
||||
public static final int chatSearchResultsAvailable = totalEvents++;
|
||||
|
||||
public static final int httpFileDidLoaded = totalEvents++;
|
||||
public static final int httpFileDidFailedLoad = totalEvents++;
|
||||
@ -147,7 +149,7 @@ public class NotificationCenter {
|
||||
|
||||
public void postNotificationName(int id, Object... args) {
|
||||
boolean allowDuringAnimation = false;
|
||||
if (id == dialogsNeedReload || id == closeChats || id == messagesDidLoaded || id == mediaCountDidLoaded || id == mediaDidLoaded) {
|
||||
if (id == dialogsNeedReload || id == closeChats || id == messagesDidLoaded || id == mediaCountDidLoaded || id == mediaDidLoaded || id == botInfoDidLoaded || id == botKeyboardDidLoaded) {
|
||||
allowDuringAnimation = true;
|
||||
}
|
||||
postNotificationNameInternal(id, allowDuringAnimation, args);
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 2.0.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.IntentService;
|
||||
import android.content.Intent;
|
||||
|
||||
public class NotificationDelay extends IntentService {
|
||||
|
||||
public NotificationDelay() {
|
||||
super("NotificationDelay");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onHandleIntent(Intent intent) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
NotificationsController.getInstance().notificationDelayReached();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ import android.media.AudioManager;
|
||||
import android.media.SoundPool;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.provider.Settings;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
@ -32,7 +33,6 @@ import android.support.v4.app.RemoteInput;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.DispatchQueue;
|
||||
import org.telegram.messenger.FileLog;
|
||||
@ -41,6 +41,7 @@ import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PopupNotificationActivity;
|
||||
|
||||
@ -75,12 +76,18 @@ public class NotificationsController {
|
||||
private int lastBadgeCount;
|
||||
private String launcherClassName;
|
||||
|
||||
private Runnable notificationDelayRunnable;
|
||||
private PowerManager.WakeLock notificationDelayWakelock;
|
||||
|
||||
private long lastSoundPlay;
|
||||
private long lastSoundOutPlay;
|
||||
private SoundPool soundPool;
|
||||
private int soundIn;
|
||||
private int soundOut;
|
||||
private boolean soundInLoaded;
|
||||
private boolean soundOutLoaded;
|
||||
protected AudioManager audioManager;
|
||||
private AlarmManager alarmManager;
|
||||
|
||||
private static volatile NotificationsController Instance = null;
|
||||
public static NotificationsController getInstance() {
|
||||
@ -106,6 +113,37 @@ public class NotificationsController {
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
alarmManager = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
try {
|
||||
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
||||
notificationDelayWakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "lock");
|
||||
notificationDelayWakelock.setReferenceCounted(false);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
notificationDelayRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FileLog.e("tmessages", "delay reached");
|
||||
if (!delayedPushMessages.isEmpty()) {
|
||||
showOrUpdateNotification(true);
|
||||
delayedPushMessages.clear();
|
||||
}
|
||||
try {
|
||||
if (notificationDelayWakelock.isHeld()) {
|
||||
notificationDelayWakelock.release();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
@ -118,8 +156,17 @@ public class NotificationsController {
|
||||
popupMessages.clear();
|
||||
wearNotificationsIds.clear();
|
||||
autoNotificationsIds.clear();
|
||||
delayedPushMessages.clear();
|
||||
notifyCheck = false;
|
||||
lastBadgeCount = 0;
|
||||
try {
|
||||
if (notificationDelayWakelock.isHeld()) {
|
||||
notificationDelayWakelock.release();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
setBadge(0);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.clear();
|
||||
@ -173,9 +220,9 @@ public class NotificationsController {
|
||||
if (preferences.getBoolean("EnablePreviewAll", true)) {
|
||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined) {
|
||||
msg = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationContactJoined", R.string.NotificationContactJoined, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) {
|
||||
msg = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationContactNewPhoto", R.string.NotificationContactNewPhoto, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionLoginUnknownLocation) {
|
||||
String date = LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.formatterYear.format(((long) messageObject.messageOwner.date) * 1000), LocaleController.formatterDay.format(((long) messageObject.messageOwner.date) * 1000));
|
||||
msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
|
||||
@ -184,33 +231,33 @@ public class NotificationsController {
|
||||
if (messageObject.isMediaEmpty()) {
|
||||
if (!shortMessage) {
|
||||
if (messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
|
||||
msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.message);
|
||||
msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, UserObject.getUserName(user), messageObject.messageOwner.message);
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, UserObject.getUserName(user));
|
||||
}
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, UserObject.getUserName(user));
|
||||
}
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
msg = LocaleController.formatString("NotificationMessagePhoto", R.string.NotificationMessagePhoto, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessagePhoto", R.string.NotificationMessagePhoto, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
msg = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageVideo", R.string.NotificationMessageVideo, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
|
||||
msg = LocaleController.formatString("NotificationMessageContact", R.string.NotificationMessageContact, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageContact", R.string.NotificationMessageContact, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
|
||||
msg = LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageMap", R.string.NotificationMessageMap, UserObject.getUserName(user));
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
|
||||
if (messageObject.isSticker()) {
|
||||
msg = LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageSticker", R.string.NotificationMessageSticker, UserObject.getUserName(user));
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageDocument", R.string.NotificationMessageDocument, UserObject.getUserName(user));
|
||||
}
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaAudio) {
|
||||
msg = LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageAudio", R.string.NotificationMessageAudio, UserObject.getUserName(user));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, ContactsController.formatName(user.first_name, user.last_name));
|
||||
msg = LocaleController.formatString("NotificationMessageNoText", R.string.NotificationMessageNoText, UserObject.getUserName(user));
|
||||
}
|
||||
} else if (chat_id != 0) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
@ -218,35 +265,35 @@ public class NotificationsController {
|
||||
if (messageObject.messageOwner instanceof TLRPC.TL_messageService) {
|
||||
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatAddUser) {
|
||||
if (messageObject.messageOwner.action.user_id == UserConfig.getClientUserId()) {
|
||||
msg = LocaleController.formatString("NotificationInvitedToGroup", R.string.NotificationInvitedToGroup, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationInvitedToGroup", R.string.NotificationInvitedToGroup, UserObject.getUserName(user), chat.title);
|
||||
} else {
|
||||
TLRPC.User u2 = MessagesController.getInstance().getUser(messageObject.messageOwner.action.user_id);
|
||||
if (u2 == null) {
|
||||
return null;
|
||||
}
|
||||
if (user.id == u2.id) {
|
||||
msg = LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationGroupAddSelf", R.string.NotificationGroupAddSelf, UserObject.getUserName(user), chat.title);
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, ContactsController.formatName(user.first_name, user.last_name), chat.title, ContactsController.formatName(u2.first_name, u2.last_name));
|
||||
msg = LocaleController.formatString("NotificationGroupAddMember", R.string.NotificationGroupAddMember, UserObject.getUserName(user), chat.title, UserObject.getUserName(u2));
|
||||
}
|
||||
}
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatJoinedByLink) {
|
||||
msg = LocaleController.formatString("NotificationInvitedToGroupByLink", R.string.NotificationInvitedToGroupByLink, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationInvitedToGroupByLink", R.string.NotificationInvitedToGroupByLink, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditTitle) {
|
||||
msg = LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.action.title);
|
||||
msg = LocaleController.formatString("NotificationEditedGroupName", R.string.NotificationEditedGroupName, UserObject.getUserName(user), messageObject.messageOwner.action.title);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatEditPhoto || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeletePhoto) {
|
||||
msg = LocaleController.formatString("NotificationEditedGroupPhoto", R.string.NotificationEditedGroupPhoto, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationEditedGroupPhoto", R.string.NotificationEditedGroupPhoto, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
|
||||
if (messageObject.messageOwner.action.user_id == UserConfig.getClientUserId()) {
|
||||
msg = LocaleController.formatString("NotificationGroupKickYou", R.string.NotificationGroupKickYou, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationGroupKickYou", R.string.NotificationGroupKickYou, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.action.user_id == user.id) {
|
||||
msg = LocaleController.formatString("NotificationGroupLeftMember", R.string.NotificationGroupLeftMember, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationGroupLeftMember", R.string.NotificationGroupLeftMember, UserObject.getUserName(user), chat.title);
|
||||
} else {
|
||||
TLRPC.User u2 = MessagesController.getInstance().getUser(messageObject.messageOwner.action.user_id);
|
||||
if (u2 == null) {
|
||||
return null;
|
||||
}
|
||||
msg = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, ContactsController.formatName(user.first_name, user.last_name), chat.title, ContactsController.formatName(u2.first_name, u2.last_name));
|
||||
msg = LocaleController.formatString("NotificationGroupKickMember", R.string.NotificationGroupKickMember, UserObject.getUserName(user), chat.title, UserObject.getUserName(u2));
|
||||
}
|
||||
} else if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatCreate) {
|
||||
msg = messageObject.messageText.toString();
|
||||
@ -254,30 +301,30 @@ public class NotificationsController {
|
||||
} else {
|
||||
if (messageObject.isMediaEmpty()) {
|
||||
if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, ContactsController.formatName(user.first_name, user.last_name), chat.title, messageObject.messageOwner.message);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, UserObject.getUserName(user), chat.title, messageObject.messageOwner.message);
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, UserObject.getUserName(user), chat.title);
|
||||
}
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupPhoto", R.string.NotificationMessageGroupPhoto, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupPhoto", R.string.NotificationMessageGroupPhoto, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupVideo", R.string.NotificationMessageGroupVideo, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupVideo", R.string.NotificationMessageGroupVideo, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaContact) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupContact", R.string.NotificationMessageGroupContact, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupContact", R.string.NotificationMessageGroupContact, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupMap", R.string.NotificationMessageGroupMap, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupMap", R.string.NotificationMessageGroupMap, UserObject.getUserName(user), chat.title);
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
|
||||
if (messageObject.isSticker()) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupSticker", R.string.NotificationMessageGroupSticker, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupSticker", R.string.NotificationMessageGroupSticker, UserObject.getUserName(user), chat.title);
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupDocument", R.string.NotificationMessageGroupDocument, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupDocument", R.string.NotificationMessageGroupDocument, UserObject.getUserName(user), chat.title);
|
||||
}
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaAudio) {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupAudio", R.string.NotificationMessageGroupAudio, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupAudio", R.string.NotificationMessageGroupAudio, UserObject.getUserName(user), chat.title);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
msg = LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, ContactsController.formatName(user.first_name, user.last_name), chat.title);
|
||||
msg = LocaleController.formatString("NotificationMessageGroupNoText", R.string.NotificationMessageGroupNoText, UserObject.getUserName(user), chat.title);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,14 +333,13 @@ public class NotificationsController {
|
||||
|
||||
private void scheduleNotificationRepeat() {
|
||||
try {
|
||||
AlarmManager alarm = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
int minutes = preferences.getInt("repeat_messages", 60);
|
||||
if (minutes > 0 && personal_count > 0) {
|
||||
alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + minutes * 60 * 1000, pintent);
|
||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + minutes * 60 * 1000, pintent);
|
||||
} else {
|
||||
alarm.cancel(pintent);
|
||||
alarmManager.cancel(pintent);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -303,24 +349,12 @@ public class NotificationsController {
|
||||
private void scheduleNotificationDelay(boolean onlineReason) {
|
||||
try {
|
||||
FileLog.e("tmessages", "delay notification start, onlineReason = " + onlineReason);
|
||||
AlarmManager alarm = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationDelay.class), 0);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
if (onlineReason) {
|
||||
alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 3 * 1000, pintent);
|
||||
} else {
|
||||
alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pintent);
|
||||
}
|
||||
notificationDelayWakelock.acquire(10000);
|
||||
AndroidUtilities.cancelRunOnUIThread(notificationDelayRunnable);
|
||||
AndroidUtilities.runOnUIThread(notificationDelayRunnable, (onlineReason ? 3 * 1000 : 1000));
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void notificationDelayReached() {
|
||||
FileLog.e("tmessages", "delay reached");
|
||||
if (!delayedPushMessages.isEmpty()) {
|
||||
showOrUpdateNotification(true);
|
||||
delayedPushMessages.clear();
|
||||
showOrUpdateNotification(notifyCheck);
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,7 +563,7 @@ public class NotificationsController {
|
||||
if (chat != null) {
|
||||
name = chat.title;
|
||||
} else {
|
||||
name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
name = UserObject.getUserName(user);
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,9 +707,11 @@ public class NotificationsController {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Long> sortedDialogs = new ArrayList<>();
|
||||
HashMap<Long, ArrayList<MessageObject>> messagesByDialogs = new HashMap<>();
|
||||
for (MessageObject messageObject : pushMessages) {
|
||||
for (int a = 0; a < pushMessages.size(); a++) {
|
||||
MessageObject messageObject = pushMessages.get(a);
|
||||
long dialog_id = messageObject.getDialogId();
|
||||
if ((int)dialog_id == 0) {
|
||||
continue;
|
||||
@ -698,7 +734,8 @@ public class NotificationsController {
|
||||
oldIdsAuto.putAll(autoNotificationsIds);
|
||||
autoNotificationsIds.clear();
|
||||
|
||||
for (long dialog_id : sortedDialogs) {
|
||||
for (int b = 0; b < sortedDialogs.size(); b++) {
|
||||
long dialog_id = sortedDialogs.get(b);
|
||||
ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id);
|
||||
int max_id = messageObjects.get(0).getId();
|
||||
int max_date = messageObjects.get(0).messageOwner.date;
|
||||
@ -719,7 +756,7 @@ public class NotificationsController {
|
||||
if (chat != null) {
|
||||
name = chat.title;
|
||||
} else {
|
||||
name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
name = UserObject.getUserName(user);
|
||||
}
|
||||
|
||||
Integer notificationIdWear = oldIdsWear.get(dialog_id);
|
||||
@ -736,19 +773,6 @@ public class NotificationsController {
|
||||
oldIdsAuto.remove(dialog_id);
|
||||
}
|
||||
|
||||
Intent replyIntent = new Intent(ApplicationLoader.applicationContext, WearReplyReceiver.class);
|
||||
replyIntent.putExtra("dialog_id", dialog_id);
|
||||
replyIntent.putExtra("max_id", max_id);
|
||||
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, notificationIdWear, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
RemoteInput remoteInputWear = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
|
||||
String replyToString;
|
||||
if (chat != null) {
|
||||
replyToString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, name);
|
||||
} else {
|
||||
replyToString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, name);
|
||||
}
|
||||
NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, replyToString, replyPendingIntent).addRemoteInput(remoteInputWear).build();
|
||||
|
||||
Intent msgHeardIntent = new Intent();
|
||||
msgHeardIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
|
||||
msgHeardIntent.setAction("org.telegram.messenger.ACTION_MESSAGE_HEARD");
|
||||
@ -769,6 +793,19 @@ public class NotificationsController {
|
||||
.setReplyAction(msgReplyPendingIntent, remoteInputAuto)
|
||||
.setLatestTimestamp((long) max_date * 1000);
|
||||
|
||||
Intent replyIntent = new Intent(ApplicationLoader.applicationContext, WearReplyReceiver.class);
|
||||
replyIntent.putExtra("dialog_id", dialog_id);
|
||||
replyIntent.putExtra("max_id", max_id);
|
||||
PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, notificationIdWear, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
RemoteInput remoteInputWear = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
|
||||
String replyToString;
|
||||
if (chat != null) {
|
||||
replyToString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, name);
|
||||
} else {
|
||||
replyToString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, name);
|
||||
}
|
||||
NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon, replyToString, replyPendingIntent).addRemoteInput(remoteInputWear).build();
|
||||
|
||||
String text = "";
|
||||
for (int a = messageObjects.size() - 1; a >= 0; a--) {
|
||||
MessageObject messageObject = messageObjects.get(a);
|
||||
@ -789,8 +826,6 @@ public class NotificationsController {
|
||||
unreadConvBuilder.addMessage(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TLRPC.FileLocation photoPath = null;
|
||||
if (chat != null) {
|
||||
if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) {
|
||||
@ -801,23 +836,6 @@ public class NotificationsController {
|
||||
photoPath = user.photo.photo_small;
|
||||
}
|
||||
}
|
||||
//notificationBuilder.extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build()));
|
||||
NotificationCompat.Builder builderAuto = new NotificationCompat.Builder(ApplicationLoader.applicationContext)
|
||||
.setSmallIcon(R.drawable.notification)
|
||||
.setColor(0xff2ca5e0)
|
||||
.setGroup("messages")
|
||||
.setLocalOnly(true)
|
||||
//.setGroupSummary(false)
|
||||
//.setCategory(NotificationCompat.CATEGORY_MESSAGE)
|
||||
.extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build()));
|
||||
if (photoPath != null) {
|
||||
BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50");
|
||||
if (img != null) {
|
||||
builderAuto.setLargeIcon(img.getBitmap());
|
||||
}
|
||||
}
|
||||
notificationManager.notify("android_auto", notificationIdAuto, builderAuto.build());
|
||||
autoNotificationsIds.put(dialog_id, notificationIdAuto);
|
||||
|
||||
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
||||
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
||||
@ -838,6 +856,7 @@ public class NotificationsController {
|
||||
.setGroupSummary(false)
|
||||
.setContentIntent(contentIntent)
|
||||
.extend(new NotificationCompat.WearableExtender().addAction(action))
|
||||
.extend(new NotificationCompat.CarExtender().setUnreadConversation(unreadConvBuilder.build()))
|
||||
.setCategory(NotificationCompat.CATEGORY_MESSAGE);
|
||||
if (photoPath != null) {
|
||||
BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50");
|
||||
@ -854,9 +873,6 @@ public class NotificationsController {
|
||||
wearNotificationsIds.put(dialog_id, notificationIdWear);
|
||||
}
|
||||
|
||||
for (HashMap.Entry<Long, Integer> entry : oldIdsAuto.entrySet()) {
|
||||
notificationManager.cancel(entry.getValue());
|
||||
}
|
||||
for (HashMap.Entry<Long, Integer> entry : oldIdsWear.entrySet()) {
|
||||
notificationManager.cancel(entry.getValue());
|
||||
}
|
||||
@ -919,6 +935,9 @@ public class NotificationsController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pushMessages.isEmpty() && !popupMessages.isEmpty()) {
|
||||
popupMessages.clear();
|
||||
}
|
||||
}
|
||||
if (dialog_id != 0 && (max_id != 0 || max_date != 0)) {
|
||||
for (int a = 0; a < pushMessages.size(); a++) {
|
||||
@ -952,6 +971,9 @@ public class NotificationsController {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pushMessages.isEmpty() && !popupMessages.isEmpty()) {
|
||||
popupMessages.clear();
|
||||
}
|
||||
}
|
||||
if (oldCount != popupMessages.size()) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated);
|
||||
@ -984,7 +1006,7 @@ public class NotificationsController {
|
||||
}
|
||||
try {
|
||||
if (soundPool == null) {
|
||||
soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 0);
|
||||
soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0);
|
||||
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
|
||||
@Override
|
||||
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
|
||||
@ -994,10 +1016,13 @@ public class NotificationsController {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (soundIn == 0) {
|
||||
if (soundIn == 0 && !soundInLoaded) {
|
||||
soundInLoaded = true;
|
||||
soundIn = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_in, 1);
|
||||
}
|
||||
if (soundIn != 0) {
|
||||
soundPool.play(soundIn, 1.0f, 1.0f, 1, 0, 1.0f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -1028,7 +1053,7 @@ public class NotificationsController {
|
||||
}
|
||||
lastSoundOutPlay = System.currentTimeMillis();
|
||||
if (soundPool == null) {
|
||||
soundPool = new SoundPool(4, AudioManager.STREAM_SYSTEM, 0);
|
||||
soundPool = new SoundPool(2, AudioManager.STREAM_SYSTEM, 0);
|
||||
soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
|
||||
@Override
|
||||
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
|
||||
@ -1038,10 +1063,13 @@ public class NotificationsController {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (soundOut == 0) {
|
||||
if (soundOut == 0 && !soundOutLoaded) {
|
||||
soundOutLoaded = true;
|
||||
soundOut = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1);
|
||||
}
|
||||
if (soundOut != 0) {
|
||||
soundPool.play(soundOut, 1.0f, 1.0f, 1, 0, 1.0f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -1071,7 +1099,8 @@ public class NotificationsController {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
|
||||
int popup = 0;
|
||||
|
||||
for (MessageObject messageObject : messageObjects) {
|
||||
for (int a = 0; a < messageObjects.size(); a++) {
|
||||
MessageObject messageObject = messageObjects.get(a);
|
||||
if (pushMessagesDict.containsKey(messageObject.getId())) {
|
||||
continue;
|
||||
}
|
||||
@ -1175,6 +1204,9 @@ public class NotificationsController {
|
||||
popupMessages.remove(messageObject);
|
||||
}
|
||||
}
|
||||
if (pushMessages.isEmpty() && !popupMessages.isEmpty()) {
|
||||
popupMessages.clear();
|
||||
}
|
||||
} else if (canAddValue) {
|
||||
total_unread_count += newCount;
|
||||
pushDialogs.put(dialog_id, newCount);
|
||||
@ -1190,7 +1222,7 @@ public class NotificationsController {
|
||||
}
|
||||
notifyCheck = false;
|
||||
if (preferences.getBoolean("badgeNumber", true)) {
|
||||
setBadge(ApplicationLoader.applicationContext, total_unread_count);
|
||||
setBadge(total_unread_count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1264,15 +1296,15 @@ public class NotificationsController {
|
||||
showOrUpdateNotification(SystemClock.uptimeMillis() / 1000 < 60);
|
||||
|
||||
if (preferences.getBoolean("badgeNumber", true)) {
|
||||
setBadge(ApplicationLoader.applicationContext, total_unread_count);
|
||||
setBadge(total_unread_count);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBadgeEnabled(boolean enabled) {
|
||||
setBadge(ApplicationLoader.applicationContext, enabled ? total_unread_count : 0);
|
||||
setBadge(enabled ? total_unread_count : 0);
|
||||
}
|
||||
|
||||
private void setBadge(final Context context, final int count) {
|
||||
private void setBadge(final int count) {
|
||||
notificationsQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -1283,14 +1315,14 @@ public class NotificationsController {
|
||||
try {
|
||||
ContentValues cv = new ContentValues();
|
||||
//cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity");
|
||||
cv.put("tag", context.getPackageName() + "/org.telegram.ui.LaunchActivity"); //Plus
|
||||
cv.put("tag", ApplicationLoader.applicationContext.getPackageName() + "/org.telegram.ui.LaunchActivity"); //Plus
|
||||
cv.put("count", count);
|
||||
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
|
||||
ApplicationLoader.applicationContext.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
|
||||
} catch (Throwable e) {
|
||||
//ignore
|
||||
}
|
||||
try {
|
||||
launcherClassName = getLauncherClassName(context);
|
||||
launcherClassName = getLauncherClassName(ApplicationLoader.applicationContext);
|
||||
if (launcherClassName == null) {
|
||||
return;
|
||||
}
|
||||
@ -1300,9 +1332,9 @@ public class NotificationsController {
|
||||
try {
|
||||
Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
|
||||
intent.putExtra("badge_count", count);
|
||||
intent.putExtra("badge_count_package_name", context.getPackageName());
|
||||
intent.putExtra("badge_count_package_name", ApplicationLoader.applicationContext.getPackageName());
|
||||
intent.putExtra("badge_count_class_name", launcherClassName);
|
||||
context.sendBroadcast(intent);
|
||||
ApplicationLoader.applicationContext.sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -1368,7 +1400,7 @@ public class NotificationsController {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user.access_hash != 0) {
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer = new TLRPC.TL_inputPeerForeign();
|
||||
((TLRPC.TL_inputNotifyPeer)req.peer).peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
|
@ -12,9 +12,9 @@ import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
||||
public class ScreenReceiver extends BroadcastReceiver {
|
||||
|
||||
|
@ -19,7 +19,6 @@ import android.provider.MediaStore;
|
||||
import android.webkit.MimeTypeMap;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
@ -29,6 +28,7 @@ import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
@ -449,7 +449,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVenue || messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaGeo) {
|
||||
sendMessage(messageObject.messageOwner.media, did, messageObject.replyMessageObject);
|
||||
} else if (messageObject.messageOwner.media.phone_number != null) {
|
||||
TLRPC.User user = new TLRPC.TL_userContact();
|
||||
TLRPC.User user = new TLRPC.TL_userContact_old2();
|
||||
user.phone = messageObject.messageOwner.media.phone_number;
|
||||
user.first_name = messageObject.messageOwner.media.first_name;
|
||||
user.last_name = messageObject.messageOwner.media.last_name;
|
||||
@ -503,6 +503,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((int) peer == 0) {
|
||||
for (int a = 0; a < document.attributes.size(); a++) {
|
||||
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
|
||||
if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
|
||||
@ -511,6 +512,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, peer, replyingMessageObject);
|
||||
}
|
||||
|
||||
@ -537,7 +539,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
if (sendToUser == null) {
|
||||
return;
|
||||
}
|
||||
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
|
||||
if (sendToUser.access_hash != 0) {
|
||||
sendToPeer = new TLRPC.TL_inputPeerForeign();
|
||||
sendToPeer.user_id = sendToUser.id;
|
||||
sendToPeer.access_hash = sendToUser.access_hash;
|
||||
@ -736,6 +738,15 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
ArrayList<TLRPC.InputUser> sendToPeers = null;
|
||||
if (lower_id == 0) {
|
||||
encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id);
|
||||
if (encryptedChat == null) {
|
||||
if (msgObj != null) {
|
||||
MessagesStorage.getInstance().markMessageAsSendError(msgObj.getId());
|
||||
msgObj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, msgObj.getId());
|
||||
processSentMessage(msgObj.getId());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (retry) {
|
||||
@ -766,7 +777,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
video = (TLRPC.TL_video) newMsg.media.video;
|
||||
}
|
||||
} else if (msgObj.type == 12) {
|
||||
user = new TLRPC.TL_userRequest();
|
||||
user = new TLRPC.TL_userRequest_old2();
|
||||
user.phone = newMsg.media.phone_number;
|
||||
user.first_name = newMsg.media.first_name;
|
||||
user.last_name = newMsg.media.last_name;
|
||||
@ -862,6 +873,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
newMsg.media.first_name = user.first_name;
|
||||
newMsg.media.last_name = user.last_name;
|
||||
newMsg.media.user_id = user.id;
|
||||
if (newMsg.media.first_name == null) {
|
||||
user.first_name = newMsg.media.first_name = "";
|
||||
}
|
||||
if (newMsg.media.last_name == null) {
|
||||
user.last_name = newMsg.media.last_name = "";
|
||||
}
|
||||
newMsg.message = "";
|
||||
type = 6;
|
||||
} else if (document != null) {
|
||||
@ -941,7 +958,10 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
processSentMessage(newMsg.id);
|
||||
return;
|
||||
}
|
||||
if (sendToUser instanceof TLRPC.TL_userForeign || sendToUser instanceof TLRPC.TL_userRequest) {
|
||||
if ((sendToUser.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
newMsg.flags &= ~TLRPC.MESSAGE_FLAG_UNREAD;
|
||||
}
|
||||
if (sendToUser.access_hash != 0) {
|
||||
sendToPeer = new TLRPC.TL_inputPeerForeign();
|
||||
sendToPeer.user_id = sendToUser.id;
|
||||
sendToPeer.access_hash = sendToUser.access_hash;
|
||||
@ -1758,6 +1778,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
sentMessage.attachPath = newMsg.attachPath;
|
||||
}
|
||||
}
|
||||
} else if (sentMessage.media instanceof TLRPC.TL_messageMediaContact && newMsg.media instanceof TLRPC.TL_messageMediaContact) {
|
||||
newMsg.media = sentMessage.media;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2162,16 +2184,31 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
|
||||
return src;
|
||||
}
|
||||
|
||||
public static void prepareSendingText(String text, long dialog_id) {
|
||||
text = getTrimmedString(text);
|
||||
if (text.length() != 0) {
|
||||
int count = (int) Math.ceil(text.length() / 4096.0f);
|
||||
public static void prepareSendingText(final String text, final long dialog_id) {
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String textFinal = getTrimmedString(text);
|
||||
if (textFinal.length() != 0) {
|
||||
int count = (int) Math.ceil(textFinal.length() / 4096.0f);
|
||||
for (int a = 0; a < count; a++) {
|
||||
String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length()));
|
||||
String mess = textFinal.substring(a * 4096, Math.min((a + 1) * 4096, textFinal.length()));
|
||||
SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, null, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void prepareSendingPhotos(ArrayList<String> paths, ArrayList<Uri> uris, final long dialog_id, final MessageObject reply_to_msg, final ArrayList<String> captions) {
|
||||
if (paths == null && uris == null || paths != null && paths.isEmpty() || uris != null && uris.isEmpty()) {
|
||||
|
@ -55,7 +55,10 @@ public class SharedMediaQuery {
|
||||
req.peer.chat_id = -lower_part;
|
||||
} else {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(lower_part);
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
@ -98,7 +101,10 @@ public class SharedMediaQuery {
|
||||
req.peer.chat_id = -lower_part;
|
||||
} else {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(lower_part);
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
|
@ -33,23 +33,31 @@ import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Components.StickersAlert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class StickersQuery {
|
||||
|
||||
private static String hash;
|
||||
private static String loadHash;
|
||||
private static int loadDate;
|
||||
private static ArrayList<TLRPC.Document> stickers = new ArrayList<>();
|
||||
private static HashMap<String, ArrayList<TLRPC.Document>> allStickers = new HashMap<>();
|
||||
private static ArrayList<TLRPC.TL_stickerPack> stickerPacks = new ArrayList<>();
|
||||
private static ArrayList<TLRPC.TL_stickerSet> stickerSets = new ArrayList<>();
|
||||
private static HashMap<Long, ArrayList<TLRPC.Document>> stickersBySets = new HashMap<>();
|
||||
private static ArrayList<TLRPC.TL_messages_stickerSet> stickerSets = new ArrayList<>();
|
||||
private static HashMap<Long, TLRPC.TL_messages_stickerSet> stickerSetsById = new HashMap<>();
|
||||
private static HashMap<Long, String> stickersByEmoji = new HashMap<>();
|
||||
private static HashMap<Long, TLRPC.Document> stickersById = new HashMap<>();
|
||||
private static HashMap<String, ArrayList<TLRPC.Document>> allStickers = new HashMap<>();
|
||||
|
||||
private static boolean loadingStickers;
|
||||
private static boolean stickersLoaded;
|
||||
private static boolean hideMainStickersPack;
|
||||
|
||||
public static void cleanup() {
|
||||
loadHash = null;
|
||||
loadDate = 0;
|
||||
allStickers.clear();
|
||||
stickerSets.clear();
|
||||
stickersByEmoji.clear();
|
||||
stickerSetsById.clear();
|
||||
loadingStickers = false;
|
||||
stickersLoaded = false;
|
||||
}
|
||||
|
||||
public static void checkStickers() {
|
||||
if (!loadingStickers && (!stickersLoaded || loadDate < (System.currentTimeMillis() / 1000 - 60 * 60))) {
|
||||
@ -61,28 +69,28 @@ public class StickersQuery {
|
||||
return loadingStickers;
|
||||
}
|
||||
|
||||
public static TLRPC.Document getStickerById(long id) {
|
||||
TLRPC.Document document = stickersById.get(id);
|
||||
if (document != null) {
|
||||
long setId = getStickerSetId(document);
|
||||
TLRPC.TL_messages_stickerSet stickerSet = stickerSetsById.get(setId);
|
||||
if (stickerSet != null && (stickerSet.set.flags & 2) != 0) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return document;
|
||||
}
|
||||
|
||||
public static HashMap<String, ArrayList<TLRPC.Document>> getAllStickers() {
|
||||
return allStickers;
|
||||
}
|
||||
|
||||
public static ArrayList<TLRPC.Document> getStickersForSet(long id) {
|
||||
return stickersBySets.get(id);
|
||||
}
|
||||
|
||||
public static ArrayList<TLRPC.TL_stickerPack> getStickerPacks() {
|
||||
return stickerPacks;
|
||||
}
|
||||
|
||||
public static ArrayList<TLRPC.Document> getStickers() {
|
||||
return stickers;
|
||||
}
|
||||
|
||||
public static ArrayList<TLRPC.TL_stickerSet> getStickerSets() {
|
||||
public static ArrayList<TLRPC.TL_messages_stickerSet> getStickerSets() {
|
||||
return stickerSets;
|
||||
}
|
||||
|
||||
public static boolean isStickerPackInstalled(long id) {
|
||||
return stickersBySets.containsKey(id);
|
||||
return stickerSetsById.containsKey(id);
|
||||
}
|
||||
|
||||
public static String getEmojiForSticker(long id) {
|
||||
@ -99,43 +107,91 @@ public class StickersQuery {
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.messages_AllStickers result = null;
|
||||
ArrayList<TLRPC.TL_messages_stickerSet> newStickerArray = null;
|
||||
int date = 0;
|
||||
String hash = null;
|
||||
try {
|
||||
SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT value FROM keyvalue WHERE id = 'hide_stickers'");
|
||||
if (cursor.next()) {
|
||||
int value = Utilities.parseInt(cursor.stringValue(0));
|
||||
hideMainStickersPack = value == 1;
|
||||
}
|
||||
cursor.dispose();
|
||||
|
||||
cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT data, date FROM stickers WHERE 1");
|
||||
ArrayList<TLRPC.User> loadedUsers = new ArrayList<>();
|
||||
SQLiteCursor cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT data, date, hash FROM stickers_v2 WHERE 1");
|
||||
if (cursor.next()) {
|
||||
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(cursor.byteArrayLength(0));
|
||||
if (data != null && cursor.byteBufferValue(0, data.buffer) != 0) {
|
||||
result = TLRPC.messages_AllStickers.TLdeserialize(data, data.readInt32(false), false);
|
||||
if (newStickerArray == null) {
|
||||
newStickerArray = new ArrayList<>();
|
||||
}
|
||||
int count = data.readInt32(false);
|
||||
for (int a = 0; a < count; a++) {
|
||||
TLRPC.TL_messages_stickerSet stickerSet = TLRPC.TL_messages_stickerSet.TLdeserialize(data, data.readInt32(false), false);
|
||||
newStickerArray.add(stickerSet);
|
||||
}
|
||||
}
|
||||
date = cursor.intValue(1);
|
||||
hash = cursor.stringValue(2);
|
||||
MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data);
|
||||
}
|
||||
cursor.dispose();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
processLoadedStickers(result, true, date);
|
||||
processLoadedStickers(newStickerArray, true, date, hash);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
TLRPC.TL_messages_getAllStickers req = new TLRPC.TL_messages_getAllStickers();
|
||||
req.hash = hash == null || force ? "" : hash;
|
||||
req.hash = loadHash == null || force ? "" : loadHash;
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
processLoadedStickers((TLRPC.messages_AllStickers) response, false, (int) (System.currentTimeMillis() / 1000));
|
||||
if (response instanceof TLRPC.TL_messages_allStickers) {
|
||||
final HashMap<Long, TLRPC.TL_messages_stickerSet> newStickerSets = new HashMap<>();
|
||||
final ArrayList<TLRPC.TL_messages_stickerSet> newStickerArray = new ArrayList<>();
|
||||
final TLRPC.TL_messages_allStickers res = (TLRPC.TL_messages_allStickers) response;
|
||||
|
||||
for (int a = 0; a < res.sets.size(); a++) {
|
||||
final TLRPC.StickerSet stickerSet = res.sets.get(a);
|
||||
|
||||
TLRPC.TL_messages_stickerSet oldSet = stickerSetsById.get(stickerSet.id);
|
||||
if (oldSet != null && oldSet.set.hash == stickerSet.hash) {
|
||||
oldSet.set.flags = stickerSet.flags;
|
||||
newStickerSets.put(oldSet.set.id, oldSet);
|
||||
newStickerArray.add(oldSet);
|
||||
|
||||
if (newStickerSets.size() == res.sets.size()) {
|
||||
processLoadedStickers(newStickerArray, false, (int) (System.currentTimeMillis() / 1000), res.hash);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
newStickerArray.add(null);
|
||||
final int index = a;
|
||||
|
||||
TLRPC.TL_messages_getStickerSet req = new TLRPC.TL_messages_getStickerSet();
|
||||
req.stickerset = new TLRPC.TL_inputStickerSetID();
|
||||
req.stickerset.id = stickerSet.id;
|
||||
req.stickerset.access_hash = stickerSet.access_hash;
|
||||
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(final TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
TLRPC.TL_messages_stickerSet res1 = (TLRPC.TL_messages_stickerSet) response;
|
||||
newStickerArray.set(index, res1);
|
||||
newStickerSets.put(stickerSet.id, res1);
|
||||
if (newStickerSets.size() == res.sets.size()) {
|
||||
processLoadedStickers(newStickerArray, false, (int) (System.currentTimeMillis() / 1000), res.hash);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
processLoadedStickers(null, false, (int) (System.currentTimeMillis() / 1000), error == null ? "" : null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -143,18 +199,26 @@ public class StickersQuery {
|
||||
}
|
||||
}
|
||||
|
||||
private static void putStickersToCache(final TLRPC.TL_messages_allStickers stickers) {
|
||||
private static void putStickersToCache(final ArrayList<TLRPC.TL_messages_stickerSet> stickers, final int date, final String hash) {
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
SQLitePreparedStatement state = MessagesStorage.getInstance().getDatabase().executeFast("REPLACE INTO stickers VALUES(?, ?, ?)");
|
||||
SQLitePreparedStatement state = MessagesStorage.getInstance().getDatabase().executeFast("REPLACE INTO stickers_v2 VALUES(?, ?, ?, ?)");
|
||||
state.requery();
|
||||
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(stickers.getObjectSize());
|
||||
stickers.serializeToStream(data);
|
||||
int size = 4;
|
||||
for (int a = 0; a < stickers.size(); a++) {
|
||||
size += stickers.get(a).getObjectSize();
|
||||
}
|
||||
ByteBufferDesc data = MessagesStorage.getInstance().getBuffersStorage().getFreeBuffer(size);
|
||||
data.writeInt32(stickers.size());
|
||||
for (int a = 0; a < stickers.size(); a++) {
|
||||
stickers.get(a).serializeToStream(data);
|
||||
}
|
||||
state.bindInteger(1, 1);
|
||||
state.bindByteBuffer(2, data.buffer);
|
||||
state.bindInteger(3, (int) (System.currentTimeMillis() / 1000));
|
||||
state.bindInteger(3, date);
|
||||
state.bindString(4, hash);
|
||||
state.step();
|
||||
MessagesStorage.getInstance().getBuffersStorage().reuseFreeBuffer(data);
|
||||
state.dispose();
|
||||
@ -177,7 +241,7 @@ public class StickersQuery {
|
||||
return -1;
|
||||
}
|
||||
|
||||
private static void processLoadedStickers(final TLRPC.messages_AllStickers res, final boolean cache, final int date) {
|
||||
private static void processLoadedStickers(final ArrayList<TLRPC.TL_messages_stickerSet> res, final boolean cache, final int date, final String hash) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -188,104 +252,77 @@ public class StickersQuery {
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if ((res == null || date < (int) (System.currentTimeMillis() / 1000 - 60 * 60)) && cache) {
|
||||
if (cache && (res == null || date < (int) (System.currentTimeMillis() / 1000 - 60 * 60)) || !cache && res == null && hash == null) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (res != null && cache && hash != null) {
|
||||
loadHash = hash;
|
||||
}
|
||||
loadStickers(false, false);
|
||||
}
|
||||
});
|
||||
}, res == null && !cache ? 1000 : 0);
|
||||
if (res == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (res instanceof TLRPC.TL_messages_allStickers) {
|
||||
HashMap<Long, TLRPC.Document> documents = new HashMap<>();
|
||||
final HashMap<Long, ArrayList<TLRPC.Document>> sets = new HashMap<>();
|
||||
final ArrayList<TLRPC.Document> allDocuments = new ArrayList<>();
|
||||
final HashMap<Long, String> stickersEmoji = new HashMap<>();
|
||||
for (TLRPC.Document document : res.documents) {
|
||||
if (document == null) {
|
||||
if (res != null) {
|
||||
final ArrayList<TLRPC.TL_messages_stickerSet> stickerSetsNew = new ArrayList<>();
|
||||
final HashMap<Long, TLRPC.TL_messages_stickerSet> stickerSetsByIdNew = new HashMap<>();
|
||||
final HashMap<Long, String> stickersByEmojiNew = new HashMap<>();
|
||||
final HashMap<Long, TLRPC.Document> stickersByIdNew = new HashMap<>();
|
||||
final HashMap<String, ArrayList<TLRPC.Document>> allStickersNew = new HashMap<>();
|
||||
|
||||
for (int a = 0; a < res.size(); a++) {
|
||||
TLRPC.TL_messages_stickerSet stickerSet = res.get(a);
|
||||
if (stickerSet == null) {
|
||||
continue;
|
||||
}
|
||||
stickerSetsNew.add(stickerSet);
|
||||
stickerSetsByIdNew.put(stickerSet.set.id, stickerSet);
|
||||
|
||||
documents.put(document.id, document);
|
||||
long setId = getStickerSetId(document);
|
||||
if (setId != -1 || setId == -1 && !hideMainStickersPack) {
|
||||
allDocuments.add(document);
|
||||
for (int b = 0; b < stickerSet.documents.size(); b++) {
|
||||
TLRPC.Document document = stickerSet.documents.get(b);
|
||||
if (document == null || document instanceof TLRPC.TL_documentEmpty) {
|
||||
continue;
|
||||
}
|
||||
ArrayList<TLRPC.Document> docs = sets.get(setId);
|
||||
if (docs == null) {
|
||||
docs = new ArrayList<>();
|
||||
sets.put(setId, docs);
|
||||
if (setId == -1) {
|
||||
boolean contain = false;
|
||||
for (TLRPC.TL_stickerSet set : res.sets) {
|
||||
if (set.id == setId) {
|
||||
contain = true;
|
||||
break;
|
||||
stickersByIdNew.put(document.id, document);
|
||||
}
|
||||
if ((stickerSet.set.flags & 2) == 0) {
|
||||
for (int b = 0; b < stickerSet.packs.size(); b++) {
|
||||
TLRPC.TL_stickerPack stickerPack = stickerSet.packs.get(b);
|
||||
if (stickerPack == null || stickerPack.emoticon == null) {
|
||||
continue;
|
||||
}
|
||||
if (!contain) {
|
||||
TLRPC.TL_stickerSet set = new TLRPC.TL_stickerSet();
|
||||
set.title = set.short_name = "";
|
||||
set.id = -1;
|
||||
res.sets.add(0, set);
|
||||
}
|
||||
}
|
||||
}
|
||||
docs.add(document);
|
||||
}
|
||||
final HashMap<String, ArrayList<TLRPC.Document>> result = new HashMap<>();
|
||||
for (TLRPC.TL_stickerPack stickerPack : res.packs) {
|
||||
if (stickerPack != null && stickerPack.emoticon != null) {
|
||||
stickerPack.emoticon = stickerPack.emoticon.replace("\uFE0F", "");
|
||||
ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon);
|
||||
for (Long id : stickerPack.documents) {
|
||||
if (!stickersEmoji.containsKey(id)) {
|
||||
stickersEmoji.put(id, stickerPack.emoticon);
|
||||
}
|
||||
TLRPC.Document document = documents.get(id);
|
||||
if (document != null) {
|
||||
long setId = getStickerSetId(document);
|
||||
if (setId == -1 && hideMainStickersPack) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<TLRPC.Document> arrayList = allStickersNew.get(stickerPack.emoticon);
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList<>();
|
||||
result.put(stickerPack.emoticon, arrayList);
|
||||
allStickersNew.put(stickerPack.emoticon, arrayList);
|
||||
}
|
||||
arrayList.add(document);
|
||||
for (int c = 0; c < stickerPack.documents.size(); c++) {
|
||||
Long id = stickerPack.documents.get(c);
|
||||
if (!stickersByEmojiNew.containsKey(id)) {
|
||||
stickersByEmojiNew.put(id, stickerPack.emoticon);
|
||||
}
|
||||
arrayList.add(stickersByIdNew.get(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(allDocuments, new Comparator<TLRPC.Document>() {
|
||||
@Override
|
||||
public int compare(TLRPC.Document lhs, TLRPC.Document rhs) {
|
||||
long lid = getStickerSetId(lhs);
|
||||
long rid = getStickerSetId(rhs);
|
||||
if (lid < rid) {
|
||||
return -1;
|
||||
} else if (lid > rid) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
if (!cache) {
|
||||
putStickersToCache((TLRPC.TL_messages_allStickers) res);
|
||||
putStickersToCache(stickerSetsNew, date, hash);
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
stickerSets = res.sets;
|
||||
allStickers = result;
|
||||
stickers = allDocuments;
|
||||
stickersBySets = sets;
|
||||
stickersByEmoji = stickersEmoji;
|
||||
hash = res.hash;
|
||||
stickersById = stickersByIdNew;
|
||||
stickerSetsById = stickerSetsByIdNew;
|
||||
stickerSets = stickerSetsNew;
|
||||
allStickers = allStickersNew;
|
||||
stickersByEmoji = stickersByEmojiNew;
|
||||
loadHash = hash;
|
||||
loadDate = date;
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.stickersDidLoaded);
|
||||
}
|
||||
@ -323,7 +360,7 @@ public class StickersQuery {
|
||||
if (error == null) {
|
||||
final TLRPC.TL_messages_stickerSet res = (TLRPC.TL_messages_stickerSet) response;
|
||||
|
||||
StickersAlert alert = new StickersAlert(fragment.getParentActivity(), res.set, res.documents);
|
||||
StickersAlert alert = new StickersAlert(fragment.getParentActivity(), res);
|
||||
if (res.set == null || !StickersQuery.isStickerPackInstalled(res.set.id)) {
|
||||
alert.setButton(AlertDialog.BUTTON_POSITIVE, LocaleController.getString("AddStickers", R.string.AddStickers), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
@ -354,7 +391,7 @@ public class StickersQuery {
|
||||
alert.setButton(AlertDialog.BUTTON_NEUTRAL, LocaleController.getString("StickersRemove", R.string.StickersRemove), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
removeStickersSet(fragment.getParentActivity(), res.set);
|
||||
removeStickersSet(fragment.getParentActivity(), res.set, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -385,30 +422,34 @@ public class StickersQuery {
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
public static void setHideMainStickersPack(final boolean value) {
|
||||
hideMainStickersPack = value;
|
||||
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
|
||||
public static void removeStickersSet(final Context context, TLRPC.StickerSet stickerSet, int hide) {
|
||||
TLRPC.TL_inputStickerSetID stickerSetID = new TLRPC.TL_inputStickerSetID();
|
||||
stickerSetID.access_hash = stickerSet.access_hash;
|
||||
stickerSetID.id = stickerSet.id;
|
||||
if (hide != 0) {
|
||||
if (hide == 1) {
|
||||
stickerSet.flags |= 2;
|
||||
} else {
|
||||
stickerSet.flags &= ~2;
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.stickersDidLoaded);
|
||||
TLRPC.TL_messages_installStickerSet req = new TLRPC.TL_messages_installStickerSet();
|
||||
req.stickerset = stickerSetID;
|
||||
req.disabled = hide == 1;
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, final TLRPC.TL_error error) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
SQLitePreparedStatement state = MessagesStorage.getInstance().getDatabase().executeFast("REPLACE INTO keyvalue VALUES(?, ?)");
|
||||
state.requery();
|
||||
state.bindString(1, "hide_stickers");
|
||||
state.bindString(2, value ? "1" : "0");
|
||||
state.step();
|
||||
state.dispose();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
loadStickers(false, true);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void removeStickersSet(final Context context, TLRPC.TL_stickerSet stickerSet) {
|
||||
} else {
|
||||
TLRPC.TL_messages_uninstallStickerSet req = new TLRPC.TL_messages_uninstallStickerSet();
|
||||
req.stickerset = new TLRPC.TL_inputStickerSetID();
|
||||
req.stickerset.access_hash = stickerSet.access_hash;
|
||||
req.stickerset.id = stickerSet.id;
|
||||
req.stickerset = stickerSetID;
|
||||
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
||||
@Override
|
||||
public void run(TLObject response, final TLRPC.TL_error error) {
|
||||
@ -430,8 +471,5 @@ public class StickersQuery {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean getHideMainStickersPack() {
|
||||
return hideMainStickersPack;
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
|
||||
import android.support.v4.view.accessibility.AccessibilityRecordCompat;
|
||||
import android.support.v4.widget.EdgeEffectCompat;
|
||||
import android.support.v4.widget.ScrollerCompat;
|
||||
import static org.telegram.android.support.widget.AdapterHelper.UpdateOp;
|
||||
import static org.telegram.android.support.widget.AdapterHelper.Callback;
|
||||
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
@ -55,13 +58,12 @@ import android.view.accessibility.AccessibilityEvent;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.telegram.android.support.widget.AdapterHelper.Callback;
|
||||
import static org.telegram.android.support.widget.AdapterHelper.UpdateOp;
|
||||
|
||||
/**
|
||||
* A flexible view for providing a limited window into a large data set.
|
||||
*
|
||||
@ -5028,7 +5030,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
* @see #notifyItemRangeInserted(int, int)
|
||||
* @see #notifyItemRangeRemoved(int, int)
|
||||
*/
|
||||
public final void notifyDataSetChanged() {
|
||||
public void notifyDataSetChanged() {
|
||||
mObservable.notifyChanged();
|
||||
}
|
||||
|
||||
@ -5043,7 +5045,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
*
|
||||
* @see #notifyItemRangeChanged(int, int)
|
||||
*/
|
||||
public final void notifyItemChanged(int position) {
|
||||
public void notifyItemChanged(int position) {
|
||||
mObservable.notifyItemRangeChanged(position, 1);
|
||||
}
|
||||
|
||||
@ -5060,7 +5062,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
*
|
||||
* @see #notifyItemChanged(int)
|
||||
*/
|
||||
public final void notifyItemRangeChanged(int positionStart, int itemCount) {
|
||||
public void notifyItemRangeChanged(int positionStart, int itemCount) {
|
||||
mObservable.notifyItemRangeChanged(positionStart, itemCount);
|
||||
}
|
||||
|
||||
@ -5077,7 +5079,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
*
|
||||
* @see #notifyItemRangeInserted(int, int)
|
||||
*/
|
||||
public final void notifyItemInserted(int position) {
|
||||
public void notifyItemInserted(int position) {
|
||||
mObservable.notifyItemRangeInserted(position, 1);
|
||||
}
|
||||
|
||||
@ -5092,7 +5094,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
* @param fromPosition Previous position of the item.
|
||||
* @param toPosition New position of the item.
|
||||
*/
|
||||
public final void notifyItemMoved(int fromPosition, int toPosition) {
|
||||
public void notifyItemMoved(int fromPosition, int toPosition) {
|
||||
mObservable.notifyItemMoved(fromPosition, toPosition);
|
||||
}
|
||||
|
||||
@ -5111,7 +5113,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
*
|
||||
* @see #notifyItemInserted(int)
|
||||
*/
|
||||
public final void notifyItemRangeInserted(int positionStart, int itemCount) {
|
||||
public void notifyItemRangeInserted(int positionStart, int itemCount) {
|
||||
mObservable.notifyItemRangeInserted(positionStart, itemCount);
|
||||
}
|
||||
|
||||
@ -5128,7 +5130,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
*
|
||||
* @see #notifyItemRangeRemoved(int, int)
|
||||
*/
|
||||
public final void notifyItemRemoved(int position) {
|
||||
public void notifyItemRemoved(int position) {
|
||||
mObservable.notifyItemRangeRemoved(position, 1);
|
||||
}
|
||||
|
||||
@ -5145,7 +5147,7 @@ public class RecyclerView extends ViewGroup implements ScrollingView {
|
||||
* @param positionStart Previous position of the first item that was removed
|
||||
* @param itemCount Number of items removed from the data set
|
||||
*/
|
||||
public final void notifyItemRangeRemoved(int positionStart, int itemCount) {
|
||||
public void notifyItemRangeRemoved(int positionStart, int itemCount) {
|
||||
mObservable.notifyItemRangeRemoved(positionStart, itemCount);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ import com.google.android.gms.gcm.GoogleCloudMessaging;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.NotificationsService;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NativeLoader;
|
||||
import org.telegram.android.NotificationsService;
|
||||
import org.telegram.android.ScreenReceiver;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.ui.Components.ForegroundDetector;
|
||||
|
||||
import java.io.File;
|
||||
@ -66,6 +66,7 @@ public class ApplicationLoader extends Application {
|
||||
|
||||
public static boolean SHOW_ANDROID_EMOJI;
|
||||
public static boolean KEEP_ORIGINAL_FILENAME;
|
||||
public static boolean USE_DEVICE_FONT;
|
||||
|
||||
public static boolean isCustomTheme() {
|
||||
return isCustomTheme;
|
||||
@ -205,6 +206,7 @@ public class ApplicationLoader extends Application {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SHOW_ANDROID_EMOJI = preferences.getBoolean("showAndroidEmoji", false);
|
||||
KEEP_ORIGINAL_FILENAME = preferences.getBoolean("keepOriginalFilename", false);
|
||||
USE_DEVICE_FONT = preferences.getBoolean("useDeviceFont", false);
|
||||
//
|
||||
startPushService();
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import java.net.NetworkInterface;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Matcher;
|
||||
@ -132,7 +133,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (lastPauseTime != 0 && lastPauseTime < currentTime - nextSleepTimeout) {
|
||||
boolean dontSleep = !pushMessagesReceived;
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
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)) {
|
||||
@ -142,7 +144,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
}
|
||||
if (!dontSleep) {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
for (int a = 0; a < requestQueue.size(); a++) {
|
||||
RPCRequest request = requestQueue.get(a);
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
dontSleep = true;
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) != 0 || (request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
@ -190,7 +193,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
processRequestQueue(0, 0);
|
||||
} else {
|
||||
boolean notFound = true;
|
||||
for (Action actor : actionQueue) {
|
||||
for (int a = 0; a < actionQueue.size(); a++) {
|
||||
Action actor = actionQueue.get(a);
|
||||
if (actor instanceof HandshakeAction) {
|
||||
HandshakeAction eactor = (HandshakeAction) actor;
|
||||
if (eactor.datacenter.datacenterId == datacenter.datacenterId) {
|
||||
@ -536,7 +540,9 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
continue;
|
||||
}
|
||||
FileLog.e("tmessages", "valid interface: " + networkInterface);
|
||||
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
|
||||
List<InterfaceAddress> interfaceAddresses = networkInterface.getInterfaceAddresses();
|
||||
for (int a = 0; a < interfaceAddresses.size(); a++) {
|
||||
InterfaceAddress address = interfaceAddresses.get(a);
|
||||
InetAddress inetAddress = address.getAddress();
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
FileLog.e("tmessages", "address: " + inetAddress.getHostAddress());
|
||||
@ -553,20 +559,22 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 50) {
|
||||
if (Build.VERSION.SDK_INT < 19) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
NetworkInterface networkInterface;
|
||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
boolean hasIpv4 = false;
|
||||
boolean hasIpv6 = false;
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
networkInterface = networkInterfaces.nextElement();
|
||||
if (!networkInterface.isUp() || networkInterface.isLoopback()) {
|
||||
continue;
|
||||
}
|
||||
boolean hasIpv4 = false;
|
||||
boolean hasIpv6 = false;
|
||||
for (InterfaceAddress address : networkInterface.getInterfaceAddresses()) {
|
||||
List<InterfaceAddress> interfaceAddresses = networkInterface.getInterfaceAddresses();
|
||||
for (int a = 0; a < interfaceAddresses.size(); a++) {
|
||||
InterfaceAddress address = interfaceAddresses.get(a);
|
||||
InetAddress inetAddress = address.getAddress();
|
||||
if (inetAddress.isLinkLocalAddress() || inetAddress.isLoopbackAddress() || inetAddress.isMulticastAddress()) {
|
||||
continue;
|
||||
@ -574,13 +582,16 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (inetAddress instanceof Inet6Address) {
|
||||
hasIpv6 = true;
|
||||
} else if (inetAddress instanceof Inet4Address) {
|
||||
String addrr = inetAddress.getHostAddress();
|
||||
if (!addrr.startsWith("192.0.0.")) {
|
||||
hasIpv4 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasIpv4 && hasIpv6) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
@ -609,8 +620,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (!sessions.isEmpty()) {
|
||||
SerializedData data = new SerializedData(sessions.size() * 8 + 4);
|
||||
data.writeInt32(sessions.size());
|
||||
for (long session : sessions) {
|
||||
data.writeInt64(session);
|
||||
for (int a = 0; a < sessions.size(); a++) {
|
||||
data.writeInt64(sessions.get(a));
|
||||
}
|
||||
editor.putString("sessionsToDestroy", Base64.encodeToString(data.toByteArray(), Base64.DEFAULT));
|
||||
data.cleanup();
|
||||
@ -648,7 +659,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
|
||||
void clearRequestsForRequestClass(int requestClass, Datacenter datacenter) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
Datacenter dcenter = datacenterWithId(request.runningDatacenterId);
|
||||
if ((request.flags & requestClass) != 0 && dcenter != null && dcenter.datacenterId == datacenter.datacenterId) {
|
||||
request.runningMessageId = 0;
|
||||
@ -736,7 +748,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
public void cancelRpcsForClassGuid(int guid) {
|
||||
ArrayList<Long> requests = requestsByGuids.get(guid);
|
||||
if (requests != null) {
|
||||
for (Long request : requests) {
|
||||
for (int a = 0; a < requests.size(); a++) {
|
||||
Long request = requests.get(a);
|
||||
cancelRpc(request, true);
|
||||
}
|
||||
requestsByGuids.remove(guid);
|
||||
@ -858,7 +871,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
lastDcUpdateTime = (int) (System.currentTimeMillis() / 1000) - DC_UPDATE_TIME + updateIn;
|
||||
ArrayList<Datacenter> datacentersArr = new ArrayList<>();
|
||||
HashMap<Integer, Datacenter> datacenterMap = new HashMap<>();
|
||||
for (TLRPC.TL_dcOption datacenterDesc : config.dc_options) {
|
||||
for (int a = 0; a < config.dc_options.size(); a++) {
|
||||
TLRPC.TL_dcOption datacenterDesc = config.dc_options.get(a);
|
||||
Datacenter existing = datacenterMap.get(datacenterDesc.id);
|
||||
if (existing == null) {
|
||||
existing = new Datacenter();
|
||||
@ -870,7 +884,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
|
||||
if (!datacentersArr.isEmpty()) {
|
||||
for (Datacenter datacenter : datacentersArr) {
|
||||
for (int a = 0; a < datacentersArr.size(); a++) {
|
||||
Datacenter datacenter = datacentersArr.get(a);
|
||||
Datacenter exist = datacenterWithId(datacenter.datacenterId);
|
||||
if (exist == null) {
|
||||
datacenters.put(datacenter.datacenterId, datacenter);
|
||||
@ -1281,7 +1296,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (genericConnection != null && genericConnection.channelToken != 0) {
|
||||
Datacenter currentDatacenter = datacenterWithId(currentDatacenterId);
|
||||
|
||||
for (Long it : sessionsToDestroy) {
|
||||
for (int a = 0; a < sessionsToDestroy.size(); a++) {
|
||||
Long it = sessionsToDestroy.get(a);
|
||||
if (destroyingSessions.contains(it)) {
|
||||
continue;
|
||||
}
|
||||
@ -1304,7 +1320,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
int uploadRunningRequestCount = 0;
|
||||
int downloadRunningRequestCount = 0;
|
||||
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
|
||||
genericRunningRequestCount++;
|
||||
} else if ((request.flags & RPCRequest.RPCRequestClassUploadMedia) != 0) {
|
||||
@ -1481,7 +1498,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
|
||||
boolean hasSendMessage = false;
|
||||
ArrayList<NetworkMessage> arr = genericMessagesToDatacenters.get(iter);
|
||||
for (NetworkMessage networkMessage : arr) {
|
||||
for (int b = 0; b < arr.size(); b++) {
|
||||
NetworkMessage networkMessage = arr.get(b);
|
||||
TLRPC.TL_protoMessage message = networkMessage.protoMessage;
|
||||
|
||||
Object rawRequest = networkMessage.rawRequest;
|
||||
@ -1502,7 +1520,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
scannedPreviousRequests = true;
|
||||
|
||||
ArrayList<Long> currentRequests = new ArrayList<>();
|
||||
for (NetworkMessage currentNetworkMessage : arr) {
|
||||
for (int a = 0; a < arr.size(); a++) {
|
||||
NetworkMessage currentNetworkMessage = arr.get(a);
|
||||
TLRPC.TL_protoMessage currentMessage = currentNetworkMessage.protoMessage;
|
||||
|
||||
Object currentRawRequest = currentNetworkMessage.rawRequest;
|
||||
@ -1519,7 +1538,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
|
||||
long maxRequestId = 0;
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (request.rawRequest instanceof TLRPC.TL_messages_sendMessage ||
|
||||
request.rawRequest instanceof TLRPC.TL_messages_sendMedia ||
|
||||
request.rawRequest instanceof TLRPC.TL_messages_forwardMessages ||
|
||||
@ -1564,10 +1584,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
updateDcSettings(0);
|
||||
}
|
||||
|
||||
for (int num : neededDatacenterIds) {
|
||||
for (int a = 0; a < neededDatacenterIds.size(); a++) {
|
||||
int num = neededDatacenterIds.get(a);
|
||||
if (num != movingToDatacenterId) {
|
||||
boolean notFound = true;
|
||||
for (Action actor : actionQueue) {
|
||||
for (int b = 0; b < actionQueue.size(); b++) {
|
||||
Action actor = actionQueue.get(b);
|
||||
if (actor instanceof HandshakeAction) {
|
||||
HandshakeAction eactor = (HandshakeAction) actor;
|
||||
if (eactor.datacenter.datacenterId == num) {
|
||||
@ -1584,10 +1606,12 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
}
|
||||
|
||||
for (int num : unauthorizedDatacenterIds) {
|
||||
for (int a = 0; a < unauthorizedDatacenterIds.size(); a++) {
|
||||
int num = unauthorizedDatacenterIds.get(a);
|
||||
if (num != currentDatacenterId && num != movingToDatacenterId && UserConfig.isClientActivated()) {
|
||||
boolean notFound = true;
|
||||
for (Action actor : actionQueue) {
|
||||
for (int b = 0; b < actionQueue.size(); b++) {
|
||||
Action actor = actionQueue.get(b);
|
||||
if (actor instanceof ExportAuthorizationAction) {
|
||||
ExportAuthorizationAction eactor = (ExportAuthorizationAction) actor;
|
||||
if (eactor.datacenter.datacenterId == num) {
|
||||
@ -1677,7 +1701,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (reportAck && quickAckId.size() != 0) {
|
||||
ArrayList<Long> requestIds = new ArrayList<>();
|
||||
|
||||
for (NetworkMessage message : messagesToSend) {
|
||||
for (int b = 0; b < messagesToSend.size(); b++) {
|
||||
NetworkMessage message = messagesToSend.get(b);
|
||||
if (message.requestId != 0) {
|
||||
requestIds.add(message.requestId);
|
||||
}
|
||||
@ -1756,7 +1781,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
|
||||
ArrayList<TLRPC.TL_protoMessage> containerMessages = new ArrayList<>(messages.size());
|
||||
|
||||
for (NetworkMessage networkMessage : messages) {
|
||||
for (int a = 0; a < messages.size(); a++) {
|
||||
NetworkMessage networkMessage = messages.get(a);
|
||||
TLRPC.TL_protoMessage message = networkMessage.protoMessage;
|
||||
containerMessages.add(message);
|
||||
if (BuildVars.DEBUG_VERSION) {
|
||||
@ -1841,7 +1867,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RPCRequest request : requestQueue) {
|
||||
for (int a = 0; a < requestQueue.size(); a++) {
|
||||
RPCRequest request = requestQueue.get(a);
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId);
|
||||
if (requestDatacenter.datacenterId == datacenter.datacenterId) {
|
||||
@ -1850,7 +1877,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
}
|
||||
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (request.rawRequest instanceof TLRPC.TL_get_future_salts) {
|
||||
Datacenter requestDatacenter = datacenterWithId(request.runningDatacenterId);
|
||||
if (requestDatacenter.datacenterId == datacenter.datacenterId) {
|
||||
@ -1881,7 +1909,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (requestMsgId == request.runningMessageId) {
|
||||
request.confirmed = true;
|
||||
}
|
||||
@ -1991,7 +2020,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
serverSaltDesc.value = serverSalt;
|
||||
datacenter.addServerSalt(serverSaltDesc);
|
||||
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
Datacenter dcenter = datacenterWithId(request.runningDatacenterId);
|
||||
if (request.runningMessageId < newSession.first_msg_id && (request.flags & connection.transportRequestClass) != 0 && dcenter != null && dcenter.datacenterId == datacenter.datacenterId) {
|
||||
request.runningMessageId = 0;
|
||||
@ -2021,7 +2051,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}*/
|
||||
|
||||
TLRPC.TL_msg_container messageContainer = (TLRPC.TL_msg_container) message;
|
||||
for (TLRPC.TL_protoMessage innerMessage : messageContainer.messages) {
|
||||
for (int a = 0; a < messageContainer.messages.size(); a++) {
|
||||
TLRPC.TL_protoMessage innerMessage = messageContainer.messages.get(a);
|
||||
long innerMessageId = innerMessage.msg_id;
|
||||
if (innerMessage.seqno % 2 != 0) {
|
||||
connection.addMessageToConfirm(innerMessageId);
|
||||
@ -2060,8 +2091,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
itemsToDelete.add(pid);
|
||||
}
|
||||
}
|
||||
for (Long pid : itemsToDelete) {
|
||||
pingIdToDate.remove(pid);
|
||||
for (int a = 0; a < itemsToDelete.size(); a++) {
|
||||
pingIdToDate.remove(itemsToDelete.get(a));
|
||||
}
|
||||
} else {
|
||||
FileLog.e("tmessages", "received push ping");
|
||||
@ -2070,7 +2101,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
} else if (message instanceof TLRPC.TL_futuresalts) {
|
||||
TLRPC.TL_futuresalts futureSalts = (TLRPC.TL_futuresalts) message;
|
||||
long requestMid = futureSalts.req_msg_id;
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (request.respondsToMessageId(requestMid)) {
|
||||
if (request.completionBlock != null) {
|
||||
request.completionBlock.run(futureSalts, null);
|
||||
@ -2090,7 +2122,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
ArrayList<Long> lst = new ArrayList<>();
|
||||
lst.addAll(sessionsToDestroy);
|
||||
destroyingSessions.remove(res.session_id);
|
||||
for (long session : lst) {
|
||||
for (int a = 0; a < lst.size(); a++) {
|
||||
long session = lst.get(a);
|
||||
if (session == res.session_id) {
|
||||
sessionsToDestroy.remove(session);
|
||||
FileLog.d("tmessages", String.format("Destroyed session %d (%s)", res.session_id, res instanceof TLRPC.TL_destroy_session_ok ? "ok" : "not found"));
|
||||
@ -2114,7 +2147,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
migrateErrors.add("NETWORK_MIGRATE_");
|
||||
migrateErrors.add("PHONE_MIGRATE_");
|
||||
migrateErrors.add("USER_MIGRATE_");
|
||||
for (String possibleError : migrateErrors) {
|
||||
for (int a = 0; a < migrateErrors.size(); a++) {
|
||||
String possibleError = migrateErrors.get(a);
|
||||
if (errorMessage.contains(possibleError)) {
|
||||
String errorMsg = errorMessage.replace(possibleError, "");
|
||||
|
||||
@ -2152,7 +2186,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
if (!ignoreResult) {
|
||||
boolean found = false;
|
||||
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (request.respondsToMessageId(resultMid)) {
|
||||
found = true;
|
||||
|
||||
@ -2356,7 +2391,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
long resultMid = ((TLRPC.TL_bad_server_salt) message).bad_msg_id;
|
||||
if (resultMid != 0) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if ((request.flags & RPCRequest.RPCRequestClassDownloadMedia) == 0) {
|
||||
continue;
|
||||
}
|
||||
@ -2389,7 +2425,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
boolean confirm = true;
|
||||
|
||||
if (detailedInfo instanceof TLRPC.TL_msg_detailed_info) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (request.respondsToMessageId(detailedInfo.msg_id)) {
|
||||
if (request.completed) {
|
||||
break;
|
||||
@ -2486,8 +2523,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
itemsToDelete.add(pid);
|
||||
}
|
||||
}
|
||||
for (Long pid : itemsToDelete) {
|
||||
pingIdToDate.remove(pid);
|
||||
for (int a = 0; a < itemsToDelete.size(); a++) {
|
||||
pingIdToDate.remove(itemsToDelete.get(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2605,7 +2642,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
public void tcpConnectionQuiackAckReceived(TcpConnection connection, int ack) {
|
||||
ArrayList<Long> arr = quickAckIdToRequestIds.get(ack);
|
||||
if (arr != null) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (arr.contains(request.token)) {
|
||||
if (request.quickAckBlock != null) {
|
||||
request.quickAckBlock.quickAck();
|
||||
@ -2699,14 +2737,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
int messageSeqNo = data.readInt32(false);
|
||||
int messageLength = data.readInt32(false);
|
||||
|
||||
if (connection.isMessageIdProcessed(messageId)) {
|
||||
doNotProcess = true;
|
||||
}
|
||||
|
||||
if (messageSeqNo % 2 != 0) {
|
||||
connection.addMessageToConfirm(messageId);
|
||||
}
|
||||
|
||||
byte[] realMessageKeyFull = Utilities.computeSHA1(data.buffer, 24, Math.min(messageLength + 32 + 24, data.limit()));
|
||||
if (realMessageKeyFull == null) {
|
||||
return;
|
||||
@ -2720,6 +2750,14 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
return;
|
||||
}
|
||||
|
||||
if (connection.isMessageIdProcessed(messageId)) {
|
||||
doNotProcess = true;
|
||||
}
|
||||
|
||||
if (messageSeqNo % 2 != 0) {
|
||||
connection.addMessageToConfirm(messageId);
|
||||
}
|
||||
|
||||
if (!doNotProcess) {
|
||||
TLObject message = deserialize(getRequestWithMessageId(messageId), data, true);
|
||||
if (message != null) {
|
||||
@ -2776,7 +2814,8 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
||||
}
|
||||
|
||||
public TLObject getRequestWithMessageId(long msgId) {
|
||||
for (RPCRequest request : runningRequests) {
|
||||
for (int a = 0; a < runningRequests.size(); a++) {
|
||||
RPCRequest request = runningRequests.get(a);
|
||||
if (msgId == request.runningMessageId) {
|
||||
return request.rawRequest;
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
package org.telegram.messenger;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.io.File;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
@ -297,6 +297,9 @@ public class HandshakeAction extends Action implements TcpConnection.TcpConnecti
|
||||
}
|
||||
} else if (message instanceof TLRPC.Server_DH_Params) {
|
||||
if (message instanceof TLRPC.TL_server_DH_params_ok) {
|
||||
if (authNewNonce == null) {
|
||||
return;
|
||||
}
|
||||
TLRPC.TL_server_DH_params_ok serverDhParams = (TLRPC.TL_server_DH_params_ok)message;
|
||||
|
||||
SerializedData tmpAesKey = new SerializedData();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -132,7 +132,7 @@ public class UserConfig {
|
||||
int ver = data.readInt32(false);
|
||||
if (ver == 1) {
|
||||
int constructor = data.readInt32(false);
|
||||
currentUser = TLRPC.TL_userSelf.TLdeserialize(data, constructor, false);
|
||||
currentUser = TLRPC.User.TLdeserialize(data, constructor, false);
|
||||
MessagesStorage.lastDateValue = data.readInt32(false);
|
||||
MessagesStorage.lastPtsValue = data.readInt32(false);
|
||||
MessagesStorage.lastSeqValue = data.readInt32(false);
|
||||
@ -159,7 +159,7 @@ public class UserConfig {
|
||||
});
|
||||
} else if (ver == 2) {
|
||||
int constructor = data.readInt32(false);
|
||||
currentUser = TLRPC.TL_userSelf.TLdeserialize(data, constructor, false);
|
||||
currentUser = TLRPC.User.TLdeserialize(data, constructor, false);
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("userconfing", Context.MODE_PRIVATE);
|
||||
registeredForPush = preferences.getBoolean("registeredForPush", false);
|
||||
@ -211,7 +211,7 @@ public class UserConfig {
|
||||
byte[] userBytes = Base64.decode(user, Base64.DEFAULT);
|
||||
if (userBytes != null) {
|
||||
SerializedData data = new SerializedData(userBytes);
|
||||
currentUser = TLRPC.TL_userSelf.TLdeserialize(data, data.readInt32(false), false);
|
||||
currentUser = TLRPC.User.TLdeserialize(data, data.readInt32(false), false);
|
||||
data.cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ 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) {
|
||||
if (arr1 == null || arr2 == null || offset1 < 0 || offset2 < 0 || arr1.length - offset1 != arr2.length - offset2 || arr1.length - offset1 < 0 || arr2.length - offset2 < 0) {
|
||||
return false;
|
||||
}
|
||||
boolean result = true;
|
||||
@ -450,7 +450,7 @@ public class Utilities {
|
||||
int mPendingIntentId = 123456;
|
||||
PendingIntent mPendingIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, mPendingIntentId, mRestartApp, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
AlarmManager mgr = (AlarmManager)ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, mPendingIntent);
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
|
@ -28,12 +28,11 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -184,6 +183,13 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void drawHeaderShadow(Canvas canvas, int y) {
|
||||
if (headerShadowDrawable != null) {
|
||||
headerShadowDrawable.setBounds(0, y, getMeasuredWidth(), y + headerShadowDrawable.getIntrinsicHeight());
|
||||
headerShadowDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
public void setInnerTranslationX(float value) {
|
||||
innerTranslationX = value;
|
||||
invalidate();
|
||||
@ -264,7 +270,10 @@ public class ActionBarLayout extends FrameLayout {
|
||||
layerShadowDrawable.setAlpha((int) (0xff * alpha));
|
||||
layerShadowDrawable.draw(canvas);
|
||||
} else if (child == containerViewBack) {
|
||||
final float opacity = Math.min(0.8f, (width - translationX) / (float)width);
|
||||
float opacity = Math.min(0.8f, (width - translationX) / (float)width);
|
||||
if (opacity < 0) {
|
||||
opacity = 0;
|
||||
}
|
||||
scrimPaint.setColor((int) (((0x99000000 & 0xff000000) >>> 24) * opacity) << 24);
|
||||
canvas.drawRect(clipLeft, 0, clipRight, getHeight(), scrimPaint);
|
||||
}
|
||||
@ -293,6 +302,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
lastFragment = fragmentsStack.get(fragmentsStack.size() - 1);
|
||||
currentActionBar = lastFragment.actionBar;
|
||||
lastFragment.onResume();
|
||||
lastFragment.onBecomeFullyVisible();
|
||||
} else {
|
||||
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
|
||||
lastFragment.onPause();
|
||||
@ -309,7 +319,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
containerViewBack.setVisibility(View.INVISIBLE);
|
||||
containerViewBack.setVisibility(View.GONE);
|
||||
//AndroidUtilities.unlockOrientation(parentActivity);
|
||||
startedTracking = false;
|
||||
animationInProgress = false;
|
||||
@ -428,13 +438,13 @@ public class ActionBarLayout extends FrameLayout {
|
||||
if (!backAnimation) {
|
||||
distToMove = containerView.getMeasuredWidth() - x;
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "x", containerView.getMeasuredWidth()),
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "translationX", containerView.getMeasuredWidth()),
|
||||
ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", (float)containerView.getMeasuredWidth())
|
||||
);
|
||||
} else {
|
||||
distToMove = x;
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "x", 0),
|
||||
ObjectAnimatorProxy.ofFloat(containerView, "translationX", 0),
|
||||
ObjectAnimatorProxy.ofFloat(this, "innerTranslationX", 0.0f)
|
||||
);
|
||||
}
|
||||
@ -545,7 +555,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
}
|
||||
}
|
||||
containerViewBack.setVisibility(View.INVISIBLE);
|
||||
containerViewBack.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public boolean presentFragment(BaseFragment fragment) {
|
||||
@ -560,6 +570,13 @@ public class ActionBarLayout extends FrameLayout {
|
||||
if (first) {
|
||||
animationProgress = 0.0f;
|
||||
lastFrameTime = System.nanoTime() / 1000000;
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
if (open) {
|
||||
containerView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
} else {
|
||||
containerViewBack.setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@ -600,7 +617,6 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
if (parentActivity.getCurrentFocus() != null) {
|
||||
AndroidUtilities.hideKeyboard(parentActivity.getCurrentFocus());
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.hideEmojiKeyboard);
|
||||
}
|
||||
boolean needAnimation = Build.VERSION.SDK_INT > 10 && !forceWithoutAnimation && parentActivity.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).getBoolean("view_animations", true);
|
||||
|
||||
@ -665,6 +681,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
@Override
|
||||
public void run() {
|
||||
fragment.onOpenAnimationEnd();
|
||||
fragment.onBecomeFullyVisible();
|
||||
}
|
||||
};
|
||||
ArrayList<Object> animators = new ArrayList<>();
|
||||
@ -697,8 +714,12 @@ public class ActionBarLayout extends FrameLayout {
|
||||
onOpenAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(LAYER_TYPE_NONE, null);
|
||||
}
|
||||
presentFragmentInternalRemoveOld(removeLast, currentFragment);
|
||||
fragment.onOpenAnimationEnd();
|
||||
fragment.onBecomeFullyVisible();
|
||||
ViewProxy.setTranslationX(containerView, 0);
|
||||
}
|
||||
};
|
||||
@ -737,6 +758,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
fragment.onOpenAnimationStart();
|
||||
fragment.onOpenAnimationEnd();
|
||||
fragment.onBecomeFullyVisible();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -779,7 +801,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
fragment.onFragmentDestroy();
|
||||
fragment.setParentLayout(null);
|
||||
fragmentsStack.remove(fragment);
|
||||
containerViewBack.setVisibility(View.INVISIBLE);
|
||||
containerViewBack.setVisibility(View.GONE);
|
||||
bringChildToFront(containerView);
|
||||
}
|
||||
|
||||
@ -830,6 +852,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.height = LayoutHelper.MATCH_PARENT;
|
||||
fragmentView.setLayoutParams(layoutParams);
|
||||
previousFragment.onOpenAnimationStart();
|
||||
previousFragment.onResume();
|
||||
currentActionBar = previousFragment.actionBar;
|
||||
if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
|
||||
@ -843,11 +866,17 @@ public class ActionBarLayout extends FrameLayout {
|
||||
if (needAnimation) {
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
transitionAnimationInProgress = true;
|
||||
final BaseFragment previousFragmentFinal = previousFragment;
|
||||
onCloseAnimationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerViewBack.setLayerType(LAYER_TYPE_NONE, null);
|
||||
}
|
||||
closeLastFragmentInternalRemoveOld(currentFragment);
|
||||
ViewProxy.setTranslationX(containerViewBack, 0);
|
||||
previousFragmentFinal.onOpenAnimationEnd();
|
||||
previousFragmentFinal.onBecomeFullyVisible();
|
||||
}
|
||||
};
|
||||
startLayoutAnimation(false, true);
|
||||
@ -875,6 +904,9 @@ public class ActionBarLayout extends FrameLayout {
|
||||
}
|
||||
});
|
||||
currentAnimation.start();*/
|
||||
} else {
|
||||
previousFragment.onOpenAnimationEnd();
|
||||
previousFragment.onBecomeFullyVisible();
|
||||
}
|
||||
} else {
|
||||
if (useAlphaAnimations) {
|
||||
@ -885,9 +917,9 @@ public class ActionBarLayout extends FrameLayout {
|
||||
@Override
|
||||
public void run() {
|
||||
removeFragmentFromStack(currentFragment);
|
||||
setVisibility(INVISIBLE);
|
||||
setVisibility(GONE);
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(INVISIBLE);
|
||||
backgroundView.setVisibility(GONE);
|
||||
}
|
||||
if (drawerLayoutContainer != null) {
|
||||
drawerLayoutContainer.setAllowOpenDrawer(true, false);
|
||||
@ -924,9 +956,9 @@ public class ActionBarLayout extends FrameLayout {
|
||||
currentAnimation.start();
|
||||
} else {
|
||||
removeFragmentFromStack(currentFragment);
|
||||
setVisibility(INVISIBLE);
|
||||
setVisibility(GONE);
|
||||
if (backgroundView != null) {
|
||||
backgroundView.setVisibility(INVISIBLE);
|
||||
backgroundView.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -986,7 +1018,7 @@ public class ActionBarLayout extends FrameLayout {
|
||||
|
||||
public void rebuildAllFragmentViews(boolean last) {
|
||||
for (int a = 0; a < fragmentsStack.size() - (last ? 0 : 1); a++) {
|
||||
fragmentsStack.get(a).setParentLayout(null);
|
||||
fragmentsStack.get(a).clearViews();
|
||||
fragmentsStack.get(a).setParentLayout(this);
|
||||
}
|
||||
if (delegate != null) {
|
||||
|
@ -65,6 +65,10 @@ public class ActionBarMenu extends LinearLayout {
|
||||
return addItem(id, icon, parentActionBar.itemsBackgroundResourceId, null, width);
|
||||
}
|
||||
|
||||
public ActionBarMenuItem addItemWithWidth(int id, Drawable icon, int width) {
|
||||
return addItem(id, 0, parentActionBar.itemsBackgroundResourceId, icon, width);
|
||||
}
|
||||
|
||||
public ActionBarMenuItem addItem(int id, int icon, int backgroundResource, Drawable drawable, int width) {
|
||||
ActionBarMenuItem menuItem = new ActionBarMenuItem(getContext(), this, backgroundResource);
|
||||
menuItem.setTag(id);
|
||||
|
@ -32,9 +32,9 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Components.FrameLayoutFixed;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
@ -46,10 +46,14 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
public void onSearchExpand() {
|
||||
}
|
||||
|
||||
public boolean onSearchCollapse() {
|
||||
public boolean canCollapseSearch() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onSearchCollapse() {
|
||||
|
||||
}
|
||||
|
||||
public void onTextChanged(EditText editText) {
|
||||
}
|
||||
|
||||
@ -78,6 +82,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
private int menuHeight = AndroidUtilities.dp(16);
|
||||
private int subMenuOpenSide = 0;
|
||||
private ActionBarMenuItemDelegate delegate;
|
||||
private boolean allowCloseAnimation = true;
|
||||
|
||||
public ActionBarMenuItem(Context context, ActionBarMenu menu, int background) {
|
||||
super(context);
|
||||
@ -155,8 +160,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
} else if (delegate != null) {
|
||||
delegate.onItemClick((Integer) selectedMenuView.getTag());
|
||||
}
|
||||
}
|
||||
popupWindow.dismiss(allowCloseAnimation);
|
||||
} else {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
} else {
|
||||
if (selectedMenuView != null) {
|
||||
selectedMenuView.setSelected(false);
|
||||
@ -172,6 +179,9 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
|
||||
public void setShowFromBottom(boolean value) {
|
||||
showFromBottom = value;
|
||||
if (popupLayout != null) {
|
||||
popupLayout.setShowedFromBotton(showFromBottom);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSubMenuOpenSide(int side) {
|
||||
@ -184,7 +194,8 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
location = new int[2];
|
||||
popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
|
||||
popupLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
popupLayout.setBackgroundResource(R.drawable.popup_fixed);
|
||||
popupLayout.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8), AndroidUtilities.dp(8));
|
||||
//popupLayout.setBackgroundResource(R.drawable.popup_fixed);
|
||||
popupLayout.setOnTouchListener(new OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
@ -229,6 +240,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
textView.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(icon), null);
|
||||
}
|
||||
}
|
||||
popupLayout.setShowedFromBotton(showFromBottom);
|
||||
popupLayout.addView(textView);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams();
|
||||
if (LocaleController.isRTL) {
|
||||
@ -240,14 +252,14 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
textView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss(allowCloseAnimation);
|
||||
}
|
||||
if (parentMenu != null) {
|
||||
parentMenu.onItemClick((Integer) view.getTag());
|
||||
} else if (delegate != null) {
|
||||
delegate.onItemClick((Integer) view.getTag());
|
||||
}
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
menuHeight += layoutParams.height;
|
||||
@ -273,7 +285,11 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
if (popupWindow == null) {
|
||||
popupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
|
||||
//popupWindow.setBackgroundDrawable(new BitmapDrawable());
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
popupWindow.setAnimationStyle(0);
|
||||
} else {
|
||||
popupWindow.setAnimationStyle(R.style.PopupAnimation);
|
||||
}
|
||||
popupWindow.setOutsideTouchable(true);
|
||||
popupWindow.setClippingEnabled(true);
|
||||
popupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
||||
@ -293,54 +309,11 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
}
|
||||
popupWindow.setFocusable(true);
|
||||
if (popupLayout.getMeasuredWidth() == 0) {
|
||||
if (subMenuOpenSide == 0) {
|
||||
if (showFromBottom) {
|
||||
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), getOffsetY());
|
||||
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), getOffsetY(), -1, -1);
|
||||
updateOrShowPopup(true, true);
|
||||
} else {
|
||||
if (parentMenu != null) {
|
||||
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 (getParent() != null) {
|
||||
View parent = (View) getParent();
|
||||
popupWindow.showAsDropDown(this, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), getOffsetY());
|
||||
popupWindow.update(this, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), getOffsetY(), -1, -1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
popupWindow.showAsDropDown(this, -AndroidUtilities.dp(8), getOffsetY());
|
||||
popupWindow.update(this, -AndroidUtilities.dp(8), getOffsetY(), -1, -1);
|
||||
}
|
||||
} else {
|
||||
if (subMenuOpenSide == 0) {
|
||||
if (showFromBottom) {
|
||||
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), getOffsetY());
|
||||
} else {
|
||||
if (parentMenu != null) {
|
||||
popupWindow.showAsDropDown(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY());
|
||||
} else {
|
||||
View parent = (View) getParent();
|
||||
popupWindow.showAsDropDown(this, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), getOffsetY());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
popupWindow.showAsDropDown(this, -AndroidUtilities.dp(8), getOffsetY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getOffsetY() {
|
||||
if (showFromBottom) {
|
||||
getLocationOnScreen(location);
|
||||
int diff = location[1] - AndroidUtilities.statusBarHeight + getMeasuredHeight() - menuHeight;
|
||||
int y = -menuHeight;
|
||||
if (diff < 0) {
|
||||
y -= diff;
|
||||
}
|
||||
return y;
|
||||
} else {
|
||||
return -getMeasuredHeight();
|
||||
updateOrShowPopup(true, false);
|
||||
}
|
||||
popupWindow.startAnimation();
|
||||
}
|
||||
|
||||
public void openSearch() {
|
||||
@ -355,10 +328,13 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
return false;
|
||||
}
|
||||
if (searchContainer.getVisibility() == VISIBLE) {
|
||||
if (listener == null || listener != null && listener.onSearchCollapse()) {
|
||||
if (listener == null || listener != null && listener.canCollapseSearch()) {
|
||||
searchContainer.setVisibility(GONE);
|
||||
setVisibility(VISIBLE);
|
||||
AndroidUtilities.hideKeyboard(searchField);
|
||||
if (listener != null) {
|
||||
listener.onSearchCollapse();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
@ -393,6 +369,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
}
|
||||
|
||||
public ActionBarMenuItem setIsSearchField(boolean value) {
|
||||
return setIsSearchField(value, true);
|
||||
}
|
||||
|
||||
public ActionBarMenuItem setIsSearchField(boolean value, boolean needClearButton) {
|
||||
if (parentMenu == null) {
|
||||
return this;
|
||||
}
|
||||
@ -428,6 +408,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
}
|
||||
|
||||
public void onDestroyActionMode(ActionMode mode) {
|
||||
|
||||
}
|
||||
|
||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||
@ -462,8 +443,10 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
if (listener != null) {
|
||||
listener.onTextChanged(searchField);
|
||||
}
|
||||
if (clearButton != null) {
|
||||
ViewProxy.setAlpha(clearButton, s == null || s.length() == 0 ? 0.6f : 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
@ -492,6 +475,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
layoutParams2.rightMargin = AndroidUtilities.dp(48);
|
||||
searchField.setLayoutParams(layoutParams2);
|
||||
|
||||
if (needClearButton) {
|
||||
clearButton = new ImageView(getContext());
|
||||
clearButton.setImageResource(R.drawable.ic_close_white);
|
||||
clearButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||
@ -509,6 +493,7 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
layoutParams2.height = LayoutHelper.MATCH_PARENT;
|
||||
clearButton.setLayoutParams(layoutParams2);
|
||||
}
|
||||
}
|
||||
isSearchField = value;
|
||||
return this;
|
||||
}
|
||||
@ -522,26 +507,73 @@ public class ActionBarMenuItem extends FrameLayoutFixed {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ActionBarMenuItem setAllowCloseAnimation(boolean value) {
|
||||
allowCloseAnimation = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
if (popupWindow != null && popupWindow.isShowing()) {
|
||||
updateOrShowPopup(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOrShowPopup(boolean show, boolean update) {
|
||||
int offsetY;
|
||||
if (showFromBottom) {
|
||||
getLocationOnScreen(location);
|
||||
int diff = location[1] - AndroidUtilities.statusBarHeight + getMeasuredHeight() - menuHeight;
|
||||
offsetY = -menuHeight;
|
||||
if (diff < 0) {
|
||||
offsetY -= diff;
|
||||
}
|
||||
} else {
|
||||
if (parentMenu != null && subMenuOpenSide == 0) {
|
||||
offsetY = -parentMenu.parentActionBar.getMeasuredHeight() + parentMenu.getTop();
|
||||
} else {
|
||||
offsetY = -getMeasuredHeight();
|
||||
}
|
||||
}
|
||||
|
||||
if (subMenuOpenSide == 0) {
|
||||
if (showFromBottom) {
|
||||
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), getOffsetY(), -1, -1);
|
||||
if (show) {
|
||||
popupWindow.showAsDropDown(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), offsetY);
|
||||
}
|
||||
if (update) {
|
||||
popupWindow.update(this, -popupLayout.getMeasuredWidth() + getMeasuredWidth(), offsetY, -1, -1);
|
||||
}
|
||||
} else {
|
||||
if (parentMenu != null) {
|
||||
popupWindow.update(this, parentMenu.parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), getOffsetY(), -1, -1);
|
||||
} else {
|
||||
View parent = parentMenu.parentActionBar;
|
||||
if (show) {
|
||||
popupWindow.showAsDropDown(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth(), offsetY);
|
||||
}
|
||||
if (update) {
|
||||
popupWindow.update(parent, getLeft() + parentMenu.getLeft() + getMeasuredWidth() - popupLayout.getMeasuredWidth(), offsetY, -1, -1);
|
||||
}
|
||||
} else if (getParent() != null) {
|
||||
View parent = (View) getParent();
|
||||
popupWindow.update(this, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), getOffsetY(), -1, -1);
|
||||
if (show) {
|
||||
popupWindow.showAsDropDown(parent, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), offsetY);
|
||||
}
|
||||
if (update) {
|
||||
popupWindow.update(parent, parent.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parent.getLeft(), offsetY, -1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
popupWindow.update(this, -AndroidUtilities.dp(8), getOffsetY(), -1, -1);
|
||||
if (show) {
|
||||
popupWindow.showAsDropDown(this, -AndroidUtilities.dp(8), offsetY);
|
||||
}
|
||||
if (update) {
|
||||
popupWindow.update(this, -AndroidUtilities.dp(8), offsetY, -1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//plus
|
||||
public ImageView getClearButton(){
|
||||
return clearButton;
|
||||
|
@ -10,20 +10,33 @@
|
||||
|
||||
package org.telegram.ui.ActionBar;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ActionBarPopupWindow extends PopupWindow {
|
||||
|
||||
private static final Field superListenerField;
|
||||
private static final boolean animationEnabled = Build.VERSION.SDK_INT >= 18;
|
||||
private static DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
|
||||
private AnimatorSet windowAnimatorSet;
|
||||
static {
|
||||
Field f = null;
|
||||
try {
|
||||
@ -52,15 +65,104 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
public static class ActionBarPopupWindowLayout extends LinearLayout {
|
||||
|
||||
private OnDispatchKeyEventListener mOnDispatchKeyEventListener;
|
||||
protected static Drawable backgroundDrawable;
|
||||
private float backScaleX = 1;
|
||||
private float backScaleY = 1;
|
||||
private int backAlpha = 255;
|
||||
private int lastStartedChild = 0;
|
||||
private boolean showedFromBotton;
|
||||
private HashMap<View, Integer> positions = new HashMap<>();
|
||||
|
||||
public ActionBarPopupWindowLayout(Context context) {
|
||||
super(context);
|
||||
setWillNotDraw(false);
|
||||
|
||||
if (backgroundDrawable == null) {
|
||||
backgroundDrawable = getResources().getDrawable(R.drawable.popup_fixed);
|
||||
}
|
||||
}
|
||||
|
||||
public void setShowedFromBotton(boolean value) {
|
||||
showedFromBotton = value;
|
||||
}
|
||||
|
||||
public void setDispatchKeyEventListener(OnDispatchKeyEventListener listener) {
|
||||
mOnDispatchKeyEventListener = listener;
|
||||
}
|
||||
|
||||
public void setBackAlpha(int value) {
|
||||
backAlpha = value;
|
||||
}
|
||||
|
||||
public int getBackAlpha() {
|
||||
return backAlpha;
|
||||
}
|
||||
|
||||
public void setBackScaleX(float value) {
|
||||
backScaleX = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setBackScaleY(float value) {
|
||||
backScaleY = value;
|
||||
if (animationEnabled) {
|
||||
int count = getChildCount();
|
||||
int visibleCount = 0;
|
||||
for (int a = 0; a < count; a++) {
|
||||
visibleCount += getChildAt(a).getVisibility() == VISIBLE ? 1 : 0;
|
||||
}
|
||||
int height = getMeasuredHeight() - AndroidUtilities.dp(16);
|
||||
if (showedFromBotton) {
|
||||
for (int a = lastStartedChild; a >= 0; a--) {
|
||||
View child = getChildAt(a);
|
||||
if (child.getVisibility() != VISIBLE) {
|
||||
continue;
|
||||
}
|
||||
int position = positions.get(child);
|
||||
if (height - (position * AndroidUtilities.dp(48) + AndroidUtilities.dp(32)) > value * height) {
|
||||
break;
|
||||
}
|
||||
lastStartedChild = a - 1;
|
||||
startChildAnimation(child);
|
||||
}
|
||||
} else {
|
||||
for (int a = lastStartedChild; a < count; a++) {
|
||||
View child = getChildAt(a);
|
||||
if (child.getVisibility() != VISIBLE) {
|
||||
continue;
|
||||
}
|
||||
int position = positions.get(child);
|
||||
if ((position + 1) * AndroidUtilities.dp(48) - AndroidUtilities.dp(24) > value * height) {
|
||||
break;
|
||||
}
|
||||
lastStartedChild = a + 1;
|
||||
startChildAnimation(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private void startChildAnimation(View child) {
|
||||
if (animationEnabled) {
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(child, "alpha", 0.0f, 1.0f),
|
||||
ObjectAnimator.ofFloat(child, "translationY", AndroidUtilities.dp(showedFromBotton ? 6 : -6), 0));
|
||||
animatorSet.setDuration(180);
|
||||
animatorSet.setInterpolator(decelerateInterpolator);
|
||||
animatorSet.start();
|
||||
}
|
||||
}
|
||||
|
||||
public float getBackScaleX() {
|
||||
return backScaleX;
|
||||
}
|
||||
|
||||
public float getBackScaleY() {
|
||||
return backScaleY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (mOnDispatchKeyEventListener != null) {
|
||||
@ -68,6 +170,19 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (backgroundDrawable != null) {
|
||||
backgroundDrawable.setAlpha(backAlpha);
|
||||
if (showedFromBotton) {
|
||||
backgroundDrawable.setBounds(0, (int) (getMeasuredHeight() * (1.0f - backScaleY)), (int) (getMeasuredWidth() * backScaleX), getMeasuredHeight());
|
||||
} else {
|
||||
backgroundDrawable.setBounds(0, 0, (int) (getMeasuredWidth() * backScaleX), (int) (getMeasuredHeight() * backScaleY));
|
||||
}
|
||||
backgroundDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ActionBarPopupWindow() {
|
||||
@ -109,15 +224,6 @@ 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() {
|
||||
@ -153,6 +259,63 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
}
|
||||
}
|
||||
|
||||
public void startAnimation() {
|
||||
if (animationEnabled) {
|
||||
if (windowAnimatorSet != null) {
|
||||
return;
|
||||
}
|
||||
ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
|
||||
content.setTranslationY(0);
|
||||
content.setAlpha(1.0f);
|
||||
content.setPivotX(content.getMeasuredWidth());
|
||||
content.setPivotY(0);
|
||||
int count = content.getChildCount();
|
||||
content.positions.clear();
|
||||
int visibleCount = 0;
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = content.getChildAt(a);
|
||||
if (child.getVisibility() != View.VISIBLE) {
|
||||
continue;
|
||||
}
|
||||
content.positions.put(child, visibleCount);
|
||||
child.setAlpha(0.0f);
|
||||
visibleCount++;
|
||||
}
|
||||
if (content.showedFromBotton) {
|
||||
content.lastStartedChild = count - 1;
|
||||
} else {
|
||||
content.lastStartedChild = 0;
|
||||
}
|
||||
windowAnimatorSet = new AnimatorSet();
|
||||
windowAnimatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(content, "backScaleY", 0.0f, 1.0f),
|
||||
ObjectAnimator.ofInt(content, "backAlpha", 0, 255));
|
||||
windowAnimatorSet.setDuration(150 + 16 * visibleCount);
|
||||
windowAnimatorSet.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
windowAnimatorSet = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
windowAnimatorSet.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(View anchor, int xoff, int yoff, int width, int height) {
|
||||
super.update(anchor, xoff, yoff, width, height);
|
||||
@ -173,6 +336,50 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
dismiss(true);
|
||||
}
|
||||
|
||||
public void dismiss(boolean animated) {
|
||||
if (animationEnabled && animated) {
|
||||
if (windowAnimatorSet != null) {
|
||||
windowAnimatorSet.cancel();
|
||||
}
|
||||
ActionBarPopupWindowLayout content = (ActionBarPopupWindowLayout) getContentView();
|
||||
windowAnimatorSet = new AnimatorSet();
|
||||
windowAnimatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(content, "translationY", AndroidUtilities.dp(content.showedFromBotton ? 5 : -5)),
|
||||
ObjectAnimator.ofFloat(content, "alpha", 0.0f));
|
||||
windowAnimatorSet.setDuration(150);
|
||||
windowAnimatorSet.addListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
public void onAnimationStart(Animator animation) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationEnd(Animator animation) {
|
||||
windowAnimatorSet = null;
|
||||
setFocusable(false);
|
||||
try {
|
||||
ActionBarPopupWindow.super.dismiss();
|
||||
} catch (Exception e) {
|
||||
//don't promt
|
||||
}
|
||||
unregisterListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationCancel(Animator animation) {
|
||||
onAnimationEnd(animation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAnimationRepeat(Animator animation) {
|
||||
|
||||
}
|
||||
});
|
||||
windowAnimatorSet.start();
|
||||
} else {
|
||||
setFocusable(false);
|
||||
try {
|
||||
super.dismiss();
|
||||
@ -182,3 +389,4 @@ public class ActionBarPopupWindow extends PopupWindow {
|
||||
unregisterListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -56,9 +56,7 @@ public class BaseFragment {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
protected void setParentLayout(ActionBarLayout layout) {
|
||||
if (parentLayout != layout) {
|
||||
parentLayout = layout;
|
||||
protected void clearViews() {
|
||||
if (fragmentView != null) {
|
||||
ViewGroup parent = (ViewGroup) fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
@ -79,8 +77,41 @@ public class BaseFragment {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
actionBar = null;
|
||||
}
|
||||
if (parentLayout != null) {
|
||||
parentLayout = null;
|
||||
}
|
||||
|
||||
protected void setParentLayout(ActionBarLayout layout) {
|
||||
if (parentLayout != layout) {
|
||||
parentLayout = layout;
|
||||
if (fragmentView != null) {
|
||||
ViewGroup parent = (ViewGroup) fragmentView.getParent();
|
||||
if (parent != null) {
|
||||
try {
|
||||
parent.removeView(fragmentView);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
if (parentLayout != null && parentLayout.getContext() != fragmentView.getContext()) {
|
||||
fragmentView = null;
|
||||
}
|
||||
}
|
||||
if (actionBar != null) {
|
||||
ViewGroup parent = (ViewGroup) actionBar.getParent();
|
||||
if (parent != null) {
|
||||
try {
|
||||
parent.removeView(actionBar);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
if (parentLayout != null && parentLayout.getContext() != actionBar.getContext()) {
|
||||
actionBar = null;
|
||||
}
|
||||
}
|
||||
if (parentLayout != null && actionBar == null) {
|
||||
actionBar = new ActionBar(parentLayout.getContext());
|
||||
actionBar.parentFragment = this;
|
||||
//actionBar.setBackgroundColor(0xff54759e);
|
||||
@ -208,6 +239,10 @@ public class BaseFragment {
|
||||
|
||||
}
|
||||
|
||||
protected void onBecomeFullyVisible() {
|
||||
|
||||
}
|
||||
|
||||
public void onLowMemory() {
|
||||
|
||||
}
|
||||
@ -217,7 +252,7 @@ public class BaseFragment {
|
||||
}
|
||||
|
||||
public Dialog showDialog(Dialog dialog) {
|
||||
if (parentLayout == null || parentLayout.animationInProgress || parentLayout.startedTracking || parentLayout.checkTransitionAnimation()) {
|
||||
if (dialog == null || parentLayout == null || parentLayout.animationInProgress || parentLayout.startedTracking || parentLayout.checkTransitionAnimation()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
@ -230,8 +265,6 @@ public class BaseFragment {
|
||||
}
|
||||
try {
|
||||
visibleDialog = dialog;
|
||||
|
||||
|
||||
visibleDialog.setCanceledOnTouchOutside(true);
|
||||
visibleDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
@ -268,6 +301,10 @@ public class BaseFragment {
|
||||
|
||||
}
|
||||
|
||||
public Dialog getVisibleDialog() {
|
||||
return visibleDialog;
|
||||
}
|
||||
|
||||
public void setVisibleDialog(Dialog dialog) {
|
||||
visibleDialog = dialog;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ListView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
@ -92,7 +94,6 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
|
||||
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
if (drawerGravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (drawerGravity == Gravity.RIGHT) {
|
||||
@ -100,11 +101,9 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
}
|
||||
child.dispatchApplyWindowInsets(wi);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyMarginInsets(MarginLayoutParams lp, Object insets, int drawerGravity, boolean topOnly) {
|
||||
WindowInsets wi = (WindowInsets) insets;
|
||||
if (Build.VERSION.SDK_INT >= 20) {
|
||||
if (drawerGravity == Gravity.LEFT) {
|
||||
wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
|
||||
} else if (drawerGravity == Gravity.RIGHT) {
|
||||
@ -115,7 +114,6 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
lp.rightMargin = wi.getSystemWindowInsetRight();
|
||||
lp.bottomMargin = wi.getSystemWindowInsetBottom();
|
||||
}
|
||||
}
|
||||
|
||||
private int getTopInset(Object insets) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
@ -151,7 +149,7 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
}
|
||||
requestLayout();
|
||||
|
||||
final int newVisibility = drawerPosition > 0 ? VISIBLE : INVISIBLE;
|
||||
final int newVisibility = drawerPosition > 0 ? VISIBLE : GONE;
|
||||
if (drawerLayout.getVisibility() != newVisibility) {
|
||||
drawerLayout.setVisibility(newVisibility);
|
||||
}
|
||||
@ -397,11 +395,15 @@ public class DrawerLayoutContainer extends FrameLayout {
|
||||
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
try {
|
||||
if (drawerLayout != child) {
|
||||
child.layout(lp.leftMargin, lp.topMargin, lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight());
|
||||
} else {
|
||||
child.layout(-child.getMeasuredWidth() + (int)drawerPosition, lp.topMargin, (int)drawerPosition, lp.topMargin + child.getMeasuredHeight());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
inLayout = false;
|
||||
}
|
||||
|
@ -21,10 +21,12 @@ import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Cells.LoadingCell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
|
||||
private Context mContext;
|
||||
private boolean serverOnly;
|
||||
private int dialogsType;
|
||||
private long openedDialogId;
|
||||
private int currentCount;
|
||||
|
||||
@ -35,9 +37,9 @@ public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
}
|
||||
|
||||
public DialogsAdapter(Context context, boolean onlyFromServer) {
|
||||
public DialogsAdapter(Context context, int type) {
|
||||
mContext = context;
|
||||
serverOnly = onlyFromServer;
|
||||
dialogsType = type;
|
||||
}
|
||||
|
||||
public void setOpenedDialogId(long id) {
|
||||
@ -49,14 +51,20 @@ public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
return current != getItemCount();
|
||||
}
|
||||
|
||||
private ArrayList<TLRPC.TL_dialog> getDialogsArray() {
|
||||
if (dialogsType == 0) {
|
||||
return MessagesController.getInstance().dialogs;
|
||||
} else if (dialogsType == 1) {
|
||||
return MessagesController.getInstance().dialogsServerOnly;
|
||||
} else if (dialogsType == 2) {
|
||||
return MessagesController.getInstance().dialogsGroupsOnly;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
int count;
|
||||
if (serverOnly) {
|
||||
count = MessagesController.getInstance().dialogsServerOnly.size();
|
||||
} else {
|
||||
count = MessagesController.getInstance().dialogs.size();
|
||||
}
|
||||
int count = getDialogsArray().size();
|
||||
if (count == 0 && MessagesController.getInstance().loadingDialogs) {
|
||||
return 0;
|
||||
}
|
||||
@ -68,17 +76,11 @@ public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
}
|
||||
|
||||
public TLRPC.TL_dialog getItem(int i) {
|
||||
if (serverOnly) {
|
||||
if (i < 0 || i >= MessagesController.getInstance().dialogsServerOnly.size()) {
|
||||
ArrayList<TLRPC.TL_dialog> arrayList = getDialogsArray();
|
||||
if (i < 0 || i >= arrayList.size()) {
|
||||
return null;
|
||||
}
|
||||
return MessagesController.getInstance().dialogsServerOnly.get(i);
|
||||
} else {
|
||||
if (i < 0 || i >= MessagesController.getInstance().dialogs.size()) {
|
||||
return null;
|
||||
}
|
||||
return MessagesController.getInstance().dialogs.get(i);
|
||||
}
|
||||
return arrayList.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -104,29 +106,19 @@ public class DialogsAdapter extends RecyclerView.Adapter {
|
||||
if (viewHolder.getItemViewType() == 0) {
|
||||
DialogCell cell = (DialogCell) viewHolder.itemView;
|
||||
cell.useSeparator = (i != getItemCount() - 1);
|
||||
TLRPC.TL_dialog dialog;
|
||||
if (serverOnly) {
|
||||
dialog = MessagesController.getInstance().dialogsServerOnly.get(i);
|
||||
} else {
|
||||
dialog = MessagesController.getInstance().dialogs.get(i);
|
||||
TLRPC.TL_dialog dialog = getItem(i);
|
||||
if (dialogsType == 0) {
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(dialog.id == openedDialogId);
|
||||
}
|
||||
}
|
||||
cell.setDialog(dialog, i, serverOnly);
|
||||
cell.setDialog(dialog, i, dialogsType);
|
||||
}
|
||||
|
||||
//updateTheme(viewHolder);
|
||||
}
|
||||
/*
|
||||
private void updateTheme(RecyclerView.ViewHolder viewHolder){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
viewHolder.setBackgroundColor(themePrefs.getInt("chatsRowColor", 0xffffffff));
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int i) {
|
||||
if (serverOnly && i == MessagesController.getInstance().dialogsServerOnly.size() || !serverOnly && i == MessagesController.getInstance().dialogs.size()) {
|
||||
if (i == getDialogsArray().size()) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -160,7 +160,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
}, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
|
||||
}
|
||||
|
||||
private void searchDialogsInternal(final String query, final boolean serverOnly, final int searchId) {
|
||||
private void searchDialogsInternal(final String query, final int dialogsType, final int searchId) {
|
||||
if (needMessagesSearch == 2) {
|
||||
return;
|
||||
}
|
||||
@ -202,12 +202,12 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
int high_id = (int) (id >> 32);
|
||||
if (lower_id != 0) {
|
||||
if (high_id == 1) {
|
||||
if (!serverOnly && !chatsToLoad.contains(lower_id)) {
|
||||
if (dialogsType == 0 && !chatsToLoad.contains(lower_id)) {
|
||||
chatsToLoad.add(lower_id);
|
||||
}
|
||||
} else {
|
||||
if (lower_id > 0) {
|
||||
if (!usersToLoad.contains(lower_id)) {
|
||||
if (dialogsType != 2 && !usersToLoad.contains(lower_id)) {
|
||||
usersToLoad.add(lower_id);
|
||||
}
|
||||
} else {
|
||||
@ -216,7 +216,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!serverOnly) {
|
||||
} else if (dialogsType == 0) {
|
||||
if (!encryptedToLoad.contains(high_id)) {
|
||||
encryptedToLoad.add(high_id);
|
||||
}
|
||||
@ -394,6 +394,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
resultArrayNames.add(dialogSearchResult.name);
|
||||
}
|
||||
|
||||
if (dialogsType != 2) {
|
||||
cursor = MessagesStorage.getInstance().getDatabase().queryFinalized("SELECT u.data, u.status, u.name, u.uid FROM users as u INNER JOIN contacts as c ON u.uid = c.uid");
|
||||
while (cursor.next()) {
|
||||
int uid = cursor.intValue(3);
|
||||
@ -437,6 +438,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
}
|
||||
}
|
||||
cursor.dispose();
|
||||
}
|
||||
|
||||
updateSearchResults(resultArray, resultArrayNames, encUsers, searchId);
|
||||
} catch (Exception e) {
|
||||
@ -502,13 +504,14 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void searchDialogs(final String query, final boolean serverOnly) {
|
||||
public void searchDialogs(final String query, final int dialogsType) {
|
||||
if (query != null && lastSearchText != null && query.equals(lastSearchText)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (searchTimer != null) {
|
||||
searchTimer.cancel();
|
||||
searchTimer = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
@ -524,7 +527,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
searchMessagesInternal(null);
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
if (query.startsWith("#") && query.length() == 1) {
|
||||
if (needMessagesSearch != 2 && (query.startsWith("#") && query.length() == 1)) {
|
||||
messagesSearchEndReached = true;
|
||||
if (!hashtagsLoadedFromDb) {
|
||||
loadRecentHashtags();
|
||||
@ -553,12 +556,13 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
cancel();
|
||||
searchTimer.cancel();
|
||||
searchTimer = null;
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
searchDialogsInternal(query, serverOnly, searchId);
|
||||
searchDialogsInternal(query, dialogsType, searchId);
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -14,6 +14,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
@ -86,7 +87,7 @@ public class DrawerLayoutAdapter extends BaseAdapter {
|
||||
((DrawerProfileCell) view).setUser(MessagesController.getInstance().getUser(UserConfig.getClientUserId()));
|
||||
} else if (type == 1) {
|
||||
if (view == null) {
|
||||
view = new EmptyCell(mContext, 8);
|
||||
view = new EmptyCell(mContext, AndroidUtilities.dp(8));
|
||||
}
|
||||
} else if (type == 2) {
|
||||
if (view == null) {
|
||||
|
@ -14,6 +14,7 @@ import android.view.ViewGroup;
|
||||
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Cells.MentionCell;
|
||||
|
||||
@ -32,7 +33,11 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
private TLRPC.ChatParticipants info;
|
||||
private ArrayList<TLRPC.User> searchResultUsernames;
|
||||
private ArrayList<String> searchResultHashtags;
|
||||
private ArrayList<String> searchResultCommands;
|
||||
private ArrayList<String> searchResultCommandsHelp;
|
||||
private ArrayList<TLRPC.User> searchResultCommandsUsers;
|
||||
private MentionsAdapterDelegate delegate;
|
||||
private HashMap<Integer, TLRPC.BotInfo> botInfo;
|
||||
private int resultStartPosition;
|
||||
private int resultLength;
|
||||
private String lastText;
|
||||
@ -40,6 +45,7 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
private ArrayList<MessageObject> messages;
|
||||
private boolean needUsernames = true;
|
||||
private boolean isDarkTheme;
|
||||
private int botsCount;
|
||||
|
||||
public MentionsAdapter(Context context, boolean isDarkTheme, MentionsAdapterDelegate delegate) {
|
||||
mContext = context;
|
||||
@ -58,6 +64,14 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
needUsernames = value;
|
||||
}
|
||||
|
||||
public void setBotInfo(HashMap<Integer, TLRPC.BotInfo> info) {
|
||||
botInfo = info;
|
||||
}
|
||||
|
||||
public void setBotsCount(int count) {
|
||||
botsCount = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRecentHashtags() {
|
||||
super.clearRecentHashtags();
|
||||
@ -126,6 +140,11 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
resultLength = result.length() + 1;
|
||||
result.insert(0, ch);
|
||||
break;
|
||||
} else if (a == 0 && botInfo != null && ch == '/') {
|
||||
foundType = 2;
|
||||
resultStartPosition = a;
|
||||
resultLength = result.length() + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(ch >= '0' && ch <= '9' || ch >= 'a' && ch <= 'z' || ch >= 'A' && ch <= 'Z' || ch == '_')) {
|
||||
@ -149,7 +168,7 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
ArrayList<TLRPC.User> newResult = new ArrayList<>();
|
||||
for (TLRPC.TL_chatParticipant chatParticipant : info.participants) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(chatParticipant.user_id);
|
||||
if (user == null || user instanceof TLRPC.TL_userSelf) {
|
||||
if (user == null || UserObject.isUserSelf(user)) {
|
||||
continue;
|
||||
}
|
||||
if (user.username != null && user.username.length() > 0 && (usernameString.length() > 0 && user.username.toLowerCase().startsWith(usernameString) || usernameString.length() == 0)) {
|
||||
@ -157,6 +176,9 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
}
|
||||
}
|
||||
searchResultHashtags = null;
|
||||
searchResultCommands = null;
|
||||
searchResultCommandsHelp = null;
|
||||
searchResultCommandsUsers = null;
|
||||
searchResultUsernames = newResult;
|
||||
Collections.sort(searchResultUsernames, new Comparator<TLRPC.User>() {
|
||||
@Override
|
||||
@ -175,16 +197,40 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
});
|
||||
notifyDataSetChanged();
|
||||
delegate.needChangePanelVisibility(!newResult.isEmpty());
|
||||
} else {
|
||||
} else if (foundType == 1) {
|
||||
ArrayList<String> newResult = new ArrayList<>();
|
||||
String hashtagString = result.toString().toLowerCase();
|
||||
for (HashtagObject hashtagObject : hashtags) {
|
||||
if (hashtagString != null && hashtagObject.hashtag != null && hashtagObject.hashtag.startsWith(hashtagString)) {
|
||||
if (hashtagObject != null && hashtagObject.hashtag != null && hashtagObject.hashtag.startsWith(hashtagString)) {
|
||||
newResult.add(hashtagObject.hashtag);
|
||||
}
|
||||
}
|
||||
searchResultHashtags = newResult;
|
||||
searchResultUsernames = null;
|
||||
searchResultCommands = null;
|
||||
searchResultCommandsHelp = null;
|
||||
searchResultCommandsUsers = null;
|
||||
notifyDataSetChanged();
|
||||
delegate.needChangePanelVisibility(!newResult.isEmpty());
|
||||
} else if (foundType == 2) {
|
||||
ArrayList<String> newResult = new ArrayList<>();
|
||||
ArrayList<String> newResultHelp = new ArrayList<>();
|
||||
ArrayList<TLRPC.User> newResultUsers = new ArrayList<>();
|
||||
String command = result.toString().toLowerCase();
|
||||
for (HashMap.Entry<Integer, TLRPC.BotInfo> entry : botInfo.entrySet()) {
|
||||
for (TLRPC.TL_botCommand botCommand : entry.getValue().commands) {
|
||||
if (botCommand != null && botCommand.command != null && botCommand.command.startsWith(command)) {
|
||||
newResult.add("/" + botCommand.command);
|
||||
newResultHelp.add(botCommand.description);
|
||||
newResultUsers.add(MessagesController.getInstance().getUser(entry.getValue().user_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
searchResultHashtags = null;
|
||||
searchResultUsernames = null;
|
||||
searchResultCommands = newResult;
|
||||
searchResultCommandsHelp = newResultHelp;
|
||||
searchResultCommandsUsers = newResultUsers;
|
||||
notifyDataSetChanged();
|
||||
delegate.needChangePanelVisibility(!newResult.isEmpty());
|
||||
}
|
||||
@ -209,6 +255,8 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
return searchResultUsernames.size();
|
||||
} else if (searchResultHashtags != null) {
|
||||
return searchResultHashtags.size();
|
||||
} else if (searchResultCommands != null) {
|
||||
return searchResultCommands.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -219,6 +267,8 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
return searchResultUsernames.isEmpty();
|
||||
} else if (searchResultHashtags != null) {
|
||||
return searchResultHashtags.isEmpty();
|
||||
} else if (searchResultCommands != null) {
|
||||
return searchResultCommands.isEmpty();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -255,10 +305,26 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
return null;
|
||||
}
|
||||
return searchResultHashtags.get(i);
|
||||
} else if (searchResultCommands != null) {
|
||||
if (i < 0 || i >= searchResultCommands.size()) {
|
||||
return null;
|
||||
}
|
||||
if (searchResultCommandsUsers != null && botsCount != 1) {
|
||||
return String.format("%s@%s", searchResultCommands.get(i), searchResultCommandsUsers.get(i).username);
|
||||
}
|
||||
return searchResultCommands.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isLongClickEnabled() {
|
||||
return searchResultHashtags != null;
|
||||
}
|
||||
|
||||
public boolean isBotCommands() {
|
||||
return searchResultCommands != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
if (view == null) {
|
||||
@ -269,6 +335,8 @@ public class MentionsAdapter extends BaseSearchAdapter {
|
||||
((MentionCell) view).setUser(searchResultUsernames.get(i));
|
||||
} else if (searchResultHashtags != null) {
|
||||
((MentionCell) view).setText(searchResultHashtags.get(i));
|
||||
} else if (searchResultCommands != null) {
|
||||
((MentionCell) view).setBotCommand(searchResultCommands.get(i), searchResultCommandsHelp.get(i), searchResultCommandsUsers.get(i));
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
@ -13,12 +13,12 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Cells.GreySectionCell;
|
||||
|
@ -51,7 +51,7 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileDidFailedLoad);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
public void onDestroy() {
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidLoaded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileDidFailedLoad);
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
@ -90,7 +92,12 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.addItem(block_user, R.drawable.plus);
|
||||
//menu.addItem(block_user, R.drawable.plus);
|
||||
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable plus = getParentActivity().getResources().getDrawable(R.drawable.plus);
|
||||
plus.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
menu.addItem(block_user, plus);
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
@ -213,6 +220,18 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.SimpleTextView;
|
||||
|
||||
public class AddMemberCell extends FrameLayout {
|
||||
|
||||
private SimpleTextView textView;
|
||||
private ImageView imageView;
|
||||
|
||||
@ -34,11 +35,9 @@ public class AddMemberCell extends FrameLayout {
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 68, 8, LocaleController.isRTL ? 68 : 0, 0));
|
||||
|
||||
//SimpleTextView textView = new SimpleTextView(context);
|
||||
textView = new SimpleTextView(context);
|
||||
textView.setTextColor(0xff212121);
|
||||
textView.setTextSize(17);
|
||||
textView.setText(LocaleController.getString("AddMember", R.string.AddMember));
|
||||
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
|
||||
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 28 : 129, 22.5f, LocaleController.isRTL ? 129 : 28, 0));
|
||||
}
|
||||
@ -57,4 +56,8 @@ public class AddMemberCell extends FrameLayout {
|
||||
d.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
imageView.setImageDrawable(d);
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,11 @@ public class BaseCell extends View {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverlappingRendering() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void onLongPress() {
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ import android.view.SoundEffectConstants;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.Components.ProgressView;
|
||||
import org.telegram.ui.Components.ResourceLoader;
|
||||
import org.telegram.ui.Components.SeekBar;
|
||||
@ -149,14 +149,14 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
buttonState = 3;
|
||||
invalidate();
|
||||
} else if (buttonState == 3) {
|
||||
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
|
||||
buttonState = 2;
|
||||
invalidate();
|
||||
} else if (buttonState == 4) {
|
||||
if (currentMessageObject.isOut() && currentMessageObject.isSending()) {
|
||||
if (delegate != null) {
|
||||
delegate.didPressedCancelSendButton(this);
|
||||
}
|
||||
} else {
|
||||
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
|
||||
buttonState = 2;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -199,8 +199,16 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
if (currentMessageObject.isOut() && currentMessageObject.isSending()) {
|
||||
buttonState = 4;
|
||||
} else {
|
||||
String fileName = currentMessageObject.getFileName();
|
||||
File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
File cacheFile = null;
|
||||
if (currentMessageObject.messageOwner.attachPath != null && currentMessageObject.messageOwner.attachPath.length() > 0) {
|
||||
cacheFile = new File(currentMessageObject.messageOwner.attachPath);
|
||||
if(!cacheFile.exists()) {
|
||||
cacheFile = null;
|
||||
}
|
||||
}
|
||||
if (cacheFile == null) {
|
||||
cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
|
||||
}
|
||||
if (cacheFile.exists()) {
|
||||
MediaController.getInstance().removeLoadingFileObserver(this);
|
||||
boolean playing = MediaController.getInstance().isPlayingAudio(currentMessageObject);
|
||||
@ -211,6 +219,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
|
||||
}
|
||||
progressView.setProgress(0);
|
||||
} else {
|
||||
String fileName = currentMessageObject.getFileName();
|
||||
MediaController.getInstance().addLoadingFileObserver(fileName, this);
|
||||
if (!FileLoader.getInstance().isLoadingFile(fileName)) {
|
||||
buttonState = 2;
|
||||
|
@ -14,7 +14,6 @@ import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Layout;
|
||||
@ -26,18 +25,19 @@ import android.view.MotionEvent;
|
||||
import android.view.SoundEffectConstants;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.LinkPath;
|
||||
import org.telegram.ui.Components.ResourceLoader;
|
||||
import org.telegram.ui.Components.StaticLayoutEx;
|
||||
|
||||
@ -48,49 +48,14 @@ public class ChatBaseCell extends BaseCell {
|
||||
void didPressedCancelSendButton(ChatBaseCell cell);
|
||||
void didLongPressed(ChatBaseCell cell);
|
||||
void didPressReplyMessage(ChatBaseCell cell, int id);
|
||||
void didPressUrl(String url);
|
||||
void didPressUrl(MessageObject messageObject, String url);
|
||||
void needOpenWebView(String url, String title, String originalUrl, int w, int h);
|
||||
boolean canPerformActions();
|
||||
}
|
||||
|
||||
protected class MyPath extends Path {
|
||||
|
||||
private StaticLayout currentLayout;
|
||||
private int currentLine;
|
||||
private float lastTop = -1;
|
||||
|
||||
public void setCurrentLayout(StaticLayout layout, int start) {
|
||||
currentLayout = layout;
|
||||
currentLine = layout.getLineForOffset(start);
|
||||
lastTop = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRect(float left, float top, float right, float bottom, Direction dir) {
|
||||
if (lastTop == -1) {
|
||||
lastTop = top;
|
||||
} else if (lastTop != top) {
|
||||
lastTop = top;
|
||||
currentLine++;
|
||||
}
|
||||
float lineRight = currentLayout.getLineRight(currentLine);
|
||||
float lineLeft = currentLayout.getLineLeft(currentLine);
|
||||
if (left >= lineRight) {
|
||||
return;
|
||||
}
|
||||
if (right > lineRight) {
|
||||
right = lineRight;
|
||||
}
|
||||
if (left < lineLeft) {
|
||||
left = lineLeft;
|
||||
}
|
||||
super.addRect(left, top, right, bottom, dir);
|
||||
}
|
||||
}
|
||||
|
||||
protected ClickableSpan pressedLink;
|
||||
protected boolean linkPreviewPressed;
|
||||
protected MyPath urlPath = new MyPath();
|
||||
protected LinkPath urlPath = new LinkPath();
|
||||
protected static Paint urlPaint;
|
||||
|
||||
public boolean isChat = false;
|
||||
@ -370,7 +335,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
String newNameString = null;
|
||||
if (drawName && isChat && newUser != null && !currentMessageObject.isOut()) {
|
||||
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
||||
newNameString = UserObject.getUserName(newUser);
|
||||
}
|
||||
|
||||
if (currentNameString == null && newNameString != null || currentNameString != null && newNameString == null || currentNameString != null && newNameString != null && !currentNameString.equals(newNameString)) {
|
||||
@ -380,7 +345,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.fwd_from_id);
|
||||
newNameString = null;
|
||||
if (newUser != null && drawForwardedName && currentMessageObject.messageOwner.fwd_from_id != 0) {
|
||||
newNameString = ContactsController.formatName(newUser.first_name, newUser.last_name);
|
||||
newNameString = UserObject.getUserName(newUser);
|
||||
}
|
||||
return currentForwardNameString == null && newNameString != null || currentForwardNameString != null && newNameString == null || currentForwardNameString != null && newNameString != null && !currentForwardNameString.equals(newNameString);
|
||||
}
|
||||
@ -451,7 +416,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
namesOffset = 0;
|
||||
|
||||
if (drawName && isChat && currentUser != null && !currentMessageObject.isOut()) {
|
||||
currentNameString = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
|
||||
currentNameString = UserObject.getUserName(currentUser);
|
||||
nameWidth = getMaxNameWidth();
|
||||
|
||||
CharSequence nameStringFinal = TextUtils.ellipsize(currentNameString.replace("\n", " "), namePaint, nameWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
@ -472,7 +437,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
if (drawForwardedName && messageObject.isForwarded()) {
|
||||
currentForwardUser = MessagesController.getInstance().getUser(messageObject.messageOwner.fwd_from_id);
|
||||
if (currentForwardUser != null) {
|
||||
currentForwardNameString = ContactsController.formatName(currentForwardUser.first_name, currentForwardUser.last_name);
|
||||
currentForwardNameString = UserObject.getUserName(currentForwardUser);
|
||||
|
||||
forwardedNameWidth = getMaxNameWidth();
|
||||
|
||||
@ -553,7 +518,7 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(messageObject.replyMessageObject.messageOwner.from_id);
|
||||
if (user != null) {
|
||||
stringFinalName = TextUtils.ellipsize(ContactsController.formatName(user.first_name, user.last_name).replace("\n", " "), replyNamePaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END);
|
||||
stringFinalName = TextUtils.ellipsize(UserObject.getUserName(user).replace("\n", " "), replyNamePaint, maxWidth - AndroidUtilities.dp(8), TextUtils.TruncateAt.END);
|
||||
}
|
||||
if (messageObject.replyMessageObject.messageText != null && messageObject.replyMessageObject.messageText.length() > 0) {
|
||||
String mess = messageObject.replyMessageObject.messageText.toString();
|
||||
@ -726,7 +691,6 @@ public class ChatBaseCell extends BaseCell {
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
if (currentMessageObject == null) {
|
||||
return;
|
||||
}
|
||||
@ -945,7 +909,6 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
|
||||
if (drawClock) {
|
||||
//ResourceLoader.clockDrawable = ResourceLoader.clockMediaDrawable;
|
||||
if (!media) {
|
||||
setDrawableBounds(ResourceLoader.clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - ResourceLoader.clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - ResourceLoader.clockDrawable.getIntrinsicHeight());
|
||||
ResourceLoader.clockDrawable.draw(canvas);
|
||||
@ -966,7 +929,6 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
} else {
|
||||
if (drawCheck2) {
|
||||
//ResourceLoader.checkDrawable = ResourceLoader.checkMediaDrawable;
|
||||
if (!media) {
|
||||
if (drawCheck1) {
|
||||
setDrawableBounds(ResourceLoader.checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - ResourceLoader.checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.checkDrawable.getIntrinsicHeight());
|
||||
@ -984,7 +946,6 @@ public class ChatBaseCell extends BaseCell {
|
||||
}
|
||||
}
|
||||
if (drawCheck1) {
|
||||
//ResourceLoader.halfCheckDrawable = ResourceLoader.halfCheckMediaDrawable;
|
||||
if (!media) {
|
||||
setDrawableBounds(ResourceLoader.halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - ResourceLoader.halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.0f) - ResourceLoader.halfCheckDrawable.getIntrinsicHeight());
|
||||
ResourceLoader.halfCheckDrawable.draw(canvas);
|
||||
|
@ -9,6 +9,7 @@
|
||||
package org.telegram.ui.Cells;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Layout;
|
||||
@ -25,6 +26,7 @@ import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
@ -283,6 +285,12 @@ public class ChatContactCell extends ChatBaseCell {
|
||||
canvas.restore();
|
||||
}
|
||||
if (phoneLayout != null) {
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int color = themePrefs.getInt("chatLTextColor", 0xff000000);
|
||||
if (currentMessageObject.isOut()) {
|
||||
color = themePrefs.getInt("chatRTextColor", 0xff000000);
|
||||
}
|
||||
phonePaint.setColor(color);
|
||||
canvas.save();
|
||||
canvas.translate(avatarImage.getImageX() + avatarImage.getImageWidth() + AndroidUtilities.dp(9), AndroidUtilities.dp(31) + namesOffset);
|
||||
phoneLayout.draw(canvas);
|
||||
|
@ -34,6 +34,7 @@ import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
@ -187,7 +188,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
boolean result = false;
|
||||
int side = AndroidUtilities.dp(48);
|
||||
if (currentMessageObject.caption instanceof Spannable && !isPressed) {
|
||||
if (currentMessageObject.caption instanceof Spannable && delegate.canPerformActions()) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN || (linkPreviewPressed || pressedLink != null) && event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (nameLayout != null && x >= captionX && x <= captionX + backgroundWidth && y >= captionY && y <= captionY + captionHeight) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
@ -228,9 +229,9 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
try {
|
||||
if (pressedLink instanceof URLSpanNoUnderline) {
|
||||
String url = ((URLSpanNoUnderline) pressedLink).getURL();
|
||||
if (url.startsWith("@") || url.startsWith("#")) {
|
||||
if (url.startsWith("@") || url.startsWith("#") || url.startsWith("/")) {
|
||||
if (delegate != null) {
|
||||
delegate.didPressUrl(url);
|
||||
delegate.didPressUrl(currentMessageObject, url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -554,7 +555,17 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
|
||||
if(isChat){
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
//String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
String senderName = "";
|
||||
if (UserObject.isDeleted(fromUser)) {
|
||||
senderName = "Deleted";
|
||||
} else {
|
||||
if (fromUser.first_name != null && fromUser.first_name.length() > 0) {
|
||||
senderName = fromUser.first_name;
|
||||
} else {
|
||||
senderName = fromUser.last_name;
|
||||
}
|
||||
}
|
||||
infoWidth2 = Math.min(maxWidth, (int) Math.ceil(senderPaint.measureText(senderName)));
|
||||
CharSequence str2 = TextUtils.ellipsize(senderName, senderPaint, infoWidth2, TextUtils.TruncateAt.END);
|
||||
infoLayout2 = new StaticLayout(str2, senderPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
@ -607,7 +618,16 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||
}//Plus: member name in photos
|
||||
else if (messageObject.type == 1) { //PHOTO
|
||||
TLRPC.User fromUser = MessagesController.getInstance().getUser(messageObject.messageOwner.from_id);
|
||||
String senderName = String.format("%s %s", fromUser.first_name, fromUser.last_name);
|
||||
String senderName = "";
|
||||
if (UserObject.isDeleted(fromUser)) {
|
||||
senderName = "Deleted";
|
||||
} else {
|
||||
if (fromUser.first_name != null && fromUser.first_name.length() > 0) {
|
||||
senderName = fromUser.first_name;
|
||||
} else {
|
||||
senderName = fromUser.last_name;
|
||||
}
|
||||
}
|
||||
if (currentInfoString == null || !currentInfoString.equals(senderName)) {
|
||||
currentInfoString = senderName;
|
||||
infoOffset = 0;
|
||||
|
@ -29,10 +29,10 @@ import android.view.MotionEvent;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Components.ResourceLoader;
|
||||
@ -81,7 +81,7 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
boolean result = false;
|
||||
if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !isPressed) {
|
||||
if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && delegate.canPerformActions()) {
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN || (linkPreviewPressed || pressedLink != null) && event.getAction() == MotionEvent.ACTION_UP) {
|
||||
int x = (int) event.getX();
|
||||
int y = (int) event.getY();
|
||||
@ -118,9 +118,9 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
try {
|
||||
if (pressedLink instanceof URLSpanNoUnderline) {
|
||||
String url = ((URLSpanNoUnderline) pressedLink).getURL();
|
||||
if (url.startsWith("@") || url.startsWith("#")) {
|
||||
if (url.startsWith("@") || url.startsWith("#") || url.startsWith("/")) {
|
||||
if (delegate != null) {
|
||||
delegate.didPressUrl(url);
|
||||
delegate.didPressUrl(currentMessageObject, url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -620,7 +620,7 @@ public class ChatMessageCell extends ChatBaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
if (webPage.duration != 0) {
|
||||
if (webPage.type != null && webPage.type.equals("video") && webPage.duration != 0) {
|
||||
if (durationPaint == null) {
|
||||
durationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
||||
durationPaint.setTextSize(AndroidUtilities.dp(12));
|
||||
|
@ -29,6 +29,7 @@ import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
@ -36,6 +37,8 @@ import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DialogCell extends BaseCell {
|
||||
|
||||
private static TextPaint namePaint;
|
||||
@ -72,7 +75,7 @@ public class DialogCell extends BaseCell {
|
||||
private boolean dialogMuted;
|
||||
private MessageObject message;
|
||||
private int index;
|
||||
private boolean isServerOnly;
|
||||
private int dialogsType;
|
||||
|
||||
private ImageReceiver avatarImage;
|
||||
private AvatarDrawable avatarDrawable;
|
||||
@ -128,6 +131,7 @@ public class DialogCell extends BaseCell {
|
||||
|
||||
public DialogCell(Context context) {
|
||||
super(context);
|
||||
|
||||
if (namePaint == null) {
|
||||
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
|
||||
namePaint.setTextSize(AndroidUtilities.dp(17));
|
||||
@ -201,11 +205,11 @@ public class DialogCell extends BaseCell {
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
public void setDialog(TLRPC.TL_dialog dialog, int i, boolean server) {
|
||||
public void setDialog(TLRPC.TL_dialog dialog, int i, int type) {
|
||||
currentDialogId = dialog.id;
|
||||
isDialogCell = true;
|
||||
index = i;
|
||||
isServerOnly = server;
|
||||
dialogsType = type;
|
||||
update(0);
|
||||
}
|
||||
|
||||
@ -376,12 +380,14 @@ public class DialogCell extends BaseCell {
|
||||
currentMessagePaint = messagePrintingPaint;
|
||||
} else {
|
||||
if (chat != null && chat.id > 0) {
|
||||
String name = "";
|
||||
String name;
|
||||
if (message.isOut()) {
|
||||
name = LocaleController.getString("FromYou", R.string.FromYou);
|
||||
} else {
|
||||
if (fromUser != null) {
|
||||
if (fromUser.first_name.length() > 0) {
|
||||
if (UserObject.isDeleted(fromUser)) {
|
||||
name = "Deleted";
|
||||
} else {
|
||||
if (fromUser.first_name != null && fromUser.first_name.length() > 0) {
|
||||
name = fromUser.first_name;
|
||||
} else {
|
||||
name = fromUser.last_name;
|
||||
@ -487,17 +493,17 @@ public class DialogCell extends BaseCell {
|
||||
} else if (user != null) {
|
||||
if (user.id / 1000 != 777 && user.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(user.id) == null) {
|
||||
if (ContactsController.getInstance().contactsDict.size() == 0 && (!ContactsController.getInstance().contactsLoaded || ContactsController.getInstance().isLoadingContacts())) {
|
||||
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
||||
nameString = UserObject.getUserName(user);
|
||||
} else {
|
||||
if (user.phone != null && user.phone.length() != 0) {
|
||||
nameString = PhoneFormat.getInstance().format("+" + user.phone);
|
||||
} else {
|
||||
currentNamePaint = nameUnknownPaint;
|
||||
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
||||
nameString = UserObject.getUserName(user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nameString = ContactsController.formatName(user.first_name, user.last_name);
|
||||
nameString = UserObject.getUserName(user);
|
||||
}
|
||||
if (encryptedChat != null) {
|
||||
currentNamePaint = nameEncryptedPaint;
|
||||
@ -684,18 +690,20 @@ public class DialogCell extends BaseCell {
|
||||
isSelected = value;
|
||||
}
|
||||
|
||||
private ArrayList<TLRPC.TL_dialog> getDialogsArray() {
|
||||
if (dialogsType == 0) {
|
||||
return MessagesController.getInstance().dialogs;
|
||||
} else if (dialogsType == 1) {
|
||||
return MessagesController.getInstance().dialogsServerOnly;
|
||||
} else if (dialogsType == 2) {
|
||||
return MessagesController.getInstance().dialogsGroupsOnly;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void checkCurrentDialogIndex() {
|
||||
TLRPC.TL_dialog dialog = null;
|
||||
if (isServerOnly) {
|
||||
if (index < MessagesController.getInstance().dialogsServerOnly.size()) {
|
||||
dialog = MessagesController.getInstance().dialogsServerOnly.get(index);
|
||||
}
|
||||
} else {
|
||||
if (index < MessagesController.getInstance().dialogs.size()) {
|
||||
dialog = MessagesController.getInstance().dialogs.get(index);
|
||||
}
|
||||
}
|
||||
if (dialog != null) {
|
||||
if (index < getDialogsArray().size()) {
|
||||
TLRPC.TL_dialog dialog = getDialogsArray().get(index);
|
||||
if (currentDialogId != dialog.id || message != null && message.getId() != dialog.top_message || unreadCount != dialog.unread_count) {
|
||||
currentDialogId = dialog.id;
|
||||
update(0);
|
||||
@ -863,7 +871,7 @@ public class DialogCell extends BaseCell {
|
||||
|
||||
countDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.SRC_IN);
|
||||
|
||||
nColor = themePrefs.getInt("chatsNameColor", 0xff000000);
|
||||
nColor = themePrefs.getInt("chatsGroupIconColor", themePrefs.getInt("chatsGroupNameColor", 0xff000000));
|
||||
groupDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN);
|
||||
broadcastDrawable.setColorFilter(nColor, PorterDuff.Mode.SRC_IN);
|
||||
|
||||
@ -945,7 +953,11 @@ public class DialogCell extends BaseCell {
|
||||
setDrawableBounds(errorDrawable, errorLeft, errorTop);
|
||||
errorDrawable.draw(canvas);
|
||||
} else if (drawCount) {
|
||||
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int size = themePrefs.getInt("chatsCountSize", 13);
|
||||
size = size > 13 ? (size - 13) / 2 : 0;
|
||||
//setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop, countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
|
||||
setDrawableBounds(countDrawable, countLeft - AndroidUtilities.dp(5.5f), countTop + AndroidUtilities.dp(size), countWidth + AndroidUtilities.dp(11), countDrawable.getIntrinsicHeight());
|
||||
countDrawable.draw(canvas);
|
||||
canvas.save();
|
||||
canvas.translate(countLeft, countTop + AndroidUtilities.dp(4));
|
||||
|
@ -28,9 +28,9 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
@ -63,7 +63,10 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
|
||||
|
||||
avatarImageView = new BackupImageView(context);
|
||||
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
|
||||
addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int aSize = themePrefs.getInt("drawerAvatarSize", 64);
|
||||
//addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
|
||||
addView(avatarImageView, LayoutHelper.createFrame(aSize, aSize, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
|
||||
|
||||
final Activity activity = (Activity) context;
|
||||
avatarImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@ -156,7 +159,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
|
||||
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
|
||||
avatarDrawable.setColor(0xff5c98cd);
|
||||
@ -238,6 +241,8 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
|
||||
avatarDrawable.setColor(themePrefs.getInt("drawerAvatarColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
|
||||
int radius = AndroidUtilities.dp(themePrefs.getInt("drawerAvatarRadius", 32));
|
||||
avatarDrawable.setRadius(radius);
|
||||
//avatarImageView.getImageReceiver().setImageCoords(avatarImageView.getImageReceiver(), avatarTop, avatarSize, avatarSize);
|
||||
|
||||
avatarImageView.getImageReceiver().setRoundRadius(radius);
|
||||
avatarImageView.setImage(photo, "50_50", avatarDrawable);
|
||||
if(AndroidUtilities.getBoolMain("hideMobile")){
|
||||
|
@ -16,7 +16,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
@ -55,7 +55,7 @@ public class MentionCell extends LinearLayout {
|
||||
usernameTextView.setSingleLine(true);
|
||||
usernameTextView.setGravity(Gravity.LEFT);
|
||||
usernameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
addView(usernameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 0, 0));
|
||||
addView(usernameTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, 12, 0, 8, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,7 +76,7 @@ public class MentionCell extends LinearLayout {
|
||||
} else {
|
||||
imageView.setImageDrawable(avatarDrawable);
|
||||
}
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
usernameTextView.setText("@" + user.username);
|
||||
imageView.setVisibility(VISIBLE);
|
||||
usernameTextView.setVisibility(VISIBLE);
|
||||
@ -88,6 +88,23 @@ public class MentionCell extends LinearLayout {
|
||||
nameTextView.setText(text);
|
||||
}
|
||||
|
||||
public void setBotCommand(String command, String help, TLRPC.User user) {
|
||||
if (user != null) {
|
||||
imageView.setVisibility(VISIBLE);
|
||||
avatarDrawable.setInfo(user);
|
||||
if (user.photo != null && user.photo.photo_small != null) {
|
||||
imageView.setImage(user.photo.photo_small, "50_50", avatarDrawable);
|
||||
} else {
|
||||
imageView.setImageDrawable(avatarDrawable);
|
||||
}
|
||||
} else {
|
||||
imageView.setVisibility(INVISIBLE);
|
||||
}
|
||||
usernameTextView.setVisibility(VISIBLE);
|
||||
nameTextView.setText(command);
|
||||
usernameTextView.setText(help);
|
||||
}
|
||||
|
||||
public void setIsDarkTheme(boolean isDarkTheme) {
|
||||
if (isDarkTheme) {
|
||||
nameTextView.setTextColor(0xffffffff);
|
||||
|
@ -26,6 +26,7 @@ import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.R;
|
||||
@ -207,7 +208,7 @@ public class ProfileSearchCell extends BaseCell {
|
||||
if (chat != null) {
|
||||
nameString2 = chat.title;
|
||||
} else if (user != null) {
|
||||
nameString2 = ContactsController.formatName(user.first_name, user.last_name);
|
||||
nameString2 = UserObject.getUserName(user);
|
||||
}
|
||||
nameString = nameString2.replace("\n", " ");
|
||||
}
|
||||
@ -254,6 +255,9 @@ public class ProfileSearchCell extends BaseCell {
|
||||
|
||||
if (subLabel != null) {
|
||||
onlineString = subLabel;
|
||||
} else {
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
onlineString = LocaleController.getString("Bot", R.string.Bot);
|
||||
} else {
|
||||
onlineString = LocaleController.formatUserStatus(user);
|
||||
if (user != null && (user.id == UserConfig.getClientUserId() || user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime())) {
|
||||
@ -261,6 +265,7 @@ public class ProfileSearchCell extends BaseCell {
|
||||
onlineString = LocaleController.getString("Online", R.string.Online);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CharSequence onlineStringFinal = TextUtils.ellipsize(onlineString, currentOnlinePaint, onlineWidth - AndroidUtilities.dp(12), TextUtils.TruncateAt.END);
|
||||
onlineLayout = new StaticLayout(onlineStringFinal, currentOnlinePaint, onlineWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
||||
|
@ -212,7 +212,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.F
|
||||
placeholderImabeView.setImageResource(getThumbForNameOrMime(name, document.messageOwner.media.document.mime_type));
|
||||
nameTextView.setText(name);
|
||||
extTextView.setText((idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase());
|
||||
if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty) {
|
||||
if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty || document.messageOwner.media.document.thumb == null) {
|
||||
thumbImageView.setVisibility(INVISIBLE);
|
||||
thumbImageView.setImageBitmap(null);
|
||||
} else {
|
||||
|
@ -83,7 +83,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
|
||||
|
||||
checkBox = new CheckBox(context, R.drawable.round_check2);
|
||||
checkBox.setVisibility(INVISIBLE);
|
||||
addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 6, 0, 6, 0));
|
||||
addView(checkBox, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 6, 6, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,6 +28,8 @@ public class TextCell extends FrameLayout {
|
||||
private ImageView imageView;
|
||||
private ImageView valueImageView;
|
||||
|
||||
private boolean multiline;
|
||||
|
||||
public TextCell(Context context) {
|
||||
super(context);
|
||||
|
||||
@ -62,7 +64,7 @@ public class TextCell extends FrameLayout {
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
super.onMeasure(widthMeasureSpec, multiline ? MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED) : MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(48), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
public void setTextColor(int color) {
|
||||
@ -84,6 +86,22 @@ public class TextCell extends FrameLayout {
|
||||
valueImageView.setVisibility(INVISIBLE);
|
||||
}
|
||||
|
||||
public void setMultiline(boolean value) {
|
||||
if (multiline == value) {
|
||||
return;
|
||||
}
|
||||
multiline = value;
|
||||
if (value) {
|
||||
textView.setSingleLine(false);
|
||||
textView.setPadding(0, AndroidUtilities.dp(6), 0, AndroidUtilities.dp(6));
|
||||
} else {
|
||||
textView.setLines(1);
|
||||
textView.setMaxLines(1);
|
||||
textView.setSingleLine(true);
|
||||
}
|
||||
requestLayout();
|
||||
}
|
||||
|
||||
public void setTextSize(int size) {
|
||||
textView.setTextSize(size);
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.R;
|
||||
@ -149,7 +149,7 @@ public class UserCell extends FrameLayout {
|
||||
}
|
||||
}
|
||||
if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
|
||||
newName = ContactsController.formatName(currentUser.first_name, currentUser.last_name);
|
||||
newName = UserObject.getUserName(currentUser);
|
||||
if (!newName.equals(lastName)) {
|
||||
continueUpdate = true;
|
||||
}
|
||||
@ -170,7 +170,7 @@ public class UserCell extends FrameLayout {
|
||||
lastName = null;
|
||||
nameTextView.setText(currentName);
|
||||
} else {
|
||||
lastName = newName == null ? ContactsController.formatName(currentUser.first_name, currentUser.last_name) : newName;
|
||||
lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
|
||||
nameTextView.setText(lastName);
|
||||
nameTextView.setTextColor(nameColor);
|
||||
nameTextView.setTextSize(themePrefs.getInt("contactsNameSize", 17));
|
||||
@ -179,7 +179,15 @@ public class UserCell extends FrameLayout {
|
||||
statusTextView.setTextColor(statusColor);
|
||||
statusTextView.setText(currrntStatus);
|
||||
} else {
|
||||
if (currentUser.id == UserConfig.getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance().getCurrentTime()) {
|
||||
if ((currentUser.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
statusTextView.setTextColor(statusColor);
|
||||
if ((currentUser.flags & TLRPC.USER_FLAG_BOT_READING_HISTORY) != 0) {
|
||||
statusTextView.setText(LocaleController.getString("BotStatusRead", R.string.BotStatusRead));
|
||||
} else {
|
||||
statusTextView.setText(LocaleController.getString("BotStatusCantRead", R.string.BotStatusCantRead));
|
||||
}
|
||||
} else {
|
||||
if (currentUser.id == UserConfig.getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance().getCurrentTime() || MessagesController.getInstance().onlinePrivacy.containsKey(currentUser.id)) {
|
||||
statusTextView.setTextColor(statusOnlineColor);
|
||||
statusTextView.setText(LocaleController.getString("Online", R.string.Online));
|
||||
} else {
|
||||
@ -187,6 +195,7 @@ public class UserCell extends FrameLayout {
|
||||
statusTextView.setText(LocaleController.formatUserStatus(currentUser));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (imageView.getVisibility() == VISIBLE && currentDrawable == 0 || imageView.getVisibility() == GONE && currentDrawable != 0) {
|
||||
imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE);
|
||||
|
@ -12,6 +12,7 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
@ -28,10 +29,10 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
@ -77,7 +78,11 @@ public class ChangeChatNameActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
doneButton = menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
|
||||
|
||||
@ -137,6 +142,21 @@ public class ChangeChatNameActivity extends BaseFragment {
|
||||
firstNameField.requestFocus();
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,6 +12,7 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.InputType;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
@ -27,14 +28,14 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.TLObject;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
@ -70,7 +71,12 @@ public class ChangeNameActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
doneButton = menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||
if (user == null) {
|
||||
@ -157,6 +163,18 @@ public class ChangeNameActivity extends BaseFragment {
|
||||
firstNameField.requestFocus();
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private void saveName() {
|
||||
|
@ -12,7 +12,9 @@ import android.annotation.SuppressLint;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.Editable;
|
||||
@ -39,10 +41,6 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
@ -59,6 +57,10 @@ import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.SlideView;
|
||||
import org.telegram.ui.Components.TypefaceSpan;
|
||||
@ -118,7 +120,12 @@ public class ChangePhoneActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
fragmentView = new ScrollView(context);
|
||||
ScrollView scrollView = (ScrollView) fragmentView;
|
||||
@ -164,6 +171,18 @@ public class ChangePhoneActivity extends BaseFragment {
|
||||
if (!AndroidUtilities.isTablet()) {
|
||||
getParentActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -499,7 +518,7 @@ public class ChangePhoneActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setText(LocaleController.getString("StartText", R.string.StartText));
|
||||
textView.setText(LocaleController.getString("ChangePhoneHelp", R.string.ChangePhoneHelp));
|
||||
textView.setTextColor(0xff757575);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setGravity(Gravity.LEFT);
|
||||
|
@ -15,6 +15,7 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
@ -79,7 +80,12 @@ public class ChangeUsernameActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
doneButton = menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
|
||||
if (user == null) {
|
||||
@ -194,6 +200,18 @@ public class ChangeUsernameActivity extends BaseFragment {
|
||||
firstNameField.requestFocus();
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private void showErrorAlert(String error) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,15 +19,15 @@ import android.provider.MediaStore;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.LaunchActivity;
|
||||
import org.telegram.ui.PhotoAlbumPickerActivity;
|
||||
import org.telegram.ui.PhotoCropActivity;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
|
||||
import java.io.File;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -18,8 +18,8 @@ import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
|
||||
public class ClippingImageView extends View {
|
||||
|
||||
|
@ -12,14 +12,17 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.DataSetObserver;
|
||||
import android.os.Build;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.GridView;
|
||||
@ -28,6 +31,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
@ -36,6 +40,7 @@ import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Cells.EmptyCell;
|
||||
import org.telegram.ui.Cells.StickerEmojiCell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -43,7 +48,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class EmojiView extends LinearLayout implements NotificationCenter.NotificationCenterDelegate {
|
||||
public class EmojiView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
public interface Listener {
|
||||
boolean onBackspace();
|
||||
@ -52,9 +57,9 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
}
|
||||
|
||||
private ArrayList<EmojiGridAdapter> adapters = new ArrayList<>();
|
||||
private StickersGridAdapter stickersGridAdapter;
|
||||
private HashMap<Long, Integer> stickersUseHistory = new HashMap<>();
|
||||
private ArrayList<TLRPC.Document> stickers;
|
||||
private ArrayList<TLRPC.Document> recentStickers = new ArrayList<>();
|
||||
private ArrayList<TLRPC.TL_messages_stickerSet> stickerSets = new ArrayList<>();
|
||||
|
||||
private int[] icons = {
|
||||
R.drawable.ic_emoji_recent,
|
||||
@ -68,9 +73,15 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
private Listener listener;
|
||||
private ViewPager pager;
|
||||
private FrameLayout recentsWrap;
|
||||
private FrameLayout emojiWrap;
|
||||
private FrameLayout stickersWrap;
|
||||
private ArrayList<GridView> views = new ArrayList<>();
|
||||
private ImageView backspaceButton;
|
||||
private StickersGridAdapter stickersGridAdapter;
|
||||
private LinearLayout pagerSlidingTabStripContainer;
|
||||
private ScrollSlidingTabStrip scrollSlidingTabStrip;
|
||||
|
||||
private int oldWidth;
|
||||
private int lastNotifyWidth;
|
||||
|
||||
private boolean backspacePressed;
|
||||
private boolean backspaceOnce;
|
||||
@ -84,7 +95,7 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
int bgColor = themePrefs.getInt("chatEmojiViewBGColor", 0xfff5f6f7);
|
||||
int tabColor = themePrefs.getInt("chatEmojiViewTabColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x15));
|
||||
int lineColor = bgColor == 0xfff5f6f7 ? 0xffe2e5e7 : AndroidUtilities.setDarkColor(bgColor, 0x10);
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
//setOrientation(LinearLayout.VERTICAL);
|
||||
for (int i = 0; i < Emoji.data.length; i++) {
|
||||
GridView gridView = new GridView(context);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
@ -104,7 +115,6 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
|
||||
if (showStickers) {
|
||||
StickersQuery.checkStickers();
|
||||
stickers = StickersQuery.getStickers();
|
||||
GridView gridView = new GridView(context);
|
||||
gridView.setColumnWidth(AndroidUtilities.dp(72));
|
||||
gridView.setNumColumns(-1);
|
||||
@ -115,33 +125,187 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
gridView.setAdapter(stickersGridAdapter);
|
||||
//AndroidUtilities.setListViewEdgeEffectColor(gridView, 0xfff5f6f7);
|
||||
AndroidUtilities.setListViewEdgeEffectColor(gridView, bgColor);
|
||||
stickersWrap = new FrameLayout(context);
|
||||
stickersWrap.addView(gridView);
|
||||
|
||||
|
||||
TextView textView = new TextView(context);
|
||||
textView.setText(LocaleController.getString("NoStickers", R.string.NoStickers));
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
textView.setTextColor(0xff888888);
|
||||
stickersWrap.addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
gridView.setEmptyView(textView);
|
||||
|
||||
scrollSlidingTabStrip = new ScrollSlidingTabStrip(context) {
|
||||
|
||||
boolean startedScroll;
|
||||
float lastX;
|
||||
float lastTranslateX;
|
||||
boolean first = true;
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (getParent() != null) {
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
if (first) {
|
||||
first = false;
|
||||
lastX = ev.getX();
|
||||
}
|
||||
float newTranslationX = ViewProxy.getTranslationX(scrollSlidingTabStrip);
|
||||
if (scrollSlidingTabStrip.getScrollX() == 0 && newTranslationX == 0) {
|
||||
if (!startedScroll && lastX - ev.getX() < 0) {
|
||||
if (pager.beginFakeDrag()) {
|
||||
startedScroll = true;
|
||||
lastTranslateX = ViewProxy.getTranslationX(scrollSlidingTabStrip);
|
||||
}
|
||||
} else if (startedScroll && lastX - ev.getX() > 0) {
|
||||
if (pager.isFakeDragging()) {
|
||||
pager.endFakeDrag();
|
||||
startedScroll = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (startedScroll) {
|
||||
int dx = (int) (ev.getX() - lastX + newTranslationX - lastTranslateX);
|
||||
try {
|
||||
pager.fakeDragBy(dx);
|
||||
lastTranslateX = newTranslationX;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
pager.endFakeDrag();
|
||||
} catch (Exception e2) {
|
||||
//don't promt
|
||||
}
|
||||
startedScroll = false;
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
lastX = ev.getX();
|
||||
if (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP) {
|
||||
first = true;
|
||||
if (startedScroll) {
|
||||
pager.endFakeDrag();
|
||||
startedScroll = false;
|
||||
}
|
||||
}
|
||||
return startedScroll || super.onTouchEvent(ev);
|
||||
}
|
||||
return super.onTouchEvent(ev);
|
||||
}
|
||||
};
|
||||
scrollSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1));
|
||||
//scrollSlidingTabStrip.setIndicatorColor(0xffe2e5e7);
|
||||
//scrollSlidingTabStrip.setUnderlineColor(0xffe2e5e7);
|
||||
scrollSlidingTabStrip.setIndicatorColor(tabColor);
|
||||
scrollSlidingTabStrip.setUnderlineColor(lineColor);
|
||||
addView(scrollSlidingTabStrip, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP));
|
||||
ViewProxy.setTranslationX(scrollSlidingTabStrip, AndroidUtilities.displaySize.x);
|
||||
updateStickerTabs();
|
||||
scrollSlidingTabStrip.setDelegate(new ScrollSlidingTabStrip.ScrollSlidingTabStripDelegate() {
|
||||
@Override
|
||||
public void onPageSelected(int page) {
|
||||
if (page == 0) {
|
||||
pager.setCurrentItem(0);
|
||||
return;
|
||||
} else if (page == 1 && !recentStickers.isEmpty()) {
|
||||
views.get(6).setSelection(0);
|
||||
return;
|
||||
}
|
||||
int index = page - (recentStickers.isEmpty() ? 1 : 2);
|
||||
if (index >= stickerSets.size()) {
|
||||
index = stickerSets.size() - 1;
|
||||
}
|
||||
views.get(6).setSelection(stickersGridAdapter.getPositionForPack(stickerSets.get(index)));
|
||||
}
|
||||
});
|
||||
|
||||
gridView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
|
||||
int count = view.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = view.getChildAt(a);
|
||||
if (child.getHeight() + child.getTop() < AndroidUtilities.dp(5)) {
|
||||
firstVisibleItem++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
scrollSlidingTabStrip.onPageScrolled(stickersGridAdapter.getTabForPosition(firstVisibleItem) + 1, 0);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//setBackgroundColor(0xfff5f6f7);
|
||||
setBackgroundColor(bgColor);
|
||||
|
||||
pager = new ViewPager(context);
|
||||
pager = new ViewPager(context) {
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (getParent() != null) {
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
};
|
||||
pager.setAdapter(new EmojiPagesAdapter());
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
//linearLayout.setBackgroundColor(0xfff5f6f7);
|
||||
linearLayout.setBackgroundColor(bgColor);
|
||||
addView(linearLayout, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtilities.dp(48)));
|
||||
pagerSlidingTabStripContainer = new LinearLayout(context) {
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
if (getParent() != null) {
|
||||
getParent().requestDisallowInterceptTouchEvent(true);
|
||||
}
|
||||
return super.onInterceptTouchEvent(ev);
|
||||
}
|
||||
};
|
||||
pagerSlidingTabStripContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||
//pagerSlidingTabStripContainer.setBackgroundColor(0xfff5f6f7);
|
||||
pagerSlidingTabStripContainer.setBackgroundColor(bgColor);
|
||||
addView(pagerSlidingTabStripContainer, LayoutHelper.createFrame(LayoutParams.MATCH_PARENT, 48));
|
||||
|
||||
PagerSlidingTabStrip tabs = new PagerSlidingTabStrip(context);
|
||||
tabs.setViewPager(pager);
|
||||
tabs.setShouldExpand(true);
|
||||
tabs.setIndicatorHeight(AndroidUtilities.dp(2));
|
||||
tabs.setUnderlineHeight(AndroidUtilities.dp(1));
|
||||
//tabs.setIndicatorColor(0xff2b96e2);
|
||||
tabs.setIndicatorColor(tabColor);
|
||||
//tabs.setUnderlineColor(0xffe2e5e7);
|
||||
tabs.setUnderlineColor(lineColor);
|
||||
linearLayout.addView(tabs, new LinearLayout.LayoutParams(0, AndroidUtilities.dp(48), 1.0f));
|
||||
PagerSlidingTabStrip pagerSlidingTabStrip = new PagerSlidingTabStrip(context);
|
||||
pagerSlidingTabStrip.setViewPager(pager);
|
||||
pagerSlidingTabStrip.setShouldExpand(true);
|
||||
pagerSlidingTabStrip.setIndicatorHeight(AndroidUtilities.dp(2));
|
||||
pagerSlidingTabStrip.setUnderlineHeight(AndroidUtilities.dp(1));
|
||||
//pagerSlidingTabStrip.setIndicatorColor(0xff2b96e2);
|
||||
//pagerSlidingTabStrip.setUnderlineColor(0xffe2e5e7);
|
||||
pagerSlidingTabStrip.setIndicatorColor(tabColor);
|
||||
pagerSlidingTabStrip.setUnderlineColor(lineColor);
|
||||
pagerSlidingTabStripContainer.addView(pagerSlidingTabStrip, LayoutHelper.createLinear(0, 48, 1.0f));
|
||||
pagerSlidingTabStrip.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
EmojiView.this.onPageScrolled(position, getMeasuredWidth(), positionOffsetPixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
linearLayout.addView(frameLayout, new LinearLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));
|
||||
pagerSlidingTabStripContainer.addView(frameLayout, LayoutHelper.createLinear(52, 48));
|
||||
|
||||
backspaceButton = new ImageView(context) {
|
||||
@Override
|
||||
@ -165,12 +329,12 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
backspaceButton.setImageResource(R.drawable.ic_smiles_backspace);
|
||||
backspaceButton.setBackgroundResource(R.drawable.ic_emoji_backspace);
|
||||
backspaceButton.setScaleType(ImageView.ScaleType.CENTER);
|
||||
frameLayout.addView(backspaceButton, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(48)));
|
||||
frameLayout.addView(backspaceButton, LayoutHelper.createFrame(52, 48));
|
||||
|
||||
View view = new View(context);
|
||||
//view.setBackgroundColor(0xffe2e5e7);
|
||||
view.setBackgroundColor(lineColor);
|
||||
frameLayout.addView(view, new FrameLayout.LayoutParams(AndroidUtilities.dp(52), AndroidUtilities.dp(1), Gravity.LEFT | Gravity.BOTTOM));
|
||||
frameLayout.addView(view, LayoutHelper.createFrame(52, 1, Gravity.LEFT | Gravity.BOTTOM));
|
||||
|
||||
recentsWrap = new FrameLayout(context);
|
||||
recentsWrap.addView(views.get(0));
|
||||
@ -183,20 +347,7 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
recentsWrap.addView(textView);
|
||||
views.get(0).setEmptyView(textView);
|
||||
|
||||
if (views.size() > 6) {
|
||||
emojiWrap = new FrameLayout(context);
|
||||
emojiWrap.addView(views.get(6));
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setText(LocaleController.getString("NoStickers", R.string.NoStickers));
|
||||
textView.setTextSize(18);
|
||||
textView.setTextColor(0xff888888);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
emojiWrap.addView(textView);
|
||||
views.get(6).setEmptyView(textView);
|
||||
}
|
||||
|
||||
addView(pager);
|
||||
addView(pager, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 48, 0, 0));
|
||||
|
||||
loadRecents();
|
||||
|
||||
@ -205,6 +356,39 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
}
|
||||
}
|
||||
|
||||
private void onPageScrolled(int position, int width, int positionOffsetPixels) {
|
||||
if (scrollSlidingTabStrip == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (width == 0) {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
}
|
||||
|
||||
int margin = 0;
|
||||
if (position == 5) {
|
||||
margin = -positionOffsetPixels;
|
||||
} else if (position == 6) {
|
||||
margin = -width;
|
||||
}
|
||||
|
||||
if (ViewProxy.getTranslationX(pagerSlidingTabStripContainer) != margin) {
|
||||
ViewProxy.setTranslationX(pagerSlidingTabStripContainer, margin);
|
||||
ViewProxy.setTranslationX(scrollSlidingTabStrip, width + margin);
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
if (margin <= -width) {
|
||||
pagerSlidingTabStripContainer.clearAnimation();
|
||||
pagerSlidingTabStripContainer.setVisibility(GONE);
|
||||
} else {
|
||||
pagerSlidingTabStripContainer.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
} else if (Build.VERSION.SDK_INT < 11 && pagerSlidingTabStripContainer.getVisibility() == GONE) {
|
||||
pagerSlidingTabStripContainer.clearAnimation();
|
||||
pagerSlidingTabStripContainer.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void postBackspaceRunnable(final int time) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
@ -284,12 +468,17 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
}
|
||||
|
||||
private void sortStickers() {
|
||||
if (StickersQuery.getStickerSets().isEmpty()) {
|
||||
recentStickers.clear();
|
||||
return;
|
||||
}
|
||||
recentStickers.clear();
|
||||
HashMap<Long, Integer> hashMap = new HashMap<>();
|
||||
for (TLRPC.Document document : stickers) {
|
||||
Integer count = stickersUseHistory.get(document.id);
|
||||
if (count != null) {
|
||||
hashMap.put(document.id, count);
|
||||
stickersUseHistory.remove(document.id);
|
||||
for (HashMap.Entry<Long, Integer> entry : stickersUseHistory.entrySet()) {
|
||||
TLRPC.Document sticker = StickersQuery.getStickerById(entry.getKey());
|
||||
if (sticker != null) {
|
||||
recentStickers.add(sticker);
|
||||
hashMap.put(sticker.id, entry.getValue());
|
||||
}
|
||||
}
|
||||
if (!stickersUseHistory.isEmpty()) {
|
||||
@ -298,7 +487,7 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
} else {
|
||||
stickersUseHistory = hashMap;
|
||||
}
|
||||
Collections.sort(stickers, new Comparator<TLRPC.Document>() {
|
||||
Collections.sort(recentStickers, new Comparator<TLRPC.Document>() {
|
||||
@Override
|
||||
public int compare(TLRPC.Document lhs, TLRPC.Document rhs) {
|
||||
Integer count1 = stickersUseHistory.get(lhs.id);
|
||||
@ -317,6 +506,28 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
while (recentStickers.size() > 20) {
|
||||
recentStickers.remove(recentStickers.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStickerTabs() {
|
||||
scrollSlidingTabStrip.removeTabs();
|
||||
scrollSlidingTabStrip.addIconTab(R.drawable.ic_emoji_smile);
|
||||
if (!recentStickers.isEmpty()) {
|
||||
scrollSlidingTabStrip.addIconTab(R.drawable.ic_smiles_recent);
|
||||
}
|
||||
stickerSets.clear();
|
||||
ArrayList<TLRPC.TL_messages_stickerSet> packs = StickersQuery.getStickerSets();
|
||||
for (int a = 0; a < packs.size(); a++) {
|
||||
TLRPC.TL_messages_stickerSet pack = packs.get(a);
|
||||
if ((pack.set.flags & 2) != 0 || pack.documents == null || pack.documents.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
stickerSets.add(pack);
|
||||
scrollSlidingTabStrip.addStickerTab(pack.documents.get(0));
|
||||
}
|
||||
scrollSlidingTabStrip.updateTabStyles();
|
||||
}
|
||||
|
||||
public void loadRecents() {
|
||||
@ -355,14 +566,42 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
}
|
||||
}
|
||||
sortStickers();
|
||||
updateStickerTabs();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY));
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) pagerSlidingTabStripContainer.getLayoutParams();
|
||||
FrameLayout.LayoutParams layoutParams1 = null;
|
||||
layoutParams.width = View.MeasureSpec.getSize(widthMeasureSpec);
|
||||
if (scrollSlidingTabStrip != null) {
|
||||
layoutParams1 = (FrameLayout.LayoutParams) scrollSlidingTabStrip.getLayoutParams();
|
||||
layoutParams1.width = layoutParams.width;
|
||||
}
|
||||
if (layoutParams.width != oldWidth) {
|
||||
if (scrollSlidingTabStrip != null) {
|
||||
onPageScrolled(pager.getCurrentItem(), layoutParams.width, 0);
|
||||
scrollSlidingTabStrip.setLayoutParams(layoutParams1);
|
||||
}
|
||||
pagerSlidingTabStripContainer.setLayoutParams(layoutParams);
|
||||
oldWidth = layoutParams.width;
|
||||
}
|
||||
super.onMeasure(View.MeasureSpec.makeMeasureSpec(layoutParams.width, MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
if (lastNotifyWidth != right - left) {
|
||||
lastNotifyWidth = right - left;
|
||||
if (stickersGridAdapter != null) {
|
||||
stickersGridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
super.onLayout(changed, left, top, right, bottom);
|
||||
}
|
||||
|
||||
public void setListener(Listener value) {
|
||||
@ -382,8 +621,16 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
super.onAttachedToWindow();
|
||||
if (stickersGridAdapter != null) {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.stickersDidLoaded);
|
||||
stickers = StickersQuery.getStickers();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibility(int visibility) {
|
||||
super.setVisibility(visibility);
|
||||
if (visibility != GONE && stickersGridAdapter != null) {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.stickersDidLoaded);
|
||||
sortStickers();
|
||||
updateStickerTabs();
|
||||
stickersGridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@ -399,31 +646,82 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == NotificationCenter.stickersDidLoaded) {
|
||||
updateStickerTabs();
|
||||
stickersGridAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private class StickersGridAdapter extends BaseAdapter {
|
||||
|
||||
Context context;
|
||||
private Context context;
|
||||
private int stickersPerRow;
|
||||
private HashMap<Integer, TLRPC.TL_messages_stickerSet> rowStartPack = new HashMap<>();
|
||||
private HashMap<TLRPC.TL_messages_stickerSet, Integer> packStartRow = new HashMap<>();
|
||||
private HashMap<Integer, TLRPC.Document> cache = new HashMap<>();
|
||||
private int totalItems;
|
||||
|
||||
public StickersGridAdapter(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return stickers.size();
|
||||
return totalItems != 0 ? totalItems + 1 : 0;
|
||||
}
|
||||
|
||||
public Object getItem(int i) {
|
||||
return stickers.get(i);
|
||||
return cache.get(i);
|
||||
}
|
||||
|
||||
public long getItemId(int i) {
|
||||
return stickers.get(i).id;
|
||||
return NO_ID;
|
||||
}
|
||||
|
||||
public int getPositionForPack(TLRPC.TL_messages_stickerSet stickerSet) {
|
||||
return packStartRow.get(stickerSet) * stickersPerRow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areAllItemsEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int position) {
|
||||
return cache.get(position) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (cache.get(position) != null) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getViewTypeCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getTabForPosition(int position) {
|
||||
if (stickersPerRow == 0) {
|
||||
int width = getMeasuredWidth();
|
||||
if (width == 0) {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
}
|
||||
stickersPerRow = width / AndroidUtilities.dp(72);
|
||||
}
|
||||
int row = position / stickersPerRow;
|
||||
TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
|
||||
if (pack == null) {
|
||||
return 0;
|
||||
}
|
||||
return stickerSets.indexOf(pack) + (recentStickers.isEmpty() ? 0 : 1);
|
||||
}
|
||||
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
TLRPC.Document sticker = cache.get(i);
|
||||
if (sticker != null) {
|
||||
if (view == null) {
|
||||
view = new StickerEmojiCell(context) {
|
||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
@ -438,6 +736,16 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
Integer count = stickersUseHistory.get(document.id);
|
||||
if (count == null) {
|
||||
count = 0;
|
||||
}
|
||||
if (count == 0 && stickersUseHistory.size() > 19) {
|
||||
for (int a = recentStickers.size() - 1; a >= 0; a--) {
|
||||
TLRPC.Document sticker = recentStickers.get(a);
|
||||
stickersUseHistory.remove(sticker.id);
|
||||
recentStickers.remove(a);
|
||||
if (stickersUseHistory.size() <= 19) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
stickersUseHistory.put(document.id, ++count);
|
||||
saveRecentStickers();
|
||||
@ -446,10 +754,65 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
}
|
||||
});
|
||||
}
|
||||
((StickerEmojiCell) view).setSticker(stickers.get(i), false);
|
||||
((StickerEmojiCell) view).setSticker(sticker, false);
|
||||
} else {
|
||||
if (view == null) {
|
||||
view = new EmptyCell(context);
|
||||
}
|
||||
if (i == totalItems) {
|
||||
int row = (i - 1) / stickersPerRow;
|
||||
TLRPC.TL_messages_stickerSet pack = rowStartPack.get(row);
|
||||
if (pack == null) {
|
||||
((EmptyCell) view).setHeight(1);
|
||||
} else {
|
||||
int height = pager.getHeight() - (int) Math.ceil(pack.documents.size() / (float) stickersPerRow) * AndroidUtilities.dp(82);
|
||||
((EmptyCell) view).setHeight(height > 0 ? height : 1);
|
||||
}
|
||||
} else {
|
||||
((EmptyCell) view).setHeight(AndroidUtilities.dp(82));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDataSetChanged() {
|
||||
int width = getMeasuredWidth();
|
||||
if (width == 0) {
|
||||
width = AndroidUtilities.displaySize.x;
|
||||
}
|
||||
stickersPerRow = width / AndroidUtilities.dp(72);
|
||||
rowStartPack.clear();
|
||||
packStartRow.clear();
|
||||
cache.clear();
|
||||
totalItems = 0;
|
||||
ArrayList<TLRPC.TL_messages_stickerSet> packs = stickerSets;
|
||||
for (int a = -1; a < packs.size(); a++) {
|
||||
ArrayList<TLRPC.Document> documents;
|
||||
TLRPC.TL_messages_stickerSet pack = null;
|
||||
int startRow = totalItems / stickersPerRow;
|
||||
if (a == -1) {
|
||||
documents = recentStickers;
|
||||
} else {
|
||||
pack = packs.get(a);
|
||||
documents = pack.documents;
|
||||
packStartRow.put(pack, startRow);
|
||||
}
|
||||
if (documents.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
int count = (int) Math.ceil(documents.size() / (float) stickersPerRow);
|
||||
for (int b = 0; b < documents.size(); b++) {
|
||||
cache.put(b + totalItems, documents.get(b));
|
||||
}
|
||||
totalItems += count * stickersPerRow;
|
||||
for (int b = 0; b < count; b++) {
|
||||
rowStartPack.put(startRow + b, pack);
|
||||
}
|
||||
}
|
||||
super.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
if (observer != null) {
|
||||
@ -511,16 +874,16 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
|
||||
private class EmojiPagesAdapter extends PagerAdapter implements PagerSlidingTabStrip.IconTabProvider {
|
||||
|
||||
public void destroyItem(ViewGroup paramViewGroup, int paramInt, Object paramObject) {
|
||||
View localObject;
|
||||
if (paramInt == 0) {
|
||||
localObject = recentsWrap;
|
||||
} else if (paramInt == 6) {
|
||||
localObject = emojiWrap;
|
||||
public void destroyItem(ViewGroup viewGroup, int position, Object object) {
|
||||
View view;
|
||||
if (position == 0) {
|
||||
view = recentsWrap;
|
||||
} else if (position == 6) {
|
||||
view = stickersWrap;
|
||||
} else {
|
||||
localObject = views.get(paramInt);
|
||||
view = views.get(position);
|
||||
}
|
||||
paramViewGroup.removeView(localObject);
|
||||
viewGroup.removeView(view);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
@ -531,21 +894,21 @@ public class EmojiView extends LinearLayout implements NotificationCenter.Notifi
|
||||
return icons[paramInt];
|
||||
}
|
||||
|
||||
public Object instantiateItem(ViewGroup paramViewGroup, int paramInt) {
|
||||
View localObject;
|
||||
if (paramInt == 0) {
|
||||
localObject = recentsWrap;
|
||||
} else if (paramInt == 6) {
|
||||
localObject = emojiWrap;
|
||||
public Object instantiateItem(ViewGroup viewGroup, int position) {
|
||||
View view;
|
||||
if (position == 0) {
|
||||
view = recentsWrap;
|
||||
} else if (position == 6) {
|
||||
view = stickersWrap;
|
||||
} else {
|
||||
localObject = views.get(paramInt);
|
||||
view = views.get(position);
|
||||
}
|
||||
paramViewGroup.addView(localObject);
|
||||
return localObject;
|
||||
viewGroup.addView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
public boolean isViewFromObject(View paramView, Object paramObject) {
|
||||
return paramView == paramObject;
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -30,10 +30,6 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.support.widget.LinearLayoutManager;
|
||||
import org.telegram.android.support.widget.RecyclerView;
|
||||
@ -41,6 +37,10 @@ import org.telegram.messenger.DispatchQueue;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.Cells.PhotoEditToolCell;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.text.Editable;
|
||||
import android.text.InputFilter;
|
||||
@ -17,21 +16,15 @@ import android.text.style.ImageSpan;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.Emoji;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
@ -39,26 +32,21 @@ import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
|
||||
public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierRelativeLayoutPhoto.SizeNotifierRelativeLayoutPhotoDelegate {
|
||||
public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayoutPhoto.SizeNotifierFrameLayoutPhotoDelegate {
|
||||
|
||||
public interface PhotoViewerCaptionEnterViewDelegate {
|
||||
void onCaptionEnter();
|
||||
void onTextChanged(CharSequence text, boolean bigChange);
|
||||
void onTextChanged(CharSequence text);
|
||||
void onWindowSizeChanged(int size);
|
||||
}
|
||||
|
||||
private EditText messageEditText;
|
||||
private PopupWindow emojiPopup;
|
||||
private ImageView emojiButton;
|
||||
private EmojiView emojiView;
|
||||
private SizeNotifierRelativeLayoutPhoto sizeNotifierFrameLayout;
|
||||
|
||||
private int framesDroped;
|
||||
|
||||
private int keyboardTransitionState;
|
||||
private boolean showKeyboardOnEmojiButton;
|
||||
private ViewTreeObserver.OnPreDrawListener onPreDrawListener;
|
||||
private SizeNotifierFrameLayoutPhoto sizeNotifierLayout;
|
||||
|
||||
private AnimatorSetProxy runningAnimation;
|
||||
private AnimatorSetProxy runningAnimation2;
|
||||
@ -66,22 +54,23 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
private int runningAnimationType;
|
||||
private int audioInterfaceState;
|
||||
|
||||
private int lastSizeChangeValue1;
|
||||
private boolean lastSizeChangeValue2;
|
||||
|
||||
private int keyboardHeight;
|
||||
private int keyboardHeightLand;
|
||||
private boolean keyboardVisible;
|
||||
private int emojiPadding;
|
||||
|
||||
private View window;
|
||||
private PhotoViewerCaptionEnterViewDelegate delegate;
|
||||
private boolean wasFocus;
|
||||
|
||||
public PhotoViewerCaptionEnterView(Context context, View windowView, SizeNotifierRelativeLayoutPhoto parent) {
|
||||
public PhotoViewerCaptionEnterView(Context context, SizeNotifierFrameLayoutPhoto parent) {
|
||||
super(context);
|
||||
setBackgroundColor(0x7f000000);
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
|
||||
window = windowView;
|
||||
sizeNotifierFrameLayout = parent;
|
||||
sizeNotifierLayout = parent;
|
||||
|
||||
LinearLayout textFieldContainer = new LinearLayout(context);
|
||||
textFieldContainer.setOrientation(LinearLayout.HORIZONTAL);
|
||||
@ -98,36 +87,20 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
emojiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (showKeyboardOnEmojiButton) {
|
||||
setKeyboardTransitionState(1);
|
||||
showEmojiPopup(false, false);
|
||||
int selection = messageEditText.getSelectionStart();
|
||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0);
|
||||
messageEditText.onTouchEvent(event);
|
||||
event.recycle();
|
||||
messageEditText.setSelection(selection);
|
||||
if (!isPopupShowing()) {
|
||||
showPopup(1);
|
||||
} else {
|
||||
boolean show = emojiPopup == null || !emojiPopup.isShowing();
|
||||
if (show) {
|
||||
setKeyboardTransitionState(5);
|
||||
showEmojiPopup(show, true);
|
||||
} else {
|
||||
showEmojiPopup(show, true);
|
||||
setKeyboardTransitionState(1);
|
||||
}
|
||||
openKeyboardInternal();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messageEditText = new EditText(context);
|
||||
messageEditText.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
|
||||
//messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_DONE);
|
||||
//messageEditText.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
|
||||
//Show suggestions
|
||||
messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
|
||||
messageEditText.setSingleLine(false);
|
||||
messageEditText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI | EditorInfo.IME_ACTION_DONE);
|
||||
messageEditText.setInputType(EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_CLASS_TEXT);
|
||||
messageEditText.setMaxLines(4);
|
||||
messageEditText.setHorizontallyScrolling(false);
|
||||
messageEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
messageEditText.setGravity(Gravity.BOTTOM);
|
||||
messageEditText.setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(12));
|
||||
@ -142,9 +115,9 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
messageEditText.setOnKeyListener(new OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
||||
if (i == 4 && !keyboardVisible && emojiPopup != null && emojiPopup.isShowing()) {
|
||||
if (i == KeyEvent.KEYCODE_BACK && !keyboardVisible && isPopupShowing()) {
|
||||
if (keyEvent.getAction() == 1) {
|
||||
showEmojiPopup(false, true);
|
||||
showPopup(0);
|
||||
}
|
||||
return true;
|
||||
} else if (i == KeyEvent.KEYCODE_ENTER && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
@ -154,30 +127,18 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
return false;
|
||||
}
|
||||
});
|
||||
messageEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (!wasFocus) {
|
||||
setKeyboardTransitionState(3);
|
||||
}
|
||||
wasFocus = hasFocus;
|
||||
}
|
||||
});
|
||||
messageEditText.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
setKeyboardTransitionState(1);
|
||||
showEmojiPopup(false, false);
|
||||
} else {
|
||||
setKeyboardTransitionState(3);
|
||||
if (isPopupShowing()) {
|
||||
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2);
|
||||
}
|
||||
}
|
||||
});
|
||||
messageEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
if (i == EditorInfo.IME_ACTION_DONE || i == EditorInfo.IME_ACTION_NEXT) {
|
||||
delegate.onCaptionEnter();
|
||||
return true;
|
||||
} else if (keyEvent != null && i == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
@ -195,10 +156,8 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
|
||||
String message = getTrimmedString(charSequence.toString());
|
||||
|
||||
if (delegate != null) {
|
||||
delegate.onTextChanged(charSequence, before > count || count > 2);
|
||||
delegate.onTextChanged(charSequence);
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,48 +178,11 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
});
|
||||
}
|
||||
|
||||
private void setKeyboardTransitionState(int state) {
|
||||
if (AndroidUtilities.usingHardwareInput) {
|
||||
if (state == 1) {
|
||||
showEmojiPopup(false, false);
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;//AndroidUtilities.dp(48);
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
} else if (state == 2) {
|
||||
int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, currentHeight);
|
||||
keyboardTransitionState = 0;
|
||||
} else if (state == 3) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;//AndroidUtilities.dp(48);
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
} else if (state == 4) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = -AndroidUtilities.dp(400);
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
} else if (state == 5) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
private void onWindowSizeChanged() {
|
||||
int size = sizeNotifierLayout.getHeight();
|
||||
if (!keyboardVisible) {
|
||||
size -= emojiPadding;
|
||||
}
|
||||
} else {
|
||||
framesDroped = 0;
|
||||
keyboardTransitionState = state;
|
||||
if (state == 1) {
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getKeyboardTransitionState() {
|
||||
return keyboardTransitionState;
|
||||
}
|
||||
|
||||
private void onWindowSizeChanged(int size) {
|
||||
if (delegate != null) {
|
||||
delegate.onWindowSizeChanged(size);
|
||||
}
|
||||
@ -268,202 +190,21 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
|
||||
public void onCreate() {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.emojiDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.hideEmojiKeyboard);
|
||||
sizeNotifierFrameLayout.getViewTreeObserver().addOnPreDrawListener(onPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
if (keyboardTransitionState == 1) {
|
||||
if (keyboardVisible || framesDroped >= 60) {
|
||||
showEmojiPopup(false, false);
|
||||
keyboardTransitionState = 0;
|
||||
} else {
|
||||
if (messageEditText != null) {
|
||||
messageEditText.requestFocus();
|
||||
AndroidUtilities.showKeyboard(messageEditText);
|
||||
}
|
||||
}
|
||||
framesDroped++;
|
||||
return false;
|
||||
} else if (keyboardTransitionState == 2) {
|
||||
if (!keyboardVisible || framesDroped >= 60) {
|
||||
int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, currentHeight);
|
||||
keyboardTransitionState = 0;
|
||||
}
|
||||
framesDroped++;
|
||||
return false;
|
||||
} else if (keyboardTransitionState == 3) {
|
||||
if (keyboardVisible) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;//AndroidUtilities.usingHardwareInput ? AndroidUtilities.dp(48) : 0;
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
}
|
||||
} else if (keyboardTransitionState == 4) {
|
||||
if (!keyboardVisible && (emojiPopup == null || !emojiPopup.isShowing())) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = -AndroidUtilities.dp(400);
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
}
|
||||
} else if (keyboardTransitionState == 5) {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;
|
||||
setLayoutParams(layoutParams);
|
||||
keyboardTransitionState = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
sizeNotifierFrameLayout.setDelegate(this);
|
||||
sizeNotifierLayout.setDelegate(this);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (isEmojiPopupShowing()) {
|
||||
hideEmojiPopup();
|
||||
}
|
||||
hidePopup();
|
||||
if (isKeyboardVisible()) {
|
||||
closeKeyboard();
|
||||
}
|
||||
keyboardVisible = false;
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.hideEmojiKeyboard);
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
sizeNotifierFrameLayout.getViewTreeObserver().removeOnPreDrawListener(onPreDrawListener);
|
||||
sizeNotifierFrameLayout.setDelegate(null);
|
||||
if (sizeNotifierLayout != null) {
|
||||
sizeNotifierLayout.setDelegate(null);
|
||||
}
|
||||
}
|
||||
|
||||
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 showEmojiPopup(boolean show, boolean post) {
|
||||
if (show) {
|
||||
if (emojiPopup == null) {
|
||||
emojiView = new EmojiView(false, getContext());
|
||||
emojiView.setListener(new EmojiView.Listener() {
|
||||
public boolean onBackspace() {
|
||||
if (messageEditText.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onEmojiSelected(String symbol) {
|
||||
int i = messageEditText.getSelectionEnd();
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
try {
|
||||
CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
messageEditText.setText(messageEditText.getText().insert(i, localCharSequence));
|
||||
int j = i + localCharSequence.length();
|
||||
messageEditText.setSelection(j, j);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onStickerSelected(TLRPC.Document sticker) {
|
||||
|
||||
}
|
||||
});
|
||||
emojiPopup = new PopupWindow(emojiView);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
||||
FileLog.e("tmessages", "show emoji with height = " + currentHeight);
|
||||
emojiPopup.setHeight(View.MeasureSpec.makeMeasureSpec(currentHeight, View.MeasureSpec.EXACTLY));
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
emojiPopup.setWidth(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.displaySize.x, View.MeasureSpec.EXACTLY));
|
||||
}
|
||||
|
||||
emojiPopup.showAtLocation(window, Gravity.BOTTOM | Gravity.LEFT, 0, 0);
|
||||
|
||||
if (!keyboardVisible) {
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, currentHeight);
|
||||
emojiButton.setImageResource(R.drawable.arrow_down_w);
|
||||
showKeyboardOnEmojiButton = false;
|
||||
onWindowSizeChanged(sizeNotifierFrameLayout.getHeight() - sizeNotifierFrameLayout.getPaddingBottom());
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
setKeyboardTransitionState(2);
|
||||
AndroidUtilities.hideKeyboard(messageEditText);
|
||||
}
|
||||
emojiButton.setImageResource(R.drawable.ic_keyboard_w);
|
||||
showKeyboardOnEmojiButton = true;
|
||||
return;
|
||||
}
|
||||
if (emojiButton != null) {
|
||||
showKeyboardOnEmojiButton = false;
|
||||
emojiButton.setImageResource(R.drawable.ic_smile_w);
|
||||
}
|
||||
if (emojiPopup != null) {
|
||||
try {
|
||||
emojiPopup.dismiss();
|
||||
} catch (Exception e) {
|
||||
//don't promt
|
||||
}
|
||||
}
|
||||
if (keyboardTransitionState == 0) {
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
if (post) {
|
||||
sizeNotifierFrameLayout.post(new Runnable() {
|
||||
public void run() {
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, 0);
|
||||
onWindowSizeChanged(sizeNotifierFrameLayout.getHeight());
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, 0);
|
||||
onWindowSizeChanged(sizeNotifierFrameLayout.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hideEmojiPopup() {
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false, true);
|
||||
}
|
||||
setKeyboardTransitionState(4);
|
||||
}
|
||||
|
||||
public void openKeyboard() {
|
||||
setKeyboardTransitionState(3);
|
||||
messageEditText.requestFocus();
|
||||
AndroidUtilities.showKeyboard(messageEditText);
|
||||
}
|
||||
|
||||
public void closeKeyboard() {
|
||||
setKeyboardTransitionState(4);
|
||||
AndroidUtilities.hideKeyboard(messageEditText);
|
||||
}
|
||||
|
||||
public void setDelegate(PhotoViewerCaptionEnterViewDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
@ -475,7 +216,7 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
messageEditText.setText(text);
|
||||
messageEditText.setSelection(messageEditText.getText().length());
|
||||
if (delegate != null) {
|
||||
delegate.onTextChanged(messageEditText.getText(), true);
|
||||
delegate.onTextChanged(messageEditText.getText());
|
||||
}
|
||||
}
|
||||
|
||||
@ -527,27 +268,122 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasText() {
|
||||
return messageEditText != null && messageEditText.length() > 0;
|
||||
}
|
||||
|
||||
public String getFieldText() {
|
||||
if (messageEditText != null && messageEditText.length() > 0) {
|
||||
return getTrimmedString(messageEditText.getText().toString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CharSequence getFieldCharSequence() {
|
||||
return messageEditText.getText();
|
||||
}
|
||||
|
||||
public boolean isEmojiPopupShowing() {
|
||||
return emojiPopup != null && emojiPopup.isShowing();
|
||||
public int getEmojiPadding() {
|
||||
return emojiPadding;
|
||||
}
|
||||
|
||||
public boolean isPopupView(View view) {
|
||||
return view == emojiView;
|
||||
}
|
||||
|
||||
private void showPopup(int show) {
|
||||
if (show == 1) {
|
||||
if (emojiView == null) {
|
||||
emojiView = new EmojiView(false, getContext());
|
||||
emojiView.setListener(new EmojiView.Listener() {
|
||||
public boolean onBackspace() {
|
||||
if (messageEditText.length() == 0) {
|
||||
return false;
|
||||
}
|
||||
messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onEmojiSelected(String symbol) {
|
||||
int i = messageEditText.getSelectionEnd();
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
try {
|
||||
CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20));
|
||||
messageEditText.setText(messageEditText.getText().insert(i, localCharSequence));
|
||||
int j = i + localCharSequence.length();
|
||||
messageEditText.setSelection(j, j);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void onStickerSelected(TLRPC.Document sticker) {
|
||||
|
||||
}
|
||||
});
|
||||
sizeNotifierLayout.addView(emojiView);
|
||||
}
|
||||
|
||||
emojiView.setVisibility(VISIBLE);
|
||||
|
||||
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));
|
||||
}
|
||||
int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
|
||||
layoutParams.width = AndroidUtilities.displaySize.x;
|
||||
layoutParams.height = currentHeight;
|
||||
emojiView.setLayoutParams(layoutParams);
|
||||
AndroidUtilities.hideKeyboard(messageEditText);
|
||||
if (sizeNotifierLayout != null) {
|
||||
emojiPadding = currentHeight;
|
||||
sizeNotifierLayout.requestLayout();
|
||||
emojiButton.setImageResource(R.drawable.ic_keyboard_w);
|
||||
onWindowSizeChanged();
|
||||
}
|
||||
} else {
|
||||
if (emojiButton != null) {
|
||||
emojiButton.setImageResource(R.drawable.ic_smile_w);
|
||||
}
|
||||
if (emojiView != null) {
|
||||
emojiView.setVisibility(GONE);
|
||||
}
|
||||
if (sizeNotifierLayout != null) {
|
||||
if (show == 0) {
|
||||
emojiPadding = 0;
|
||||
}
|
||||
sizeNotifierLayout.requestLayout();
|
||||
onWindowSizeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void hidePopup() {
|
||||
if (isPopupShowing()) {
|
||||
showPopup(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void openKeyboardInternal() {
|
||||
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2);
|
||||
/*int selection = messageEditText.getSelectionStart();
|
||||
MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_UP, 0, 0, 0);
|
||||
messageEditText.onTouchEvent(event);
|
||||
event.recycle();
|
||||
messageEditText.setSelection(selection);*/
|
||||
AndroidUtilities.showKeyboard(messageEditText);
|
||||
}
|
||||
|
||||
public void openKeyboard() {
|
||||
messageEditText.requestFocus();
|
||||
AndroidUtilities.showKeyboard(messageEditText);
|
||||
}
|
||||
|
||||
public boolean isPopupShowing() {
|
||||
return emojiView != null && emojiView.getVisibility() == VISIBLE;
|
||||
}
|
||||
|
||||
public void closeKeyboard() {
|
||||
AndroidUtilities.hideKeyboard(messageEditText);
|
||||
}
|
||||
|
||||
public boolean isKeyboardVisible() {
|
||||
return AndroidUtilities.usingHardwareInput && getLayoutParams() != null && ((RelativeLayout.LayoutParams) getLayoutParams()).bottomMargin == 0 || keyboardVisible;
|
||||
return AndroidUtilities.usingHardwareInput && getLayoutParams() != null && ((FrameLayout.LayoutParams) getLayoutParams()).bottomMargin == 0 || keyboardVisible;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -562,41 +398,44 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
}
|
||||
}
|
||||
|
||||
if (emojiPopup != null && emojiPopup.isShowing()) {
|
||||
int newHeight = 0;
|
||||
if (isPopupShowing()) {
|
||||
int newHeight;
|
||||
if (isWidthGreater) {
|
||||
newHeight = keyboardHeightLand;
|
||||
} else {
|
||||
newHeight = keyboardHeight;
|
||||
}
|
||||
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) emojiPopup.getContentView().getLayoutParams();
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emojiView.getLayoutParams();
|
||||
if (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) {
|
||||
layoutParams.width = AndroidUtilities.displaySize.x;
|
||||
layoutParams.height = newHeight;
|
||||
WindowManager wm = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (wm != null) {
|
||||
wm.updateViewLayout(emojiPopup.getContentView(), layoutParams);
|
||||
if (!keyboardVisible) {
|
||||
if (sizeNotifierFrameLayout != null) {
|
||||
sizeNotifierFrameLayout.setPadding(0, 0, 0, layoutParams.height);
|
||||
sizeNotifierFrameLayout.requestLayout();
|
||||
onWindowSizeChanged(sizeNotifierFrameLayout.getHeight() - sizeNotifierFrameLayout.getPaddingBottom());
|
||||
}
|
||||
}
|
||||
emojiView.setLayoutParams(layoutParams);
|
||||
if (sizeNotifierLayout != null) {
|
||||
emojiPadding = layoutParams.height;
|
||||
sizeNotifierLayout.requestLayout();
|
||||
onWindowSizeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
|
||||
onWindowSizeChanged();
|
||||
return;
|
||||
}
|
||||
lastSizeChangeValue1 = height;
|
||||
lastSizeChangeValue2 = isWidthGreater;
|
||||
|
||||
boolean oldValue = keyboardVisible;
|
||||
keyboardVisible = height > 0;
|
||||
if (keyboardVisible && (sizeNotifierFrameLayout.getPaddingBottom() > 0 || keyboardTransitionState == 1)) {
|
||||
setKeyboardTransitionState(1);
|
||||
} else if (keyboardTransitionState != 2 && !keyboardVisible && keyboardVisible != oldValue && emojiPopup != null && emojiPopup.isShowing()) {
|
||||
showEmojiPopup(false, true);
|
||||
if (keyboardVisible && isPopupShowing()) {
|
||||
showPopup(0);
|
||||
}
|
||||
if (keyboardTransitionState == 0) {
|
||||
onWindowSizeChanged(sizeNotifierFrameLayout.getHeight() - sizeNotifierFrameLayout.getPaddingBottom());
|
||||
if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
|
||||
emojiPadding = 0;
|
||||
sizeNotifierLayout.requestLayout();
|
||||
}
|
||||
onWindowSizeChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -605,8 +444,6 @@ public class PhotoViewerCaptionEnterView extends FrameLayoutFixed implements Not
|
||||
if (emojiView != null) {
|
||||
emojiView.invalidateViews();
|
||||
}
|
||||
} else if (id == NotificationCenter.hideEmojiKeyboard) {
|
||||
hideEmojiPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,10 +20,10 @@ import android.view.SoundEffectConstants;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.Cells.BaseCell;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -290,7 +290,7 @@ public class RecyclerListView extends RecyclerView {
|
||||
return;
|
||||
}
|
||||
boolean emptyViewVisible = getAdapter().getItemCount() == 0;
|
||||
emptyView.setVisibility(emptyViewVisible ? VISIBLE : INVISIBLE);
|
||||
emptyView.setVisibility(emptyViewVisible ? VISIBLE : GONE);
|
||||
setVisibility(emptyViewVisible ? INVISIBLE : VISIBLE);
|
||||
}
|
||||
|
||||
|
@ -1,112 +0,0 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
public class SizeNotifierRelativeLayout extends RelativeLayout {
|
||||
|
||||
private Rect rect = new Rect();
|
||||
private Drawable backgroundDrawable;
|
||||
private int keyboardHeight;
|
||||
private SizeNotifierRelativeLayoutDelegate delegate;
|
||||
|
||||
public interface SizeNotifierRelativeLayoutDelegate {
|
||||
void onSizeChanged(int keyboardHeight, boolean isWidthGreater);
|
||||
}
|
||||
|
||||
public SizeNotifierRelativeLayout(Context context) {
|
||||
super(context);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
public void setBackgroundImage(int resourceId) {
|
||||
try {
|
||||
backgroundDrawable = getResources().getDrawable(resourceId);
|
||||
} catch (Throwable e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setBackgroundImage(Drawable bitmap) {
|
||||
backgroundDrawable = bitmap;
|
||||
}
|
||||
|
||||
public Drawable getBackgroundImage() {
|
||||
return backgroundDrawable;
|
||||
}
|
||||
|
||||
public void setDelegate(SizeNotifierRelativeLayoutDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
|
||||
if (delegate != null) {
|
||||
View rootView = this.getRootView();
|
||||
int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
|
||||
this.getWindowVisibleDisplayFrame(rect);
|
||||
keyboardHeight = usableViewHeight - (rect.bottom - rect.top);
|
||||
final boolean isWidthGreater = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y;
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (delegate != null) {
|
||||
delegate.onSizeChanged(keyboardHeight, isWidthGreater);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (backgroundDrawable != null) {
|
||||
if (backgroundDrawable instanceof ColorDrawable) {
|
||||
backgroundDrawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
||||
backgroundDrawable.draw(canvas);
|
||||
} else {
|
||||
float scaleX = (float) getMeasuredWidth() / (float) backgroundDrawable.getIntrinsicWidth();
|
||||
float scaleY = (float) (getMeasuredHeight() + keyboardHeight) / (float) backgroundDrawable.getIntrinsicHeight();
|
||||
float scale = scaleX < scaleY ? scaleY : scaleX;
|
||||
int width = (int) Math.ceil(backgroundDrawable.getIntrinsicWidth() * scale);
|
||||
int height = (int) Math.ceil(backgroundDrawable.getIntrinsicHeight() * scale);
|
||||
int x = (getMeasuredWidth() - width) / 2;
|
||||
int y = (getMeasuredHeight() - height + keyboardHeight) / 2;
|
||||
backgroundDrawable.setBounds(x, y, x + width, y + height);
|
||||
backgroundDrawable.draw(canvas);
|
||||
}
|
||||
} else {
|
||||
super.onDraw(canvas);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This is the source code of Telegram for Android v. 2.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-2015.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Components;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
|
||||
public class SizeNotifierRelativeLayoutPhoto extends RelativeLayout {
|
||||
|
||||
public interface SizeNotifierRelativeLayoutPhotoDelegate {
|
||||
void onSizeChanged(int keyboardHeight, boolean isWidthGreater);
|
||||
}
|
||||
|
||||
private Rect rect = new Rect();
|
||||
private int keyboardHeight;
|
||||
private SizeNotifierRelativeLayoutPhotoDelegate delegate;
|
||||
|
||||
public SizeNotifierRelativeLayoutPhoto(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public void setDelegate(SizeNotifierRelativeLayoutPhotoDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@SuppressLint("DrawAllocation")
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
super.onLayout(changed, l, t, r, b);
|
||||
|
||||
if (delegate != null) {
|
||||
View rootView = this.getRootView();
|
||||
int usableViewHeight = rootView.getHeight() - AndroidUtilities.getViewInset(rootView);
|
||||
this.getWindowVisibleDisplayFrame(rect);
|
||||
keyboardHeight = (rect.bottom - rect.top) - usableViewHeight;
|
||||
final boolean isWidthGreater = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y;
|
||||
post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (delegate != null) {
|
||||
delegate.onSizeChanged(keyboardHeight, isWidthGreater);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -18,7 +18,9 @@ import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@ -33,6 +35,7 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
@ -41,10 +44,12 @@ import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.SecretChatHelper;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
@ -167,7 +172,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public void onSearchCollapse() {
|
||||
searchListViewAdapter.searchDialogs(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
@ -179,7 +184,6 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
listView.setFastScrollEnabled(true);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -420,10 +424,21 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0 && (user.flags & TLRPC.USER_FLAG_BOT_CANT_JOIN_GROUP) != 0) {
|
||||
try {
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
|
||||
final EditText editText = new EditText(getParentActivity());
|
||||
String message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user));
|
||||
EditText editText = null;
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) == 0) {
|
||||
message = String.format("%s\n\n%s", message, LocaleController.getString("AddToTheGroupForwardCount", R.string.AddToTheGroupForwardCount));
|
||||
editText = new EditText(getParentActivity());
|
||||
if (android.os.Build.VERSION.SDK_INT < 11) {
|
||||
editText.setBackgroundResource(android.R.drawable.editbox_background_normal);
|
||||
}
|
||||
@ -432,15 +447,54 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
editText.setGravity(Gravity.CENTER);
|
||||
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
final EditText editTextFinal = editText;
|
||||
editText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
try {
|
||||
String str = s.toString();
|
||||
if (str.length() != 0) {
|
||||
int value = Utilities.parseInt(str);
|
||||
if (value < 0) {
|
||||
editTextFinal.setText("0");
|
||||
editTextFinal.setSelection(editTextFinal.length());
|
||||
} else if (value > 300) {
|
||||
editTextFinal.setText("300");
|
||||
editTextFinal.setSelection(editTextFinal.length());
|
||||
} else if (!str.equals("" + value)) {
|
||||
editTextFinal.setText("" + value);
|
||||
editTextFinal.setSelection(editTextFinal.length());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
builder.setView(editText);
|
||||
}
|
||||
builder.setMessage(message);
|
||||
final EditText finalEditText = editText;
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
didSelectResult(user, false, editText.getText().toString());
|
||||
didSelectResult(user, false, finalEditText != null ? finalEditText.getText().toString() : "0");
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
if (editText != null) {
|
||||
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) editText.getLayoutParams();
|
||||
if (layoutParams != null) {
|
||||
if (layoutParams instanceof FrameLayout.LayoutParams) {
|
||||
@ -450,6 +504,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
editText.setLayoutParams(layoutParams);
|
||||
}
|
||||
editText.setSelection(editText.getText().length());
|
||||
}
|
||||
} else {
|
||||
if (delegate != null) {
|
||||
delegate.didSelectContact(user, param);
|
||||
|
@ -25,13 +25,13 @@ import android.widget.TextView;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.Adapters.CountryAdapter;
|
||||
import org.telegram.ui.Adapters.CountryAdapter.Country;
|
||||
import org.telegram.ui.Adapters.CountrySearchAdapter;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.CountryAdapter;
|
||||
import org.telegram.ui.Adapters.CountryAdapter.Country;
|
||||
import org.telegram.ui.Adapters.CountrySearchAdapter;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.LetterSectionsListView;
|
||||
|
||||
@ -84,7 +84,7 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public void onSearchCollapse() {
|
||||
searchListViewAdapter.search(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
@ -96,8 +96,6 @@ public class CountrySelectActivity extends BaseFragment {
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
|
||||
emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,21 +39,21 @@ import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||
import org.telegram.ui.Adapters.SearchAdapter;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.ContactsAdapter;
|
||||
import org.telegram.ui.Adapters.SearchAdapter;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.LetterSectionsListView;
|
||||
@ -508,7 +508,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
|
||||
LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
|
||||
View textView = lf.inflate(R.layout.group_create_bubble, null);
|
||||
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
|
||||
String name = ContactsController.formatName(user.first_name, user.last_name);
|
||||
String name = UserObject.getUserName(user);
|
||||
if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
|
||||
name = PhoneFormat.getInstance().format("+" + user.phone);
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Components.IdenticonDrawable;
|
||||
@ -97,12 +97,10 @@ public class IdenticonActivity extends BaseFragment {
|
||||
obs.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
||||
@Override
|
||||
public boolean onPreDraw() {
|
||||
if (fragmentView != null) {
|
||||
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
if (getParentActivity() == null || fragmentView == null) {
|
||||
if (fragmentView == null) {
|
||||
return true;
|
||||
}
|
||||
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
LinearLayout layout = (LinearLayout)fragmentView;
|
||||
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Context.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
@ -114,7 +112,7 @@ public class IdenticonActivity extends BaseFragment {
|
||||
}
|
||||
|
||||
fragmentView.setPadding(fragmentView.getPaddingLeft(), 0, fragmentView.getPaddingRight(), fragmentView.getPaddingBottom());
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -12,6 +12,8 @@ import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
@ -26,17 +28,17 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.Cells.TextSettingsCell;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -73,14 +75,16 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||
//ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||
Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search);
|
||||
ActionBarMenuItem item = menu.addItem(0, search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
||||
@Override
|
||||
public void onSearchExpand() {
|
||||
searching = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public void onSearchCollapse() {
|
||||
search(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
@ -88,8 +92,6 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
emptyTextView.setVisibility(View.GONE);
|
||||
listView.setAdapter(listAdapter);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -246,6 +248,21 @@ public class LanguageSelectActivity extends BaseFragment {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
|
||||
Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search);
|
||||
search.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
public void search(final String query) {
|
||||
|
@ -141,7 +141,12 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
doneButton = menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
doneButton.setVisibility(View.GONE);
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
@ -395,6 +400,18 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
|
@ -12,6 +12,8 @@ import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
@ -232,6 +234,18 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
|
@ -46,6 +46,7 @@ import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.android.query.StickersQuery;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
@ -348,6 +349,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
//Toast.makeText(getApplicationContext(), intent.toString(), Toast.LENGTH_SHORT).show();
|
||||
startActivityForResult(intent, 503);
|
||||
} catch (Exception e) {
|
||||
Intent in = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=es.rafalense.themes"));
|
||||
startActivityForResult(in, 503);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
drawerLayoutContainer.closeDrawer(false);
|
||||
@ -451,6 +454,10 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
|
||||
}
|
||||
|
||||
/*if (BuildVars.DEBUG_VERSION) {
|
||||
ViewServer.get(this).addWindow(this);
|
||||
}*/
|
||||
|
||||
handleIntent(getIntent(), false, savedInstanceState != null, false);
|
||||
needLayout();
|
||||
}
|
||||
@ -580,7 +587,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
if (name != null && !phones.isEmpty()) {
|
||||
contactsToSend = new ArrayList<>();
|
||||
for (String phone : phones) {
|
||||
TLRPC.User user = new TLRPC.TL_userContact();
|
||||
TLRPC.User user = new TLRPC.TL_userContact_old2();
|
||||
user.phone = phone;
|
||||
user.first_name = name;
|
||||
user.last_name = "";
|
||||
@ -608,9 +615,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
text = subject + "\n" + text;
|
||||
}
|
||||
sendingText = text;
|
||||
if (sendingText.contains("WhatsApp")) { //who needs this sent from ...?
|
||||
sendingText = null;
|
||||
}
|
||||
} else {
|
||||
error = true;
|
||||
}
|
||||
@ -652,6 +656,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
documentsMimeType = type;
|
||||
}
|
||||
}
|
||||
if (sendingText != null) {
|
||||
if (sendingText.contains("WhatsApp")) { //who needs this sent from ...?
|
||||
sendingText = null;
|
||||
}
|
||||
}
|
||||
} else if (sendingText == null) {
|
||||
error = true;
|
||||
}
|
||||
@ -715,6 +724,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
String username = null;
|
||||
String group = null;
|
||||
String sticker = null;
|
||||
String botUser = null;
|
||||
String botChat = null;
|
||||
String scheme = data.getScheme();
|
||||
if (scheme != null) {
|
||||
if ((scheme.equals("http") || scheme.equals("https"))) {
|
||||
@ -728,7 +739,9 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
} else if (path.startsWith("addstickers/")) {
|
||||
sticker = path.replace("addstickers/", "");
|
||||
} else {
|
||||
username = path;
|
||||
username = data.getLastPathSegment();
|
||||
botUser = data.getQueryParameter("start");
|
||||
botChat = data.getQueryParameter("startgroup");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -738,6 +751,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
url = url.replace("tg:resolve", "tg://telegram.org").replace("tg://resolve", "tg://telegram.org");
|
||||
data = Uri.parse(url);
|
||||
username = data.getQueryParameter("domain");
|
||||
botUser = data.getQueryParameter("start");
|
||||
botChat = data.getQueryParameter("startgroup");
|
||||
} else if (url.startsWith("tg:join") || url.startsWith("tg://join")) {
|
||||
url = url.replace("tg:join", "tg://telegram.org").replace("tg://join", "tg://telegram.org");
|
||||
data = Uri.parse(url);
|
||||
@ -750,7 +765,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
}
|
||||
}
|
||||
if (username != null || group != null || sticker != null) {
|
||||
runLinkRequest(username, group, sticker, 0);
|
||||
runLinkRequest(username, group, sticker, botUser, botChat, 0);
|
||||
} else {
|
||||
try {
|
||||
Cursor cursor = getContentResolver().query(intent.getData(), null, null, null, null);
|
||||
@ -902,7 +917,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
return false;
|
||||
}
|
||||
|
||||
private void runLinkRequest(final String username, final String group, final String sticker, final int state) {
|
||||
private void runLinkRequest(final String username, final String group, final String sticker, final String botUser, final String botChat, final int state) {
|
||||
final ProgressDialog progressDialog = new ProgressDialog(this);
|
||||
progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
|
||||
progressDialog.setCanceledOnTouchOutside(false);
|
||||
@ -925,17 +940,54 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (error == null && actionBarLayout != null) {
|
||||
TLRPC.User user = (TLRPC.User) response;
|
||||
final TLRPC.User user = (TLRPC.User) response;
|
||||
MessagesController.getInstance().putUser(user, false);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
users.add(user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
|
||||
if (botChat != null) {
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0 && (user.flags & TLRPC.USER_FLAG_BOT_CANT_JOIN_GROUP) != 0) {
|
||||
try {
|
||||
Toast.makeText(LaunchActivity.this, LocaleController.getString("BotCantJoinGroups", R.string.BotCantJoinGroups), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
args.putInt("dialogsType", 2);
|
||||
args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getUserName(user), "%1$s"));
|
||||
MessagesActivity fragment = new MessagesActivity(args);
|
||||
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
|
||||
@Override
|
||||
public void didSelectDialog(MessagesActivity fragment, long did, boolean param) {
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
MessagesController.getInstance().addUserToChat(-(int) did, user, null, 0, botChat);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("scrollToTopOnResume", true);
|
||||
args.putInt("chat_id", -(int) did);
|
||||
actionBarLayout.presentFragment(new ChatActivity(args), true, false, true);
|
||||
}
|
||||
});
|
||||
presentFragment(fragment);
|
||||
} else {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user.id);
|
||||
if (botUser != null) {
|
||||
args.putString("botUser", botUser);
|
||||
}
|
||||
ChatActivity fragment = new ChatActivity(args);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
actionBarLayout.presentFragment(fragment, false, true, true);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Toast.makeText(LaunchActivity.this, LocaleController.getString("NoUsernameFound", R.string.NoUsernameFound), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -976,7 +1028,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
runLinkRequest(username, group, sticker, 1);
|
||||
runLinkRequest(username, group, sticker, botUser, botChat, 1);
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
@ -1144,12 +1196,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, null);
|
||||
}
|
||||
} else {
|
||||
|
||||
actionBarLayout.presentFragment(fragment, true);
|
||||
|
||||
if (sendingText != null) {
|
||||
SendMessagesHelper.prepareSendingText(sendingText, dialog_id);
|
||||
}
|
||||
|
||||
actionBarLayout.presentFragment(fragment, true);
|
||||
|
||||
if (photoPathsArray != null) {
|
||||
SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id, null, null);
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AbsListView;
|
||||
@ -46,24 +47,24 @@ import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MarkerOptions;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.BaseLocationAdapter;
|
||||
import org.telegram.ui.Adapters.LocationActivityAdapter;
|
||||
import org.telegram.ui.Adapters.LocationActivitySearchAdapter;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.MapPlaceholderDrawable;
|
||||
|
||||
@ -211,7 +212,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public void onSearchCollapse() {
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
searchListView.setEmptyView(null);
|
||||
@ -220,7 +221,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||
searchListView.setVisibility(View.GONE);
|
||||
emptyTextLayout.setVisibility(View.GONE);
|
||||
searchAdapter.searchDelayed(null, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -617,6 +617,14 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public void onOpenAnimationEnd() {
|
||||
try {
|
||||
if (mapView.getParent() instanceof ViewGroup) {
|
||||
ViewGroup viewGroup = (ViewGroup) mapView.getParent();
|
||||
viewGroup.removeView(mapView);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (mapViewClip != null) {
|
||||
mapViewClip.addView(mapView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, overScrollHeight + AndroidUtilities.dp(10), Gravity.TOP | Gravity.LEFT));
|
||||
updateClipView(listView.getFirstVisiblePosition());
|
||||
@ -758,7 +766,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
avatarImageView.setImage(photo, null, new AvatarDrawable(user));
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
} else {
|
||||
avatarImageView.setImageDrawable(null);
|
||||
}
|
||||
|
@ -50,7 +50,6 @@ import android.widget.TextView;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
@ -58,6 +57,7 @@ import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.TLObject;
|
||||
@ -633,7 +633,7 @@ public class LoginActivity extends BaseFragment {
|
||||
});
|
||||
|
||||
textView = new TextView(context);
|
||||
textView.setText(LocaleController.getString("ChangePhoneHelp", R.string.ChangePhoneHelp));
|
||||
textView.setText(LocaleController.getString("StartText", R.string.StartText));
|
||||
textView.setTextColor(0xff757575);
|
||||
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
@ -2144,14 +2144,13 @@ public class LoginActivity extends BaseFragment {
|
||||
needHideProgress();
|
||||
if (error == null) {
|
||||
final TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response;
|
||||
TLRPC.TL_userSelf user = (TLRPC.TL_userSelf) res.user;
|
||||
UserConfig.clearConfig();
|
||||
MessagesController.getInstance().cleanUp();
|
||||
UserConfig.setCurrentUser(user);
|
||||
UserConfig.setCurrentUser(res.user);
|
||||
UserConfig.saveConfig(true);
|
||||
MessagesStorage.getInstance().cleanUp(true);
|
||||
ArrayList<TLRPC.User> users = new ArrayList<>();
|
||||
users.add(user);
|
||||
users.add(res.user);
|
||||
MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
|
||||
//MessagesController.getInstance().uploadAndApplyUserAvatar(avatarPhotoBig);
|
||||
MessagesController.getInstance().putUser(res.user, false);
|
||||
|
@ -283,7 +283,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
} else if (id == forward) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
args.putBoolean("serverOnly", true);
|
||||
args.putInt("dialogsType", 1);
|
||||
MessagesActivity fragment = new MessagesActivity(args);
|
||||
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
|
||||
@Override
|
||||
@ -346,14 +346,12 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public void onSearchCollapse() {
|
||||
dropDownContainer.setVisibility(View.VISIBLE);
|
||||
documentsSearchAdapter.searchDocuments(null);
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
switchToCurrentSelectedMode();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -702,7 +700,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
public boolean onPreDraw() {
|
||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
fixLayoutInternal();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1246,7 +1244,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
||||
req.peer.chat_id = -uid;
|
||||
} else {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(uid);
|
||||
if (user instanceof TLRPC.TL_userForeign || user instanceof TLRPC.TL_userRequest) {
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
if (user.access_hash != 0) {
|
||||
req.peer = new TLRPC.TL_inputPeerForeign();
|
||||
req.peer.access_hash = user.access_hash;
|
||||
} else {
|
||||
|
@ -11,6 +11,7 @@ package org.telegram.ui;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.animation.StateListAnimator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
@ -46,6 +47,8 @@ import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.NotificationsController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.android.support.widget.LinearLayoutManager;
|
||||
import org.telegram.android.support.widget.RecyclerView;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
@ -63,6 +66,7 @@ import org.telegram.ui.Adapters.DialogsAdapter;
|
||||
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
||||
import org.telegram.ui.Cells.DialogCell;
|
||||
import org.telegram.ui.Cells.UserCell;
|
||||
import org.telegram.ui.Components.AlertsCreator;
|
||||
import org.telegram.ui.Components.EmptyTextProgressView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.RecyclerListView;
|
||||
@ -90,7 +94,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
private String selectAlertString;
|
||||
private String selectAlertStringGroup;
|
||||
private boolean serverOnly;
|
||||
private String addToGroupAlertString;
|
||||
private int dialogsType;
|
||||
|
||||
private static boolean dialogsLoaded;
|
||||
private boolean searching;
|
||||
@ -116,9 +121,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
if (getArguments() != null) {
|
||||
onlySelect = arguments.getBoolean("onlySelect", false);
|
||||
serverOnly = arguments.getBoolean("serverOnly", false);
|
||||
dialogsType = arguments.getInt("dialogsType", 0);
|
||||
selectAlertString = arguments.getString("selectAlertString");
|
||||
selectAlertStringGroup = arguments.getString("selectAlertStringGroup");
|
||||
addToGroupAlertString = arguments.getString("addToGroupAlertString");
|
||||
}
|
||||
|
||||
if (searchString == null) {
|
||||
@ -189,8 +195,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
if (listView != null) {
|
||||
if (searchString != null) {
|
||||
listView.setEmptyView(searchEmptyView);
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
}
|
||||
if (!onlySelect) {
|
||||
floatingButton.setVisibility(View.GONE);
|
||||
@ -200,20 +206,25 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public boolean canCollapseSearch() {
|
||||
if (searchString != null) {
|
||||
finishFragment();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchCollapse() {
|
||||
searching = false;
|
||||
searchWas = false;
|
||||
if (listView != null) {
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(progressView);
|
||||
} else {
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (!onlySelect) {
|
||||
@ -228,10 +239,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
if (dialogsSearchAdapter != null) {
|
||||
dialogsSearchAdapter.searchDialogs(null, false);
|
||||
dialogsSearchAdapter.searchDialogs(null, dialogsType);
|
||||
}
|
||||
updatePasscodeButton();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -244,14 +254,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
dialogsSearchAdapter.notifyDataSetChanged();
|
||||
}
|
||||
if (searchEmptyView != null && listView.getEmptyView() != searchEmptyView) {
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
searchEmptyView.showTextView();
|
||||
listView.setEmptyView(searchEmptyView);
|
||||
}
|
||||
}
|
||||
if (dialogsSearchAdapter != null) {
|
||||
dialogsSearchAdapter.searchDialogs(text, serverOnly);
|
||||
dialogsSearchAdapter.searchDialogs(text, dialogsType);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -388,7 +398,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
if (openedDialogId == dialog_id) {
|
||||
if (openedDialogId == dialog_id && adapter != dialogsSearchAdapter) {
|
||||
return;
|
||||
}
|
||||
if (dialogsAdapter != null) {
|
||||
@ -432,17 +442,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
return;
|
||||
}
|
||||
TLRPC.TL_dialog dialog;
|
||||
if (serverOnly) {
|
||||
if (position < 0 || position >= MessagesController.getInstance().dialogsServerOnly.size()) {
|
||||
ArrayList<TLRPC.TL_dialog> dialogs = getDialogsArray();
|
||||
if (position < 0 || position >= dialogs.size()) {
|
||||
return;
|
||||
}
|
||||
dialog = MessagesController.getInstance().dialogsServerOnly.get(position);
|
||||
} else {
|
||||
if (position < 0 || position >= MessagesController.getInstance().dialogs.size()) {
|
||||
return;
|
||||
}
|
||||
dialog = MessagesController.getInstance().dialogs.get(position);
|
||||
}
|
||||
dialog = dialogs.get(position);
|
||||
selectedDialog = dialog.id;
|
||||
|
||||
/*AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
@ -457,10 +461,34 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
int high_id = (int) (selectedDialog >> 32);
|
||||
|
||||
final boolean isChat = lower_id < 0 && high_id != 1;
|
||||
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory),
|
||||
isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : LocaleController.getString("Delete", R.string.Delete)}, new DialogInterface.OnClickListener() {
|
||||
|
||||
int rightIcon = MessagesController.getInstance().isDialogMuted(selectedDialog) ? R.drawable.mute_fixed : 0;
|
||||
|
||||
|
||||
builder.setItems(new CharSequence[]{
|
||||
|
||||
LocaleController.getString("ClearHistory", R.string.ClearHistory),
|
||||
isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : LocaleController.getString("Delete", R.string.Delete),
|
||||
rightIcon != 0 ? LocaleController.getString("UnmuteNotifications", R.string.UnmuteNotifications) : LocaleController.getString("MuteNotifications", R.string.MuteNotifications)}, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, final int which) {
|
||||
if(which == 2){
|
||||
boolean muted = MessagesController.getInstance().isDialogMuted(selectedDialog);
|
||||
if (!muted) {
|
||||
showDialog(AlertsCreator.createMuteAlert(getParentActivity(), selectedDialog));
|
||||
} else {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.putInt("notify2_" + selectedDialog, 0);
|
||||
MessagesStorage.getInstance().setDialogFlags(selectedDialog, 0);
|
||||
editor.commit();
|
||||
TLRPC.TL_dialog dialg = MessagesController.getInstance().dialogs_dict.get(selectedDialog);
|
||||
if (dialg != null) {
|
||||
dialg.notify_settings = new TLRPC.TL_peerNotifySettings();
|
||||
}
|
||||
NotificationsController.updateServerNotificationsSettings(selectedDialog);
|
||||
}
|
||||
}else{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
if (which == 0) {
|
||||
@ -497,20 +525,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
|
||||
searchEmptyView = new EmptyTextProgressView(context);
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
searchEmptyView.setShowAtCenter(true);
|
||||
searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
||||
frameLayout.addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
|
||||
emptyView = new LinearLayout(context);
|
||||
emptyView.setOrientation(LinearLayout.VERTICAL);
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
emptyView.setGravity(Gravity.CENTER);
|
||||
frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
emptyView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@ -541,7 +570,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
emptyView.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
progressView = new ProgressBar(context);
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
frameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
||||
|
||||
floatingButton = new ImageView(context);
|
||||
@ -593,7 +622,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
return;
|
||||
}
|
||||
if (visibleItemCount > 0) {
|
||||
if (layoutManager.findLastVisibleItemPosition() == MessagesController.getInstance().dialogs.size() && !serverOnly || layoutManager.findLastVisibleItemPosition() == MessagesController.getInstance().dialogsServerOnly.size() && serverOnly) {
|
||||
if (layoutManager.findLastVisibleItemPosition() == getDialogsArray().size()) {
|
||||
MessagesController.getInstance().loadDialogs(MessagesController.getInstance().dialogs.size(), MessagesController.getInstance().dialogsServerOnly.size(), 100, true);
|
||||
}
|
||||
}
|
||||
@ -624,7 +653,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
|
||||
if (searchString == null) {
|
||||
dialogsAdapter = new DialogsAdapter(context, serverOnly);
|
||||
dialogsAdapter = new DialogsAdapter(context, dialogsType);
|
||||
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
||||
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
||||
}
|
||||
@ -651,12 +680,12 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
});
|
||||
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(progressView);
|
||||
} else {
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (searchString != null) {
|
||||
@ -757,16 +786,16 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
if (listView != null) {
|
||||
try {
|
||||
if (MessagesController.getInstance().loadingDialogs && MessagesController.getInstance().dialogs.isEmpty()) {
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(progressView);
|
||||
} else {
|
||||
progressView.setVisibility(View.INVISIBLE);
|
||||
progressView.setVisibility(View.GONE);
|
||||
if (searching && searchWas) {
|
||||
emptyView.setVisibility(View.INVISIBLE);
|
||||
emptyView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(searchEmptyView);
|
||||
} else {
|
||||
searchEmptyView.setVisibility(View.INVISIBLE);
|
||||
searchEmptyView.setVisibility(View.GONE);
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
}
|
||||
@ -787,7 +816,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
} else if (id == NotificationCenter.contactsDidLoaded) {
|
||||
updateVisibleRows(0);
|
||||
} else if (id == NotificationCenter.openedChatChanged) {
|
||||
if (!serverOnly && AndroidUtilities.isTablet()) {
|
||||
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
||||
boolean close = (Boolean) args[1];
|
||||
long dialog_id = (Long) args[0];
|
||||
if (close) {
|
||||
@ -811,6 +840,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<TLRPC.TL_dialog> getDialogsArray() {
|
||||
if (dialogsType == 0) {
|
||||
return MessagesController.getInstance().dialogs;
|
||||
} else if (dialogsType == 1) {
|
||||
return MessagesController.getInstance().dialogsServerOnly;
|
||||
} else if (dialogsType == 2) {
|
||||
return MessagesController.getInstance().dialogsGroupsOnly;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void updatePasscodeButton() {
|
||||
if (passcodeItem == null) {
|
||||
return;
|
||||
@ -851,19 +891,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
for (int a = 0; a < count; a++) {
|
||||
View child = listView.getChildAt(a);
|
||||
if (child instanceof DialogCell) {
|
||||
if (listView.getAdapter() != dialogsSearchAdapter) {
|
||||
DialogCell cell = (DialogCell) child;
|
||||
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) {
|
||||
cell.checkCurrentDialogIndex();
|
||||
if (!serverOnly && AndroidUtilities.isTablet()) {
|
||||
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
} else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
||||
if (!serverOnly && AndroidUtilities.isTablet()) {
|
||||
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
||||
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
||||
}
|
||||
} else {
|
||||
cell.update(mask);
|
||||
}
|
||||
}
|
||||
} else if (child instanceof UserCell) {
|
||||
((UserCell) child).update(mask);
|
||||
}
|
||||
@ -883,7 +925,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
|
||||
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
|
||||
if (useAlert && selectAlertString != null && selectAlertStringGroup != null) {
|
||||
if (useAlert && (selectAlertString != null && selectAlertStringGroup != null || addToGroupAlertString != null)) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
@ -904,22 +946,26 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)));
|
||||
} else if (lower_part < 0) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().getChat(-lower_part);
|
||||
if (chat == null) {
|
||||
return;
|
||||
}
|
||||
if (addToGroupAlertString != null) {
|
||||
builder.setMessage(LocaleController.formatStringSimple(addToGroupAlertString, chat.title));
|
||||
} else {
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, chat.title));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
TLRPC.EncryptedChat chat = MessagesController.getInstance().getEncryptedChat(high_id);
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(chat.user_id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, ContactsController.formatName(user.first_name, user.last_name)));
|
||||
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)));
|
||||
}
|
||||
|
||||
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
||||
|
@ -14,6 +14,8 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.media.Ringtone;
|
||||
import android.media.RingtoneManager;
|
||||
import android.net.Uri;
|
||||
@ -89,6 +91,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
private int otherSectionRow;
|
||||
private int badgeNumberRow;
|
||||
private int pebbleAlertRow;
|
||||
private int androidAutoAlertRow;
|
||||
private int repeatRow;
|
||||
private int resetSectionRow2;
|
||||
private int resetSectionRow;
|
||||
@ -141,6 +144,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
otherSectionRow2 = rowCount++;
|
||||
otherSectionRow = rowCount++;
|
||||
badgeNumberRow = rowCount++;
|
||||
androidAutoAlertRow = -1;
|
||||
pebbleAlertRow = rowCount++;
|
||||
repeatRow = rowCount++;
|
||||
resetSectionRow2 = rowCount++;
|
||||
@ -327,6 +331,12 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
enabled = preferences.getBoolean("EnablePebbleNotifications", false);
|
||||
editor.putBoolean("EnablePebbleNotifications", !enabled);
|
||||
editor.commit();
|
||||
} else if (i == androidAutoAlertRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
enabled = preferences.getBoolean("EnableAutoNotifications", false);
|
||||
editor.putBoolean("EnableAutoNotifications", !enabled);
|
||||
editor.commit();
|
||||
} else if (i == badgeNumberRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -617,6 +627,23 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
private Context mContext;
|
||||
|
||||
@ -704,6 +731,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), false);
|
||||
} else if (i == pebbleAlertRow) {
|
||||
checkCell.setTextAndCheck(LocaleController.getString("Pebble", R.string.Pebble), preferences.getBoolean("EnablePebbleNotifications", false), true);
|
||||
} else if (i == androidAutoAlertRow) {
|
||||
checkCell.setTextAndCheck("Android Auto", preferences.getBoolean("EnableAutoNotifications", false), true);
|
||||
} else if (i == notificationsServiceRow) {
|
||||
checkCell.setTextAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), preferences.getBoolean("pushService", true), false);
|
||||
} else if (i == badgeNumberRow) {
|
||||
@ -831,7 +860,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
|
||||
i == groupPreviewRow || i == inappSoundRow || i == inappVibrateRow ||
|
||||
i == inappPreviewRow || i == contactJoinedRow || i == pebbleAlertRow ||
|
||||
i == notificationsServiceRow || i == badgeNumberRow || i == inappPriorityRow ||
|
||||
i == inchatSoundRow) {
|
||||
i == inchatSoundRow || i == androidAutoAlertRow) {
|
||||
return 1;
|
||||
} else if (i == messageLedRow || i == groupLedRow) {
|
||||
return 3;
|
||||
|
@ -13,7 +13,9 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Vibrator;
|
||||
import android.text.Editable;
|
||||
@ -140,7 +142,11 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
if (type != 0) {
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
//menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
Drawable done = getParentActivity().getResources().getDrawable(R.drawable.ic_done);
|
||||
done.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
|
||||
menu.addItemWithWidth(done_button, done, AndroidUtilities.dp(56));
|
||||
|
||||
titleTextView = new TextView(context);
|
||||
titleTextView.setTextColor(0xff757575);
|
||||
@ -421,6 +427,18 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
}, 200);
|
||||
}
|
||||
fixLayoutInternal();
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -459,7 +477,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
|
||||
public boolean onPreDraw() {
|
||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
fixLayoutInternal();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -422,7 +422,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
|
||||
if (listView != null) {
|
||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import org.json.JSONObject;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.volley.AuthFailureError;
|
||||
@ -51,13 +50,14 @@ import org.telegram.messenger.BuildVars;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Adapters.BaseFragmentAdapter;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Cells.PhotoPickerPhotoCell;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
@ -184,7 +184,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSearchCollapse() {
|
||||
public boolean canCollapseSearch() {
|
||||
finishFragment();
|
||||
return false;
|
||||
}
|
||||
@ -899,7 +899,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
|
||||
if (listView != null) {
|
||||
listView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -42,46 +42,45 @@ import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Scroller;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.ImageLoader;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.android.query.SharedMediaQuery;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.ui.Adapters.MentionsAdapter;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
||||
import org.telegram.ui.Adapters.MentionsAdapter;
|
||||
import org.telegram.ui.Components.CheckBox;
|
||||
import org.telegram.ui.Components.ClippingImageView;
|
||||
import org.telegram.android.ImageReceiver;
|
||||
import org.telegram.ui.Components.GifDrawable;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.PhotoCropView;
|
||||
import org.telegram.ui.Components.PhotoFilterView;
|
||||
import org.telegram.ui.Components.PhotoPickerBottomLayout;
|
||||
import org.telegram.ui.Components.PhotoViewerCaptionEnterView;
|
||||
import org.telegram.ui.Components.SizeNotifierRelativeLayoutPhoto;
|
||||
import org.telegram.ui.Components.SizeNotifierFrameLayoutPhoto;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
@ -515,36 +514,114 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
}
|
||||
|
||||
private class FrameLayoutDrawer extends SizeNotifierRelativeLayoutPhoto {
|
||||
private class FrameLayoutDrawer extends SizeNotifierFrameLayoutPhoto {
|
||||
public FrameLayoutDrawer(Context context) {
|
||||
super(context);
|
||||
setWillNotDraw(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
getInstance().onDraw(canvas);
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
setMeasuredDimension(widthSize, heightSize);
|
||||
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
if (captionEditText.isPopupView(child)) {
|
||||
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
if ((child == captionEditText || child == pickerView || child == captionTextView || child == mentionListView)) {
|
||||
int state = captionEditText.getKeyboardTransitionState();
|
||||
if (!(state == 0 || state == 1 || state == 2)) {
|
||||
if (child == captionTextView) {
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
final int count = getChildCount();
|
||||
|
||||
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) ? captionEditText.getEmojiPadding() : 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
final int width = child.getMeasuredWidth();
|
||||
final int height = child.getMeasuredHeight();
|
||||
|
||||
int childLeft;
|
||||
int childTop;
|
||||
|
||||
int gravity = lp.gravity;
|
||||
if (gravity == -1) {
|
||||
gravity = Gravity.TOP | Gravity.LEFT;
|
||||
}
|
||||
|
||||
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
|
||||
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||
case Gravity.CENTER_HORIZONTAL:
|
||||
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.RIGHT:
|
||||
childLeft = r - width - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.LEFT:
|
||||
default:
|
||||
childLeft = lp.leftMargin;
|
||||
}
|
||||
|
||||
switch (verticalGravity) {
|
||||
case Gravity.TOP:
|
||||
childTop = lp.topMargin;
|
||||
break;
|
||||
case Gravity.CENTER_VERTICAL:
|
||||
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
|
||||
break;
|
||||
case Gravity.BOTTOM:
|
||||
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
|
||||
break;
|
||||
default:
|
||||
childTop = lp.topMargin;
|
||||
}
|
||||
|
||||
if (child == mentionListView) {
|
||||
if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) {
|
||||
childTop += AndroidUtilities.dp(400);
|
||||
} else {
|
||||
childTop -= captionEditText.getMeasuredHeight();
|
||||
}
|
||||
} else if (child == captionEditText) {
|
||||
if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) {
|
||||
childTop += AndroidUtilities.dp(400);
|
||||
}
|
||||
} else if (child == pickerView || child == captionTextViewNew || child == captionTextViewOld) {
|
||||
if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) {
|
||||
childTop += AndroidUtilities.dp(400);
|
||||
}
|
||||
} else if (captionEditText.isPopupView(child)) {
|
||||
childTop = captionEditText.getBottom();
|
||||
}
|
||||
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
||||
}
|
||||
|
||||
notifyHeightChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (captionTextView != null) {
|
||||
captionTextView.invalidate();
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return super.drawChild(canvas, child, drawingTime);
|
||||
protected void onDraw(Canvas canvas) {
|
||||
getInstance().onDraw(canvas);
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +864,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
@Override
|
||||
public boolean dispatchKeyEventPreIme(KeyEvent event) {
|
||||
if (event != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
|
||||
if (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible()) {
|
||||
if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) {
|
||||
closeCaptionEnter(false);
|
||||
return false;
|
||||
}
|
||||
@ -822,13 +899,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
actionBar.setItemsBackground(R.drawable.bar_selector_white);
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setTitle(LocaleController.formatString("Of", R.string.Of, 1, 1));
|
||||
containerView.addView(actionBar, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
containerView.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
||||
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
if (needCaptionLayout && (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible())) {
|
||||
if (needCaptionLayout && (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible())) {
|
||||
closeCaptionEnter(false);
|
||||
return;
|
||||
}
|
||||
@ -991,6 +1068,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
checkImageView.setVisibility(View.GONE);
|
||||
captionDoneItem.setVisibility(View.VISIBLE);
|
||||
pickerView.setVisibility(View.GONE);
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) captionEditText.getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;
|
||||
captionEditText.setLayoutParams(layoutParams);
|
||||
layoutParams = (FrameLayout.LayoutParams) mentionListView.getLayoutParams();
|
||||
layoutParams.bottomMargin = 0;
|
||||
mentionListView.setLayoutParams(layoutParams);
|
||||
captionTextView.clearAnimation();
|
||||
captionTextView.setVisibility(View.INVISIBLE);
|
||||
captionEditText.openKeyboard();
|
||||
@ -1032,7 +1115,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
bottomLayout = new FrameLayout(parentActivity);
|
||||
bottomLayout.setBackgroundColor(0x7f000000);
|
||||
containerView.addView(bottomLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(bottomLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT));
|
||||
|
||||
captionTextViewOld = new TextView(parentActivity);
|
||||
captionTextViewOld.setMaxLines(10);
|
||||
@ -1043,7 +1126,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
captionTextViewOld.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
|
||||
captionTextViewOld.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
captionTextViewOld.setVisibility(View.INVISIBLE);
|
||||
containerView.addView(captionTextViewOld, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 48, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(captionTextViewOld, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
|
||||
|
||||
captionTextView = captionTextViewNew = new TextView(parentActivity);
|
||||
captionTextViewNew.setMaxLines(10);
|
||||
@ -1054,7 +1137,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
captionTextViewNew.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
|
||||
captionTextViewNew.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
captionTextViewNew.setVisibility(View.INVISIBLE);
|
||||
containerView.addView(captionTextViewNew, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, 48, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(captionTextViewNew, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 48));
|
||||
|
||||
radialProgressViews[0] = new RadialProgressView(containerView.getContext(), containerView);
|
||||
radialProgressViews[0].setBackgroundState(0, false);
|
||||
@ -1128,7 +1211,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
pickerView = new PhotoPickerBottomLayout(parentActivity);
|
||||
pickerView.setBackgroundColor(0x7f000000);
|
||||
containerView.addView(pickerView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(pickerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.LEFT));
|
||||
pickerView.cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@ -1152,7 +1235,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
editorDoneLayout.setBackgroundColor(0x7f000000);
|
||||
editorDoneLayout.updateSelectedCount(0, false);
|
||||
editorDoneLayout.setVisibility(View.GONE);
|
||||
containerView.addView(editorDoneLayout, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 48, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(editorDoneLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
|
||||
editorDoneLayout.cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@ -1198,7 +1281,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
checkImageView.setCheckOffset(AndroidUtilities.dp(1));
|
||||
checkImageView.setColor(0xff3ccaef);
|
||||
checkImageView.setVisibility(View.GONE);
|
||||
containerView.addView(checkImageView, LayoutHelper.createRelative(45, 45, 0, rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 58 : 68, 10, 0, RelativeLayout.ALIGN_PARENT_RIGHT));
|
||||
containerView.addView(checkImageView, LayoutHelper.createFrame(45, 45, Gravity.RIGHT | Gravity.TOP, 0, rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 58 : 68, 10, 0));
|
||||
checkImageView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -1210,8 +1293,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
});
|
||||
|
||||
captionEditText = new PhotoViewerCaptionEnterView(parentActivity, windowView, containerView);
|
||||
captionEditText.setId(1000);
|
||||
captionEditText = new PhotoViewerCaptionEnterView(parentActivity, containerView);
|
||||
captionEditText.setDelegate(new PhotoViewerCaptionEnterView.PhotoViewerCaptionEnterViewDelegate() {
|
||||
@Override
|
||||
public void onCaptionEnter() {
|
||||
@ -1219,7 +1301,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence text, boolean bigChange) {
|
||||
public void onTextChanged(CharSequence text) {
|
||||
if (mentionsAdapter != null && captionEditText != null && parentChatActivity != null && text != null) {
|
||||
mentionsAdapter.searchUsernameOrHashtag(text.toString(), captionEditText.getCursorPosition(), parentChatActivity.messages);
|
||||
}
|
||||
@ -1243,7 +1325,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
}
|
||||
});
|
||||
containerView.addView(captionEditText, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 0, 0, -400, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
containerView.addView(captionEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, -400));
|
||||
|
||||
mentionListView = new ListView(parentActivity);
|
||||
mentionListView.setBackgroundColor(0x7f000000);
|
||||
@ -1254,13 +1336,13 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (Build.VERSION.SDK_INT > 8) {
|
||||
mentionListView.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
|
||||
}
|
||||
containerView.addView(mentionListView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 110, 0, -110, 0, 0, RelativeLayout.ALIGN_TOP, 1000));
|
||||
containerView.addView(mentionListView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 110, Gravity.LEFT | Gravity.BOTTOM));
|
||||
|
||||
mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(parentActivity, true, new MentionsAdapter.MentionsAdapterDelegate() {
|
||||
@Override
|
||||
public void needChangePanelVisibility(boolean show) {
|
||||
if (show) {
|
||||
RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) mentionListView.getLayoutParams();
|
||||
FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) mentionListView.getLayoutParams();
|
||||
int height = 36 * Math.min(3, mentionsAdapter.getCount()) + (mentionsAdapter.getCount() > 3 ? 18 : 0);
|
||||
layoutParams3.height = AndroidUtilities.dp(height);
|
||||
layoutParams3.topMargin = -AndroidUtilities.dp(height);
|
||||
@ -1411,6 +1493,14 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
captionDoneItem.setVisibility(View.GONE);
|
||||
pickerView.setVisibility(View.VISIBLE);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) captionEditText.getLayoutParams();
|
||||
layoutParams.bottomMargin = -AndroidUtilities.dp(400);
|
||||
captionEditText.setLayoutParams(layoutParams);
|
||||
|
||||
layoutParams = (FrameLayout.LayoutParams) mentionListView.getLayoutParams();
|
||||
layoutParams.bottomMargin = -AndroidUtilities.dp(400);
|
||||
mentionListView.setLayoutParams(layoutParams);
|
||||
|
||||
if (lastTitle != null) {
|
||||
actionBar.setTitle(lastTitle);
|
||||
lastTitle = null;
|
||||
@ -1418,8 +1508,8 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
|
||||
updateCaptionTextForCurrentPhoto(object);
|
||||
setCurrentCaption(captionEditText.getFieldCharSequence());
|
||||
if (captionEditText.isEmojiPopupShowing()) {
|
||||
captionEditText.hideEmojiPopup();
|
||||
if (captionEditText.isPopupShowing()) {
|
||||
captionEditText.hidePopup();
|
||||
} else {
|
||||
captionEditText.closeKeyboard();
|
||||
}
|
||||
@ -1619,7 +1709,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (photoCropView == null) {
|
||||
photoCropView = new PhotoCropView(parentActivity);
|
||||
photoCropView.setVisibility(View.GONE);
|
||||
containerView.addView(photoCropView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 48));
|
||||
containerView.addView(photoCropView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 48));
|
||||
photoCropView.setDelegate(new PhotoCropView.PhotoCropViewDelegate() {
|
||||
@Override
|
||||
public void needMoveImageTo(float x, float y, float s, boolean animated) {
|
||||
@ -1722,7 +1812,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
} else if (mode == 2) {
|
||||
if (photoFilterView == null) {
|
||||
photoFilterView = new PhotoFilterView(parentActivity, centerImage.getBitmap(), centerImage.getOrientation());
|
||||
containerView.addView(photoFilterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
containerView.addView(photoFilterView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
photoFilterView.getDoneTextView().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -2236,9 +2326,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
captionEditText.setVisibility(cropItem.getVisibility());
|
||||
needCaptionLayout = captionItem.getVisibility() == View.VISIBLE;
|
||||
if (needCaptionLayout) {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) captionEditText.getLayoutParams();
|
||||
layoutParams.bottomMargin = -AndroidUtilities.dp(400);
|
||||
captionEditText.setLayoutParams(layoutParams);
|
||||
captionEditText.onCreate();
|
||||
}
|
||||
}
|
||||
@ -2288,7 +2375,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
currentMessageObject = imagesArr.get(currentIndex);
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
|
||||
if (user != null) {
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
} else {
|
||||
nameTextView.setText("");
|
||||
}
|
||||
@ -2849,6 +2936,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (containerView == null) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
animationInProgress = 0;
|
||||
transitionAnimationStartTime = 0;
|
||||
setImages();
|
||||
@ -2892,7 +2982,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
animatorSet.start();
|
||||
}
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
backgroundDrawable.drawRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -3052,6 +3144,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
animationEndRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
}
|
||||
@ -3078,6 +3173,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
animatorSet.start();
|
||||
} else {
|
||||
AnimatorSetProxy animatorSet = new AnimatorSetProxy();
|
||||
@ -3094,6 +3192,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
if (containerView == null) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_NONE, null);
|
||||
}
|
||||
animationInProgress = 0;
|
||||
onPhotoClosed(object);
|
||||
ViewProxy.setScaleX(containerView, 1.0f);
|
||||
@ -3112,6 +3213,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
});
|
||||
transitionAnimationStartTime = System.currentTimeMillis();
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
containerView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
animatorSet.start();
|
||||
}
|
||||
}
|
||||
@ -3285,7 +3389,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
}
|
||||
}
|
||||
|
||||
if (captionEditText.isEmojiPopupShowing() || captionEditText.isKeyboardVisible()) {
|
||||
if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3776,7 +3880,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||
checkImageView.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) checkImageView.getLayoutParams();
|
||||
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) checkImageView.getLayoutParams();
|
||||
WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90 ? 58 : 68);
|
||||
|
@ -31,21 +31,22 @@ import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.NotificationsController;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
@ -55,7 +56,7 @@ import org.telegram.ui.Components.FrameLayoutFixed;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
import org.telegram.ui.Components.PopupAudioView;
|
||||
import org.telegram.ui.Components.RecordStatusDrawable;
|
||||
import org.telegram.ui.Components.SizeNotifierRelativeLayout;
|
||||
import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
||||
import org.telegram.ui.Components.TypingDotsDrawable;
|
||||
|
||||
import java.io.File;
|
||||
@ -164,38 +165,112 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
typingDotsDrawable = new TypingDotsDrawable();
|
||||
recordStatusDrawable = new RecordStatusDrawable();
|
||||
|
||||
SizeNotifierRelativeLayout contentView = new SizeNotifierRelativeLayout(this);
|
||||
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this) {
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
||||
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
setMeasuredDimension(widthSize, heightSize);
|
||||
|
||||
int keyboardSize = getKeyboardHeight();
|
||||
|
||||
if (keyboardSize <= AndroidUtilities.dp(20)) {
|
||||
heightSize -= chatActivityEnterView.getEmojiPadding();
|
||||
}
|
||||
|
||||
int childCount = getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
if (chatActivityEnterView.isPopupView(child)) {
|
||||
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
|
||||
} else {
|
||||
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)), MeasureSpec.EXACTLY));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
final int count = getChildCount();
|
||||
|
||||
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) ? chatActivityEnterView.getEmojiPadding() : 0;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
final View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
|
||||
int width = child.getMeasuredWidth();
|
||||
int height = child.getMeasuredHeight();
|
||||
|
||||
int childLeft;
|
||||
int childTop;
|
||||
|
||||
int gravity = lp.gravity;
|
||||
if (gravity == -1) {
|
||||
gravity = Gravity.TOP | Gravity.LEFT;
|
||||
}
|
||||
|
||||
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
|
||||
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
||||
case Gravity.CENTER_HORIZONTAL:
|
||||
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.RIGHT:
|
||||
childLeft = r - width - lp.rightMargin;
|
||||
break;
|
||||
case Gravity.LEFT:
|
||||
default:
|
||||
childLeft = lp.leftMargin;
|
||||
}
|
||||
|
||||
switch (verticalGravity) {
|
||||
case Gravity.TOP:
|
||||
childTop = lp.topMargin;
|
||||
break;
|
||||
case Gravity.CENTER_VERTICAL:
|
||||
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
|
||||
break;
|
||||
case Gravity.BOTTOM:
|
||||
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
|
||||
break;
|
||||
default:
|
||||
childTop = lp.topMargin;
|
||||
}
|
||||
if (chatActivityEnterView.isPopupView(child)) {
|
||||
childTop = paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight();
|
||||
}
|
||||
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
||||
}
|
||||
|
||||
notifyHeightChanged();
|
||||
}
|
||||
};
|
||||
setContentView(contentView);
|
||||
contentView.setBackgroundColor(0x99000000);
|
||||
|
||||
RelativeLayout relativeLayout = new RelativeLayout(this);
|
||||
contentView.addView(relativeLayout);
|
||||
RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) relativeLayout.getLayoutParams();
|
||||
layoutParams3.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams3.height = LayoutHelper.MATCH_PARENT;
|
||||
relativeLayout.setLayoutParams(layoutParams3);
|
||||
contentView.addView(relativeLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
||||
|
||||
RelativeLayout popupContainer = new RelativeLayout(this);
|
||||
popupContainer.setBackgroundColor(0xffffffff);
|
||||
relativeLayout.addView(popupContainer);
|
||||
layoutParams3 = (RelativeLayout.LayoutParams) popupContainer.getLayoutParams();
|
||||
layoutParams3.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams3.height = AndroidUtilities.dp(240);
|
||||
layoutParams3.leftMargin = AndroidUtilities.dp(12);
|
||||
layoutParams3.rightMargin = AndroidUtilities.dp(12);
|
||||
layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT);
|
||||
popupContainer.setLayoutParams(layoutParams3);
|
||||
relativeLayout.addView(popupContainer, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT));
|
||||
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.onDestroy();
|
||||
}
|
||||
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
|
||||
popupContainer.addView(chatActivityEnterView);
|
||||
layoutParams3 = (RelativeLayout.LayoutParams) chatActivityEnterView.getLayoutParams();
|
||||
layoutParams3.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams3.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
||||
chatActivityEnterView.setLayoutParams(layoutParams3);
|
||||
popupContainer.addView(chatActivityEnterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
||||
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
|
||||
@Override
|
||||
public void onMessageSend(String message) {
|
||||
@ -750,7 +825,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
}
|
||||
int padding = (AndroidUtilities.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
|
||||
avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -768,7 +843,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
messageContainer.setLayoutParams(layoutParams);
|
||||
applyViewsLayoutParams(0);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -873,11 +948,11 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
|
||||
if (currentChat != null && currentUser != null) {
|
||||
nameTextView.setText(currentChat.title);
|
||||
onlineTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
|
||||
onlineTextView.setText(UserObject.getUserName(currentUser));
|
||||
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||
nameTextView.setCompoundDrawablePadding(0);
|
||||
} else if (currentUser != null) {
|
||||
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(currentUser));
|
||||
if ((int)dialog_id == 0) {
|
||||
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
||||
nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
|
||||
@ -904,10 +979,10 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
if (currentUser.phone != null && currentUser.phone.length() != 0) {
|
||||
nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
|
||||
} else {
|
||||
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(currentUser));
|
||||
}
|
||||
} else {
|
||||
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(currentUser));
|
||||
}
|
||||
CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId());
|
||||
if (printString == null || printString.length() == 0) {
|
||||
@ -985,8 +1060,8 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (chatActivityEnterView.isEmojiPopupShowing()) {
|
||||
chatActivityEnterView.hideEmojiPopup();
|
||||
if (chatActivityEnterView.isPopupShowing()) {
|
||||
chatActivityEnterView.hidePopup();
|
||||
return;
|
||||
}
|
||||
super.onBackPressed();
|
||||
@ -1009,7 +1084,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
|
||||
super.onPause();
|
||||
overridePendingTransition(0, 0);
|
||||
if (chatActivityEnterView != null) {
|
||||
chatActivityEnterView.hideEmojiPopup();
|
||||
chatActivityEnterView.hidePopup();
|
||||
chatActivityEnterView.setFieldFocused(false);
|
||||
}
|
||||
ConnectionsManager.getInstance().setAppPaused(true, false);
|
||||
|
@ -14,6 +14,8 @@ import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -278,6 +280,18 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
private class ListAdapter extends BaseFragmentAdapter {
|
||||
|
@ -18,6 +18,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -32,6 +33,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
@ -41,6 +44,9 @@ import android.widget.TextView;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
@ -50,6 +56,8 @@ import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.SecretChatHelper;
|
||||
import org.telegram.android.SendMessagesHelper;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.android.query.BotQuery;
|
||||
import org.telegram.android.query.SharedMediaQuery;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.ConnectionsManager;
|
||||
@ -90,7 +98,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private TextView nameTextView;
|
||||
private TextView onlineTextView;
|
||||
private ImageView writeButton;
|
||||
|
||||
private AnimatorSetProxy writeButtonAnimation;
|
||||
private int user_id;
|
||||
private int chat_id;
|
||||
private long dialog_id;
|
||||
@ -105,6 +113,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
private TLRPC.EncryptedChat currentEncryptedChat;
|
||||
private TLRPC.Chat currentChat;
|
||||
private TLRPC.BotInfo botInfo;
|
||||
|
||||
private int totalMediaCount = -1;
|
||||
|
||||
@ -116,6 +125,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private final static int add_member = 6;
|
||||
private final static int leave_group = 7;
|
||||
private final static int edit_name = 8;
|
||||
private final static int invite_to_group = 9;
|
||||
private final static int share = 10;
|
||||
|
||||
private int overscrollRow;
|
||||
private int emptyRow;
|
||||
@ -129,6 +140,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
private int sharedMediaRow;
|
||||
private int startSecretChatRow;
|
||||
private int sectionRow;
|
||||
private int botSectionRow;
|
||||
private int botInfoRow;
|
||||
private int membersSectionRow;
|
||||
private int membersEndRow;
|
||||
private int addMemberRow;
|
||||
@ -147,7 +160,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
if (dialog_id != 0) {
|
||||
currentEncryptedChat = MessagesController.getInstance().getEncryptedChat((int) (dialog_id >> 32));
|
||||
}
|
||||
if (MessagesController.getInstance().getUser(user_id) == null) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user == null) {
|
||||
return false;
|
||||
}
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
@ -155,8 +169,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatCreated);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.encryptedChatUpdated);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.botInfoDidLoaded);
|
||||
userBlocked = MessagesController.getInstance().blockedUsers.contains(user_id);
|
||||
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
BotQuery.loadBotInfo(user.id, true, classGuid);
|
||||
}
|
||||
MessagesController.getInstance().loadFullUser(MessagesController.getInstance().getUser(user_id), classGuid);
|
||||
} else if (chat_id != 0) {
|
||||
currentChat = MessagesController.getInstance().getChat(chat_id);
|
||||
@ -222,6 +239,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatCreated);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.botInfoDidLoaded);
|
||||
MessagesController.getInstance().cancelLoadFullUser(user_id);
|
||||
} else if (chat_id != 0) {
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.chatInfoDidLoaded);
|
||||
@ -278,7 +296,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
} else if (id == share_contact) {
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
args.putBoolean("serverOnly", true);
|
||||
args.putInt("dialogsType", 1);
|
||||
MessagesActivity fragment = new MessagesActivity(args);
|
||||
fragment.setDelegate(ProfileActivity.this);
|
||||
presentFragment(fragment);
|
||||
@ -322,6 +340,47 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", chat_id);
|
||||
presentFragment(new ChangeChatNameActivity(args));
|
||||
} else if (id == invite_to_group) {
|
||||
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("onlySelect", true);
|
||||
args.putInt("dialogsType", 2);
|
||||
args.putString("addToGroupAlertString", LocaleController.formatString("AddToTheGroupTitle", R.string.AddToTheGroupTitle, UserObject.getUserName(user), "%1$s"));
|
||||
MessagesActivity fragment = new MessagesActivity(args);
|
||||
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
|
||||
@Override
|
||||
public void didSelectDialog(MessagesActivity fragment, long did, boolean param) {
|
||||
NotificationCenter.getInstance().removeObserver(ProfileActivity.this, NotificationCenter.closeChats);
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
|
||||
MessagesController.getInstance().addUserToChat(-(int) did, user, null, 0, null);
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("scrollToTopOnResume", true);
|
||||
args.putInt("chat_id", -(int) did);
|
||||
presentFragment(new ChatActivity(args), true);
|
||||
removeSelfFromStack();
|
||||
}
|
||||
});
|
||||
presentFragment(fragment);
|
||||
} else if (id == share) {
|
||||
try {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("text/plain");
|
||||
if (botInfo != null && botInfo.share_text != null && botInfo.share_text.length() > 0) {
|
||||
intent.putExtra(Intent.EXTRA_TEXT, String.format("%s https://telegram.me/%s", botInfo.share_text, user.username));
|
||||
} else {
|
||||
intent.putExtra(Intent.EXTRA_TEXT, String.format("https://telegram.me/%s", user.username));
|
||||
}
|
||||
startActivityForResult(Intent.createChooser(intent, LocaleController.getString("BotShare", R.string.BotShare)), 500);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -330,7 +389,34 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
fragmentView = new FrameLayout(context) {
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
if (child == listView) {
|
||||
boolean result = super.drawChild(canvas, child, drawingTime);
|
||||
if (parentLayout != null) {
|
||||
int actionBarHeight = 0;
|
||||
int childCount = getChildCount();
|
||||
for (int a = 0; a < childCount; a++) {
|
||||
View view = getChildAt(a);
|
||||
if (view == child) {
|
||||
continue;
|
||||
}
|
||||
if (view instanceof ActionBar && view.getVisibility() == VISIBLE) {
|
||||
if (((ActionBar) view).getCastShadows()) {
|
||||
actionBarHeight = view.getMeasuredHeight();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
parentLayout.drawHeaderShadow(canvas, actionBarHeight);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return super.drawChild(canvas, child, drawingTime);
|
||||
}
|
||||
}
|
||||
};
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
|
||||
avatarImage = new BackupImageView(context);
|
||||
@ -479,6 +565,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
} else if (i == 1) {
|
||||
try {
|
||||
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
||||
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
clipboard.setText("+" + user.phone);
|
||||
@ -487,6 +574,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -680,18 +770,18 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
args.putBoolean("onlyUsers", true);
|
||||
args.putBoolean("destroyAfterSelect", true);
|
||||
args.putBoolean("returnAsResult", true);
|
||||
//args.putBoolean("allowUsernameSearch", false);
|
||||
if (chat_id > 0) {
|
||||
if (info != null && info.admin_id == UserConfig.getClientUserId()) {
|
||||
args.putInt("chat_id", currentChat.id);
|
||||
}
|
||||
//args.putBoolean("allowUsernameSearch", false);
|
||||
if (chat_id > 0) {
|
||||
args.putString("selectAlertString", LocaleController.getString("AddToTheGroup", R.string.AddToTheGroup));
|
||||
}
|
||||
ContactsActivity fragment = new ContactsActivity(args);
|
||||
fragment.setDelegate(new ContactsActivity.ContactsActivityDelegate() {
|
||||
@Override
|
||||
public void didSelectContact(TLRPC.User user, String param) {
|
||||
MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0);
|
||||
MessagesController.getInstance().addUserToChat(chat_id, user, info, param != null ? Utilities.parseInt(param) : 0, null);
|
||||
}
|
||||
});
|
||||
if (info != null) {
|
||||
@ -746,10 +836,53 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
|
||||
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
|
||||
writeButton.setLayoutParams(layoutParams);
|
||||
ViewProxy.setAlpha(writeButton, diff);
|
||||
/*ViewProxy.setAlpha(writeButton, diff);
|
||||
writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE);
|
||||
if (writeButton.getVisibility() == View.GONE) {
|
||||
writeButton.clearAnimation();
|
||||
}*/
|
||||
final boolean setVisible = diff > 0.2f;
|
||||
boolean currentVisible = writeButton.getTag() == null;
|
||||
if (setVisible != currentVisible) {
|
||||
if (setVisible) {
|
||||
writeButton.setTag(null);
|
||||
writeButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
writeButton.setTag(0);
|
||||
}
|
||||
if (writeButtonAnimation != null) {
|
||||
AnimatorSetProxy old = writeButtonAnimation;
|
||||
writeButtonAnimation = null;
|
||||
old.cancel();
|
||||
}
|
||||
writeButtonAnimation = new AnimatorSetProxy();
|
||||
if (setVisible) {
|
||||
writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 1.0f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 1.0f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 1.0f)
|
||||
);
|
||||
} else {
|
||||
writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 0.2f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 0.2f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 0.0f)
|
||||
);
|
||||
}
|
||||
writeButtonAnimation.setDuration(150);
|
||||
writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Object animation) {
|
||||
if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
|
||||
writeButton.clearAnimation();
|
||||
writeButton.setVisibility(setVisible ? View.VISIBLE : View.GONE);
|
||||
writeButtonAnimation = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
writeButtonAnimation.start();
|
||||
}
|
||||
}
|
||||
|
||||
@ -794,7 +927,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
needLayout();
|
||||
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -903,6 +1036,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
}
|
||||
} else if (id == NotificationCenter.closeChats) {
|
||||
removeSelfFromStack();
|
||||
} else if (id == NotificationCenter.botInfoDidLoaded) {
|
||||
TLRPC.BotInfo info = (TLRPC.BotInfo) args[0];
|
||||
if (info.user_id == user_id) {
|
||||
botInfo = info;
|
||||
updateRowsIds();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1080,14 +1219,22 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
rowCount = 0;
|
||||
overscrollRow = rowCount++;
|
||||
if (user_id != 0) {
|
||||
emptyRow = rowCount++;
|
||||
phoneRow = rowCount++;
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
emptyRow = rowCount++;
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
phoneRow = -1;
|
||||
} else {
|
||||
phoneRow = rowCount++;
|
||||
}
|
||||
if (user != null && user.username != null && user.username.length() > 0) {
|
||||
usernameRow = rowCount++;
|
||||
} else {
|
||||
usernameRow = -1;
|
||||
}
|
||||
if (botInfo != null && botInfo.share_text != null && botInfo.share_text.length() > 0) {
|
||||
botSectionRow = rowCount++;
|
||||
botInfoRow = rowCount++;
|
||||
}
|
||||
sectionRow = rowCount++;
|
||||
settingsNotificationsRow = rowCount++;
|
||||
sharedMediaRow = rowCount++;
|
||||
@ -1098,7 +1245,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
settingsTimerRow = -1;
|
||||
settingsKeyRow = -1;
|
||||
}
|
||||
if (currentEncryptedChat == null) {
|
||||
if (user != null && (user.flags & TLRPC.USER_FLAG_BOT) == 0 && currentEncryptedChat == null) {
|
||||
startSecretChatRow = rowCount++;
|
||||
} else {
|
||||
startSecretChatRow = -1;
|
||||
@ -1148,12 +1295,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
avatarDrawable.setRadius(radius);
|
||||
avatarImage.setImage(photo, "50_50", avatarDrawable);
|
||||
|
||||
if (user instanceof TLRPC.TL_userDeleted) {
|
||||
nameTextView.setText(LocaleController.getString("HiddenName", R.string.HiddenName));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
onlineTextView.setText(LocaleController.getString("Bot", R.string.Bot));
|
||||
} else {
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
}
|
||||
onlineTextView.setText(LocaleController.formatUserStatus(user));
|
||||
}
|
||||
|
||||
avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
} else if (chat_id != 0) {
|
||||
@ -1218,6 +1365,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
return;
|
||||
}
|
||||
ActionBarMenuItem item = menu.addItem(0, dots);
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT) != 0) {
|
||||
if ((user.flags & TLRPC.USER_FLAG_BOT_CANT_JOIN_GROUP) == 0) {
|
||||
item.addSubItem(invite_to_group, LocaleController.getString("BotInvite", R.string.BotInvite), 0);
|
||||
}
|
||||
item.addSubItem(share, LocaleController.getString("BotShare", R.string.BotShare), 0);
|
||||
}
|
||||
if (user.phone != null && user.phone.length() != 0) {
|
||||
item.addSubItem(add_contact, LocaleController.getString("AddContact", R.string.AddContact), 0);
|
||||
item.addSubItem(share_contact, LocaleController.getString("ShareContact", R.string.ShareContact), 0);
|
||||
@ -1384,6 +1537,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
} else {
|
||||
value = String.format("%d", totalMediaCount);
|
||||
}
|
||||
textCell.setMultiline(false);
|
||||
textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value);
|
||||
textCell.setValueColor(themePrefs.getInt("profileTitleColor", def));
|
||||
} else if (i == settingsTimerRow) {
|
||||
@ -1394,13 +1548,16 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
} else {
|
||||
value = AndroidUtilities.formatTTLString(encryptedChat.ttl);
|
||||
}
|
||||
textCell.setMultiline(false);
|
||||
textCell.setTextAndValue(LocaleController.getString("MessageLifetime", R.string.MessageLifetime), value);
|
||||
} else if (i == settingsNotificationsRow) {
|
||||
textCell.setMultiline(false);
|
||||
//textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list);
|
||||
Drawable pf = mContext.getResources().getDrawable(R.drawable.profile_list);
|
||||
pf.setColorFilter(dColor, PorterDuff.Mode.SRC_IN);
|
||||
textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), pf);
|
||||
} else if (i == startSecretChatRow) {
|
||||
textCell.setMultiline(false);
|
||||
textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
||||
//textCell.setTextColor(0xff37a919);
|
||||
textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
|
||||
@ -1408,7 +1565,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
IdenticonDrawable identiconDrawable = new IdenticonDrawable();
|
||||
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
|
||||
identiconDrawable.setEncryptedChat(encryptedChat);
|
||||
textCell.setMultiline(false);
|
||||
textCell.setTextAndValueDrawable(LocaleController.getString("EncryptionKey", R.string.EncryptionKey), identiconDrawable);
|
||||
} else if (i == botInfoRow) {
|
||||
textCell.setMultiline(true);
|
||||
textCell.setTextAndIcon(botInfo.share_text, R.drawable.bot_info);
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (view == null) {
|
||||
@ -1435,6 +1596,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
} else if (type == 6) {
|
||||
if (view == null) {
|
||||
view = new AddMemberCell(mContext);
|
||||
if (chat_id > 0) {
|
||||
((AddMemberCell) view).setText(LocaleController.getString("AddMember", R.string.AddMember));
|
||||
} else {
|
||||
((AddMemberCell) view).setText(LocaleController.getString("AddRecipient", R.string.AddRecipient));
|
||||
}
|
||||
}
|
||||
((AddMemberCell) view).setTextColor(tColor);
|
||||
((AddMemberCell) view).setDrawableColor(dColor);
|
||||
@ -1447,11 +1613,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
public int getItemViewType(int i) {
|
||||
if (i == emptyRow || i == overscrollRow || i == emptyRowChat || i == emptyRowChat2) {
|
||||
return 0;
|
||||
} else if (i == sectionRow) {
|
||||
} else if (i == sectionRow || i == botSectionRow) {
|
||||
return 1;
|
||||
} else if (i == phoneRow || i == usernameRow) {
|
||||
return 2;
|
||||
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == startSecretChatRow || i == settingsKeyRow) {
|
||||
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == startSecretChatRow || i == settingsKeyRow || i == botInfoRow) {
|
||||
return 3;
|
||||
} else if (i > emptyRowChat2 && i < membersEndRow) {
|
||||
return 4;
|
||||
|
@ -115,6 +115,8 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
|
||||
listView = new ListView(context);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
listView.setBackgroundColor(preferences.getInt("prefBGColor", 0xffffffff));
|
||||
listView.setDivider(null);
|
||||
listView.setDividerHeight(0);
|
||||
listView.setVerticalScrollBarEnabled(false);
|
||||
|
@ -296,6 +296,18 @@ public class SessionsActivity extends BaseFragment implements NotificationCenter
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Outline;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@ -40,6 +41,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewOutlineProvider;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.FrameLayout;
|
||||
@ -50,14 +53,17 @@ import android.widget.Toast;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.android.AndroidUtilities;
|
||||
import org.telegram.android.AnimationCompat.AnimatorListenerAdapterProxy;
|
||||
import org.telegram.android.AnimationCompat.AnimatorSetProxy;
|
||||
import org.telegram.android.AnimationCompat.ObjectAnimatorProxy;
|
||||
import org.telegram.android.AnimationCompat.ViewProxy;
|
||||
import org.telegram.android.ContactsController;
|
||||
import org.telegram.android.LocaleController;
|
||||
import org.telegram.android.MediaController;
|
||||
import org.telegram.android.MessageObject;
|
||||
import org.telegram.android.MessagesController;
|
||||
import org.telegram.android.MessagesStorage;
|
||||
import org.telegram.android.NotificationCenter;
|
||||
import org.telegram.android.UserObject;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
import org.telegram.messenger.BuildVars;
|
||||
@ -101,6 +107,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
private TextView nameTextView;
|
||||
private TextView onlineTextView;
|
||||
private ImageView writeButton;
|
||||
private AnimatorSetProxy writeButtonAnimation;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
|
||||
private int overscrollRow;
|
||||
@ -140,6 +147,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
private int rowCount;
|
||||
private int disableMessageClickRow;
|
||||
private int showAndroidEmojiRow;
|
||||
private int useDeviceFontRow;
|
||||
private int keepOriginalFilenameRow;
|
||||
private int keepOriginalFilenameDetailRow;
|
||||
private int emojiPopupSize;
|
||||
@ -241,6 +249,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
} else {
|
||||
showAndroidEmojiRow = -1;
|
||||
}
|
||||
useDeviceFontRow = rowCount++;
|
||||
mediaDownloadSection = rowCount++;
|
||||
mediaDownloadSection2 = rowCount++;
|
||||
mobileDownloadRow = rowCount++;
|
||||
@ -249,7 +258,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
saveToGalleryRow = rowCount++;
|
||||
keepOriginalFilenameRow = rowCount++;
|
||||
keepOriginalFilenameDetailRow = rowCount++;
|
||||
messagesSectionRow = -1;
|
||||
messagesSectionRow = rowCount++;
|
||||
|
||||
|
||||
|
||||
messagesSectionRow2 = rowCount++;
|
||||
textSizeRow = rowCount++;
|
||||
stickersRow = rowCount++;
|
||||
@ -297,6 +309,10 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(5));
|
||||
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5));
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
//Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
//SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
//back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
//actionBar.setBackButtonDrawable(back);
|
||||
actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBar.setOccupyStatusBar(false);
|
||||
@ -327,13 +343,44 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
});
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||
//ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
||||
|
||||
Drawable other = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_other);
|
||||
ActionBarMenuItem item = menu.addItem(0, other);
|
||||
|
||||
item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0);
|
||||
item.addSubItem(logout, LocaleController.getString("LogOut", R.string.LogOut), 0);
|
||||
|
||||
listAdapter = new ListAdapter(context);
|
||||
|
||||
fragmentView = new FrameLayout(context);
|
||||
fragmentView = new FrameLayout(context) {
|
||||
@Override
|
||||
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
||||
if (child == listView) {
|
||||
boolean result = super.drawChild(canvas, child, drawingTime);
|
||||
if (parentLayout != null) {
|
||||
int actionBarHeight = 0;
|
||||
int childCount = getChildCount();
|
||||
for (int a = 0; a < childCount; a++) {
|
||||
View view = getChildAt(a);
|
||||
if (view == child) {
|
||||
continue;
|
||||
}
|
||||
if (view instanceof ActionBar && view.getVisibility() == VISIBLE) {
|
||||
if (((ActionBar) view).getCastShadows()) {
|
||||
actionBarHeight = view.getMeasuredHeight();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
parentLayout.drawHeaderShadow(canvas, actionBarHeight);
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return super.drawChild(canvas, child, drawingTime);
|
||||
}
|
||||
}
|
||||
};
|
||||
FrameLayout frameLayout = (FrameLayout) fragmentView;
|
||||
|
||||
avatarImage = new BackupImageView(context);
|
||||
@ -349,9 +396,11 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
nameTextView = new TextView(context);
|
||||
nameTextView.setTextColor(0xffffffff);
|
||||
//nameTextView.setTextColor(0xffffffff);
|
||||
nameTextView.setTextColor(preferences.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
nameTextView.setLines(1);
|
||||
nameTextView.setMaxLines(1);
|
||||
@ -373,7 +422,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
actionBar.addView(onlineTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM, LocaleController.isRTL ? 16 : 97, 0, LocaleController.isRTL ? 97 : 16, 30));
|
||||
|
||||
listView = new ListView(context);
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
|
||||
int bgColor = preferences.getInt("prefBGColor", 0xffffffff);
|
||||
listView.setBackgroundColor(bgColor);
|
||||
listView.setDivider(null);
|
||||
@ -459,6 +508,26 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(!enabled);
|
||||
}
|
||||
} else if (i == useDeviceFontRow) {
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
boolean enabled = preferences.getBoolean("useDeviceFont", false);
|
||||
editor.putBoolean("useDeviceFont", !enabled);
|
||||
editor.commit();
|
||||
ApplicationLoader.USE_DEVICE_FONT = !enabled;
|
||||
AndroidUtilities.needRestart = true;
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getParentActivity() != null) {
|
||||
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("AppWillRestart", R.string.AppWillRestart), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (view instanceof TextCheckCell) {
|
||||
((TextCheckCell) view).setChecked(!enabled);
|
||||
}
|
||||
} else if (i == notificationRow) {
|
||||
presentFragment(new NotificationsSettingsActivity());
|
||||
} else if (i == backgroundRow) {
|
||||
@ -945,9 +1014,25 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateUserData();
|
||||
updateTheme();
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
|
||||
Drawable other = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_other);
|
||||
other.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
@ -978,10 +1063,52 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
layoutParams = (FrameLayout.LayoutParams) writeButton.getLayoutParams();
|
||||
layoutParams.topMargin = (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0) + AndroidUtilities.getCurrentActionBarHeight() + actionBar.getExtraHeight() - AndroidUtilities.dp(29.5f);
|
||||
writeButton.setLayoutParams(layoutParams);
|
||||
ViewProxy.setAlpha(writeButton, diff);
|
||||
writeButton.setVisibility(diff <= 0.02 ? View.GONE : View.VISIBLE);
|
||||
if (writeButton.getVisibility() == View.GONE) {
|
||||
|
||||
//ViewProxy.setScaleX(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f);
|
||||
//ViewProxy.setScaleY(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f);
|
||||
//ViewProxy.setAlpha(writeButton, diff > 0.2f ? 1.0f : diff / 0.2f);
|
||||
final boolean setVisible = diff > 0.2f;
|
||||
boolean currentVisible = writeButton.getTag() == null;
|
||||
if (setVisible != currentVisible) {
|
||||
if (setVisible) {
|
||||
writeButton.setTag(null);
|
||||
writeButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
writeButton.setTag(0);
|
||||
}
|
||||
if (writeButtonAnimation != null) {
|
||||
AnimatorSetProxy old = writeButtonAnimation;
|
||||
writeButtonAnimation = null;
|
||||
old.cancel();
|
||||
}
|
||||
writeButtonAnimation = new AnimatorSetProxy();
|
||||
if (setVisible) {
|
||||
writeButtonAnimation.setInterpolator(new DecelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 1.0f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 1.0f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 1.0f)
|
||||
);
|
||||
} else {
|
||||
writeButtonAnimation.setInterpolator(new AccelerateInterpolator());
|
||||
writeButtonAnimation.playTogether(
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleX", 0.2f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "scaleY", 0.2f),
|
||||
ObjectAnimatorProxy.ofFloat(writeButton, "alpha", 0.0f)
|
||||
);
|
||||
}
|
||||
writeButtonAnimation.setDuration(150);
|
||||
writeButtonAnimation.addListener(new AnimatorListenerAdapterProxy() {
|
||||
@Override
|
||||
public void onAnimationEnd(Object animation) {
|
||||
if (writeButtonAnimation != null && writeButtonAnimation.equals(animation)) {
|
||||
writeButton.clearAnimation();
|
||||
writeButton.setVisibility(setVisible ? View.VISIBLE : View.GONE);
|
||||
writeButtonAnimation = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
writeButtonAnimation.start();
|
||||
}
|
||||
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
|
||||
@ -1022,7 +1149,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
needLayout();
|
||||
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
|
||||
}
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1044,7 +1171,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
avatarImage.setImage(photo, "50_50", avatarDrawable);
|
||||
avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
|
||||
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
||||
nameTextView.setText(UserObject.getUserName(user));
|
||||
onlineTextView.setText(LocaleController.getString("Online", R.string.Online));
|
||||
|
||||
avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
@ -1098,7 +1225,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(int i) {
|
||||
return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow || i == showAndroidEmojiRow || i == emojiPopupSize ||
|
||||
return i == textSizeRow || i == enableAnimationsRow || i == notificationRow || i == backgroundRow || i == numberRow || i == showAndroidEmojiRow || i == useDeviceFontRow || i == emojiPopupSize ||
|
||||
i == askQuestionRow || i == sendLogsRow || i == sendByEnterRow || i == privacyRow || i == wifiDownloadRow || i == disableMessageClickRow ||
|
||||
i == mobileDownloadRow || i == clearLogsRow || i == roamingDownloadRow || i == languageRow || i == usernameRow ||
|
||||
i == switchBackendButtonRow || i == telegramFaqRow || i == contactsSortRow || i == contactsReimportRow || i == saveToGalleryRow || i == keepOriginalFilenameRow ||
|
||||
@ -1209,7 +1336,9 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
} else if (i == keepOriginalFilenameRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("KeepOriginalFilename", R.string.KeepOriginalFilename), ApplicationLoader.KEEP_ORIGINAL_FILENAME, false);
|
||||
} else if (i == showAndroidEmojiRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("ShowAndroidEmoji", R.string.ShowAndroidEmoji), ApplicationLoader.SHOW_ANDROID_EMOJI, false);
|
||||
textCell.setTextAndCheck(LocaleController.getString("ShowAndroidEmoji", R.string.ShowAndroidEmoji), ApplicationLoader.SHOW_ANDROID_EMOJI, true);
|
||||
} else if (i == useDeviceFontRow) {
|
||||
textCell.setTextAndCheck(LocaleController.getString("UseDeviceFont", R.string.UseDeviceFont), ApplicationLoader.USE_DEVICE_FONT, false);
|
||||
}
|
||||
} else if (type == 4) {
|
||||
if (view == null) {
|
||||
@ -1320,7 +1449,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
if (i == settingsSectionRow || i == supportSectionRow || i == messagesSectionRow || i == mediaDownloadSection || i == contactsSectionRow) {
|
||||
return 1;
|
||||
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == disableMessageClickRow || i == showAndroidEmojiRow || i == keepOriginalFilenameRow ) {
|
||||
} else if (i == enableAnimationsRow || i == sendByEnterRow || i == saveToGalleryRow || i == disableMessageClickRow || i == showAndroidEmojiRow || i == useDeviceFontRow || i == keepOriginalFilenameRow ) {
|
||||
return 3;
|
||||
} else if (i == notificationRow || i == backgroundRow || i == askQuestionRow || i == sendLogsRow || i == privacyRow || i == clearLogsRow || i == switchBackendButtonRow || i == telegramFaqRow || i == contactsReimportRow || i == textSizeRow || i == emojiPopupSize || i == languageRow || i == contactsSortRow || i == stickersRow) {
|
||||
return 2;
|
||||
|
@ -16,6 +16,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -119,17 +120,14 @@ public class ThemingActivity extends BaseFragment {
|
||||
public View createView(Context context, LayoutInflater inflater) {
|
||||
if (fragmentView == null) {
|
||||
|
||||
|
||||
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(5));
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
|
||||
|
||||
if (AndroidUtilities.isTablet()) {
|
||||
actionBar.setOccupyStatusBar(false);
|
||||
}
|
||||
actionBar.setTitle(LocaleController.getString("Theming", R.string.Theming));
|
||||
|
||||
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
@ -314,6 +312,15 @@ public class ThemingActivity extends BaseFragment {
|
||||
}
|
||||
});
|
||||
AndroidUtilities.needRestart = true;
|
||||
AndroidUtilities.runOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (getParentActivity() != null) {
|
||||
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("AppWillRestart", R.string.AppWillRestart), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
@ -358,70 +365,6 @@ public class ThemingActivity extends BaseFragment {
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
private void showAttachmentError() {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnsupportedAttachment", R.string.UnsupportedAttachment), Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
/*
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (requestCode == 0) {
|
||||
|
||||
} else if (requestCode == 22) {
|
||||
if (data == null || data.getData() == null) {
|
||||
showAttachmentError();
|
||||
return;
|
||||
}
|
||||
String tempPath = Utilities.getPath(data.getData());
|
||||
String originalPath = tempPath;
|
||||
if (tempPath == null) {
|
||||
originalPath = data.toString();
|
||||
tempPath = MediaController.copyDocumentToCache(data.getData(), "file");
|
||||
}
|
||||
if (tempPath == null) {
|
||||
showAttachmentError();
|
||||
return;
|
||||
}
|
||||
Toast toast = Toast.makeText(getParentActivity(), tempPath + "\n " + originalPath, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
//SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, null, null, Long.parseLong(null));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
private void saveThemeDialog(){
|
||||
|
||||
LayoutInflater li = LayoutInflater.from(getParentActivity());
|
||||
View promptsView = li.inflate(R.layout.editbox_dialog, null);
|
||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getParentActivity());
|
||||
alertDialogBuilder.setView(promptsView);
|
||||
final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);
|
||||
|
||||
alertDialogBuilder
|
||||
.setCancelable(false)
|
||||
.setPositiveButton(R.string.ok,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
savePrefs(Utils.this);
|
||||
String pName = userInput.getText().toString();
|
||||
functions.savePreferencesToSD(Utils.this,my_pref_file_name+".xml",pName+".xml",true);
|
||||
functions.copyWallpaperToSD(Utils.this,pName,true);
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel,
|
||||
new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog,int id) {
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||
alertDialog.show();
|
||||
}*/
|
||||
|
||||
private void commitInt(int i){
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
SharedPreferences.Editor editor = preferences.edit();
|
||||
@ -450,6 +393,8 @@ public class ThemingActivity extends BaseFragment {
|
||||
editor.putInt("contactsHeaderColor", i);
|
||||
editor.putInt("contactsOnlineColor", darkColor);
|
||||
|
||||
editor.putInt("prefHeaderColor", i);
|
||||
|
||||
editor.commit();
|
||||
fixLayout();
|
||||
AndroidUtilities.themeColor = i;
|
||||
@ -462,6 +407,18 @@ public class ThemingActivity extends BaseFragment {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
fixLayout();
|
||||
updateTheme();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,6 +14,8 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -971,9 +973,21 @@ public class ThemingChatActivity extends BaseFragment {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateTheme();
|
||||
fixLayout();
|
||||
}
|
||||
|
||||
private void updateTheme(){
|
||||
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
|
||||
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
|
||||
actionBar.setBackgroundColor(themePrefs.getInt("prefHeaderColor", def));
|
||||
actionBar.setTitleColor(themePrefs.getInt("prefHeaderTitleColor", 0xffffffff));
|
||||
|
||||
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
|
||||
back.setColorFilter(themePrefs.getInt("prefHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
|
||||
actionBar.setBackButtonDrawable(back);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user