diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle
index e8637c4d..3b892e53 100644
--- a/TMessagesProj/build.gradle
+++ b/TMessagesProj/build.gradle
@@ -89,7 +89,7 @@ android {
applicationId "org.telegram.plus"
minSdkVersion 8
targetSdkVersion 22
- versionCode 475
- versionName "2.6.1.1"
+ versionCode 492
+ versionName "2.7.0.1"
}
}
diff --git a/TMessagesProj/jni/Android.mk b/TMessagesProj/jni/Android.mk
index ae2c6323..f9b84ba9 100755
--- a/TMessagesProj/jni/Android.mk
+++ b/TMessagesProj/jni/Android.mk
@@ -104,7 +104,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false
LOCAL_STATIC_LIBRARIES := webp sqlite
-LOCAL_MODULE := tmessages.6
+LOCAL_MODULE := tmessages.7
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math
diff --git a/TMessagesProj/jni/image.c b/TMessagesProj/jni/image.c
index 06c5e9f3..85a85900 100644
--- a/TMessagesProj/jni/image.c
+++ b/TMessagesProj/jni/image.c
@@ -419,6 +419,11 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass
free(cdfsMin);
}
+JNIEXPORT int Java_org_telegram_messenger_Utilities_pinBitmap(JNIEnv *env, jclass class, jobject bitmap) {
+ unsigned char *pixels;
+ return AndroidBitmap_lockPixels(env, bitmap, &pixels) >= 0 ? 1 : 0;
+}
+
JNIEXPORT void Java_org_telegram_messenger_Utilities_loadBitmap(JNIEnv *env, jclass class, jstring path, jobject bitmap, int scale, int width, int height, int stride) {
AndroidBitmapInfo info;
diff --git a/TMessagesProj/libs/armeabi-v7a/libtmessages.6.so b/TMessagesProj/libs/armeabi-v7a/libtmessages.6.so
deleted file mode 100644
index 41f66ec8..00000000
Binary files a/TMessagesProj/libs/armeabi-v7a/libtmessages.6.so and /dev/null differ
diff --git a/TMessagesProj/libs/armeabi/libtmessages.6.so b/TMessagesProj/libs/armeabi/libtmessages.6.so
deleted file mode 100644
index aa46c089..00000000
Binary files a/TMessagesProj/libs/armeabi/libtmessages.6.so and /dev/null differ
diff --git a/TMessagesProj/libs/x86/libtmessages.6.so b/TMessagesProj/libs/x86/libtmessages.6.so
deleted file mode 100644
index e455cf5a..00000000
Binary files a/TMessagesProj/libs/x86/libtmessages.6.so and /dev/null differ
diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index 1a664aad..a484954a 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -39,8 +39,6 @@
-
")) != -1) {
+ stringBuilder.replace(start, start + 4, "\n");
+ }
+ while ((start = stringBuilder.indexOf("
")) != -1) {
+ stringBuilder.replace(start, start + 5, "\n");
+ }
ArrayList bolds = new ArrayList<>();
- while ((start = str.indexOf("")) != -1) {
- int end = str.indexOf("") - 3;
- str = str.replaceFirst("", "").replaceFirst("", "");
+ ArrayList colors = new ArrayList<>();
+ while ((start = stringBuilder.indexOf("")) != -1 || (startColor = stringBuilder.indexOf("");
+ stringBuilder.replace(end, end + 4, "");
bolds.add(start);
bolds.add(end);
- }
- SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str);
+ } 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, "");
+ end = stringBuilder.indexOf("");
+ stringBuilder.replace(end, end + 4, "");
+ colors.add(startColor);
+ colors.add(end);
+ colors.add(color);
+ }
+ }
+ SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
for (int a = 0; a < bolds.size() / 2; a++) {
- TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- stringBuilder.setSpan(span, bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
+ spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ for (int a = 0; a < colors.size() / 3; a++) {
+ spannableStringBuilder.setSpan(new ForegroundColorSpan(colors.get(a * 3 + 2)), colors.get(a * 3), colors.get(a * 3 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ }
+ return spannableStringBuilder;
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
}
- return stringBuilder;
+ return new SpannableStringBuilder(str);
}
public static boolean needShowPasscode(boolean reset) {
@@ -590,6 +616,61 @@ public class AndroidUtilities {
(UserConfig.appLocked || UserConfig.autoLockIn != 0 && UserConfig.lastPauseTime != 0 && !UserConfig.appLocked && (UserConfig.lastPauseTime + UserConfig.autoLockIn) <= ConnectionsManager.getInstance().getCurrentTime());
}
+ public static void shakeTextView(final TextView textView, final float x, final int num) {
+ if (num == 6) {
+ ViewProxy.setTranslationX(textView, 0);
+ textView.clearAnimation();
+ return;
+ }
+ AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
+ animatorSetProxy.playTogether(ObjectAnimatorProxy.ofFloat(textView, "translationX", AndroidUtilities.dp(x)));
+ animatorSetProxy.setDuration(50);
+ animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
+ @Override
+ public void onAnimationEnd(Object animation) {
+ shakeTextView(textView, num == 5 ? 0 : -x, num + 1);
+ }
+ });
+ animatorSetProxy.start();
+ }
+
+
+
+ /*public static String ellipsize(String text, int maxLines, int maxWidth, TextPaint paint) {
+ if (text == null || paint == null) {
+ return null;
+ }
+ int count;
+ int offset = 0;
+ StringBuilder result = null;
+ TextView
+ for (int a = 0; a < maxLines; a++) {
+ count = paint.breakText(text, true, maxWidth, null);
+ if (a != maxLines - 1) {
+ if (result == null) {
+ result = new StringBuilder(count * maxLines + 1);
+ }
+ boolean foundSpace = false;
+ for (int c = count - 1; c >= offset; c--) {
+ if (text.charAt(c) == ' ') {
+ foundSpace = true;
+ result.append(text.substring(offset, c - 1));
+ offset = c - 1;
+ }
+ }
+ if (!foundSpace) {
+ offset = count;
+ }
+ text = text.substring(0, offset);
+ } else if (maxLines == 1) {
+ return text.substring(0, count);
+ } else {
+ result.append(text.substring(0, count));
+ }
+ }
+ return result.toString();
+ }*/
+
/*public static void turnOffHardwareAcceleration(Window window) {
if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) {
return;
@@ -606,7 +687,13 @@ public class AndroidUtilities {
//PLUS
public static int getIntColor(String key){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(THEME_PREFS, THEME_PREFS_MODE);
- return themePrefs.getInt(key, defColor);
+ return themePrefs.getInt(key, defColor);//Def color is Teal
+ }
+
+ public static int getIntTColor(String key){
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(THEME_PREFS, THEME_PREFS_MODE);
+ int def = themePrefs.getInt("themeColor", defColor);
+ return themePrefs.getInt(key, def);//Def color is theme color
}
public static int getIntDef(String key, int def){
@@ -755,162 +842,6 @@ public class AndroidUtilities {
return d;
}
- public static void restartApp(){
- Intent mRestartApp = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
- 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);
- System.exit(0);
- }
-
- public static void savePreferencesToSD(Context context, String prefName, String tName, boolean toast){
- String folder = "/Telegram/Themes";
- File dataF = new File (findPrefFolder(context),prefName);
- if(checkSDStatus() > 1){
- File f = new File (Environment.getExternalStorageDirectory(), folder);
- f.mkdirs();
- File sdF = new File(f, tName);
- String s = getError(copyFile(dataF,sdF,true));
- if (s.equalsIgnoreCase("4")) {
- if(toast && sdF.getName()!="")Toast.makeText(context,context.getString(R.string.SavedTo,sdF.getName(),folder),Toast.LENGTH_SHORT ).show();
- }else if (s.contains("0")) {
- s = context.getString(R.string.SaveErrorMsg0);
- Toast.makeText(context,"ERROR: "+ s ,Toast.LENGTH_LONG ).show();
- }else{
- Toast.makeText(context,"ERROR: "+s,Toast.LENGTH_LONG ).show();
- Toast.makeText(context,dataF.getAbsolutePath(),Toast.LENGTH_LONG ).show();
- }
- }else{
- Toast.makeText(context,"ERROR: " + context.getString(R.string.NoMediaMessage) , Toast.LENGTH_LONG ).show();
- }
- }
-
- public static void copyWallpaperToSD(Context context, String tName, boolean toast){
- String folder = "/Telegram/Themes";
- String nFile = "wallpaper.jpg";
- if(checkSDStatus()>0){
- File f1 = context.getFilesDir();
- f1 = new File (f1.getAbsolutePath(), nFile);
- File f2 = new File (Environment.getExternalStorageDirectory(), folder);
- f2.mkdirs();
- f2 = new File(f2, tName+"_"+nFile);
- if(f1.length()>1){
- String s = getError(copyFile(f1,f2,true));
- if(s.contains("4")){
- if(toast && f2.getName()!="" && folder !="")Toast.makeText(context,context.getString(R.string.SavedTo,f2.getName(),folder),Toast.LENGTH_SHORT ).show();
- if(f2.getName()=="" || folder =="") Toast.makeText(context,"ERROR: "+s,Toast.LENGTH_SHORT ).show();
-
- }else{
- Toast.makeText(context,"ERROR: "+s+"\n"+f1.getAbsolutePath(),Toast.LENGTH_LONG ).show();
- }
- }
- }
- }
-
- static String findPrefFolder(Context context){
- File f = context.getFilesDir();
- String appDir = f.getAbsolutePath();
- File SPDir = new File (appDir.substring(0,appDir.lastIndexOf('/')+1)+ "shared_prefs/");
- if(!SPDir.exists()) {// && SPDir.isDirectory()) {
- String pck = context.getPackageName();
- SPDir=new File ("/dbdata/databases/"+pck+"/shared_prefs/");
- }
- //Log.i("TAG", SPDir.getAbsolutePath());
- return SPDir.getAbsolutePath();
- }
-
- static int checkSDStatus(){
- int b=0;
- String s = Environment.getExternalStorageState();
- if (s.equals(Environment.MEDIA_MOUNTED))b=2;
- else if (s.equals(Environment.MEDIA_MOUNTED_READ_ONLY))b=1;
- return b;
- }
-
- static String getError(int i){
- String s="-1";
- if(i==0)s="0: SOURCE FILE DOESN'T EXIST";
- if(i==1)s="1: DESTINATION FILE DOESN'T EXIST";
- if(i==2)s="2: NULL SOURCE & DESTINATION FILES";
- if(i==3)s="3: NULL SOURCE FILE";
- if(i==4)s="4";
- return s;
- }
-
- //0: source file doesn't exist
- //1: dest file doesn't exist
- //2: source & dest = NULL
- //3: source = NULL
- //4: dest = NULL
- static int copyFile(File sourceFile, File destFile, boolean save) {
- int i=-1;
- try{
- if (!sourceFile.exists()) {
- return i+1;
- }
- if (!destFile.exists()) {
- if(save)i=i+2;
- destFile.createNewFile();
- }
- FileChannel source = null;
- FileChannel destination = null;
- FileInputStream fileInputStream = new FileInputStream(sourceFile);
- source = fileInputStream.getChannel();
- FileOutputStream fileOutputStream = new FileOutputStream(destFile);
- destination = fileOutputStream.getChannel();
- if (destination != null && source != null) {
- destination.transferFrom(source, 0, source.size());
- i=2;
- }
- if (source != null) {
- source.close();
- i=3;
- }
- if (destination != null) {
- destination.close();
- i=4;
- }
- fileInputStream.close();
- fileOutputStream.close();
- }catch (Exception e)
- {
- System.err.println("Error saving preferences: " + e.getMessage());
- Log.e(e.getMessage() , e.toString());
- }
- return i;
- }
-
- public static int loadPrefFromSD(Context context, String prefPath){
- File dataF = new File (findPrefFolder(context), THEME_PREFS + ".xml");
- File prefFile = new File (prefPath);
- String s = getError(copyFile(prefFile, dataF, false));
- if (s.contains("0")) {
- Toast.makeText(context,"ERROR: "+ context.getString(R.string.restoreErrorMsg, prefFile.getAbsolutePath()) , Toast.LENGTH_LONG ).show();
- }
- return Integer.parseInt(s);
- }
-
- public static int loadWallpaperFromSDPath(Context context, String wPath){
- String nFile = "wallpaper.jpg";
- File f1 = context.getFilesDir();
- f1= new File (f1.getAbsolutePath(), nFile);
- //Log.i("f1", f1.getAbsolutePath());
- File wFile = new File (wPath);
- //Log.i("wPath", wPath);
- //Log.i("wFile", wFile.getAbsolutePath());
- String s = "-1";
- if (wFile.exists()){
- s = getError(copyFile(wFile,f1,false));
- if (s.contains("0")) {
- Toast.makeText(context,"ERROR: "+ context.getString(R.string.restoreErrorMsg,wFile.getAbsolutePath()) ,Toast.LENGTH_LONG ).show();
- }else{
- Toast.makeText(context,"ERROR: "+s+"\n"+wFile.getAbsolutePath(),Toast.LENGTH_LONG ).show();
- }
- }
- return Integer.parseInt(s);
- }
-
public static int getDefBubbleColor(){
int color = 0xffb2dfdb;//0xff80cbc4;
if(getIntColor("themeColor") != 0xff009688){
@@ -918,6 +849,7 @@ public class AndroidUtilities {
}
return color;
}
+
/*
static void modifyXMLfile(File preffile,String sname){
try {
diff --git a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java
index 3628ad92..4c116e37 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/ContactsController.java
@@ -22,6 +22,7 @@ import android.provider.ContactsContract;
import android.util.SparseArray;
import org.telegram.PhoneFormat.PhoneFormat;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
@@ -31,7 +32,6 @@ 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.util.ArrayList;
import java.util.Collections;
@@ -1773,7 +1773,7 @@ public class ContactsController {
}
public static String formatName(String firstName, String lastName) {
- String result = null;
+ String result = "";
if (LocaleController.nameDisplayOrder == 1) {
result = firstName;
if (result == null || result.length() == 0) {
diff --git a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java
index 08eb5190..1549263d 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/Emoji.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/Emoji.java
@@ -8,11 +8,6 @@
package org.telegram.android;
-import java.io.File;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Locale;
-
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
@@ -27,9 +22,14 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
-import org.telegram.messenger.ApplicationLoader;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Locale;
public class Emoji {
private static HashMap rects = new HashMap<>();
@@ -401,12 +401,17 @@ public class Emoji {
if (cs == null || cs.length() == 0) {
return cs;
}
+
Spannable s;
if (cs instanceof Spannable) {
s = (Spannable)cs;
} else {
s = Spannable.Factory.getInstance().newSpannable(cs);
}
+ // If showAndroidEmoji is enabled don't replace anything
+ if (android.os.Build.VERSION.SDK_INT >= 19 && ApplicationLoader.SHOW_ANDROID_EMOJI) {
+ return s;
+ }
long buf = 0;
int emojiCount = 0;
try {
diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java
index 2cca9e96..37c0267a 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/ImageLoader.java
@@ -26,6 +26,7 @@ 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;
@@ -33,7 +34,6 @@ 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;
@@ -645,9 +645,13 @@ public class ImageLoader {
} else {
opts.inPreferredConfig = Bitmap.Config.RGB_565;
}
+ //if (Build.VERSION.SDK_INT < 21) {
+ // opts.inPurgeable = true;
+ //}
+
opts.inDither = false;
if (mediaId != null) {
- image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, null);
+ image = MediaStore.Images.Thumbnails.getThumbnail(ApplicationLoader.applicationContext.getContentResolver(), mediaId, MediaStore.Images.Thumbnails.MINI_KIND, opts);
}
if (image == null) {
if (isWebp) {
@@ -1143,6 +1147,19 @@ public class ImageLoader {
} catch (Exception e) {
FileLog.e("tmessages", e);
}
+ // Themes
+ try {
+ File themesPath = new File(telegramPath, "Themes");
+ themesPath.mkdir();
+ if (themesPath.isDirectory()) {
+ new File(themesPath, ".nomedia").createNewFile();
+ mediaDirs.put(FileLoader.MEDIA_DIR_THEME, themesPath);
+ FileLog.e("tmessages", "themes path = " + themesPath);
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ //
}
} else {
FileLog.e("tmessages", "this Android can't rename files");
@@ -1981,6 +1998,15 @@ public class ImageLoader {
}
}
}
+ } else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
+ if (message.media.webpage.photo != null) {
+ for (TLRPC.PhotoSize size : message.media.webpage.photo.sizes) {
+ if (size instanceof TLRPC.TL_photoCachedSize) {
+ photoSize = size;
+ break;
+ }
+ }
+ }
}
if (photoSize != null && photoSize.bytes != null && photoSize.bytes.length != 0) {
if (photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) {
@@ -2018,6 +2044,13 @@ public class ImageLoader {
message.media.video.thumb = newPhotoSize;
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
message.media.document.thumb = newPhotoSize;
+ } else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
+ for (int a = 0; a < message.media.webpage.photo.sizes.size(); a++) {
+ if (message.media.webpage.photo.sizes.get(a) instanceof TLRPC.TL_photoCachedSize) {
+ message.media.webpage.photo.sizes.set(a, newPhotoSize);
+ break;
+ }
+ }
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java
index fa79c264..1f75dd4b 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/ImageReceiver.java
@@ -22,9 +22,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 {
@@ -224,10 +224,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setImageBitmap(bitmap != null ? new BitmapDrawable(null, bitmap) : null);
}
- public void setDisableRecycle(boolean value) {
- disableRecycle = value;
- }
-
public void setImageBitmap(Drawable bitmap) {
ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0);
recycleBitmap(null, false);
@@ -497,10 +493,18 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return imageX;
}
+ public int getImageX2() {
+ return imageX + imageW;
+ }
+
public int getImageY() {
return imageY;
}
+ public int getImageY2() {
+ return imageY + imageH;
+ }
+
public int getImageWidth() {
return imageW;
}
@@ -682,7 +686,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (newKey != null) {
newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey);
}
- if (key == null || image == null || image == newBitmap || disableRecycle) {
+ if (key == null || image == null || image == newBitmap) {
return;
}
Bitmap bitmap = image.getBitmap();
diff --git a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java
index 095a0f69..cd58ef94 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java
@@ -19,12 +19,12 @@ 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.Utilities;
-import org.telegram.messenger.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser;
import java.io.File;
@@ -158,6 +158,45 @@ public class LocaleController {
"tr", "vi", "wo", "yo", "zh", "bo", "dz", "id", "jv", "ka", "km", "kn", "ms", "th"}, new PluralRules_None());
LocaleInfo localeInfo = new LocaleInfo();
+ localeInfo.name = "English";
+ localeInfo.nameEnglish = "English";
+ localeInfo.shortName = "en";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Italiano";
+ localeInfo.nameEnglish = "Italian";
+ localeInfo.shortName = "it";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Español";
+ localeInfo.nameEnglish = "Spanish";
+ localeInfo.shortName = "es";
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Deutsch";
+ localeInfo.nameEnglish = "German";
+ localeInfo.shortName = "de";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Nederlands";
+ localeInfo.nameEnglish = "Dutch";
+ localeInfo.shortName = "nl";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
localeInfo.name = "العربية";
localeInfo.nameEnglish = "Arabic";
localeInfo.shortName = "ar";
@@ -181,6 +220,14 @@ public class LocaleController {
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "简体中文";
+ localeInfo.nameEnglish = "Simplified Chinese";
+ localeInfo.shortName = "zh_CN";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
localeInfo = new LocaleInfo();
localeInfo.name = "Hrvatski";
localeInfo.nameEnglish = "Croatian";
@@ -189,29 +236,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
- localeInfo = new LocaleInfo();
- localeInfo.name = "Deutsch";
- localeInfo.nameEnglish = "German";
- localeInfo.shortName = "de";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
- localeInfo = new LocaleInfo();
- localeInfo.name = "English";
- localeInfo.nameEnglish = "English";
- localeInfo.shortName = "en";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
- localeInfo = new LocaleInfo();
- localeInfo.name = "Español";
- localeInfo.nameEnglish = "Spanish";
- localeInfo.shortName = "es";
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
localeInfo = new LocaleInfo();
localeInfo.name = "Français";
localeInfo.nameEnglish = "French";
@@ -226,22 +250,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
- localeInfo = new LocaleInfo();
- localeInfo.name = "Italiano";
- localeInfo.nameEnglish = "Italian";
- localeInfo.shortName = "it";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
- localeInfo = new LocaleInfo();
- localeInfo.name = "Nederlands";
- localeInfo.nameEnglish = "Dutch";
- localeInfo.shortName = "nl";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
localeInfo = new LocaleInfo();
localeInfo.name = "Polski";
localeInfo.nameEnglish = "Polish";
@@ -250,22 +258,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
- localeInfo = new LocaleInfo();
- localeInfo.name = "Português (Brasil)";
- localeInfo.nameEnglish = "Portuguese (Brazil)";
- localeInfo.shortName = "pt_BR";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
- localeInfo = new LocaleInfo();
- localeInfo.name = "Português (Portugal)";
- localeInfo.nameEnglish = "Portuguese (Portugal)";
- localeInfo.shortName = "pt_PT";
- localeInfo.pathToFile = null;
- sortedLanguages.add(localeInfo);
- languagesDict.put(localeInfo.shortName, localeInfo);
-
localeInfo = new LocaleInfo();
localeInfo.name = "Русский";
localeInfo.nameEnglish = "Russian";
@@ -281,6 +273,22 @@ public class LocaleController {
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Português (Brasil)";
+ localeInfo.nameEnglish = "Portuguese (Brazil)";
+ localeInfo.shortName = "pt_BR";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
+ localeInfo = new LocaleInfo();
+ localeInfo.name = "Português (Portugal)";
+ localeInfo.nameEnglish = "Portuguese (Portugal)";
+ localeInfo.shortName = "pt_PT";
+ localeInfo.pathToFile = null;
+ sortedLanguages.add(localeInfo);
+ languagesDict.put(localeInfo.shortName, localeInfo);
+
localeInfo = new LocaleInfo();
localeInfo.name = "한국어";
localeInfo.nameEnglish = "Korean";
diff --git a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java
index 0fd27e2a..800b396c 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/MediaController.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/MediaController.java
@@ -48,6 +48,7 @@ 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;
@@ -56,7 +57,6 @@ 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;
@@ -1105,8 +1105,16 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
if (proximitySensor != null && audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] < proximitySensor.getMaximumRange() / 10))) {
return;
}
+ boolean newValue = event.values[0] < proximitySensor.getMaximumRange() / 10;
+ try {
+ if (newValue && NotificationsController.getInstance().audioManager.isWiredHeadsetOn()) {
+ return;
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
ignoreProximity = true;
- useFrontSpeaker = event.values[0] < proximitySensor.getMaximumRange() / 10;
+ useFrontSpeaker = newValue;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker);
MessageObject currentMessageObject = playingMessageObject;
float progress = playingMessageObject.audioProgress;
diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java
index da836f8c..774235e6 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/MessageObject.java
@@ -8,6 +8,7 @@
package org.telegram.android;
+import android.content.SharedPreferences;
import android.graphics.Paint;
import android.text.Layout;
import android.text.Spannable;
@@ -18,11 +19,12 @@ import android.text.TextPaint;
import android.text.TextUtils;
import android.text.util.Linkify;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
-import org.telegram.messenger.TLRPC;
import org.telegram.messenger.R;
+import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.URLSpanNoUnderline;
@@ -41,6 +43,7 @@ public class MessageObject {
public TLRPC.Message messageOwner;
public CharSequence messageText;
+ public CharSequence linkDescription;
public MessageObject replyMessageObject;
public int type;
public int contentType;
@@ -76,16 +79,17 @@ public class MessageObject {
textPaint.setColor(0xff000000);
textPaint.linkColor = 0xff316f9f;
}
-
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
- textPaintLeft.setColor(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000));
- textPaintLeft.linkColor = AndroidUtilities.getIntDarkerColor("chatLTextColor", -0x10);
+ textPaintLeft.setColor(themePrefs.getInt("chatLTextColor", 0xff000000));
+ textPaintLeft.linkColor = themePrefs.getInt("chatLLinkColor", def);
textPaintLeft.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
textPaint = textPaintLeft;
- textPaintRight.setColor(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000));
- textPaintRight.linkColor = AndroidUtilities.getIntDarkerColor("chatRTextColor", -0x10);
+ textPaintRight.setColor(themePrefs.getInt("chatRTextColor", 0xff000000));
+ textPaintRight.linkColor = themePrefs.getInt("chatRLinkColor", def);
textPaintRight.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
messageOwner = message;
@@ -96,6 +100,7 @@ public class MessageObject {
if(isOut()){
textPaint = textPaintRight;
+ textPaint.linkColor = themePrefs.getInt("chatRLinkColor", def);
}
if (message instanceof TLRPC.TL_messageService) {
@@ -288,7 +293,7 @@ public class MessageObject {
messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList);
}
}
- } else if (message.media != null && !(message.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ } else if (!isMediaEmpty()) {
if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
@@ -324,22 +329,22 @@ public class MessageObject {
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20));
if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) {
- if (message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty) {
+ if (isMediaEmpty()) {
contentType = type = 0;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaPhoto) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
contentType = type = 1;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaGeo) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaGeo) {
contentType = 1;
type = 4;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaVideo) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
contentType = 1;
type = 3;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaContact) {
contentType = 3;
type = 12;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
contentType = type = 0;
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
contentType = 1;
if (message.media.document.mime_type != null) {
if (message.media.document.mime_type.equals("image/gif") && message.media.document.thumb != null && !(message.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
@@ -355,7 +360,7 @@ public class MessageObject {
} else {
type = 9;
}
- } else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaAudio) {
+ } else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
contentType = type = 2;
}
} else if (message instanceof TLRPC.TL_messageService) {
@@ -448,6 +453,24 @@ public class MessageObject {
photoObject.location = messageOwner.media.document.thumb.location;
}
}
+ } else if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
+ if (messageOwner.media.webpage.photo != null) {
+ if (!update || photoThumbs == null) {
+ photoThumbs = new ArrayList<>(messageOwner.media.webpage.photo.sizes);
+ } else if (photoThumbs != null && !photoThumbs.isEmpty()) {
+ for (TLRPC.PhotoSize photoObject : photoThumbs) {
+ for (TLRPC.PhotoSize size : messageOwner.media.webpage.photo.sizes) {
+ if (size instanceof TLRPC.TL_photoSizeEmpty) {
+ continue;
+ }
+ if (size.type.equals(photoObject.type)) {
+ photoObject.location = size.location;
+ break;
+ }
+ }
+ }
+ }
+ }
}
}
}
@@ -553,11 +576,24 @@ public class MessageObject {
return false;
}
+ public void generateLinkDescription() {
+ if (linkDescription != null) {
+ return;
+ }
+ if (messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageOwner.media.webpage instanceof TLRPC.TL_webPage && messageOwner.media.webpage.description != null) {
+ linkDescription = Spannable.Factory.getInstance().newSpannable(messageOwner.media.webpage.description);
+ if (containsUrls(linkDescription)) {
+ Linkify.addLinks((Spannable) linkDescription, Linkify.WEB_URLS);
+ }
+ }
+ }
+
private void generateLayout() {
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
return;
}
+ generateLinkDescription();
textLayoutBlocks = new ArrayList<>();
if (messageText instanceof Spannable && containsUrls(messageText)) {
@@ -796,7 +832,7 @@ public class MessageObject {
}
public boolean isSending() {
- return messageOwner.send_state == MESSAGE_SEND_STATE_SENDING;
+ return messageOwner.send_state == MESSAGE_SEND_STATE_SENDING && messageOwner.id < 0;
}
public boolean isSendError() {
@@ -804,7 +840,7 @@ public class MessageObject {
}
public boolean isSent() {
- return messageOwner.send_state == MESSAGE_SEND_STATE_SENT;
+ return messageOwner.send_state == MESSAGE_SEND_STATE_SENT || messageOwner.id > 0;
}
public String getSecretTimeString() {
@@ -959,4 +995,12 @@ public class MessageObject {
public boolean isReply() {
return !(replyMessageObject != null && replyMessageObject.messageOwner instanceof TLRPC.TL_messageEmpty) && messageOwner.reply_to_msg_id != 0 && (messageOwner.flags & TLRPC.MESSAGE_FLAG_REPLY) != 0;
}
+
+ public boolean isMediaEmpty() {
+ return isMediaEmpty(messageOwner);
+ }
+
+ public static boolean isMediaEmpty(TLRPC.Message message) {
+ return message == null || message.media == null || message.media instanceof TLRPC.TL_messageMediaEmpty || message.media instanceof TLRPC.TL_messageMediaWebPage;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
index 2586f562..5773daf1 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java
@@ -13,10 +13,10 @@ import android.app.AlertDialog;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Build;
-import android.text.Html;
import android.util.Base64;
import android.util.SparseArray;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
@@ -28,7 +28,6 @@ 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 java.util.ArrayList;
@@ -179,7 +178,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
public void updateConfig(final TLRPC.TL_config config) {
- AndroidUtilities.runOnUIThread(new Runnable() {
+ AndroidUtilities.runOnUIThread(new Runnable() { //TODO use new config params
@Override
public void run() {
maxBroadcastCount = config.broadcast_size_max;
@@ -1307,12 +1306,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (label.length() != 0) {
if (count > 1) {
if (arr.size() > 2) {
- newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, LocaleController.formatPluralString("AndMoreTyping", arr.size() - 2))));
+ newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.formatPluralString("AndMoreTyping", arr.size() - 2)));
} else {
- newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, LocaleController.getString("AreTyping", R.string.AreTyping))));
+ newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.getString("AreTyping", R.string.AreTyping)));
}
} else {
- newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, LocaleController.getString("IsTyping", R.string.IsTyping))));
+ newPrintingStrings.put(key, String.format("%s %s", label, LocaleController.getString("IsTyping", R.string.IsTyping)));
}
}
}
@@ -1472,13 +1471,22 @@ public class MessagesController implements NotificationCenter.NotificationCenter
for (TLRPC.Message message : messagesRes.messages) {
message.dialog_id = dialog_id;
objects.add(new MessageObject(message, usersLocal, true));
- if (isCache && message.media instanceof TLRPC.TL_messageMediaUnsupported) {
+ 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) {
if (messagesToReload == null) {
messagesToReload = new ArrayList<>();
}
messagesToReload.add(message.id);
}
+ } else if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
+ if (message.media.webpage instanceof TLRPC.TL_webPagePending && message.media.webpage.date <= ConnectionsManager.getInstance().getCurrentTime()) {
+ if (messagesToReload == null) {
+ messagesToReload = new ArrayList<>();
+ }
+ messagesToReload.add(message.id);
+ }
+ }
}
}
if (messagesToReload != null) {
@@ -1941,7 +1949,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
}
- public long createChat(String title, ArrayList selectedContacts, final TLRPC.InputFile uploadedAvatar, boolean isBroadcast) {
+ public long createChat(String title, ArrayList selectedContacts, boolean isBroadcast) {
if (isBroadcast) {
TLRPC.TL_chat chat = new TLRPC.TL_chat();
chat.id = UserConfig.lastBroadcastId;
@@ -2015,35 +2023,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
});
return;
}
- final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
- MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
-
+ final TLRPC.Updates updates = (TLRPC.Updates) response;
+ processUpdates(updates, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
- putUsers(res.users, false);
- putChats(res.chats, false);
- final ArrayList messagesObj = new ArrayList<>();
- messagesObj.add(new MessageObject(res.message, users, true));
- TLRPC.Chat chat = res.chats.get(0);
- updateInterfaceWithMessages(-chat.id, messagesObj);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, chat.id);
- if (uploadedAvatar != null) {
- changeChatAvatar(chat.id, uploadedAvatar);
+ putUsers(updates.users, false);
+ putChats(updates.chats, false);
+ TLRPC.Chat chat = null;
+ if (updates.chats != null && !updates.chats.isEmpty()) {
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, updates.chats.get(0).id);
+ } else {
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidFailCreate);
}
}
});
-
- final ArrayList messages = new ArrayList<>();
- messages.add(res.message);
- MessagesStorage.getInstance().putMessages(messages, true, true, false, 0);
-
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
- }
}
});
}
@@ -2066,57 +2060,16 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) {
return;
}
-
- final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
- MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
-
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- putUsers(res.users, false);
- putChats(res.chats, false);
- final ArrayList messagesObj = new ArrayList<>();
- messagesObj.add(new MessageObject(res.message, users, true));
- TLRPC.Chat chat = res.chats.get(0);
- updateInterfaceWithMessages(-chat.id, messagesObj);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_MEMBERS);
-
+ processUpdates((TLRPC.Updates) response, false);
+ }
+ });
+ } else {
if (info != null) {
for (TLRPC.TL_chatParticipant p : info.participants) {
if (p.user_id == user.id) {
return;
}
}
- TLRPC.TL_chatParticipant newPart = new TLRPC.TL_chatParticipant();
- newPart.user_id = user.id;
- newPart.inviter_id = UserConfig.getClientUserId();
- newPart.date = ConnectionsManager.getInstance().getCurrentTime();
- info.participants.add(0, newPart);
- MessagesStorage.getInstance().updateChatInfo(info.chat_id, info, true);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
- }
- }
- });
-
- final ArrayList messages = new ArrayList<>();
- messages.add(res.message);
- MessagesStorage.getInstance().putMessages(messages, true, true, false, 0);
-
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
- }
- }
- });
- } else {
- if (info != null) {
- for (TLRPC.TL_chatParticipant p : info.participants) {
- if (p.user_id == user.id) {
- return;
- }
- }
TLRPC.Chat chat = getChat(chat_id);
chat.participants_count++;
@@ -2124,13 +2077,13 @@ public class MessagesController implements NotificationCenter.NotificationCenter
chatArrayList.add(chat);
MessagesStorage.getInstance().putUsersAndChats(null, chatArrayList, true, true);
- TLRPC.TL_chatParticipant newPart = new TLRPC.TL_chatParticipant();
- newPart.user_id = user.id;
- newPart.inviter_id = UserConfig.getClientUserId();
- newPart.date = ConnectionsManager.getInstance().getCurrentTime();
- info.participants.add(0, newPart);
- MessagesStorage.getInstance().updateChatInfo(info.chat_id, info, true);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
+ TLRPC.TL_chatParticipant newPart = new TLRPC.TL_chatParticipant();
+ newPart.user_id = user.id;
+ newPart.inviter_id = UserConfig.getClientUserId();
+ newPart.date = ConnectionsManager.getInstance().getCurrentTime();
+ info.participants.add(0, newPart);
+ MessagesStorage.getInstance().updateChatInfo(info.chat_id, info, true);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_MEMBERS);
}
}
@@ -2150,57 +2103,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) {
return;
}
- final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
+ final TLRPC.Updates updates = (TLRPC.Updates) response;
+ processUpdates(updates, false);
if (user.id == UserConfig.getClientUserId()) {
- res.chats = null;
- }
- MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
-
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- putUsers(res.users, false);
- putChats(res.chats, false);
- if (user.id != UserConfig.getClientUserId()) {
- final ArrayList messagesObj = new ArrayList<>();
- messagesObj.add(new MessageObject(res.message, users, true));
- TLRPC.Chat chat = res.chats.get(0);
- updateInterfaceWithMessages(-chat.id, messagesObj);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_MEMBERS);
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
}
- boolean changed = false;
- if (info != null) {
- for (int a = 0; a < info.participants.size(); a++) {
- TLRPC.TL_chatParticipant p = info.participants.get(a);
- if (p.user_id == user.id) {
- info.participants.remove(a);
- changed = true;
- break;
- }
- }
- if (changed) {
- MessagesStorage.getInstance().updateChatInfo(chat_id, info, true);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
- } else {
- MessagesStorage.getInstance().updateChatInfo(chat_id, user.id, true, 0, 0);
- }
- } else {
- MessagesStorage.getInstance().updateChatInfo(chat_id, user.id, true, 0, 0);
- }
- }
- });
-
- if (user.id != UserConfig.getClientUserId()) {
- final ArrayList messages = new ArrayList<>();
- messages.add(res.message);
- MessagesStorage.getInstance().putMessages(messages, true, true, false, 0);
- }
-
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
+ });
}
}
});
@@ -2212,17 +2123,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter
chatArrayList.add(chat);
MessagesStorage.getInstance().putUsersAndChats(null, chatArrayList, true, true);
- boolean changed = false;
- if (info != null) {
- for (int a = 0; a < info.participants.size(); a++) {
- TLRPC.TL_chatParticipant p = info.participants.get(a);
- if (p.user_id == user.id) {
- info.participants.remove(a);
- changed = true;
- break;
- }
- }
- if (changed) {
+ boolean changed = false;
+ if (info != null) {
+ for (int a = 0; a < info.participants.size(); a++) {
+ TLRPC.TL_chatParticipant p = info.participants.get(a);
+ if (p.user_id == user.id) {
+ info.participants.remove(a);
+ changed = true;
+ break;
+ }
+ }
+ if (changed) {
MessagesStorage.getInstance().updateChatInfo(info.chat_id, info, true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatInfoDidLoaded, info.chat_id, info);
}
@@ -2243,32 +2154,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) {
return;
}
- final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
- MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
-
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- putUsers(res.users, false);
- putChats(res.chats, false);
- final ArrayList messagesObj = new ArrayList<>();
- messagesObj.add(new MessageObject(res.message, users, true));
- TLRPC.Chat chat = res.chats.get(0);
- updateInterfaceWithMessages(-chat.id, messagesObj);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_NAME);
- }
- });
-
- final ArrayList messages = new ArrayList<>();
- messages.add(res.message);
- MessagesStorage.getInstance().putMessages(messages, true, true, false, 0);
-
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
- }
+ processUpdates((TLRPC.Updates) response, false);
}
});
} else {
@@ -2277,9 +2163,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
ArrayList chatArrayList = new ArrayList<>();
chatArrayList.add(chat);
MessagesStorage.getInstance().putUsersAndChats(null, chatArrayList, true, true);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_NAME);
- }
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_NAME);
+ }
}
public void changeChatAvatar(int chat_id, TLRPC.InputFile uploadedAvatar) {
@@ -2298,34 +2184,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) {
return;
}
- final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
- MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
-
- final ArrayList messages = new ArrayList<>();
- messages.add(res.message);
- ImageLoader.saveMessagesThumbs(messages);
-
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- putUsers(res.users, false);
- putChats(res.chats, false);
- final ArrayList messagesObj = new ArrayList<>();
- messagesObj.add(new MessageObject(res.message, users, true));
- TLRPC.Chat chat = res.chats.get(0);
- updateInterfaceWithMessages(-chat.id, messagesObj);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_CHAT_AVATAR);
- }
- });
-
- MessagesStorage.getInstance().putMessages(messages, true, true, false, 0);
-
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
- }
+ processUpdates((TLRPC.Updates) response, false);
}
});
}
@@ -2617,6 +2476,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.pts = MessagesStorage.lastPtsValue;
req.date = MessagesStorage.lastDateValue;
req.qts = MessagesStorage.lastQtsValue;
+ if (req.date == 0) {
+ req.date = ConnectionsManager.getInstance().getCurrentTime();
+ }
FileLog.e("tmessages", "start getDifference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue);
if (ConnectionsManager.getInstance().getConnectionState() == 0) {
ConnectionsManager.getInstance().setConnectionState(3);
@@ -2681,7 +2543,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
Integer oldId = entry.getKey();
SendMessagesHelper.getInstance().processSentMessage(oldId);
Integer newId = entry.getValue();
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newId, null);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newId, null, false);
}
}
});
@@ -2860,9 +2722,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter
TLRPC.User user = getUser(updates.user_id);
TLRPC.User user2 = null;
+ if (user == null) {
+ user = MessagesStorage.getInstance().getUserSync(updates.user_id);
+ putUser(user, true);
+ }
+
boolean needFwdUser = false;
if (updates.fwd_from_id != 0) {
user2 = getUser(updates.fwd_from_id);
+ if (user2 == null) {
+ user2 = MessagesStorage.getInstance().getUserSync(updates.fwd_from_id);
+ putUser(user2, true);
+ }
needFwdUser = true;
}
@@ -2870,7 +2741,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (updates instanceof TLRPC.TL_updateShortMessage) {
missingData = user == null || needFwdUser && user2 == null;
} else {
- missingData = getChat(updates.chat_id) == null || user == null || needFwdUser && user2 == null;
+ TLRPC.Chat chat = getChat(updates.chat_id);
+ if (chat == null) {
+ chat = MessagesStorage.getInstance().getChatSync(updates.chat_id);
+ putChat(chat, true);
+ }
+ missingData = chat == null || user == null || needFwdUser && user2 == null;
}
if (user != null && user.status != null && user.status.expires <= 0) {
onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime());
@@ -3036,7 +2912,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
if (processUpdate) {
processUpdateArray(updates.updates, updates.users, updates.chats);
+ if (updates.date != 0) {
MessagesStorage.lastDateValue = updates.date;
+ }
if (updates.seq != 0) {
MessagesStorage.lastSeqValue = updates.seq;
}
@@ -3113,6 +2991,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
long currentTime = System.currentTimeMillis();
final HashMap> messages = new HashMap<>();
+ final HashMap webPages = new HashMap<>();
final ArrayList pushMessages = new ArrayList<>();
final ArrayList messagesArr = new ArrayList<>();
final HashMap markAsReadMessagesInbox = new HashMap<>();
@@ -3305,6 +3184,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else if (update instanceof TLRPC.TL_updateActivation) {
//DEPRECATED
} else if (update instanceof TLRPC.TL_updateNewAuthorization) {
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.newSessionReceived);
+ }
+ });
TLRPC.TL_messageService newMessage = new TLRPC.TL_messageService();
newMessage.action = new TLRPC.TL_messageActionLoginUnknownLocation();
newMessage.action.title = update.device;
@@ -3438,6 +3323,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
pushMessages.add(obj);
} else if (update instanceof TLRPC.TL_updatePrivacy) {
updatesOnMainThread.add(update);
+ } else if (update instanceof TLRPC.TL_updateWebPage) {
+ webPages.put(update.webpage.id, update.webpage);
}
}
if (!messages.isEmpty()) {
@@ -3618,6 +3505,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
MessagesStorage.getInstance().updateUsers(dbUsers, false, true, true);
}
+ if (!webPages.isEmpty()) {
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceivedWebpagesInUpdates, webPages);
+ }
+
if (!messages.isEmpty()) {
for (HashMap.Entry> entry : messages.entrySet()) {
Long key = entry.getKey();
@@ -3707,6 +3598,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
});
+ if (!webPages.isEmpty()) {
+ MessagesStorage.getInstance().putWebPages(webPages);
+ }
if (!markAsReadMessagesInbox.isEmpty() || !markAsReadMessagesOutbox.isEmpty() || !markAsReadEncrypted.isEmpty()) {
if (!markAsReadMessagesInbox.isEmpty() || !markAsReadMessagesOutbox.isEmpty()) {
MessagesStorage.getInstance().updateDialogsWithReadedMessages(markAsReadMessagesInbox, true);
diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
index 1f396219..04fe7b66 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesStorage.java
@@ -18,6 +18,7 @@ import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement;
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;
@@ -29,7 +30,6 @@ 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;
@@ -123,6 +123,7 @@ public class MessagesStorage {
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 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();
database.executeFast("CREATE TABLE user_contacts_v6(uid INTEGER PRIMARY KEY, fname TEXT, sname TEXT)").stepThis().dispose();
database.executeFast("CREATE TABLE user_phones_v6(uid INTEGER, phone TEXT, sphone TEXT, deleted INTEGER, PRIMARY KEY (uid, phone))").stepThis().dispose();
@@ -163,7 +164,7 @@ public class MessagesStorage {
database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
//version
- database.executeFast("PRAGMA user_version = 15").stepThis().dispose();
+ database.executeFast("PRAGMA user_version = 16").stepThis().dispose();
} else {
try {
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1");
@@ -194,7 +195,7 @@ public class MessagesStorage {
}
}
int version = database.executeInt("PRAGMA user_version");
- if (version < 15) {
+ if (version < 16) {
updateDbToLastVersion(version);
}
}
@@ -379,6 +380,11 @@ public class MessagesStorage {
database.executeFast("PRAGMA user_version = 15").stepThis().dispose();
version = 15;
}
+ if (version == 15 && version < 16) {
+ database.executeFast("CREATE TABLE IF NOT EXISTS webpage_pending(id INTEGER, mid INTEGER, PRIMARY KEY (id, mid));").stepThis().dispose();
+ database.executeFast("PRAGMA user_version = 16").stepThis().dispose();
+ version = 16;
+ }
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@@ -2660,6 +2666,79 @@ public class MessagesStorage {
return -1;
}
+ public void putWebPages(final HashMap webPages) {
+ if (webPages == null || webPages.isEmpty()) {
+ return;
+ }
+ storageQueue.postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ String ids = TextUtils.join(",", webPages.keySet());
+ SQLiteCursor cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid FROM webpage_pending WHERE id IN (%s)", ids));
+ ArrayList mids = new ArrayList<>();
+ while (cursor.next()) {
+ mids.add(cursor.intValue(0));
+ }
+ cursor.dispose();
+
+ if (mids.isEmpty()) {
+ return;
+ }
+ final ArrayList messages = new ArrayList<>();
+ cursor = database.queryFinalized(String.format(Locale.US, "SELECT mid, data FROM messages WHERE mid IN (%s)", TextUtils.join(",", mids)));
+ while (cursor.next()) {
+ int mid = cursor.intValue(0);
+ ByteBufferDesc data = buffersStorage.getFreeBuffer(cursor.byteArrayLength(1));
+ if (data != null && cursor.byteBufferValue(1, data.buffer) != 0) {
+ TLRPC.Message message = (TLRPC.Message)TLClassStore.Instance().TLdeserialize(data, data.readInt32());
+ if (message.media instanceof TLRPC.TL_messageMediaWebPage) {
+ message.id = mid;
+ message.media.webpage = webPages.get(message.media.webpage.id);
+ messages.add(message);
+ }
+ }
+ buffersStorage.reuseFreeBuffer(data);
+ }
+ cursor.dispose();
+
+ database.executeFast(String.format(Locale.US, "DELETE FROM webpage_pending WHERE id IN (%s)", ids)).stepThis().dispose();
+
+ if (messages.isEmpty()) {
+ return;
+ }
+
+ database.beginTransaction();
+
+ SQLitePreparedStatement state = database.executeFast("UPDATE messages SET data = ? WHERE mid = ?");
+ for (TLRPC.Message message : messages) {
+ ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
+ message.serializeToStream(data);
+
+ state.requery();
+ state.bindByteBuffer(1, data.buffer);
+ state.bindInteger(2, message.id);
+ state.step();
+
+ buffersStorage.reuseFreeBuffer(data);
+ }
+ state.dispose();
+
+ database.commitTransaction();
+
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceivedWebpages, messages);
+ }
+ });
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+ });
+ }
+
private void putMessagesInternal(final ArrayList messages, final boolean withTransaction, final boolean isBroadcast, final int downloadMask) {
try {
if (withTransaction) {
@@ -2677,6 +2756,7 @@ public class MessagesStorage {
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO randoms VALUES(?, ?)");
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?)");
+ SQLitePreparedStatement state5 = database.executeFast("REPLACE INTO webpage_pending VALUES(?, ?)");
for (TLRPC.Message message : messages) {
long dialog_id = message.dialog_id;
@@ -2810,15 +2890,23 @@ public class MessagesStorage {
state2.bindByteBuffer(5, data.buffer);
state2.step();
}
+
+ if (message.media instanceof TLRPC.TL_messageMediaWebPage && message.media.webpage instanceof TLRPC.TL_webPagePending) {
+ state5.requery();
+ state5.bindLong(1, message.media.webpage.id);
+ state5.bindInteger(2, message.id);
+ state5.step();
+ }
+
buffersStorage.reuseFreeBuffer(data);
- if (downloadMask != 0) {
+ if (message.date >= ConnectionsManager.getInstance().getCurrentTime() - 60 * 60 * 24 && downloadMask != 0) {
if (message.media instanceof TLRPC.TL_messageMediaAudio || message.media instanceof TLRPC.TL_messageMediaPhoto || message.media instanceof TLRPC.TL_messageMediaVideo || message.media instanceof TLRPC.TL_messageMediaDocument) {
int type = 0;
long id = 0;
TLObject object = null;
if (message.media instanceof TLRPC.TL_messageMediaAudio) {
- if ((downloadMask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0) {
+ if ((downloadMask & MediaController.AUTODOWNLOAD_MASK_AUDIO) != 0 && message.media.audio.size < 1024 * 1024 * 5) {
id = message.media.audio.id;
type = MediaController.AUTODOWNLOAD_MASK_AUDIO;
object = message.media.audio;
@@ -2864,6 +2952,7 @@ public class MessagesStorage {
state2.dispose();
state3.dispose();
state4.dispose();
+ state5.dispose();
state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)");
for (HashMap.Entry pair : messagesMap.entrySet()) {
@@ -3543,11 +3632,19 @@ public class MessagesStorage {
}
private void fixUnsupportedMedia(TLRPC.Message message) {
- if (message != null && message.media instanceof TLRPC.TL_messageMediaUnsupported && message.media.bytes != null) {
+ if (message == null) {
+ return;
+ }
+ boolean ok = false;
+ if (message.media instanceof TLRPC.TL_messageMediaUnsupported_old) {
if (message.media.bytes.length == 0) {
message.media.bytes = new byte[1];
message.media.bytes[0] = TLRPC.LAYER;
}
+ } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
+ message.media = new TLRPC.TL_messageMediaUnsupported_old();
+ message.media.bytes = new byte[1];
+ message.media.bytes[0] = TLRPC.LAYER;
}
}
@@ -3802,6 +3899,42 @@ public class MessagesStorage {
});
}
+ public TLRPC.User getUserSync(final int user_id) {
+ final Semaphore semaphore = new Semaphore(0);
+ final TLRPC.User[] user = new TLRPC.User[1];
+ MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ user[0] = getUser(user_id);
+ semaphore.release();
+ }
+ });
+ try {
+ semaphore.acquire();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ return user[0];
+ }
+
+ public TLRPC.Chat getChatSync(final int user_id) {
+ final Semaphore semaphore = new Semaphore(0);
+ final TLRPC.Chat[] chat = new TLRPC.Chat[1];
+ MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ chat[0] = getChat(user_id);
+ semaphore.release();
+ }
+ });
+ try {
+ semaphore.acquire();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ return chat[0];
+ }
+
public TLRPC.User getUser(final int user_id) {
TLRPC.User user = null;
try {
diff --git a/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java b/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java
index 17e55ea2..6eab0a11 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/NativeLoader.java
@@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader {
- private final static int LIB_VERSION = 6;
+ private final static int LIB_VERSION = 7;
private final static String LIB_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";
diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java
index b21a9fd2..962de697 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationCenter.java
@@ -49,9 +49,13 @@ public class NotificationCenter {
public static final int recentImagesDidLoaded = totalEvents++;
public static final int replaceMessagesObjects = totalEvents++;
public static final int didSetPasscode = totalEvents++;
+ public static final int didSetTwoStepPassword = totalEvents++;
public static final int screenStateChanged = totalEvents++;
public static final int appSwitchedToForeground = totalEvents++;
public static final int didLoadedReplyMessages = totalEvents++;
+ public static final int newSessionReceived = totalEvents++;
+ public static final int didReceivedWebpages = totalEvents++;
+ public static final int didReceivedWebpagesInUpdates = totalEvents++;
public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++;
@@ -64,7 +68,6 @@ public class NotificationCenter {
public static final int didReceiveSmsCode = totalEvents++;
public static final int emojiDidLoaded = totalEvents++;
public static final int appDidLogout = totalEvents++;
- public static final int needPasswordEnter = totalEvents++;
public static final int FileDidUpload = totalEvents++;
public static final int FileDidFailUpload = totalEvents++;
diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java
index 41e71a89..b31839cb 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java
@@ -17,10 +17,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.content.res.AssetFileDescriptor;
import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager;
import android.media.MediaPlayer;
-import android.media.SoundPool;
import android.net.Uri;
import android.os.Build;
import android.os.SystemClock;
@@ -31,6 +31,7 @@ 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;
@@ -39,7 +40,6 @@ 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;
@@ -70,11 +70,10 @@ public class NotificationsController {
private int lastOnlineFromOtherDevice = 0;
private boolean inChatSoundEnabled = true;
- private SoundPool soundPool;
- private int inChatOutgoingSound;
private long lastSoundPlay;
- private MediaPlayer mediaPlayer;
- private String lastMediaPlayerUri;
+ private MediaPlayer mediaPlayerIn;
+ private MediaPlayer mediaPlayerOut;
+ protected AudioManager audioManager;
private static volatile NotificationsController Instance = null;
public static NotificationsController getInstance() {
@@ -96,9 +95,8 @@ public class NotificationsController {
inChatSoundEnabled = preferences.getBoolean("EnableInChatSound", true);
try {
- soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0);
- inChatOutgoingSound = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1);
- mediaPlayer = new MediaPlayer();
+ audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(Context.AUDIO_SERVICE);
+ //mediaPlayer = new MediaPlayer();
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@@ -175,7 +173,7 @@ public class NotificationsController {
msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
}
} else {
- if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) {
+ 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);
@@ -240,7 +238,7 @@ public class NotificationsController {
msg = messageObject.messageText.toString();
}
} else {
- if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) {
+ 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);
} else {
@@ -416,6 +414,7 @@ public class NotificationsController {
inAppPriority = preferences.getBoolean("EnableInAppPriority", false);
vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);
priority_override = preferences.getInt("priority_" + dialog_id, 3);
+ boolean vibrateOnlyIfSilent = false;
choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
if (chat_id != 0) {
@@ -445,6 +444,10 @@ public class NotificationsController {
priority = priority_override;
}
+ if (needVibrate == 4) {
+ vibrateOnlyIfSilent = true;
+ needVibrate = 0;
+ }
if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) {
needVibrate = vibrate_override;
}
@@ -461,6 +464,16 @@ public class NotificationsController {
priority = 1;
}
}
+ if (vibrateOnlyIfSilent && needVibrate != 2) {
+ try {
+ int mode = audioManager.getRingerMode();
+ if (mode != AudioManager.RINGER_MODE_SILENT && mode != AudioManager.RINGER_MODE_VIBRATE) {
+ needVibrate = 2;
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
}
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
@@ -852,13 +865,53 @@ public class NotificationsController {
if (!inChatSoundEnabled) {
return;
}
- if (lastSoundPlay > System.currentTimeMillis() - 1800) {
- return;
- }
try {
- String choosenSoundPath = null;
- String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
+ if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
+ return;
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+
+ try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
+ int notify_override = preferences.getInt("notify2_" + openned_dialog_id, 0);
+ if (notify_override == 3) {
+ int mute_until = preferences.getInt("notifyuntil_" + openned_dialog_id, 0);
+ if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) {
+ notify_override = 2;
+ }
+ }
+ if (notify_override == 2) {
+ return;
+ }
+ notificationsQueue.postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ if (lastSoundPlay > System.currentTimeMillis() - 500) {
+ return;
+ }
+ try {
+ if (mediaPlayerIn == null) {
+ AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_in);
+ if (assetFileDescriptor != null) {
+ mediaPlayerIn = new MediaPlayer();
+ mediaPlayerIn.setAudioStreamType(AudioManager.STREAM_SYSTEM);
+ mediaPlayerIn.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
+ mediaPlayerIn.setLooping(false);
+ assetFileDescriptor.close();
+ mediaPlayerIn.prepare();
+ }
+ }
+ mediaPlayerIn.start();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+ });
+ /*String choosenSoundPath = null;
+ String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
+
choosenSoundPath = preferences.getString("sound_path_" + openned_dialog_id, null);
boolean isChat = (int)(openned_dialog_id) < 0;
if (isChat) {
@@ -888,7 +941,7 @@ public class NotificationsController {
mediaPlayer.prepare();
}
mediaPlayer.start();
- }
+ }*/
} catch (Exception e) {
FileLog.e("tmessages", e);
}
@@ -899,10 +952,33 @@ public class NotificationsController {
return;
}
try {
- soundPool.play(inChatOutgoingSound, 1, 1, 1, 0, 1);
+ if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
+ return;
+ }
} catch (Exception e) {
FileLog.e("tmessages", e);
}
+ notificationsQueue.postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ if (mediaPlayerOut == null) {
+ AssetFileDescriptor assetFileDescriptor = ApplicationLoader.applicationContext.getResources().openRawResourceFd(R.raw.sound_out);
+ if (assetFileDescriptor != null) {
+ mediaPlayerOut = new MediaPlayer();
+ mediaPlayerOut.setAudioStreamType(AudioManager.STREAM_SYSTEM);
+ mediaPlayerOut.setDataSource(assetFileDescriptor.getFileDescriptor(), assetFileDescriptor.getStartOffset(), assetFileDescriptor.getLength());
+ mediaPlayerOut.setLooping(false);
+ assetFileDescriptor.close();
+ mediaPlayerOut.prepare();
+ }
+ }
+ mediaPlayerOut.start();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+ });
}
public void processNewMessages(ArrayList messageObjects, boolean isLast) {
@@ -1145,26 +1221,26 @@ public class NotificationsController {
try {
ContentValues cv = new ContentValues();
//cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity");
- cv.put("tag", "org.telegram.plus/org.telegram.ui.LaunchActivity");
+ cv.put("tag", context.getPackageName() + "/org.telegram.ui.LaunchActivity");
cv.put("count", count);
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
} catch (Throwable e) {
//ignore
}
- try {
- String launcherClassName = getLauncherClassName(context);
- if (launcherClassName == null) {
- return;
+ try {
+ String launcherClassName = getLauncherClassName(context);
+ if (launcherClassName == null) {
+ return;
+ }
+ 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_class_name", launcherClassName);
+ context.sendBroadcast(intent);
+ } catch (Throwable e) {
+ FileLog.e("tmessages", e);
+ }
}
- 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_class_name", launcherClassName);
- context.sendBroadcast(intent);
- } catch (Throwable e) {
- FileLog.e("tmessages", e);
- }
- }
});
}
diff --git a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java
index e9d672fc..6a34ea26 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/SecretChatHelper.java
@@ -119,7 +119,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -224,7 +224,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -252,7 +252,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -283,7 +283,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -312,7 +312,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -343,7 +343,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -375,7 +375,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -406,7 +406,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -436,7 +436,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -464,7 +464,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -500,7 +500,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService();
} else {
reqSend = new TLRPC.TL_decryptedMessageService_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
@@ -659,7 +659,7 @@ public class SecretChatHelper {
int myLayer = Math.max(17, AndroidUtilities.getMyLayerVersion(chat.layer));
layer.layer = Math.min(myLayer, AndroidUtilities.getPeerLayerVersion(chat.layer));
layer.message = req;
- layer.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ layer.random_bytes = new byte[15];
Utilities.random.nextBytes(layer.random_bytes);
toEncryptObject = layer;
@@ -795,7 +795,7 @@ public class SecretChatHelper {
@Override
public void run() {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, newMsgObj.id, newMsgObj.id, newMsgObj, false);
SendMessagesHelper.getInstance().processSentMessage(newMsgObj.id);
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
SendMessagesHelper.getInstance().stopVideoService(attachPath);
@@ -1104,10 +1104,7 @@ public class SecretChatHelper {
}
byte[] salt = new byte[256];
- for (int a = 0; a < 256; a++) {
- salt[a] = (byte) (Utilities.random.nextDouble() * 256);
- }
-
+ Utilities.random.nextBytes(salt);
BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes);
BigInteger g_b = BigInteger.valueOf(MessagesStorage.secretG);
g_b = g_b.modPow(new BigInteger(1, salt), p);
@@ -1409,9 +1406,7 @@ public class SecretChatHelper {
return;
}
final byte[] salt = new byte[256];
- for (int a = 0; a < 256; a++) {
- salt[a] = (byte) (Utilities.random.nextDouble() * 256);
- }
+ Utilities.random.nextBytes(salt);
BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG);
i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));
diff --git a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java
index 7b043fe9..5b961c34 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java
@@ -19,6 +19,7 @@ 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;
@@ -28,7 +29,6 @@ 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;
@@ -447,7 +447,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (messageObject == null) {
return;
}
- if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (messageObject.messageOwner.media != null && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) && !(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage)) {
if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) {
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did, messageObject.replyMessageObject);
} else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) {
@@ -471,14 +471,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
sendMessage(messageObject, did);
}
} else if (messageObject.messageOwner.message != null) {
- sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject);
+ TLRPC.WebPage webPage = null;
+ if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
+ webPage = messageObject.messageOwner.media.webpage;
+ }
+ sendMessage(messageObject.messageOwner.message, did, messageObject.replyMessageObject, webPage, true);
} else {
sendMessage(messageObject, did);
}
}
public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg) {
- sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null, reply_to_msg);
+ sendMessage(null, null, null, null, null, null, user, null, null, null, peer, false, null, reply_to_msg, null, true);
}
public void sendMessage(ArrayList messages, long peer) {
@@ -567,67 +571,74 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
req.id = ids;
final ArrayList newMsgObjArr = arr;
+ final HashMap messagesByRandomIdsFinal = messagesByRandomIds;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
- final TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
- if (newMsgObjArr.size() != res.messages.size()) {
- MessagesController.getInstance().getDifference();
- return;
- }
- if (res instanceof TLRPC.TL_messages_statedMessages) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
- }
- for (int a = 0; a < res.messages.size(); a++) {
- TLRPC.Message message = res.messages.get(a);
- final TLRPC.Message newMsgObj = newMsgObjArr.get(a);
- if (newMsgObj == null) {
- continue;
+ HashMap newMessagesByIds = new HashMap<>();
+ TLRPC.Updates updates = (TLRPC.Updates) response;
+ for (int a = 0; a < updates.updates.size(); a++) {
+ TLRPC.Update update = updates.updates.get(a);
+ if (update instanceof TLRPC.TL_updateMessageID) {
+ newMessagesByIds.put(update.id, update.random_id);
+ updates.updates.remove(a);
+ a--;
}
- final int oldId = newMsgObj.id;
- final ArrayList sentMessages = new ArrayList<>();
- sentMessages.add(message);
- newMsgObj.id = message.id;
- processSentMessage(newMsgObj, message, null);
- MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
- @Override
- public void run() {
- MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false);
- MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0);
- AndroidUtilities.runOnUIThread(new Runnable() {
+ }
+ for (TLRPC.Update update : updates.updates) {
+ if (update instanceof TLRPC.TL_updateNewMessage) {
+ MessagesController.getInstance().processNewDifferenceParams(-1, update.pts, -1, update.pts_count);
+ TLRPC.Message message = ((TLRPC.TL_updateNewMessage) update).message;
+ Long random_id = newMessagesByIds.get(message.id);
+ if (random_id != null) {
+ final TLRPC.Message newMsgObj = messagesByRandomIdsFinal.get(random_id);
+ if (newMsgObj == null) {
+ continue;
+ }
+ newMsgObjArr.remove(newMsgObj);
+ final int oldId = newMsgObj.id;
+ final ArrayList sentMessages = new ArrayList<>();
+ sentMessages.add(message);
+ newMsgObj.id = message.id;
+ processSentMessage(newMsgObj, message, null);
+ MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override
public void run() {
- newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj);
- processSentMessage(oldId);
- removeFromSendingMessages(oldId);
+ MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, newMsgObj.id, 0, false);
+ MessagesStorage.getInstance().putMessages(sentMessages, true, false, false, 0);
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, false);
+ processSentMessage(oldId);
+ removeFromSendingMessages(oldId);
+ }
+ });
+ if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
+ stopVideoService(newMsgObj.attachPath);
+ }
}
});
- if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
- stopVideoService(newMsgObj.attachPath);
- }
}
- });
+ }
}
- } else {
- for (final TLRPC.Message newMsgObj : newMsgObjArr) {
- MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
- processSentMessage(newMsgObj.id);
- if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
- stopVideoService(newMsgObj.attachPath);
- }
- removeFromSendingMessages(newMsgObj.id);
+ }
+ for (final TLRPC.Message newMsgObj : newMsgObjArr) {
+ MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsgObj.id);
+ processSentMessage(newMsgObj.id);
+ if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
+ stopVideoService(newMsgObj.attachPath);
}
- });
- }
+ removeFromSendingMessages(newMsgObj.id);
+ }
+ });
}
}
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress, ConnectionsManager.DEFAULT_DATACENTER_ID);
@@ -644,38 +655,38 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}
public void sendMessage(MessageObject message) {
- sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath, null);
+ sendMessage(null, null, null, null, null, message, null, null, null, null, message.getDialogId(), true, message.messageOwner.attachPath, null, null, true);
}
public void sendMessage(MessageObject message, long peer) {
- sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath, null);
+ sendMessage(null, null, null, null, null, message, null, null, null, null, peer, false, message.messageOwner.attachPath, null, null, true);
}
public void sendMessage(TLRPC.TL_document document, String originalPath, String path, long peer, MessageObject reply_to_msg) {
- sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path, reply_to_msg);
+ sendMessage(null, null, null, null, null, null, null, document, null, originalPath, peer, false, path, reply_to_msg, null, true);
}
- public void sendMessage(String message, long peer, MessageObject reply_to_msg) {
- sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null, reply_to_msg);
+ public void sendMessage(String message, long peer, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks) {
+ sendMessage(message, null, null, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, webPage, searchLinks);
}
public void sendMessage(double lat, double lon, long peer, MessageObject reply_to_msg) {
- sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null, reply_to_msg);
+ sendMessage(null, lat, lon, null, null, null, null, null, null, null, peer, false, null, reply_to_msg, null, true);
}
public void sendMessage(TLRPC.TL_photo photo, String originalPath, String path, long peer, MessageObject reply_to_msg) {
- sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path, reply_to_msg);
+ sendMessage(null, null, null, photo, null, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true);
}
public void sendMessage(TLRPC.TL_video video, String originalPath, String path, long peer, MessageObject reply_to_msg) {
- sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path, reply_to_msg);
+ sendMessage(null, null, null, null, video, null, null, null, null, originalPath, peer, false, path, reply_to_msg, null, true);
}
public void sendMessage(TLRPC.TL_audio audio, String path, long peer, MessageObject reply_to_msg) {
- sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path, reply_to_msg);
+ sendMessage(null, null, null, null, null, null, null, null, audio, null, peer, false, path, reply_to_msg, null, true);
}
- private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path, MessageObject reply_to_msg) {
+ private void sendMessage(String message, Double lat, Double lon, TLRPC.TL_photo photo, TLRPC.TL_video video, MessageObject msgObj, TLRPC.User user, TLRPC.TL_document document, TLRPC.TL_audio audio, String originalPath, long peer, boolean retry, String path, MessageObject reply_to_msg, TLRPC.WebPage webPage, boolean searchLinks) {
if (peer == 0) {
return;
}
@@ -741,7 +752,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else {
newMsg = new TLRPC.TL_message();
}
- newMsg.media = new TLRPC.TL_messageMediaEmpty();
+ if (encryptedChat != null || webPage == null) {
+ newMsg.media = new TLRPC.TL_messageMediaEmpty();
+ } else {
+ newMsg.media = new TLRPC.TL_messageMediaWebPage();
+ newMsg.media.webpage = webPage;
+ }
type = 0;
newMsg.message = message;
} else if (lat != null && lon != null) {
@@ -860,6 +876,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (lower_id != 0) {
if (high_id == 1) {
if (currentChatInfo == null) {
+ MessagesStorage.getInstance().markMessageAsSendError(newMsg.id);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsg.id);
processSentMessage(newMsg.id);
return;
}
@@ -932,9 +950,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (encryptedChat == null) {
if (sendToPeers != null) {
TLRPC.TL_messages_sendBroadcast reqSend = new TLRPC.TL_messages_sendBroadcast();
+ ArrayList random_ids = new ArrayList<>();
+ for (int a = 0; a < sendToPeers.size(); a++) {
+ random_ids.add(Utilities.random.nextLong());
+ }
reqSend.message = message;
reqSend.contacts = sendToPeers;
reqSend.media = new TLRPC.TL_inputMediaEmpty();
+ reqSend.random_id = random_ids;
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
} else {
TLRPC.TL_messages_sendMessage reqSend = new TLRPC.TL_messages_sendMessage();
@@ -942,8 +965,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.peer = sendToPeer;
reqSend.random_id = newMsg.random_id;
if (reply_to_msg != null) {
+ reqSend.flags |= 1;
reqSend.reply_to_msg_id = reply_to_msg.getId();
}
+ if (!searchLinks) {
+ reqSend.flags |= 2;
+ }
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
}
} else {
@@ -953,7 +980,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.ttl = newMsg.ttl;
} else {
reqSend = new TLRPC.TL_decryptedMessage_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
reqSend.random_id = newMsg.random_id;
@@ -1065,8 +1092,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (sendToPeers != null) {
TLRPC.TL_messages_sendBroadcast request = new TLRPC.TL_messages_sendBroadcast();
+ ArrayList random_ids = new ArrayList<>();
+ for (int a = 0; a < sendToPeers.size(); a++) {
+ random_ids.add(Utilities.random.nextLong());
+ }
request.contacts = sendToPeers;
request.media = inputMedia;
+ request.random_id = random_ids;
request.message = "";
if (delayedMessage != null) {
delayedMessage.sendRequest = request;
@@ -1078,6 +1110,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
request.random_id = newMsg.random_id;
request.media = inputMedia;
if (reply_to_msg != null) {
+ request.flags |= 1;
request.reply_to_msg_id = reply_to_msg.getId();
}
if (delayedMessage != null) {
@@ -1121,7 +1154,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.ttl = newMsg.ttl;
} else {
reqSend = new TLRPC.TL_decryptedMessage_old();
- reqSend.random_bytes = new byte[Math.max(1, (int) Math.ceil(Utilities.random.nextDouble() * 16))];
+ reqSend.random_bytes = new byte[15];
Utilities.random.nextBytes(reqSend.random_bytes);
}
reqSend.random_id = newMsg.random_id;
@@ -1424,82 +1457,82 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
+ boolean isSentError = false;
if (error == null) {
final int oldId = newMsgObj.id;
final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast;
final ArrayList sentMessages = new ArrayList<>();
final String attachPath = newMsgObj.attachPath;
-
+ final boolean mediaUpdated = response instanceof TLRPC.messages_SentMessage && !(((TLRPC.messages_SentMessage) response).media instanceof TLRPC.TL_messageMediaEmpty);
if (response instanceof TLRPC.messages_SentMessage) {
TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response;
- newMsgObj.id = res.id;
+ newMsgObj.local_id = newMsgObj.id = res.id;
newMsgObj.date = res.date;
+ newMsgObj.media = res.media;
if (res instanceof TLRPC.TL_messages_sentMessage) {
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count);
} else if (res instanceof TLRPC.TL_messages_sentMessageLink) {
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date, res.pts_count);
}
- } else if (response instanceof TLRPC.messages_StatedMessage) {
- TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response;
- sentMessages.add(res.message);
- newMsgObj.id = res.message.id;
- processSentMessage(newMsgObj, res.message, originalPath);
- if (res instanceof TLRPC.TL_messages_statedMessage) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessageLink) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.message.date, res.pts_count);
- }
- } else if (response instanceof TLRPC.messages_StatedMessages) {
- TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response;
- if (!res.messages.isEmpty()) {
- sentMessages.addAll(res.messages);
- TLRPC.Message message = res.messages.get(0);
- if (!isBroadcast) {
- newMsgObj.id = message.id;
+ sentMessages.add(newMsgObj);
+ } else if (response instanceof TLRPC.Updates) {
+ TLRPC.TL_updateNewMessage newMessage = null;
+ for (TLRPC.Update update : ((TLRPC.Updates) response).updates) {
+ if (update instanceof TLRPC.TL_updateNewMessage) {
+ newMessage = (TLRPC.TL_updateNewMessage) update;
+ break;
}
- processSentMessage(newMsgObj, message, originalPath);
}
- if (res instanceof TLRPC.TL_messages_statedMessages) {
- MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, -1, res.pts_count);
- } else if (res instanceof TLRPC.TL_messages_statedMessagesLinks) {
- MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, -1, res.pts_count);
+ if (newMessage != null) {
+ sentMessages.add(newMessage.message);
+ newMsgObj.id = newMessage.message.id;
+ processSentMessage(newMsgObj, newMessage.message, originalPath);
+ MessagesController.getInstance().processNewDifferenceParams(-1, newMessage.pts, -1, newMessage.pts_count);
+ } else {
+ isSentError = true;
}
}
- MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
- @Override
- public void run() {
- MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false);
- MessagesStorage.getInstance().putMessages(sentMessages, true, false, isBroadcast, 0);
- if (isBroadcast) {
- ArrayList currentMessage = new ArrayList<>();
- currentMessage.add(newMsgObj);
- newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
- MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0);
- }
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
+
+ if (!isSentError) {
+ MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ MessagesStorage.getInstance().updateMessageStateAndId(newMsgObj.random_id, oldId, (isBroadcast ? oldId : newMsgObj.id), 0, false);
+ MessagesStorage.getInstance().putMessages(sentMessages, true, false, isBroadcast, 0);
+ if (isBroadcast) {
+ ArrayList currentMessage = new ArrayList<>();
+ currentMessage.add(newMsgObj);
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
- if (isBroadcast) {
- for (TLRPC.Message message : sentMessages) {
- ArrayList arr = new ArrayList<>();
- MessageObject messageObject = new MessageObject(message, null, false);
- arr.add(messageObject);
- MessagesController.getInstance().updateInterfaceWithMessages(messageObject.getDialogId(), arr, isBroadcast);
- }
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
- }
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj);
- processSentMessage(oldId);
- removeFromSendingMessages(oldId);
+ MessagesStorage.getInstance().putMessages(currentMessage, true, false, false, 0);
+ }
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
+ if (isBroadcast) {
+ for (TLRPC.Message message : sentMessages) {
+ ArrayList arr = new ArrayList<>();
+ MessageObject messageObject = new MessageObject(message, null, false);
+ arr.add(messageObject);
+ MessagesController.getInstance().updateInterfaceWithMessages(messageObject.getDialogId(), arr, isBroadcast);
+ }
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
+ }
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, mediaUpdated);
+ processSentMessage(oldId);
+ removeFromSendingMessages(oldId);
+ }
+ });
+ if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
+ stopVideoService(attachPath);
}
- });
- if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
- stopVideoService(attachPath);
}
- }
- });
+ });
+ }
} else {
+ isSentError = true;
+ }
+ if (isSentError) {
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
@@ -1810,8 +1843,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
FileLog.e("tmessages", e);
}
if (bmOptions.outWidth != 0 && bmOptions.outHeight != 0 && bmOptions.outWidth <= 800 && bmOptions.outHeight <= 800) {
- TLRPC.TL_documentAttributeSticker attributeSticker = new TLRPC.TL_documentAttributeSticker();
- attributeSticker.alt = "";
+ TLRPC.TL_documentAttributeSticker attributeSticker = null;
+ if (isEncrypted) {
+ attributeSticker = new TLRPC.TL_documentAttributeSticker_old();
+ } else {
+ attributeSticker = new TLRPC.TL_documentAttributeSticker();
+ attributeSticker.alt = "";
+ }
document.attributes.add(attributeSticker);
TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize();
attributeImageSize.w = bmOptions.outWidth;
diff --git a/TMessagesProj/src/main/java/org/telegram/android/WearReplyReceiver.java b/TMessagesProj/src/main/java/org/telegram/android/WearReplyReceiver.java
index e94dc43c..dfde5442 100644
--- a/TMessagesProj/src/main/java/org/telegram/android/WearReplyReceiver.java
+++ b/TMessagesProj/src/main/java/org/telegram/android/WearReplyReceiver.java
@@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
if (dialog_id == 0 || max_id == 0) {
return;
}
- SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null);
+ SendMessagesHelper.getInstance().sendMessage(text.toString(), dialog_id, null, null, true);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java
index 481be841..0525ac4d 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java
@@ -33,13 +33,13 @@ import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
-import org.telegram.android.MediaController;
-import org.telegram.android.NotificationsService;
-import org.telegram.android.SendMessagesHelper;
import org.telegram.android.LocaleController;
+import org.telegram.android.MediaController;
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,8 @@ public class ApplicationLoader extends Application {
public static volatile boolean isScreenOn = false;
public static volatile boolean mainInterfacePaused = true;
+ public static boolean SHOW_ANDROID_EMOJI;
+
public static boolean isCustomTheme() {
return isCustomTheme;
}
@@ -193,6 +195,9 @@ public class ApplicationLoader extends Application {
applicationHandler = new Handler(applicationContext.getMainLooper());
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
+ SHOW_ANDROID_EMOJI = preferences.getBoolean("showAndroidEmoji", false);
+
startPushService();
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
index 0149b834..3d8fa2a1 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ConnectionsManager.java
@@ -1037,11 +1037,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for (int i = 0; i < runningRequests.size(); i++) {
RPCRequest request = runningRequests.get(i);
- if (UserConfig.waitingForPasswordEnter && (request.flags & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
- FileLog.e("tmessages", "skip request " + request.rawRequest + ", need password enter");
- continue;
- }
-
int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID) {
@@ -1244,11 +1239,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
continue;
}
- if (UserConfig.waitingForPasswordEnter && (request.flags & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
- FileLog.e("tmessages", "skip request " + request.rawRequest + ", need password enter");
- continue;
- }
-
int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID && (request.flags & RPCRequest.RPCRequestClassEnableUnauthorized) == 0) {
@@ -2183,10 +2173,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
});
}
- if (request.rawRequest instanceof TLRPC.TL_auth_checkPassword) {
- UserConfig.setWaitingForPasswordEnter(false);
- UserConfig.saveConfig(false);
- }
request.completionBlock.run(resultContainer.result, null);
}
}
@@ -2194,7 +2180,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (implicitError != null && implicitError.code == 401) {
isError = true;
if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) {
- UserConfig.setWaitingForPasswordEnter(true);
+ /*UserConfig.setWaitingForPasswordEnter(true); TODO
UserConfig.saveConfig(false);
if (UserConfig.isClientActivated()) {
discardResponse = true;
@@ -2204,7 +2190,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter);
}
});
- }
+ }*/
} else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) {
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) {
UserConfig.clearConfig();
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
index af3ae922..dad1b9bf 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLoader.java
@@ -33,6 +33,7 @@ public class FileLoader {
public static final int MEDIA_DIR_VIDEO = 2;
public static final int MEDIA_DIR_DOCUMENT = 3;
public static final int MEDIA_DIR_CACHE = 4;
+ public static final int MEDIA_DIR_THEME = 5;
private HashMap mediaDirs = null;
private volatile DispatchQueue fileLoaderQueue = new DispatchQueue("fileUploadQueue");
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java b/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java
index 4e7454e0..180c9446 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/RPCRequest.java
@@ -63,7 +63,7 @@ public class RPCRequest {
boolean initRequest = false;
- ArrayList respondsToMessageIds = new ArrayList();
+ ArrayList respondsToMessageIds = new ArrayList<>();
public void addRespondMessageId(long messageId) {
respondsToMessageIds.add(messageId);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java
index 016c62fe..c3e862ad 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLClassStore.java
@@ -124,8 +124,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class);
classStore.put(TLRPC.TL_boolFalse.constructor, TLRPC.TL_boolFalse.class);
classStore.put(TLRPC.TL_auth_exportedAuthorization.constructor, TLRPC.TL_auth_exportedAuthorization.class);
- classStore.put(TLRPC.TL_messages_statedMessagesLinks.constructor, TLRPC.TL_messages_statedMessagesLinks.class);
- classStore.put(TLRPC.TL_messages_statedMessages.constructor, TLRPC.TL_messages_statedMessages.class);
classStore.put(TLRPC.TL_inputNotifyChats.constructor, TLRPC.TL_inputNotifyChats.class);
classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class);
classStore.put(TLRPC.TL_inputNotifyUsers.constructor, TLRPC.TL_inputNotifyUsers.class);
@@ -322,8 +320,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_contactFound.constructor, TLRPC.TL_contactFound.class);
classStore.put(TLRPC.TL_inputFileBig.constructor, TLRPC.TL_inputFileBig.class);
classStore.put(TLRPC.TL_inputFile.constructor, TLRPC.TL_inputFile.class);
- classStore.put(TLRPC.TL_messages_statedMessageLink.constructor, TLRPC.TL_messages_statedMessageLink.class);
- classStore.put(TLRPC.TL_messages_statedMessage.constructor, TLRPC.TL_messages_statedMessage.class);
classStore.put(TLRPC.TL_userFull.constructor, TLRPC.TL_userFull.class);
classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class);
classStore.put(TLRPC.TL_resPQ.constructor, TLRPC.TL_resPQ.class);
@@ -377,6 +373,17 @@ public class TLClassStore {
classStore.put(TLRPC.TL_contactLinkHasPhone.constructor, TLRPC.TL_contactLinkHasPhone.class);
classStore.put(TLRPC.TL_contactLinkContact.constructor, TLRPC.TL_contactLinkContact.class);
classStore.put(TLRPC.TL_messages_affectedMessages.constructor, TLRPC.TL_messages_affectedMessages.class);
+ classStore.put(TLRPC.TL_updateWebPage.constructor, TLRPC.TL_updateWebPage.class);
+ classStore.put(TLRPC.TL_webPagePending.constructor, TLRPC.TL_webPagePending.class);
+ classStore.put(TLRPC.TL_webPageEmpty.constructor, TLRPC.TL_webPageEmpty.class);
+ classStore.put(TLRPC.TL_webPage.constructor, TLRPC.TL_webPage.class);
+ classStore.put(TLRPC.TL_messageMediaWebPage.constructor, TLRPC.TL_messageMediaWebPage.class);
+ classStore.put(TLRPC.TL_authorization.constructor, TLRPC.TL_authorization.class);
+ classStore.put(TLRPC.TL_account_authorizations.constructor, TLRPC.TL_account_authorizations.class);
+ classStore.put(TLRPC.TL_account_passwordSettings.constructor, TLRPC.TL_account_passwordSettings.class);
+ classStore.put(TLRPC.TL_account_passwordInputSettings.constructor, TLRPC.TL_account_passwordInputSettings.class);
+ classStore.put(TLRPC.TL_auth_passwordRecovery.constructor, TLRPC.TL_auth_passwordRecovery.class);
+ classStore.put(TLRPC.TL_messages_getWebPagePreview.constructor, TLRPC.TL_messages_getWebPagePreview.class);
classStore.put(TLRPC.TL_messageMediaUnsupported_old.constructor, TLRPC.TL_messageMediaUnsupported_old.class);
classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class);
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java
index 0a44750b..ce412857 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/TLRPC.java
@@ -9,10 +9,7 @@
package org.telegram.messenger;
import java.util.ArrayList;
-import java.util.Date;
-import java.util.LinkedList;
import java.util.Locale;
-import java.util.Queue;
@SuppressWarnings("unchecked")
public class TLRPC {
@@ -22,7 +19,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_FWD = 4;
public static final int MESSAGE_FLAG_REPLY = 8;
public static final int MESSAGE_FLAG_MENTION = 16;
- public static final int LAYER = 25;
+ public static final int LAYER = 27;
public static class ChatPhoto extends TLObject {
public FileLocation photo_small;
@@ -275,6 +272,21 @@ public class TLRPC {
}
}
+ public static class TL_account_passwordSettings extends TLObject {
+ public static int constructor = 0xb7b72ab3;
+
+ public String email;
+
+ public void readParams(AbsSerializedData stream) {
+ email = stream.readString();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(email);
+ }
+ }
+
public static class DocumentAttribute extends TLObject {
public int duration;
public String file_name;
@@ -656,6 +668,57 @@ public class TLRPC {
}
}
+ public static class TL_authorization extends TLObject {
+ public static int constructor = 0x7bf2e6f6;
+
+ public long hash;
+ public int flags;
+ public String device_model;
+ public String platform;
+ public String system_version;
+ public int api_id;
+ public String app_name;
+ public String app_version;
+ public int date_created;
+ public int date_active;
+ public String ip;
+ public String country;
+ public String region;
+
+ public void readParams(AbsSerializedData stream) {
+ hash = stream.readInt64();
+ flags = stream.readInt32();
+ device_model = stream.readString();
+ platform = stream.readString();
+ system_version = stream.readString();
+ api_id = stream.readInt32();
+ app_name = stream.readString();
+ app_version = stream.readString();
+ date_created = stream.readInt32();
+ date_active = stream.readInt32();
+ ip = stream.readString();
+ country = stream.readString();
+ region = stream.readString();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt64(hash);
+ stream.writeInt32(flags);
+ stream.writeString(device_model);
+ stream.writeString(platform);
+ stream.writeString(system_version);
+ stream.writeInt32(api_id);
+ stream.writeString(app_name);
+ stream.writeString(app_version);
+ stream.writeInt32(date_created);
+ stream.writeInt32(date_active);
+ stream.writeString(ip);
+ stream.writeString(country);
+ stream.writeString(region);
+ }
+ }
+
public static class DestroySessionRes extends TLObject {
public long session_id;
}
@@ -1117,6 +1180,7 @@ public class TLRPC {
public static class MessageMedia extends TLObject {
public Video video;
public Photo photo;
+ public WebPage webpage;
public Document document;
public GeoPoint geo;
public Audio audio;
@@ -1155,6 +1219,20 @@ public class TLRPC {
}
}
+ public static class TL_messageMediaWebPage extends MessageMedia {
+ public static int constructor = 0xa32dd600;
+
+
+ public void readParams(AbsSerializedData stream) {
+ webpage = (WebPage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ webpage.serializeToStream(stream);
+ }
+ }
+
public static class TL_messageMediaDocument extends MessageMedia {
public static int constructor = 0x2fda2204;
@@ -2038,124 +2116,144 @@ public class TLRPC {
}
}
- public static class messages_StatedMessages extends TLObject {
- public ArrayList messages = new ArrayList<>();
- public ArrayList chats = new ArrayList<>();
- public ArrayList users = new ArrayList<>();
- public int pts;
- public int pts_count;
- public ArrayList links = new ArrayList<>();
- public int seq;
+ public static class WebPage extends TLObject {
+ public long id;
+ public int date;
+ public int flags;
+ public String url;
+ public String display_url;
+ public String type;
+ public String site_name;
+ public String title;
+ public String description;
+ public Photo photo;
+ public String embed_url;
+ public String embed_type;
+ public int embed_width;
+ public int embed_height;
+ public int duration;
+ public String author;
}
- public static class TL_messages_statedMessagesLinks extends messages_StatedMessages {
- public static int constructor = 0x51be5d19;
+ public static class TL_webPagePending extends WebPage {
+ public static int constructor = 0xc586da1c;
public void readParams(AbsSerializedData stream) {
- stream.readInt32();
- int count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- messages.add((Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- pts = stream.readInt32();
- pts_count = stream.readInt32();
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- links.add((TL_contacts_link)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- seq = stream.readInt32();
+ id = stream.readInt64();
+ date = stream.readInt32();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
- stream.writeInt32(0x1cb5c415);
- int count = messages.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- messages.get(a).serializeToStream(stream);
- }
- stream.writeInt32(0x1cb5c415);
- count = chats.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- chats.get(a).serializeToStream(stream);
- }
- stream.writeInt32(0x1cb5c415);
- count = users.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- users.get(a).serializeToStream(stream);
- }
- stream.writeInt32(pts);
- stream.writeInt32(pts_count);
- stream.writeInt32(0x1cb5c415);
- count = links.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- links.get(a).serializeToStream(stream);
- }
- stream.writeInt32(seq);
+ stream.writeInt64(id);
+ stream.writeInt32(date);
}
}
- public static class TL_messages_statedMessages extends messages_StatedMessages {
- public static int constructor = 0x7d84b48;
+ public static class TL_webPageEmpty extends WebPage {
+ public static int constructor = 0xeb1477e8;
public void readParams(AbsSerializedData stream) {
- stream.readInt32();
- int count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- messages.add((Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- pts = stream.readInt32();
- pts_count = stream.readInt32();
+ id = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
- stream.writeInt32(0x1cb5c415);
- int count = messages.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- messages.get(a).serializeToStream(stream);
+ stream.writeInt64(id);
+ }
}
- stream.writeInt32(0x1cb5c415);
- count = chats.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- chats.get(a).serializeToStream(stream);
+
+ public static class TL_auth_passwordRecovery extends TLObject {
+ public static int constructor = 0x137948a5;
+
+ public String email_pattern;
+
+ public void readParams(AbsSerializedData stream) {
+ email_pattern = stream.readString();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(email_pattern);
+ }
+ }
+
+ public static class TL_webPage extends WebPage {
+ public static int constructor = 0xa31ea0b5;
+
+ public void readParams(AbsSerializedData stream) {
+ flags = stream.readInt32();
+ id = stream.readInt64();
+ url = stream.readString();
+ display_url = stream.readString();
+ if ((flags & 1) != 0) {
+ type = stream.readString();
}
- stream.writeInt32(0x1cb5c415);
- count = users.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- users.get(a).serializeToStream(stream);
+ if ((flags & 2) != 0) {
+ site_name = stream.readString();
+ }
+ if ((flags & 4) != 0) {
+ title = stream.readString();
+ }
+ if ((flags & 8) != 0) {
+ description = stream.readString();
+ }
+ if ((flags & 16) != 0) {
+ photo = (Photo) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
+ }
+ if ((flags & 32) != 0) {
+ embed_url = stream.readString();
+ embed_type = stream.readString();
+ }
+ if ((flags & 64) != 0) {
+ embed_width = stream.readInt32();
+ embed_height = stream.readInt32();
+ }
+ if ((flags & 128) != 0) {
+ duration = stream.readInt32();
+ }
+ if ((flags & 256) != 0) {
+ author = stream.readString();
+ }
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ stream.writeInt64(id);
+ stream.writeString(url);
+ stream.writeString(display_url);
+ if ((flags & 1) != 0) {
+ stream.writeString(type);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeString(site_name);
+ }
+ if ((flags & 4) != 0) {
+ stream.writeString(title);
+ }
+ if ((flags & 8) != 0) {
+ stream.writeString(description);
+ }
+ if ((flags & 16) != 0) {
+ photo.serializeToStream(stream);
+ }
+ if ((flags & 32) != 0) {
+ stream.writeString(embed_url);
+ stream.writeString(embed_type);
+ }
+ if ((flags & 64) != 0) {
+ stream.writeInt32(embed_width);
+ stream.writeInt32(embed_height);
+ }
+ if ((flags & 128) != 0) {
+ stream.writeInt32(duration);
+ }
+ if ((flags & 256) != 0) {
+ stream.writeString(author);
}
- stream.writeInt32(pts);
- stream.writeInt32(pts_count);
}
}
@@ -2320,7 +2418,7 @@ public class TLRPC {
stream.readInt32();
int count = stream.readInt32();
for (int a = 0; a < count; a++) {
- users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
+ users.add((User) TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
}
}
@@ -3539,6 +3637,7 @@ public class TLRPC {
public static class messages_SentMessage extends TLObject {
public int id;
public int date;
+ public MessageMedia media;
public int pts;
public int pts_count;
public ArrayList links = new ArrayList<>();
@@ -3546,12 +3645,13 @@ public class TLRPC {
}
public static class TL_messages_sentMessage extends messages_SentMessage {
- public static int constructor = 0x900eac40;
+ public static int constructor = 0x4c3d47f3;
public void readParams(AbsSerializedData stream) {
id = stream.readInt32();
date = stream.readInt32();
+ media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
pts = stream.readInt32();
pts_count = stream.readInt32();
}
@@ -3560,18 +3660,20 @@ public class TLRPC {
stream.writeInt32(constructor);
stream.writeInt32(id);
stream.writeInt32(date);
+ media.serializeToStream(stream);
stream.writeInt32(pts);
stream.writeInt32(pts_count);
}
}
public static class TL_messages_sentMessageLink extends messages_SentMessage {
- public static int constructor = 0xe923400d;
+ public static int constructor = 0x35a1a663;
public void readParams(AbsSerializedData stream) {
id = stream.readInt32();
date = stream.readInt32();
+ media = (MessageMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
pts = stream.readInt32();
pts_count = stream.readInt32();
stream.readInt32();
@@ -3586,6 +3688,7 @@ public class TLRPC {
stream.writeInt32(constructor);
stream.writeInt32(id);
stream.writeInt32(date);
+ media.serializeToStream(stream);
stream.writeInt32(pts);
stream.writeInt32(pts_count);
stream.writeInt32(0x1cb5c415);
@@ -3823,6 +3926,7 @@ public class TLRPC {
public int pts_count;
public int max_id;
public int version;
+ public WebPage webpage;
public String type;
public MessageMedia media;
public boolean popup;
@@ -3974,6 +4078,20 @@ public class TLRPC {
}
}
+ public static class TL_updateWebPage extends Update {
+ public static int constructor = 0x2cc36971;
+
+
+ public void readParams(AbsSerializedData stream) {
+ webpage = (WebPage)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ webpage.serializeToStream(stream);
+ }
+ }
+
public static class TL_updateServiceNotification extends Update {
public static int constructor = 0x382dd3e4;
@@ -4768,16 +4886,20 @@ public class TLRPC {
public byte[] current_salt;
public byte[] new_salt;
public String hint;
+ public boolean has_recovery;
+ public String email_unconfirmed_pattern;
}
public static class TL_account_password extends account_Password {
- public static int constructor = 0x739e5f72;
+ public static int constructor = 0x7c18141c;
public void readParams(AbsSerializedData stream) {
current_salt = stream.readByteArray();
new_salt = stream.readByteArray();
hint = stream.readString();
+ has_recovery = stream.readBool();
+ email_unconfirmed_pattern = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
@@ -4785,20 +4907,24 @@ public class TLRPC {
stream.writeByteArray(current_salt);
stream.writeByteArray(new_salt);
stream.writeString(hint);
+ stream.writeBool(has_recovery);
+ stream.writeString(email_unconfirmed_pattern);
}
}
public static class TL_account_noPassword extends account_Password {
- public static int constructor = 0x5770e7a9;
+ public static int constructor = 0x96dabc18;
public void readParams(AbsSerializedData stream) {
new_salt = stream.readByteArray();
+ email_unconfirmed_pattern = stream.readString();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeByteArray(new_salt);
+ stream.writeString(email_unconfirmed_pattern);
}
}
@@ -5058,7 +5184,7 @@ public class TLRPC {
}
public static class TL_config extends TLObject {
- public static int constructor = 0x3e6f732a;
+ public static int constructor = 0x68bac247;
public int date;
public int expires;
@@ -5067,6 +5193,7 @@ public class TLRPC {
public ArrayList dc_options = new ArrayList<>();
public int chat_size_max;
public int broadcast_size_max;
+ public int forwarded_count_max;
public int online_update_period_ms;
public int offline_blur_timeout_ms;
public int offline_idle_timeout_ms;
@@ -5088,6 +5215,7 @@ public class TLRPC {
}
chat_size_max = stream.readInt32();
broadcast_size_max = stream.readInt32();
+ forwarded_count_max = stream.readInt32();
online_update_period_ms = stream.readInt32();
offline_blur_timeout_ms = stream.readInt32();
offline_idle_timeout_ms = stream.readInt32();
@@ -5116,6 +5244,7 @@ public class TLRPC {
}
stream.writeInt32(chat_size_max);
stream.writeInt32(broadcast_size_max);
+ stream.writeInt32(forwarded_count_max);
stream.writeInt32(online_update_period_ms);
stream.writeInt32(offline_blur_timeout_ms);
stream.writeInt32(offline_idle_timeout_ms);
@@ -5318,7 +5447,7 @@ public class TLRPC {
public String phone_number;
- public Class responseClass () {
+ public Class responseClass() {
return TL_account_sentChangePhoneCode.class;
}
@@ -5357,66 +5486,6 @@ public class TLRPC {
}
}
- public static class TL_account_getPassword extends TLObject {
- public static int constructor = 0x548a30f5;
-
-
- public Class responseClass () {
- return account_Password.class;
- }
-
- public void serializeToStream(AbsSerializedData stream) {
- stream.writeInt32(constructor);
- }
- }
-
- public static class TL_account_setPassword extends TLObject {
- public static int constructor = 0xdd2a4d8f;
-
- public byte[] current_password_hash;
- public byte[] new_salt;
- public byte[] new_password_hash;
- public String hint;
-
- public Class responseClass () {
- return Bool.class;
- }
-
- public void readParams(AbsSerializedData stream) {
- current_password_hash = stream.readByteArray();
- new_salt = stream.readByteArray();
- new_password_hash = stream.readByteArray();
- hint = stream.readString();
- }
-
- public void serializeToStream(AbsSerializedData stream) {
- stream.writeInt32(constructor);
- stream.writeByteArray(current_password_hash);
- stream.writeByteArray(new_salt);
- stream.writeByteArray(new_password_hash);
- stream.writeString(hint);
- }
- }
-
- public static class TL_auth_checkPassword extends TLObject {
- public static int constructor = 0xa63011e;
-
- public byte[] password_hash;
-
- public Class responseClass () {
- return TL_auth_authorization.class;
- }
-
- public void readParams(AbsSerializedData stream) {
- password_hash = stream.readByteArray();
- }
-
- public void serializeToStream(AbsSerializedData stream) {
- stream.writeInt32(constructor);
- stream.writeByteArray(password_hash);
- }
- }
-
public static class TL_account_updateDeviceLocked extends TLObject {
public static int constructor = 0x38df3532;
@@ -5436,6 +5505,38 @@ public class TLRPC {
}
}
+ public static class TL_account_getAuthorizations extends TLObject {
+ public static int constructor = 0xe320c158;
+
+
+ public Class responseClass () {
+ return TL_account_authorizations.class;
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ }
+ }
+
+ public static class TL_account_resetAuthorization extends TLObject {
+ public static int constructor = 0xdf77f3bc;
+
+ public long hash;
+
+ public Class responseClass () {
+ return Bool.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ hash = stream.readInt64();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt64(hash);
+ }
+ }
+
public static class TL_messages_getAllStickers extends TLObject {
public static int constructor = 0xaa3bc868;
@@ -5455,6 +5556,25 @@ public class TLRPC {
}
}
+ public static class TL_messages_getWebPagePreview extends TLObject {
+ public static int constructor = 0x25223e24;
+
+ public String message;
+
+ public Class responseClass () {
+ return MessageMedia.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ message = stream.readString();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(message);
+ }
+ }
+
public static class TL_account_checkUsername extends TLObject {
public static int constructor = 0x2714d86c;
@@ -6489,109 +6609,6 @@ public class TLRPC {
}
}
- public static class messages_StatedMessage extends TLObject {
- public Message message;
- public ArrayList chats = new ArrayList<>();
- public ArrayList users = new ArrayList<>();
- public int pts;
- public int pts_count;
- public ArrayList links = new ArrayList<>();
- public int seq;
- }
-
- public static class TL_messages_statedMessageLink extends messages_StatedMessage {
- public static int constructor = 0x948a288;
-
-
- public void readParams(AbsSerializedData stream) {
- message = (Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
- stream.readInt32();
- int count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- pts = stream.readInt32();
- pts_count = stream.readInt32();
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- links.add((TL_contacts_link)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- seq = stream.readInt32();
- }
-
- public void serializeToStream(AbsSerializedData stream) {
- stream.writeInt32(constructor);
- message.serializeToStream(stream);
- stream.writeInt32(0x1cb5c415);
- int count = chats.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- chats.get(a).serializeToStream(stream);
- }
- stream.writeInt32(0x1cb5c415);
- count = users.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- users.get(a).serializeToStream(stream);
- }
- stream.writeInt32(pts);
- stream.writeInt32(pts_count);
- stream.writeInt32(0x1cb5c415);
- count = links.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- links.get(a).serializeToStream(stream);
- }
- stream.writeInt32(seq);
- }
- }
-
- public static class TL_messages_statedMessage extends messages_StatedMessage {
- public static int constructor = 0x96240c6a;
-
-
- public void readParams(AbsSerializedData stream) {
- message = (Message)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
- stream.readInt32();
- int count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- chats.add((Chat)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- stream.readInt32();
- count = stream.readInt32();
- for (int a = 0; a < count; a++) {
- users.add((User)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
- }
- pts = stream.readInt32();
- pts_count = stream.readInt32();
- }
-
- public void serializeToStream(AbsSerializedData stream) {
- stream.writeInt32(constructor);
- message.serializeToStream(stream);
- stream.writeInt32(0x1cb5c415);
- int count = chats.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- chats.get(a).serializeToStream(stream);
- }
- stream.writeInt32(0x1cb5c415);
- count = users.size();
- stream.writeInt32(count);
- for (int a = 0; a < count; a++) {
- users.get(a).serializeToStream(stream);
- }
- stream.writeInt32(pts);
- stream.writeInt32(pts_count);
- }
- }
-
public static class TL_userFull extends TLObject {
public static int constructor = 0x771095da;
@@ -7289,6 +7306,41 @@ public class TLRPC {
}
}
+ public static class TL_account_passwordInputSettings extends TLObject {
+ public static int constructor = 0xbcfc532c;
+
+ public int flags;
+ public byte[] new_salt;
+ public byte[] new_password_hash;
+ public String hint;
+ public String email;
+
+ public void readParams(AbsSerializedData stream) {
+ flags = stream.readInt32();
+ if ((flags & 1) != 0) {
+ new_salt = stream.readByteArray();
+ new_password_hash = stream.readByteArray();
+ hint = stream.readString();
+ }
+ if ((flags & 2) != 0) {
+ email = stream.readString();
+ }
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(flags);
+ if ((flags & 1) != 0) {
+ stream.writeByteArray(new_salt);
+ stream.writeByteArray(new_password_hash);
+ stream.writeString(hint);
+ }
+ if ((flags & 2) != 0) {
+ stream.writeString(email);
+ }
+ }
+ }
+
public static class TL_dcOption extends TLObject {
public static int constructor = 0x2ec2a43c;
@@ -7495,6 +7547,30 @@ public class TLRPC {
}
}
+ public static class TL_account_authorizations extends TLObject {
+ public static int constructor = 0x1250abde;
+
+ public ArrayList authorizations = new ArrayList<>();
+
+ public void readParams(AbsSerializedData stream) {
+ stream.readInt32();
+ int count = stream.readInt32();
+ for (int a = 0; a < count; a++) {
+ authorizations.add((TL_authorization)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
+ }
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeInt32(0x1cb5c415);
+ int count = authorizations.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ authorizations.get(a).serializeToStream(stream);
+ }
+ }
+ }
+
public static class TL_req_pq extends TLObject {
public static int constructor = 0x60469778;
@@ -8381,8 +8457,9 @@ public class TLRPC {
}
public static class TL_messages_sendMessage extends TLObject {
- public static int constructor = 0x1ca852a1;
+ public static int constructor = 0x9add8f26;
+ public int flags;
public InputPeer peer;
public int reply_to_msg_id;
public String message;
@@ -8393,58 +8470,71 @@ public class TLRPC {
}
public void readParams(AbsSerializedData stream) {
+ flags = stream.readInt32();
peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
- reply_to_msg_id = stream.readInt32();
+ if ((flags & 1) != 0) {
+ reply_to_msg_id = stream.readInt32();
+ }
message = stream.readString();
random_id = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
+ stream.writeInt32(flags);
peer.serializeToStream(stream);
- stream.writeInt32(reply_to_msg_id);
+ if ((flags & 1) != 0) {
+ stream.writeInt32(reply_to_msg_id);
+ }
stream.writeString(message);
stream.writeInt64(random_id);
}
}
public static class TL_messages_sendMedia extends TLObject {
- public static int constructor = 0xfcee7fc0;
+ public static int constructor = 0x2d7923b1;
+ public int flags;
public InputPeer peer;
public int reply_to_msg_id;
public InputMedia media;
public long random_id;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
+ flags = stream.readInt32();
peer = (InputPeer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
- reply_to_msg_id = stream.readInt32();
+ if ((flags & 1) != 0) {
+ reply_to_msg_id = stream.readInt32();
+ }
media = (InputMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
random_id = stream.readInt64();
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
+ stream.writeInt32(flags);
peer.serializeToStream(stream);
- stream.writeInt32(reply_to_msg_id);
+ if ((flags & 1) != 0) {
+ stream.writeInt32(reply_to_msg_id);
+ }
media.serializeToStream(stream);
stream.writeInt64(random_id);
}
}
public static class TL_messages_forwardMessages extends TLObject {
- public static int constructor = 0xded42045;
+ public static int constructor = 0x55e1728d;
public InputPeer peer;
public ArrayList id = new ArrayList<>();
public ArrayList random_id = new ArrayList<>();
public Class responseClass () {
- return messages_StatedMessages.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8527,13 +8617,13 @@ public class TLRPC {
}
public static class TL_messages_editChatTitle extends TLObject {
- public static int constructor = 0xb4bc68b5;
+ public static int constructor = 0xdc452855;
public int chat_id;
public String title;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8549,13 +8639,13 @@ public class TLRPC {
}
public static class TL_messages_editChatPhoto extends TLObject {
- public static int constructor = 0xd881821d;
+ public static int constructor = 0xca4c79d8;
public int chat_id;
public InputChatPhoto photo;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8571,14 +8661,14 @@ public class TLRPC {
}
public static class TL_messages_addChatUser extends TLObject {
- public static int constructor = 0x2ee9ee9e;
+ public static int constructor = 0xf9a0aa09;
public int chat_id;
public InputUser user_id;
public int fwd_limit;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8596,13 +8686,13 @@ public class TLRPC {
}
public static class TL_messages_deleteChatUser extends TLObject {
- public static int constructor = 0xc3c5cd23;
+ public static int constructor = 0xe0611f16;
public int chat_id;
public InputUser user_id;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8618,13 +8708,13 @@ public class TLRPC {
}
public static class TL_messages_createChat extends TLObject {
- public static int constructor = 0x419d9aee;
+ public static int constructor = 0x9cb126e;
public ArrayList users = new ArrayList<>();
public String title;
public Class responseClass () {
- return messages_StatedMessage.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8641,8 +8731,8 @@ public class TLRPC {
stream.writeInt32(0x1cb5c415);
int count = users.size();
stream.writeInt32(count);
- for (InputUser user : users) {
- user.serializeToStream(stream);
+ for (int a = 0; a < count; a++) {
+ users.get(a).serializeToStream(stream);
}
stream.writeString(title);
}
@@ -8917,14 +9007,14 @@ public class TLRPC {
}
public static class TL_messages_forwardMessage extends TLObject {
- public static int constructor = 0x3f3f4f2;
+ public static int constructor = 0x33963bf9;
public InputPeer peer;
public int id;
public long random_id;
- public Class responseClass() {
- return messages_StatedMessage.class;
+ public Class responseClass () {
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8942,14 +9032,15 @@ public class TLRPC {
}
public static class TL_messages_sendBroadcast extends TLObject {
- public static int constructor = 0x41bb0972;
+ public static int constructor = 0xbf73f4da;
public ArrayList contacts = new ArrayList<>();
+ public ArrayList random_id = new ArrayList<>();
public String message;
public InputMedia media;
public Class responseClass () {
- return messages_StatedMessages.class;
+ return Updates.class;
}
public void readParams(AbsSerializedData stream) {
@@ -8958,6 +9049,11 @@ public class TLRPC {
for (int a = 0; a < count; a++) {
contacts.add((InputUser)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()));
}
+ stream.readInt32();
+ count = stream.readInt32();
+ for (int a = 0; a < count; a++) {
+ random_id.add(stream.readInt64());
+ }
message = stream.readString();
media = (InputMedia)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
}
@@ -8967,8 +9063,14 @@ public class TLRPC {
stream.writeInt32(0x1cb5c415);
int count = contacts.size();
stream.writeInt32(count);
- for (InputUser contact : contacts) {
- contact.serializeToStream(stream);
+ for (int a = 0; a < count; a++) {
+ contacts.get(a).serializeToStream(stream);
+ }
+ stream.writeInt32(0x1cb5c415);
+ count = random_id.size();
+ stream.writeInt32(count);
+ for (int a = 0; a < count; a++) {
+ stream.writeInt64(random_id.get(a));
}
stream.writeString(message);
media.serializeToStream(stream);
@@ -9438,6 +9540,111 @@ public class TLRPC {
}
}
+ public static class TL_account_getPassword extends TLObject {
+ public static int constructor = 0x548a30f5;
+
+
+ public Class responseClass () {
+ return account_Password.class;
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ }
+ }
+
+ public static class TL_account_getPasswordSettings extends TLObject {
+ public static int constructor = 0xbc8d11bb;
+
+ public byte[] current_password_hash;
+
+ public Class responseClass () {
+ return TL_account_passwordSettings.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ current_password_hash = stream.readByteArray();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeByteArray(current_password_hash);
+ }
+ }
+
+ public static class TL_account_updatePasswordSettings extends TLObject {
+ public static int constructor = 0xfa7c4b86;
+
+ public byte[] current_password_hash;
+ public TL_account_passwordInputSettings new_settings;
+
+ public Class responseClass () {
+ return Bool.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ current_password_hash = stream.readByteArray();
+ new_settings = (TL_account_passwordInputSettings)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeByteArray(current_password_hash);
+ new_settings.serializeToStream(stream);
+ }
+ }
+
+ public static class TL_auth_checkPassword extends TLObject {
+ public static int constructor = 0xa63011e;
+
+ public byte[] password_hash;
+
+ public Class responseClass () {
+ return TL_auth_authorization.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ password_hash = stream.readByteArray();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeByteArray(password_hash);
+ }
+ }
+
+ public static class TL_auth_requestPasswordRecovery extends TLObject {
+ public static int constructor = 0xd897bc66;
+
+
+ public Class responseClass () {
+ return TL_auth_passwordRecovery.class;
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ }
+ }
+
+ public static class TL_auth_recoverPassword extends TLObject {
+ public static int constructor = 0x4ea56e92;
+
+ public String code;
+
+ public Class responseClass () {
+ return TL_auth_authorization.class;
+ }
+
+ public void readParams(AbsSerializedData stream) {
+ code = stream.readString();
+ }
+
+ public void serializeToStream(AbsSerializedData stream) {
+ stream.writeInt32(constructor);
+ stream.writeString(code);
+ }
+ }
+
//manually created
public static class TL_documentAttributeSticker_old extends TL_documentAttributeSticker {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java
index 6974ca94..42e44a7c 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/UserConfig.java
@@ -30,7 +30,6 @@ public class UserConfig {
private final static Object sync = new Object();
public static boolean saveIncomingPhotos = false;
public static int contactsVersion = 1;
- public static boolean waitingForPasswordEnter = false;
public static String passcodeHash = "";
public static boolean appLocked = false;
public static int passcodeType = 0;
@@ -67,7 +66,6 @@ public class UserConfig {
editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
- editor.putBoolean("waitingForPasswordEnter", waitingForPasswordEnter);
editor.putString("passcodeHash1", passcodeHash);
editor.putBoolean("appLocked", appLocked);
editor.putInt("passcodeType", passcodeType);
@@ -101,18 +99,6 @@ public class UserConfig {
}
}
- public static boolean isWaitingForPasswordEnter() {
- synchronized (sync) {
- return waitingForPasswordEnter;
- }
- }
-
- public static void setWaitingForPasswordEnter(boolean value) {
- synchronized (sync) {
- waitingForPasswordEnter = value;
- }
- }
-
public static int getClientUserId() {
synchronized (sync) {
return currentUser != null ? currentUser.id : 0;
@@ -208,7 +194,6 @@ public class UserConfig {
lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false);
- waitingForPasswordEnter = preferences.getBoolean("waitingForPasswordEnter", false);
passcodeHash = preferences.getString("passcodeHash1", "");
appLocked = preferences.getBoolean("appLocked", false);
passcodeType = preferences.getInt("passcodeType", 0);
@@ -231,7 +216,6 @@ public class UserConfig {
currentUser = null;
registeredForInternalPush = false;
registeredForPush = false;
- waitingForPasswordEnter = false;
contactsHash = "";
importHash = "";
lastSendMessageId = -210000;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
index 8026579c..0177cbc8 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/Utilities.java
@@ -9,6 +9,8 @@
package org.telegram.messenger;
import android.app.Activity;
+import android.app.AlarmManager;
+import android.app.PendingIntent;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
@@ -24,12 +26,17 @@ import android.provider.MediaStore;
import android.text.Html;
import android.text.SpannableStringBuilder;
import android.util.Base64;
+import android.util.Log;
+import android.util.Xml;
+import android.widget.Toast;
import net.hockeyapp.android.CrashManager;
import net.hockeyapp.android.CrashManagerListener;
import net.hockeyapp.android.UpdateManager;
import org.telegram.android.AndroidUtilities;
+import org.telegram.ui.LaunchActivity;
+import org.xmlpull.v1.XmlPullParser;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -50,6 +57,7 @@ import java.security.spec.RSAPublicKeySpec;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
@@ -111,6 +119,7 @@ public class Utilities {
public native static long doPQNative(long _what);
public native static void loadBitmap(String path, Bitmap bitmap, int scale, int width, int height, int stride);
+ public native static int pinBitmap(Bitmap bitmap);
public native static void blurBitmap(Object bitmap, int radius);
public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer);
public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options);
@@ -148,6 +157,9 @@ public class Utilities {
}
public static String bytesToHex(byte[] bytes) {
+ if (bytes == null) {
+ return "";
+ }
char[] hexChars = new char[bytes.length * 2];
int v;
for (int j = 0; j < bytes.length; j++) {
@@ -159,6 +171,9 @@ public class Utilities {
}
public static byte[] hexToBytes(String hex) {
+ if (hex == null) {
+ return null;
+ }
int len = hex.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
@@ -670,7 +685,7 @@ public class Utilities {
}
wholeString = wholeString.trim();
String lower = " " + wholeString.toLowerCase();
- String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));/*Search Name*/
int index = -1;
int lastIndex = 0;
while ((index = lower.indexOf(" " + q, lastIndex)) != -1) {
@@ -768,4 +783,256 @@ public class Utilities {
UpdateManager.register(context, BuildVars.HOCKEY_APP_HASH);
}
}
+
+ //MIO
+ public static void restartApp(){
+ Intent mRestartApp = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
+ 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);
+ System.exit(0);
+ }
+
+ public static void savePreferencesToSD(Context context, String prefName, String tName, boolean toast){
+ String folder = "/Telegram/Themes";
+ File dataF = new File (findPrefFolder(context),prefName);
+ if(checkSDStatus() > 1){
+ File f = new File (Environment.getExternalStorageDirectory(), folder);
+ f.mkdirs();
+ File sdF = new File(f, tName);
+ String s = getError(copyFile(dataF,sdF,true));
+ if (s.equalsIgnoreCase("4")) {
+ if(toast && sdF.getName()!="")Toast.makeText(context,context.getString(R.string.SavedTo,sdF.getName(),folder),Toast.LENGTH_SHORT ).show();
+ }else if (s.contains("0")) {
+ s = context.getString(R.string.SaveErrorMsg0);
+ Toast.makeText(context,"ERROR: "+ s ,Toast.LENGTH_LONG ).show();
+ }else{
+ Toast.makeText(context,"ERROR: "+s,Toast.LENGTH_LONG ).show();
+ Toast.makeText(context,dataF.getAbsolutePath(),Toast.LENGTH_LONG ).show();
+ }
+ }else{
+ Toast.makeText(context,"ERROR: " + context.getString(R.string.NoMediaMessage) , Toast.LENGTH_LONG ).show();
+ }
+ }
+
+ public static void copyWallpaperToSD(Context context, String tName, boolean toast){
+ String folder = "/Telegram/Themes";
+ String nFile = "wallpaper.jpg";
+ if(checkSDStatus()>0){
+ File f1 = context.getFilesDir();
+ f1 = new File (f1.getAbsolutePath(), nFile);
+ File f2 = new File (Environment.getExternalStorageDirectory(), folder);
+ f2.mkdirs();
+ f2 = new File(f2, tName+"_"+nFile);
+ if(f1.length()>1){
+ String s = getError(copyFile(f1,f2,true));
+ if(s.contains("4")){
+ if(toast && f2.getName()!="" && folder !="")Toast.makeText(context,context.getString(R.string.SavedTo,f2.getName(),folder),Toast.LENGTH_SHORT ).show();
+ if(f2.getName()=="" || folder =="") Toast.makeText(context,"ERROR: "+s,Toast.LENGTH_SHORT ).show();
+
+ }else{
+ Toast.makeText(context,"ERROR: "+s+"\n"+f1.getAbsolutePath(),Toast.LENGTH_LONG ).show();
+ }
+ }
+ }
+ }
+
+ static String findPrefFolder(Context context){
+ File f = context.getFilesDir();
+ String appDir = f.getAbsolutePath();
+ File SPDir = new File (appDir.substring(0,appDir.lastIndexOf('/')+1)+ "shared_prefs/");
+ if(!SPDir.exists()) {// && SPDir.isDirectory()) {
+ String pck = context.getPackageName();
+ SPDir=new File ("/dbdata/databases/"+pck+"/shared_prefs/");
+ }
+ //Log.i("TAG", SPDir.getAbsolutePath());
+ return SPDir.getAbsolutePath();
+ }
+
+ static int checkSDStatus(){
+ int b=0;
+ String s = Environment.getExternalStorageState();
+ if (s.equals(Environment.MEDIA_MOUNTED))b=2;
+ else if (s.equals(Environment.MEDIA_MOUNTED_READ_ONLY))b=1;
+ return b;
+ }
+
+ static String getError(int i){
+ String s="-1";
+ if(i==0)s="0: SOURCE FILE DOESN'T EXIST";
+ if(i==1)s="1: DESTINATION FILE DOESN'T EXIST";
+ if(i==2)s="2: NULL SOURCE & DESTINATION FILES";
+ if(i==3)s="3: NULL SOURCE FILE";
+ if(i==4)s="4";
+ return s;
+ }
+
+ //0: source file doesn't exist
+ //1: dest file doesn't exist
+ //2: source & dest = NULL
+ //3: source = NULL
+ //4: dest = NULL
+ static int copyFile(File sourceFile, File destFile, boolean save) {
+ int i=-1;
+ try{
+ if (!sourceFile.exists()) {
+ return i+1;
+ }
+ if (!destFile.exists()) {
+ if(save)i=i+2;
+ destFile.createNewFile();
+ }
+ FileChannel source;
+ FileChannel destination;
+ FileInputStream fileInputStream = new FileInputStream(sourceFile);
+ source = fileInputStream.getChannel();
+ FileOutputStream fileOutputStream = new FileOutputStream(destFile);
+ destination = fileOutputStream.getChannel();
+ if (destination != null && source != null) {
+ destination.transferFrom(source, 0, source.size());
+ i=2;
+ }
+ if (source != null) {
+ source.close();
+ i=3;
+ }
+ if (destination != null) {
+ destination.close();
+ i=4;
+ }
+ fileInputStream.close();
+ fileOutputStream.close();
+ }catch (Exception e)
+ {
+ System.err.println("Error saving preferences: " + e.getMessage());
+ Log.e(e.getMessage(), e.toString());
+ }
+ return i;
+ }
+
+ public static int loadWallpaperFromSDPath(Context context, String wPath){
+ String nFile = "wallpaper.jpg";
+ File f1 = context.getFilesDir();
+ f1= new File (f1.getAbsolutePath(), nFile);
+ File wFile = new File (wPath);
+ String s = "-1";
+ if (wFile.exists()){
+ s = getError(copyFile(wFile,f1,false));
+ if (!s.contains("4")) {
+ Toast.makeText(context,"ERROR: "+s+"\n"+ context.getString(R.string.restoreErrorMsg,wFile.getAbsolutePath()) ,Toast.LENGTH_LONG ).show();
+ }else{
+ //Toast.makeText(context,wFile.getAbsolutePath(),Toast.LENGTH_LONG ).show();
+ }
+ }
+ return Integer.parseInt(s);
+ }
+
+ public static int loadPrefFromSD(Context context, String prefPath){
+ File dataF = new File (findPrefFolder(context), "theme.xml");
+ File prefFile = new File (prefPath);
+ String s = getError(copyFile(prefFile, dataF, false));
+ if (!s.contains("4")) {
+ Toast.makeText(context, "ERROR: "+s+"\n"+ context.getString(R.string.restoreErrorMsg, prefFile.getAbsolutePath()), Toast.LENGTH_LONG).show();
+ }
+ return Integer.parseInt(s);
+ }
+
+ public static String applyThemeFile(File file) {
+ try {
+ HashMap stringMap = getXmlFileStrings(file);
+ String xmlFile = file.getAbsolutePath();
+ String themeName = stringMap.get("themeName");
+
+ if (themeName != null && themeName.length() > 0) {
+
+ if (themeName.contains("&") || themeName.contains("|")) {
+ return "";
+ }
+
+ if(loadPrefFromSD(ApplicationLoader.applicationContext, xmlFile) != 4){
+ return "";
+ }
+
+ String wName = xmlFile.substring(0, xmlFile.lastIndexOf(".")) + "_wallpaper.jpg";
+ File wFile = new File(wName);
+ if(wFile.exists()){
+ //Change Stock Background to set Custom Wallpaper
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
+ int selectedBackground = preferences.getInt("selectedBackground", 1000001);
+ if (selectedBackground == 1000001) {
+ //File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg");
+ //if (!toFile.exists()) {
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putInt("selectedBackground", 113);
+ editor.putInt("selectedColor", 0);
+ editor.commit();
+ //}
+ }
+ Utilities.loadWallpaperFromSDPath(ApplicationLoader.applicationContext, wName);
+ }
+ return themeName;
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ return "";
+ }
+
+ private static HashMap getXmlFileStrings(File file) {
+ FileInputStream stream = null;
+ try {
+ HashMap stringMap = new HashMap<>();
+ XmlPullParser parser = Xml.newPullParser();
+ stream = new FileInputStream(file);
+ parser.setInput(stream, "UTF-8");
+ int eventType = parser.getEventType();
+ String name = null;
+ String value = null;
+ String attrName = null;
+ while (eventType != XmlPullParser.END_DOCUMENT) {
+ if(eventType == XmlPullParser.START_TAG) {
+ name = parser.getName();
+ int c = parser.getAttributeCount();
+ if (c > 0) {
+ attrName = parser.getAttributeValue(0);
+ }
+ } else if(eventType == XmlPullParser.TEXT) {
+ if (attrName != null) {
+ value = parser.getText();
+ if (value != null) {
+ value = value.trim();
+ value = value.replace("\\n", "\n");
+ value = value.replace("\\", "");
+ }
+ }
+ } else if (eventType == XmlPullParser.END_TAG) {
+ value = null;
+ attrName = null;
+ name = null;
+ }
+ if (name != null && name.equals("string") && value != null && attrName != null && value.length() != 0 && attrName.length() != 0) {
+ stringMap.put(attrName, value);
+ name = null;
+ value = null;
+ attrName = null;
+ }
+ eventType = parser.next();
+ }
+ return stringMap;
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ } finally {
+ try {
+ if (stream != null) {
+ stream.close();
+ stream = null;
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+ return null;
+ }
+ //
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/AccountPasswordActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/AccountPasswordActivity.java
deleted file mode 100644
index a7c4f6b2..00000000
--- a/TMessagesProj/src/main/java/org/telegram/ui/AccountPasswordActivity.java
+++ /dev/null
@@ -1,629 +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.ui;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.SharedPreferences;
-import android.view.Gravity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.FrameLayout;
-import android.widget.ListView;
-import android.widget.ProgressBar;
-
-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;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.ConnectionsManager;
-import org.telegram.messenger.FileLog;
-import org.telegram.messenger.R;
-import org.telegram.messenger.RPCRequest;
-import org.telegram.messenger.TLObject;
-import org.telegram.messenger.TLRPC;
-import org.telegram.messenger.UserConfig;
-import org.telegram.messenger.Utilities;
-import org.telegram.ui.ActionBar.ActionBar;
-import org.telegram.ui.ActionBar.ActionBarMenu;
-import org.telegram.ui.ActionBar.BaseFragment;
-import org.telegram.ui.Adapters.BaseFragmentAdapter;
-import org.telegram.ui.Cells.HeaderCell;
-import org.telegram.ui.Cells.TextFieldCell;
-import org.telegram.ui.Cells.TextInfoPrivacyCell;
-import org.telegram.ui.Cells.TextSettingsCell;
-
-import java.util.ArrayList;
-
-public class AccountPasswordActivity extends BaseFragment {
-
- private ListAdapter listAdapter;
- private TextFieldCell oldPasswordCell;
- private TextFieldCell newPasswordCell;
- private TextFieldCell verifyPasswordCell;
- private TextFieldCell hintPasswordCell;
- private View doneButton;
- private ProgressDialog progressDialog;
-
- private int type;
- private boolean hasPassword;
- private boolean loading;
- private byte[] new_salt;
- private String hint;
- private byte[] current_salt;
-
- private int changePasswordSectionRow;
- private int oldPasswordRow;
- private int newPasswordRow;
- private int verifyPasswordRow;
- private int hintRow;
- private int passwordDetailRow;
- private int deleteAccountSection;
- private int deleteAccountRow;
- private int deleteAccountDetailRow;
- private int rowCount;
-
- private final static int done_button = 1;
-
- public AccountPasswordActivity(int type) {
- super();
- this.type = type;
- }
-
- @Override
- public boolean onFragmentCreate() {
- super.onFragmentCreate();
-
- getCurrentPassword();
-
- return true;
- }
-
- @Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- if (type == 0) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- }
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("Password", R.string.Password));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == done_button) {
- doneWithPassword();
- }
- }
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- doneButton.setVisibility(loading ? View.GONE : View.VISIBLE);
-
- if (type == 0) {
- oldPasswordCell = new TextFieldCell(getParentActivity());
- oldPasswordCell.setFieldTitleAndHint(LocaleController.getString("OldPassword", R.string.OldPassword), LocaleController.getString("EnterOldPassword", R.string.EnterOldPassword), AndroidUtilities.dp(10), true);
- oldPasswordCell.setBackgroundColor(0xffffffff);
- newPasswordCell = new TextFieldCell(getParentActivity());
- newPasswordCell.setFieldTitleAndHint(LocaleController.getString("NewPassword", R.string.NewPassword), LocaleController.getString("EnterNewPassword", R.string.EnterNewPassword), 0, true);
- newPasswordCell.setBackgroundColor(0xffffffff);
- verifyPasswordCell = new TextFieldCell(getParentActivity());
- verifyPasswordCell.setFieldTitleAndHint(null, LocaleController.getString("VerifyNewPassword", R.string.VerifyNewPassword), AndroidUtilities.dp(10), true);
- verifyPasswordCell.setBackgroundColor(0xffffffff);
- hintPasswordCell = new TextFieldCell(getParentActivity());
- hintPasswordCell.setFieldTitleAndHint(LocaleController.getString("PasswordHint", R.string.PasswordHint), LocaleController.getString("EnterHint", R.string.EnterHint), AndroidUtilities.dp(22), false);
- hintPasswordCell.setBackgroundColor(0xffffffff);
- if (hint != null) {
- hintPasswordCell.setFieldText(hint);
- }
- } else if (type == 1) {
- oldPasswordCell = new TextFieldCell(getParentActivity());
- oldPasswordCell.setFieldTitleAndHint(null, LocaleController.getString("EnterYourPassword", R.string.EnterYourPassword), AndroidUtilities.dp(22), true);
- oldPasswordCell.setBackgroundColor(0xffffffff);
- }
-
- listAdapter = new ListAdapter(getParentActivity());
-
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
- frameLayout.setBackgroundColor(0xfff0f0f0);
-
- FrameLayout progressView = new FrameLayout(getParentActivity());
- frameLayout.addView(progressView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- progressView.setLayoutParams(layoutParams);
-
- ProgressBar progressBar = new ProgressBar(getParentActivity());
- progressView.addView(progressBar);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.gravity = Gravity.CENTER;
- progressView.setLayoutParams(layoutParams);
-
- ListView listView = new ListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDrawSelectorOnTop(true);
- listView.setEmptyView(progressView);
- frameLayout.addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(listAdapter);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
- if (i == deleteAccountRow) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.getString("AreYouSureDeleteAccount", R.string.AreYouSureDeleteAccount));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.getString("AreYouSureDeleteAccount2", R.string.AreYouSureDeleteAccount2));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
- req.reason = "Forgot password";
- ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
- @Override
- public void run(TLObject response, TLRPC.TL_error error) {
- if (error == null) {
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.clear().commit();
- MessagesController.getInstance().unregistedPush();
- MessagesController.getInstance().logOut();
- UserConfig.clearConfig();
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
- MessagesStorage.getInstance().cleanUp(false);
- MessagesController.getInstance().cleanUp();
- ContactsController.getInstance().deleteAllAppAccounts();
- }
- });
- }
- }
- }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin);
- }
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- }
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- }
- }
- });
-
- updateRows();
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
- return fragmentView;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- }
- }
-
- private void updateRows() {
- rowCount = 0;
- if (!loading) {
- if (type == 0) {
- changePasswordSectionRow = rowCount++;
- oldPasswordRow = hasPassword ? rowCount++ : -1;
- newPasswordRow = rowCount++;
- verifyPasswordRow = rowCount++;
- hintRow = rowCount++;
- passwordDetailRow = rowCount++;
- deleteAccountSection = -1;
- deleteAccountRow = -1;
- deleteAccountDetailRow = -1;
- } else if (type == 1) {
- changePasswordSectionRow = rowCount++;
- oldPasswordRow = rowCount++;
- passwordDetailRow = rowCount++;
- deleteAccountSection = rowCount++;
- deleteAccountDetailRow = rowCount++;
- verifyPasswordRow = -1;
- newPasswordRow = -1;
- hintRow = -1;
- deleteAccountRow = -1;
- }
- doneButton.setVisibility(View.VISIBLE);
- }
- listAdapter.notifyDataSetChanged();
- }
-
- private void ShowAlert(final String text) {
- if (text == null || getParentActivity() == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setMessage(text);
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
- showAlertDialog(builder);
- }
-
- private void needShowProgress() {
- if (getParentActivity() == null || getParentActivity().isFinishing() || progressDialog != null) {
- return;
- }
- progressDialog = new ProgressDialog(getParentActivity());
- progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
- progressDialog.setCanceledOnTouchOutside(false);
- progressDialog.setCancelable(false);
- progressDialog.show();
- }
-
- private void needHideProgress() {
- if (progressDialog == null) {
- return;
- }
- try {
- progressDialog.dismiss();
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
- progressDialog = null;
- }
-
- private void getCurrentPassword() {
- loading = true;
- TLRPC.TL_account_getPassword req = new TLRPC.TL_account_getPassword();
- 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() {
- loading = false;
- TLRPC.account_Password res = (TLRPC.account_Password) response;
- if (res instanceof TLRPC.TL_account_noPassword) {
- hasPassword = false;
- new_salt = res.new_salt;
- hint = null;
- current_salt = null;
- } else if (res instanceof TLRPC.TL_account_password) {
- hasPassword = true;
- new_salt = res.new_salt;
- hint = res.hint;
- current_salt = res.current_salt;
- } else {
- new_salt = null;
- hint = null;
- current_salt = null;
- }
- if (new_salt != null) {
- byte[] salt = new byte[new_salt.length + 16];
- Utilities.random.nextBytes(salt);
- System.arraycopy(new_salt, 0, salt, 0, new_salt.length);
- new_salt = salt;
- }
- if (type == 0 && hintPasswordCell != null && hint != null) {
- hintPasswordCell.setFieldText(hint);
- }
- updateRows();
- }
- });
- }
- }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
- }
-
- private void doneWithPassword() {
- if (type == 0) {
- String oldPassword = oldPasswordCell.getFieldText();
- String newPassword = newPasswordCell.getFieldText();
- String verifyPasswrod = verifyPasswordCell.getFieldText();
- String hint = hintPasswordCell.getFieldText();
- if (hasPassword) {
- if (oldPassword.length() == 0) {
- ShowAlert(LocaleController.getString("PasswordOldIncorrect", R.string.PasswordOldIncorrect));
- return;
- }
- }
- if (newPassword.length() == 0) {
- ShowAlert(LocaleController.getString("PasswordNewIncorrect", R.string.PasswordNewIncorrect));
- return;
- }
- if (!newPassword.equals(verifyPasswrod)) {
- ShowAlert(LocaleController.getString("PasswordDoNotMatch", R.string.PasswordDoNotMatch));
- return;
- }
- if (hint.toLowerCase().contains(newPassword.toLowerCase())) {
- ShowAlert(LocaleController.getString("HintIncorrect", R.string.HintIncorrect));
- return;
- }
- byte[] oldPasswordBytes = null;
- byte[] newPasswordBytes = null;
- try {
- oldPasswordBytes = oldPassword.getBytes("UTF-8");
- newPasswordBytes = newPassword.getBytes("UTF-8");
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
-
- TLRPC.TL_account_setPassword req = new TLRPC.TL_account_setPassword();
- req.hint = hintPasswordCell.getFieldText();
- if (req.hint == null) {
- req.hint = "";
- }
- if (hasPassword) {
- byte[] hash = new byte[current_salt.length * 2 + oldPasswordBytes.length];
- System.arraycopy(current_salt, 0, hash, 0, current_salt.length);
- System.arraycopy(oldPasswordBytes, 0, hash, oldPasswordBytes.length, oldPasswordBytes.length);
- System.arraycopy(current_salt, 0, hash, hash.length - current_salt.length, current_salt.length);
- req.current_password_hash = Utilities.computeSHA256(hash, 0, hash.length);
- } else {
- req.current_password_hash = new byte[0];
- }
-
- needShowProgress();
- byte[] hash = new byte[new_salt.length * 2 + newPasswordBytes.length];
- System.arraycopy(new_salt, 0, hash, 0, new_salt.length);
- System.arraycopy(newPasswordBytes, 0, hash, newPasswordBytes.length, newPasswordBytes.length);
- System.arraycopy(new_salt, 0, hash, hash.length - new_salt.length, new_salt.length);
- req.new_password_hash = Utilities.computeSHA256(hash, 0, hash.length);
- req.new_salt = new_salt;
- 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() {
- needHideProgress();
- if (error == null) {
- UserConfig.registeredForPush = false;
- UserConfig.registeredForInternalPush = false;
- UserConfig.saveConfig(false);
- MessagesController.getInstance().registerForPush(UserConfig.pushString);
- ConnectionsManager.getInstance().initPushConnection();
- finishFragment();
- } else {
- if (error.text.contains("PASSWORD_HASH_INVALID")) {
- ShowAlert(LocaleController.getString("PasswordOldIncorrect", R.string.PasswordOldIncorrect));
- } else if (error.text.contains("NEW_PASSWORD_BAD")) {
- ShowAlert(LocaleController.getString("PasswordNewIncorrect", R.string.PasswordNewIncorrect));
- } else if (error.text.startsWith("FLOOD_WAIT")) {
- ShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait));
- } else {
- ShowAlert(error.text);
- }
- }
- }
- });
- }
- }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors);
- } else if (type == 1) {
- String oldPassword = oldPasswordCell.getFieldText();
- if (oldPassword.length() == 0) {
- ShowAlert(LocaleController.getString("PasswordIncorrect", R.string.PasswordIncorrect));
- return;
- }
- byte[] oldPasswordBytes = null;
- try {
- oldPasswordBytes = oldPassword.getBytes("UTF-8");
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
-
- needShowProgress();
- byte[] hash = new byte[current_salt.length * 2 + oldPasswordBytes.length];
- System.arraycopy(current_salt, 0, hash, 0, current_salt.length);
- System.arraycopy(oldPasswordBytes, 0, hash, oldPasswordBytes.length, oldPasswordBytes.length);
- System.arraycopy(current_salt, 0, hash, hash.length - current_salt.length, current_salt.length);
-
- TLRPC.TL_auth_checkPassword req = new TLRPC.TL_auth_checkPassword();
- req.password_hash = Utilities.computeSHA256(hash, 0, hash.length);
- 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() {
- needHideProgress();
- if (error == null) {
- if (UserConfig.isClientActivated()) {
- presentFragment(new MessagesActivity(null), true);
- UserConfig.registeredForPush = false;
- UserConfig.registeredForInternalPush = false;
- UserConfig.saveConfig(false);
- MessagesController.getInstance().registerForPush(UserConfig.pushString);
- ConnectionsManager.getInstance().initPushConnection();
- } else {
- TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
- UserConfig.clearConfig();
- MessagesController.getInstance().cleanUp();
- UserConfig.setCurrentUser(res.user);
- UserConfig.saveConfig(true);
- MessagesStorage.getInstance().cleanUp(true);
- ArrayList users = new ArrayList<>();
- users.add(res.user);
- MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
- MessagesController.getInstance().putUser(res.user, false);
- ContactsController.getInstance().checkAppAccount();
- MessagesController.getInstance().getBlockedUsers(true);
- presentFragment(new MessagesActivity(null), true);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
- ConnectionsManager.getInstance().initPushConnection();
- }
- } else {
- if (error.text.contains("PASSWORD_HASH_INVALID")) {
- ShowAlert(LocaleController.getString("PasswordOldIncorrect", R.string.PasswordOldIncorrect));
- } else if (error.text.startsWith("FLOOD_WAIT")) {
- ShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait));
- } else {
- ShowAlert(error.text);
- }
- }
- }
- });
- }
- }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
- }
- }
-
- private class ListAdapter extends BaseFragmentAdapter {
- private Context mContext;
-
- public ListAdapter(Context context) {
- mContext = context;
- }
-
- @Override
- public boolean areAllItemsEnabled() {
- return false;
- }
-
- @Override
- public boolean isEnabled(int i) {
- return i == deleteAccountRow;
- }
-
- @Override
- public int getCount() {
- return rowCount;
- }
-
- @Override
- public Object getItem(int i) {
- return null;
- }
-
- @Override
- public long getItemId(int i) {
- return i;
- }
-
- @Override
- public boolean hasStableIds() {
- return false;
- }
-
- @Override
- public View getView(int i, View view, ViewGroup viewGroup) {
- int viewType = getItemViewType(i);
- if (viewType == 0) {
- if (view == null) {
- view = new TextInfoPrivacyCell(mContext);
- }
- if (i == passwordDetailRow) {
- if (type == 0) {
- ((TextInfoPrivacyCell) view).setText(LocaleController.getString("PasswordImportant", R.string.PasswordImportant));
- } else if (type == 1) {
- ((TextInfoPrivacyCell) view).setText(hint == null || hint.length() == 0 ? "" : LocaleController.formatString("PasswordHintDetail", R.string.PasswordHintDetail, hint));
- }
- ((TextInfoPrivacyCell) view).setTextColor(0xffcf3030);
- if (deleteAccountDetailRow != -1) {
- view.setBackgroundResource(R.drawable.greydivider);
- } else {
- view.setBackgroundResource(R.drawable.greydivider_bottom);
- }
- } else if (i == deleteAccountDetailRow) {
- ((TextInfoPrivacyCell) view).setText(LocaleController.getString("DeleteAccountImportant", R.string.DeleteAccountImportant));
- ((TextInfoPrivacyCell) view).setTextColor(0xffcf3030);
- view.setBackgroundResource(R.drawable.greydivider_bottom);
- }
- } else if (viewType == 1) {
- if (view == null) {
- view = new HeaderCell(mContext);
- view.setBackgroundColor(0xffffffff);
- }
- if (i == changePasswordSectionRow) {
- if (type == 0) {
- ((HeaderCell) view).setText(LocaleController.getString("ChangePassword", R.string.ChangePassword));
- } else if (type == 1) {
- ((HeaderCell) view).setText(LocaleController.getString("EnterPassword", R.string.EnterPassword));
- }
- } else if (i == deleteAccountSection) {
- ((HeaderCell) view).setText(LocaleController.getString("PasswordDeleteAccountTitle", R.string.PasswordDeleteAccountTitle));
- }
- } else if (viewType == 2) {
- return newPasswordCell;
- } else if (viewType == 3) {
- return oldPasswordCell;
- } else if (viewType == 4) {
- return verifyPasswordCell;
- } else if (viewType == 5) {
- return hintPasswordCell;
- } else if (viewType == 6) {
- if (view == null) {
- view = new TextSettingsCell(mContext);
- view.setBackgroundColor(0xffffffff);
- }
- TextSettingsCell textCell = (TextSettingsCell) view;
- if (i == deleteAccountRow) {
- textCell.setText(LocaleController.getString("PasswordDeleteAccount", R.string.PasswordDeleteAccount), false);
- }
- }
- return view;
- }
-
- @Override
- public int getItemViewType(int i) {
- if (i == passwordDetailRow || i == deleteAccountDetailRow) {
- return 0;
- } else if (i == changePasswordSectionRow || i == deleteAccountSection) {
- return 1;
- } else if (i == newPasswordRow) {
- return 2;
- } else if (i == oldPasswordRow) {
- return 3;
- } else if (i == verifyPasswordRow) {
- return 4;
- } else if (i == hintRow) {
- return 5;
- } else if (i == deleteAccountRow) {
- return 6;
- }
- return 0;
- }
-
- @Override
- public int getViewTypeCount() {
- return 7;
- }
-
- @Override
- public boolean isEmpty() {
- return rowCount == 0;
- }
- }
-}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
index f99cfad3..0fec97e2 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java
@@ -8,9 +8,7 @@
package org.telegram.ui.ActionBar;
-import android.app.Activity;
import android.content.Context;
-import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -123,18 +121,10 @@ public class ActionBar extends FrameLayout {
}
int x = 0;
- if (backButtonImageView != null) {
- if (AndroidUtilities.isTablet()) {
- x = AndroidUtilities.dp(80);
- } else {
- x = AndroidUtilities.dp(72);
- }
+ if (backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE) {
+ x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 80 : 72);
} else {
- if (AndroidUtilities.isTablet()) {
- x = AndroidUtilities.dp(26);
- } else {
- x = AndroidUtilities.dp(18);
- }
+ x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
}
if (menu != null) {
@@ -204,17 +194,31 @@ public class ActionBar extends FrameLayout {
}
public void setBackButtonDrawable(Drawable drawable) {
+ boolean reposition = false;
if (backButtonImageView == null) {
createBackButtonImage();
+ } else {
+ reposition = true;
}
+ backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE);
backButtonImageView.setImageDrawable(drawable);
+ if (reposition) {
+ positionTitle(getMeasuredWidth(), getMeasuredHeight());
+ }
}
public void setBackButtonImage(int resource) {
+ boolean reposition = false;
if (backButtonImageView == null) {
createBackButtonImage();
+ } else {
+ reposition = true;
}
+ backButtonImageView.setVisibility(resource == 0 ? GONE : VISIBLE);
backButtonImageView.setImageResource(resource);
+ if (reposition) {
+ positionTitle(getMeasuredWidth(), getMeasuredHeight());
+ }
}
private void createSubtitleTextView() {
@@ -236,7 +240,7 @@ public class ActionBar extends FrameLayout {
createSubtitleTextView();
}
if (subTitleTextView != null) {
- subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE);
+ subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
subTitleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
@@ -278,7 +282,7 @@ public class ActionBar extends FrameLayout {
}
if (titleTextView != null) {
lastTitle = value;
- titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE);
+ titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
@@ -355,7 +359,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.RIGHT;
actionMode.setLayoutParams(layoutParams);
- actionMode.setVisibility(GONE);
+ actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar) {
actionModeTop = new View(getContext());
@@ -366,7 +370,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
actionModeTop.setLayoutParams(layoutParams);
- actionModeTop.setVisibility(GONE);
+ actionModeTop.setVisibility(INVISIBLE);
}
return actionMode;
@@ -392,9 +396,9 @@ public class ActionBar extends FrameLayout {
if (actionMode == null) {
return;
}
- actionMode.setVisibility(GONE);
+ actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar && actionModeTop != null) {
- actionModeTop.setVisibility(GONE);
+ actionModeTop.setVisibility(INVISIBLE);
}
if (titleFrameLayout != null) {
titleFrameLayout.setVisibility(VISIBLE);
@@ -411,10 +415,10 @@ public class ActionBar extends FrameLayout {
protected void onSearchFieldVisibilityChanged(boolean visible) {
isSearchFieldVisible = visible;
if (titleTextView != null) {
- titleTextView.setVisibility(visible ? GONE : VISIBLE);
+ titleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
}
if (subTitleTextView != null) {
- subTitleTextView.setVisibility(visible ? GONE : VISIBLE);
+ subTitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
}
Drawable drawable = backButtonImageView.getDrawable();
if (drawable != null && drawable instanceof MenuDrawable) {
@@ -471,7 +475,7 @@ public class ActionBar extends FrameLayout {
createTitleTextView();
}
if (titleTextView != null) {
- titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : GONE);
+ titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(textToSet);
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
index 16fb026d..69e67cf9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java
@@ -303,7 +303,7 @@ public class ActionBarLayout extends FrameLayout {
}
}
}
- containerViewBack.setVisibility(View.GONE);
+ containerViewBack.setVisibility(View.INVISIBLE);
//AndroidUtilities.unlockOrientation(parentActivity);
startedTracking = false;
animationInProgress = false;
@@ -321,7 +321,15 @@ public class ActionBarLayout extends FrameLayout {
beginTrackingSent = false;
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2);
- View fragmentView = lastFragment.createView(parentActivity.getLayoutInflater());
+ View fragmentView = lastFragment.fragmentView;
+ if (fragmentView == null) {
+ fragmentView = lastFragment.createView(parentActivity, parentActivity.getLayoutInflater());
+ } else {
+ ViewGroup parent = (ViewGroup) fragmentView.getParent();
+ if (parent != null) {
+ parent.removeView(fragmentView);
+ }
+ }
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
@@ -342,7 +350,7 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
fragmentView.setLayoutParams(layoutParams);
- if (fragmentView.getBackground() == null) {
+ if (!lastFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff);
}
lastFragment.onResume();
@@ -372,7 +380,7 @@ public class ActionBarLayout extends FrameLayout {
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
int dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev);
- if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.dp(10) && Math.abs(dx) / 3 > dy) {
+ if (maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.3f, true) && Math.abs(dx) / 3 > dy) {
prepareForMoving(ev);
} else if (startedTracking) {
if (!beginTrackingSent) {
@@ -531,7 +539,7 @@ public class ActionBarLayout extends FrameLayout {
}
}
}
- containerViewBack.setVisibility(View.GONE);
+ containerViewBack.setVisibility(View.INVISIBLE);
}
public boolean presentFragment(BaseFragment fragment) {
@@ -555,7 +563,15 @@ public class ActionBarLayout extends FrameLayout {
final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
fragment.setParentLayout(this);
- View fragmentView = fragment.createView(parentActivity.getLayoutInflater());
+ View fragmentView = fragment.fragmentView;
+ if (fragmentView == null) {
+ fragmentView = fragment.createView(parentActivity, parentActivity.getLayoutInflater());
+ } else {
+ ViewGroup parent = (ViewGroup) fragmentView.getParent();
+ if (parent != null) {
+ parent.removeView(fragmentView);
+ }
+ }
if (fragment.needAddActionBar() && fragment.actionBar != null) {
if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false);
@@ -576,7 +592,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentsStack.add(fragment);
fragment.onResume();
currentActionBar = fragment.actionBar;
- if (fragmentView.getBackground() == null) {
+ if (!fragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff);
}
@@ -707,7 +723,7 @@ public class ActionBarLayout extends FrameLayout {
fragment.onFragmentDestroy();
fragment.setParentLayout(null);
fragmentsStack.remove(fragment);
- containerViewBack.setVisibility(View.GONE);
+ containerViewBack.setVisibility(View.INVISIBLE);
bringChildToFront(containerView);
}
@@ -733,7 +749,15 @@ public class ActionBarLayout extends FrameLayout {
containerView.setVisibility(View.VISIBLE);
previousFragment.setParentLayout(this);
- View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater());
+ View fragmentView = previousFragment.fragmentView;
+ if (fragmentView == null) {
+ fragmentView = previousFragment.createView(parentActivity, parentActivity.getLayoutInflater());
+ } else {
+ ViewGroup parent = (ViewGroup) fragmentView.getParent();
+ if (parent != null) {
+ parent.removeView(fragmentView);
+ }
+ }
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
@@ -752,7 +776,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume();
currentActionBar = previousFragment.actionBar;
- if (fragmentView.getBackground() == null) {
+ if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff);
}
@@ -804,9 +828,9 @@ public class ActionBarLayout extends FrameLayout {
@Override
public void run() {
removeFragmentFromStack(currentFragment);
- setVisibility(GONE);
+ setVisibility(INVISIBLE);
if (backgroundView != null) {
- backgroundView.setVisibility(GONE);
+ backgroundView.setVisibility(INVISIBLE);
}
if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true, false);
@@ -843,9 +867,9 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start();
} else {
removeFragmentFromStack(currentFragment);
- setVisibility(GONE);
+ setVisibility(INVISIBLE);
if (backgroundView != null) {
- backgroundView.setVisibility(GONE);
+ backgroundView.setVisibility(INVISIBLE);
}
}
}
@@ -857,7 +881,15 @@ public class ActionBarLayout extends FrameLayout {
}
BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
previousFragment.setParentLayout(this);
- View fragmentView = previousFragment.createView(parentActivity.getLayoutInflater());
+ View fragmentView = previousFragment.fragmentView;
+ if (fragmentView == null) {
+ fragmentView = previousFragment.createView(parentActivity, parentActivity.getLayoutInflater());
+ } else {
+ ViewGroup parent = (ViewGroup) fragmentView.getParent();
+ if (parent != null) {
+ parent.removeView(fragmentView);
+ }
+ }
if (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false);
@@ -876,7 +908,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume();
currentActionBar = previousFragment.actionBar;
- if (fragmentView.getBackground() == null) {
+ if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
index 30729bf7..7d48a094 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java
@@ -10,6 +10,7 @@ package org.telegram.ui.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@@ -34,6 +35,7 @@ public class BaseFragment {
protected int classGuid = 0;
protected Bundle arguments;
protected boolean swipeBackEnabled = true;
+ protected boolean hasOwnBackground = false;
public BaseFragment() {
classGuid = ConnectionsManager.getInstance().generateClassGuid();
@@ -44,7 +46,7 @@ public class BaseFragment {
classGuid = ConnectionsManager.getInstance().generateClassGuid();
}
- public View createView(LayoutInflater inflater) {
+ public View createView(Context context, LayoutInflater inflater) {
return null;
}
@@ -205,9 +207,9 @@ public class BaseFragment {
return true;
}
- public void showAlertDialog(AlertDialog.Builder builder) {
+ public AlertDialog showAlertDialog(AlertDialog.Builder builder) {
if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) {
- return;
+ return null;
}
try {
if (visibleDialog != null) {
@@ -242,9 +244,11 @@ public class BaseFragment {
onDialogDismiss();
}
});
+ return visibleDialog;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
+ return null;
}
protected void onDialogDismiss() {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
index 0373c2be..435bd463 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
@@ -301,7 +301,7 @@ public class DrawerLayoutContainer extends FrameLayout {
float dx = (int) (ev.getX() - startedTrackingX);
float dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev);
- if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.dp(10))) {
+ if (maybeStartTracking && !startedTracking && (dx > 0 && dx / 3.0f > Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.2f, true) || dx < 0 && Math.abs(dx) >= Math.abs(dy) && Math.abs(dx) >= AndroidUtilities.getPixelsInCM(0.3f, true))) {
prepareForDrawerOpen(ev);
startedTrackingX = (int) ev.getX();
requestDisallowInterceptTouchEvent(true);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java
index 253a905e..92a45e30 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/ContactsAdapter.java
@@ -9,6 +9,7 @@
package org.telegram.ui.Adapters;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -19,6 +20,7 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
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.ui.AnimationCompat.ViewProxy;
@@ -181,6 +183,9 @@ public class ContactsAdapter extends BaseSectionsAdapter {
@Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) {
int type = getItemViewType(section, position);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int cColorGrey = themePrefs.getInt("contactsNameColor", 0xff737373);
+ int cColorBlack = themePrefs.getInt("contactsNameColor", 0xff000000);
if (type == 4) {
if (convertView == null) {
convertView = new DividerCell(mContext);
@@ -192,43 +197,43 @@ public class ContactsAdapter extends BaseSectionsAdapter {
convertView = new GreySectionCell(mContext);
((GreySectionCell) convertView).setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase());
//((GreySectionCell) convertView).setText(String.format(Locale.US, " %d " + LocaleController.getString("Contacts", R.string.Contacts).toUpperCase(), arr0.size()));
- ((GreySectionCell) convertView).setBackgroundColor(AndroidUtilities.getIntDef("contactsRowColor", 0xffffffff));
- ((GreySectionCell) convertView).setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373));
+ ((GreySectionCell) convertView).setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff));
+ ((GreySectionCell) convertView).setTextColor(cColorGrey);
}
} else if (type == 2) {
if (convertView == null) {
convertView = new TextCell(mContext);
}
TextCell actionCell = (TextCell) convertView;
- actionCell.setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000));
+ actionCell.setTextColor(cColorBlack);
if (needPhonebook) {
//actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
Drawable invite = mContext.getResources().getDrawable(R.drawable.menu_invite);
- invite.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
+ invite.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN);
actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), invite);
} else {
if (position == 0) {
//actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
Drawable newGroup = mContext.getResources().getDrawable(R.drawable.menu_newgroup);
- newGroup.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
+ newGroup.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN);
actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), newGroup);
} else if (position == 1) {
//actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
Drawable secret = mContext.getResources().getDrawable(R.drawable.menu_secret);
- secret.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
+ secret.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN);
actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), secret);
} else if (position == 2) {
//actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
Drawable broadcast = mContext.getResources().getDrawable(R.drawable.menu_broadcast);
- broadcast.setColorFilter(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373), PorterDuff.Mode.SRC_IN);
+ broadcast.setColorFilter(cColorGrey, PorterDuff.Mode.SRC_IN);
actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), broadcast);
}
}
} else if (type == 1) {
if (convertView == null) {
convertView = new TextCell(mContext);
- ((TextCell) convertView).setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000));
- ((TextCell) convertView).setTextSize(AndroidUtilities.getIntDef("contactsNameSize", 16));
+ ((TextCell) convertView).setTextColor(cColorBlack);
+ ((TextCell) convertView).setTextSize(themePrefs.getInt("contactsNameSize", 16));
}
ContactsController.Contact contact = ContactsController.getInstance().phoneBookContacts.get(position);
if (contact.first_name != null && contact.last_name != null) {
@@ -242,9 +247,9 @@ public class ContactsAdapter extends BaseSectionsAdapter {
if (convertView == null) {
convertView = new UserCell(mContext, 58);
//((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0);
- ((UserCell) convertView).setStatusColors(AndroidUtilities.getIntDef("contactsStatusColor", 0xffa8a8a8), AndroidUtilities.getIntDef("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15)));
- ((UserCell) convertView).setNameColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000));
- ((UserCell) convertView).setAvatarRadius(AndroidUtilities.getIntDef("contactsAvatarRadius", 32));
+ ((UserCell) convertView).setStatusColors(themePrefs.getInt("contactsStatusColor", 0xffa8a8a8), themePrefs.getInt("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ ((UserCell) convertView).setNameColor(cColorBlack);
+ ((UserCell) convertView).setAvatarRadius(themePrefs.getInt("contactsAvatarRadius", 32));
}
ArrayList arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1)));
@@ -261,7 +266,7 @@ public class ContactsAdapter extends BaseSectionsAdapter {
}
}
}
- parent.setBackgroundColor(AndroidUtilities.getIntDef("contactsRowColor", 0xffffffff));
+ parent.setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff));
return convertView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java
index 8414dd5b..8c39b844 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/CountrySearchAdapter.java
@@ -73,7 +73,7 @@ public class CountrySearchAdapter extends BaseFragmentAdapter {
return;
}
long time = System.currentTimeMillis();
- ArrayList resultArray = new ArrayList();
+ ArrayList resultArray = new ArrayList<>();
String n = query.substring(0, 1);
ArrayList arr = countries.get(n.toUpperCase());
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java
index 640420a0..448e3e9e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java
@@ -9,7 +9,6 @@
package org.telegram.ui.Adapters;
import android.content.Context;
-import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
@@ -348,7 +347,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
user.status.expires = cursor.intValue(7);
}
if (found == 1) {
- dialogSearchResult.name = Html.fromHtml("" + ContactsController.formatName(user.first_name, user.last_name) + "");
+ dialogSearchResult.name = AndroidUtilities.replaceTags("" + ContactsController.formatName(user.first_name, user.last_name) + "");
} else {
dialogSearchResult.name = Utilities.generateSearchName("@" + user.username, null, "@" + q);
}
@@ -534,6 +533,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
notifyDataSetChanged();
return;
}
+ searchResultMessages.clear();
searchResultHashtags.clear();
for (HashtagObject hashtagObject : hashtags) {
searchResultHashtags.add(hashtagObject.hashtag);
@@ -666,14 +666,15 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
int localCount = searchResult.size();
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
- String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
Object obj = getItem(i);
if (obj instanceof TLRPC.User) {
- user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
+ /*user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
if (user == null) {
user = (TLRPC.User) obj;
- }
+ }*/
+ user = (TLRPC.User) obj;
} else if (obj instanceof TLRPC.Chat) {
chat = MessagesController.getInstance().getChat(((TLRPC.Chat) obj).id);
} else if (obj instanceof TLRPC.EncryptedChat) {
@@ -697,8 +698,8 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
foundUserName = foundUserName.substring(1);
}
try {
- username = Html.fromHtml(String.format("@%s%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
- //username = Html.fromHtml(String.format("@%s%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
+ //username = AndroidUtilities.replaceTags(String.format("@%s%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
+ username = AndroidUtilities.replaceTags(String.format("@%s%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
} catch (Exception e) {
username = user.username;
FileLog.e("tmessages", e);
@@ -730,6 +731,9 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
@Override
public int getItemViewType(int i) {
+ if (!searchResultHashtags.isEmpty()) {
+ return i == 0 ? 1 : 4;
+ }
int localCount = searchResult.size();
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java
index ef1e5475..47d26486 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/BlockedUsersActivity.java
@@ -26,16 +26,16 @@ import android.widget.TextView;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController;
-import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
-import org.telegram.ui.Adapters.BaseFragmentAdapter;
-import org.telegram.ui.Cells.TextInfoCell;
-import org.telegram.ui.Cells.UserCell;
+import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.Adapters.BaseFragmentAdapter;
+import org.telegram.ui.Cells.TextInfoCell;
+import org.telegram.ui.Cells.UserCell;
public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
@@ -64,131 +64,124 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == block_user) {
- Bundle args = new Bundle();
- args.putBoolean("onlyUsers", true);
- args.putBoolean("destroyAfterSelect", true);
- args.putBoolean("returnAsResult", true);
- ContactsActivity fragment = new ContactsActivity(args);
- fragment.setDelegate(BlockedUsersActivity.this);
- presentFragment(fragment);
- }
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == block_user) {
+ Bundle args = new Bundle();
+ args.putBoolean("onlyUsers", true);
+ args.putBoolean("destroyAfterSelect", true);
+ args.putBoolean("returnAsResult", true);
+ ContactsActivity fragment = new ContactsActivity(args);
+ fragment.setDelegate(BlockedUsersActivity.this);
+ presentFragment(fragment);
}
- });
+ }
+ });
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItem(block_user, R.drawable.plus);
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItem(block_user, R.drawable.plus);
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
+ fragmentView = new FrameLayout(context);
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
- emptyTextView = new TextView(getParentActivity());
- emptyTextView.setTextColor(0xff808080);
- emptyTextView.setTextSize(20);
- emptyTextView.setGravity(Gravity.CENTER);
- emptyTextView.setVisibility(View.INVISIBLE);
- emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
- frameLayout.addView(emptyTextView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- emptyTextView.setLayoutParams(layoutParams);
- emptyTextView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
+ emptyTextView = new TextView(context);
+ emptyTextView.setTextColor(0xff808080);
+ emptyTextView.setTextSize(20);
+ emptyTextView.setGravity(Gravity.CENTER);
+ emptyTextView.setVisibility(View.INVISIBLE);
+ emptyTextView.setText(LocaleController.getString("NoBlocked", R.string.NoBlocked));
+ frameLayout.addView(emptyTextView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ emptyTextView.setLayoutParams(layoutParams);
+ emptyTextView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ progressView = new FrameLayout(context);
+ frameLayout.addView(progressView);
+ layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ progressView.setLayoutParams(layoutParams);
+
+ ProgressBar progressBar = new ProgressBar(context);
+ progressView.addView(progressBar);
+ layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.CENTER;
+ progressView.setLayoutParams(layoutParams);
+
+ listView = new ListView(context);
+ listView.setEmptyView(emptyTextView);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setAdapter(listViewAdapter = new ListAdapter(context));
+ if (Build.VERSION.SDK_INT >= 11) {
+ listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
+ }
+ frameLayout.addView(listView);
+ layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ if (i < MessagesController.getInstance().blockedUsers.size()) {
+ Bundle args = new Bundle();
+ args.putInt("user_id", MessagesController.getInstance().blockedUsers.get(i));
+ presentFragment(new ProfileActivity(args));
+ }
+ }
+ });
+
+ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
+ if (i < 0 || i >= MessagesController.getInstance().blockedUsers.size() || getParentActivity() == null) {
return true;
}
- });
+ selectedUserId = MessagesController.getInstance().blockedUsers.get(i);
- progressView = new FrameLayout(getParentActivity());
- frameLayout.addView(progressView);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- progressView.setLayoutParams(layoutParams);
-
- ProgressBar progressBar = new ProgressBar(getParentActivity());
- progressView.addView(progressBar);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.gravity = Gravity.CENTER;
- progressView.setLayoutParams(layoutParams);
-
- listView = new ListView(getParentActivity());
- listView.setEmptyView(emptyTextView);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
- if (Build.VERSION.SDK_INT >= 11) {
- listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
- }
- frameLayout.addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
- if (i < MessagesController.getInstance().blockedUsers.size()) {
- Bundle args = new Bundle();
- args.putInt("user_id", MessagesController.getInstance().blockedUsers.get(i));
- presentFragment(new ProfileActivity(args));
- }
- }
- });
-
- listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
- if (i < 0 || i >= MessagesController.getInstance().blockedUsers.size() || getParentActivity() == null) {
- return true;
- }
- selectedUserId = MessagesController.getInstance().blockedUsers.get(i);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- CharSequence[] items = new CharSequence[] {LocaleController.getString("Unblock", R.string.Unblock)};
- builder.setItems(items, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- if (i == 0) {
- MessagesController.getInstance().unblockUser(selectedUserId);
- }
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ CharSequence[] items = new CharSequence[]{LocaleController.getString("Unblock", R.string.Unblock)};
+ builder.setItems(items, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ if (i == 0) {
+ MessagesController.getInstance().unblockUser(selectedUserId);
}
- });
- showAlertDialog(builder);
+ }
+ });
+ showAlertDialog(builder);
- return true;
- }
- });
-
- if (MessagesController.getInstance().loadingBlockedUsers) {
- progressView.setVisibility(View.VISIBLE);
- emptyTextView.setVisibility(View.GONE);
- listView.setEmptyView(null);
- } else {
- progressView.setVisibility(View.GONE);
- listView.setEmptyView(emptyTextView);
+ return true;
}
+ });
+
+ if (MessagesController.getInstance().loadingBlockedUsers) {
+ progressView.setVisibility(View.VISIBLE);
+ emptyTextView.setVisibility(View.GONE);
+ listView.setEmptyView(null);
} else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ progressView.setVisibility(View.GONE);
+ listView.setEmptyView(emptyTextView);
}
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
index 889c7097..71660a93 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java
@@ -9,6 +9,7 @@
package org.telegram.ui.Cells;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -32,8 +33,8 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
-import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Components.AvatarDrawable;
+import org.telegram.ui.PhotoViewer;
public class ChatActionCell extends BaseCell {
@@ -268,13 +269,14 @@ public class ChatActionCell extends BaseCell {
}
private void updateTheme(){
- int color = AndroidUtilities.getIntDef("chatDateColor", 0xffffffff);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int color = themePrefs.getInt("chatDateColor", 0xffffffff);
textPaint.setColor(color);
if(color != 0xffffffff){
textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50);
}
- textPaint.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatDateSize", 16)));//16
- backgroundWhite.setColorFilter(AndroidUtilities.getIntDef("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY);
+ textPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatDateSize", 16)));//16
+ backgroundWhite.setColorFilter(themePrefs.getInt("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY);
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
index 9c3d13ed..a09f0e8e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatBaseCell.java
@@ -10,12 +10,12 @@ package org.telegram.ui.Cells;
import android.annotation.SuppressLint;
import android.content.Context;
+import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
-import android.text.Html;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
@@ -26,15 +26,15 @@ 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.messenger.ApplicationLoader;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
-import org.telegram.messenger.TLRPC;
-import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
-import org.telegram.android.MessageObject;
-import org.telegram.android.ImageReceiver;
+import org.telegram.messenger.TLRPC;
import org.telegram.ui.Components.AvatarDrawable;
public class ChatBaseCell extends BaseCell {
@@ -84,18 +84,10 @@ public class ChatBaseCell extends BaseCell {
private static TextPaint timeMediaPaint;
private static TextPaint namePaint;
private static TextPaint forwardNamePaint;
- private static TextPaint replyNamePaint;
- private static TextPaint replyTextPaint;
- private static Paint replyLinePaint;
+ protected static TextPaint replyNamePaint;
+ protected static TextPaint replyTextPaint;
+ protected static Paint replyLinePaint;
- private static Drawable backgroundDrawableOutWhite;
- private static Drawable backgroundDrawableOutWhiteSelected;
- private static Drawable backgroundMediaDrawableOutWhite;
- private static Drawable backgroundMediaDrawableOutWhiteSelected;
- private static Drawable checkDrawableWhite;
- private static Drawable halfCheckDrawableWhite;
- private static Drawable clockDrawableWhite;
- private static Drawable mediaBackgroundWhiteDrawable;
protected int backgroundWidth = 100;
protected int layoutWidth;
@@ -176,16 +168,6 @@ public class ChatBaseCell extends BaseCell {
backgroundBlack = getResources().getDrawable(R.drawable.system_black);
backgroundBlue = getResources().getDrawable(R.drawable.system_blue);
- backgroundDrawableOutWhite = getResources().getDrawable(R.drawable.msg_out_white);
- backgroundDrawableOutWhiteSelected = getResources().getDrawable(R.drawable.msg_out_white_selected);
- backgroundMediaDrawableOutWhite = getResources().getDrawable(R.drawable.msg_out_photo_white);
- backgroundMediaDrawableOutWhiteSelected = getResources().getDrawable(R.drawable.msg_out_photo_white_selected);
- mediaBackgroundWhiteDrawable = getResources().getDrawable(R.drawable.phototime_white);
-
- checkDrawableWhite = getResources().getDrawable(R.drawable.msg_check_white);
- halfCheckDrawableWhite = getResources().getDrawable(R.drawable.msg_halfcheck_white);
- clockDrawableWhite = getResources().getDrawable(R.drawable.msg_clock_white);
-
timePaintIn = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
timePaintIn.setTextSize(AndroidUtilities.dp(12));
timePaintIn.setColor(0xffa1aab3);
@@ -210,6 +192,8 @@ public class ChatBaseCell extends BaseCell {
replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
replyTextPaint.setTextSize(AndroidUtilities.dp(14));
+ replyTextPaint.linkColor = 0xff316f9f;
+ //replyTextPaint.linkColor = AndroidUtilities.getIntTColor("chatLLinkColor");
replyLinePaint = new Paint();
}
@@ -218,36 +202,49 @@ public class ChatBaseCell extends BaseCell {
avatarDrawable = new AvatarDrawable();
replyImageReceiver = new ImageReceiver(this);
//Chat Photo
- int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int radius = AndroidUtilities.dp(themePrefs.getInt("chatAvatarRadius", 32));
avatarImage.setRoundRadius(radius);
avatarDrawable.setRadius(radius);
}
private void updateTheme(){
- int tColor = AndroidUtilities.getIntColor("themeColor");
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
int lColor = AndroidUtilities.getDefBubbleColor();
int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15);
- backgroundDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY);
- backgroundMediaDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY);
- backgroundDrawableIn.setColorFilter(AndroidUtilities.getIntDef("chatLBubbleColor",0xffffffff), PorterDuff.Mode.MULTIPLY);
- backgroundMediaDrawableIn.setColorFilter(AndroidUtilities.getIntDef("chatLBubbleColor",0xffffffff), PorterDuff.Mode.MULTIPLY);
+ int rBubbleColor = themePrefs.getInt("chatRBubbleColor", lColor);
+ int rBubbleSColor = AndroidUtilities.getIntDarkerColor("chatRBubbleColor", 0x15);
+ int lBubbleColor = themePrefs.getInt("chatLBubbleColor", 0xffffffff);
- int checksColor = AndroidUtilities.getIntDef("chatChecksColor", tColor);
- checkDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY);
- halfCheckDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY);
- clockDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY);
+ backgroundDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN);
+ backgroundMediaDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN);
+ backgroundDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN);
+ backgroundMediaDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN);
- timePaintOut.setColor(AndroidUtilities.getIntDef("chatRTimeColor",dColor));
- timePaintOut.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12)));
- timePaintIn.setColor(AndroidUtilities.getIntDef("chatLTimeColor", 0xffa1aab3));
- timePaintIn.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12)));
+ backgroundDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY);
+ backgroundMediaDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY);
+
+ int checksColor = themePrefs.getInt("chatChecksColor", tColor);
+ checkDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN);
+ halfCheckDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN);
+ clockDrawable.setColorFilter(checksColor, PorterDuff.Mode.SRC_IN);
+
+ timePaintOut.setColor(themePrefs.getInt("chatRTimeColor", dColor));
+ timePaintOut.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatTimeSize", 12)));
+ timePaintIn.setColor(themePrefs.getInt("chatLTimeColor", 0xffa1aab3));
+ timePaintIn.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatTimeSize", 12)));
+
+ int linkColor = themePrefs.getInt("chatLLinkColor", tColor);
int bColor = AndroidUtilities.getIntAlphaColor("chatLBubbleColor", 0xffffffff, 0.9f);
if(currentMessageObject.isOut()){
bColor = AndroidUtilities.getIntAlphaColor("chatRBubbleColor", lColor, 0.9f);
+ linkColor = themePrefs.getInt("chatRLinkColor", tColor);
}
- mediaBackgroundWhiteDrawable.setColorFilter(bColor, PorterDuff.Mode.MULTIPLY);
- mediaBackgroundDrawable = mediaBackgroundWhiteDrawable;
+ mediaBackgroundDrawable.setColorFilter(bColor, PorterDuff.Mode.SRC_IN);
+
+ replyTextPaint.linkColor = linkColor;
}
@Override
@@ -417,7 +414,7 @@ public class ChatBaseCell extends BaseCell {
forwardedNameWidth = getMaxNameWidth();
CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END);
- str = Html.fromHtml(String.format("%s
%s %s", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str));
+ str = AndroidUtilities.replaceTags(String.format("%s\n%s %s", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str));
forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (forwardedNameLayout.getLineCount() > 1) {
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(1)));
@@ -683,15 +680,15 @@ public class ChatBaseCell extends BaseCell {
if (currentMessageObject.isOut()) {
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
if (!media) {
- currentBackgroundDrawable = backgroundDrawableOutWhiteSelected;//backgroundDrawableOutSelected;
+ currentBackgroundDrawable = backgroundDrawableOutSelected;
} else {
- currentBackgroundDrawable = backgroundMediaDrawableOutWhiteSelected;//backgroundMediaDrawableOutSelected;
+ currentBackgroundDrawable = backgroundMediaDrawableOutSelected;
}
} else {
if (!media) {
- currentBackgroundDrawable = backgroundDrawableOutWhite;//backgroundDrawableOut;
+ currentBackgroundDrawable = backgroundDrawableOut;
} else {
- currentBackgroundDrawable = backgroundMediaDrawableOutWhite;//backgroundMediaDrawableOut;
+ currentBackgroundDrawable = backgroundMediaDrawableOut;
}
}
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2));
@@ -720,12 +717,12 @@ public class ChatBaseCell extends BaseCell {
}
onAfterBackgroundDraw(canvas);
-
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
if (drawName && nameLayout != null) {
canvas.save();
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){
- namePaint.setColor(AndroidUtilities.getIntDef("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ namePaint.setColor(themePrefs.getInt("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
}else{
namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id));
}
@@ -737,11 +734,11 @@ public class ChatBaseCell extends BaseCell {
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0));
if (currentMessageObject.isOut()) {
//forwardNamePaint.setColor(0xff4a923c);
- forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
} else {
//forwardNamePaint.setColor(0xff006fc8);
- forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", 0xff006fc8));
+ forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", 0xff006fc8));
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
}
canvas.save();
@@ -774,13 +771,13 @@ public class ChatBaseCell extends BaseCell {
back.draw(canvas);
} else {
if (currentMessageObject.isOut()) {
- int color = AndroidUtilities.getIntDef("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15));
+ int color = themePrefs.getInt("chatForwardColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15));
replyLinePaint.setColor(color);//0xff8dc97a);
replyNamePaint.setColor(color);//0xff61a349);
replyTextPaint.setColor(color);//0xff70b15c);
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11);
} else {
- int color = AndroidUtilities.getIntDef("chatForwardColor", 0xff999999);
+ int color = themePrefs.getInt("chatForwardColor", 0xff999999);
replyLinePaint.setColor(color);//0xff6c9fd2);
replyNamePaint.setColor(color);//0xff377aae);
replyTextPaint.setColor(color);//0xff999999);
@@ -857,7 +854,7 @@ public class ChatBaseCell extends BaseCell {
}
if (drawClock) {
- clockDrawable = clockMediaDrawable = clockDrawableWhite;
+ clockDrawable = clockMediaDrawable;
if (!media) {
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight());
clockDrawable.draw(canvas);
@@ -878,7 +875,7 @@ public class ChatBaseCell extends BaseCell {
}
} else {
if (drawCheck2) {
- checkDrawable = checkMediaDrawable = checkDrawableWhite;
+ checkDrawable = checkMediaDrawable;
if (!media) {
if (drawCheck1) {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight());
@@ -896,7 +893,7 @@ public class ChatBaseCell extends BaseCell {
}
}
if (drawCheck1) {
- halfCheckDrawable = halfCheckMediaDrawable = halfCheckDrawableWhite;
+ halfCheckDrawable = halfCheckMediaDrawable;
if (!media) {
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight());
halfCheckDrawable.draw(canvas);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
index 87848140..f823d5a1 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMediaCell.java
@@ -9,6 +9,7 @@
package org.telegram.ui.Cells;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -25,21 +26,22 @@ import android.view.SoundEffectConstants;
import org.telegram.android.AndroidUtilities;
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.SendMessagesHelper;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader;
-import org.telegram.android.MediaController;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities;
-import org.telegram.android.MessageObject;
import org.telegram.ui.Components.AvatarDrawable;
+import org.telegram.ui.Components.GifDrawable;
import org.telegram.ui.Components.RadialProgress;
import org.telegram.ui.PhotoViewer;
-import org.telegram.ui.Components.GifDrawable;
-import org.telegram.android.ImageReceiver;
import java.io.File;
import java.util.Locale;
@@ -484,7 +486,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
infoLayout2 = new StaticLayout(str2, senderPaint, infoWidth2, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
- infoWidth = Math.min(maxWidth, (int) Math.ceil(infoPaint.measureText(currentInfoString)));
+ infoWidth = Math.max(infoWidth2, (int) Math.ceil(infoPaint.measureText(currentInfoString)));
CharSequence str2 = TextUtils.ellipsize(currentInfoString, infoPaint, infoWidth, TextUtils.TruncateAt.END);
infoLayout = new StaticLayout(str2, infoPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
//
@@ -550,6 +552,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
infoWidth = (int) Math.ceil(senderPaint.measureText(currentInfoString));
infoLayout = new StaticLayout(currentInfoString, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
+ if(!isChat)infoLayout = null;
infoLayout2 = null;
}
nameLayout = null;
@@ -941,23 +944,24 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
}
radialProgress.setHideCurrentDrawable(false);
-
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
if (currentMessageObject.type == 9) {
Drawable menuDrawable = null;
- int color = AndroidUtilities.getIntDef("chatRTextColor", 0xff000000);
+ int color = themePrefs.getInt("chatRTextColor", 0xff000000);
if (currentMessageObject.isOut()) {
//infoPaint.setColor(0xff70b15c);
infoPaint.setColor(color);
docBackPaint.setColor(0xffdaf5c3);
- docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatRTimeColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15)), PorterDuff.Mode.MULTIPLY);
+ docMenuWhiteDrawable.setColorFilter(themePrefs.getInt("chatRTimeColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)), PorterDuff.Mode.MULTIPLY);
menuDrawable = docMenuOutDrawable = docMenuWhiteDrawable;
namePaint.setColor(color);
} else {
- color = AndroidUtilities.getIntDef("chatLTextColor", 0xff000000);
+ color = themePrefs.getInt("chatLTextColor", 0xff000000);
//infoPaint.setColor(0xffa1adbb);
infoPaint.setColor(color);
docBackPaint.setColor(0xffebf0f5);
- docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.MULTIPLY);
+ docMenuWhiteDrawable.setColorFilter(themePrefs.getInt("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.MULTIPLY);
menuDrawable = docMenuInDrawable = docMenuWhiteDrawable;
namePaint.setColor(color);
}
@@ -1023,8 +1027,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
}
radialProgress.onDraw(canvas);
- if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){
- senderPaint.setColor(AndroidUtilities.getIntDef("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ if(themePrefs.getBoolean("chatMemberColorCheck", false)){
+ senderPaint.setColor(themePrefs.getInt("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
}else{
//if(currentMessageObject.type == 9){
senderPaint.setColor(AvatarDrawable.getNameColorForId(MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id).id));
@@ -1054,11 +1058,13 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto() || currentMessageObject.type == 1 || (buttonState == 2 && currentMessageObject.type == 8) )) {
//infoPaint.setColor(0xffffffff);
if(currentMessageObject.isOut()){
- infoPaint.setColor(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000));
- videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY);
+ int color = themePrefs.getInt("chatRTextColor", 0xff000000);
+ infoPaint.setColor(color);
+ videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}else{
- infoPaint.setColor(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000));
- videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY);
+ int color = themePrefs.getInt("chatLTextColor", 0xff000000);
+ infoPaint.setColor(color);
+ videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}
if (currentMessageObject.type == 1){
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
index f1f324e6..97831921 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
@@ -9,35 +9,130 @@
package org.telegram.ui.Cells;
import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.drawable.Drawable;
+import android.net.Uri;
+import android.provider.Browser;
+import android.text.Layout;
import android.text.Spannable;
+import android.text.SpannableStringBuilder;
+import android.text.StaticLayout;
+import android.text.TextPaint;
+import android.text.TextUtils;
import android.text.style.ClickableSpan;
import android.view.MotionEvent;
import org.telegram.android.AndroidUtilities;
-import org.telegram.messenger.FileLog;
+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.messenger.R;
+import org.telegram.messenger.TLRPC;
+import org.telegram.ui.Components.StaticLayoutEx;
import org.telegram.ui.Components.URLSpanNoUnderline;
+import java.util.Locale;
+
public class ChatMessageCell extends ChatBaseCell {
private int textX, textY;
private int totalHeight = 0;
private ClickableSpan pressedLink;
+ private int linkBlockNum;
+ private MyPath urlPath = new MyPath();
+ private boolean linkPreviewPressed;
+ private static Paint urlPaint;
private int lastVisibleBlockNum = 0;
private int firstVisibleBlockNum = 0;
private int totalVisibleBlocksCount = 0;
+ private ImageReceiver linkImageView;
+ private boolean isSmallImage;
+ private boolean drawLinkImageView;
+ private boolean hasLinkPreview;
+ private int linkPreviewHeight;
+ private boolean isInstagram;
+ private int smallImageX;
+ private int descriptionY;
+ private int durationWidth;
+ private StaticLayout siteNameLayout;
+ private StaticLayout titleLayout;
+ private StaticLayout descriptionLayout;
+ private StaticLayout durationLayout;
+ private StaticLayout authorLayout;
+ private static TextPaint durationPaint;
+ private TLRPC.PhotoSize currentPhotoObject;
+ private TLRPC.PhotoSize currentPhotoObjectThumb;
+ private boolean imageCleared;
+
+ private static Drawable igvideoDrawable;
+
+ private 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);
+ }
+ }
+
public ChatMessageCell(Context context) {
super(context);
drawForwardedName = true;
+ linkImageView = new ImageReceiver(this);
+ if (urlPaint == null) {
+ urlPaint = new Paint();
+ urlPaint.setColor(0x33316f9f);
+ }
+ }
+
+ private void resetPressedLink() {
+ if (pressedLink != null) {
+ pressedLink = null;
+ }
+ linkPreviewPressed = false;
+ invalidate();
}
@Override
public boolean onTouchEvent(MotionEvent event) {
+ boolean result = false;
if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !isPressed) {
- if (event.getAction() == MotionEvent.ACTION_DOWN || pressedLink != null && event.getAction() == MotionEvent.ACTION_UP) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN || (linkPreviewPressed || pressedLink != null) && event.getAction() == MotionEvent.ACTION_UP) {
int x = (int)event.getX();
int y = (int)event.getY();
if (x >= textX && y >= textY && x <= textX + currentMessageObject.textWidth && y <= textY + currentMessageObject.textHeight) {
@@ -55,11 +150,19 @@ public class ChatMessageCell extends ChatBaseCell {
if (left <= x && left + block.textLayout.getLineWidth(line) >= x) {
Spannable buffer = (Spannable)currentMessageObject.messageText;
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
-
if (link.length != 0) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ resetPressedLink();
pressedLink = link[0];
- return true;
+ linkBlockNum = blockNum;
+ try {
+ int start = buffer.getSpanStart(pressedLink) - block.charactersOffset;
+ urlPath.setCurrentLayout(block.textLayout, start);
+ block.textLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink) - block.charactersOffset, urlPath);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ result = true;
} else {
if (link[0] == pressedLink) {
try {
@@ -76,30 +179,98 @@ public class ChatMessageCell extends ChatBaseCell {
} catch (Exception e) {
FileLog.e("tmessages", e);
}
- return true;
+ resetPressedLink();
+ result = true;
}
}
} else {
- pressedLink = null;
+ resetPressedLink();
}
} else {
- pressedLink = null;
+ resetPressedLink();
}
} catch (Exception e) {
- pressedLink = null;
+ resetPressedLink();
FileLog.e("tmessages", e);
}
} else {
- pressedLink = null;
+ resetPressedLink();
+ }
+ } else if (hasLinkPreview && x >= textX && x <= textX + backgroundWidth && y >= textY + currentMessageObject.textHeight && y <= textY + currentMessageObject.textHeight + linkPreviewHeight + AndroidUtilities.dp(8)) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ resetPressedLink();
+ if (drawLinkImageView && linkImageView.isInsideImage(x, y)) {
+ linkPreviewPressed = true;
+ result = true;
+ } else {
+ if (descriptionLayout != null && y >= descriptionY) {
+ try {
+ x -= textX + AndroidUtilities.dp(10);
+ y -= descriptionY;
+ final int line = descriptionLayout.getLineForVertical(y);
+ final int off = descriptionLayout.getOffsetForHorizontal(line, x);
+
+ final float left = descriptionLayout.getLineLeft(line);
+ if (left <= x && left + descriptionLayout.getLineWidth(line) >= x) {
+ Spannable buffer = (Spannable) currentMessageObject.linkDescription;
+ ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
+ if (link.length != 0) {
+ resetPressedLink();
+ pressedLink = link[0];
+ linkPreviewPressed = true;
+ linkBlockNum = -10;
+ result = true;
+ try {
+ int start = buffer.getSpanStart(pressedLink);
+ urlPath.setCurrentLayout(descriptionLayout, start);
+ descriptionLayout.getSelectionPath(start, buffer.getSpanEnd(pressedLink), urlPath);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ } else {
+ resetPressedLink();
+ }
+ } else {
+ resetPressedLink();
+ }
+ } catch (Exception e) {
+ resetPressedLink();
+ FileLog.e("tmessages", e);
+ }
+ }
+ }
+ } else if (linkPreviewPressed) {
+ try {
+ if (pressedLink != null) {
+ pressedLink.onClick(this);
+ } else {
+ Uri uri = Uri.parse(currentMessageObject.messageOwner.media.webpage.url);
+ Intent intent = new Intent(Intent.ACTION_VIEW, uri);
+ intent.putExtra(Browser.EXTRA_APPLICATION_ID, getContext().getPackageName());
+ getContext().startActivity(intent);
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ resetPressedLink();
+ result = true;
}
} else {
- pressedLink = null;
+ resetPressedLink();
}
+ } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
+ resetPressedLink();
}
} else {
- pressedLink = null;
+ resetPressedLink();
}
- return super.onTouchEvent(event);
+ if (result && event.getAction() == MotionEvent.ACTION_DOWN) {
+ startCheckLongPress();
+ }
+ if (event.getAction() != MotionEvent.ACTION_DOWN && event.getAction() != MotionEvent.ACTION_MOVE) {
+ cancelCheckLongPress();
+ }
+ return result || super.onTouchEvent(event);
}
public void setVisiblePart(int position, int height) {
@@ -137,6 +308,51 @@ public class ChatMessageCell extends ChatBaseCell {
return left1 <= right2;
}
+ private StaticLayout generateStaticLayout(CharSequence text, TextPaint paint, int maxWidth, int smallWidth, int linesCount, int maxLines) {
+ SpannableStringBuilder stringBuilder = new SpannableStringBuilder(text);
+ int addedChars = 0;
+ StaticLayout layout = new StaticLayout(text, paint, smallWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
+ for (int a = 0; a < linesCount; a++) {
+ int pos = layout.getLineEnd(a);
+ if (pos == text.length()) {
+ break;
+ }
+ pos--;
+ if (stringBuilder.charAt(pos + addedChars) == ' ') {
+ stringBuilder.replace(pos + addedChars, pos + addedChars + 1, "\n");
+ } else {
+ stringBuilder.insert(pos + addedChars, "\n");
+ addedChars++;
+ }
+ if (a == layout.getLineCount() - 1 || a == maxLines - 1) {
+ break;
+ }
+ }
+ return StaticLayoutEx.createStaticLayout(stringBuilder, paint, maxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, maxWidth, maxLines);
+ }
+
+ @Override
+ protected boolean isUserDataChanged() {
+ if (imageCleared || !hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) {
+ return true;
+ }
+ //suppress warning
+ return super.isUserDataChanged();
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (linkImageView != null) {
+ linkImageView.clearImage();
+ if (currentPhotoObject != null) {
+ imageCleared = true;
+ currentPhotoObject = null;
+ currentPhotoObjectThumb = null;
+ }
+ }
+ }
+
@Override
public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isUserDataChanged()) {
@@ -144,7 +360,21 @@ public class ChatMessageCell extends ChatBaseCell {
firstVisibleBlockNum = 0;
lastVisibleBlockNum = 0;
}
- pressedLink = null;
+ drawLinkImageView = false;
+ hasLinkPreview = false;
+ resetPressedLink();
+ linkPreviewPressed = false;
+ linkPreviewHeight = 0;
+ smallImageX = 0;
+ isInstagram = false;
+ durationLayout = null;
+ descriptionLayout = null;
+ titleLayout = null;
+ siteNameLayout = null;
+ authorLayout = null;
+ currentPhotoObject = null;
+ imageCleared = false;
+ currentPhotoObjectThumb = null;
int maxWidth;
if (AndroidUtilities.isTablet()) {
@@ -182,7 +412,215 @@ public class ChatMessageCell extends ChatBaseCell {
timeMore += AndroidUtilities.dp(20.5f);
}
- if (maxWidth - messageObject.lastLineWidth < timeMore) {
+ if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage && messageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage) {
+ int linkPreviewMaxWidth;
+ if (AndroidUtilities.isTablet()) {
+ if (currentMessageObject.messageOwner.to_id.chat_id != 0 && !currentMessageObject.isOut()) {
+ linkPreviewMaxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(122);
+ } else {
+ linkPreviewMaxWidth = AndroidUtilities.getMinTabletSide() - AndroidUtilities.dp(80);
+ }
+ } else {
+ if (currentMessageObject.messageOwner.to_id.chat_id != 0 && !currentMessageObject.isOut()) {
+ linkPreviewMaxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(122);
+ } else {
+ linkPreviewMaxWidth = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) - AndroidUtilities.dp(80);
+ }
+ }
+ int additinalWidth = AndroidUtilities.dp(10);
+ int restLinesCount = 3;
+ int additionalHeight = 0;
+ linkPreviewMaxWidth -= additinalWidth;
+
+ hasLinkPreview = true;
+ TLRPC.TL_webPage webPage = (TLRPC.TL_webPage) messageObject.messageOwner.media.webpage;
+
+ if (currentMessageObject.photoThumbs == null && webPage.photo != null) {
+ currentMessageObject.generateThumbs(true);
+ }
+
+ if (MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO)) {
+ isSmallImage = webPage.description != null && webPage.type != null && (webPage.type.equals("app") || webPage.type.equals("profile") || webPage.type.equals("article")) && currentMessageObject.photoThumbs != null;
+ }
+
+ if (webPage.site_name != null) {
+ try {
+ int width = (int) Math.ceil(replyNamePaint.measureText(webPage.site_name));
+ siteNameLayout = new StaticLayout(webPage.site_name, replyNamePaint, Math.min(width, linkPreviewMaxWidth), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
+ int height = siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1);
+ linkPreviewHeight += height;
+ totalHeight += height;
+ additionalHeight += height;
+ maxChildWidth = Math.max(maxChildWidth, width + additinalWidth);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+
+ if (webPage.title != null) {
+ try {
+ if (linkPreviewHeight != 0) {
+ linkPreviewHeight += AndroidUtilities.dp(2);
+ totalHeight += AndroidUtilities.dp(2);
+ }
+ int restLines = 0;
+ if (!isSmallImage || webPage.description == null) {
+ titleLayout = StaticLayoutEx.createStaticLayout(webPage.title, replyNamePaint, linkPreviewMaxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, linkPreviewMaxWidth, 2);
+ } else {
+ restLines = restLinesCount;
+ titleLayout = generateStaticLayout(webPage.title, replyNamePaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 2);
+ restLinesCount -= titleLayout.getLineCount();
+ }
+ int height = titleLayout.getLineBottom(titleLayout.getLineCount() - 1);
+ linkPreviewHeight += height;
+ totalHeight += height;
+ for (int a = 0; a < titleLayout.getLineCount(); a++) {
+ int width = (int) Math.ceil(titleLayout.getLineWidth(a));
+ if (a < restLines) {
+ smallImageX = Math.max(smallImageX, width);
+ width += AndroidUtilities.dp(48 + 2);
+ }
+ maxChildWidth = Math.max(maxChildWidth, width + additinalWidth);
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+
+ if (webPage.author != null) {
+ try {
+ if (linkPreviewHeight != 0) {
+ linkPreviewHeight += AndroidUtilities.dp(2);
+ totalHeight += AndroidUtilities.dp(2);
+ }
+ int width = Math.min((int) Math.ceil(replyNamePaint.measureText(webPage.author)), linkPreviewMaxWidth);
+ if (restLinesCount == 3 && (!isSmallImage || webPage.description == null)) {
+ authorLayout = new StaticLayout(webPage.author, replyNamePaint, width, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
+ } else {
+ authorLayout = generateStaticLayout(webPage.author, replyNamePaint, width, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 1);
+ restLinesCount -= authorLayout.getLineCount();
+ }
+ int height = authorLayout.getLineBottom(authorLayout.getLineCount() - 1);
+ linkPreviewHeight += height;
+ totalHeight += height;
+ maxChildWidth = Math.max(maxChildWidth, width + additinalWidth);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+
+ if (webPage.description != null) {
+ try {
+ currentMessageObject.generateLinkDescription();
+ if (linkPreviewHeight != 0) {
+ linkPreviewHeight += AndroidUtilities.dp(2);
+ totalHeight += AndroidUtilities.dp(2);
+ }
+ int restLines = 0;
+ if (restLinesCount == 3 && !isSmallImage) {
+ descriptionLayout = StaticLayoutEx.createStaticLayout(messageObject.linkDescription, replyTextPaint, linkPreviewMaxWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, AndroidUtilities.dp(1), false, TextUtils.TruncateAt.END, linkPreviewMaxWidth, 6);
+ } else {
+ restLines = restLinesCount;
+ descriptionLayout = generateStaticLayout(messageObject.linkDescription, replyTextPaint, linkPreviewMaxWidth, linkPreviewMaxWidth - AndroidUtilities.dp(48 + 2), restLinesCount, 6);
+ }
+ int height = descriptionLayout.getLineBottom(descriptionLayout.getLineCount() - 1);
+ linkPreviewHeight += height;
+ totalHeight += height;
+ for (int a = 0; a < descriptionLayout.getLineCount(); a++) {
+ int width = (int) Math.ceil(descriptionLayout.getLineWidth(a));
+ if (a < restLines) {
+ smallImageX = Math.max(smallImageX, width);
+ width += AndroidUtilities.dp(48 + 2);
+ }
+ maxChildWidth = Math.max(maxChildWidth, width + additinalWidth);
+ }
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+
+ if (webPage.photo != null && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_PHOTO)) {
+ boolean smallImage = webPage.type != null && (webPage.type.equals("app") || webPage.type.equals("profile") || webPage.type.equals("article"));
+ if (smallImage && descriptionLayout != null && descriptionLayout.getLineCount() == 1) {
+ smallImage = false;
+ isSmallImage = false;
+ }
+ int maxPhotoWidth = smallImage ? AndroidUtilities.dp(48) : linkPreviewMaxWidth;
+ currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, maxPhotoWidth);
+ currentPhotoObjectThumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
+ if (currentPhotoObjectThumb == currentPhotoObject) {
+ currentPhotoObjectThumb = null;
+ }
+ if (currentPhotoObject != null) {
+ if (linkPreviewHeight != 0) {
+ linkPreviewHeight += AndroidUtilities.dp(2);
+ totalHeight += AndroidUtilities.dp(2);
+ }
+
+ maxChildWidth = Math.max(maxChildWidth, maxPhotoWidth + additinalWidth);
+ currentPhotoObject.size = -1;
+ if (currentPhotoObjectThumb != null) {
+ currentPhotoObjectThumb.size = -1;
+ }
+
+ int width;
+ int height;
+ if (smallImage) {
+ width = height = maxPhotoWidth;
+ } else {
+ width = currentPhotoObject.w;
+ height = currentPhotoObject.h;
+ float scale = width / (float) maxPhotoWidth;
+ width /= scale;
+ height /= scale;
+ if (height > AndroidUtilities.displaySize.y / 3) {
+ height = AndroidUtilities.displaySize.y / 3;
+ }
+ }
+ if (isSmallImage) {
+ if (AndroidUtilities.dp(50) + additionalHeight > linkPreviewHeight) {
+ totalHeight += AndroidUtilities.dp(50) + additionalHeight - linkPreviewHeight + AndroidUtilities.dp(8);
+ linkPreviewHeight = AndroidUtilities.dp(50) + additionalHeight;
+ }
+ linkPreviewHeight -= AndroidUtilities.dp(8);
+ } else {
+ totalHeight += height + AndroidUtilities.dp(12);
+ linkPreviewHeight += height;
+ }
+
+ linkImageView.setImageCoords(0, 0, width, height);
+ linkImageView.setImage(currentPhotoObject.location, String.format(Locale.US, "%d_%d", width, height), currentPhotoObjectThumb != null ? currentPhotoObjectThumb.location : null, String.format(Locale.US, "%d_%d_b", width, height), 0, false);
+ drawLinkImageView = true;
+
+ if (webPage.site_name != null) {
+ if (webPage.site_name.toLowerCase().equals("instagram") && webPage.type != null && webPage.type.equals("video")) {
+ isInstagram = true;
+ if (igvideoDrawable == null) {
+ igvideoDrawable = getResources().getDrawable(R.drawable.igvideo);
+ }
+ }
+ }
+ }
+
+ if (webPage.duration != 0) {
+ if (durationPaint == null) {
+ durationPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
+ durationPaint.setTextSize(AndroidUtilities.dp(12));
+ durationPaint.setColor(0xffffffff);
+ }
+ int minutes = webPage.duration / 60;
+ int seconds = webPage.duration - minutes * 60;
+ String str = String.format("%d:%02d", minutes, seconds);
+ durationWidth = (int) Math.ceil(durationPaint.measureText(str));
+ durationLayout = new StaticLayout(str, durationPaint, durationWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
+ }
+ } else {
+ linkPreviewHeight -= AndroidUtilities.dp(6);
+ totalHeight += AndroidUtilities.dp(4);
+ }
+ }
+
+ if (hasLinkPreview || maxWidth - messageObject.lastLineWidth < timeMore) {
totalHeight += AndroidUtilities.dp(14);
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth) + AndroidUtilities.dp(29);
} else {
@@ -217,7 +655,7 @@ public class ChatMessageCell extends ChatBaseCell {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
- if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null || currentMessageObject.textLayoutBlocks.isEmpty() || firstVisibleBlockNum < 0) {
+ if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null || currentMessageObject.textLayoutBlocks.isEmpty()) {
return;
}
@@ -229,19 +667,131 @@ public class ChatMessageCell extends ChatBaseCell {
textY = AndroidUtilities.dp(10) + namesOffset;
}
- for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
- if (a >= currentMessageObject.textLayoutBlocks.size()) {
- break;
+ if (firstVisibleBlockNum >= 0) {
+ for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
+ if (a >= currentMessageObject.textLayoutBlocks.size()) {
+ break;
+ }
+ MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(a);
+ canvas.save();
+ canvas.translate(textX - (int) Math.ceil(block.textXOffset), textY + block.textYOffset);
+ if (pressedLink != null && a == linkBlockNum) {
+ canvas.drawPath(urlPath, urlPaint);
+ }
+ try {
+ block.textLayout.draw(canvas);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ canvas.restore();
}
- MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(a);
- canvas.save();
- canvas.translate(textX - (int)Math.ceil(block.textXOffset), textY + block.textYOffset);
- try {
- block.textLayout.draw(canvas);
- } catch (Exception e) {
- FileLog.e("tmessages", e);
+ }
+
+ if (hasLinkPreview) {
+ int startY = textY + currentMessageObject.textHeight + AndroidUtilities.dp(8);
+ int linkPreviewY = startY;
+ int smallImageStartY = 0;
+ //replyLinePaint.setColor(currentMessageObject.isOut() ? 0xff8dc97a : 0xff6c9fd2);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
+ int rColor = themePrefs.getInt("chatRLinkColor", defColor);
+ int lColor = themePrefs.getInt("chatLLinkColor", defColor);
+ int rtColor = themePrefs.getInt("chatRTextColor", 0xff000000);
+ int ltColor = themePrefs.getInt("chatLTextColor", 0xff000000);
+ replyLinePaint.setColor(currentMessageObject.isOut() ? rColor : lColor);
+ canvas.drawRect(textX, linkPreviewY - AndroidUtilities.dp(3), textX + AndroidUtilities.dp(2), linkPreviewY + linkPreviewHeight + AndroidUtilities.dp(3), replyLinePaint);
+
+ if (siteNameLayout != null) {
+ //replyNamePaint.setColor(currentMessageObject.isOut() ? 0xff70b15c : 0xff4b91cf);
+ replyNamePaint.setColor(currentMessageObject.isOut() ? rColor : lColor);
+ canvas.save();
+ canvas.translate(textX + AndroidUtilities.dp(10), linkPreviewY - AndroidUtilities.dp(3));
+ siteNameLayout.draw(canvas);
+ canvas.restore();
+ linkPreviewY += siteNameLayout.getLineBottom(siteNameLayout.getLineCount() - 1);
+ }
+
+ if (titleLayout != null) {
+ if (linkPreviewY != startY) {
+ linkPreviewY += AndroidUtilities.dp(2);
+ }
+ //replyNamePaint.setColor(0xff000000);
+ replyNamePaint.setColor(currentMessageObject.isOut() ? rtColor : ltColor);
+ smallImageStartY = linkPreviewY - AndroidUtilities.dp(1);
+ canvas.save();
+ canvas.translate(textX + AndroidUtilities.dp(10), linkPreviewY - AndroidUtilities.dp(3));
+ titleLayout.draw(canvas);
+ canvas.restore();
+ linkPreviewY += titleLayout.getLineBottom(titleLayout.getLineCount() - 1);
+ }
+
+ if (authorLayout != null) {
+ if (linkPreviewY != startY) {
+ linkPreviewY += AndroidUtilities.dp(2);
+ }
+ if (smallImageStartY == 0) {
+ smallImageStartY = linkPreviewY - AndroidUtilities.dp(1);
+ }
+ //replyNamePaint.setColor(0xff000000);
+ replyNamePaint.setColor(currentMessageObject.isOut() ? rtColor : ltColor);
+ canvas.save();
+ canvas.translate(textX + AndroidUtilities.dp(10), linkPreviewY - AndroidUtilities.dp(3));
+ authorLayout.draw(canvas);
+ canvas.restore();
+ linkPreviewY += authorLayout.getLineBottom(authorLayout.getLineCount() - 1);
+ }
+
+ if (descriptionLayout != null) {
+ if (linkPreviewY != startY) {
+ linkPreviewY += AndroidUtilities.dp(2);
+ }
+ if (smallImageStartY == 0) {
+ smallImageStartY = linkPreviewY - AndroidUtilities.dp(1);
+ }
+ //replyTextPaint.setColor(0xff000000);
+ replyTextPaint.setColor(currentMessageObject.isOut() ? rtColor : ltColor);
+ descriptionY = linkPreviewY - AndroidUtilities.dp(3);
+ canvas.save();
+ canvas.translate(textX + AndroidUtilities.dp(10), descriptionY);
+ if (pressedLink != null && linkBlockNum == -10) {
+ canvas.drawPath(urlPath, urlPaint);
+ }
+ descriptionLayout.draw(canvas);
+ canvas.restore();
+ linkPreviewY += descriptionLayout.getLineBottom(descriptionLayout.getLineCount() - 1);
+ }
+
+ if (drawLinkImageView) {
+ if (linkPreviewY != startY) {
+ linkPreviewY += AndroidUtilities.dp(2);
+ }
+
+ if (isSmallImage) {
+ linkImageView.setImageCoords(textX + smallImageX + AndroidUtilities.dp(12), smallImageStartY, linkImageView.getImageWidth(), linkImageView.getImageHeight());
+ } else {
+ linkImageView.setImageCoords(textX + AndroidUtilities.dp(10), linkPreviewY, linkImageView.getImageWidth(), linkImageView.getImageHeight());
+ }
+ linkImageView.draw(canvas);
+
+ if (isInstagram && igvideoDrawable != null) {
+ int x = linkImageView.getImageX() + linkImageView.getImageWidth() - igvideoDrawable.getIntrinsicWidth() - AndroidUtilities.dp(4);
+ int y = linkImageView.getImageY() + AndroidUtilities.dp(4);
+ igvideoDrawable.setBounds(x, y, x + igvideoDrawable.getIntrinsicWidth(), y + igvideoDrawable.getIntrinsicHeight());
+ igvideoDrawable.draw(canvas);
+ }
+
+ if (durationLayout != null) {
+ int x = linkImageView.getImageX() + linkImageView.getImageWidth() - AndroidUtilities.dp(8) - durationWidth;
+ int y = linkImageView.getImageY() + linkImageView.getImageHeight() - AndroidUtilities.dp(19);
+ mediaBackgroundDrawable.setBounds(x - AndroidUtilities.dp(4), y - AndroidUtilities.dp(1.5f), x + durationWidth + AndroidUtilities.dp(4), y + AndroidUtilities.dp(14.5f));
+ mediaBackgroundDrawable.draw(canvas);
+
+ canvas.save();
+ canvas.translate(x, y);
+ durationLayout.draw(canvas);
+ canvas.restore();
+ }
}
- canvas.restore();
}
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java
index 9b7cd5c5..ed8f4ffc 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java
@@ -8,32 +8,30 @@
package org.telegram.ui.Cells;
-import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
-import android.text.Html;
import android.text.Layout;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
-import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
-import org.telegram.android.LocaleController;
-import org.telegram.android.MessageObject;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.FileLog;
-import org.telegram.messenger.TLRPC;
+import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.Emoji;
-import org.telegram.android.MessagesController;
-import org.telegram.messenger.R;
-import org.telegram.messenger.UserConfig;
import org.telegram.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.FileLog;
+import org.telegram.messenger.R;
+import org.telegram.messenger.TLRPC;
+import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.AvatarDrawable;
public class DialogCell extends BaseCell {
@@ -145,6 +143,7 @@ public class DialogCell extends BaseCell {
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
messagePaint.setTextSize(AndroidUtilities.dp(16));
messagePaint.setColor(0xff8f8f8f);
+ messagePaint.linkColor = 0xff8f8f8f;
linePaint = new Paint();
linePaint.setColor(0xffdcdcdc);
@@ -376,13 +375,15 @@ public class DialogCell extends BaseCell {
}
}
checkMessage = false;
- String hexColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntColor("themeColor")));
- String hexMsgColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDef("chatsMessageColor",0xff8f8f8f)));
- String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDef("chatsMemberColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15))));
- if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
+ String hexColor = String.format("#%08X", (0xFFFFFFFF & defColor));
+ String hexMsgColor = String.format("#%08X", (0xFFFFFFFF & themePrefs.getInt("chatsMessageColor", 0xff8f8f8f)));
+ String hexDarkColor = String.format("#%08X", (0xFFFFFFFF & themePrefs.getInt("chatsMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))));
+ if (message.messageOwner.media != null && !message.isMediaEmpty()) {
currentMessagePaint = messagePrintingPaint;
- //messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
- messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
+ //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
+ messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} else {
if (message.messageOwner.message != null) {
String mess = message.messageOwner.message;
@@ -390,13 +391,13 @@ public class DialogCell extends BaseCell {
mess = mess.substring(0, 150);
}
mess = mess.replace("\n", " ");
- //messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
- messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
+ //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
+ messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("%s: %s", name, mess.replace("<", "<").replace(">", ">"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
}
}
} else {
messageString = message.messageText;
- if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (message.messageOwner.media != null && !message.isMediaEmpty()) {
currentMessagePaint = messagePrintingPaint;
}
}
@@ -775,7 +776,7 @@ public class DialogCell extends BaseCell {
private void updateTheme(){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
- int tColor = AndroidUtilities.getIntColor("themeColor");
+ int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15);
namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
@@ -791,10 +792,10 @@ public class DialogCell extends BaseCell {
messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f));
messagePrintingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
- messagePrintingPaint.setColor(AndroidUtilities.getIntDef("chatsMessageColor", tColor));
+ messagePrintingPaint.setColor(themePrefs.getInt("chatsMessageColor", tColor));
messageTypingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16)));
- messageTypingPaint.setColor(AndroidUtilities.getIntDef("chatsTypingColor", tColor));
+ messageTypingPaint.setColor(themePrefs.getInt("chatsTypingColor", tColor));
timePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsTimeSize", 13)));
timePaint.setColor(themePrefs.getInt("chatsTimeColor", 0xff999999));
@@ -802,9 +803,9 @@ public class DialogCell extends BaseCell {
countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13)));
countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff));
- checkWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
- halfCheckWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
- clockDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.SRC_IN);
+ checkWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY);
+ halfCheckWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY);
+ clockDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN);
countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY);
lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY);
@@ -819,7 +820,7 @@ public class DialogCell extends BaseCell {
linePaint.setColor(themePrefs.getInt("chatsDividerColor", 0xffdcdcdc));
- int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatsAvatarRadius", 32));
+ int radius = AndroidUtilities.dp(themePrefs.getInt("chatsAvatarRadius", 32));
if(avatarImage != null)avatarImage.setRoundRadius(radius);
if(avatarDrawable != null)avatarDrawable.setRadius(radius);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java
index af64d153..0b7fab23 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerActionCell.java
@@ -17,7 +17,6 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.messenger.R;
public class DrawerActionCell extends FrameLayout {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java
index 77517455..907e88f7 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DrawerProfileCell.java
@@ -10,6 +10,7 @@ package org.telegram.ui.Cells;
import android.app.Activity;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -64,7 +65,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
shadowView.setLayoutParams(layoutParams);
avatarImageView = new BackupImageView(context);
- avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
+ avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
addView(avatarImageView);
layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(64);
@@ -197,11 +198,11 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = avatarImageView;
- object.imageReceiver = avatarImageView.imageReceiver;
+ object.imageReceiver = avatarImageView.getImageReceiver();
object.user_id = UserConfig.getClientUserId();
object.thumb = object.imageReceiver.getBitmap();
object.size = -1;
- object.radius = avatarImageView.imageReceiver.getRoundRadius();
+ object.radius = avatarImageView.getImageReceiver().getRoundRadius();
return object;
}
}
@@ -218,7 +219,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
@Override
public void willHidePhotoViewer() {
- avatarImageView.imageReceiver.setVisible(true, true);
+ avatarImageView.getImageReceiver().setVisible(true, true);
}
@Override
@@ -237,23 +238,24 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
public int getSelectedCount() { return 0; }
private void updateTheme(){
- int tColor = AndroidUtilities.getIntColor("themeColor");
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",-0x40);
- setBackgroundColor(AndroidUtilities.getIntDef("drawerHeaderColor", tColor));
- nameTextView.setTextColor(AndroidUtilities.getIntDef("drawerNameColor", 0xffffffff));
- nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("drawerNameSize", 15));
- phoneTextView.setTextColor(AndroidUtilities.getIntDef("drawerPhoneColor", dColor));
- phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("drawerPhoneSize", 13));
+ setBackgroundColor(themePrefs.getInt("drawerHeaderColor", tColor));
+ nameTextView.setTextColor(themePrefs.getInt("drawerNameColor", 0xffffffff));
+ nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("drawerNameSize", 15));
+ phoneTextView.setTextColor(themePrefs.getInt("drawerPhoneColor", dColor));
+ phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("drawerPhoneSize", 13));
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
TLRPC.FileLocation photo = null;
if (user != null && user.photo != null && user.photo.photo_small != null ) {
photo = user.photo.photo_small;
}
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
- avatarDrawable.setColor(AndroidUtilities.getIntDef("drawerAvatarColor",AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
- int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("drawerAvatarRadius", 32));
+ avatarDrawable.setColor(themePrefs.getInt("drawerAvatarColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
+ int radius = AndroidUtilities.dp(themePrefs.getInt("drawerAvatarRadius", 32));
avatarDrawable.setRadius(radius);
- avatarImageView.imageReceiver.setRoundRadius(radius);
+ avatarImageView.getImageReceiver().setRoundRadius(radius);
avatarImageView.setImage(photo, "50_50", avatarDrawable);
if(AndroidUtilities.getBoolMain("hideMobile")){
phoneTextView.setVisibility(GONE);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java
index b20ed7c7..16540b5d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/PhotoPickerAlbumsCell.java
@@ -117,7 +117,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
for (int a = 0; a < 4; a++) {
albumViews[a] = new AlbumView(context);
addView(albumViews[a]);
- albumViews[a].setVisibility(GONE);
+ albumViews[a].setVisibility(INVISIBLE);
albumViews[a].setTag(a);
albumViews[a].setOnClickListener(new OnClickListener() {
@Override
@@ -132,7 +132,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
public void setAlbumsCount(int count) {
for (int a = 0; a < albumViews.length; a++) {
- albumViews[a].setVisibility(a < count ? VISIBLE : GONE);
+ albumViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE);
}
albumsCount = count;
}
@@ -156,7 +156,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
albumView.nameTextView.setText(albumEntry.bucketName);
albumView.countTextView.setText(String.format("%d", albumEntry.photos.size()));
} else {
- albumViews[a].setVisibility(GONE);
+ albumViews[a].setVisibility(INVISIBLE);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java
index a44ea690..a3af3d26 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ProfileSearchCell.java
@@ -30,6 +30,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.AvatarDrawable;
public class ProfileSearchCell extends BaseCell {
+
private static TextPaint namePaint;
private static TextPaint nameEncryptedPaint;
private static TextPaint onlinePaint;
@@ -79,7 +80,8 @@ public class ProfileSearchCell extends BaseCell {
if (namePaint == null) {
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
namePaint.setTextSize(AndroidUtilities.dp(17));
- namePaint.setColor(0xff212121);
+ //namePaint.setColor(0xff212121);
+ namePaint.setColor(AndroidUtilities.getIntDef("chatsNameColor", 0xff212121));
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
index 1938fea3..a41172b0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedDocumentCell.java
@@ -36,7 +36,7 @@ import org.telegram.ui.Components.LineProgressView;
import java.io.File;
import java.util.Date;
-public class SharedDocumentCell extends FrameLayout implements MediaController.FileDownloadProgressListener {
+public class SharedDocumentCell extends FrameLayout implements MediaController.FileDownloadProgressListener {
private ImageView placeholderImabeView;
private BackupImageView thumbImageView;
@@ -106,11 +106,11 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
extTextView.setLayoutParams(layoutParams);
thumbImageView = new BackupImageView(context);
- thumbImageView.imageReceiver.setDelegate(new ImageReceiver.ImageReceiverDelegate() {
+ thumbImageView.getImageReceiver().setDelegate(new ImageReceiver.ImageReceiverDelegate() {
@Override
public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
- extTextView.setVisibility(set ? GONE : VISIBLE);
- placeholderImabeView.setVisibility(set ? GONE : VISIBLE);
+ extTextView.setVisibility(set ? INVISIBLE : VISIBLE);
+ placeholderImabeView.setVisibility(set ? INVISIBLE : VISIBLE);
}
});
addView(thumbImageView);
@@ -143,7 +143,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
nameTextView.setLayoutParams(layoutParams);
statusImageView = new ImageView(context);
- statusImageView.setVisibility(GONE);
+ statusImageView.setVisibility(INVISIBLE);
addView(statusImageView);
layoutParams = (LayoutParams) statusImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
@@ -184,7 +184,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
progressView.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2);
- checkBox.setVisibility(GONE);
+ checkBox.setVisibility(INVISIBLE);
addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22);
@@ -229,13 +229,13 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
extTextView.setVisibility(VISIBLE);
extTextView.setText(type);
} else {
- extTextView.setVisibility(GONE);
+ extTextView.setVisibility(INVISIBLE);
}
if (resId == 0) {
placeholderImabeView.setImageResource(getThumbForNameOrMime(text, type));
placeholderImabeView.setVisibility(VISIBLE);
} else {
- placeholderImabeView.setVisibility(GONE);
+ placeholderImabeView.setVisibility(INVISIBLE);
}
if (thumb != null || resId != 0) {
if (thumb != null) {
@@ -245,7 +245,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
}
thumbImageView.setVisibility(VISIBLE);
} else {
- thumbImageView.setVisibility(GONE);
+ thumbImageView.setVisibility(INVISIBLE);
}
}
@@ -277,7 +277,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
nameTextView.setText(name);
extTextView.setText((idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase());
if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty) {
- thumbImageView.setVisibility(GONE);
+ thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null);
} else {
thumbImageView.setVisibility(VISIBLE);
@@ -291,7 +291,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
dateTextView.setText("");
placeholderImabeView.setVisibility(VISIBLE);
extTextView.setVisibility(VISIBLE);
- thumbImageView.setVisibility(GONE);
+ thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null);
}
@@ -312,7 +312,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
}
loaded = false;
if (fileName == null) {
- statusImageView.setVisibility(GONE);
+ statusImageView.setVisibility(INVISIBLE);
dateTextView.setPadding(0, 0, 0, 0);
loading = false;
loaded = true;
@@ -331,15 +331,15 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
}
progressView.setProgress(progress, false);
} else {
- progressView.setVisibility(GONE);
+ progressView.setVisibility(INVISIBLE);
}
}
} else {
loading = false;
loaded = true;
- progressView.setVisibility(GONE);
+ progressView.setVisibility(INVISIBLE);
progressView.setProgress(0, false);
- statusImageView.setVisibility(GONE);
+ statusImageView.setVisibility(INVISIBLE);
dateTextView.setPadding(0, 0, 0, 0);
MediaController.getInstance().removeLoadingFileObserver(this);
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java
index 32719d2a..7b6085d4 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java
@@ -55,8 +55,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
super(context);
imageView = new BackupImageView(context);
- imageView.imageReceiver.setNeedsQualityThumb(true);
- imageView.imageReceiver.setShouldGenerateQualityThumb(true);
+ imageView.getImageReceiver().setNeedsQualityThumb(true);
+ imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
addView(imageView);
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
@@ -105,7 +105,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
selector.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2);
- checkBox.setVisibility(GONE);
+ checkBox.setVisibility(INVISIBLE);
addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22);
@@ -134,7 +134,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
for (int a = 0; a < 6; a++) {
photoVideoViews[a] = new PhotoVideoView(context);
addView(photoVideoViews[a]);
- photoVideoViews[a].setVisibility(GONE);
+ photoVideoViews[a].setVisibility(INVISIBLE);
photoVideoViews[a].setTag(a);
photoVideoViews[a].setOnClickListener(new OnClickListener() {
@Override
@@ -164,7 +164,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
public void setItemsCount(int count) {
for (int a = 0; a < photoVideoViews.length; a++) {
- photoVideoViews[a].setVisibility(a < count ? VISIBLE : GONE);
+ photoVideoViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE);
}
itemsCount = count;
}
@@ -202,8 +202,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
photoVideoViews[a].setVisibility(VISIBLE);
PhotoVideoView photoVideoView = photoVideoViews[a];
- photoVideoView.imageView.imageReceiver.setParentMessageObject(messageObject);
- photoVideoView.imageView.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(messageObject), false);
+ photoVideoView.imageView.getImageReceiver().setParentMessageObject(messageObject);
+ photoVideoView.imageView.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(messageObject), false);
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo && messageObject.messageOwner.media.video != null) {
photoVideoView.videoInfoContainer.setVisibility(VISIBLE);
int duration = messageObject.messageOwner.media.video.duration;
@@ -217,15 +217,15 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in);
}
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageObject.messageOwner.media.photo != null && !messageObject.photoThumbs.isEmpty()) {
- photoVideoView.videoInfoContainer.setVisibility(GONE);
+ photoVideoView.videoInfoContainer.setVisibility(INVISIBLE);
TLRPC.PhotoSize photoSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80);
photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, photoSize.location, "b", 0);
} else {
- photoVideoView.videoInfoContainer.setVisibility(GONE);
+ photoVideoView.videoInfoContainer.setVisibility(INVISIBLE);
photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in);
}
} else {
- photoVideoViews[a].setVisibility(GONE);
+ photoVideoViews[a].setVisibility(INVISIBLE);
messageObjects[a] = null;
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java
index 59b9c4dd..34e04c69 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/StickerCell.java
@@ -26,9 +26,7 @@ public class StickerCell extends FrameLayoutFixed {
super(context);
imageView = new BackupImageView(context);
- imageView.imageReceiver.setAspectFit(true);
- imageView.imageReceiver.setDisableRecycle(true);
- imageView.processDetach = false;
+ imageView.setAspectFit(true);
addView(imageView);
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(66);
@@ -45,8 +43,8 @@ public class StickerCell extends FrameLayoutFixed {
@Override
public void setPressed(boolean pressed) {
- if (imageView.imageReceiver.getPressed() != pressed) {
- imageView.imageReceiver.setPressed(pressed);
+ if (imageView.getImageReceiver().getPressed() != pressed) {
+ imageView.getImageReceiver().setPressed(pressed);
imageView.invalidate();
}
super.setPressed(pressed);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
index ab395e46..a7fe6573 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
@@ -98,17 +98,17 @@ public class TextCell extends FrameLayout {
public void setText(String text) {
textView.setText(text);
- imageView.setVisibility(GONE);
- valueTextView.setVisibility(GONE);
- valueImageView.setVisibility(GONE);
+ imageView.setVisibility(INVISIBLE);
+ valueTextView.setVisibility(INVISIBLE);
+ valueImageView.setVisibility(INVISIBLE);
}
public void setTextAndIcon(String text, int resId) {
textView.setText(text);
imageView.setImageResource(resId);
imageView.setVisibility(VISIBLE);
- valueTextView.setVisibility(GONE);
- valueImageView.setVisibility(GONE);
+ valueTextView.setVisibility(INVISIBLE);
+ valueImageView.setVisibility(INVISIBLE);
}
public void setTextSize(int size) {
@@ -131,15 +131,15 @@ public class TextCell extends FrameLayout {
textView.setText(text);
valueTextView.setText(value);
valueTextView.setVisibility(VISIBLE);
- imageView.setVisibility(GONE);
- valueImageView.setVisibility(GONE);
+ imageView.setVisibility(INVISIBLE);
+ valueImageView.setVisibility(INVISIBLE);
}
public void setTextAndValueDrawable(String text, Drawable drawable) {
textView.setText(text);
valueImageView.setVisibility(VISIBLE);
valueImageView.setImageDrawable(drawable);
- valueTextView.setVisibility(GONE);
- imageView.setVisibility(GONE);
+ valueTextView.setVisibility(INVISIBLE);
+ imageView.setVisibility(INVISIBLE);
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java
index fce35004..d9921211 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailCell.java
@@ -83,7 +83,7 @@ public class TextDetailCell extends FrameLayout {
public void setTextAndValue(String text, String value) {
textView.setText(text);
valueTextView.setText(value);
- imageView.setVisibility(GONE);
+ imageView.setVisibility(INVISIBLE);
}
public void setTextAndValueAndIcon(String text, String value, int resId) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextFieldCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextFieldCell.java
deleted file mode 100644
index 18ee722f..00000000
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextFieldCell.java
+++ /dev/null
@@ -1,106 +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.ui.Cells;
-
-import android.content.Context;
-import android.graphics.PorterDuff;
-import android.graphics.Typeface;
-import android.text.InputType;
-import android.util.TypedValue;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.inputmethod.EditorInfo;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import org.telegram.android.AndroidUtilities;
-import org.telegram.android.LocaleController;
-
-public class TextFieldCell extends LinearLayout {
-
- private TextView textView;
- private EditText editText;
-
- public TextFieldCell(Context context) {
- super(context);
- setOrientation(VERTICAL);
-
- textView = new TextView(context);
- textView.setTextColor(0xff505050);
- textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
- addView(textView);
- LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(17);
- layoutParams.height = LayoutParams.WRAP_CONTENT;
- layoutParams.leftMargin = AndroidUtilities.dp(17);
- layoutParams.rightMargin = AndroidUtilities.dp(17);
- layoutParams.width = LayoutParams.MATCH_PARENT;
- textView.setLayoutParams(layoutParams);
-
- editText = new EditText(context);
- editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
- editText.setHintTextColor(0xffbebebe);
- editText.setTextColor(0xff212121);
- editText.getBackground().setColorFilter(AndroidUtilities.defColor, PorterDuff.Mode.SRC_IN);
- editText.setMaxLines(1);
- editText.setLines(1);
- editText.setSingleLine(true);
- editText.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
- AndroidUtilities.clearCursorDrawable(editText);
- addView(editText);
- layoutParams = (LayoutParams) editText.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(10);
- layoutParams.bottomMargin = AndroidUtilities.dp(17);
- layoutParams.height = AndroidUtilities.dp(30);
- layoutParams.leftMargin = AndroidUtilities.dp(17);
- layoutParams.rightMargin = AndroidUtilities.dp(17);
- layoutParams.width = LayoutParams.MATCH_PARENT;
- editText.setLayoutParams(layoutParams);
- editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
- if (i == EditorInfo.IME_ACTION_DONE) {
- textView.clearFocus();
- AndroidUtilities.hideKeyboard(textView);
- return true;
- }
- return false;
- }
- });
- }
-
- public void setFieldText(String text) {
- editText.setText(text);
- }
-
- public String getFieldText() {
- return editText.getText().toString();
- }
-
- public void setFieldTitleAndHint(String title, String hint, int bottom, boolean password) {
- editText.setHint(hint);
- LayoutParams layoutParams = (LayoutParams) editText.getLayoutParams();
- layoutParams.bottomMargin = bottom;
- editText.setLayoutParams(layoutParams);
- if (password) {
- editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
- editText.setTypeface(Typeface.DEFAULT);
- } else {
- editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
- }
- if (title != null) {
- textView.setText(title);
- textView.setVisibility(VISIBLE);
- } else {
- textView.setVisibility(GONE);
- }
- }
-}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java
index 07659668..ba7bd11a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoCell.java
@@ -15,7 +15,6 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.android.LocaleController;
import org.telegram.ui.LaunchActivity;
public class TextInfoCell extends FrameLayout {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java
index b16c84c7..6c8bcffa 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextInfoPrivacyCell.java
@@ -25,10 +25,10 @@ public class TextInfoPrivacyCell extends FrameLayout {
super(context);
textView = new TextView(context);
- textView.setTextColor(0xffa3a3a3);
- textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
+ textView.setTextColor(0xff808080);
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- textView.setPadding(0, AndroidUtilities.dp(6), 0, AndroidUtilities.dp(16));
+ textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(17));
addView(textView);
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
index 2b577fe6..a6ccb507 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
@@ -75,7 +75,7 @@ public class TextSettingsCell extends FrameLayout {
valueImageView = new ImageView(context);
valueImageView.setScaleType(ImageView.ScaleType.CENTER);
- valueImageView.setVisibility(GONE);
+ valueImageView.setVisibility(INVISIBLE);
addView(valueImageView);
layoutParams = (LayoutParams) valueImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
@@ -110,20 +110,20 @@ public class TextSettingsCell extends FrameLayout {
public void setText(String text, boolean divider) {
textView.setText(text);
- valueTextView.setVisibility(GONE);
- valueImageView.setVisibility(GONE);
+ valueTextView.setVisibility(INVISIBLE);
+ valueImageView.setVisibility(INVISIBLE);
needDivider = divider;
setWillNotDraw(!divider);
}
public void setTextAndValue(String text, String value, boolean divider) {
textView.setText(text);
- valueImageView.setVisibility(GONE);
+ valueImageView.setVisibility(INVISIBLE);
if (value != null) {
valueTextView.setText(value);
valueTextView.setVisibility(VISIBLE);
} else {
- valueTextView.setVisibility(GONE);
+ valueTextView.setVisibility(INVISIBLE);
}
needDivider = divider;
setWillNotDraw(!divider);
@@ -131,12 +131,12 @@ public class TextSettingsCell extends FrameLayout {
public void setTextAndIcon(String text, int resId, boolean divider) {
textView.setText(text);
- valueTextView.setVisibility(GONE);
+ valueTextView.setVisibility(INVISIBLE);
if (resId != 0) {
valueImageView.setVisibility(VISIBLE);
valueImageView.setImageResource(resId);
} else {
- valueImageView.setVisibility(GONE);
+ valueImageView.setVisibility(INVISIBLE);
}
needDivider = divider;
setWillNotDraw(!divider);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java
index 6d9c4a2a..15fae3f8 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UserCell.java
@@ -9,6 +9,7 @@
package org.telegram.ui.Cells;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.TypedValue;
@@ -21,6 +22,7 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
@@ -61,7 +63,7 @@ public class UserCell extends FrameLayout {
super(context);
avatarImageView = new BackupImageView(context);
- avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(24));
+ avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
addView(avatarImageView);
LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(48);
@@ -120,7 +122,7 @@ public class UserCell extends FrameLayout {
imageView.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2);
- checkBox.setVisibility(GONE);
+ checkBox.setVisibility(INVISIBLE);
addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22);
@@ -207,7 +209,7 @@ public class UserCell extends FrameLayout {
return;
}
}
-
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
avatarDrawable.setInfo(currentUser);
if (currentUser.status != null) {
lastStatus = currentUser.status.expires;
@@ -222,7 +224,7 @@ public class UserCell extends FrameLayout {
} else {
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setTextColor(nameColor);
- nameTextView.setTextSize(AndroidUtilities.getIntDef("contactsNameSize", 17));
+ nameTextView.setTextSize(themePrefs.getInt("contactsNameSize", 17));
}
if (currrntStatus != null) {
statusTextView.setText(currrntStatus);
@@ -236,13 +238,13 @@ public class UserCell extends FrameLayout {
statusTextView.setTextColor(statusColor);
}
}
- statusTextView.setTextSize(AndroidUtilities.getIntDef("contactsStatusSize", 14));
- imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE);
+ statusTextView.setTextSize(themePrefs.getInt("contactsStatusSize", 14));
+ imageView.setVisibility(currentDrawable == 0 ? INVISIBLE : VISIBLE);
imageView.setImageResource(currentDrawable);
if(curDrawable != null)imageView.setImageDrawable(curDrawable);
- //int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("contactsAvatarRadius", 32));
- avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(radius));
+ //int radius = AndroidUtilities.dp(themePrefs.getInt("contactsAvatarRadius", 32));
+ avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(radius));
avatarDrawable.setRadius(AndroidUtilities.dp(radius));
avatarImageView.setImage(photo, "50_50", avatarDrawable);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java
index b19aeaf7..f8d9adc3 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeChatNameActivity.java
@@ -9,6 +9,7 @@
package org.telegram.ui;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.os.Bundle;
@@ -27,10 +28,10 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
+import org.telegram.messenger.ApplicationLoader;
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.BaseFragment;
@@ -56,9 +57,7 @@ public class ChangeChatNameActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
-
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
@@ -81,7 +80,7 @@ public class ChangeChatNameActivity extends BaseFragment {
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
- fragmentView = new LinearLayout(getParentActivity());
+ fragmentView = new LinearLayout(context);
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@@ -91,7 +90,7 @@ public class ChangeChatNameActivity extends BaseFragment {
}
});
- firstNameField = new EditText(getParentActivity());
+ firstNameField = new EditText(context);
firstNameField.setText(currentChat.title);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
@@ -116,7 +115,7 @@ public class ChangeChatNameActivity extends BaseFragment {
});
((LinearLayout) fragmentView).addView(firstNameField);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
@@ -130,12 +129,7 @@ public class ChangeChatNameActivity extends BaseFragment {
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
}
firstNameField.setSelection(firstNameField.length());
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java
index 4d4a8b87..6a71bdd0 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeNameActivity.java
@@ -9,6 +9,7 @@
package org.telegram.ui;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.text.InputType;
@@ -26,14 +27,14 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
-import org.telegram.messenger.ApplicationLoader;
-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.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.UserConfig;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
@@ -49,8 +50,7 @@ public class ChangeNameActivity extends BaseFragment {
private final static int done_button = 1;
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
@@ -76,7 +76,7 @@ public class ChangeNameActivity extends BaseFragment {
user = UserConfig.getCurrentUser();
}
- fragmentView = new LinearLayout(getParentActivity());
+ fragmentView = new LinearLayout(context);
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@@ -86,7 +86,7 @@ public class ChangeNameActivity extends BaseFragment {
}
});
- firstNameField = new EditText(getParentActivity());
+ firstNameField = new EditText(context);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
@@ -100,7 +100,7 @@ public class ChangeNameActivity extends BaseFragment {
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
AndroidUtilities.clearCursorDrawable(firstNameField);
((LinearLayout) fragmentView).addView(firstNameField);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
@@ -119,7 +119,7 @@ public class ChangeNameActivity extends BaseFragment {
}
});
- lastNameField = new EditText(getParentActivity());
+ lastNameField = new EditText(context);
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff212121);
@@ -133,7 +133,7 @@ public class ChangeNameActivity extends BaseFragment {
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
AndroidUtilities.clearCursorDrawable(lastNameField);
((LinearLayout) fragmentView).addView(lastNameField);
- layoutParams = (LinearLayout.LayoutParams)lastNameField.getLayoutParams();
+ layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(16);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
@@ -156,12 +156,7 @@ public class ChangeNameActivity extends BaseFragment {
firstNameField.setSelection(firstNameField.length());
lastNameField.setText(user.last_name);
}
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
index 9ce3ae77..69b0622b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneActivity.java
@@ -26,7 +26,6 @@ import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
@@ -102,8 +101,7 @@ public class ChangePhoneActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@@ -120,11 +118,11 @@ public class ChangePhoneActivity extends BaseFragment {
ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- fragmentView = new ScrollView(getParentActivity());
+ fragmentView = new ScrollView(context);
ScrollView scrollView = (ScrollView) fragmentView;
scrollView.setFillViewport(true);
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
+ FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout);
ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT;
@@ -132,7 +130,7 @@ public class ChangePhoneActivity extends BaseFragment {
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
frameLayout.setLayoutParams(layoutParams);
- views[0] = new PhoneView(getParentActivity());
+ views[0] = new PhoneView(context);
views[0].setVisibility(View.VISIBLE);
frameLayout.addView(views[0]);
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams();
@@ -144,7 +142,7 @@ public class ChangePhoneActivity extends BaseFragment {
layoutParams1.gravity = Gravity.TOP | Gravity.LEFT;
views[0].setLayoutParams(layoutParams1);
- views[1] = new LoginActivitySmsView(getParentActivity());
+ views[1] = new LoginActivitySmsView(context);
views[1].setVisibility(View.GONE);
frameLayout.addView(views[1]);
layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams();
@@ -158,10 +156,10 @@ public class ChangePhoneActivity extends BaseFragment {
try {
if (views[0] == null || views[1] == null) {
- FrameLayout parent = (FrameLayout)((ScrollView) fragmentView).getChildAt(0);
+ FrameLayout parent = (FrameLayout) ((ScrollView) fragmentView).getChildAt(0);
for (int a = 0; a < views.length; a++) {
if (views[a] == null) {
- views[a] = (SlideView)parent.getChildAt(a);
+ views[a] = (SlideView) parent.getChildAt(a);
}
}
}
@@ -170,12 +168,7 @@ public class ChangePhoneActivity extends BaseFragment {
}
actionBar.setTitle(views[0].getHeaderName());
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java
index 34b5d446..03d088be 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangePhoneHelpActivity.java
@@ -9,13 +9,13 @@
package org.telegram.ui;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -35,8 +35,7 @@ import org.telegram.ui.ActionBar.BaseFragment;
public class ChangePhoneHelpActivity extends BaseFragment {
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
@@ -58,7 +57,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
}
});
- fragmentView = new RelativeLayout(getParentActivity());
+ fragmentView = new RelativeLayout(context);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@@ -68,7 +67,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
RelativeLayout relativeLayout = (RelativeLayout) fragmentView;
- ScrollView scrollView = new ScrollView(getParentActivity());
+ ScrollView scrollView = new ScrollView(context);
relativeLayout.addView(scrollView);
RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams();
layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT;
@@ -76,7 +75,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
scrollView.setLayoutParams(layoutParams3);
- LinearLayout linearLayout = new LinearLayout(getParentActivity());
+ LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20));
scrollView.addView(linearLayout);
@@ -85,28 +84,28 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT;
linearLayout.setLayoutParams(layoutParams);
- ImageView imageView = new ImageView(getParentActivity());
+ ImageView imageView = new ImageView(context);
imageView.setImageResource(R.drawable.phone_change);
linearLayout.addView(imageView);
- LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams)imageView.getLayoutParams();
+ LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
imageView.setLayoutParams(layoutParams2);
- TextView textView = new TextView(getParentActivity());
+ TextView textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTextColor(0xff212121);
try {
- textView.setText(AndroidUtilities.replaceBold(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
+ textView.setText(AndroidUtilities.replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
} catch (Exception e) {
FileLog.e("tmessages", e);
textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp));
}
linearLayout.addView(textView);
- layoutParams2 = (LinearLayout.LayoutParams)textView.getLayoutParams();
+ layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
@@ -115,7 +114,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams2.topMargin = AndroidUtilities.dp(56);
textView.setLayoutParams(layoutParams2);
- textView = new TextView(getParentActivity());
+ textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
//textView.setTextColor(0xff4d83b3);
@@ -124,7 +123,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10));
linearLayout.addView(textView);
- layoutParams2 = (LinearLayout.LayoutParams)textView.getLayoutParams();
+ layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
@@ -153,12 +152,6 @@ public class ChangePhoneHelpActivity extends BaseFragment {
}
});
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
return fragmentView;
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java
index 40c0c06b..c9eb58de 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChangeUsernameActivity.java
@@ -11,11 +11,11 @@ package org.telegram.ui;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.text.Editable;
-import android.text.Html;
import android.text.InputType;
import android.text.TextWatcher;
import android.util.TypedValue;
@@ -62,8 +62,7 @@ public class ChangeUsernameActivity extends BaseFragment {
private final static int done_button = 1;
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
@@ -86,7 +85,7 @@ public class ChangeUsernameActivity extends BaseFragment {
user = UserConfig.getCurrentUser();
}
- fragmentView = new LinearLayout(getParentActivity());
+ fragmentView = new LinearLayout(context);
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() {
@@ -96,7 +95,7 @@ public class ChangeUsernameActivity extends BaseFragment {
}
});
- firstNameField = new EditText(getParentActivity());
+ firstNameField = new EditText(context);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121);
@@ -122,7 +121,7 @@ public class ChangeUsernameActivity extends BaseFragment {
});
((LinearLayout) fragmentView).addView(firstNameField);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)firstNameField.getLayoutParams();
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24);
@@ -135,11 +134,11 @@ public class ChangeUsernameActivity extends BaseFragment {
firstNameField.setSelection(firstNameField.length());
}
- checkTextView = new TextView(getParentActivity());
+ checkTextView = new TextView(context);
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
((LinearLayout) fragmentView).addView(checkTextView);
- layoutParams = (LinearLayout.LayoutParams)checkTextView.getLayoutParams();
+ layoutParams = (LinearLayout.LayoutParams) checkTextView.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(12);
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
@@ -148,13 +147,13 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.rightMargin = AndroidUtilities.dp(24);
checkTextView.setLayoutParams(layoutParams);
- TextView helpTextView = new TextView(getParentActivity());
+ TextView helpTextView = new TextView(context);
helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
helpTextView.setTextColor(0xff6d6d72);
helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- helpTextView.setText(Html.fromHtml(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
+ helpTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("UsernameHelp", R.string.UsernameHelp)));
((LinearLayout) fragmentView).addView(helpTextView);
- layoutParams = (LinearLayout.LayoutParams)helpTextView.getLayoutParams();
+ layoutParams = (LinearLayout.LayoutParams) helpTextView.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(10);
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
@@ -181,12 +180,7 @@ public class ChangeUsernameActivity extends BaseFragment {
});
checkTextView.setVisibility(View.GONE);
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
index 8df67a4f..2ebdc1e3 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
@@ -28,7 +28,6 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.widget.LinearLayoutManager;
-import android.text.Html;
import android.text.TextUtils;
import android.util.Base64;
import android.util.SparseArray;
@@ -77,13 +76,6 @@ import org.telegram.messenger.SerializedData;
import org.telegram.messenger.TLClassStore;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
-import org.telegram.android.ContactsController;
-import org.telegram.messenger.FileLog;
-import org.telegram.android.MessageObject;
-import org.telegram.messenger.ConnectionsManager;
-import org.telegram.android.MessagesController;
-import org.telegram.android.NotificationCenter;
-import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
@@ -103,14 +95,9 @@ import org.telegram.ui.Cells.ChatBaseCell;
import org.telegram.ui.Cells.ChatContactCell;
import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Cells.ChatMessageCell;
-import org.telegram.ui.ActionBar.ActionBar;
-import org.telegram.ui.ActionBar.ActionBarMenu;
-import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
-import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.ChatActivityEnterView;
-import org.telegram.android.ImageReceiver;
import org.telegram.ui.Components.FrameLayoutFixed;
import org.telegram.ui.Components.LayoutListView;
import org.telegram.ui.Components.RecyclerListView;
@@ -180,6 +167,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private MessageObject replyingMessageObject;
private boolean paused = true;
private boolean readWhenResume = false;
+ private TLRPC.FileLocation replyImageLocation;
+ private long linkSearchRequestId;
+ private TLRPC.WebPage foundWebPage;
+ private String pendingLinkSearchString;
+ private Runnable pendingWebPageTimeoutRunnable;
+ private Runnable waitingForCharaterEnterRunnable;
private boolean openAnimationEnded = false;
@@ -256,6 +249,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final static int reply = 15;
private final static int attach_music = 16;
private final static int id_chat_compose_panel = 1000;
+ private final static int attach_sticker = 17;
private static boolean QuoteForward;
@@ -404,7 +398,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false;
}
}
- dialog_id = ((long)encId) << 32;
+ dialog_id = ((long) encId) << 32;
maxMessageId = Integer.MIN_VALUE;
minMessageId = Integer.MAX_VALUE;
MediaController.getInstance().startMediaObserver();
@@ -438,6 +432,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().addObserver(this, NotificationCenter.replaceMessagesObjects);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didLoadedReplyMessages);
+ NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedWebpages);
+ NotificationCenter.getInstance().addObserver(this, NotificationCenter.didReceivedWebpagesInUpdates);
super.onFragmentCreate();
@@ -474,12 +470,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (chatActivityEnterView != null) {
chatActivityEnterView.onDestroy();
}
- if (avatarImageView != null) {
- avatarImageView.setImageDrawable(null);
- }
- if (replyImageView != null) {
- replyImageView.setImageDrawable(null);
- }
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.emojiDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
@@ -506,6 +496,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.replaceMessagesObjects);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didLoadedReplyMessages);
+ NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedWebpages);
+ NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didReceivedWebpagesInUpdates);
+
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
}
@@ -526,13 +519,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
+
lastPrintString = null;
lastStatus = null;
+ hasOwnBackground = true;
//actionBar.setBackButtonImage(R.drawable.ic_ab_back);
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
- back.setColorFilter(AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ back.setColorFilter(themePrefs.getInt("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
actionBar.setBackButtonDrawable(back);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
@@ -590,7 +585,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void didSelectPhotos(ArrayList photos, ArrayList webPhotos) {
SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject);
SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
@Override
@@ -635,7 +630,30 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} catch (Exception e) {
FileLog.e("tmessages", e);
}
- } else if (id == attach_location) {
+ } else if (id == attach_sticker) {
+ PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false);
+ fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
+ @Override
+ public void didSelectPhotos(ArrayList photos, ArrayList webPhotos) {
+ SendMessagesHelper.prepareSendingPhotos(photos, null, dialog_id, replyingMessageObject);
+ SendMessagesHelper.prepareSendingPhotosSearch(webPhotos, dialog_id, replyingMessageObject);
+ showReplyPanel(false, null, null, null, false, true);
+ }
+
+ @Override
+ public void startPhotoSelectActivity() {
+ try {
+ Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
+ photoPickerIntent.setType("image/webp");
+ startActivityForResult(photoPickerIntent, 4);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ }
+ });
+ presentFragment(fragment);
+ }//
+ else if (id == attach_location) {
if (!isGoogleMapsInstalled()) {
return;
}
@@ -645,7 +663,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void didSelectLocation(double latitude, double longitude) {
SendMessagesHelper.getInstance().sendMessage(latitude, longitude, dialog_id, replyingMessageObject);
moveScrollToLastMessage();
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
if (paused) {
scrollToTopOnResume = true;
}
@@ -659,7 +677,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void didSelectFiles(DocumentSelectActivity activity, ArrayList files) {
activity.finishFragment();
SendMessagesHelper.prepareSendingDocuments(files, files, null, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
@Override
@@ -755,7 +773,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (getParentActivity() == null) {
return;
}
- final boolean isChat = (int)dialog_id < 0 && (int)(dialog_id >> 32) != 1;
+ final boolean isChat = (int) dialog_id < 0 && (int) (dialog_id >> 32) != 1;
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
if (id == clear_history) {
@@ -770,12 +788,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
- MessagesController.getInstance().deleteDialog(dialog_id, 0, id == clear_history);
if (id != clear_history) {
if (isChat) {
MessagesController.getInstance().deleteUserFromChat((int) -dialog_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
- }
- finishFragment();
+ } else {
+ MessagesController.getInstance().deleteDialog(dialog_id, 0, false);
+ }
+ finishFragment();
+ } else {
+ MessagesController.getInstance().deleteDialog(dialog_id, 0, true);
}
}
});
@@ -799,7 +820,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onClick(DialogInterface dialogInterface, int i) {
SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id, replyingMessageObject);
moveScrollToLastMessage();
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
@@ -839,7 +860,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
editor.putInt("notify2_" + dialog_id, 3);
editor.putInt("notifyuntil_" + dialog_id, untilTime);
- flags = ((long)untilTime << 32) | 1;
+ flags = ((long) untilTime << 32) | 1;
}
MessagesStorage.getInstance().setDialogFlags(dialog_id, flags);
editor.commit();
@@ -871,7 +892,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ArrayList ids = new ArrayList<>(selectedMessagesIds.keySet());
MessageObject messageObject = messagesDict.get(ids.get(0));
if (messageObject != null && messageObject.messageOwner.id > 0) {
- showReplyForMessageObjectOrForward(true, messageObject, null, true);
+ showReplyPanel(true, messageObject, null, null, false, true);
}
}
selectedMessagesIds.clear();
@@ -882,7 +903,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
- avatarContainer = new FrameLayoutFixed(getParentActivity());
+ avatarContainer = new FrameLayoutFixed(context);
avatarContainer.setBackgroundResource(R.drawable.bar_selector);
avatarContainer.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), 0);
actionBar.addView(avatarContainer);
@@ -923,9 +944,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
- avatarImageView = new BackupImageView(getParentActivity());
- avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(21));
- avatarImageView.processDetach = false;
+ avatarImageView = new BackupImageView(context);
+ avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
avatarContainer.addView(avatarImageView);
layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
layoutParams2.width = AndroidUtilities.dp(42);
@@ -935,11 +955,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
avatarImageView.setLayoutParams(layoutParams2);
if (currentEncryptedChat != null) {
- timeItem = new ImageView(getParentActivity());
+ timeItem = new ImageView(context);
timeItem.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(5), AndroidUtilities.dp(5));
timeItem.setScaleType(ImageView.ScaleType.CENTER);
avatarContainer.addView(timeItem);
- timerDrawable = new TimerDrawable(getParentActivity());
+ timerDrawable = new TimerDrawable(context);
layoutParams2 = (FrameLayout.LayoutParams) timeItem.getLayoutParams();
layoutParams2.width = AndroidUtilities.dp(34);
@@ -961,7 +981,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
}
- nameTextView = new TextView(getParentActivity());
+ nameTextView = new TextView(context);
nameTextView.setTextColor(0xffffffff);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
nameTextView.setLines(1);
@@ -980,7 +1000,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.BOTTOM;
nameTextView.setLayoutParams(layoutParams2);
- onlineTextView = new TextView(getParentActivity());
+ onlineTextView = new TextView(context);
onlineTextView.setTextColor(0xffd7e8f7);
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1);
@@ -1028,6 +1048,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
attachItem = menu.addItem(chat_menu_attach, dots);
attachItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
attachItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
+ //attachItem.addSubItem(attach_sticker, "Sticker", R.drawable.ic_msg_panel_smiles);
attachItem.addSubItem(attach_music, LocaleController.getString("ChatMusic", R.string.ChatMusic), R.drawable.ic_attach_music);
attachItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video);
attachItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc);
@@ -1035,11 +1056,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
attachItem.setVisibility(View.INVISIBLE);
Drawable clip = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_attach_white);
- clip.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
+ clip.setColorFilter(themePrefs.getInt("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
menuItem = menu.addItem(chat_menu_attach, clip);
//menuItem = menu.addItem(chat_menu_attach, R.drawable.ic_ab_attach);
menuItem.addSubItem(attach_photo, LocaleController.getString("ChatTakePhoto", R.string.ChatTakePhoto), R.drawable.ic_attach_photo);
menuItem.addSubItem(attach_gallery, LocaleController.getString("ChatGallery", R.string.ChatGallery), R.drawable.ic_attach_gallery);
+ //menuItem.addSubItem(attach_sticker, "Sticker", R.drawable.ic_msg_panel_smiles);
menuItem.addSubItem(attach_music, LocaleController.getString("ChatMusic", R.string.ChatMusic), R.drawable.ic_attach_music);
menuItem.addSubItem(attach_video, LocaleController.getString("ChatVideo", R.string.ChatVideo), R.drawable.ic_attach_video);
menuItem.addSubItem(attach_document, LocaleController.getString("ChatDocument", R.string.ChatDocument), R.drawable.ic_ab_doc);
@@ -1068,7 +1090,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
actionMode.addView(selectedMessagesCountTextView);
- layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
+ layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1;
layoutParams.width = 0;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
@@ -1092,12 +1114,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
checkActionBarMenu();
- fragmentView = new SizeNotifierRelativeLayout(getParentActivity());
+ fragmentView = new SizeNotifierRelativeLayout(context);
SizeNotifierRelativeLayout contentView = (SizeNotifierRelativeLayout) fragmentView;
contentView.setBackgroundImage(ApplicationLoader.getCachedWallpaper());
- emptyViewContainer = new FrameLayout(getParentActivity());
+ emptyViewContainer = new FrameLayout(context);
emptyViewContainer.setPadding(0, 0, 0, AndroidUtilities.dp(48));
emptyViewContainer.setVisibility(View.INVISIBLE);
contentView.addView(emptyViewContainer);
@@ -1113,7 +1135,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
if (currentEncryptedChat == null) {
- TextView emptyView = new TextView(getParentActivity());
+ TextView emptyView = new TextView(context);
if (currentUser != null && currentUser.id != 777000 && (currentUser.id / 1000 == 333 || currentUser.id % 1000 == 0)) {
emptyView.setText(LocaleController.getString("GotAQuestion", R.string.GotAQuestion));
} else {
@@ -1131,7 +1153,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.CENTER;
emptyView.setLayoutParams(layoutParams2);
} else {
- LinearLayout secretChatPlaceholder = new LinearLayout(getParentActivity());
+ LinearLayout secretChatPlaceholder = new LinearLayout(context);
secretChatPlaceholder.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_black : R.drawable.system_blue);
secretChatPlaceholder.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(12), AndroidUtilities.dp(16), AndroidUtilities.dp(12));
secretChatPlaceholder.setOrientation(LinearLayout.VERTICAL);
@@ -1142,7 +1164,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.CENTER;
secretChatPlaceholder.setLayoutParams(layoutParams2);
- secretViewStatusTextView = new TextView(getParentActivity());
+ secretViewStatusTextView = new TextView(context);
secretViewStatusTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
secretViewStatusTextView.setTextColor(0xffffffff);
secretViewStatusTextView.setGravity(Gravity.CENTER_HORIZONTAL);
@@ -1167,7 +1189,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
secretViewStatusTextView.setLayoutParams(layoutParams);
- TextView textView = new TextView(getParentActivity());
+ TextView textView = new TextView(context);
textView.setText(LocaleController.getString("EncryptedDescriptionTitle", R.string.EncryptedDescriptionTitle));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTextColor(0xffffffff);
@@ -1182,7 +1204,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
textView.setLayoutParams(layoutParams);
for (int a = 0; a < 4; a++) {
- LinearLayout linearLayout = new LinearLayout(getParentActivity());
+ LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
secretChatPlaceholder.addView(linearLayout);
layoutParams = (LinearLayout.LayoutParams) linearLayout.getLayoutParams();
@@ -1192,10 +1214,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams.gravity = LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT;
linearLayout.setLayoutParams(layoutParams);
- ImageView imageView = new ImageView(getParentActivity());
+ ImageView imageView = new ImageView(context);
imageView.setImageResource(R.drawable.ic_lock_white);
- textView = new TextView(getParentActivity());
+ textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTextColor(0xffffffff);
textView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
@@ -1238,8 +1260,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
- chatListView = new LayoutListView(getParentActivity());
- chatListView.setAdapter(chatAdapter = new ChatAdapter(getParentActivity()));
+ chatListView = new LayoutListView(context);
+ chatListView.setAdapter(chatAdapter = new ChatAdapter(context));
chatListView.setCacheColorHint(ApplicationLoader.getSelectedColor());
chatListView.setClipToPadding(false);
chatListView.setStackFromBottom(true);
@@ -1262,8 +1284,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return false;
}
if (event.getAction() == MotionEvent.ACTION_DOWN) {
- int x = (int)event.getX();
- int y = (int)event.getY();
+ int x = (int) event.getX();
+ int y = (int) event.getY();
int count = chatListView.getChildCount();
Rect rect = new Rect();
for (int a = 0; a < count; a++) {
@@ -1277,7 +1299,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!(view instanceof ChatMediaCell)) {
break;
}
- final ChatMediaCell cell = (ChatMediaCell)view;
+ final ChatMediaCell cell = (ChatMediaCell) view;
final MessageObject messageObject = cell.getMessageObject();
if (messageObject == null || !messageObject.isSecretPhoto() || !cell.getPhotoImage().isInsideImage(x, y - top)) {
break;
@@ -1400,7 +1422,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (int a = 0; a < visibleItemCount; a++) {
View view = absListView.getChildAt(a);
if (view instanceof ChatMessageCell) {
- ChatMessageCell messageCell = (ChatMessageCell)view;
+ ChatMessageCell messageCell = (ChatMessageCell) view;
messageCell.getLocalVisibleRect(scrollRect);
messageCell.setVisiblePart(scrollRect.top, scrollRect.bottom - scrollRect.top);
}
@@ -1408,7 +1430,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
- progressView = new FrameLayout(getParentActivity());
+ progressView = new FrameLayout(context);
progressView.setVisibility(View.INVISIBLE);
progressView.setBackgroundResource(ApplicationLoader.isCustomTheme() ? R.drawable.system_loader2 : R.drawable.system_loader1);
contentView.addView(progressView);
@@ -1419,9 +1441,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams3.addRule(RelativeLayout.CENTER_IN_PARENT);
progressView.setLayoutParams(layoutParams3);
- ProgressBar progressBar = new ProgressBar(getParentActivity());
+ ProgressBar progressBar = new ProgressBar(context);
try {
- progressBar.setIndeterminateDrawable(getParentActivity().getResources().getDrawable(R.drawable.loading_animation));
+ progressBar.setIndeterminateDrawable(context.getResources().getDrawable(R.drawable.loading_animation));
} catch (Exception e) {
//don't promt
}
@@ -1435,7 +1457,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
progressBar.setLayoutParams(layoutParams2);
if (currentEncryptedChat == null && !isBroadcast) {
- mentionListView = new ListView(getParentActivity());
+ mentionListView = new ListView(context);
mentionListView.setBackgroundResource(R.drawable.compose_panel);
mentionListView.setVisibility(View.GONE);
mentionListView.setPadding(0, AndroidUtilities.dp(2), 0, 0);
@@ -1453,7 +1475,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams3.addRule(RelativeLayout.ALIGN_TOP, id_chat_compose_panel);
mentionListView.setLayoutParams(layoutParams3);
- mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(getParentActivity(), new MentionsAdapter.MentionsAdapterDelegate() {
+ mentionListView.setAdapter(mentionsAdapter = new MentionsAdapter(context, new MentionsAdapter.MentionsAdapterDelegate() {
@Override
public void needChangePanelVisibility(boolean show) {
if (show) {
@@ -1587,7 +1609,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onMessageSend(String message) {
moveScrollToLastMessage();
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
if (mentionsAdapter != null) {
mentionsAdapter.addHashtagsFromMessage(message);
}
@@ -1597,13 +1619,31 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
- public void onTextChanged(CharSequence text) {
+ public void onTextChanged(final CharSequence text, boolean bigChange) {
if (stickersAdapter != null) {
stickersAdapter.loadStikersForEmoji(text);
}
if (mentionsAdapter != null) {
mentionsAdapter.searchUsernameOrHashtag(text.toString(), chatActivityEnterView.getCursorPosition(), messages);
}
+ if (waitingForCharaterEnterRunnable != null) {
+ AndroidUtilities.cancelRunOnUIThread(waitingForCharaterEnterRunnable);
+ waitingForCharaterEnterRunnable = null;
+ }
+ if (bigChange) {
+ searchLinks(text, true);
+ } else {
+ waitingForCharaterEnterRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if (this == waitingForCharaterEnterRunnable) {
+ searchLinks(text, false);
+ waitingForCharaterEnterRunnable = null;
+ }
+ }
+ };
+ AndroidUtilities.runOnUIThread(waitingForCharaterEnterRunnable, 1000);
+ }
}
@Override
@@ -1657,11 +1697,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
- FrameLayout replyLayout = new FrameLayout(getParentActivity());
+ FrameLayout replyLayout = new FrameLayout(context);
replyLayout.setClickable(true);
chatActivityEnterView.addTopView(replyLayout, AndroidUtilities.dp(48));
- View lineView = new View(getParentActivity());
+ View lineView = new View(context);
lineView.setBackgroundColor(0xffe8e8e8);
replyLayout.addView(lineView);
layoutParams2 = (FrameLayout.LayoutParams) lineView.getLayoutParams();
@@ -1670,7 +1710,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.height = AndroidUtilities.dp(1);
lineView.setLayoutParams(layoutParams2);
- replyIconImageView = new ImageView(getParentActivity());
+ replyIconImageView = new ImageView(context);
replyIconImageView.setScaleType(ImageView.ScaleType.CENTER);
replyLayout.addView(replyIconImageView);
layoutParams2 = (FrameLayout.LayoutParams) replyIconImageView.getLayoutParams();
@@ -1679,7 +1719,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.height = AndroidUtilities.dp(46);
replyIconImageView.setLayoutParams(layoutParams2);
- ImageView imageView = new ImageView(getParentActivity());
+ ImageView imageView = new ImageView(context);
imageView.setImageResource(R.drawable.delete_reply);
imageView.setScaleType(ImageView.ScaleType.CENTER);
replyLayout.addView(imageView);
@@ -1695,11 +1735,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (forwardingMessages != null) {
forwardingMessages.clear();
}
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, foundWebPage, true, true);
}
});
- replyNameTextView = new TextView(getParentActivity());
+ replyNameTextView = new TextView(context);
replyNameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
replyNameTextView.setTextColor(0xff377aae);
replyNameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
@@ -1716,7 +1756,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
replyNameTextView.setLayoutParams(layoutParams2);
- replyObjectTextView = new TextView(getParentActivity());
+ replyObjectTextView = new TextView(context);
replyObjectTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
replyObjectTextView.setTextColor(0xff999999);
replyObjectTextView.setSingleLine(true);
@@ -1732,8 +1772,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
replyObjectTextView.setLayoutParams(layoutParams2);
- replyImageView = new BackupImageView(getParentActivity());
- replyImageView.processDetach = false;
+ replyImageView = new BackupImageView(context);
replyLayout.addView(replyImageView);
layoutParams2 = (FrameLayout.LayoutParams) replyImageView.getLayoutParams();
layoutParams2.leftMargin = AndroidUtilities.dp(52);
@@ -1743,7 +1782,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
replyImageView.setLayoutParams(layoutParams2);
- stickersPanel = new FrameLayout(getParentActivity());
+ stickersPanel = new FrameLayout(context);
stickersPanel.setVisibility(View.GONE);
contentView.addView(stickersPanel);
layoutParams3 = (RelativeLayout.LayoutParams) stickersPanel.getLayoutParams();
@@ -1754,8 +1793,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams3.addRule(RelativeLayout.ALIGN_BOTTOM, id_chat_compose_panel);
stickersPanel.setLayoutParams(layoutParams3);
- stickersListView = new RecyclerListView(getParentActivity());
- LinearLayoutManager layoutManager = new LinearLayoutManager(getParentActivity());
+ stickersListView = new RecyclerListView(context);
+ LinearLayoutManager layoutManager = new LinearLayoutManager(context);
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
stickersListView.setLayoutManager(layoutManager);
stickersListView.setClipToPadding(false);
@@ -1773,7 +1812,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
stickersAdapter.destroy();
}
stickersListView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
- stickersListView.setAdapter(stickersAdapter = new StickersAdapter(getParentActivity(), new StickersAdapter.StickersAdapterDelegate() {
+ stickersListView.setAdapter(stickersAdapter = new StickersAdapter(context, new StickersAdapter.StickersAdapterDelegate() {
@Override
public void needChangePanelVisibility(final boolean show) {
if (show && stickersPanel.getVisibility() == View.VISIBLE || !show && stickersPanel.getVisibility() == View.GONE) {
@@ -1813,7 +1852,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}));
- stickersListView.addOnItemTouchListener(new RecyclerListView.RecyclerListViewItemClickListener(getParentActivity(), new RecyclerListView.OnItemClickListener() {
+ stickersListView.addOnItemTouchListener(new RecyclerListView.RecyclerListViewItemClickListener(context, new RecyclerListView.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
TLRPC.Document document = stickersAdapter.getItem(position);
@@ -1822,8 +1861,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
File file = FileLoader.getPathToAttach(document.thumb, true);
if (file.exists()) {
try {
- int len = (int)file.length();
- byte[] arr = new byte[(int)file.length()];
+ int len = (int) file.length();
+ byte[] arr = new byte[(int) file.length()];
RandomAccessFile reader = new RandomAccessFile(file, "r");
reader.readFully(arr);
TLRPC.TL_document newDocument = new TLRPC.TL_document();
@@ -1848,15 +1887,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
+ for (int a = 0; a < document.attributes.size(); a++) {
+ TLRPC.DocumentAttribute attribute = document.attributes.get(a);
+ if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
+ document.attributes.remove(a);
+ document.attributes.add(new TLRPC.TL_documentAttributeSticker_old());
+ break;
+ }
+ }
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
chatActivityEnterView.setFieldText("");
}
}));
}
- imageView = new ImageView(getParentActivity());
+ imageView = new ImageView(context);
imageView.setImageResource(R.drawable.stickers_back_arrow);
stickersPanel.addView(imageView);
layoutParams2 = (FrameLayout.LayoutParams) imageView.getLayoutParams();
@@ -1866,7 +1913,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.leftMargin = AndroidUtilities.dp(53);
imageView.setLayoutParams(layoutParams2);
- bottomOverlay = new FrameLayout(getParentActivity());
+ bottomOverlay = new FrameLayout(context);
bottomOverlay.setBackgroundColor(0xffffffff);
bottomOverlay.setVisibility(View.INVISIBLE);
bottomOverlay.setFocusable(true);
@@ -1879,7 +1926,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
bottomOverlay.setLayoutParams(layoutParams3);
- bottomOverlayText = new TextView(getParentActivity());
+ bottomOverlayText = new TextView(context);
bottomOverlayText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
bottomOverlayText.setTextColor(0xff7f7f7f);
bottomOverlay.addView(bottomOverlayText);
@@ -1889,7 +1936,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.CENTER;
bottomOverlayText.setLayoutParams(layoutParams2);
- bottomOverlayChat = new FrameLayout(getParentActivity());
+ bottomOverlayChat = new FrameLayout(context);
bottomOverlayChat.setBackgroundColor(0xfffbfcfd);
bottomOverlayChat.setVisibility(View.INVISIBLE);
contentView.addView(bottomOverlayChat);
@@ -1929,7 +1976,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
- bottomOverlayChatText = new TextView(getParentActivity());
+ bottomOverlayChatText = new TextView(context);
bottomOverlayChatText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
bottomOverlayChatText.setTextColor(0xff3e6fa1);
bottomOverlayChat.addView(bottomOverlayChatText);
@@ -1939,7 +1986,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
layoutParams2.gravity = Gravity.CENTER;
bottomOverlayChatText.setLayoutParams(layoutParams2);
- pagedownButton = new ImageView(getParentActivity());
+ pagedownButton = new ImageView(context);
pagedownButton.setVisibility(View.INVISIBLE);
pagedownButton.setImageResource(R.drawable.pagedown);
contentView.addView(pagedownButton);
@@ -1973,15 +2020,82 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateContactStatus();
updateBottomOverlay();
updateSecretStatus();
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
+ private void searchLinks(CharSequence charSequence, boolean force) {
+ if (currentEncryptedChat != null) {
+ return;
+ }
+ if (linkSearchRequestId != 0) {
+ ConnectionsManager.getInstance().cancelRpc(linkSearchRequestId, true);
+ linkSearchRequestId = 0;
+ }
+ if (force && foundWebPage != null) {
+ if (foundWebPage.url != null) {
+ int index = TextUtils.indexOf(charSequence, foundWebPage.url);
+ char lastChar;
+ boolean lenEqual;
+ if (index == -1) {
+ index = TextUtils.indexOf(charSequence, foundWebPage.display_url);
+ lenEqual = index != -1 && index + foundWebPage.display_url.length() == charSequence.length();
+ lastChar = index != -1 && !lenEqual ? charSequence.charAt(index + foundWebPage.display_url.length()) : 0;
+ } else {
+ lenEqual = index != -1 && index + foundWebPage.url.length() == charSequence.length();
+ lastChar = index != -1 && !lenEqual ? charSequence.charAt(index + foundWebPage.url.length()) : 0;
+ }
+ if (index != -1 && (lenEqual || lastChar == ' ' || lastChar == ',' || lastChar == '.' || lastChar == '!' || lastChar == '/')) {
+ return;
+ }
+ }
+ pendingLinkSearchString = null;
+ showReplyPanel(false, null, null, foundWebPage, false, true);
+ }
+ if (charSequence.length() == 0 || TextUtils.indexOf(charSequence, "http") == -1 && TextUtils.indexOf(charSequence, ".com/") == -1) {
+ return;
+ }
+ final TLRPC.TL_messages_getWebPagePreview req = new TLRPC.TL_messages_getWebPagePreview();
+ if (charSequence instanceof String) {
+ req.message = (String) charSequence;
+ } else {
+ req.message = charSequence.toString();
+ }
+ linkSearchRequestId = 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() {
+ linkSearchRequestId = 0;
+ if (error == null) {
+ if (response instanceof TLRPC.TL_messageMediaWebPage) {
+ foundWebPage = ((TLRPC.TL_messageMediaWebPage) response).webpage;
+ if (foundWebPage instanceof TLRPC.TL_webPage || foundWebPage instanceof TLRPC.TL_webPagePending) {
+ if (foundWebPage instanceof TLRPC.TL_webPagePending) {
+ pendingLinkSearchString = req.message;
+ }
+ showReplyPanel(true, null, null, foundWebPage, false, true);
+ } else {
+ if (foundWebPage != null) {
+ showReplyPanel(false, null, null, foundWebPage, false, true);
+ foundWebPage = null;
+ }
+ }
+ } else {
+ if (foundWebPage != null) {
+ showReplyPanel(false, null, null, foundWebPage, false, true);
+ foundWebPage = null;
+ }
+ }
+ }
+ }
+ });
+ }
+ });
+ ConnectionsManager.getInstance().bindRequestToGuid(linkSearchRequestId, classGuid);
+ }
+
private void forwardMessages(ArrayList arrayList, boolean fromMyName) {
if (arrayList == null || arrayList.isEmpty()) {
return;
@@ -1995,9 +2109,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
- public void showReplyForMessageObjectOrForward(boolean show, MessageObject messageObject, ArrayList messageObjects, boolean animated) {
+ public void showReplyPanel(boolean show, MessageObject messageObject, ArrayList messageObjects, TLRPC.WebPage webPage, boolean cancel, boolean animated) {
if (show) {
- if (messageObject == null && messageObjects == null) {
+ if (messageObject == null && messageObjects == null && webPage == null) {
return;
}
if (messageObject != null) {
@@ -2006,9 +2120,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
forwardingMessages = null;
- replyIconImageView.setImageResource(R.drawable.reply);
replyingMessageObject = messageObject;
chatActivityEnterView.setReplyingMessageObject(messageObject);
+
+ if (foundWebPage != null) {
+ return;
+ }
+ replyIconImageView.setImageResource(R.drawable.reply);
replyNameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
if (messageObject.messageText != null) {
String mess = messageObject.messageText.toString();
@@ -2022,12 +2140,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObjects.isEmpty()) {
return;
}
- chatActivityEnterView.setForceShowSendButton(true, animated);
- chatActivityEnterView.setReplyingMessageObject(null);
replyingMessageObject = null;
+ chatActivityEnterView.setReplyingMessageObject(null);
+ forwardingMessages = messageObjects;
+
+ if (foundWebPage != null) {
+ return;
+ }
+ chatActivityEnterView.setForceShowSendButton(true, animated);
ArrayList uids = new ArrayList<>();
replyIconImageView.setImageResource(R.drawable.forward_blue);
- forwardingMessages = messageObjects;
uids.add(messageObjects.get(0).messageOwner.from_id);
int type = messageObjects.get(0).type;
for (int a = 1; a < messageObjects.size(); a++) {
@@ -2108,16 +2230,40 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
+ } else if (webPage != null) {
+ replyIconImageView.setImageResource(R.drawable.link);
+ if (webPage instanceof TLRPC.TL_webPagePending) {
+ replyNameTextView.setText(LocaleController.getString("GettingLinkInfo", R.string.GettingLinkInfo));
+ replyObjectTextView.setText(pendingLinkSearchString);
+ } else {
+ if (webPage.site_name != null) {
+ replyNameTextView.setText(webPage.site_name);
+ } else if (webPage.title != null) {
+ replyNameTextView.setText(webPage.title);
+ }
+ if (webPage.description != null) {
+ replyObjectTextView.setText(webPage.description);
+ } else if (webPage.title != null && webPage.site_name != null) {
+ replyObjectTextView.setText(webPage.title);
+ } else if (webPage.author != null) {
+ replyObjectTextView.setText(webPage.author);
+ } else {
+ replyObjectTextView.setText(webPage.display_url);
+ }
+ chatActivityEnterView.setWebPage(webPage, true);
+ }
}
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) replyNameTextView.getLayoutParams();
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) replyObjectTextView.getLayoutParams();
TLRPC.PhotoSize photoSize = messageObject != null ? FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 80) : null;
- if (photoSize == null || messageObject.type == 13) {
+ if (photoSize == null || messageObject != null && messageObject.type == 13) {
replyImageView.setImageBitmap(null);
+ replyImageLocation = null;
replyImageView.setVisibility(View.INVISIBLE);
layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(52);
} else {
- replyImageView.setImage(photoSize.location, "50_50", (Drawable) null);
+ replyImageLocation = photoSize.location;
+ replyImageView.setImage(replyImageLocation, "50_50", (Drawable) null);
replyImageView.setVisibility(View.VISIBLE);
layoutParams1.leftMargin = layoutParams2.leftMargin = AndroidUtilities.dp(96);
}
@@ -2125,9 +2271,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
replyObjectTextView.setLayoutParams(layoutParams2);
chatActivityEnterView.showTopView(animated);
} else {
- if (replyingMessageObject == null && forwardingMessages == null) {
+ if (replyingMessageObject == null && forwardingMessages == null && foundWebPage == null) {
return;
}
+ if (foundWebPage != null) {
+ foundWebPage = null;
+ chatActivityEnterView.setWebPage(null, !cancel);
+ if (webPage != null && (replyingMessageObject != null || forwardingMessages != null)) {
+ showReplyPanel(true, replyingMessageObject, forwardingMessages, null, false, true);
+ return;
+ }
+ }
if (forwardingMessages != null) {
forwardMessages(forwardingMessages, !QuoteForward);
}
@@ -2136,6 +2290,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatActivityEnterView.setReplyingMessageObject(null);
replyingMessageObject = null;
forwardingMessages = null;
+ replyImageLocation = null;
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
preferences.edit().remove("reply_" + dialog_id).commit();
}
@@ -2304,7 +2459,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
bottomOverlay.setVisibility(View.VISIBLE);
hideKeyboard = true;
} else if (currentEncryptedChat instanceof TLRPC.TL_encryptedChatWaiting) {
- bottomOverlayText.setText(Html.fromHtml(LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, "" + currentUser.first_name + "")));
+ bottomOverlayText.setText(AndroidUtilities.replaceTags(LocaleController.formatString("AwaitingEncryption", R.string.AwaitingEncryption, "" + currentUser.first_name + "")));
bottomOverlay.setVisibility(View.VISIBLE);
hideKeyboard = true;
} else if (currentEncryptedChat instanceof TLRPC.TL_encryptedChatDiscarded) {
@@ -2382,7 +2537,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean isBroadcastError = isBroadcast && messageObject.getId() <= 0 && messageObject.isSendError();
if (!isBroadcast && messageObject.getId() <= 0 && messageObject.isOut() || isBroadcastError) {
if (messageObject.isSendError()) {
- if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (!messageObject.isMediaEmpty()) {
return 0;
} else {
return 7;
@@ -2399,7 +2554,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
return 1;
} else {
- if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (!messageObject.isMediaEmpty()) {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo ||
messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto ||
messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
@@ -2443,7 +2598,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObject.type == 6) {
return -1;
} else if (messageObject.isSendError()) {
- if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (!messageObject.isMediaEmpty()) {
return 0;
} else {
return 7;
@@ -2455,7 +2610,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return 1;
}
} else {
- if (!(messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) {
+ if (!messageObject.isMediaEmpty()) {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo ||
messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto ||
messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
@@ -2518,9 +2673,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private void processRowSelect(View view) {
MessageObject message = null;
if (view instanceof ChatBaseCell) {
- message = ((ChatBaseCell)view).getMessageObject();
+ message = ((ChatBaseCell) view).getMessageObject();
} else if (view instanceof ChatActionCell) {
- message = ((ChatActionCell)view).getMessageObject();
+ message = ((ChatActionCell) view).getMessageObject();
}
int type = getMessageType(message);
@@ -2566,14 +2721,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updateTitleIcons() {
- int leftIcon = currentEncryptedChat != null ? R.drawable.ic_lock_header : 0;
+ //int leftIcon = currentEncryptedChat != null ? R.drawable.ic_lock_header : 0;
int rightIcon = MessagesController.getInstance().isDialogMuted(dialog_id) ? R.drawable.mute_fixed : 0;
//nameTextView.setCompoundDrawablesWithIntrinsicBounds(leftIcon, 0, rightIcon, 0);
Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.ic_lock_header);
- lock.setColorFilter(AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int color = themePrefs.getInt("chatHeaderIconsColor", 0xffffffff);
+ lock.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
lock = currentEncryptedChat != null ? lock : null;
Drawable mute = getParentActivity().getResources().getDrawable(R.drawable.mute_blue);
- mute.setColorFilter(AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
+ mute.setColorFilter(color, PorterDuff.Mode.SRC_IN);
mute = MessagesController.getInstance().isDialogMuted(dialog_id) ? mute : null;
nameTextView.setCompoundDrawablesWithIntrinsicBounds(lock, null, mute, null);
if (rightIcon != 0) {
@@ -2684,7 +2841,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
//Chat header photo
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
- if(avatarImageView != null)avatarImageView.imageReceiver.setRoundRadius(radius);
+ if(avatarImageView != null)avatarImageView.setRoundRadius(radius);
if(avatarDrawable != null)avatarDrawable.setRadius(radius);
//
if (avatarImageView != null) {
@@ -2710,13 +2867,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
videoEditedInfo.resultHeight = resultHeight;
videoEditedInfo.originalPath = videoPath;
SendMessagesHelper.prepareSendingVideo(videoPath, estimatedSize, estimatedDuration, resultWidth, resultHeight, videoEditedInfo, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
});
if (parentLayout == null || !fragment.onFragmentCreate()) {
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
return false;
}
parentLayout.presentFragment(fragment, removeLast, true, true);
@@ -2741,7 +2898,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
try {
ExifInterface ei = new ExifInterface(currentPicturePath);
int exif = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
- switch(exif) {
+ switch (exif) {
case ExifInterface.ORIENTATION_ROTATE_90:
orientation = 90;
break;
@@ -2763,10 +2920,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) arrayList.get(0);
if (photoEntry.imagePath != null) {
SendMessagesHelper.prepareSendingPhoto(photoEntry.imagePath, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
} else if (photoEntry.path != null) {
SendMessagesHelper.prepareSendingPhoto(photoEntry.path, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
}
});
@@ -2778,7 +2935,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
} else if (requestCode == 2) {
String videoPath = null;
if (data != null) {
@@ -2812,7 +2969,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
currentPicturePath = null;
}
- if(Build.VERSION.SDK_INT >= 16) {
+ if (Build.VERSION.SDK_INT >= 16) {
if (paused) {
startVideoEdit = videoPath;
} else {
@@ -2820,7 +2977,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else {
SendMessagesHelper.prepareSendingVideo(videoPath, 0, 0, 0, 0, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
}
} else if (requestCode == 21) {
if (data == null || data.getData() == null) {
@@ -2838,7 +2995,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, null, null, dialog_id, replyingMessageObject);
- showReplyForMessageObjectOrForward(false, null, null, true);
+ showReplyPanel(false, null, null, null, false, true);
} //attach_music
else if (requestCode == 3) {
if (data == null || data.getData() == null) {
@@ -2856,6 +3013,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, null, null, dialog_id, replyingMessageObject);
+ } else if (requestCode == 4) { //attach_sticker
+ if (data == null || data.getData() == null) {
+ showAttachmentError();
+ return;
+ }
+ SendMessagesHelper.prepareSendingPhoto(null, data.getData(), dialog_id, replyingMessageObject);
+ showReplyPanel(false, null, null, null, false, true);
}
}
}
@@ -2895,24 +3059,24 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void didReceivedNotification(int id, final Object... args) {
if (id == NotificationCenter.messagesDidLoaded) {
- long did = (Long)args[0];
+ long did = (Long) args[0];
if (did == dialog_id) {
loadsCount++;
- int count = (Integer)args[1];
- boolean isCache = (Boolean)args[3];
- int fnid = (Integer)args[4];
- int last_unread_date = (Integer)args[8];
- int load_type = (Integer)args[9];
+ int count = (Integer) args[1];
+ boolean isCache = (Boolean) args[3];
+ int fnid = (Integer) args[4];
+ int last_unread_date = (Integer) args[8];
+ int load_type = (Integer) args[9];
boolean wasUnread = false;
if (fnid != 0) {
first_unread_id = fnid;
- last_message_id = (Integer)args[5];
- unread_to_load = (Integer)args[7];
+ last_message_id = (Integer) args[5];
+ unread_to_load = (Integer) args[7];
} else if (startLoadFromMessageId != 0 && load_type == 3) {
- last_message_id = (Integer)args[5];
- first_message_id = (Integer)args[6];
+ last_message_id = (Integer) args[5];
+ first_message_id = (Integer) args[6];
}
- ArrayList messArr = (ArrayList)args[2];
+ ArrayList messArr = (ArrayList) args[2];
int newRowsCount = 0;
@@ -3155,7 +3319,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
replyObjectTextView.invalidate();
}
} else if (id == NotificationCenter.updateInterfaces) {
- int updateMask = (Integer)args[0];
+ int updateMask = (Integer) args[0];
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0) {
updateTitle();
}
@@ -3187,19 +3351,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateContactStatus();
}
} else if (id == NotificationCenter.didReceivedNewMessages) {
- long did = (Long)args[0];
+ long did = (Long) args[0];
if (did == dialog_id) {
boolean updateChat = false;
boolean hasFromMe = false;
- ArrayList arr = (ArrayList)args[1];
+ ArrayList arr = (ArrayList) args[1];
if (currentEncryptedChat != null && arr.size() == 1) {
MessageObject obj = arr.get(0);
if (currentEncryptedChat != null && obj.isOut() && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && getParentActivity() != null) {
- TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL)obj.messageOwner.action.encryptedAction;
+ TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction;
if (AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 17 && currentEncryptedChat.ttl > 0 && currentEncryptedChat.ttl <= 60) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
@@ -3221,7 +3385,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) {
- TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL)obj.messageOwner.action.encryptedAction;
+ TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction;
timerDrawable.setTime(action.ttl_seconds);
}
if (obj.isOut() && obj.isSending()) {
@@ -3268,7 +3432,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (MessageObject obj : arr) {
if (currentEncryptedChat != null && obj.messageOwner.action != null && obj.messageOwner.action instanceof TLRPC.TL_messageEncryptedAction &&
obj.messageOwner.action.encryptedAction instanceof TLRPC.TL_decryptedMessageActionSetMessageTTL && timerDrawable != null) {
- TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL)obj.messageOwner.action.encryptedAction;
+ TLRPC.TL_decryptedMessageActionSetMessageTTL action = (TLRPC.TL_decryptedMessageActionSetMessageTTL) obj.messageOwner.action.encryptedAction;
timerDrawable.setTime(action.ttl_seconds);
}
if (messagesDict.containsKey(obj.getId())) {
@@ -3367,7 +3531,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
} else if (id == NotificationCenter.closeChats) {
if (args != null && args.length > 0) {
- long did = (Long)args[0];
+ long did = (Long) args[0];
if (did == dialog_id) {
finishFragment();
}
@@ -3414,7 +3578,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateVisibleRows();
}
} else if (id == NotificationCenter.messagesDeleted) {
- ArrayList markAsDeletedMessages = (ArrayList)args[0];
+ ArrayList markAsDeletedMessages = (ArrayList) args[0];
boolean updated = false;
for (Integer ids : markAsDeletedMessages) {
MessageObject obj = messagesDict.get(ids);
@@ -3457,11 +3621,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatAdapter.notifyDataSetChanged();
}
} else if (id == NotificationCenter.messageReceivedByServer) {
- Integer msgId = (Integer)args[0];
+ Integer msgId = (Integer) args[0];
MessageObject obj = messagesDict.get(msgId);
if (obj != null) {
- Integer newMsgId = (Integer)args[1];
- TLRPC.Message newMsgObj = (TLRPC.Message)args[2];
+ Integer newMsgId = (Integer) args[1];
+ TLRPC.Message newMsgObj = (TLRPC.Message) args[2];
+ boolean mediaUpdated = (Boolean) args[3];
if (newMsgObj != null) {
obj.messageOwner.media = newMsgObj.media;
obj.generateThumbs(true);
@@ -3471,25 +3636,28 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
obj.messageOwner.id = newMsgId;
obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
updateVisibleRows();
+ if (mediaUpdated && chatListView.getLastVisiblePosition() >= messages.size() - 1) {
+ moveScrollToLastMessage();
+ }
}
} else if (id == NotificationCenter.messageReceivedByAck) {
- Integer msgId = (Integer)args[0];
+ Integer msgId = (Integer) args[0];
MessageObject obj = messagesDict.get(msgId);
if (obj != null) {
obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
updateVisibleRows();
}
} else if (id == NotificationCenter.messageSendError) {
- Integer msgId = (Integer)args[0];
+ Integer msgId = (Integer) args[0];
MessageObject obj = messagesDict.get(msgId);
if (obj != null) {
obj.messageOwner.send_state = MessageObject.MESSAGE_SEND_STATE_SEND_ERROR;
updateVisibleRows();
}
} else if (id == NotificationCenter.chatInfoDidLoaded) {
- int chatId = (Integer)args[0];
+ int chatId = (Integer) args[0];
if (currentChat != null && chatId == currentChat.id) {
- info = (TLRPC.ChatParticipants)args[1];
+ info = (TLRPC.ChatParticipants) args[1];
if (mentionsAdapter != null) {
mentionsAdapter.setChatInfo(info);
}
@@ -3503,16 +3671,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateContactStatus();
updateSubtitle();
} else if (id == NotificationCenter.encryptedChatUpdated) {
- TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0];
+ TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat) args[0];
if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) {
currentEncryptedChat = chat;
updateContactStatus();
updateSecretStatus();
}
} else if (id == NotificationCenter.messagesReadedEncrypted) {
- int encId = (Integer)args[0];
+ int encId = (Integer) args[0];
if (currentEncryptedChat != null && currentEncryptedChat.id == encId) {
- int date = (Integer)args[1];
+ int date = (Integer) args[1];
boolean started = false;
for (MessageObject obj : messages) {
if (!obj.isOut()) {
@@ -3527,13 +3695,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateVisibleRows();
}
} else if (id == NotificationCenter.audioDidReset) {
- Integer mid = (Integer)args[0];
+ Integer mid = (Integer) args[0];
if (chatListView != null) {
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatAudioCell) {
- ChatAudioCell cell = (ChatAudioCell)view;
+ ChatAudioCell cell = (ChatAudioCell) view;
if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) {
cell.updateButtonState();
break;
@@ -3542,13 +3710,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
} else if (id == NotificationCenter.audioProgressDidChanged) {
- Integer mid = (Integer)args[0];
+ Integer mid = (Integer) args[0];
if (chatListView != null) {
int count = chatListView.getChildCount();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatAudioCell) {
- ChatAudioCell cell = (ChatAudioCell)view;
+ ChatAudioCell cell = (ChatAudioCell) view;
if (cell.getMessageObject() != null && cell.getMessageObject().getId() == mid) {
cell.updateProgress();
break;
@@ -3557,7 +3725,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
} else if (id == NotificationCenter.removeAllMessagesFromDialog) {
- long did = (Long)args[0];
+ long did = (Long) args[0];
if (dialog_id == did) {
messages.clear();
messagesByDays.clear();
@@ -3589,19 +3757,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
} else if (id == NotificationCenter.FileNewChunkAvailable) {
- MessageObject messageObject = (MessageObject)args[0];
- long finalSize = (Long)args[2];
+ MessageObject messageObject = (MessageObject) args[0];
+ long finalSize = (Long) args[2];
if (finalSize != 0 && dialog_id == messageObject.getDialogId()) {
MessageObject currentObject = messagesDict.get(messageObject.getId());
if (currentObject != null) {
- currentObject.messageOwner.media.video.size = (int)finalSize;
+ currentObject.messageOwner.media.video.size = (int) finalSize;
updateVisibleRows();
}
}
} else if (id == NotificationCenter.didCreatedNewDeleteTask) {
- SparseArray> mids = (SparseArray>)args[0];
+ SparseArray> mids = (SparseArray>) args[0];
boolean changed = false;
- for(int i = 0; i < mids.size(); i++) {
+ for (int i = 0; i < mids.size(); i++) {
int key = mids.keyAt(i);
ArrayList arr = mids.get(key);
for (Integer mid : arr) {
@@ -3616,10 +3784,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
updateVisibleRows();
}
} else if (id == NotificationCenter.audioDidStarted) {
- MessageObject messageObject = (MessageObject)args[0];
+ MessageObject messageObject = (MessageObject) args[0];
sendSecretMessageRead(messageObject);
} else if (id == NotificationCenter.updateMessageMedia) {
- MessageObject messageObject = (MessageObject)args[0];
+ MessageObject messageObject = (MessageObject) args[0];
MessageObject existMessageObject = messagesDict.get(messageObject.getId());
if (existMessageObject != null) {
existMessageObject.messageOwner.media = messageObject.messageOwner.media;
@@ -3630,10 +3798,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else if (id == NotificationCenter.replaceMessagesObjects) {
if (dialog_id == (long) args[0]) {
boolean changed = false;
+ boolean mediaUpdated = false;
ArrayList messageObjects = (ArrayList) args[1];
for (MessageObject messageObject : messageObjects) {
MessageObject old = messagesDict.get(messageObject.getId());
if (old != null) {
+ if (!mediaUpdated && messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
+ mediaUpdated = true;
+ }
messagesDict.put(old.getId(), messageObject);
int idx = messages.indexOf(old);
if (idx >= 0) {
@@ -3644,6 +3816,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (changed) {
chatAdapter.notifyDataSetChanged();
+ if (mediaUpdated && chatListView.getLastVisiblePosition() >= messages.size() - 1) {
+ moveScrollToLastMessage();
+ }
}
}
} else if (id == NotificationCenter.notificationsSettingsUpdated) {
@@ -3653,6 +3828,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (did == dialog_id) {
updateVisibleRows();
}
+ } else if (id == NotificationCenter.didReceivedWebpages) {
+ ArrayList arrayList = (ArrayList) args[0];
+ boolean updated = false;
+ for (TLRPC.Message message : arrayList) {
+ MessageObject currentMessage = messagesDict.get(message.id);
+ if (currentMessage != null) {
+ currentMessage.messageOwner.media.webpage = message.media.webpage;
+ currentMessage.generateThumbs(true);
+ updated = true;
+ }
+ }
+ if (updated) {
+ updateVisibleRows();
+ if (chatListView.getLastVisiblePosition() >= messages.size() - 1) {
+ moveScrollToLastMessage();
+ }
+ }
+ } else if (id == NotificationCenter.didReceivedWebpagesInUpdates) {
+ if (foundWebPage != null) {
+ HashMap hashMap = (HashMap) args[0];
+ for (TLRPC.WebPage webPage : hashMap.values()) {
+ if (webPage.id == foundWebPage.id) {
+ showReplyPanel(!(webPage instanceof TLRPC.TL_webPageEmpty), null, null, webPage, false, true);
+ break;
+ }
+ }
+ }
}
}
@@ -3663,7 +3865,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatMediaCell) {
- ChatMediaCell cell = (ChatMediaCell)view;
+ ChatMediaCell cell = (ChatMediaCell) view;
cell.setAllowedToSetPhoto(true);
}
}
@@ -3735,6 +3937,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
checkActionBarMenu();
+ if (replyImageLocation != null && replyImageView != null) {
+ replyImageView.setImage(replyImageLocation, "50_50", (Drawable) null);
+ }
NotificationsController.getInstance().setOpennedDialogId(dialog_id);
if (scrollToTopOnResume) {
@@ -3781,7 +3986,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
TLRPC.Message message = (TLRPC.Message) TLClassStore.Instance().TLdeserialize(data, data.readInt32());
if (message != null) {
replyingMessageObject = new MessageObject(message, MessagesController.getInstance().getUsers(), false);
- showReplyForMessageObjectOrForward(true, replyingMessageObject, null, false);
+ showReplyPanel(true, replyingMessageObject, null, null, false, false);
}
}
} catch (Exception e) {
@@ -3813,12 +4018,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void updateTheme(){
- actionBar.setBackgroundColor(AndroidUtilities.getIntDef("chatHeaderColor", AndroidUtilities.getIntColor("themeColor")));
- nameTextView.setTextColor(AndroidUtilities.getIntDef("chatNameColor", 0xffffffff));
- nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("chatNameSize", 18));
- onlineTextView.setTextColor(AndroidUtilities.getIntDef("chatStatusColor", AndroidUtilities.getIntDarkerColor("themeColor",-0x40)));
- onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("chatStatusSize", 14));
- int iColor = AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
+ actionBar.setBackgroundColor(themePrefs.getInt("chatHeaderColor", def));
+ nameTextView.setTextColor(themePrefs.getInt("chatNameColor", 0xffffffff));
+ nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("chatNameSize", 18));
+ onlineTextView.setTextColor(themePrefs.getInt("chatStatusColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x40)));
+ onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("chatStatusSize", 14));
+ int iColor = themePrefs.getInt("chatHeaderIconsColor", 0xffffffff);
Drawable mute = getParentActivity().getResources().getDrawable(R.drawable.mute_blue);
mute.setColorFilter(iColor, PorterDuff.Mode.SRC_IN);
Drawable dots = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_other);
@@ -3916,15 +4123,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedMessagesCountTextView.setTextSize(20);
}
if (AndroidUtilities.isTablet()) {
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int color = themePrefs.getInt("chatHeaderIconsColor", 0xffffffff);
if (AndroidUtilities.isSmallTablet() && getParentActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
//actionBar.setBackButtonImage(R.drawable.ic_ab_back);
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
- back.setColorFilter(AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ back.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
actionBar.setBackButtonDrawable(back);
} else {
//actionBar.setBackButtonImage(R.drawable.ic_close_white);
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_close_white);
- back.setColorFilter(AndroidUtilities.getIntDef("chatHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ back.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
actionBar.setBackButtonDrawable(back);
}
}
@@ -4024,7 +4233,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
options = new int[]{8, 4, 20, 2, 1};
} else if (type == 5) {
- items = new CharSequence[]{LocaleController.getString("Reply", R.string.Reply), LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
+ items = new CharSequence[]{LocaleController.getString("Reply", R.string.Reply), LocaleController.getString("ApplyTheme", R.string.ApplyTheme), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
options = new int[]{8, 5, 4, 20, 2, 1};
} else if (type == 6) {
items = new CharSequence[]{LocaleController.getString("Reply", R.string.Reply), LocaleController.getString("SaveToGallery", R.string.SaveToGallery), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
@@ -4045,7 +4254,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
options = new int[]{4, 20, 2, 1};
} else if (type == 5) {
- items = new CharSequence[]{LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
+ items = new CharSequence[]{LocaleController.getString("ApplyTheme", R.string.ApplyTheme), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
options = new int[]{5, 4, 20, 2, 1};
} else if (type == 6) {
items = new CharSequence[]{LocaleController.getString("SaveToGallery", R.string.SaveToGallery), LocaleController.getString("ShareFile", R.string.ShareFile), LocaleController.getString("Forward", R.string.Forward), LocaleController.getString("ForwardNoQuote", R.string.ForwardNoQuote), LocaleController.getString("Delete", R.string.Delete)};
@@ -4067,7 +4276,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
options = new int[]{4, 1};
} else if (type == 5) {
- items = new CharSequence[]{LocaleController.getString("ApplyLocalizationFile", R.string.ApplyLocalizationFile), LocaleController.getString("Delete", R.string.Delete)};
+ items = new CharSequence[]{LocaleController.getString("ApplyTheme", R.string.ApplyTheme), LocaleController.getString("Delete", R.string.Delete)};
options = new int[]{5, 1};
}/* else if (type == 6) {
options = new int[]{7, 6, 2, 1};
@@ -4160,11 +4369,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
fragment.setDelegate(this);
presentFragment(fragment);
} else if (option == 3) {
- if(Build.VERSION.SDK_INT < 11) {
- android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
+ if (Build.VERSION.SDK_INT < 11) {
+ android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText(selectedObject.messageText);
} else {
- android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
+ android.content.ClipboardManager clipboard = (android.content.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedObject.messageText);
clipboard.setPrimaryClip(clip);
}
@@ -4192,7 +4401,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
// To allow saving instead of sharing replace this elseif with:
// MediaController.saveFile(path, getParentActivity(), 2, selectedObject.getDocumentName());
}
- } else if (option == 5) {
+ }/*else if (option == 5) {
File locFile = null;
if (selectedObject.messageOwner.attachPath != null && selectedObject.messageOwner.attachPath.length() != 0) {
File f = new File(selectedObject.messageOwner.attachPath);
@@ -4220,7 +4429,46 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
showAlertDialog(builder);
}
}
- } else if (option == 6 || option == 7) {
+ }*/else if (option == 5) { //Apply theme
+ File locFile = null;
+ if (selectedObject.messageOwner.attachPath != null && selectedObject.messageOwner.attachPath.length() != 0) {
+ File f = new File(selectedObject.messageOwner.attachPath);
+ if (f.exists()) {
+ locFile = f;
+ }
+ }
+ if (locFile == null) {
+ File f = FileLoader.getPathToMessage(selectedObject.messageOwner);
+ if (f.exists()) {
+ locFile = f;
+ }
+ }
+ if (locFile != null) {
+ String theme = Utilities.applyThemeFile(locFile);
+ if (!theme.equals("")) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(theme);
+ builder.setMessage(LocaleController.getString("ThemeApplied", R.string.ThemeApplied) + "\n" + LocaleController.getString("ClickOkToRestart", R.string.ClickOkToRestart));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Utilities.restartApp();
+ }
+ });
+ showAlertDialog(builder);
+ } else {
+ if (getParentActivity() == null) {
+ return;
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setMessage(LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
+ showAlertDialog(builder);
+ }
+ }
+ }
+ else if (option == 6 || option == 7) {
String fileName = selectedObject.getFileName();
String path = selectedObject.messageOwner.attachPath;
if (path != null && path.length() > 0) {
@@ -4282,7 +4530,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
selectedObject = null;
}
} else if (option == 8) {
- showReplyForMessageObjectOrForward(true, selectedObject, null, true);
+ showReplyPanel(true, selectedObject, null, null, false, true);
}
selectedObject = null;
}
@@ -4373,7 +4621,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (did != dialog_id) {
- int lower_part = (int)did;
+ int lower_part = (int) did;
if (lower_part != 0) {
Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", scrollToTopOnResume);
@@ -4384,7 +4632,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
ChatActivity chatActivity = new ChatActivity(args);
if (presentFragment(chatActivity, true)) {
- chatActivity.showReplyForMessageObjectOrForward(true, null, fmessages, false);
+ chatActivity.showReplyPanel(true, null, fmessages, null, false, false);
if (!AndroidUtilities.isTablet()) {
removeSelfFromStack();
Activity parentActivity = getParentActivity();
@@ -4404,7 +4652,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
} else {
activity.finishFragment();
moveScrollToLastMessage();
- showReplyForMessageObjectOrForward(true, null, fmessages, AndroidUtilities.isTablet());
+ showReplyPanel(true, null, fmessages, null, false, AndroidUtilities.isTablet());
if (AndroidUtilities.isTablet()) {
actionBar.hideActionMode();
}
@@ -4461,7 +4709,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
try {
ApplicationInfo info = ApplicationLoader.applicationContext.getPackageManager().getApplicationInfo("com.google.android.apps.maps", 0);
return true;
- } catch(PackageManager.NameNotFoundException e) {
+ } catch (PackageManager.NameNotFoundException e) {
if (getParentActivity() == null) {
return false;
}
@@ -4493,7 +4741,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatBaseCell) {
- ChatBaseCell cell = (ChatBaseCell)view;
+ ChatBaseCell cell = (ChatBaseCell) view;
boolean disableSelection = false;
boolean selected = false;
@@ -4548,14 +4796,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
ImageReceiver imageReceiver = null;
View view = chatListView.getChildAt(a);
if (view instanceof ChatMediaCell) {
- ChatMediaCell cell = (ChatMediaCell)view;
+ ChatMediaCell cell = (ChatMediaCell) view;
MessageObject message = cell.getMessageObject();
if (message != null && message.getId() == messageObject.getId()) {
messageToOpen = message;
imageReceiver = cell.getPhotoImage();
}
} else if (view instanceof ChatActionCell) {
- ChatActionCell cell = (ChatActionCell)view;
+ ChatActionCell cell = (ChatActionCell) view;
MessageObject message = cell.getMessageObject();
if (message != null && message.getId() == messageObject.getId()) {
messageToOpen = message;
@@ -4585,25 +4833,34 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
@Override
- public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { }
+ public void willSwitchFromPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
+ }
@Override
- public void willHidePhotoViewer() { }
+ public void willHidePhotoViewer() {
+ }
@Override
- public boolean isPhotoChecked(int index) { return false; }
+ public boolean isPhotoChecked(int index) {
+ return false;
+ }
@Override
- public void setPhotoChecked(int index) { }
+ public void setPhotoChecked(int index) {
+ }
@Override
- public void cancelButtonPressed() { }
+ public void cancelButtonPressed() {
+ }
@Override
- public void sendButtonPressed(int index) { }
+ public void sendButtonPressed(int index) {
+ }
@Override
- public int getSelectedCount() { return 0; }
+ public int getSelectedCount() {
+ return 0;
+ }
private class ChatAdapter extends BaseFragmentAdapter {
@@ -4662,7 +4919,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (i == 0 && !endReached || !forward_end_reached && i == (messages.size() + 1 - offset)) {
View progressBar = null;
if (view == null) {
- LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_loading_layout, viewGroup, false);
progressBar = view.findViewById(R.id.progressLayout);
if (ApplicationLoader.isCustomTheme()) {
@@ -4683,21 +4940,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (view == null) {
if (type == 0) {
view = new ChatMessageCell(mContext);
- } if (type == 1) {
+ }
+ if (type == 1) {
view = new ChatMediaCell(mContext);
} else if (type == 2) {
view = new ChatAudioCell(mContext);
} else if (type == 3) {
view = new ChatContactCell(mContext);
} else if (type == 6) {
- LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.chat_unread_layout, viewGroup, false);
} else if (type == 4) {
view = new ChatActionCell(mContext);
}
if (view instanceof ChatBaseCell) {
- ((ChatBaseCell)view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() {
+ ((ChatBaseCell) view).setDelegate(new ChatBaseCell.ChatBaseCellDelegate() {
@Override
public void didPressedUserAvatar(ChatBaseCell cell, TLRPC.User user) {
if (actionBar.isActionModeShowed()) {
@@ -4840,7 +5098,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
} else if (view instanceof ChatContactCell) {
- ((ChatContactCell)view).setContactDelegate(new ChatContactCell.ChatContactCellDelegate() {
+ ((ChatContactCell) view).setContactDelegate(new ChatContactCell.ChatContactCellDelegate() {
@Override
public void didClickAddButton(ChatContactCell cell, TLRPC.User user) {
if (actionBar.isActionModeShowed()) {
@@ -4895,7 +5153,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
}
} else if (view instanceof ChatActionCell) {
- ((ChatActionCell)view).setDelegate(new ChatActionCell.ChatActionCellDelegate() {
+ ((ChatActionCell) view).setDelegate(new ChatActionCell.ChatActionCellDelegate() {
@Override
public void didClickedImage(ChatActionCell cell) {
MessageObject message = cell.getMessageObject();
@@ -4935,20 +5193,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
if (view instanceof ChatBaseCell) {
- ChatBaseCell baseCell = (ChatBaseCell)view;
+ ChatBaseCell baseCell = (ChatBaseCell) view;
baseCell.isChat = currentChat != null;
baseCell.setMessageObject(message);
baseCell.setCheckPressed(!disableSelection, disableSelection && selected);
if (view instanceof ChatAudioCell && MediaController.getInstance().canDownloadMedia(MediaController.AUTODOWNLOAD_MASK_AUDIO)) {
- ((ChatAudioCell)view).downloadAudioIfNeed();
+ ((ChatAudioCell) view).downloadAudioIfNeed();
}
baseCell.setHighlighted(highlightMessageId != Integer.MAX_VALUE && message.getId() == highlightMessageId);
} else if (view instanceof ChatActionCell) {
- ChatActionCell actionCell = (ChatActionCell)view;
+ ChatActionCell actionCell = (ChatActionCell) view;
actionCell.setMessageObject(message);
}
if (type == 6) {
- TextView messageTextView = (TextView)view.findViewById(R.id.chat_message_text);
+ TextView messageTextView = (TextView) view.findViewById(R.id.chat_message_text);
messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load));
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java
index a7472c6f..872ea924 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarUpdater.java
@@ -19,22 +19,23 @@ import android.provider.MediaStore;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader;
import org.telegram.android.MediaController;
-import org.telegram.messenger.TLRPC;
+import org.telegram.android.NotificationCenter;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
-import org.telegram.android.NotificationCenter;
+import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
+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;
import java.util.ArrayList;
public class AvatarUpdater implements NotificationCenter.NotificationCenterDelegate, PhotoCropActivity.PhotoEditActivityDelegate {
+
public String currentPicturePath;
private TLRPC.PhotoSize smallPhoto;
private TLRPC.PhotoSize bigPhoto;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java
index ad0478de..156bab8d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BackupImageView.java
@@ -20,10 +20,9 @@ import org.telegram.android.ImageReceiver;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
-
public class BackupImageView extends View {
- public ImageReceiver imageReceiver;
- public boolean processDetach = true;
+
+ private ImageReceiver imageReceiver;
public BackupImageView(Context context) {
super(context);
@@ -91,13 +90,23 @@ public class BackupImageView extends View {
imageReceiver.setImageBitmap(drawable);
}
+ public void setRoundRadius(int value) {
+ imageReceiver.setRoundRadius(value);
+ }
+
+ public void setAspectFit(boolean value) {
+ imageReceiver.setAspectFit(value);
+ }
+
+ public ImageReceiver getImageReceiver() {
+ return imageReceiver;
+ }
+
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- if (processDetach) {
imageReceiver.clearImage();
}
- }
@Override
protected void onDraw(Canvas canvas) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
index b52d3cd3..62005691 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java
@@ -12,7 +12,6 @@ import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
-import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.os.Build;
@@ -20,12 +19,10 @@ import android.os.PowerManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.style.ImageSpan;
-import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -50,7 +47,6 @@ import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
-import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
@@ -59,7 +55,6 @@ import org.telegram.ui.AnimationCompat.AnimatorListenerAdapterProxy;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.AnimationCompat.ViewProxy;
-import org.telegram.messenger.ApplicationLoader;
import java.lang.reflect.Field;
@@ -68,7 +63,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
public interface ChatActivityEnterViewDelegate {
void onMessageSend(String message);
void needSendTyping();
- void onTextChanged(CharSequence text);
+ void onTextChanged(CharSequence text, boolean bigChange);
void onAttachButtonHidden();
void onAttachButtonShow();
void onWindowSizeChanged(int size);
@@ -111,11 +106,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
private long dialog_id;
private boolean ignoreTextChange;
private MessageObject replyingMessageObject;
+ private TLRPC.WebPage messageWebPage;
+ private boolean messageWebPageSearch;
private ChatActivityEnterViewDelegate delegate;
private float topViewAnimation;
+ private boolean topViewShowed;
private boolean needShowTopView;
private boolean allowShowTopView;
+ private AnimatorSetProxy currentTopViewAnimation;
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
super(context);
@@ -161,7 +160,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
emojiButton = new ImageView(context);
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles);
- emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ final int color = themePrefs.getInt("chatEditTextIconsColor", 0xffadadad);
+ emoji.setColorFilter(color, PorterDuff.Mode.SRC_IN);
emojiButton.setImageDrawable(emoji);
emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0);
@@ -244,12 +245,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
@Override
- public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
+ public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
String message = getTrimmedString(charSequence.toString());
checkSendButton(true);
if (delegate != null) {
- delegate.onTextChanged(charSequence);
+ if (before > count || count > 1) {
+ messageWebPageSearch = true;
+ }
+ delegate.onTextChanged(charSequence, before > count || count > 1);
}
if (message.length() != 0 && lastTypingTimeSend < System.currentTimeMillis() - 5000 && !ignoreTextChange) {
@@ -386,8 +390,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//audioSendButton.setImageResource(R.drawable.mic_button_states);
//audioSendButton.setBackgroundColor(0xffffffff);
+ audioSendButton.setSoundEffectsEnabled(false);
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic);
- mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
+ mic.setColorFilter(color, PorterDuff.Mode.SRC_IN);
audioSendButton.setImageDrawable(mic);
audioSendButton.setBackgroundColor(0x00000000);
audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
@@ -425,7 +430,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
updateAudioRecordIntefrace();
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
- mic.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
+ mic.setColorFilter(color, PorterDuff.Mode.SRC_IN);
audioSendButton.setImageDrawable(mic);
startedDraggingX = -1;
MediaController.getInstance().stopRecording(true);
@@ -480,6 +485,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
sendButton.setVisibility(View.INVISIBLE);
sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
sendButton.setImageResource(R.drawable.ic_send);
+ sendButton.setSoundEffectsEnabled(false);
ViewProxy.setScaleX(sendButton, 0.1f);
ViewProxy.setScaleY(sendButton, 0.1f);
ViewProxy.setAlpha(sendButton, 0.0f);
@@ -502,13 +508,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
private void updateTheme() {
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
Drawable send = parentActivity.getResources().getDrawable(R.drawable.ic_send);
- send.setColorFilter(AndroidUtilities.getIntDef("chatSendIconColor", AndroidUtilities.getIntColor("chatEditTextIconsColor")), PorterDuff.Mode.SRC_IN);
+ send.setColorFilter(themePrefs.getInt("chatSendIconColor", themePrefs.getInt("chatEditTextIconsColor", def)), PorterDuff.Mode.SRC_IN);
sendButton.setImageDrawable(send);
- messageEditText.setTextColor(AndroidUtilities.getIntDef("chatEditTextColor",0xff000000));
+ messageEditText.setTextColor(themePrefs.getInt("chatEditTextColor", 0xff000000));
messageEditText.setHintTextColor(AndroidUtilities.getIntAlphaColor("chatEditTextColor", 0xff000000, 0.35f));
- messageEditText.setTextSize(AndroidUtilities.getIntDef("chatEditTextSize",18));
- int color = AndroidUtilities.getIntDef("chatEditTextBGColor", 0xffffffff);
+ messageEditText.setTextSize(themePrefs.getInt("chatEditTextSize", 18));
+ int color = themePrefs.getInt("chatEditTextBGColor", 0xffffffff);
setBackgroundColor(color);
textFieldContainer.setBackgroundColor(color);
}
@@ -530,6 +538,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
public void setTopViewAnimation(float progress) {
+ topViewAnimation = progress;
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
layoutParams2.topMargin = AndroidUtilities.dp(2) + (int) (topView.getLayoutParams().height * progress);
textFieldContainer.setLayoutParams(layoutParams2);
@@ -545,75 +554,85 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
public void showTopView(boolean animated) {
- if (topView == null) {
+ if (topView == null || topViewShowed) {
return;
}
needShowTopView = true;
+ topViewShowed = true;
if (allowShowTopView) {
topView.setVisibility(VISIBLE);
+ float resumeValue = 0.0f;
+ if (currentTopViewAnimation != null) {
+ resumeValue = topViewAnimation;
+ currentTopViewAnimation.cancel();
+ currentTopViewAnimation = null;
+ }
if (animated) {
if (keyboardVisible || emojiPopup != null && emojiPopup.isShowing()) {
- AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
- animatorSetProxy.playTogether(
- ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 0.0f, 1.0f)
+ currentTopViewAnimation = new AnimatorSetProxy();
+ currentTopViewAnimation.playTogether(
+ ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 1.0f)
);
- animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
+ currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
- textFieldContainer.setLayoutParams(layoutParams2);
+ if (animation == currentTopViewAnimation) {
+ setTopViewAnimation(1.0f);
if (!forceShowSendButton) {
openKeyboard();
}
- }
- });
- animatorSetProxy.setDuration(200);
- animatorSetProxy.start();
- } else {
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
- textFieldContainer.setLayoutParams(layoutParams2);
+ currentTopViewAnimation = null;
+ }
+ }
+ });
+ currentTopViewAnimation.setDuration(200);
+ currentTopViewAnimation.start();
+ } else {
+ setTopViewAnimation(1.0f);
if (!forceShowSendButton) {
openKeyboard();
}
}
} else {
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
- textFieldContainer.setLayoutParams(layoutParams2);
+ setTopViewAnimation(1.0f);
}
}
- }
+ }
- public void hideTopView(boolean animated) {
- if (topView == null) {
+ public void hideTopView(final boolean animated) {
+ if (topView == null || !topViewShowed) {
return;
}
+ topViewShowed = false;
needShowTopView = false;
if (allowShowTopView) {
+ float resumeValue = 1.0f;
+ if (currentTopViewAnimation != null) {
+ resumeValue = topViewAnimation;
+ currentTopViewAnimation.cancel();
+ currentTopViewAnimation = null;
+ }
if (animated) {
- AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
- animatorSetProxy.playTogether(
- ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 1.0f, 0.0f)
+ currentTopViewAnimation = new AnimatorSetProxy();
+ currentTopViewAnimation.playTogether(
+ ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", resumeValue, 0.0f)
);
- animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
+ currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override
public void onAnimationEnd(Object animation) {
- topView.setVisibility(GONE);
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2);
- textFieldContainer.setLayoutParams(layoutParams2);
+ if (animation == currentTopViewAnimation) {
+ topView.setVisibility(GONE);
+ setTopViewAnimation(0.0f);
+ currentTopViewAnimation = null;
+ }
}
});
- animatorSetProxy.setDuration(200);
- animatorSetProxy.start();
+ currentTopViewAnimation.setDuration(200);
+ currentTopViewAnimation.start();
} else {
topView.setVisibility(GONE);
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2);
- textFieldContainer.setLayoutParams(layoutParams2);
+ setTopViewAnimation(0.0f);
}
}
}
@@ -632,9 +651,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
allowShowTopView = false;
if (needShowTopView) {
topView.setVisibility(View.GONE);
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2);
- textFieldContainer.setLayoutParams(layoutParams2);
+ setTopViewAnimation(0.0f);
}
}
} else {
@@ -642,9 +659,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
allowShowTopView = true;
if (needShowTopView) {
topView.setVisibility(View.VISIBLE);
- LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
- layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
- textFieldContainer.setLayoutParams(layoutParams2);
+ setTopViewAnimation(1.0f);
}
}
}
@@ -682,6 +697,11 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
replyingMessageObject = messageObject;
}
+ public void setWebPage(TLRPC.WebPage webPage, boolean searchWebPages) {
+ messageWebPage = webPage;
+ messageWebPageSearch = searchWebPages;
+ }
+
private void sendMessage() {
if (parentFragment != null) {
String action = null;
@@ -720,7 +740,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
int count = (int) Math.ceil(text.length() / 4096.0f);
for (int a = 0; a < count; a++) {
String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length()));
- SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, replyingMessageObject);
+ SendMessagesHelper.getInstance().sendMessage(mess, dialog_id, replyingMessageObject, messageWebPage, messageWebPageSearch);
}
return true;
}
@@ -991,6 +1011,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
private void showEmojiPopup(boolean show) {
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int color = themePrefs.getInt("chatEditTextIconsColor", 0xffadadad);
if (show) {
if (emojiPopup == null) {
if (parentActivity == null) {
@@ -1076,7 +1098,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
//emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
Drawable hide = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_hide);
- hide.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
+ hide.setColorFilter(color, PorterDuff.Mode.SRC_IN);
emojiButton.setImageDrawable(hide);
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
}
@@ -1095,14 +1117,14 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
}
//emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
Drawable kb = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_kb_white);
- kb.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.MULTIPLY);
+ kb.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
emojiButton.setImageDrawable(kb);
return;
}
if (emojiButton != null) {
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
Drawable emoji = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_smiles);
- emoji.setColorFilter(AndroidUtilities.getIntDef("chatEditTextIconsColor", 0xffadadad), PorterDuff.Mode.SRC_IN);
+ emoji.setColorFilter(color, PorterDuff.Mode.SRC_IN);
emojiButton.setImageDrawable(emoji);
}
if (emojiPopup != null) {
@@ -1147,7 +1169,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
messageEditText.setSelection(messageEditText.getText().length());
ignoreTextChange = false;
if (delegate != null) {
- delegate.onTextChanged(messageEditText.getText());
+ delegate.onTextChanged(messageEditText.getText(), true);
}
}
@@ -1229,7 +1251,6 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
@Override
public void onSizeChanged(int height, boolean isWidthGreater) {
if (height > AndroidUtilities.dp(50) && keyboardVisible) {
- //if (height > AndroidUtilities.dp(50) ) {
if (isWidthGreater) {
keyboardHeightLand = height;
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java
index 6d670978..3c17e47e 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClippingImageView.java
@@ -22,6 +22,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.ui.AnimationCompat.ViewProxy;
public class ClippingImageView extends View {
+
private int clipBottom;
private int clipLeft;
private int clipRight;
@@ -79,7 +80,7 @@ public class ClippingImageView extends View {
}
public void onDraw(Canvas canvas) {
- if (getVisibility() == GONE || getVisibility() == INVISIBLE) {
+ if (getVisibility() != VISIBLE) {
return;
}
if (bmp != null) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java
index d43b9dc9..262163d9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiView.java
@@ -9,6 +9,7 @@
package org.telegram.ui.Components;
import android.content.Context;
+import android.content.SharedPreferences;
import android.database.DataSetObserver;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
@@ -26,12 +27,14 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.Emoji;
import org.telegram.android.LocaleController;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R;
import java.util.ArrayList;
public class EmojiView extends LinearLayout {
- private ArrayList adapters = new ArrayList();
+
+ private ArrayList adapters = new ArrayList<>();
private int[] icons = {
R.drawable.ic_emoji_recent,
R.drawable.ic_emoji_smile,
@@ -42,7 +45,7 @@ public class EmojiView extends LinearLayout {
private Listener listener;
private ViewPager pager;
private FrameLayout recentsWrap;
- private ArrayList views = new ArrayList();
+ private ArrayList views = new ArrayList<>();
public EmojiView(Context paramContext) {
super(paramContext);
@@ -63,7 +66,7 @@ public class EmojiView extends LinearLayout {
if (this.pager.getCurrentItem() == 0) {
return;
}
- ArrayList localArrayList = new ArrayList();
+ ArrayList localArrayList = new ArrayList<>();
long[] currentRecent = Emoji.data[0];
boolean was = false;
for (long aCurrentRecent : currentRecent) {
@@ -163,12 +166,13 @@ public class EmojiView extends LinearLayout {
}
private void updateTheme(PagerSlidingTabStrip tabs) {
- setBackgroundColor(AndroidUtilities.getIntDef("chatEmojiViewBGColor",0xff222222));
- tabs.setIndicatorColor(AndroidUtilities.getIntDef("chatEmojiViewTabColor",AndroidUtilities.getIntDarkerColor("themeColor",0x15)));//0xff33b5e5
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ setBackgroundColor(themePrefs.getInt("chatEmojiViewBGColor", 0xff222222));
+ tabs.setIndicatorColor(themePrefs.getInt("chatEmojiViewTabColor",AndroidUtilities.getIntDarkerColor("themeColor",0x15)));//0xff33b5e5
}
private void saveRecents() {
- ArrayList localArrayList = new ArrayList();
+ ArrayList localArrayList = new ArrayList<>();
long[] arrayOfLong = Emoji.data[0];
int i = arrayOfLong.length;
for (int j = 0; ; j++) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java
index 1d30c568..542623e9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FrameLayoutFixed.java
@@ -19,7 +19,8 @@ import org.telegram.messenger.FileLog;
import java.util.ArrayList;
public class FrameLayoutFixed extends FrameLayout {
- private final ArrayList mMatchParentChildren = new ArrayList(1);
+
+ private final ArrayList mMatchParentChildren = new ArrayList<>(1);
public FrameLayoutFixed(Context context) {
super(context);
@@ -110,7 +111,7 @@ public class FrameLayoutFixed extends FrameLayout {
}
setMeasuredDimension(resolveSizeAndStateFixed(maxWidth, widthMeasureSpec, childState),
- resolveSizeAndStateFixed(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT));
+ resolveSizeAndStateFixed(maxHeight, heightMeasureSpec, childState << 16));
count = mMatchParentChildren.size();
if (count > 1) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java
index adaa786e..b6f2561b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ProgressView.java
@@ -14,6 +14,7 @@ import android.graphics.Paint;
import org.telegram.android.AndroidUtilities;
public class ProgressView {
+
private Paint innerPaint;
private Paint outerPaint;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java
index d0d4187e..54ec83b9 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SizeNotifierRelativeLayout.java
@@ -33,14 +33,17 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
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) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java
index 6464ce5f..a1ae84c6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SlideView.java
@@ -49,4 +49,8 @@ public class SlideView extends LinearLayout {
public void restoreStateParams(Bundle bundle) {
}
+
+ public boolean needBackButton() {
+ return false;
+ }
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java
index 74da7e49..d562cc6b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/VideoTimelineView.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
@TargetApi(10)
public class VideoTimelineView extends View {
+
private long videoLength = 0;
private float progressLeft = 0;
private float progressRight = 1;
@@ -39,7 +40,7 @@ public class VideoTimelineView extends View {
private float pressDx = 0;
private MediaMetadataRetriever mediaMetadataRetriever = null;
private VideoTimelineViewDelegate delegate = null;
- private ArrayList frames = new ArrayList();
+ private ArrayList frames = new ArrayList<>();
private AsyncTask currentTask = null;
private static final Object sync = new Object();
private long frameTimeOffset = 0;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java
index 288690a3..e2db7ba6 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactAddActivity.java
@@ -9,6 +9,7 @@
package org.telegram.ui;
import android.app.Activity;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.InputType;
@@ -19,7 +20,6 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.FrameLayout;
@@ -27,20 +27,20 @@ import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
-import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
+import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
+import org.telegram.messenger.ApplicationLoader;
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.BaseFragment;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
-import org.telegram.ui.ActionBar.BaseFragment;
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@@ -74,198 +74,186 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
- if (avatarImage != null) {
- avatarImage.setImageDrawable(null);
- }
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- if (addContact) {
- actionBar.setTitle(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
- } else {
- actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
- }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ if (addContact) {
+ actionBar.setTitle(LocaleController.getString("AddContactTitle", R.string.AddContactTitle));
+ } else {
+ actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
+ }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == done_button) {
+ if (firstNameField.getText().length() != 0) {
+ TLRPC.User user = MessagesController.getInstance().getUser(user_id);
+ user.first_name = firstNameField.getText().toString();
+ user.last_name = lastNameField.getText().toString();
+ ContactsController.getInstance().addContact(user);
finishFragment();
- } else if (id == done_button) {
- if (firstNameField.getText().length() != 0) {
- TLRPC.User user = MessagesController.getInstance().getUser(user_id);
- user.first_name = firstNameField.getText().toString();
- user.last_name = lastNameField.getText().toString();
- ContactsController.getInstance().addContact(user);
- finishFragment();
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
- }
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
}
}
- });
+ }
+ });
- ActionBarMenu menu = actionBar.createMenu();
- doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+ ActionBarMenu menu = actionBar.createMenu();
+ doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- fragmentView = new ScrollView(getParentActivity());
+ fragmentView = new ScrollView(context);
- LinearLayout linearLayout = new LinearLayout(getParentActivity());
- linearLayout.setOrientation(LinearLayout.VERTICAL);
- ((ScrollView) fragmentView).addView(linearLayout);
- ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
- layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT;
- layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT;
- linearLayout.setLayoutParams(layoutParams2);
- linearLayout.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
+ LinearLayout linearLayout = new LinearLayout(context);
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
+ ((ScrollView) fragmentView).addView(linearLayout);
+ ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
+ layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT;
+ layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT;
+ linearLayout.setLayoutParams(layoutParams2);
+ linearLayout.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ FrameLayout frameLayout = new FrameLayout(context);
+ linearLayout.addView(frameLayout);
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
+ layoutParams.topMargin = AndroidUtilities.dp(24);
+ layoutParams.leftMargin = AndroidUtilities.dp(24);
+ layoutParams.rightMargin = AndroidUtilities.dp(24);
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ frameLayout.setLayoutParams(layoutParams);
+
+ avatarImage = new BackupImageView(context);
+ avatarImage.setRoundRadius(AndroidUtilities.dp(30));
+ frameLayout.addView(avatarImage);
+ FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
+ layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
+ layoutParams3.width = AndroidUtilities.dp(60);
+ layoutParams3.height = AndroidUtilities.dp(60);
+ avatarImage.setLayoutParams(layoutParams3);
+
+ nameTextView = new TextView(context);
+ nameTextView.setTextColor(0xff212121);
+ nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ nameTextView.setLines(1);
+ nameTextView.setMaxLines(1);
+ nameTextView.setSingleLine(true);
+ nameTextView.setEllipsize(TextUtils.TruncateAt.END);
+ nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
+ nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ frameLayout.addView(nameTextView);
+ layoutParams3 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
+ layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
+ layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
+ layoutParams3.topMargin = AndroidUtilities.dp(3);
+ layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
+ nameTextView.setLayoutParams(layoutParams3);
+
+ onlineTextView = new TextView(context);
+ onlineTextView.setTextColor(0xff999999);
+ onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ onlineTextView.setLines(1);
+ onlineTextView.setMaxLines(1);
+ onlineTextView.setSingleLine(true);
+ onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
+ onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
+ frameLayout.addView(onlineTextView);
+ layoutParams3 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
+ layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
+ layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
+ layoutParams3.topMargin = AndroidUtilities.dp(32);
+ layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
+ onlineTextView.setLayoutParams(layoutParams3);
+
+ firstNameField = new EditText(context);
+ firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
+ firstNameField.setHintTextColor(0xff979797);
+ firstNameField.setTextColor(0xff212121);
+ firstNameField.setMaxLines(1);
+ firstNameField.setLines(1);
+ firstNameField.setSingleLine(true);
+ firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
+ firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
+ firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
+ firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
+ AndroidUtilities.clearCursorDrawable(firstNameField);
+ linearLayout.addView(firstNameField);
+ layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
+ layoutParams.topMargin = AndroidUtilities.dp(24);
+ layoutParams.height = AndroidUtilities.dp(36);
+ layoutParams.leftMargin = AndroidUtilities.dp(24);
+ layoutParams.rightMargin = AndroidUtilities.dp(24);
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ firstNameField.setLayoutParams(layoutParams);
+ firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+ if (i == EditorInfo.IME_ACTION_NEXT) {
+ lastNameField.requestFocus();
+ lastNameField.setSelection(lastNameField.length());
return true;
}
- });
-
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
- linearLayout.addView(frameLayout);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(24);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
- frameLayout.setLayoutParams(layoutParams);
-
- avatarImage = new BackupImageView(getParentActivity());
- avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30));
- avatarImage.processDetach = false;
- frameLayout.addView(avatarImage);
- FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
- layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
- layoutParams3.width = AndroidUtilities.dp(60);
- layoutParams3.height = AndroidUtilities.dp(60);
- avatarImage.setLayoutParams(layoutParams3);
-
- nameTextView = new TextView(getParentActivity());
- nameTextView.setTextColor(0xff212121);
- nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
- nameTextView.setLines(1);
- nameTextView.setMaxLines(1);
- nameTextView.setSingleLine(true);
- nameTextView.setEllipsize(TextUtils.TruncateAt.END);
- nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
- nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- frameLayout.addView(nameTextView);
- layoutParams3 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
- layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
- layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
- layoutParams3.topMargin = AndroidUtilities.dp(3);
- layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
- nameTextView.setLayoutParams(layoutParams3);
-
- onlineTextView = new TextView(getParentActivity());
- onlineTextView.setTextColor(0xff999999);
- onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
- onlineTextView.setLines(1);
- onlineTextView.setMaxLines(1);
- onlineTextView.setSingleLine(true);
- onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
- onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
- frameLayout.addView(onlineTextView);
- layoutParams3 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
- layoutParams3.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams3.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
- layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
- layoutParams3.topMargin = AndroidUtilities.dp(32);
- layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
- onlineTextView.setLayoutParams(layoutParams3);
-
- firstNameField = new EditText(getParentActivity());
- firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
- firstNameField.setHintTextColor(0xff979797);
- firstNameField.setTextColor(0xff212121);
- firstNameField.setMaxLines(1);
- firstNameField.setLines(1);
- firstNameField.setSingleLine(true);
- firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
- firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
- firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
- AndroidUtilities.clearCursorDrawable(firstNameField);
- linearLayout.addView(firstNameField);
- layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(24);
- layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- firstNameField.setLayoutParams(layoutParams);
- firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
- if (i == EditorInfo.IME_ACTION_NEXT) {
- lastNameField.requestFocus();
- lastNameField.setSelection(lastNameField.length());
- return true;
- }
- return false;
- }
- });
-
- lastNameField = new EditText(getParentActivity());
- lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
- lastNameField.setHintTextColor(0xff979797);
- lastNameField.setTextColor(0xff212121);
- lastNameField.setMaxLines(1);
- lastNameField.setLines(1);
- lastNameField.setSingleLine(true);
- lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
- lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
- lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
- AndroidUtilities.clearCursorDrawable(lastNameField);
- linearLayout.addView(lastNameField);
- layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(16);
- layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- lastNameField.setLayoutParams(layoutParams);
- lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
- if (i == EditorInfo.IME_ACTION_DONE) {
- doneButton.performClick();
- return true;
- }
- return false;
- }
- });
-
- TLRPC.User user = MessagesController.getInstance().getUser(user_id);
- if (user != null) {
- if (user.phone == null) {
- if (phone != null) {
- user.phone = PhoneFormat.stripExceptNumbers(phone);
- }
- }
- firstNameField.setText(user.first_name);
- firstNameField.setSelection(firstNameField.length());
- lastNameField.setText(user.last_name);
+ return false;
}
+ });
- updateAvatarLayout();
- } else {
- ViewGroup parent = (ViewGroup) fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
+ lastNameField = new EditText(context);
+ lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
+ lastNameField.setHintTextColor(0xff979797);
+ lastNameField.setTextColor(0xff212121);
+ lastNameField.setMaxLines(1);
+ lastNameField.setLines(1);
+ lastNameField.setSingleLine(true);
+ lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
+ lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
+ lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
+ AndroidUtilities.clearCursorDrawable(lastNameField);
+ linearLayout.addView(lastNameField);
+ layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
+ layoutParams.topMargin = AndroidUtilities.dp(16);
+ layoutParams.height = AndroidUtilities.dp(36);
+ layoutParams.leftMargin = AndroidUtilities.dp(24);
+ layoutParams.rightMargin = AndroidUtilities.dp(24);
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ lastNameField.setLayoutParams(layoutParams);
+ lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+ if (i == EditorInfo.IME_ACTION_DONE) {
+ doneButton.performClick();
+ return true;
+ }
+ return false;
}
+ });
+
+ TLRPC.User user = MessagesController.getInstance().getUser(user_id);
+ if (user != null) {
+ if (user.phone == null) {
+ if (phone != null) {
+ user.phone = PhoneFormat.stripExceptNumbers(phone);
+ }
+ }
+ firstNameField.setText(user.first_name);
+ firstNameField.setSelection(firstNameField.length());
+ lastNameField.setText(user.last_name);
}
+
return fragmentView;
}
@@ -299,6 +287,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override
public void onResume() {
super.onResume();
+ updateAvatarLayout();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true);
if (!animations) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java
index 69cd4244..6626b192 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ContactsActivity.java
@@ -9,10 +9,9 @@
package org.telegram.ui;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.graphics.PorterDuff;
-import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -33,23 +32,23 @@ import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.android.LocaleController;
-import org.telegram.android.MessagesStorage;
-import org.telegram.android.SecretChatHelper;
-import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
-import org.telegram.messenger.FileLog;
+import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
+import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter;
+import org.telegram.android.SecretChatHelper;
+import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
-import org.telegram.ui.Adapters.BaseSectionsAdapter;
-import org.telegram.ui.Adapters.ContactsAdapter;
-import org.telegram.ui.Adapters.SearchAdapter;
-import org.telegram.ui.Cells.UserCell;
+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.BaseSectionsAdapter;
+import org.telegram.ui.Adapters.ContactsAdapter;
+import org.telegram.ui.Adapters.SearchAdapter;
+import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.Components.LetterSectionsListView;
import java.util.ArrayList;
@@ -118,8 +117,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
+
searching = false;
searchWas = false;
@@ -182,7 +181,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (listView != null) {
listView.setAdapter(searchListViewAdapter);
searchListViewAdapter.notifyDataSetChanged();
- if(android.os.Build.VERSION.SDK_INT >= 11) {
+ if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false);
}
listView.setFastScrollEnabled(false);
@@ -197,12 +196,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
});
item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
- searchListViewAdapter = new SearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch);
- listViewAdapter = new ContactsAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers);
+ searchListViewAdapter = new SearchAdapter(context, ignoreUsers, allowUsernameSearch);
+ listViewAdapter = new ContactsAdapter(context, onlyUsers, needPhonebook, ignoreUsers);
- fragmentView = new FrameLayout(getParentActivity());
+ fragmentView = new FrameLayout(context);
- LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
+ LinearLayout emptyTextLayout = new LinearLayout(context);
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout);
@@ -218,7 +217,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
});
- emptyTextView = new TextView(getParentActivity());
+ emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
emptyTextView.setGravity(Gravity.CENTER);
@@ -230,7 +229,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1);
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
+ FrameLayout frameLayout = new FrameLayout(context);
emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
@@ -238,7 +237,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1);
- listView = new LetterSectionsListView(getParentActivity());
+ listView = new LetterSectionsListView(context);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
@@ -392,12 +391,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}
}
});
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java
index 414f9345..aa838efd 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/CountrySelectActivity.java
@@ -8,12 +8,12 @@
package org.telegram.ui;
+import android.content.Context;
import android.os.Build;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.EditText;
@@ -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.LetterSectionsListView;
public class CountrySelectActivity extends BaseFragment {
@@ -61,174 +61,168 @@ public class CountrySelectActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- }
- }
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
- @Override
- public void onSearchExpand() {
- searching = true;
- }
-
- @Override
- public boolean onSearchCollapse() {
- searchListViewAdapter.search(null);
- searching = false;
- searchWas = false;
- listView.setAdapter(listViewAdapter);
- if (android.os.Build.VERSION.SDK_INT >= 11) {
- listView.setFastScrollAlwaysVisible(true);
- }
- listView.setFastScrollEnabled(true);
- listView.setVerticalScrollBarEnabled(false);
-
- emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
-
- return true;
- }
-
- @Override
- public void onTextChanged(EditText editText) {
- String text = editText.getText().toString();
- searchListViewAdapter.search(text);
- if (text.length() != 0) {
- searchWas = true;
- if (listView != null) {
- listView.setAdapter(searchListViewAdapter);
- if(android.os.Build.VERSION.SDK_INT >= 11) {
- listView.setFastScrollAlwaysVisible(false);
- }
- listView.setFastScrollEnabled(false);
- listView.setVerticalScrollBarEnabled(true);
- }
- if (emptyTextView != null) {
-
- }
- }
- }
- });
- item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
-
- searching = false;
- searchWas = false;
-
- listViewAdapter = new CountryAdapter(getParentActivity());
- searchListViewAdapter = new CountrySearchAdapter(getParentActivity(), listViewAdapter.getCountries());
-
- fragmentView = new FrameLayout(getParentActivity());
-
- LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
- emptyTextLayout.setVisibility(View.INVISIBLE);
- emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
- ((FrameLayout) fragmentView).addView(emptyTextLayout);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- emptyTextLayout.setLayoutParams(layoutParams);
- emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
-
- emptyTextView = new TextView(getParentActivity());
- emptyTextView.setTextColor(0xff808080);
- emptyTextView.setTextSize(20);
- emptyTextView.setGravity(Gravity.CENTER);
- emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
- emptyTextLayout.addView(emptyTextView);
- LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.weight = 0.5f;
- emptyTextView.setLayoutParams(layoutParams1);
-
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
- emptyTextLayout.addView(frameLayout);
- layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.weight = 0.5f;
- frameLayout.setLayoutParams(layoutParams1);
-
- listView = new LetterSectionsListView(getParentActivity());
- listView.setEmptyView(emptyTextLayout);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setFastScrollEnabled(true);
- listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
- listView.setAdapter(listViewAdapter);
- if (Build.VERSION.SDK_INT >= 11) {
- listView.setFastScrollAlwaysVisible(true);
- listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
- }
- ((FrameLayout) fragmentView).addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
- Country country = null;
- if (searching && searchWas) {
- country = searchListViewAdapter.getItem(i);
- } else {
- int section = listViewAdapter.getSectionForPosition(i);
- int row = listViewAdapter.getPositionInSectionForPosition(i);
- if (row < 0 || section < 0) {
- return;
- }
- country = listViewAdapter.getItem(section, row);
- }
- if (i < 0) {
- return;
- }
- if (country != null && delegate != null) {
- delegate.didSelectCountry(country.name);
- }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
finishFragment();
}
- });
-
- listView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView absListView, int i) {
- if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
- AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
- }
- }
-
- @Override
- public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- if (absListView.isFastScrollEnabled()) {
- AndroidUtilities.clearDrawableAnimation(absListView);
- }
- }
- });
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
}
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
+ @Override
+ public void onSearchExpand() {
+ searching = true;
+ }
+
+ @Override
+ public boolean onSearchCollapse() {
+ searchListViewAdapter.search(null);
+ searching = false;
+ searchWas = false;
+ listView.setAdapter(listViewAdapter);
+ if (android.os.Build.VERSION.SDK_INT >= 11) {
+ listView.setFastScrollAlwaysVisible(true);
+ }
+ listView.setFastScrollEnabled(true);
+ listView.setVerticalScrollBarEnabled(false);
+
+ emptyTextView.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
+
+ return true;
+ }
+
+ @Override
+ public void onTextChanged(EditText editText) {
+ String text = editText.getText().toString();
+ searchListViewAdapter.search(text);
+ if (text.length() != 0) {
+ searchWas = true;
+ if (listView != null) {
+ listView.setAdapter(searchListViewAdapter);
+ if (android.os.Build.VERSION.SDK_INT >= 11) {
+ listView.setFastScrollAlwaysVisible(false);
+ }
+ listView.setFastScrollEnabled(false);
+ listView.setVerticalScrollBarEnabled(true);
+ }
+ if (emptyTextView != null) {
+
+ }
+ }
+ }
+ });
+ item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
+
+ searching = false;
+ searchWas = false;
+
+ listViewAdapter = new CountryAdapter(context);
+ searchListViewAdapter = new CountrySearchAdapter(context, listViewAdapter.getCountries());
+
+ fragmentView = new FrameLayout(context);
+
+ LinearLayout emptyTextLayout = new LinearLayout(context);
+ emptyTextLayout.setVisibility(View.INVISIBLE);
+ emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
+ ((FrameLayout) fragmentView).addView(emptyTextLayout);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ emptyTextLayout.setLayoutParams(layoutParams);
+ emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ emptyTextView = new TextView(context);
+ emptyTextView.setTextColor(0xff808080);
+ emptyTextView.setTextSize(20);
+ emptyTextView.setGravity(Gravity.CENTER);
+ emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
+ emptyTextLayout.addView(emptyTextView);
+ LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.weight = 0.5f;
+ emptyTextView.setLayoutParams(layoutParams1);
+
+ FrameLayout frameLayout = new FrameLayout(context);
+ emptyTextLayout.addView(frameLayout);
+ layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.weight = 0.5f;
+ frameLayout.setLayoutParams(layoutParams1);
+
+ listView = new LetterSectionsListView(context);
+ listView.setEmptyView(emptyTextLayout);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setFastScrollEnabled(true);
+ listView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
+ listView.setAdapter(listViewAdapter);
+ if (Build.VERSION.SDK_INT >= 11) {
+ listView.setFastScrollAlwaysVisible(true);
+ listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
}
+ ((FrameLayout) fragmentView).addView(listView);
+ layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ Country country = null;
+ if (searching && searchWas) {
+ country = searchListViewAdapter.getItem(i);
+ } else {
+ int section = listViewAdapter.getSectionForPosition(i);
+ int row = listViewAdapter.getPositionInSectionForPosition(i);
+ if (row < 0 || section < 0) {
+ return;
+ }
+ country = listViewAdapter.getItem(section, row);
+ }
+ if (i < 0) {
+ return;
+ }
+ if (country != null && delegate != null) {
+ delegate.didSelectCountry(country.name);
+ }
+ finishFragment();
+ }
+ });
+
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) {
+ if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
+ AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
+ }
+ }
+
+ @Override
+ public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ if (absListView.isFastScrollEnabled()) {
+ AndroidUtilities.clearDrawableAnimation(absListView);
+ }
+ }
+ });
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java
index 0a68445d..839b5d3b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/DocumentSelectActivity.java
@@ -29,16 +29,16 @@ import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
+import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
-import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
+import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
-import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Cells.SharedDocumentCell;
import java.io.BufferedReader;
@@ -128,7 +128,7 @@ public class DocumentSelectActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
+ public View createView(Context context, LayoutInflater inflater) {
if (!receiverRegistered) {
receiverRegistered = true;
IntentFilter filter = new IntentFilter();
@@ -145,7 +145,6 @@ public class DocumentSelectActivity extends BaseFragment {
getParentActivity().registerReceiver(receiver, filter);
}
- if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
@@ -189,7 +188,7 @@ public class DocumentSelectActivity extends BaseFragment {
}
});
actionMode.addView(selectedMessagesCountTextView);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1;
layoutParams.width = 0;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
@@ -198,15 +197,15 @@ public class DocumentSelectActivity extends BaseFragment {
actionModeViews.add(actionMode.addItem(done, R.drawable.ic_ab_done_gray, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
fragmentView = inflater.inflate(R.layout.document_select_layout, null, false);
- listAdapter = new ListAdapter(getParentActivity());
- emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView);
+ listAdapter = new ListAdapter(context);
+ emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
- listView = (ListView)fragmentView.findViewById(R.id.listView);
+ listView = (ListView) fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyView);
listView.setAdapter(listAdapter);
@@ -350,12 +349,7 @@ public class DocumentSelectActivity extends BaseFragment {
});
listRoots();
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java
index 603d423e..e6043110 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java
@@ -9,6 +9,7 @@
package org.telegram.ui;
import android.app.Activity;
+import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
@@ -29,7 +30,6 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.AbsListView;
import android.widget.AdapterView;
@@ -39,21 +39,21 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
-import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
-import org.telegram.android.LocaleController;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.TLRPC;
+import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
-import org.telegram.messenger.FileLog;
+import org.telegram.android.LocaleController;
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.ui.Adapters.ContactsAdapter;
-import org.telegram.ui.Adapters.SearchAdapter;
+import org.telegram.messenger.TLRPC;
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.LetterSectionsListView;
@@ -142,8 +142,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
searching = false;
searchWas = false;
@@ -186,17 +185,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- searchListViewAdapter = new SearchAdapter(getParentActivity(), null, false);
+ searchListViewAdapter = new SearchAdapter(context, null, false);
searchListViewAdapter.setCheckedMap(selectedContacts);
searchListViewAdapter.setUseUserCell(true);
- listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null);
+ listViewAdapter = new ContactsAdapter(context, true, false, null);
listViewAdapter.setCheckedMap(selectedContacts);
- fragmentView = new LinearLayout(getParentActivity());
+ fragmentView = new LinearLayout(context);
LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL);
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
+ FrameLayout frameLayout = new FrameLayout(context);
linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
@@ -204,7 +203,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.gravity = Gravity.TOP;
frameLayout.setLayoutParams(layoutParams);
- userSelectEditText = new EditText(getParentActivity());
+ userSelectEditText = new EditText(context);
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
userSelectEditText.setHintTextColor(0xff979797);
userSelectEditText.setTextColor(0xff212121);
@@ -295,7 +294,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (listView != null) {
listView.setAdapter(searchListViewAdapter);
searchListViewAdapter.notifyDataSetChanged();
- if(android.os.Build.VERSION.SDK_INT >= 11) {
+ if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false);
}
listView.setFastScrollEnabled(false);
@@ -323,7 +322,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
});
- LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
+ LinearLayout emptyTextLayout = new LinearLayout(context);
emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(emptyTextLayout);
@@ -338,7 +337,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
});
- emptyTextView = new TextView(getParentActivity());
+ emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER);
@@ -350,7 +349,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams);
- FrameLayout frameLayout2 = new FrameLayout(getParentActivity());
+ FrameLayout frameLayout2 = new FrameLayout(context);
emptyTextLayout.addView(frameLayout2);
layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
@@ -358,7 +357,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.weight = 0.5f;
frameLayout2.setLayoutParams(layoutParams);
- listView = new LetterSectionsListView(getParentActivity());
+ listView = new LetterSectionsListView(context);
listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null);
@@ -468,12 +467,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
}
}
});
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java
index c5974180..9499d8a2 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java
@@ -29,23 +29,23 @@ import android.widget.LinearLayout;
import android.widget.ListView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.LocaleController;
-import org.telegram.android.MessagesStorage;
-import org.telegram.messenger.TLRPC;
-import org.telegram.messenger.FileLog;
import org.telegram.android.MessagesController;
+import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter;
+import org.telegram.messenger.ConnectionsManager;
+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.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.UserCell;
-import org.telegram.ui.ActionBar.ActionBar;
-import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.AvatarUpdater;
import org.telegram.ui.Components.BackupImageView;
-import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.FrameLayoutFixed;
import java.util.ArrayList;
@@ -138,191 +138,185 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- if (isBroadcast) {
- actionBar.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
- } else {
- actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
- }
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ if (isBroadcast) {
+ actionBar.setTitle(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList));
+ } else {
+ actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
+ }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == done_button) {
- if (donePressed) {
- return;
- }
- if (nameTextView.getText().length() == 0) {
- return;
- }
- donePressed = true;
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == done_button) {
+ if (donePressed) {
+ return;
+ }
+ if (nameTextView.getText().length() == 0) {
+ return;
+ }
+ donePressed = true;
- if (isBroadcast) {
- MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, isBroadcast);
+ if (isBroadcast) {
+ MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, isBroadcast);
+ } else {
+ if (avatarUpdater.uploadingAvatar != null) {
+ createAfterUpload = true;
} else {
- if (avatarUpdater.uploadingAvatar != null) {
- createAfterUpload = true;
- } else {
- progressDialog = new ProgressDialog(getParentActivity());
- progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
- progressDialog.setCanceledOnTouchOutside(false);
- progressDialog.setCancelable(false);
+ progressDialog = new ProgressDialog(getParentActivity());
+ progressDialog.setMessage(LocaleController.getString("Loading", R.string.Loading));
+ progressDialog.setCanceledOnTouchOutside(false);
+ progressDialog.setCancelable(false);
- final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, isBroadcast);
+ final long reqId = MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, isBroadcast);
- progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- ConnectionsManager.getInstance().cancelRpc(reqId, true);
- donePressed = false;
- try {
- dialog.dismiss();
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
+ progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ ConnectionsManager.getInstance().cancelRpc(reqId, true);
+ donePressed = false;
+ try {
+ dialog.dismiss();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
}
- });
- progressDialog.show();
- }
+ }
+ });
+ progressDialog.show();
}
}
}
- });
+ }
+ });
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- fragmentView = new LinearLayout(getParentActivity());
- LinearLayout linearLayout = (LinearLayout) fragmentView;
- linearLayout.setOrientation(LinearLayout.VERTICAL);
+ fragmentView = new LinearLayout(context);
+ LinearLayout linearLayout = (LinearLayout) fragmentView;
+ linearLayout.setOrientation(LinearLayout.VERTICAL);
- FrameLayout frameLayout = new FrameLayoutFixed(getParentActivity());
- linearLayout.addView(frameLayout);
- LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
- frameLayout.setLayoutParams(layoutParams);
+ FrameLayout frameLayout = new FrameLayoutFixed(context);
+ linearLayout.addView(frameLayout);
+ LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ frameLayout.setLayoutParams(layoutParams);
- avatarImage = new BackupImageView(getParentActivity());
- avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
- avatarDrawable.setInfo(5, null, null, isBroadcast);
- avatarImage.setImageDrawable(avatarDrawable);
- frameLayout.addView(avatarImage);
- FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
- layoutParams1.width = AndroidUtilities.dp(64);
- layoutParams1.height = AndroidUtilities.dp(64);
- layoutParams1.topMargin = AndroidUtilities.dp(12);
- layoutParams1.bottomMargin = AndroidUtilities.dp(12);
- layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
- layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
- layoutParams1.gravity = Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
- avatarImage.setLayoutParams(layoutParams1);
- if (!isBroadcast) {
- avatarDrawable.setDrawPhoto(true);
- avatarImage.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (getParentActivity() == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ avatarImage = new BackupImageView(context);
+ avatarImage.setRoundRadius(AndroidUtilities.dp(32));
+ avatarDrawable.setInfo(5, null, null, isBroadcast);
+ avatarImage.setImageDrawable(avatarDrawable);
+ frameLayout.addView(avatarImage);
+ FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
+ layoutParams1.width = AndroidUtilities.dp(64);
+ layoutParams1.height = AndroidUtilities.dp(64);
+ layoutParams1.topMargin = AndroidUtilities.dp(12);
+ layoutParams1.bottomMargin = AndroidUtilities.dp(12);
+ layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
+ layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
+ layoutParams1.gravity = Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
+ avatarImage.setLayoutParams(layoutParams1);
+ if (!isBroadcast) {
+ avatarDrawable.setDrawPhoto(true);
+ avatarImage.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- CharSequence[] items;
+ CharSequence[] items;
- if (avatar != null) {
- items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
- } else {
- items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
- }
+ if (avatar != null) {
+ items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
+ } else {
+ items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
+ }
- builder.setItems(items, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- if (i == 0) {
- avatarUpdater.openCamera();
- } else if (i == 1) {
- avatarUpdater.openGallery();
- } else if (i == 2) {
- avatar = null;
- uploadedAvatar = null;
- avatarImage.setImage(avatar, "50_50", avatarDrawable);
- }
+ builder.setItems(items, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ if (i == 0) {
+ avatarUpdater.openCamera();
+ } else if (i == 1) {
+ avatarUpdater.openGallery();
+ } else if (i == 2) {
+ avatar = null;
+ uploadedAvatar = null;
+ avatarImage.setImage(avatar, "50_50", avatarDrawable);
}
- });
- showAlertDialog(builder);
- }
- });
- }
-
- nameTextView = new EditText(getParentActivity());
- nameTextView.setHint(isBroadcast ? LocaleController.getString("EnterListName", R.string.EnterListName) : LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
- if (nameToSet != null) {
- nameTextView.setText(nameToSet);
- nameToSet = null;
- }
- nameTextView.setMaxLines(4);
- nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
- nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
- nameTextView.setHintTextColor(0xff979797);
- nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
- nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
- nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
- AndroidUtilities.clearCursorDrawable(nameTextView);
- nameTextView.setTextColor(0xff212121);
- frameLayout.addView(nameTextView);
- layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
- layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
- layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
- layoutParams1.gravity = Gravity.CENTER_VERTICAL;
- nameTextView.setLayoutParams(layoutParams1);
- if (!isBroadcast) {
- nameTextView.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) {
- avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, isBroadcast);
- avatarImage.invalidate();
- }
- });
- }
-
- GreySectionCell sectionCell = new GreySectionCell(getParentActivity());
- sectionCell.setText(LocaleController.formatPluralString("Members", selectedContacts.size()));
- linearLayout.addView(sectionCell);
-
- listView = new ListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalScrollBarEnabled(false);
- listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
- linearLayout.addView(listView);
- layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ }
+ });
+ showAlertDialog(builder);
+ }
+ });
}
+
+ nameTextView = new EditText(context);
+ nameTextView.setHint(isBroadcast ? LocaleController.getString("EnterListName", R.string.EnterListName) : LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
+ if (nameToSet != null) {
+ nameTextView.setText(nameToSet);
+ nameToSet = null;
+ }
+ nameTextView.setMaxLines(4);
+ nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
+ nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
+ nameTextView.setHintTextColor(0xff979797);
+ nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
+ nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
+ AndroidUtilities.clearCursorDrawable(nameTextView);
+ nameTextView.setTextColor(0xff212121);
+ frameLayout.addView(nameTextView);
+ layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
+ layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
+ layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
+ layoutParams1.gravity = Gravity.CENTER_VERTICAL;
+ nameTextView.setLayoutParams(layoutParams1);
+ if (!isBroadcast) {
+ nameTextView.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) {
+ avatarDrawable.setInfo(5, nameTextView.length() > 0 ? nameTextView.getText().toString() : null, null, isBroadcast);
+ avatarImage.invalidate();
+ }
+ });
+ }
+
+ GreySectionCell sectionCell = new GreySectionCell(context);
+ sectionCell.setText(LocaleController.formatPluralString("Members", selectedContacts.size()));
+ linearLayout.addView(sectionCell);
+
+ listView = new ListView(context);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setAdapter(listAdapter = new ListAdapter(context));
+ linearLayout.addView(listView);
+ layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+
return fragmentView;
}
@@ -336,7 +330,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
avatarImage.setImage(avatar, "50_50", avatarDrawable);
if (createAfterUpload) {
FileLog.e("tmessages", "avatar did uploaded");
- MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, false);
+ MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, false);
}
}
});
@@ -402,10 +396,14 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
FileLog.e("tmessages", e);
}
}
+ int chat_id = (Integer)args[0];
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
Bundle args2 = new Bundle();
- args2.putInt("chat_id", (Integer)args[0]);
+ args2.putInt("chat_id", chat_id);
presentFragment(new ChatActivity(args2), true);
+ if (uploadedAvatar != null) {
+ MessagesController.getInstance().changeChatAvatar(chat_id, uploadedAvatar);
+ }
}
});
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java
index 88ae3a8b..d882721d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/IdenticonActivity.java
@@ -10,23 +10,22 @@ package org.telegram.ui;
import android.content.Context;
import android.os.Bundle;
-import android.text.Html;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.View;
-import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
+import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R;
+import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.IdenticonDrawable;
@@ -45,45 +44,39 @@ public class IdenticonActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
}
- });
-
- fragmentView = inflater.inflate(R.layout.identicon_layout, null, false);
- ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view);
- TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
- TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
- if (encryptedChat != null) {
- IdenticonDrawable drawable = new IdenticonDrawable();
- identiconView.setImageDrawable(drawable);
- drawable.setEncryptedChat(encryptedChat);
- TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
- textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
}
+ });
- fragmentView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ fragmentView = inflater.inflate(R.layout.identicon_layout, null, false);
+ ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view);
+ TextView textView = (TextView) fragmentView.findViewById(R.id.identicon_text);
+ TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
+ if (encryptedChat != null) {
+ IdenticonDrawable drawable = new IdenticonDrawable();
+ identiconView.setImageDrawable(drawable);
+ drawable.setEncryptedChat(encryptedChat);
+ TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id);
+ textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
}
+
+ fragmentView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java
index f02ef1cb..6132d892 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/IntroActivity.java
@@ -19,7 +19,6 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
-import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
@@ -255,7 +254,7 @@ public class IntroActivity extends Activity {
container.addView(view, 0);
headerTextView.setText(getString(titles[position]));
- messageTextView.setText(Html.fromHtml(getString(messages[position])));
+ messageTextView.setText(AndroidUtilities.replaceTags(getString(messages[position])));
return view;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java
index 0ff48eb8..494c4128 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LanguageSelectActivity.java
@@ -25,16 +25,16 @@ import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
-import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
+import org.telegram.messenger.FileLog;
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 java.util.ArrayList;
import java.util.Timer;
@@ -52,192 +52,186 @@ public class LanguageSelectActivity extends BaseFragment {
public ArrayList searchResult;
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- searching = false;
- searchWas = false;
+ public View createView(Context context, LayoutInflater inflater) {
+ searching = false;
+ searchWas = false;
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("Language", R.string.Language));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- }
- }
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
- @Override
- public void onSearchExpand() {
- searching = true;
- }
-
- @Override
- public boolean onSearchCollapse() {
- search(null);
- searching = false;
- searchWas = false;
- if (listView != null) {
- emptyTextView.setVisibility(View.GONE);
- listView.setAdapter(listAdapter);
- }
-
- return true;
- }
-
- @Override
- public void onTextChanged(EditText editText) {
- String text = editText.getText().toString();
- search(text);
- if (text.length() != 0) {
- searchWas = true;
- if (listView != null) {
- listView.setAdapter(searchListViewAdapter);
- }
- }
- }
- });
- item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
-
- listAdapter = new ListAdapter(getParentActivity());
- searchListViewAdapter = new SearchAdapter(getParentActivity());
-
- fragmentView = new FrameLayout(getParentActivity());
-
- LinearLayout emptyTextLayout = new LinearLayout(getParentActivity());
- emptyTextLayout.setVisibility(View.INVISIBLE);
- emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
- ((FrameLayout) fragmentView).addView(emptyTextLayout);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- emptyTextLayout.setLayoutParams(layoutParams);
- emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
-
- emptyTextView = new TextView(getParentActivity());
- emptyTextView.setTextColor(0xff808080);
- emptyTextView.setTextSize(20);
- emptyTextView.setGravity(Gravity.CENTER);
- emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
- emptyTextLayout.addView(emptyTextView);
- LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.weight = 0.5f;
- emptyTextView.setLayoutParams(layoutParams1);
-
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
- emptyTextLayout.addView(frameLayout);
- layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.weight = 0.5f;
- frameLayout.setLayoutParams(layoutParams1);
-
- listView = new ListView(getParentActivity());
- listView.setEmptyView(emptyTextLayout);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setAdapter(listAdapter);
- ((FrameLayout) fragmentView).addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
- LocaleController.LocaleInfo localeInfo = null;
- if (searching && searchWas) {
- if (i >= 0 && i < searchResult.size()) {
- localeInfo = searchResult.get(i);
- }
- } else {
- if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
- localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
- }
- }
- if (localeInfo != null) {
- LocaleController.getInstance().applyLanguage(localeInfo, true);
- parentLayout.rebuildAllFragmentViews(false);
- }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
finishFragment();
}
- });
+ }
+ });
- listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
- LocaleController.LocaleInfo localeInfo = null;
- if (searching && searchWas) {
- if (i >= 0 && i < searchResult.size()) {
- localeInfo = searchResult.get(i);
- }
- } else {
- if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
- localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
- }
+ ActionBarMenu menu = actionBar.createMenu();
+ ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
+ @Override
+ public void onSearchExpand() {
+ searching = true;
+ }
+
+ @Override
+ public boolean onSearchCollapse() {
+ search(null);
+ searching = false;
+ searchWas = false;
+ if (listView != null) {
+ emptyTextView.setVisibility(View.GONE);
+ listView.setAdapter(listAdapter);
+ }
+
+ return true;
+ }
+
+ @Override
+ public void onTextChanged(EditText editText) {
+ String text = editText.getText().toString();
+ search(text);
+ if (text.length() != 0) {
+ searchWas = true;
+ if (listView != null) {
+ listView.setAdapter(searchListViewAdapter);
}
- if (localeInfo == null || localeInfo.pathToFile == null || getParentActivity() == null) {
- return false;
+ }
+ }
+ });
+ item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
+
+ listAdapter = new ListAdapter(context);
+ searchListViewAdapter = new SearchAdapter(context);
+
+ fragmentView = new FrameLayout(context);
+
+ LinearLayout emptyTextLayout = new LinearLayout(context);
+ emptyTextLayout.setVisibility(View.INVISIBLE);
+ emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
+ ((FrameLayout) fragmentView).addView(emptyTextLayout);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextLayout.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ emptyTextLayout.setLayoutParams(layoutParams);
+ emptyTextLayout.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ emptyTextView = new TextView(context);
+ emptyTextView.setTextColor(0xff808080);
+ emptyTextView.setTextSize(20);
+ emptyTextView.setGravity(Gravity.CENTER);
+ emptyTextView.setText(LocaleController.getString("NoResult", R.string.NoResult));
+ emptyTextLayout.addView(emptyTextView);
+ LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.weight = 0.5f;
+ emptyTextView.setLayoutParams(layoutParams1);
+
+ FrameLayout frameLayout = new FrameLayout(context);
+ emptyTextLayout.addView(frameLayout);
+ layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.weight = 0.5f;
+ frameLayout.setLayoutParams(layoutParams1);
+
+ listView = new ListView(context);
+ listView.setEmptyView(emptyTextLayout);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setAdapter(listAdapter);
+ ((FrameLayout) fragmentView).addView(listView);
+ layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ LocaleController.LocaleInfo localeInfo = null;
+ if (searching && searchWas) {
+ if (i >= 0 && i < searchResult.size()) {
+ localeInfo = searchResult.get(i);
}
- final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) {
- if (searchResult != null) {
- searchResult.remove(finalLocaleInfo);
- }
- if (listAdapter != null) {
- listAdapter.notifyDataSetChanged();
- }
- if (searchListViewAdapter != null) {
- searchListViewAdapter.notifyDataSetChanged();
- }
+ } else {
+ if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
+ localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
+ }
+ }
+ if (localeInfo != null) {
+ LocaleController.getInstance().applyLanguage(localeInfo, true);
+ parentLayout.rebuildAllFragmentViews(false);
+ }
+ finishFragment();
+ }
+ });
+
+ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
+ LocaleController.LocaleInfo localeInfo = null;
+ if (searching && searchWas) {
+ if (i >= 0 && i < searchResult.size()) {
+ localeInfo = searchResult.get(i);
+ }
+ } else {
+ if (i >= 0 && i < LocaleController.getInstance().sortedLanguages.size()) {
+ localeInfo = LocaleController.getInstance().sortedLanguages.get(i);
+ }
+ }
+ if (localeInfo == null || localeInfo.pathToFile == null || getParentActivity() == null) {
+ return false;
+ }
+ final LocaleController.LocaleInfo finalLocaleInfo = localeInfo;
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.getString("DeleteLocalization", R.string.DeleteLocalization));
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ if (LocaleController.getInstance().deleteLanguage(finalLocaleInfo)) {
+ if (searchResult != null) {
+ searchResult.remove(finalLocaleInfo);
+ }
+ if (listAdapter != null) {
+ listAdapter.notifyDataSetChanged();
+ }
+ if (searchListViewAdapter != null) {
+ searchListViewAdapter.notifyDataSetChanged();
}
}
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- return true;
- }
- });
-
- listView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView absListView, int i) {
- if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
- AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
}
- }
-
- @Override
- public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- }
- });
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ return true;
}
- }
+ });
+
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView absListView, int i) {
+ if (i == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
+ AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
+ }
+ }
+
+ @Override
+ public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ }
+ });
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java
index 79cd7c00..b2c6096b 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenActivity.java
@@ -99,150 +99,144 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == done_button) {
- if (getParentActivity() == null) {
- return;
- }
-
- if (currentType != 0) {
- final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
- boolean showed = preferences.getBoolean("privacyAlertShowed", false);
- if (!showed) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- applyCurrentPrivacySettings();
- preferences.edit().putBoolean("privacyAlertShowed", true).commit();
- }
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- return;
- }
- }
- applyCurrentPrivacySettings();
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == done_button) {
+ if (getParentActivity() == null) {
+ return;
}
- }
- });
- ActionBarMenu menu = actionBar.createMenu();
- doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- doneButton.setVisibility(View.GONE);
-
- listAdapter = new ListAdapter(getParentActivity());
-
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
- frameLayout.setBackgroundColor(0xfff0f0f0);
-
- ListView listView = new ListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDrawSelectorOnTop(true);
- frameLayout.addView(listView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(listAdapter);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
- if (i == nobodyRow || i == everybodyRow || i == myContactsRow) {
- int newType = currentType;
- if (i == nobodyRow) {
- newType = 1;
- } else if (i == everybodyRow) {
- newType = 0;
- } else if (i == myContactsRow) {
- newType = 2;
- }
- if (newType == currentType) {
+ if (currentType != 0) {
+ final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
+ boolean showed = preferences.getBoolean("privacyAlertShowed", false);
+ if (!showed) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp));
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ applyCurrentPrivacySettings();
+ preferences.edit().putBoolean("privacyAlertShowed", true).commit();
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
return;
}
- doneButton.setVisibility(View.VISIBLE);
- currentType = newType;
- updateRows();
- } else if (i == neverShareRow || i == alwaysShareRow) {
- ArrayList createFromArray = null;
- if (i == neverShareRow) {
- createFromArray = currentMinus;
- } else {
- createFromArray = currentPlus;
- }
- if (createFromArray.isEmpty()) {
- Bundle args = new Bundle();
- args.putBoolean(i == neverShareRow ? "isNeverShare" : "isAlwaysShare", true);
- GroupCreateActivity fragment = new GroupCreateActivity(args);
- fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
- @Override
- public void didSelectUsers(ArrayList ids) {
- if (i == neverShareRow) {
- currentMinus = ids;
+ }
+ applyCurrentPrivacySettings();
+ }
+ }
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+ doneButton.setVisibility(View.GONE);
+
+ listAdapter = new ListAdapter(context);
+
+ fragmentView = new FrameLayout(context);
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
+ frameLayout.setBackgroundColor(0xfff0f0f0);
+
+ ListView listView = new ListView(context);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDrawSelectorOnTop(true);
+ frameLayout.addView(listView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ listView.setLayoutParams(layoutParams);
+ listView.setAdapter(listAdapter);
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
+ if (i == nobodyRow || i == everybodyRow || i == myContactsRow) {
+ int newType = currentType;
+ if (i == nobodyRow) {
+ newType = 1;
+ } else if (i == everybodyRow) {
+ newType = 0;
+ } else if (i == myContactsRow) {
+ newType = 2;
+ }
+ if (newType == currentType) {
+ return;
+ }
+ doneButton.setVisibility(View.VISIBLE);
+ currentType = newType;
+ updateRows();
+ } else if (i == neverShareRow || i == alwaysShareRow) {
+ ArrayList createFromArray = null;
+ if (i == neverShareRow) {
+ createFromArray = currentMinus;
+ } else {
+ createFromArray = currentPlus;
+ }
+ if (createFromArray.isEmpty()) {
+ Bundle args = new Bundle();
+ args.putBoolean(i == neverShareRow ? "isNeverShare" : "isAlwaysShare", true);
+ GroupCreateActivity fragment = new GroupCreateActivity(args);
+ fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
+ @Override
+ public void didSelectUsers(ArrayList ids) {
+ if (i == neverShareRow) {
+ currentMinus = ids;
+ for (Integer id : currentMinus) {
+ currentPlus.remove(id);
+ }
+ } else {
+ currentPlus = ids;
+ for (Integer id : currentPlus) {
+ currentMinus.remove(id);
+ }
+ }
+ doneButton.setVisibility(View.VISIBLE);
+ listAdapter.notifyDataSetChanged();
+ }
+ });
+ presentFragment(fragment);
+ } else {
+ LastSeenUsersActivity fragment = new LastSeenUsersActivity(createFromArray, i == alwaysShareRow);
+ fragment.setDelegate(new LastSeenUsersActivity.LastSeenUsersActivityDelegate() {
+ @Override
+ public void didUpdatedUserList(ArrayList ids, boolean added) {
+ if (i == neverShareRow) {
+ currentMinus = ids;
+ if (added) {
for (Integer id : currentMinus) {
currentPlus.remove(id);
}
- } else {
- currentPlus = ids;
+ }
+ } else {
+ currentPlus = ids;
+ if (added) {
for (Integer id : currentPlus) {
currentMinus.remove(id);
}
}
- doneButton.setVisibility(View.VISIBLE);
- listAdapter.notifyDataSetChanged();
}
- });
- presentFragment(fragment);
- } else {
- LastSeenUsersActivity fragment = new LastSeenUsersActivity(createFromArray, i == alwaysShareRow);
- fragment.setDelegate(new LastSeenUsersActivity.LastSeenUsersActivityDelegate() {
- @Override
- public void didUpdatedUserList(ArrayList ids, boolean added) {
- if (i == neverShareRow) {
- currentMinus = ids;
- if (added) {
- for (Integer id : currentMinus) {
- currentPlus.remove(id);
- }
- }
- } else {
- currentPlus = ids;
- if (added) {
- for (Integer id : currentPlus) {
- currentMinus.remove(id);
- }
- }
- }
- doneButton.setVisibility(View.VISIBLE);
- listAdapter.notifyDataSetChanged();
- }
- });
- presentFragment(fragment);
- }
+ doneButton.setVisibility(View.VISIBLE);
+ listAdapter.notifyDataSetChanged();
+ }
+ });
+ presentFragment(fragment);
}
}
- });
- } else {
- ViewGroup parent = (ViewGroup) fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
}
- }
+ });
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java
index db8badfc..a0ce4a77 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LastSeenUsersActivity.java
@@ -75,127 +75,121 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- if (isAlwaysShare) {
- actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
- } else {
- actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
- }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == block_user) {
- Bundle args = new Bundle();
- args.putBoolean(isAlwaysShare ? "isAlwaysShare" : "isNeverShare", true);
- GroupCreateActivity fragment = new GroupCreateActivity(args);
- fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
- @Override
- public void didSelectUsers(ArrayList ids) {
- for (Integer id : ids) {
- if (uidArray.contains(id)) {
- continue;
- }
- uidArray.add(id);
- }
- listViewAdapter.notifyDataSetChanged();
- if (delegate != null) {
- delegate.didUpdatedUserList(uidArray, true);
- }
- }
- });
- presentFragment(fragment);
- }
- }
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItem(block_user, R.drawable.plus);
-
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
-
- TextView emptyTextView = new TextView(getParentActivity());
- emptyTextView.setTextColor(0xff808080);
- emptyTextView.setTextSize(20);
- emptyTextView.setGravity(Gravity.CENTER);
- emptyTextView.setVisibility(View.INVISIBLE);
- emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
- frameLayout.addView(emptyTextView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- emptyTextView.setLayoutParams(layoutParams);
- emptyTextView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
-
- listView = new ListView(getParentActivity());
- listView.setEmptyView(emptyTextView);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity()));
- if (Build.VERSION.SDK_INT >= 11) {
- listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
- }
- frameLayout.addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
-
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
- if (i < uidArray.size()) {
- Bundle args = new Bundle();
- args.putInt("user_id", uidArray.get(i));
- presentFragment(new ProfileActivity(args));
- }
- }
- });
-
- listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
- if (i < 0 || i >= uidArray.size() || getParentActivity() == null) {
- return true;
- }
- selectedUserId = uidArray.get(i);
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- CharSequence[] items = new CharSequence[] {LocaleController.getString("Delete", R.string.Delete)};
- builder.setItems(items, new DialogInterface.OnClickListener() {
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ if (isAlwaysShare) {
+ actionBar.setTitle(LocaleController.getString("AlwaysShareWithTitle", R.string.AlwaysShareWithTitle));
+ } else {
+ actionBar.setTitle(LocaleController.getString("NeverShareWithTitle", R.string.NeverShareWithTitle));
+ }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == block_user) {
+ Bundle args = new Bundle();
+ args.putBoolean(isAlwaysShare ? "isAlwaysShare" : "isNeverShare", true);
+ GroupCreateActivity fragment = new GroupCreateActivity(args);
+ fragment.setDelegate(new GroupCreateActivity.GroupCreateActivityDelegate() {
@Override
- public void onClick(DialogInterface dialogInterface, int i) {
- if (i == 0) {
- uidArray.remove((Integer)selectedUserId);
- listViewAdapter.notifyDataSetChanged();
- if (delegate != null) {
- delegate.didUpdatedUserList(uidArray, false);
+ public void didSelectUsers(ArrayList ids) {
+ for (Integer id : ids) {
+ if (uidArray.contains(id)) {
+ continue;
}
+ uidArray.add(id);
+ }
+ listViewAdapter.notifyDataSetChanged();
+ if (delegate != null) {
+ delegate.didUpdatedUserList(uidArray, true);
}
}
});
- showAlertDialog(builder);
+ presentFragment(fragment);
+ }
+ }
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItem(block_user, R.drawable.plus);
+
+ fragmentView = new FrameLayout(context);
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
+
+ TextView emptyTextView = new TextView(context);
+ emptyTextView.setTextColor(0xff808080);
+ emptyTextView.setTextSize(20);
+ emptyTextView.setGravity(Gravity.CENTER);
+ emptyTextView.setVisibility(View.INVISIBLE);
+ emptyTextView.setText(LocaleController.getString("NoContacts", R.string.NoContacts));
+ frameLayout.addView(emptyTextView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) emptyTextView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ emptyTextView.setLayoutParams(layoutParams);
+ emptyTextView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ listView = new ListView(context);
+ listView.setEmptyView(emptyTextView);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setAdapter(listViewAdapter = new ListAdapter(context));
+ if (Build.VERSION.SDK_INT >= 11) {
+ listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
+ }
+ frameLayout.addView(listView);
+ layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
+ if (i < uidArray.size()) {
+ Bundle args = new Bundle();
+ args.putInt("user_id", uidArray.get(i));
+ presentFragment(new ProfileActivity(args));
+ }
+ }
+ });
+
+ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView> adapterView, View view, int i, long l) {
+ if (i < 0 || i >= uidArray.size() || getParentActivity() == null) {
return true;
}
- });
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
+ selectedUserId = uidArray.get(i);
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ CharSequence[] items = new CharSequence[]{LocaleController.getString("Delete", R.string.Delete)};
+ builder.setItems(items, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ if (i == 0) {
+ uidArray.remove((Integer) selectedUserId);
+ listViewAdapter.notifyDataSetChanged();
+ if (delegate != null) {
+ delegate.didUpdatedUserList(uidArray, false);
+ }
+ }
+ }
+ });
+ showAlertDialog(builder);
+ return true;
}
- }
+ });
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
index d71270a3..4dfecf4a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
@@ -22,7 +22,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.provider.ContactsContract;
-import android.util.Log;
import android.view.ActionMode;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -39,27 +38,26 @@ import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
-import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat;
-import org.telegram.android.ContactsController;
+import org.telegram.android.AndroidUtilities;
+import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController;
import org.telegram.android.MessagesStorage;
+import org.telegram.android.NotificationCenter;
import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
-import org.telegram.android.LocaleController;
-import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
-import org.telegram.ui.Adapters.DrawerLayoutAdapter;
import org.telegram.ui.ActionBar.ActionBarLayout;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.DrawerLayoutContainer;
+import org.telegram.ui.Adapters.DrawerLayoutAdapter;
import org.telegram.ui.Components.PasscodeView;
import java.io.BufferedReader;
@@ -110,7 +108,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication();
- if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
+ if (!UserConfig.isClientActivated()) {
Intent intent = getIntent();
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
super.onCreate(savedInstanceState);
@@ -211,7 +209,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
int viewX = location[0];
int viewY = location[1];
- if (x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
+ if (layersActionBarLayout.checkTransitionAnimation() || x > viewX && x < viewX + layersActionBarLayout.getWidth() && y > viewY && y < viewY + layersActionBarLayout.getHeight()) {
return false;
} else {
if (!layersActionBarLayout.fragmentsStack.isEmpty()) {
@@ -362,7 +360,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
NotificationCenter.getInstance().addObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
- NotificationCenter.getInstance().addObserver(this, NotificationCenter.needPasswordEnter);
if (Build.VERSION.SDK_INT < 14) {
NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged);
} else {
@@ -370,17 +367,12 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
if (actionBarLayout.fragmentsStack.isEmpty()) {
- if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
+ if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else {
- if (UserConfig.isWaitingForPasswordEnter()) {
- actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
- drawerLayoutContainer.setAllowOpenDrawer(false, false);
- } else {
- actionBarLayout.addFragmentToStack(new MessagesActivity(null));
- drawerLayoutContainer.setAllowOpenDrawer(true, false);
- }
+ actionBarLayout.addFragmentToStack(new MessagesActivity(null));
+ drawerLayoutContainer.setAllowOpenDrawer(true, false);
}
try {
@@ -438,7 +430,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else {
allowOpen = actionBarLayout.fragmentsStack.size() <= 1;
}
- if (actionBarLayout.fragmentsStack.size() == 1 && (actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity || actionBarLayout.fragmentsStack.get(0) instanceof AccountPasswordActivity)) {
+ if (actionBarLayout.fragmentsStack.size() == 1 && actionBarLayout.fragmentsStack.get(0) instanceof LoginActivity) {
allowOpen = false;
}
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
@@ -503,7 +495,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
documentsUrisArray = null;
contactsToSend = null;
- if (UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter() && (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
+ if (UserConfig.isClientActivated() && (flags & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
if (intent != null && intent.getAction() != null && !restore) {
if (Intent.ACTION_SEND.equals(intent.getAction())) {
boolean error = false;
@@ -891,35 +883,25 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (!pushOpened && !isNew) {
if (AndroidUtilities.isTablet()) {
- if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
+ if (!UserConfig.isClientActivated()) {
if (layersActionBarLayout.fragmentsStack.isEmpty()) {
layersActionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false);
}
} else {
if (actionBarLayout.fragmentsStack.isEmpty()) {
- if (UserConfig.isWaitingForPasswordEnter()) {
- layersActionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
- drawerLayoutContainer.setAllowOpenDrawer(false, false);
- } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
- drawerLayoutContainer.setAllowOpenDrawer(true, false);
+ drawerLayoutContainer.setAllowOpenDrawer(true, false);
}
}
- }
- } else {
- if (actionBarLayout.fragmentsStack.isEmpty()) {
- if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) {
+ } else {
+ if (actionBarLayout.fragmentsStack.isEmpty()) {
+ if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else {
- if (UserConfig.isWaitingForPasswordEnter()) {
- actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
- drawerLayoutContainer.setAllowOpenDrawer(false, false);
- } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null));
- drawerLayoutContainer.setAllowOpenDrawer(true, false);
- }
+ drawerLayoutContainer.setAllowOpenDrawer(true, false);
}
}
}
@@ -1028,7 +1010,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
- NotificationCenter.getInstance().removeObserver(this, NotificationCenter.needPasswordEnter);
if (Build.VERSION.SDK_INT < 14) {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenStateChanged);
} else {
@@ -1245,28 +1226,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
} else if (id == NotificationCenter.mainUserInfoChanged) {
drawerLayoutAdapter.notifyDataSetChanged();
- } else if (id == NotificationCenter.needPasswordEnter) {
- if (AndroidUtilities.isTablet()) {
- for (int a = 0; a < layersActionBarLayout.fragmentsStack.size() - 1; a++) {
- layersActionBarLayout.removeFragmentFromStack(layersActionBarLayout.fragmentsStack.get(0));
- a--;
- }
- for (int a = 0; a < actionBarLayout.fragmentsStack.size() - 1; a++) {
- actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(0));
- a--;
- }
- rightActionBarLayout.closeLastFragment(false);
- actionBarLayout.closeLastFragment(false);
- layersActionBarLayout.presentFragment(new AccountPasswordActivity(1), false, true, true);
- drawerLayoutContainer.setAllowOpenDrawer(false, false);
- } else {
- for (int a = 0; a < actionBarLayout.fragmentsStack.size() - 1; a++) {
- actionBarLayout.removeFragmentFromStack(actionBarLayout.fragmentsStack.get(0));
- a--;
- }
- actionBarLayout.presentFragment(new AccountPasswordActivity(1), true);
- drawerLayoutContainer.setAllowOpenDrawer(false, false);
- }
} else if (id == NotificationCenter.screenStateChanged) {
if (!ApplicationLoader.mainInterfacePaused) {
if (!ApplicationLoader.isScreenOn) {
@@ -1479,7 +1438,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
if (AndroidUtilities.isTablet()) {
- drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof AccountPasswordActivity) && !(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
+ drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
@@ -1548,7 +1507,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false, true);
- if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
+ if (fragment instanceof LoginActivity) {
backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000);
@@ -1560,7 +1519,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
return true;
} else {
- drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false);
+ drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false);
return true;
}
}
@@ -1568,7 +1527,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
if (AndroidUtilities.isTablet()) {
- drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
+ drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && layersActionBarLayout.getVisibility() != View.VISIBLE, true);
if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
@@ -1613,7 +1572,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false, true);
- if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) {
+ if (fragment instanceof LoginActivity) {
backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000);
@@ -1625,7 +1584,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
}
return true;
} else {
- drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false);
+ drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false);
return true;
}
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java
index e9c476fe..21004481 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LocationActivity.java
@@ -13,14 +13,12 @@ import android.location.Location;
import android.location.LocationManager;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
-
import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
@@ -29,24 +27,25 @@ import com.google.android.gms.maps.model.MarkerOptions;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
-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.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView;
-import org.telegram.ui.ActionBar.BaseFragment;
import java.util.List;
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
+
private GoogleMap googleMap;
private TextView distanceTextView;
private Marker userMarker;
@@ -88,170 +87,159 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (mapView != null) {
mapView.onDestroy();
}
- if (avatarImageView != null) {
- avatarImageView.setImageDrawable(null);
- }
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- if (messageObject != null) {
- actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
- } else {
- actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
- }
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ if (messageObject != null) {
+ actionBar.setTitle(LocaleController.getString("ChatLocation", R.string.ChatLocation));
+ } else {
+ actionBar.setTitle(LocaleController.getString("ShareLocation", R.string.ShareLocation));
+ }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == map_list_menu_map) {
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == map_list_menu_map) {
+ if (googleMap != null) {
+ googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
+ }
+ } else if (id == map_list_menu_satellite) {
+ if (googleMap != null) {
+ googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
+ }
+ } else if (id == map_list_menu_hybrid) {
+ if (googleMap != null) {
+ googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
+ }
+ } else if (id == map_to_my_location) {
+ if (myLocation != null) {
+ LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
if (googleMap != null) {
- googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
- }
- } else if (id == map_list_menu_satellite) {
- if (googleMap != null) {
- googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
- }
- } else if (id == map_list_menu_hybrid) {
- if (googleMap != null) {
- googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
- }
- } else if (id == map_to_my_location) {
- if (myLocation != null) {
- LatLng latLng = new LatLng(myLocation.getLatitude(), myLocation.getLongitude());
- if (googleMap != null) {
- CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
- googleMap.animateCamera(position);
- }
+ CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
+ googleMap.animateCamera(position);
}
}
}
+ }
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItem(map_to_my_location, R.drawable.ic_ab_location);
+
+ ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
+ item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0);
+ item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0);
+ item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0);
+
+ if (messageObject != null) {
+ fragmentView = inflater.inflate(R.layout.location_view_layout, null, false);
+ } else {
+ fragmentView = inflater.inflate(R.layout.location_attach_layout, null, false);
+ }
+
+ avatarImageView = (BackupImageView) fragmentView.findViewById(R.id.location_avatar_view);
+ if (avatarImageView != null) {
+ avatarImageView.setRoundRadius(AndroidUtilities.dp(32));
+ }
+ nameTextView = (TextView) fragmentView.findViewById(R.id.location_name_label);
+ distanceTextView = (TextView) fragmentView.findViewById(R.id.location_distance_label);
+ View bottomView = fragmentView.findViewById(R.id.location_bottom_view);
+ TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button);
+ if (sendButton != null) {
+ sendButton.setText(LocaleController.getString("SendLocation", R.string.SendLocation).toUpperCase());
+ sendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ }
+
+ mapView = (MapView) fragmentView.findViewById(R.id.map_view);
+ mapView.onCreate(null);
+ try {
+ MapsInitializer.initialize(context);
+ googleMap = mapView.getMap();
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+
+ if (googleMap != null) {
+ googleMap.setMyLocationEnabled(true);
+ googleMap.getUiSettings().setMyLocationButtonEnabled(false);
+ googleMap.getUiSettings().setZoomControlsEnabled(false);
+ googleMap.getUiSettings().setCompassEnabled(false);
+ googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
+ @Override
+ public void onMyLocationChange(Location location) {
+ positionMarker(location);
+ }
});
+ myLocation = getLastLocation();
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItem(map_to_my_location, R.drawable.ic_ab_location);
-
- ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
- item.addSubItem(map_list_menu_map, LocaleController.getString("Map", R.string.Map), 0);
- item.addSubItem(map_list_menu_satellite, LocaleController.getString("Satellite", R.string.Satellite), 0);
- item.addSubItem(map_list_menu_hybrid, LocaleController.getString("Hybrid", R.string.Hybrid), 0);
-
- if (messageObject != null) {
- fragmentView = inflater.inflate(R.layout.location_view_layout, null, false);
- } else {
- fragmentView = inflater.inflate(R.layout.location_attach_layout, null, false);
- }
-
- avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view);
- if (avatarImageView != null) {
- avatarImageView.processDetach = false;
- avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
- }
- nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label);
- distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label);
- View bottomView = fragmentView.findViewById(R.id.location_bottom_view);
- TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button);
if (sendButton != null) {
- sendButton.setText(LocaleController.getString("SendLocation", R.string.SendLocation).toUpperCase());
- sendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- }
+ userLocation = new Location("network");
+ userLocation.setLatitude(20.659322);
+ userLocation.setLongitude(-11.406250);
+ LatLng latLng = new LatLng(20.659322, -11.406250);
+ userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)).draggable(true));
- mapView = (MapView)fragmentView.findViewById(R.id.map_view);
- mapView.onCreate(null);
- try {
- MapsInitializer.initialize(getParentActivity());
- googleMap = mapView.getMap();
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
-
- if (googleMap != null) {
- googleMap.setMyLocationEnabled(true);
- googleMap.getUiSettings().setMyLocationButtonEnabled(false);
- googleMap.getUiSettings().setZoomControlsEnabled(false);
- googleMap.getUiSettings().setCompassEnabled(false);
- googleMap.setOnMyLocationChangeListener(new GoogleMap.OnMyLocationChangeListener() {
+ sendButton.setOnClickListener(new View.OnClickListener() {
@Override
- public void onMyLocationChange(Location location) {
- positionMarker(location);
+ public void onClick(View view) {
+ if (delegate != null) {
+ delegate.didSelectLocation(userLocation.getLatitude(), userLocation.getLongitude());
+ }
+ finishFragment();
}
});
- myLocation = getLastLocation();
- if (sendButton != null) {
- userLocation = new Location("network");
- userLocation.setLatitude(20.659322);
- userLocation.setLongitude(-11.406250);
- LatLng latLng = new LatLng(20.659322, -11.406250);
- userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)).draggable(true));
+ googleMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
+ @Override
+ public void onMarkerDragStart(Marker marker) {
+ }
- sendButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (delegate != null) {
- delegate.didSelectLocation(userLocation.getLatitude(), userLocation.getLongitude());
- }
- finishFragment();
- }
- });
+ @Override
+ public void onMarkerDrag(Marker marker) {
+ userLocationMoved = true;
+ }
- googleMap.setOnMarkerDragListener(new GoogleMap.OnMarkerDragListener() {
- @Override
- public void onMarkerDragStart(Marker marker) {
- }
-
- @Override
- public void onMarkerDrag(Marker marker) {
- userLocationMoved = true;
- }
-
- @Override
- public void onMarkerDragEnd(Marker marker) {
- LatLng latLng = marker.getPosition();
- userLocation.setLatitude(latLng.latitude);
- userLocation.setLongitude(latLng.longitude);
- }
- });
- }
-
- if (bottomView != null) {
- bottomView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (userLocation != null) {
- LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
- CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
- googleMap.animateCamera(position);
- }
- }
- });
- }
-
- if (messageObject != null) {
- updateUserData();
- userLocation = new Location("network");
- userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
- userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
- LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
- userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).
- icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
- CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
- googleMap.moveCamera(position);
- }
-
- positionMarker(myLocation);
+ @Override
+ public void onMarkerDragEnd(Marker marker) {
+ LatLng latLng = marker.getPosition();
+ userLocation.setLatitude(latLng.latitude);
+ userLocation.setLongitude(latLng.longitude);
+ }
+ });
}
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
+
+ if (bottomView != null) {
+ bottomView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (userLocation != null) {
+ LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
+ CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
+ googleMap.animateCamera(position);
+ }
+ }
+ });
}
+
+ if (messageObject != null) {
+ userLocation = new Location("network");
+ userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
+ userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
+ LatLng latLng = new LatLng(userLocation.getLatitude(), userLocation.getLongitude());
+ userMarker = googleMap.addMarker(new MarkerOptions().position(latLng).
+ icon(BitmapDescriptorFactory.fromResource(R.drawable.map_pin)));
+ CameraUpdate position = CameraUpdateFactory.newLatLngZoom(latLng, googleMap.getMaxZoomLevel() - 8);
+ googleMap.moveCamera(position);
+ }
+
+ positionMarker(myLocation);
}
+
return fragmentView;
}
@@ -297,7 +285,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (userLocation != null && distanceTextView != null) {
float distance = location.distanceTo(userLocation);
if (distance < 1000) {
- distanceTextView.setText(String.format("%d %s", (int)(distance), LocaleController.getString("MetersAway", R.string.MetersAway)));
+ distanceTextView.setText(String.format("%d %s", (int) (distance), LocaleController.getString("MetersAway", R.string.MetersAway)));
} else {
distanceTextView.setText(String.format("%.2f %s", distance / 1000.0f, LocaleController.getString("KMetersAway", R.string.KMetersAway)));
}
@@ -326,7 +314,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
@Override
public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
- int mask = (Integer)args[0];
+ int mask = (Integer) args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateUserData();
}
@@ -353,6 +341,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (mapView != null) {
mapView.onResume();
}
+ updateUserData();
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
index 754f8c83..a035967f 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
@@ -17,8 +17,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.graphics.PorterDuff;
+import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
+import android.os.Vibrator;
import android.telephony.TelephonyManager;
import android.text.Editable;
import android.text.InputFilter;
@@ -27,12 +29,12 @@ import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextWatcher;
+import android.text.method.PasswordTransformationMethod;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.inputmethod.EditorInfo;
@@ -46,6 +48,7 @@ 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;
@@ -53,7 +56,6 @@ 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;
@@ -81,7 +83,7 @@ import java.util.TimerTask;
public class LoginActivity extends BaseFragment {
private int currentViewNum = 0;
- private SlideView[] views = new SlideView[3];
+ private SlideView[] views = new SlideView[5];
private ProgressDialog progressDialog;
private final static int done_button = 1;
@@ -105,8 +107,7 @@ public class LoginActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@@ -114,6 +115,8 @@ public class LoginActivity extends BaseFragment {
public void onItemClick(int id) {
if (id == done_button) {
views[currentViewNum].onNextPressed();
+ } else if (id == -1) {
+ onBackPressed();
}
}
});
@@ -121,11 +124,11 @@ public class LoginActivity extends BaseFragment {
ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
- fragmentView = new ScrollView(getParentActivity());
+ fragmentView = new ScrollView(context);
ScrollView scrollView = (ScrollView) fragmentView;
scrollView.setFillViewport(true);
- FrameLayout frameLayout = new FrameLayout(getParentActivity());
+ FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout);
ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT;
@@ -133,76 +136,43 @@ public class LoginActivity extends BaseFragment {
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
frameLayout.setLayoutParams(layoutParams);
- views[0] = new PhoneView(getParentActivity());
- views[0].setVisibility(View.VISIBLE);
- frameLayout.addView(views[0]);
- FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams();
+ views[0] = new PhoneView(context);
+ views[1] = new LoginActivitySmsView(context);
+ views[2] = new LoginActivityRegisterView(context);
+ views[3] = new LoginActivityPasswordView(context);
+ views[4] = new LoginActivityRecoverView(context);
+
+ for (int a = 0; a < 5; a++) {
+ views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
+ frameLayout.addView(views[a]);
+ FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[a].getLayoutParams();
layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.leftMargin = AndroidUtilities.dp(16);
- layoutParams1.rightMargin = AndroidUtilities.dp(16);
+ layoutParams1.height = a == 0 ? FrameLayout.LayoutParams.WRAP_CONTENT : FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams1.leftMargin = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
+ layoutParams1.rightMargin = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
layoutParams1.topMargin = AndroidUtilities.dp(30);
layoutParams1.gravity = Gravity.TOP | Gravity.LEFT;
- views[0].setLayoutParams(layoutParams1);
-
- views[1] = new LoginActivitySmsView(getParentActivity());
- views[1].setVisibility(View.GONE);
- frameLayout.addView(views[1]);
- layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams();
- layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.leftMargin = AndroidUtilities.dp(16);
- layoutParams1.rightMargin = AndroidUtilities.dp(16);
- layoutParams1.topMargin = AndroidUtilities.dp(30);
- layoutParams1.gravity = Gravity.TOP | Gravity.LEFT;
- views[1].setLayoutParams(layoutParams1);
-
- views[2] = new RegisterView(getParentActivity());
- views[2].setVisibility(View.GONE);
- frameLayout.addView(views[2]);
- layoutParams1 = (FrameLayout.LayoutParams) views[2].getLayoutParams();
- layoutParams1.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams1.leftMargin = AndroidUtilities.dp(16);
- layoutParams1.rightMargin = AndroidUtilities.dp(16);
- layoutParams1.topMargin = AndroidUtilities.dp(30);
- layoutParams1.gravity = Gravity.TOP | Gravity.LEFT;
- views[2].setLayoutParams(layoutParams1);
-
- try {
- if (views[0] == null || views[1] == null || views[2] == null) {
- FrameLayout parent = (FrameLayout)((ScrollView) fragmentView).getChildAt(0);
- for (int a = 0; a < views.length; a++) {
- if (views[a] == null) {
- views[a] = (SlideView)parent.getChildAt(a);
- }
- }
- }
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
-
- actionBar.setTitle(views[0].getHeaderName());
-
- Bundle savedInstanceState = loadCurrentState();
- if (savedInstanceState != null) {
- currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
- }
- for (int a = 0; a < views.length; a++) {
- SlideView v = views[a];
- if (v != null) {
- if (savedInstanceState != null) {
- v.restoreStateParams(savedInstanceState);
- }
- v.setVisibility(currentViewNum == a ? View.VISIBLE : View.GONE);
- }
- }
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ views[a].setLayoutParams(layoutParams1);
}
+
+ Bundle savedInstanceState = loadCurrentState();
+ if (savedInstanceState != null) {
+ currentViewNum = savedInstanceState.getInt("currentViewNum", 0);
+ }
+ actionBar.setTitle(views[currentViewNum].getHeaderName());
+ for (int a = 0; a < views.length; a++) {
+ if (savedInstanceState != null) {
+ views[a].restoreStateParams(savedInstanceState);
+ }
+ if (currentViewNum == a) {
+ actionBar.setBackButtonImage(views[a].needBackButton() ? R.drawable.ic_ab_back : 0);
+ views[a].setVisibility(View.VISIBLE);
+ views[a].onShow();
+ } else {
+ views[a].setVisibility(View.GONE);
+ }
+ }
+
return fragmentView;
}
@@ -281,7 +251,7 @@ public class LoginActivity extends BaseFragment {
editor.putInt(key, (Integer) obj);
}
} else if (obj instanceof Bundle) {
- putBundleToEditor((Bundle)obj, editor, key);
+ putBundleToEditor((Bundle) obj, editor, key);
}
}
}
@@ -296,18 +266,22 @@ public class LoginActivity extends BaseFragment {
}
clearCurrentState();
return true;
- } else if (currentViewNum != 1 && currentViewNum != 2) {
+ } else if (currentViewNum == 3) {
+ views[currentViewNum].onBackPressed();
setPage(0, true, null, true);
+ } else if (currentViewNum == 4) {
+ views[currentViewNum].onBackPressed();
+ setPage(3, true, null, true);
}
return false;
}
- public void needShowAlert(final String text) {
+ public void needShowAlert(String title, String text) {
if (text == null || getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setTitle(title);
builder.setMessage(text);
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
showAlertDialog(builder);
@@ -337,10 +311,11 @@ public class LoginActivity extends BaseFragment {
}
public void setPage(int page, boolean animated, Bundle params, boolean back) {
- if(android.os.Build.VERSION.SDK_INT > 13) {
+ if (android.os.Build.VERSION.SDK_INT > 13) {
final SlideView outView = views[currentViewNum];
final SlideView newView = views[page];
currentViewNum = page;
+ actionBar.setBackButtonImage(newView.needBackButton() ? R.drawable.ic_ab_back : 0);
newView.setParams(params);
actionBar.setTitle(newView.getHeaderName());
@@ -384,6 +359,7 @@ public class LoginActivity extends BaseFragment {
}
}).setDuration(300).translationX(0).start();
} else {
+ actionBar.setBackButtonImage(views[page].needBackButton() ? R.drawable.ic_ab_back : 0);
views[currentViewNum].setVisibility(View.GONE);
currentViewNum = page;
views[page].setParams(params);
@@ -416,13 +392,9 @@ public class LoginActivity extends BaseFragment {
public void needFinishActivity() {
clearCurrentState();
- if (UserConfig.isWaitingForPasswordEnter()) {
- presentFragment(new AccountPasswordActivity(1), true);
- } else {
presentFragment(new MessagesActivity(null), true);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.mainUserInfoChanged);
}
- }
public class PhoneView extends SlideView implements AdapterView.OnItemSelectedListener {
@@ -459,8 +431,6 @@ public class LoginActivity extends BaseFragment {
LayoutParams layoutParams = (LayoutParams) countryButton.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(20);
- layoutParams.rightMargin = AndroidUtilities.dp(20);
layoutParams.bottomMargin = AndroidUtilities.dp(14);
countryButton.setLayoutParams(layoutParams);
countryButton.setOnClickListener(new OnClickListener() {
@@ -485,9 +455,9 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) view.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = 1;
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.topMargin = AndroidUtilities.dp(-17.5f);
+ layoutParams.leftMargin = AndroidUtilities.dp(4);
+ layoutParams.rightMargin = AndroidUtilities.dp(4);
view.setLayoutParams(layoutParams);
LinearLayout linearLayout = new LinearLayout(context);
@@ -507,7 +477,6 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
- layoutParams.leftMargin = AndroidUtilities.dp(24);
textView.setLayoutParams(layoutParams);
codeField = new EditText(context);
@@ -600,7 +569,6 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) phoneField.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
phoneField.setLayoutParams(layoutParams);
phoneField.addTextChangedListener(new TextWatcher() {
@Override
@@ -618,7 +586,7 @@ public class LoginActivity extends BaseFragment {
int toDelete = 0;
for (int a = start; a >= 0; a--) {
substr = str.substring(a, a + 1);
- if(phoneChars.contains(substr)) {
+ if (phoneChars.contains(substr)) {
break;
}
toDelete++;
@@ -670,8 +638,6 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.topMargin = AndroidUtilities.dp(28);
layoutParams.bottomMargin = AndroidUtilities.dp(10);
layoutParams.gravity = Gravity.LEFT;
@@ -703,7 +669,7 @@ public class LoginActivity extends BaseFragment {
String country = null;
try {
- TelephonyManager telephonyManager = (TelephonyManager)ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
+ TelephonyManager telephonyManager = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
country = telephonyManager.getSimCountryIso().toUpperCase();
}
@@ -795,14 +761,14 @@ public class LoginActivity extends BaseFragment {
return;
}
if (countryState == 1) {
- needShowAlert(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
return;
} else if (countryState == 2 && !BuildVars.DEBUG_VERSION) {
- needShowAlert(LocaleController.getString("WrongCountry", R.string.WrongCountry));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("WrongCountry", R.string.WrongCountry));
return;
}
if (codeField.length() == 0) {
- needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
return;
}
TLRPC.TL_auth_sendCode req = new TLRPC.TL_auth_sendCode();
@@ -836,22 +802,22 @@ public class LoginActivity extends BaseFragment {
public void run() {
nextPressed = false;
if (error == null) {
- final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode)response;
+ final TLRPC.TL_auth_sentCode res = (TLRPC.TL_auth_sentCode) response;
params.putString("phoneHash", res.phone_code_hash);
params.putInt("calltime", res.send_call_timeout * 1000);
setPage(1, true, params, false);
} else {
if (error.text != null) {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
- needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("CodeExpired", R.string.CodeExpired));
} else if (error.text.startsWith("FLOOD_WAIT")) {
- needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("FloodWait", R.string.FloodWait));
} else if (error.code != -1000) {
- needShowAlert(error.text);
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
}
}
}
@@ -938,15 +904,15 @@ public class LoginActivity extends BaseFragment {
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.LEFT;
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
confirmTextView.setLayoutParams(layoutParams);
codeField = new EditText(context);
codeField.setTextColor(0xff212121);
codeField.setHint(LocaleController.getString("Code", R.string.Code));
AndroidUtilities.clearCursorDrawable(codeField);
- codeField.getBackground().setColorFilter(AndroidUtilities.getIntColor("themeColor"), PorterDuff.Mode.SRC_IN);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
+ codeField.getBackground().setColorFilter(defColor, PorterDuff.Mode.SRC_IN);
codeField.setHintTextColor(0xff979797);
codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
@@ -959,8 +925,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.height = AndroidUtilities.dp(36);
layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
layoutParams.topMargin = AndroidUtilities.dp(20);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
codeField.setLayoutParams(layoutParams);
codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
@@ -984,8 +948,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.LEFT;
layoutParams.topMargin = AndroidUtilities.dp(30);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
timeText.setLayoutParams(layoutParams);
problemText = new TextView(context);
@@ -994,7 +956,7 @@ public class LoginActivity extends BaseFragment {
problemText.setGravity(Gravity.LEFT);
problemText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
//problemText.setTextColor(0xff4d83b3);
- problemText.setTextColor(AndroidUtilities.getIntColor("themeColor"));
+ problemText.setTextColor(defColor);
problemText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
problemText.setPadding(0, AndroidUtilities.dp(2), 0, AndroidUtilities.dp(12));
addView(problemText);
@@ -1003,8 +965,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.LEFT;
layoutParams.topMargin = AndroidUtilities.dp(20);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
problemText.setLayoutParams(layoutParams);
problemText.setOnClickListener(new OnClickListener() {
@Override
@@ -1020,7 +980,7 @@ public class LoginActivity extends BaseFragment {
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);
getContext().startActivity(Intent.createChooser(mailer, "Send email..."));
} catch (Exception e) {
- needShowAlert(LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
}
}
});
@@ -1036,7 +996,7 @@ public class LoginActivity extends BaseFragment {
TextView wrongNumber = new TextView(context);
wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL);
//wrongNumber.setTextColor(0xff4d83b3);
- wrongNumber.setTextColor(AndroidUtilities.getIntColor("themeColor"));
+ wrongNumber.setTextColor(defColor);
wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0);
@@ -1046,8 +1006,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
layoutParams.bottomMargin = AndroidUtilities.dp(10);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
wrongNumber.setLayoutParams(layoutParams);
wrongNumber.setText(LocaleController.getString("WrongNumber", R.string.WrongNumber));
wrongNumber.setOnClickListener(new OnClickListener() {
@@ -1138,7 +1096,7 @@ public class LoginActivity extends BaseFragment {
private void destroyCodeTimer() {
try {
- synchronized(timerSync) {
+ synchronized (timerSync) {
if (codeTimer != null) {
codeTimer.cancel();
codeTimer = null;
@@ -1197,7 +1155,7 @@ public class LoginActivity extends BaseFragment {
private void destroyTimer() {
try {
- synchronized(timerSync) {
+ synchronized (timerSync) {
if (timeTimer != null) {
timeTimer.cancel();
timeTimer = null;
@@ -1229,10 +1187,10 @@ public class LoginActivity extends BaseFragment {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
- needHideProgress();
nextPressed = false;
if (error == null) {
- TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization)response;
+ needHideProgress();
+ TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response;
destroyTimer();
destroyCodeTimer();
UserConfig.clearConfig();
@@ -1258,6 +1216,7 @@ public class LoginActivity extends BaseFragment {
lastError = error.text;
if (error.text.contains("PHONE_NUMBER_UNOCCUPIED")) {
+ needHideProgress();
Bundle params = new Bundle();
params.putString("phoneFormated", requestPhone);
params.putString("phoneHash", phoneHash);
@@ -1266,21 +1225,47 @@ public class LoginActivity extends BaseFragment {
destroyTimer();
destroyCodeTimer();
} else if (error.text.contains("SESSION_PASSWORD_NEEDED")) {
- needFinishActivity();
+ TLRPC.TL_account_getPassword req2 = new TLRPC.TL_account_getPassword();
+ ConnectionsManager.getInstance().performRpc(req2, new RPCRequest.RPCRequestDelegate() {
+ @Override
+ public void run(final TLObject response, final TLRPC.TL_error error) {
+ AndroidUtilities.runOnUIThread(new Runnable() {
+ @Override
+ public void run() {
+ needHideProgress();
+ if (error == null) {
+ TLRPC.TL_account_password password = (TLRPC.TL_account_password) response;
+ Bundle bundle = new Bundle();
+ bundle.putString("current_salt", Utilities.bytesToHex(password.current_salt));
+ bundle.putString("hint", password.hint);
+ bundle.putString("email_unconfirmed_pattern", password.email_unconfirmed_pattern);
+ bundle.putString("phoneFormated", requestPhone);
+ bundle.putString("phoneHash", phoneHash);
+ bundle.putString("code", req.phone_code);
+ bundle.putInt("has_recovery", password.has_recovery ? 1 : 0);
+ setPage(3, true, bundle, false);
+ } else {
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
+ }
+ }
+ });
+ }
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
destroyTimer();
destroyCodeTimer();
} else {
+ needHideProgress();
createTimer();
if (error.text.contains("PHONE_NUMBER_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
- needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("CodeExpired", R.string.CodeExpired));
} else if (error.text.startsWith("FLOOD_WAIT")) {
- needShowAlert(LocaleController.getString("FloodWait", R.string.FloodWait));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("FloodWait", R.string.FloodWait));
} else {
- needShowAlert(error.text);
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
}
}
}
@@ -1368,7 +1353,635 @@ public class LoginActivity extends BaseFragment {
}
}
- public class RegisterView extends SlideView {
+ public class LoginActivityPasswordView extends SlideView {
+
+ private EditText codeField;
+ private TextView confirmTextView;
+ private TextView resetAccountButton;
+ private TextView resetAccountText;
+
+ private Bundle currentParams;
+ private boolean nextPressed;
+ private byte[] current_salt;
+ private String hint;
+ private String email_unconfirmed_pattern;
+ private boolean has_recovery;
+ private String requestPhone;
+ private String phoneHash;
+ private String phoneCode;
+
+ public LoginActivityPasswordView(Context context) {
+ super(context);
+
+ setOrientation(VERTICAL);
+
+ confirmTextView = new TextView(context);
+ confirmTextView.setTextColor(0xff757575);
+ confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ confirmTextView.setGravity(Gravity.LEFT);
+ confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ confirmTextView.setText(LocaleController.getString("LoginPasswordText", R.string.LoginPasswordText));
+ addView(confirmTextView);
+ LayoutParams layoutParams = (LayoutParams) confirmTextView.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.LEFT;
+ confirmTextView.setLayoutParams(layoutParams);
+
+ codeField = new EditText(context);
+ codeField.setTextColor(0xff212121);
+ AndroidUtilities.clearCursorDrawable(codeField);
+ codeField.setHintTextColor(0xff979797);
+ codeField.setHint(LocaleController.getString("LoginPassword", R.string.LoginPassword));
+ codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
+ codeField.setMaxLines(1);
+ codeField.setPadding(0, 0, 0, 0);
+ codeField.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
+ codeField.setTransformationMethod(PasswordTransformationMethod.getInstance());
+ codeField.setTypeface(Typeface.DEFAULT);
+ addView(codeField);
+ layoutParams = (LayoutParams) codeField.getLayoutParams();
+ layoutParams.width = LayoutParams.MATCH_PARENT;
+ layoutParams.height = AndroidUtilities.dp(36);
+ layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
+ layoutParams.topMargin = AndroidUtilities.dp(20);
+ codeField.setLayoutParams(layoutParams);
+ codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+ if (i == EditorInfo.IME_ACTION_NEXT) {
+ onNextPressed();
+ return true;
+ }
+ return false;
+ }
+ });
+
+ TextView cancelButton = new TextView(context);
+ cancelButton.setGravity(Gravity.LEFT | Gravity.TOP);
+ cancelButton.setTextColor(0xff4d83b3);
+ cancelButton.setText(LocaleController.getString("ForgotPassword", R.string.ForgotPassword));
+ cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ cancelButton.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ cancelButton.setPadding(0, AndroidUtilities.dp(14), 0, 0);
+ addView(cancelButton);
+ layoutParams = (LayoutParams) cancelButton.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ cancelButton.setLayoutParams(layoutParams);
+ cancelButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (has_recovery) {
+ needShowProgress();
+ TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery();
+ 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() {
+ needHideProgress();
+ if (error == null) {
+ final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response;
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.formatString("RestoreEmailSent", R.string.RestoreEmailSent, res.email_pattern));
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ Bundle bundle = new Bundle();
+ bundle.putString("email_unconfirmed_pattern", res.email_pattern);
+ setPage(4, true, bundle, false);
+ }
+ });
+ AlertDialog dialog = showAlertDialog(builder);
+ if (dialog != null) {
+ dialog.setCanceledOnTouchOutside(false);
+ dialog.setCancelable(false);
+ }
+ } else {
+ if (error.text.startsWith("FLOOD_WAIT")) {
+ int time = Utilities.parseInt(error.text);
+ String timeString;
+ if (time < 60) {
+ timeString = LocaleController.formatPluralString("Seconds", time);
+ } else {
+ timeString = LocaleController.formatPluralString("Minutes", time / 60);
+ }
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
+ } else {
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
+ }
+ }
+ }
+ });
+ }
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
+ } else {
+ resetAccountText.setVisibility(VISIBLE);
+ resetAccountButton.setVisibility(VISIBLE);
+ AndroidUtilities.hideKeyboard(codeField);
+ needShowAlert(LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestorePasswordNoEmailText", R.string.RestorePasswordNoEmailText));
+ }
+ }
+ });
+
+ resetAccountButton = new TextView(context);
+ resetAccountButton.setGravity(Gravity.LEFT | Gravity.TOP);
+ resetAccountButton.setTextColor(0xffff6666);
+ resetAccountButton.setVisibility(GONE);
+ resetAccountButton.setText(LocaleController.getString("ResetMyAccount", R.string.ResetMyAccount));
+ resetAccountButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ resetAccountButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ resetAccountButton.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ resetAccountButton.setPadding(0, AndroidUtilities.dp(14), 0, 0);
+ addView(resetAccountButton);
+ layoutParams = (LayoutParams) resetAccountButton.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ layoutParams.topMargin = AndroidUtilities.dp(34);
+ resetAccountButton.setLayoutParams(layoutParams);
+ resetAccountButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.getString("ResetMyAccountWarningText", R.string.ResetMyAccountWarningText));
+ builder.setTitle(LocaleController.getString("ResetMyAccountWarning", R.string.ResetMyAccountWarning));
+ builder.setPositiveButton(LocaleController.getString("ResetMyAccountWarningReset", R.string.ResetMyAccountWarningReset), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ needShowProgress();
+ TLRPC.TL_account_deleteAccount req = new TLRPC.TL_account_deleteAccount();
+ req.reason = "Forgot password";
+ 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() {
+ needHideProgress();
+ if (error == null) {
+ Bundle params = new Bundle();
+ params.putString("phoneFormated", requestPhone);
+ params.putString("phoneHash", phoneHash);
+ params.putString("code", phoneCode);
+ setPage(2, true, params, false);
+ } else {
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
+ }
+ }
+ });
+ }
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin | RPCRequest.RPCRequestClassFailOnServerErrors);
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ }
+ });
+
+ resetAccountText = new TextView(context);
+ resetAccountText.setGravity(Gravity.LEFT | Gravity.TOP);
+ resetAccountText.setVisibility(GONE);
+ resetAccountText.setTextColor(0xff757575);
+ resetAccountText.setText(LocaleController.getString("ResetMyAccountText", R.string.ResetMyAccountText));
+ resetAccountText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ resetAccountText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ addView(resetAccountText);
+ layoutParams = (LayoutParams) resetAccountText.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ layoutParams.bottomMargin = AndroidUtilities.dp(14);
+ layoutParams.topMargin = AndroidUtilities.dp(7);
+ resetAccountText.setLayoutParams(layoutParams);
+ }
+
+ @Override
+ public String getHeaderName() {
+ return LocaleController.getString("LoginPassword", R.string.LoginPassword);
+ }
+
+ @Override
+ public void setParams(Bundle params) {
+ if (params == null) {
+ return;
+ }
+ if (params.isEmpty()) {
+ resetAccountButton.setVisibility(VISIBLE);
+ resetAccountText.setVisibility(VISIBLE);
+ AndroidUtilities.hideKeyboard(codeField);
+ return;
+ }
+ resetAccountButton.setVisibility(GONE);
+ resetAccountText.setVisibility(GONE);
+ codeField.setText("");
+ currentParams = params;
+ current_salt = Utilities.hexToBytes(currentParams.getString("current_salt"));
+ hint = currentParams.getString("hint");
+ has_recovery = currentParams.getInt("has_recovery") == 1;
+ email_unconfirmed_pattern = currentParams.getString("email_unconfirmed_pattern");
+ requestPhone = params.getString("phoneFormated");
+ phoneHash = params.getString("phoneHash");
+ phoneCode = params.getString("code");
+
+ AndroidUtilities.showKeyboard(codeField);
+ codeField.requestFocus();
+
+
+ if (hint != null && hint.length() > 0) {
+ codeField.setHint(hint);
+ } else {
+ codeField.setHint(LocaleController.getString("LoginPassword", R.string.LoginPassword));
+ }
+ }
+
+ private void onPasscodeError(boolean clear) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
+ if (v != null) {
+ v.vibrate(200);
+ }
+ if (clear) {
+ codeField.setText("");
+ }
+ AndroidUtilities.shakeTextView(confirmTextView, 2, 0);
+ }
+
+ @Override
+ public void onNextPressed() {
+ if (nextPressed) {
+ return;
+ }
+
+ String oldPassword = codeField.getText().toString();
+ if (oldPassword.length() == 0) {
+ onPasscodeError(false);
+ return;
+ }
+ nextPressed = true;
+ byte[] oldPasswordBytes = null;
+ try {
+ oldPasswordBytes = oldPassword.getBytes("UTF-8");
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+
+ needShowProgress();
+ byte[] hash = new byte[current_salt.length * 2 + oldPasswordBytes.length];
+ System.arraycopy(current_salt, 0, hash, 0, current_salt.length);
+ System.arraycopy(oldPasswordBytes, 0, hash, current_salt.length, oldPasswordBytes.length);
+ System.arraycopy(current_salt, 0, hash, hash.length - current_salt.length, current_salt.length);
+
+ final TLRPC.TL_auth_checkPassword req = new TLRPC.TL_auth_checkPassword();
+ req.password_hash = Utilities.computeSHA256(hash, 0, hash.length);
+ 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() {
+ needHideProgress();
+ nextPressed = false;
+ if (error == null) {
+ TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response;
+ UserConfig.clearConfig();
+ MessagesController.getInstance().cleanUp();
+ UserConfig.setCurrentUser(res.user);
+ UserConfig.saveConfig(true);
+ MessagesStorage.getInstance().cleanUp(true);
+ ArrayList users = new ArrayList<>();
+ users.add(res.user);
+ MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
+ MessagesController.getInstance().putUser(res.user, false);
+ ContactsController.getInstance().checkAppAccount();
+ MessagesController.getInstance().getBlockedUsers(true);
+ needFinishActivity();
+ ConnectionsManager.getInstance().initPushConnection();
+ Utilities.stageQueue.postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ ConnectionsManager.getInstance().updateDcSettings(0);
+ }
+ });
+ } else {
+ if (error.text.equals("PASSWORD_HASH_INVALID")) {
+ onPasscodeError(true);
+ } else if (error.text.startsWith("FLOOD_WAIT")) {
+ int time = Utilities.parseInt(error.text);
+ String timeString;
+ if (time < 60) {
+ timeString = LocaleController.formatPluralString("Seconds", time);
+ } else {
+ timeString = LocaleController.formatPluralString("Minutes", time / 60);
+ }
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
+ } else {
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
+ }
+ }
+ }
+ });
+ }
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
+ }
+
+ @Override
+ public boolean needBackButton() {
+ return true;
+ }
+
+ @Override
+ public void onBackPressed() {
+ currentParams = null;
+ }
+
+ @Override
+ public void onShow() {
+ super.onShow();
+ if (codeField != null) {
+ codeField.requestFocus();
+ codeField.setSelection(codeField.length());
+ }
+ }
+
+ @Override
+ public void saveStateParams(Bundle bundle) {
+ String code = codeField.getText().toString();
+ if (code != null && code.length() != 0) {
+ bundle.putString("passview_code", code);
+ }
+ if (currentParams != null) {
+ bundle.putBundle("passview_params", currentParams);
+ }
+ }
+
+ @Override
+ public void restoreStateParams(Bundle bundle) {
+ currentParams = bundle.getBundle("passview_params");
+ if (currentParams != null) {
+ setParams(currentParams);
+ }
+ String code = bundle.getString("passview_code");
+ if (code != null) {
+ codeField.setText(code);
+ }
+ }
+ }
+
+ public class LoginActivityRecoverView extends SlideView {
+
+ private EditText codeField;
+ private TextView confirmTextView;
+ private TextView cancelButton;
+
+ private Bundle currentParams;
+ private boolean nextPressed;
+ private String email_unconfirmed_pattern;
+
+ public LoginActivityRecoverView(Context context) {
+ super(context);
+
+ setOrientation(VERTICAL);
+
+ confirmTextView = new TextView(context);
+ confirmTextView.setTextColor(0xff757575);
+ confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ confirmTextView.setGravity(Gravity.LEFT);
+ confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ confirmTextView.setText(LocaleController.getString("RestoreEmailSentInfo", R.string.RestoreEmailSentInfo));
+ addView(confirmTextView);
+ LayoutParams layoutParams = (LayoutParams) confirmTextView.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.LEFT;
+ confirmTextView.setLayoutParams(layoutParams);
+
+ codeField = new EditText(context);
+ codeField.setTextColor(0xff212121);
+ AndroidUtilities.clearCursorDrawable(codeField);
+ codeField.setHintTextColor(0xff979797);
+ codeField.setHint(LocaleController.getString("PasswordCode", R.string.PasswordCode));
+ codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
+ codeField.setMaxLines(1);
+ codeField.setPadding(0, 0, 0, 0);
+ codeField.setInputType(InputType.TYPE_CLASS_PHONE);
+ codeField.setTransformationMethod(PasswordTransformationMethod.getInstance());
+ codeField.setTypeface(Typeface.DEFAULT);
+ addView(codeField);
+ layoutParams = (LayoutParams) codeField.getLayoutParams();
+ layoutParams.width = LayoutParams.MATCH_PARENT;
+ layoutParams.height = AndroidUtilities.dp(36);
+ layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
+ layoutParams.topMargin = AndroidUtilities.dp(20);
+ codeField.setLayoutParams(layoutParams);
+ codeField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+ if (i == EditorInfo.IME_ACTION_NEXT) {
+ onNextPressed();
+ return true;
+ }
+ return false;
+ }
+ });
+
+ cancelButton = new TextView(context);
+ cancelButton.setGravity(Gravity.LEFT | Gravity.BOTTOM);
+ cancelButton.setTextColor(0xff4d83b3);
+ cancelButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
+ cancelButton.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
+ cancelButton.setPadding(0, AndroidUtilities.dp(14), 0, 0);
+ addView(cancelButton);
+ layoutParams = (LayoutParams) cancelButton.getLayoutParams();
+ layoutParams.width = LayoutParams.WRAP_CONTENT;
+ layoutParams.height = LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
+ layoutParams.bottomMargin = AndroidUtilities.dp(14);
+ cancelButton.setLayoutParams(layoutParams);
+ cancelButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.getString("RestoreEmailTroubleText", R.string.RestoreEmailTroubleText));
+ builder.setTitle(LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ setPage(3, true, new Bundle(), true);
+ }
+ });
+ AlertDialog dialog = showAlertDialog(builder);
+ if (dialog != null) {
+ dialog.setCanceledOnTouchOutside(false);
+ dialog.setCancelable(false);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean needBackButton() {
+ return true;
+ }
+
+ @Override
+ public String getHeaderName() {
+ return LocaleController.getString("LoginPassword", R.string.LoginPassword);
+ }
+
+ @Override
+ public void setParams(Bundle params) {
+ if (params == null) {
+ return;
+ }
+ codeField.setText("");
+ currentParams = params;
+ email_unconfirmed_pattern = currentParams.getString("email_unconfirmed_pattern");
+ cancelButton.setText(LocaleController.formatString("RestoreEmailTrouble", R.string.RestoreEmailTrouble, email_unconfirmed_pattern));
+
+ AndroidUtilities.showKeyboard(codeField);
+ codeField.requestFocus();
+ }
+
+ private void onPasscodeError(boolean clear) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
+ if (v != null) {
+ v.vibrate(200);
+ }
+ if (clear) {
+ codeField.setText("");
+ }
+ AndroidUtilities.shakeTextView(confirmTextView, 2, 0);
+ }
+
+ @Override
+ public void onNextPressed() {
+ if (nextPressed) {
+ return;
+ }
+
+ String oldPassword = codeField.getText().toString();
+ if (oldPassword.length() == 0) {
+ onPasscodeError(false);
+ return;
+ }
+ nextPressed = true;
+ byte[] oldPasswordBytes = null;
+ try {
+ oldPasswordBytes = oldPassword.getBytes("UTF-8");
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+
+ String code = codeField.getText().toString();
+ if (code.length() == 0) {
+ onPasscodeError(false);
+ return;
+ }
+ needShowProgress();
+ TLRPC.TL_auth_recoverPassword req = new TLRPC.TL_auth_recoverPassword();
+ req.code = code;
+ 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() {
+ needHideProgress();
+ nextPressed = false;
+ if (error == null) {
+ TLRPC.TL_auth_authorization res = (TLRPC.TL_auth_authorization) response;
+ UserConfig.clearConfig();
+ MessagesController.getInstance().cleanUp();
+ UserConfig.setCurrentUser(res.user);
+ UserConfig.saveConfig(true);
+ MessagesStorage.getInstance().cleanUp(true);
+ ArrayList users = new ArrayList<>();
+ users.add(res.user);
+ MessagesStorage.getInstance().putUsersAndChats(users, null, true, true);
+ MessagesController.getInstance().putUser(res.user, false);
+ ContactsController.getInstance().checkAppAccount();
+ MessagesController.getInstance().getBlockedUsers(true);
+ needFinishActivity();
+ ConnectionsManager.getInstance().initPushConnection();
+ Utilities.stageQueue.postRunnable(new Runnable() {
+ @Override
+ public void run() {
+ ConnectionsManager.getInstance().updateDcSettings(0);
+ }
+ });
+ } else {
+ if (error.text.startsWith("CODE_INVALID")) {
+ onPasscodeError(true);
+ } else if (error.text.startsWith("FLOOD_WAIT")) {
+ int time = Utilities.parseInt(error.text);
+ String timeString;
+ if (time < 60) {
+ timeString = LocaleController.formatPluralString("Seconds", time);
+ } else {
+ timeString = LocaleController.formatPluralString("Minutes", time / 60);
+ }
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
+ } else {
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
+ }
+ }
+ }
+ });
+ }
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors | RPCRequest.RPCRequestClassWithoutLogin);
+ }
+
+ @Override
+ public void onBackPressed() {
+ currentParams = null;
+ }
+
+ @Override
+ public void onShow() {
+ super.onShow();
+ if (codeField != null) {
+ codeField.requestFocus();
+ codeField.setSelection(codeField.length());
+ }
+ }
+
+ @Override
+ public void saveStateParams(Bundle bundle) {
+ String code = codeField.getText().toString();
+ if (code != null && code.length() != 0) {
+ bundle.putString("recoveryview_code", code);
+ }
+ if (currentParams != null) {
+ bundle.putBundle("recoveryview_params", currentParams);
+ }
+ }
+
+ @Override
+ public void restoreStateParams(Bundle bundle) {
+ currentParams = bundle.getBundle("recoveryview_params");
+ if (currentParams != null) {
+ setParams(currentParams);
+ }
+ String code = bundle.getString("recoveryview_code");
+ if (code != null) {
+ codeField.setText(code);
+ }
+ }
+ }
+
+ public class LoginActivityRegisterView extends SlideView {
private EditText firstNameField;
private EditText lastNameField;
@@ -1378,7 +1991,7 @@ public class LoginActivity extends BaseFragment {
private Bundle currentParams;
private boolean nextPressed = false;
- public RegisterView(Context context) {
+ public LoginActivityRegisterView(Context context) {
super(context);
setOrientation(VERTICAL);
@@ -1393,8 +2006,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.width = LayoutParams.WRAP_CONTENT;
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.topMargin = AndroidUtilities.dp(8);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.gravity = Gravity.LEFT;
textView.setLayoutParams(layoutParams);
@@ -1411,8 +2022,6 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) firstNameField.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.topMargin = AndroidUtilities.dp(26);
firstNameField.setLayoutParams(layoutParams);
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@@ -1439,8 +2048,6 @@ public class LoginActivity extends BaseFragment {
layoutParams = (LayoutParams) lastNameField.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT;
layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
layoutParams.topMargin = AndroidUtilities.dp(10);
lastNameField.setLayoutParams(layoutParams);
@@ -1455,8 +2062,7 @@ public class LoginActivity extends BaseFragment {
TextView wrongNumber = new TextView(context);
wrongNumber.setText(LocaleController.getString("CancelRegistration", R.string.CancelRegistration));
wrongNumber.setGravity(Gravity.LEFT | Gravity.CENTER_HORIZONTAL);
- //wrongNumber.setTextColor(0xff4d83b3);
- wrongNumber.setTextColor(AndroidUtilities.getIntColor("themeColor"));
+ wrongNumber.setTextColor(0xff4d83b3);
wrongNumber.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
wrongNumber.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
wrongNumber.setPadding(0, AndroidUtilities.dp(24), 0, 0);
@@ -1466,8 +2072,6 @@ public class LoginActivity extends BaseFragment {
layoutParams.height = LayoutParams.WRAP_CONTENT;
layoutParams.gravity = Gravity.BOTTOM | Gravity.LEFT;
layoutParams.bottomMargin = AndroidUtilities.dp(10);
- layoutParams.leftMargin = AndroidUtilities.dp(24);
- layoutParams.rightMargin = AndroidUtilities.dp(24);
wrongNumber.setLayoutParams(layoutParams);
wrongNumber.setOnClickListener(new OnClickListener() {
@Override
@@ -1566,23 +2170,23 @@ public class LoginActivity extends BaseFragment {
});
} else {
if (error.text.contains("PHONE_NUMBER_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
} else if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidCode", R.string.InvalidCode));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidCode", R.string.InvalidCode));
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
- needShowAlert(LocaleController.getString("CodeExpired", R.string.CodeExpired));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("CodeExpired", R.string.CodeExpired));
} else if (error.text.contains("FIRSTNAME_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidFirstName", R.string.InvalidFirstName));
} else if (error.text.contains("LASTNAME_INVALID")) {
- needShowAlert(LocaleController.getString("InvalidLastName", R.string.InvalidLastName));
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), LocaleController.getString("InvalidLastName", R.string.InvalidLastName));
} else {
- needShowAlert(error.text);
+ needShowAlert(LocaleController.getString("AppName", R.string.AppName), error.text);
}
}
}
});
}
- }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin);
+ }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassWithoutLogin | RPCRequest.RPCRequestClassFailOnServerErrors);
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java
index a34f7e35..5493a700 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java
@@ -40,23 +40,24 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
+import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController;
+import org.telegram.android.NotificationCenter;
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.messenger.R;
import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
-import org.telegram.android.MessageObject;
-import org.telegram.android.NotificationCenter;
-import org.telegram.messenger.R;
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.ActionBarPopupWindow;
-import org.telegram.ui.ActionBar.ActionBar;
+import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Adapters.BaseSectionsAdapter;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
@@ -67,7 +68,6 @@ import org.telegram.ui.Cells.SharedDocumentCell;
import org.telegram.ui.Cells.SharedMediaSectionCell;
import org.telegram.ui.Cells.SharedPhotoVideoCell;
import org.telegram.ui.Components.BackupImageView;
-import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.SectionsListView;
import java.io.File;
@@ -216,364 +216,358 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setTitle("");
- actionBar.setAllowOverlayTitle(false);
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- if (Build.VERSION.SDK_INT < 11 && listView != null) {
- listView.setAdapter(null);
- listView = null;
- photoVideoAdapter = null;
- documentsAdapter = null;
- }
- finishFragment();
- } else if (id == -2) {
- selectedFiles.clear();
- actionBar.hideActionMode();
- listView.invalidateViews();
- } else if (id == shared_media_item) {
- if (selectedMode == 0) {
- return;
- }
- selectedMode = 0;
- switchToCurrentSelectedMode();
- } else if (id == files_item) {
- if (selectedMode == 1) {
- return;
- }
- selectedMode = 1;
- switchToCurrentSelectedMode();
- } else if (id == delete) {
- if (getParentActivity() == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.formatString("AreYouSureDeleteMessages", R.string.AreYouSureDeleteMessages, LocaleController.formatPluralString("items", selectedFiles.size())));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- ArrayList ids = new ArrayList<>(selectedFiles.keySet());
- ArrayList random_ids = null;
- TLRPC.EncryptedChat currentEncryptedChat = null;
- if ((int) dialog_id == 0) {
- currentEncryptedChat = MessagesController.getInstance().getEncryptedChat((int) (dialog_id >> 32));
- }
- if (currentEncryptedChat != null) {
- random_ids = new ArrayList<>();
- for (HashMap.Entry entry : selectedFiles.entrySet()) {
- MessageObject msg = entry.getValue();
- if (msg.messageOwner.random_id != 0 && msg.type != 10) {
- random_ids.add(msg.messageOwner.random_id);
- }
- }
- }
- MessagesController.getInstance().deleteMessages(ids, random_ids, currentEncryptedChat);
- actionBar.hideActionMode();
- selectedFiles.clear();
- }
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- } else if (id == forward) {
- Bundle args = new Bundle();
- args.putBoolean("onlySelect", true);
- args.putBoolean("serverOnly", true);
- MessagesActivity fragment = new MessagesActivity(args);
- fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
- @Override
- public void didSelectDialog(MessagesActivity fragment, long did, boolean param) {
- int lower_part = (int)did;
- if (lower_part != 0) {
- Bundle args = new Bundle();
- args.putBoolean("scrollToTopOnResume", true);
- if (lower_part > 0) {
- args.putInt("user_id", lower_part);
- } else if (lower_part < 0) {
- args.putInt("chat_id", -lower_part);
- }
-
- ArrayList fmessages = new ArrayList<>();
- ArrayList ids = new ArrayList<>(selectedFiles.keySet());
- Collections.sort(ids);
- for (Integer id : ids) {
- if (id > 0) {
- fmessages.add(selectedFiles.get(id));
- }
- }
- selectedFiles.clear();
- actionBar.hideActionMode();
-
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
- ChatActivity chatActivity = new ChatActivity(args);
- presentFragment(chatActivity, true);
- chatActivity.showReplyForMessageObjectOrForward(true, null, fmessages, false);
-
- if (!AndroidUtilities.isTablet()) {
- removeSelfFromStack();
- Activity parentActivity = getParentActivity();
- if (parentActivity == null) {
- parentActivity = chatActivity.getParentActivity();
- }
- if (parentActivity != null) {
- parentActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- }
- }
- } else {
- fragment.finishFragment();
- }
- }
- });
- presentFragment(fragment);
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setTitle("");
+ actionBar.setAllowOverlayTitle(false);
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ if (Build.VERSION.SDK_INT < 11 && listView != null) {
+ listView.setAdapter(null);
+ listView = null;
+ photoVideoAdapter = null;
+ documentsAdapter = null;
}
- }
- });
-
- selectedFiles.clear();
- actionModeViews.clear();
-
- final ActionBarMenu menu = actionBar.createMenu();
- searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
- @Override
- public void onSearchExpand() {
- dropDownContainer.setVisibility(View.GONE);
- searching = true;
- }
-
- @Override
- public boolean onSearchCollapse() {
- dropDownContainer.setVisibility(View.VISIBLE);
- documentsSearchAdapter.searchDocuments(null);
- searching = false;
- searchWas = false;
+ finishFragment();
+ } else if (id == -2) {
+ selectedFiles.clear();
+ actionBar.hideActionMode();
+ listView.invalidateViews();
+ } else if (id == shared_media_item) {
+ if (selectedMode == 0) {
+ return;
+ }
+ selectedMode = 0;
switchToCurrentSelectedMode();
-
- return true;
- }
-
- @Override
- public void onTextChanged(EditText editText) {
- if (documentsSearchAdapter == null) {
+ } else if (id == files_item) {
+ if (selectedMode == 1) {
return;
}
- String text = editText.getText().toString();
- if (text.length() != 0) {
- searchWas = true;
- switchToCurrentSelectedMode();
- }
- documentsSearchAdapter.searchDocuments(text);
- }
- });
- searchItem.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
- searchItem.setVisibility(View.GONE);
-
- dropDownContainer = new ActionBarMenuItem(getParentActivity(), menu, R.drawable.bar_selector);
- dropDownContainer.setSubMenuOpenSide(1);
- dropDownContainer.addSubItem(shared_media_item, LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle), 0);
- dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0);
- actionBar.addView(dropDownContainer);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.rightMargin = AndroidUtilities.dp(40);
- layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
- layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
- dropDownContainer.setLayoutParams(layoutParams);
- dropDownContainer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dropDownContainer.toggleSubMenu();
- }
- });
-
- dropDown = new TextView(getParentActivity());
- dropDown.setGravity(Gravity.LEFT);
- dropDown.setSingleLine(true);
- dropDown.setLines(1);
- dropDown.setMaxLines(1);
- dropDown.setEllipsize(TextUtils.TruncateAt.END);
- dropDown.setTextColor(0xffffffff);
- dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
- dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
- dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
- dropDownContainer.addView(dropDown);
- layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.leftMargin = AndroidUtilities.dp(16);
- layoutParams.gravity = Gravity.CENTER_VERTICAL;
- dropDown.setLayoutParams(layoutParams);
-
- final ActionBarMenu actionMode = actionBar.createActionMode();
- actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
-
- selectedMessagesCountTextView = new TextView(actionMode.getContext());
- selectedMessagesCountTextView.setTextSize(18);
- selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- selectedMessagesCountTextView.setTextColor(0xff737373);
- selectedMessagesCountTextView.setSingleLine(true);
- selectedMessagesCountTextView.setLines(1);
- selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
- selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
- selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
- selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
- actionMode.addView(selectedMessagesCountTextView);
- LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams();
- layoutParams1.weight = 1;
- layoutParams1.width = 0;
- layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
- selectedMessagesCountTextView.setLayoutParams(layoutParams1);
-
- if ((int) dialog_id != 0) {
- actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
- }
- actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
-
- photoVideoAdapter = new SharedPhotoVideoAdapter(getParentActivity());
- documentsAdapter = new SharedDocumentsAdapter(getParentActivity());
- documentsSearchAdapter = new DocumentsSearchAdapter(getParentActivity());
-
- FrameLayout frameLayout;
- fragmentView = frameLayout = new FrameLayout(getParentActivity());
-
- listView = new SectionsListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setDrawSelectorOnTop(true);
- listView.setClipToPadding(false);
- frameLayout.addView(listView);
- layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- listView.setLayoutParams(layoutParams);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
- if (selectedMode == 1 && view instanceof SharedDocumentCell) {
- SharedDocumentCell cell = (SharedDocumentCell) view;
- MessageObject message = cell.getDocument();
- MediaActivity.this.onItemClick(i, view, message, 0);
- }
- }
- });
- listView.setOnScrollListener(new AbsListView.OnScrollListener() {
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- if (scrollState == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
- AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
- }
- scrolling = scrollState != SCROLL_STATE_IDLE;
- }
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- if (searching && searchWas) {
+ selectedMode = 1;
+ switchToCurrentSelectedMode();
+ } else if (id == delete) {
+ if (getParentActivity() == null) {
return;
}
- if (visibleItemCount != 0 && firstVisibleItem + visibleItemCount > totalItemCount - 2 && !sharedMediaData[selectedMode].loading && !sharedMediaData[selectedMode].endReached) {
- sharedMediaData[selectedMode].loading = true;
- int type;
- if (selectedMode == 0) {
- type = SharedMediaQuery.MEDIA_PHOTOVIDEO;
- } else if (selectedMode == 1) {
- type = SharedMediaQuery.MEDIA_FILE;
- } else {
- type = SharedMediaQuery.MEDIA_AUDIO;
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.formatString("AreYouSureDeleteMessages", R.string.AreYouSureDeleteMessages, LocaleController.formatPluralString("items", selectedFiles.size())));
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ ArrayList ids = new ArrayList<>(selectedFiles.keySet());
+ ArrayList random_ids = null;
+ TLRPC.EncryptedChat currentEncryptedChat = null;
+ if ((int) dialog_id == 0) {
+ currentEncryptedChat = MessagesController.getInstance().getEncryptedChat((int) (dialog_id >> 32));
+ }
+ if (currentEncryptedChat != null) {
+ random_ids = new ArrayList<>();
+ for (HashMap.Entry entry : selectedFiles.entrySet()) {
+ MessageObject msg = entry.getValue();
+ if (msg.messageOwner.random_id != 0 && msg.type != 10) {
+ random_ids.add(msg.messageOwner.random_id);
+ }
+ }
+ }
+ MessagesController.getInstance().deleteMessages(ids, random_ids, currentEncryptedChat);
+ actionBar.hideActionMode();
+ selectedFiles.clear();
}
- SharedMediaQuery.loadMedia(dialog_id, 0, 50, sharedMediaData[selectedMode].max_id, type, !sharedMediaData[selectedMode].cacheEndReached, classGuid);
- }
- }
- });
- listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
- @Override
- public boolean onItemLongClick(AdapterView> parent, View view, int i, long id) {
- if (selectedMode == 1 && view instanceof SharedDocumentCell) {
- SharedDocumentCell cell = (SharedDocumentCell) view;
- MessageObject message = cell.getDocument();
- return MediaActivity.this.onItemLongClick(message, view, 0);
- }
- return false;
- }
- });
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ } else if (id == forward) {
+ Bundle args = new Bundle();
+ args.putBoolean("onlySelect", true);
+ args.putBoolean("serverOnly", true);
+ MessagesActivity fragment = new MessagesActivity(args);
+ fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
+ @Override
+ public void didSelectDialog(MessagesActivity fragment, long did, boolean param) {
+ int lower_part = (int) did;
+ if (lower_part != 0) {
+ Bundle args = new Bundle();
+ args.putBoolean("scrollToTopOnResume", true);
+ if (lower_part > 0) {
+ args.putInt("user_id", lower_part);
+ } else if (lower_part < 0) {
+ args.putInt("chat_id", -lower_part);
+ }
- for (int a = 0; a < 6; a++) {
- cellCache.add(new SharedPhotoVideoCell(getParentActivity()));
+ ArrayList fmessages = new ArrayList<>();
+ ArrayList ids = new ArrayList<>(selectedFiles.keySet());
+ Collections.sort(ids);
+ for (Integer id : ids) {
+ if (id > 0) {
+ fmessages.add(selectedFiles.get(id));
+ }
+ }
+ selectedFiles.clear();
+ actionBar.hideActionMode();
+
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
+ ChatActivity chatActivity = new ChatActivity(args);
+ presentFragment(chatActivity, true);
+ chatActivity.showReplyPanel(true, null, fmessages, null, false, false);
+
+ if (!AndroidUtilities.isTablet()) {
+ removeSelfFromStack();
+ Activity parentActivity = getParentActivity();
+ if (parentActivity == null) {
+ parentActivity = chatActivity.getParentActivity();
+ }
+ if (parentActivity != null) {
+ parentActivity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+ }
+ }
+ } else {
+ fragment.finishFragment();
+ }
+ }
+ });
+ presentFragment(fragment);
+ }
+ }
+ });
+
+ selectedFiles.clear();
+ actionModeViews.clear();
+
+ final ActionBarMenu menu = actionBar.createMenu();
+ searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
+ @Override
+ public void onSearchExpand() {
+ dropDownContainer.setVisibility(View.GONE);
+ searching = true;
}
- emptyView = new LinearLayout(getParentActivity());
- emptyView.setOrientation(LinearLayout.VERTICAL);
- emptyView.setGravity(Gravity.CENTER);
- emptyView.setVisibility(View.GONE);
- emptyView.setBackgroundColor(0xfff0f0f0);
- frameLayout.addView(emptyView);
- layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- emptyView.setLayoutParams(layoutParams);
- emptyView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
+ @Override
+ public boolean onSearchCollapse() {
+ dropDownContainer.setVisibility(View.VISIBLE);
+ documentsSearchAdapter.searchDocuments(null);
+ searching = false;
+ searchWas = false;
+ switchToCurrentSelectedMode();
- emptyImageView = new ImageView(getParentActivity());
- emptyView.addView(emptyImageView);
- layoutParams1 = (LinearLayout.LayoutParams) emptyImageView.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT;
- emptyImageView.setLayoutParams(layoutParams1);
-
- emptyTextView = new TextView(getParentActivity());
- emptyTextView.setTextColor(0xff8a8a8a);
- emptyTextView.setGravity(Gravity.CENTER);
- emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
- emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128));
- emptyView.addView(emptyTextView);
- layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
- layoutParams1.topMargin = AndroidUtilities.dp(24);
- layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.gravity = Gravity.CENTER;
- emptyTextView.setLayoutParams(layoutParams1);
-
- progressView = new LinearLayout(getParentActivity());
- progressView.setGravity(Gravity.CENTER);
- progressView.setOrientation(LinearLayout.VERTICAL);
- progressView.setVisibility(View.GONE);
- progressView.setBackgroundColor(0xfff0f0f0);
- frameLayout.addView(progressView);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- progressView.setLayoutParams(layoutParams);
-
- ProgressBar progressBar = new ProgressBar(getParentActivity());
- progressView.addView(progressBar);
- layoutParams1 = (LinearLayout.LayoutParams) progressBar.getLayoutParams();
- layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
- layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT;
- progressBar.setLayoutParams(layoutParams1);
-
- switchToCurrentSelectedMode();
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
+ return true;
}
+
+ @Override
+ public void onTextChanged(EditText editText) {
+ if (documentsSearchAdapter == null) {
+ return;
+ }
+ String text = editText.getText().toString();
+ if (text.length() != 0) {
+ searchWas = true;
+ switchToCurrentSelectedMode();
+ }
+ documentsSearchAdapter.searchDocuments(text);
+ }
+ });
+ searchItem.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
+ searchItem.setVisibility(View.GONE);
+
+ dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector);
+ dropDownContainer.setSubMenuOpenSide(1);
+ dropDownContainer.addSubItem(shared_media_item, LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle), 0);
+ dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0);
+ actionBar.addView(dropDownContainer);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.rightMargin = AndroidUtilities.dp(40);
+ layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ dropDownContainer.setLayoutParams(layoutParams);
+ dropDownContainer.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ dropDownContainer.toggleSubMenu();
+ }
+ });
+
+ dropDown = new TextView(context);
+ dropDown.setGravity(Gravity.LEFT);
+ dropDown.setSingleLine(true);
+ dropDown.setLines(1);
+ dropDown.setMaxLines(1);
+ dropDown.setEllipsize(TextUtils.TruncateAt.END);
+ dropDown.setTextColor(0xffffffff);
+ dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
+ dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
+ dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
+ dropDownContainer.addView(dropDown);
+ layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.leftMargin = AndroidUtilities.dp(16);
+ layoutParams.gravity = Gravity.CENTER_VERTICAL;
+ dropDown.setLayoutParams(layoutParams);
+
+ final ActionBarMenu actionMode = actionBar.createActionMode();
+ actionModeViews.add(actionMode.addItem(-2, R.drawable.ic_ab_back_grey, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
+
+ selectedMessagesCountTextView = new TextView(actionMode.getContext());
+ selectedMessagesCountTextView.setTextSize(18);
+ selectedMessagesCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ selectedMessagesCountTextView.setTextColor(0xff737373);
+ selectedMessagesCountTextView.setSingleLine(true);
+ selectedMessagesCountTextView.setLines(1);
+ selectedMessagesCountTextView.setEllipsize(TextUtils.TruncateAt.END);
+ selectedMessagesCountTextView.setPadding(AndroidUtilities.dp(11), 0, 0, AndroidUtilities.dp(2));
+ selectedMessagesCountTextView.setGravity(Gravity.CENTER_VERTICAL);
+ selectedMessagesCountTextView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+ actionMode.addView(selectedMessagesCountTextView);
+ LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
+ layoutParams1.weight = 1;
+ layoutParams1.width = 0;
+ layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
+ selectedMessagesCountTextView.setLayoutParams(layoutParams1);
+
+ if ((int) dialog_id != 0) {
+ actionModeViews.add(actionMode.addItem(forward, R.drawable.ic_ab_fwd_forward, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
}
+ actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, R.drawable.bar_selector_mode, null, AndroidUtilities.dp(54)));
+
+ photoVideoAdapter = new SharedPhotoVideoAdapter(context);
+ documentsAdapter = new SharedDocumentsAdapter(context);
+ documentsSearchAdapter = new DocumentsSearchAdapter(context);
+
+ FrameLayout frameLayout;
+ fragmentView = frameLayout = new FrameLayout(context);
+
+ listView = new SectionsListView(context);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setDrawSelectorOnTop(true);
+ listView.setClipToPadding(false);
+ frameLayout.addView(listView);
+ layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ listView.setLayoutParams(layoutParams);
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
+ if (selectedMode == 1 && view instanceof SharedDocumentCell) {
+ SharedDocumentCell cell = (SharedDocumentCell) view;
+ MessageObject message = cell.getDocument();
+ MediaActivity.this.onItemClick(i, view, message, 0);
+ }
+ }
+ });
+ listView.setOnScrollListener(new AbsListView.OnScrollListener() {
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ if (scrollState == SCROLL_STATE_TOUCH_SCROLL && searching && searchWas) {
+ AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
+ }
+ scrolling = scrollState != SCROLL_STATE_IDLE;
+ }
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
+ if (searching && searchWas) {
+ return;
+ }
+ if (visibleItemCount != 0 && firstVisibleItem + visibleItemCount > totalItemCount - 2 && !sharedMediaData[selectedMode].loading && !sharedMediaData[selectedMode].endReached) {
+ sharedMediaData[selectedMode].loading = true;
+ int type;
+ if (selectedMode == 0) {
+ type = SharedMediaQuery.MEDIA_PHOTOVIDEO;
+ } else if (selectedMode == 1) {
+ type = SharedMediaQuery.MEDIA_FILE;
+ } else {
+ type = SharedMediaQuery.MEDIA_AUDIO;
+ }
+ SharedMediaQuery.loadMedia(dialog_id, 0, 50, sharedMediaData[selectedMode].max_id, type, !sharedMediaData[selectedMode].cacheEndReached, classGuid);
+ }
+ }
+ });
+ listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView> parent, View view, int i, long id) {
+ if (selectedMode == 1 && view instanceof SharedDocumentCell) {
+ SharedDocumentCell cell = (SharedDocumentCell) view;
+ MessageObject message = cell.getDocument();
+ return MediaActivity.this.onItemLongClick(message, view, 0);
+ }
+ return false;
+ }
+ });
+
+ for (int a = 0; a < 6; a++) {
+ cellCache.add(new SharedPhotoVideoCell(context));
+ }
+
+ emptyView = new LinearLayout(context);
+ emptyView.setOrientation(LinearLayout.VERTICAL);
+ emptyView.setGravity(Gravity.CENTER);
+ emptyView.setVisibility(View.GONE);
+ emptyView.setBackgroundColor(0xfff0f0f0);
+ frameLayout.addView(emptyView);
+ layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ emptyView.setLayoutParams(layoutParams);
+ emptyView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ emptyImageView = new ImageView(context);
+ emptyView.addView(emptyImageView);
+ layoutParams1 = (LinearLayout.LayoutParams) emptyImageView.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ emptyImageView.setLayoutParams(layoutParams1);
+
+ emptyTextView = new TextView(context);
+ emptyTextView.setTextColor(0xff8a8a8a);
+ emptyTextView.setGravity(Gravity.CENTER);
+ emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
+ emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128));
+ emptyView.addView(emptyTextView);
+ layoutParams1 = (LinearLayout.LayoutParams) emptyTextView.getLayoutParams();
+ layoutParams1.topMargin = AndroidUtilities.dp(24);
+ layoutParams1.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams1.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams1.gravity = Gravity.CENTER;
+ emptyTextView.setLayoutParams(layoutParams1);
+
+ progressView = new LinearLayout(context);
+ progressView.setGravity(Gravity.CENTER);
+ progressView.setOrientation(LinearLayout.VERTICAL);
+ progressView.setVisibility(View.GONE);
+ progressView.setBackgroundColor(0xfff0f0f0);
+ frameLayout.addView(progressView);
+ layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ progressView.setLayoutParams(layoutParams);
+
+ ProgressBar progressBar = new ProgressBar(context);
+ progressView.addView(progressBar);
+ layoutParams1 = (LinearLayout.LayoutParams) progressBar.getLayoutParams();
+ layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT;
+ progressBar.setLayoutParams(layoutParams1);
+
+ switchToCurrentSelectedMode();
+
return fragmentView;
}
@@ -742,7 +736,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = listView;
- object.imageReceiver = imageView.imageReceiver;
+ object.imageReceiver = imageView.getImageReceiver();
object.thumb = object.imageReceiver.getBitmap();
return object;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java
index 7f6c14b6..13a3ad88 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/MessagesActivity.java
@@ -10,20 +10,16 @@ package org.telegram.ui;
import android.animation.ObjectAnimator;
import android.animation.StateListAnimator;
-import android.app.Activity;
import android.app.AlertDialog;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.res.Configuration;
-import android.content.res.Resources;
-import android.graphics.Color;
import android.graphics.Outline;
import android.graphics.PorterDuff;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
-import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -34,7 +30,6 @@ import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.AbsListView;
import android.widget.AdapterView;
-import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.FrameLayout;
@@ -43,29 +38,29 @@ import android.widget.ListView;
import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
+import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
-import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.FileLog;
-import org.telegram.messenger.TLRPC;
-import org.telegram.android.ContactsController;
import org.telegram.android.MessagesController;
import org.telegram.android.MessagesStorage;
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.messenger.UserConfig;
-import org.telegram.ui.Adapters.BaseFragmentAdapter;
-import org.telegram.ui.Adapters.DialogsAdapter;
-import org.telegram.ui.Adapters.DialogsSearchAdapter;
-import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
-import org.telegram.ui.AnimationCompat.ViewProxy;
-import org.telegram.ui.Cells.UserCell;
-import org.telegram.ui.Cells.DialogCell;
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.ActionBar.MenuDrawable;
+import org.telegram.ui.Adapters.BaseFragmentAdapter;
+import org.telegram.ui.Adapters.DialogsAdapter;
+import org.telegram.ui.Adapters.DialogsSearchAdapter;
+import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
+import org.telegram.ui.AnimationCompat.ViewProxy;
+import org.telegram.ui.Cells.DialogCell;
+import org.telegram.ui.Cells.UserCell;
import java.util.ArrayList;
@@ -165,15 +160,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
+ public View createView(Context context, LayoutInflater inflater) {
searching = false;
searchWas = false;
-
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
ActionBarMenu menu = actionBar.createMenu();
if (!onlySelect && searchString == null) {
Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.lock_close);
- lock.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ lock.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
passcodeItem = menu.addItem(passcode_menu_item, lock);
updatePasscodeButton();
}
@@ -257,11 +251,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
});
item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
- item.getSearchField().setTextColor(AndroidUtilities.getIntDef("chatsHeaderTitleColor", 0xffffffff));
+ item.getSearchField().setTextColor(themePrefs.getInt("chatsHeaderTitleColor", 0xffffffff));
if (onlySelect) {
//actionBar.setBackButtonImage(R.drawable.ic_ab_back);
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
- back.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ back.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
actionBar.setBackButtonDrawable(back);
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
} else {
@@ -294,7 +288,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
fragmentView = inflater.inflate(R.layout.messages_list, null, false);
if (searchString == null) {
- dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly);
+ dialogsAdapter = new DialogsAdapter(context, serverOnly);
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
dialogsAdapter.setOpenedDialogId(openedDialogId);
}
@@ -305,7 +299,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else if (!onlySelect) {
type = 1;
}
- dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), type);
+ dialogsSearchAdapter = new DialogsSearchAdapter(context, type);
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
@Override
public void searchStateChanged(boolean search) {
@@ -317,7 +311,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
});
- messagesListView = (ListView)fragmentView.findViewById(R.id.messages_list_view);
+ messagesListView = (ListView) fragmentView.findViewById(R.id.messages_list_view);
if (dialogsAdapter != null) {
messagesListView.setAdapter(dialogsAdapter);
}
@@ -342,15 +336,15 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
});
- TextView textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text1);
+ TextView textView = (TextView) fragmentView.findViewById(R.id.list_empty_view_text1);
textView.setText(LocaleController.getString("NoChats", R.string.NoChats));
- textView = (TextView)fragmentView.findViewById(R.id.list_empty_view_text2);
+ textView = (TextView) fragmentView.findViewById(R.id.list_empty_view_text2);
String help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp);
if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
help = help.replace("\n", " ");
}
textView.setText(help);
- textView = (TextView)fragmentView.findViewById(R.id.search_empty_text);
+ textView = (TextView) fragmentView.findViewById(R.id.search_empty_text);
textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
floatingButton = (ImageView) fragmentView.findViewById(R.id.floating_button);
@@ -358,8 +352,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
- animator.addState(new int[] {android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
- animator.addState(new int[] {}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
+ animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
+ animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@Override
@@ -368,7 +362,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
});
}
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams)floatingButton.getLayoutParams();
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) floatingButton.getLayoutParams();
layoutParams.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(14) : 0;
layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(14);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM;
@@ -413,7 +407,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
dialog_id = ((TLRPC.User) obj).id;
if (dialogsSearchAdapter.isGlobalSearch(i)) {
ArrayList users = new ArrayList<>();
- users.add((TLRPC.User)obj);
+ users.add((TLRPC.User) obj);
MessagesController.getInstance().putUsers(users, false);
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true);
}
@@ -424,9 +418,9 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
}
} else if (obj instanceof TLRPC.EncryptedChat) {
- dialog_id = ((long)((TLRPC.EncryptedChat) obj).id) << 32;
+ dialog_id = ((long) ((TLRPC.EncryptedChat) obj).id) << 32;
} else if (obj instanceof MessageObject) {
- MessageObject messageObject = (MessageObject)obj;
+ MessageObject messageObject = (MessageObject) obj;
dialog_id = messageObject.getDialogId();
message_id = messageObject.getId();
dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString());
@@ -443,8 +437,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
didSelectResult(dialog_id, true, false);
} else {
Bundle args = new Bundle();
- int lower_part = (int)dialog_id;
- int high_id = (int)(dialog_id >> 32);
+ int lower_part = (int) dialog_id;
+ int high_id = (int) (dialog_id >> 32);
if (lower_part != 0) {
if (high_id == 1) {
args.putInt("chat_id", lower_part);
@@ -527,8 +521,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- int lower_id = (int)selectedDialog;
- int high_id = (int)(selectedDialog >> 32);
+ int lower_id = (int) selectedDialog;
+ 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),
@@ -549,14 +543,17 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
- MessagesController.getInstance().deleteDialog(selectedDialog, 0, which == 0);
if (which != 0) {
if (isChat) {
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
+ } else {
+ MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
}
if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog);
}
+ } else {
+ MessagesController.getInstance().deleteDialog(selectedDialog, 0, true);
}
}
});
@@ -620,12 +617,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
if (searchString != null) {
actionBar.openSearchField(searchString);
}
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
- }
+
return fragmentView;
}
@@ -642,24 +634,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
}
private void updateTheme(){
- updateActionBarTitle();
- actionBar.setBackgroundColor(AndroidUtilities.getIntDef("chatsHeaderColor", AndroidUtilities.getIntColor("themeColor")));
- Drawable floatingDrawableWhite = fragmentView.getResources().getDrawable(R.drawable.floating_white);
- floatingDrawableWhite.setColorFilter(AndroidUtilities.getIntDef("chatsFloatingBGColor", AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY);
- floatingButton.setBackgroundDrawable(floatingDrawableWhite);
- Drawable pencilDrawableWhite = fragmentView.getResources().getDrawable(R.drawable.floating_pencil);
- pencilDrawableWhite.setColorFilter(AndroidUtilities.getIntDef("chatsFloatingPencilColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
- floatingButton.setImageDrawable(pencilDrawableWhite);
- Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search);
- search.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
- Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.lock_close);
- lock.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
- lock = getParentActivity().getResources().getDrawable(R.drawable.lock_open);
- lock.setColorFilter(AndroidUtilities.getIntDef("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
- }
-
- private void updateActionBarTitle(){
- int value = AndroidUtilities.getIntDef("chatsHeaderTitle", 0);
+ SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
+ int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
+ //UpdateupdateActionBarTitle
+ int value = themePrefs.getInt("chatsHeaderTitle", 0);
String title = LocaleController.getString("AppName", R.string.AppName);
TLRPC.User user = UserConfig.getCurrentUser();
if( value == 1){
@@ -676,7 +654,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
title = "";
}
actionBar.setTitle(title);
- actionBar.setTitleColor(AndroidUtilities.getIntDef("chatsHeaderTitleColor", 0xffffffff));
+ actionBar.setTitleColor(themePrefs.getInt("chatsHeaderTitleColor", 0xffffffff));
+
+ actionBar.setBackgroundColor(themePrefs.getInt("chatsHeaderColor", def));
+ Drawable floatingDrawableWhite = fragmentView.getResources().getDrawable(R.drawable.floating_white);
+ floatingDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingBGColor", def), PorterDuff.Mode.MULTIPLY);
+ floatingButton.setBackgroundDrawable(floatingDrawableWhite);
+ Drawable pencilDrawableWhite = fragmentView.getResources().getDrawable(R.drawable.floating_pencil);
+ pencilDrawableWhite.setColorFilter(themePrefs.getInt("chatsFloatingPencilColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ floatingButton.setImageDrawable(pencilDrawableWhite);
+ Drawable search = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_search);
+ search.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.lock_close);
+ lock.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
+ lock = getParentActivity().getResources().getDrawable(R.drawable.lock_open);
+ lock.setColorFilter(themePrefs.getInt("chatsHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
}
@Override
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java
index 5d7d0e5a..5024538c 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java
@@ -29,24 +29,24 @@ import android.widget.Toast;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
-import org.telegram.android.NotificationsController;
+import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
+import org.telegram.android.NotificationsController;
import org.telegram.messenger.ApplicationLoader;
-import org.telegram.messenger.TLObject;
-import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
-import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest;
+import org.telegram.messenger.TLObject;
+import org.telegram.messenger.TLRPC;
+import org.telegram.ui.ActionBar.ActionBar;
+import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextColorCell;
import org.telegram.ui.Cells.TextDetailSettingsCell;
-import org.telegram.ui.ActionBar.ActionBar;
-import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.ColorPickerView;
public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@@ -156,388 +156,385 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- }
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
}
- });
+ }
+ });
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
+ fragmentView = new FrameLayout(context);
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
- listView = new ListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalScrollBarEnabled(false);
- frameLayout.addView(listView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(new ListAdapter(getParentActivity()));
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
- boolean enabled = false;
- if (i == messageAlertRow || i == groupAlertRow) {
+ listView = new ListView(context);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setVerticalScrollBarEnabled(false);
+ frameLayout.addView(listView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ listView.setLayoutParams(layoutParams);
+ listView.setAdapter(new ListAdapter(context));
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
+ boolean enabled = false;
+ if (i == messageAlertRow || i == groupAlertRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ if (i == messageAlertRow) {
+ enabled = preferences.getBoolean("EnableAll", true);
+ editor.putBoolean("EnableAll", !enabled);
+ } else if (i == groupAlertRow) {
+ enabled = preferences.getBoolean("EnableGroup", true);
+ editor.putBoolean("EnableGroup", !enabled);
+ }
+ editor.commit();
+ updateServerNotificationsSettings(i == groupAlertRow);
+ } else if (i == messagePreviewRow || i == groupPreviewRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ if (i == messagePreviewRow) {
+ enabled = preferences.getBoolean("EnablePreviewAll", true);
+ editor.putBoolean("EnablePreviewAll", !enabled);
+ } else if (i == groupPreviewRow) {
+ enabled = preferences.getBoolean("EnablePreviewGroup", true);
+ editor.putBoolean("EnablePreviewGroup", !enabled);
+ }
+ editor.commit();
+ updateServerNotificationsSettings(i == groupPreviewRow);
+ } else if (i == messageSoundRow || i == groupSoundRow) {
+ try {
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- if (i == messageAlertRow) {
- enabled = preferences.getBoolean("EnableAll", true);
- editor.putBoolean("EnableAll", !enabled);
- } else if (i == groupAlertRow) {
- enabled = preferences.getBoolean("EnableGroup", true);
- editor.putBoolean("EnableGroup", !enabled);
- }
- editor.commit();
- updateServerNotificationsSettings(i == groupAlertRow);
- } else if (i == messagePreviewRow || i == groupPreviewRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- if (i == messagePreviewRow) {
- enabled = preferences.getBoolean("EnablePreviewAll", true);
- editor.putBoolean("EnablePreviewAll", !enabled);
- } else if (i == groupPreviewRow) {
- enabled = preferences.getBoolean("EnablePreviewGroup", true);
- editor.putBoolean("EnablePreviewGroup", !enabled);
- }
- editor.commit();
- updateServerNotificationsSettings(i == groupPreviewRow);
- } else if (i == messageSoundRow || i == groupSoundRow) {
- try {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
- tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
- tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
- tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
- Uri currentSound = null;
+ Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
+ tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
+ tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
+ tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
+ Uri currentSound = null;
- String defaultPath = null;
- Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
- if (defaultUri != null) {
- defaultPath = defaultUri.getPath();
- }
+ String defaultPath = null;
+ Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
+ if (defaultUri != null) {
+ defaultPath = defaultUri.getPath();
+ }
- if (i == messageSoundRow) {
- String path = preferences.getString("GlobalSoundPath", defaultPath);
- if (path != null && !path.equals("NoSound")) {
- if (path.equals(defaultPath)) {
- currentSound = defaultUri;
- } else {
- currentSound = Uri.parse(path);
- }
- }
- } else if (i == groupSoundRow) {
- String path = preferences.getString("GroupSoundPath", defaultPath);
- if (path != null && !path.equals("NoSound")) {
- if (path.equals(defaultPath)) {
- currentSound = defaultUri;
- } else {
- currentSound = Uri.parse(path);
- }
+ if (i == messageSoundRow) {
+ String path = preferences.getString("GlobalSoundPath", defaultPath);
+ if (path != null && !path.equals("NoSound")) {
+ if (path.equals(defaultPath)) {
+ currentSound = defaultUri;
+ } else {
+ currentSound = Uri.parse(path);
}
}
- tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
- startActivityForResult(tmpIntent, i);
- } catch (Exception e) {
- FileLog.e("tmessages", e);
- }
- } else if (i == resetNotificationsRow) {
- if (reseting) {
- return;
- }
- reseting = true;
- TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
- ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
- @Override
- public void run(TLObject response, TLRPC.TL_error error) {
- AndroidUtilities.runOnUIThread(new Runnable() {
- @Override
- public void run() {
- MessagesController.getInstance().enableJoined = true;
- reseting = false;
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.clear();
- editor.commit();
- if (listView != null) {
- listView.invalidateViews();
- }
- if (getParentActivity() != null) {
- Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("ResetNotificationsText", R.string.ResetNotificationsText), Toast.LENGTH_SHORT);
- toast.show();
- }
- }
- });
+ } else if (i == groupSoundRow) {
+ String path = preferences.getString("GroupSoundPath", defaultPath);
+ if (path != null && !path.equals("NoSound")) {
+ if (path.equals(defaultPath)) {
+ currentSound = defaultUri;
+ } else {
+ currentSound = Uri.parse(path);
+ }
}
- });
- } else if (i == inappSoundRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableInAppSounds", true);
- editor.putBoolean("EnableInAppSounds", !enabled);
- editor.commit();
- } else if (i == inappVibrateRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableInAppVibrate", true);
- editor.putBoolean("EnableInAppVibrate", !enabled);
- editor.commit();
- } else if (i == inappPreviewRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableInAppPreview", true);
- editor.putBoolean("EnableInAppPreview", !enabled);
- editor.commit();
- } else if (i == inchatSoundRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableInChatSound", true);
- editor.putBoolean("EnableInChatSound", !enabled);
- editor.commit();
- NotificationsController.getInstance().setInChatSoundEnabled(!enabled);
- } else if (i == inappPriorityRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableInAppPriority", false);
- editor.putBoolean("EnableInAppPriority", !enabled);
- editor.commit();
- } else if (i == contactJoinedRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnableContactJoined", true);
- MessagesController.getInstance().enableJoined = !enabled;
- editor.putBoolean("EnableContactJoined", !enabled);
- editor.commit();
- } else if (i == pebbleAlertRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("EnablePebbleNotifications", false);
- editor.putBoolean("EnablePebbleNotifications", !enabled);
- editor.commit();
- } else if (i == badgeNumberRow) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- enabled = preferences.getBoolean("badgeNumber", true);
- editor.putBoolean("badgeNumber", !enabled);
- editor.commit();
- NotificationsController.getInstance().setBadgeEnabled(!enabled);
- } else if (i == notificationsServiceRow) {
- final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- enabled = preferences.getBoolean("pushService", true);
- if (!enabled) {
- final SharedPreferences.Editor editor = preferences.edit();
- editor.putBoolean("pushService", !enabled);
- editor.commit();
- ApplicationLoader.startPushService();
- } else {
- if (getParentActivity() == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
- builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
- builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ }
+ tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
+ startActivityForResult(tmpIntent, i);
+ } catch (Exception e) {
+ FileLog.e("tmessages", e);
+ }
+ } else if (i == resetNotificationsRow) {
+ if (reseting) {
+ return;
+ }
+ reseting = true;
+ TLRPC.TL_account_resetNotifySettings req = new TLRPC.TL_account_resetNotifySettings();
+ ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
+ @Override
+ public void run(TLObject response, TLRPC.TL_error error) {
+ AndroidUtilities.runOnUIThread(new Runnable() {
@Override
- public void onClick(DialogInterface dialogInterface, int i) {
- ApplicationLoader.stopPushService();
- final SharedPreferences.Editor editor = preferences.edit();
- editor.putBoolean("pushService", false);
+ public void run() {
+ MessagesController.getInstance().enableJoined = true;
+ reseting = false;
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.clear();
editor.commit();
- listView.invalidateViews();
+ if (listView != null) {
+ listView.invalidateViews();
+ }
+ if (getParentActivity() != null) {
+ Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("ResetNotificationsText", R.string.ResetNotificationsText), Toast.LENGTH_SHORT);
+ toast.show();
+ }
}
});
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
}
- } else if (i == messageLedRow || i == groupLedRow) {
+ });
+ } else if (i == inappSoundRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableInAppSounds", true);
+ editor.putBoolean("EnableInAppSounds", !enabled);
+ editor.commit();
+ } else if (i == inappVibrateRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableInAppVibrate", true);
+ editor.putBoolean("EnableInAppVibrate", !enabled);
+ editor.commit();
+ } else if (i == inappPreviewRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableInAppPreview", true);
+ editor.putBoolean("EnableInAppPreview", !enabled);
+ editor.commit();
+ } else if (i == inchatSoundRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableInChatSound", true);
+ editor.putBoolean("EnableInChatSound", !enabled);
+ editor.commit();
+ NotificationsController.getInstance().setInChatSoundEnabled(!enabled);
+ } else if (i == inappPriorityRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableInAppPriority", false);
+ editor.putBoolean("EnableInAppPriority", !enabled);
+ editor.commit();
+ } else if (i == contactJoinedRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnableContactJoined", true);
+ MessagesController.getInstance().enableJoined = !enabled;
+ editor.putBoolean("EnableContactJoined", !enabled);
+ editor.commit();
+ } else if (i == pebbleAlertRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("EnablePebbleNotifications", false);
+ editor.putBoolean("EnablePebbleNotifications", !enabled);
+ editor.commit();
+ } else if (i == badgeNumberRow) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ enabled = preferences.getBoolean("badgeNumber", true);
+ editor.putBoolean("badgeNumber", !enabled);
+ editor.commit();
+ NotificationsController.getInstance().setBadgeEnabled(!enabled);
+ } else if (i == notificationsServiceRow) {
+ final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ enabled = preferences.getBoolean("pushService", true);
+ if (!enabled) {
+ final SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("pushService", !enabled);
+ editor.commit();
+ ApplicationLoader.startPushService();
+ } else {
if (getParentActivity() == null) {
return;
}
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setMessage(LocaleController.getString("NotificationsServiceDisableInfo", R.string.NotificationsServiceDisableInfo));
+ builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
+ builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i) {
+ ApplicationLoader.stopPushService();
+ final SharedPreferences.Editor editor = preferences.edit();
+ editor.putBoolean("pushService", false);
+ editor.commit();
+ listView.invalidateViews();
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ }
+ } else if (i == messageLedRow || i == groupLedRow) {
+ if (getParentActivity() == null) {
+ return;
+ }
- LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
- final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker);
+ LayoutInflater li = (LayoutInflater) getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
+ final ColorPickerView colorPickerView = (ColorPickerView) view.findViewById(R.id.color_picker);
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- if (i == messageLedRow) {
- colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
- } else if (i == groupLedRow) {
- colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ if (i == messageLedRow) {
+ colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
+ } else if (i == groupLedRow) {
+ colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
+ }
+
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
+ builder.setView(view);
+ builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int which) {
+ final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ if (i == messageLedRow) {
+ editor.putInt("MessagesLed", colorPickerView.getColor());
+ } else if (i == groupLedRow) {
+ editor.putInt("GroupLed", colorPickerView.getColor());
+ }
+ editor.commit();
+ listView.invalidateViews();
}
-
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("LedColor", R.string.LedColor));
- builder.setView(view);
- builder.setPositiveButton(LocaleController.getString("Set", R.string.Set), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int which) {
- final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- if (i == messageLedRow) {
- editor.putInt("MessagesLed", colorPickerView.getColor());
- } else if (i == groupLedRow) {
- editor.putInt("GroupLed", colorPickerView.getColor());
- }
- editor.commit();
+ });
+ builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ if (i == messageLedRow) {
+ editor.putInt("MessagesLed", 0);
+ } else if (i == groupLedRow) {
+ editor.putInt("GroupLed", 0);
+ }
+ editor.commit();
+ listView.invalidateViews();
+ }
+ });
+ showAlertDialog(builder);
+ } else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
+ builder.setItems(new CharSequence[]{
+ LocaleController.getString("NoPopup", R.string.NoPopup),
+ LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
+ LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
+ LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup)
+ }, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ if (i == messagePopupNotificationRow) {
+ editor.putInt("popupAll", which);
+ } else if (i == groupPopupNotificationRow) {
+ editor.putInt("popupGroup", which);
+ }
+ editor.commit();
+ if (listView != null) {
listView.invalidateViews();
}
- });
- builder.setNeutralButton(LocaleController.getString("LedDisabled", R.string.LedDisabled), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- if (i == messageLedRow) {
- editor.putInt("MessagesLed", 0);
- } else if (i == groupLedRow) {
- editor.putInt("GroupLed", 0);
- }
- editor.commit();
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ } else if (i == messageVibrateRow || i == groupVibrateRow) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
+ builder.setItems(new CharSequence[]{
+ LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
+ LocaleController.getString("Default", R.string.Default),
+ LocaleController.getString("Short", R.string.Short),
+ LocaleController.getString("Long", R.string.Long),
+ LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent)
+ }, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ SharedPreferences.Editor editor = preferences.edit();
+ String param = "vibrate_messages";
+ if (i == groupVibrateRow) {
+ param = "vibrate_group";
+ }
+ if (which == 0) {
+ editor.putInt(param, 2);
+ } else if (which == 1) {
+ editor.putInt(param, 0);
+ } else if (which == 2) {
+ editor.putInt(param, 1);
+ } else if (which == 3) {
+ editor.putInt(param, 3);
+ } else if (which == 4) {
+ editor.putInt(param, 4);
+ }
+ editor.commit();
+ if (listView != null) {
listView.invalidateViews();
}
- });
- showAlertDialog(builder);
- } else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
- builder.setItems(new CharSequence[] {
- LocaleController.getString("NoPopup", R.string.NoPopup),
- LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
- LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
- LocaleController.getString("AlwaysShowPopup", R.string.AlwaysShowPopup)
- }, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- if (i == messagePopupNotificationRow) {
- editor.putInt("popupAll", which);
- } else if (i == groupPopupNotificationRow) {
- editor.putInt("popupGroup", which);
- }
- editor.commit();
- if (listView != null) {
- listView.invalidateViews();
- }
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ } else if (i == messagePriorityRow || i == groupPriorityRow) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
+ builder.setItems(new CharSequence[]{
+ LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault),
+ LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh),
+ LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax)
+ }, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ if (i == messagePriorityRow) {
+ preferences.edit().putInt("priority_messages", which).commit();
+ } else if (i == groupPriorityRow) {
+ preferences.edit().putInt("priority_group", which).commit();
}
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- } else if (i == messageVibrateRow || i == groupVibrateRow) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
- builder.setItems(new CharSequence[] {
- LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
- LocaleController.getString("Default", R.string.Default),
- LocaleController.getString("Short", R.string.Short),
- LocaleController.getString("Long", R.string.Long)
- }, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- String param = "vibrate_messages";
- if (i == groupVibrateRow) {
- param = "vibrate_group";
- }
- if (which == 0) {
- editor.putInt(param, 2);
- } else if (which == 1) {
- editor.putInt(param, 0);
- } else if (which == 2) {
- editor.putInt(param, 1);
- } else if (which == 3) {
- editor.putInt(param, 3);
- }
- editor.commit();
- if (listView != null) {
- listView.invalidateViews();
- }
+ if (listView != null) {
+ listView.invalidateViews();
}
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- } else if (i == messagePriorityRow || i == groupPriorityRow) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
- builder.setItems(new CharSequence[] {
- LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault),
- LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh),
- LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax)
- }, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- if (i == messagePriorityRow) {
- preferences.edit().putInt("priority_messages", which).commit();
- } else if (i == groupPriorityRow) {
- preferences.edit().putInt("priority_group", which).commit();
- }
- if (listView != null) {
- listView.invalidateViews();
- }
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ } else if (i == repeatRow) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
+ builder.setItems(new CharSequence[]{
+ LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled),
+ LocaleController.formatPluralString("Minutes", 5),
+ LocaleController.formatPluralString("Minutes", 10),
+ LocaleController.formatPluralString("Minutes", 30),
+ LocaleController.formatPluralString("Hours", 1),
+ LocaleController.formatPluralString("Hours", 2),
+ LocaleController.formatPluralString("Hours", 4)
+ }, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ int minutes = 0;
+ if (which == 1) {
+ minutes = 5;
+ } else if (which == 2) {
+ minutes = 10;
+ } else if (which == 3) {
+ minutes = 30;
+ } else if (which == 4) {
+ minutes = 60;
+ } else if (which == 5) {
+ minutes = 60 * 2;
+ } else if (which == 6) {
+ minutes = 60 * 4;
}
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- } else if (i == repeatRow) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
- builder.setItems(new CharSequence[] {
- LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled),
- LocaleController.formatPluralString("Minutes", 5),
- LocaleController.formatPluralString("Minutes", 10),
- LocaleController.formatPluralString("Minutes", 30),
- LocaleController.formatPluralString("Hours", 1),
- LocaleController.formatPluralString("Hours", 2),
- LocaleController.formatPluralString("Hours", 4)
- }, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- int minutes = 0;
- if (which == 1) {
- minutes = 5;
- } else if (which == 2) {
- minutes = 10;
- } else if (which == 3) {
- minutes = 30;
- } else if (which == 4) {
- minutes = 60;
- } else if (which == 5) {
- minutes = 60 * 2;
- } else if (which == 6) {
- minutes = 60 * 4;
- }
- SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
- preferences.edit().putInt("repeat_messages", minutes).commit();
- if (listView != null) {
- listView.invalidateViews();
- }
+ SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
+ preferences.edit().putInt("repeat_messages", minutes).commit();
+ if (listView != null) {
+ listView.invalidateViews();
}
- });
- builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
- showAlertDialog(builder);
- }
- if (view instanceof TextCheckCell) {
- ((TextCheckCell) view).setChecked(!enabled);
- }
+ }
+ });
+ builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
+ showAlertDialog(builder);
+ }
+ if (view instanceof TextCheckCell) {
+ ((TextCheckCell) view).setChecked(!enabled);
}
- });
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
}
- }
+ });
+
return fragmentView;
}
@@ -574,7 +571,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
if (rng != null) {
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
- name = LocaleController.getString("Default", R.string.Default);
+ name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
} else {
name = rng.getTitle(getParentActivity());
}
@@ -721,9 +718,9 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
textCell.setMultilineDetail(false);
String value = null;
if (i == messageSoundRow) {
- value = preferences.getString("GlobalSound", LocaleController.getString("Default", R.string.Default));
+ value = preferences.getString("GlobalSound", LocaleController.getString("SoundDefault", R.string.SoundDefault));
} else if (i == groupSoundRow) {
- value = preferences.getString("GroupSound", LocaleController.getString("Default", R.string.Default));
+ value = preferences.getString("GroupSound", LocaleController.getString("SoundDefault", R.string.SoundDefault));
}
if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", R.string.NoSound);
@@ -767,6 +764,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), true);
} else if (value == 3) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true);
+ } else if (value == 4) {
+ textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent), true);
}
} else if (i == repeatRow) {
textCell.setMultilineDetail(false);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java
index a0548ca3..f5cad11a 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/PasscodeActivity.java
@@ -55,9 +55,6 @@ 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.AnimationCompat.AnimatorListenerAdapterProxy;
-import org.telegram.ui.AnimationCompat.AnimatorSetProxy;
-import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell;
@@ -111,297 +108,295 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- if (type != 3) {
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ public View createView(Context context, LayoutInflater inflater) {
+ if (type != 3) {
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ }
+ actionBar.setAllowOverlayTitle(false);
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == done_button) {
+ if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_NEXT) {
+ processNext();
+ } else if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_DONE) {
+ processDone();
+ }
+ } else if (id == pin_item) {
+ currentPasswordType = 0;
+ updateDropDownTextView();
+ } else if (id == password_item) {
+ currentPasswordType = 1;
+ updateDropDownTextView();
+ }
}
- actionBar.setAllowOverlayTitle(false);
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ });
+
+ fragmentView = new FrameLayout(context);
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
+
+ if (type != 0) {
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+
+ titleTextView = new TextView(context);
+ titleTextView.setTextColor(0xff757575);
+ if (type == 1) {
+ if (UserConfig.passcodeHash.length() != 0) {
+ titleTextView.setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode));
+ } else {
+ titleTextView.setText(LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode));
+ }
+ } else {
+ titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode));
+ }
+ titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
+ titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
+ frameLayout.addView(titleTextView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
+ layoutParams.topMargin = AndroidUtilities.dp(38);
+ titleTextView.setLayoutParams(layoutParams);
+
+ passwordEditText = new EditText(context);
+ passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
+ passwordEditText.setTextColor(0xff000000);
+ passwordEditText.setMaxLines(1);
+ passwordEditText.setLines(1);
+ passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
+ passwordEditText.setSingleLine(true);
+ if (type == 1) {
+ passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
+ } else {
+ passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
+ }
+ passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
+ passwordEditText.setTypeface(Typeface.DEFAULT);
+ AndroidUtilities.clearCursorDrawable(passwordEditText);
+ frameLayout.addView(passwordEditText);
+ layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
+ layoutParams.topMargin = AndroidUtilities.dp(90);
+ layoutParams.height = AndroidUtilities.dp(36);
+ layoutParams.leftMargin = AndroidUtilities.dp(40);
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ layoutParams.rightMargin = AndroidUtilities.dp(40);
+ layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
+ passwordEditText.setLayoutParams(layoutParams);
+ passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == done_button) {
- if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_NEXT) {
- processNext();
- } else if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_DONE) {
+ public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
+ if (i == EditorInfo.IME_ACTION_NEXT) {
+ processNext();
+ return true;
+ } else if (i == EditorInfo.IME_ACTION_DONE) {
+ processDone();
+ return true;
+ }
+ return false;
+ }
+ });
+ passwordEditText.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) {
+ if (passwordEditText.length() == 4) {
+ if (type == 2 && UserConfig.passcodeType == 0) {
processDone();
+ } else if (type == 1 && currentPasswordType == 0) {
+ if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_NEXT) {
+ processNext();
+ } else if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_DONE) {
+ processDone();
+ }
}
- } else if (id == pin_item) {
- currentPasswordType = 0;
- updateDropDownTextView();
- } else if (id == password_item) {
- currentPasswordType = 1;
- updateDropDownTextView();
}
}
});
+ if (android.os.Build.VERSION.SDK_INT < 11) {
+ passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+ menu.clear();
+ }
+ });
+ } else {
+ passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
- fragmentView = new FrameLayout(getParentActivity());
- FrameLayout frameLayout = (FrameLayout) fragmentView;
+ public void onDestroyActionMode(ActionMode mode) {
+ }
- if (type != 0) {
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
- titleTextView = new TextView(getParentActivity());
- titleTextView.setTextColor(0xff757575);
- if (type == 1) {
- titleTextView.setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode));
- } else {
- titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode));
- }
- titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
- titleTextView.setGravity(Gravity.CENTER_HORIZONTAL);
- frameLayout.addView(titleTextView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.gravity = Gravity.CENTER_HORIZONTAL;
- layoutParams.topMargin = AndroidUtilities.dp(38);
- titleTextView.setLayoutParams(layoutParams);
-
- passwordEditText = new EditText(getParentActivity());
- passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
- passwordEditText.setTextColor(0xff000000);
- passwordEditText.setMaxLines(1);
- passwordEditText.setLines(1);
- passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL);
- passwordEditText.setSingleLine(true);
- if (type == 1) {
- passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
- } else {
- passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
- }
- passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
- passwordEditText.setTypeface(Typeface.DEFAULT);
- AndroidUtilities.clearCursorDrawable(passwordEditText);
- frameLayout.addView(passwordEditText);
- layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams();
- layoutParams.topMargin = AndroidUtilities.dp(90);
- layoutParams.height = AndroidUtilities.dp(36);
- layoutParams.leftMargin = AndroidUtilities.dp(40);
- layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
- layoutParams.rightMargin = AndroidUtilities.dp(40);
- layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
- passwordEditText.setLayoutParams(layoutParams);
- passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
- if (i == EditorInfo.IME_ACTION_NEXT) {
- processNext();
- return true;
- } else if (i == EditorInfo.IME_ACTION_DONE) {
- processDone();
- return true;
- }
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
});
- passwordEditText.addTextChangedListener(new TextWatcher() {
+ }
+
+ if (type == 1) {
+ dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector);
+ dropDownContainer.setSubMenuOpenSide(1);
+ dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0);
+ dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0);
+ actionBar.addView(dropDownContainer);
+ layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.rightMargin = AndroidUtilities.dp(40);
+ layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
+ layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
+ dropDownContainer.setLayoutParams(layoutParams);
+ dropDownContainer.setOnClickListener(new View.OnClickListener() {
@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) {
- if (passwordEditText.length() == 4) {
- if (type == 2 && UserConfig.passcodeType == 0) {
- processDone();
- } else if (type == 1 && currentPasswordType == 0) {
- if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_NEXT) {
- processNext();
- } else if (passwordEditText.getImeOptions() == EditorInfo.IME_ACTION_DONE) {
- processDone();
- }
- }
- }
+ public void onClick(View view) {
+ dropDownContainer.toggleSubMenu();
}
});
- if (android.os.Build.VERSION.SDK_INT < 11) {
- passwordEditText.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
- menu.clear();
- }
- });
- } else {
- passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return false;
- }
- public void onDestroyActionMode(ActionMode mode) {
- }
-
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- return false;
- }
- });
- }
-
- if (type == 1) {
- dropDownContainer = new ActionBarMenuItem(getParentActivity(), menu, R.drawable.bar_selector);
- dropDownContainer.setSubMenuOpenSide(1);
- dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0);
- dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0);
- actionBar.addView(dropDownContainer);
- layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams();
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.rightMargin = AndroidUtilities.dp(40);
- layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56);
- layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
- dropDownContainer.setLayoutParams(layoutParams);
- dropDownContainer.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- dropDownContainer.toggleSubMenu();
- }
- });
-
- dropDown = new TextView(getParentActivity());
- dropDown.setGravity(Gravity.LEFT);
- dropDown.setSingleLine(true);
- dropDown.setLines(1);
- dropDown.setMaxLines(1);
- dropDown.setEllipsize(TextUtils.TruncateAt.END);
- dropDown.setTextColor(0xffffffff);
- dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
- dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
- dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
- dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
- dropDownContainer.addView(dropDown);
- layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.leftMargin = AndroidUtilities.dp(16);
- layoutParams.gravity = Gravity.CENTER_VERTICAL;
- layoutParams.bottomMargin = AndroidUtilities.dp(1);
- dropDown.setLayoutParams(layoutParams);
- } else {
- actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
- }
-
- updateDropDownTextView();
+ dropDown = new TextView(context);
+ dropDown.setGravity(Gravity.LEFT);
+ dropDown.setSingleLine(true);
+ dropDown.setLines(1);
+ dropDown.setMaxLines(1);
+ dropDown.setEllipsize(TextUtils.TruncateAt.END);
+ dropDown.setTextColor(0xffffffff);
+ dropDown.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
+ dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0);
+ dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4));
+ dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0);
+ dropDownContainer.addView(dropDown);
+ layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.leftMargin = AndroidUtilities.dp(16);
+ layoutParams.gravity = Gravity.CENTER_VERTICAL;
+ layoutParams.bottomMargin = AndroidUtilities.dp(1);
+ dropDown.setLayoutParams(layoutParams);
} else {
actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
- frameLayout.setBackgroundColor(0xfff0f0f0);
- listView = new ListView(getParentActivity());
- listView.setDivider(null);
- listView.setDividerHeight(0);
- listView.setVerticalScrollBarEnabled(false);
- listView.setDrawSelectorOnTop(true);
- frameLayout.addView(listView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.gravity = Gravity.TOP;
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
- if (i == changePasscodeRow) {
- presentFragment(new PasscodeActivity(1));
- } else if (i == passcodeRow) {
- TextCheckCell cell = (TextCheckCell) view;
- if (UserConfig.passcodeHash.length() != 0) {
- UserConfig.passcodeHash = "";
- UserConfig.appLocked = false;
- UserConfig.saveConfig(false);
- int count = listView.getChildCount();
- for (int a = 0; a < count; a++) {
- View child = listView.getChildAt(a);
- if (child instanceof TextSettingsCell) {
- TextSettingsCell textCell = (TextSettingsCell) child;
- textCell.setTextColor(0xffc6c6c6);
- break;
- }
- }
- cell.setChecked(UserConfig.passcodeHash.length() != 0);
- NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode);
- } else {
- presentFragment(new PasscodeActivity(1));
- }
- } else if (i == autoLockRow) {
- if (getParentActivity() == null) {
- return;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
- builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
- final NumberPicker numberPicker = new NumberPicker(getParentActivity());
- numberPicker.setMinValue(0);
- numberPicker.setMaxValue(4);
- if (UserConfig.autoLockIn == 0) {
- numberPicker.setValue(0);
- } else if (UserConfig.autoLockIn == 60) {
- numberPicker.setValue(1);
- } else if (UserConfig.autoLockIn == 60 * 5) {
- numberPicker.setValue(2);
- } else if (UserConfig.autoLockIn == 60 * 60) {
- numberPicker.setValue(3);
- } else if (UserConfig.autoLockIn == 60 * 60 * 5) {
- numberPicker.setValue(4);
- }
- numberPicker.setFormatter(new NumberPicker.Formatter() {
- @Override
- public String format(int value) {
- if (value == 0) {
- return LocaleController.getString("Disabled", R.string.Disabled);
- } else if (value == 1) {
- return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1));
- } else if (value == 2) {
- return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5));
- } else if (value == 3) {
- return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
- } else if (value == 4) {
- return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5));
- }
- return "";
- }
- });
- builder.setView(numberPicker);
- builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- which = numberPicker.getValue();
- if (which == 0) {
- UserConfig.autoLockIn = 0;
- } else if (which == 1) {
- UserConfig.autoLockIn = 60;
- } else if (which == 2) {
- UserConfig.autoLockIn = 60 * 5;
- } else if (which == 3) {
- UserConfig.autoLockIn = 60 * 60;
- } else if (which == 4) {
- UserConfig.autoLockIn = 60 * 60 * 5;
- }
- listView.invalidateViews();
- UserConfig.saveConfig(false);
- }
- });
- showAlertDialog(builder);
- }
- }
- });
}
+
+ updateDropDownTextView();
} else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
+ frameLayout.setBackgroundColor(0xfff0f0f0);
+ listView = new ListView(context);
+ listView.setDivider(null);
+ listView.setDividerHeight(0);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setDrawSelectorOnTop(true);
+ frameLayout.addView(listView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.gravity = Gravity.TOP;
+ listView.setLayoutParams(layoutParams);
+ listView.setAdapter(listAdapter = new ListAdapter(context));
+ listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> adapterView, View view, final int i, long l) {
+ if (i == changePasscodeRow) {
+ presentFragment(new PasscodeActivity(1));
+ } else if (i == passcodeRow) {
+ TextCheckCell cell = (TextCheckCell) view;
+ if (UserConfig.passcodeHash.length() != 0) {
+ UserConfig.passcodeHash = "";
+ UserConfig.appLocked = false;
+ UserConfig.saveConfig(false);
+ int count = listView.getChildCount();
+ for (int a = 0; a < count; a++) {
+ View child = listView.getChildAt(a);
+ if (child instanceof TextSettingsCell) {
+ TextSettingsCell textCell = (TextSettingsCell) child;
+ textCell.setTextColor(0xffc6c6c6);
+ break;
+ }
+ }
+ cell.setChecked(UserConfig.passcodeHash.length() != 0);
+ NotificationCenter.getInstance().postNotificationName(NotificationCenter.didSetPasscode);
+ } else {
+ presentFragment(new PasscodeActivity(1));
+ }
+ } else if (i == autoLockRow) {
+ if (getParentActivity() == null) {
+ return;
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
+ builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock));
+ final NumberPicker numberPicker = new NumberPicker(getParentActivity());
+ numberPicker.setMinValue(0);
+ numberPicker.setMaxValue(4);
+ if (UserConfig.autoLockIn == 0) {
+ numberPicker.setValue(0);
+ } else if (UserConfig.autoLockIn == 60) {
+ numberPicker.setValue(1);
+ } else if (UserConfig.autoLockIn == 60 * 5) {
+ numberPicker.setValue(2);
+ } else if (UserConfig.autoLockIn == 60 * 60) {
+ numberPicker.setValue(3);
+ } else if (UserConfig.autoLockIn == 60 * 60 * 5) {
+ numberPicker.setValue(4);
+ }
+ numberPicker.setFormatter(new NumberPicker.Formatter() {
+ @Override
+ public String format(int value) {
+ if (value == 0) {
+ return LocaleController.getString("Disabled", R.string.Disabled);
+ } else if (value == 1) {
+ return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 1));
+ } else if (value == 2) {
+ return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Minutes", 5));
+ } else if (value == 3) {
+ return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
+ } else if (value == 4) {
+ return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5));
+ }
+ return "";
+ }
+ });
+ builder.setView(numberPicker);
+ builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ which = numberPicker.getValue();
+ if (which == 0) {
+ UserConfig.autoLockIn = 0;
+ } else if (which == 1) {
+ UserConfig.autoLockIn = 60;
+ } else if (which == 2) {
+ UserConfig.autoLockIn = 60 * 5;
+ } else if (which == 3) {
+ UserConfig.autoLockIn = 60 * 60;
+ } else if (which == 4) {
+ UserConfig.autoLockIn = 60 * 60 * 5;
+ }
+ listView.invalidateViews();
+ UserConfig.saveConfig(false);
+ }
+ });
+ showAlertDialog(builder);
+ }
+ }
+ });
}
+
return fragmentView;
}
@@ -526,7 +521,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} catch (Exception e) {
FileLog.e("tmessages", e);
}
- shakeTextView(2, 0);
+ AndroidUtilities.shakeTextView(titleTextView, 2, 0);
passwordEditText.setText("");
return;
}
@@ -550,23 +545,6 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
}
}
- private void shakeTextView(final float x, final int num) {
- if (num == 6) {
- titleTextView.clearAnimation();
- return;
- }
- AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy();
- animatorSetProxy.playTogether(ObjectAnimatorProxy.ofFloat(titleTextView, "translationX", AndroidUtilities.dp(x)));
- animatorSetProxy.setDuration(50);
- animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() {
- @Override
- public void onAnimationEnd(Object animation) {
- shakeTextView(num == 5 ? 0 : -x, num + 1);
- }
- });
- animatorSetProxy.start();
- }
-
private void onPasscodeError() {
if (getParentActivity() == null) {
return;
@@ -575,7 +553,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (v != null) {
v.vibrate(200);
}
- shakeTextView(2, 0);
+ AndroidUtilities.shakeTextView(titleTextView, 2, 0);
}
private void fixLayoutInternal() {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java
index b2ad1a74..fa330b1d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoAlbumPickerActivity.java
@@ -95,129 +95,123 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
@SuppressWarnings("unchecked")
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackgroundColor(0xff333333);
- actionBar.setItemsBackground(R.drawable.bar_selector_picker);
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- if (Build.VERSION.SDK_INT < 11) {
- listView.setAdapter(null);
- listView = null;
- listAdapter = null;
- }
- finishFragment();
- } else if (id == 1) {
- if (delegate != null) {
- finishFragment(false);
- delegate.startPhotoSelectActivity();
- }
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackgroundColor(0xff333333);
+ actionBar.setItemsBackground(R.drawable.bar_selector_picker);
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setTitle(LocaleController.getString("Gallery", R.string.Gallery));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ if (Build.VERSION.SDK_INT < 11) {
+ listView.setAdapter(null);
+ listView = null;
+ listAdapter = null;
+ }
+ finishFragment();
+ } else if (id == 1) {
+ if (delegate != null) {
+ finishFragment(false);
+ delegate.startPhotoSelectActivity();
}
}
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItem(1, R.drawable.ic_ab_other);
-
- fragmentView = new FrameLayout(getParentActivity());
-
- FrameLayout frameLayout = (FrameLayout) fragmentView;
- frameLayout.setBackgroundColor(0xff000000);
-
- listView = new ListView(getParentActivity());
- listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
- listView.setClipToPadding(false);
- listView.setHorizontalScrollBarEnabled(false);
- listView.setVerticalScrollBarEnabled(false);
- listView.setSelector(new ColorDrawable(0));
- listView.setDividerHeight(0);
- listView.setDivider(null);
- listView.setDrawingCacheEnabled(false);
- listView.setScrollingCacheEnabled(false);
- frameLayout.addView(listView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.bottomMargin = AndroidUtilities.dp(48);
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
- AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
-
- emptyView = new TextView(getParentActivity());
- emptyView.setTextColor(0xff808080);
- emptyView.setTextSize(20);
- emptyView.setGravity(Gravity.CENTER);
- emptyView.setVisibility(View.GONE);
- emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
- frameLayout.addView(emptyView);
- layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.bottomMargin = AndroidUtilities.dp(48);
- emptyView.setLayoutParams(layoutParams);
- emptyView.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- return true;
- }
- });
-
- progressView = new FrameLayout(getParentActivity());
- progressView.setVisibility(View.GONE);
- frameLayout.addView(progressView);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.bottomMargin = AndroidUtilities.dp(48);
- progressView.setLayoutParams(layoutParams);
-
- ProgressBar progressBar = new ProgressBar(getParentActivity());
- progressView.addView(progressBar);
- layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
- layoutParams.gravity = Gravity.CENTER;
- progressView.setLayoutParams(layoutParams);
-
- photoPickerBottomLayout = new PhotoPickerBottomLayout(getParentActivity());
- frameLayout.addView(photoPickerBottomLayout);
- layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = AndroidUtilities.dp(48);
- layoutParams.gravity = Gravity.BOTTOM;
- photoPickerBottomLayout.setLayoutParams(layoutParams);
- photoPickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- finishFragment();
- }
- });
- photoPickerBottomLayout.doneButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- sendSelectedPhotos();
- finishFragment();
- }
- });
-
- if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
- progressView.setVisibility(View.VISIBLE);
- listView.setEmptyView(null);
- } else {
- progressView.setVisibility(View.GONE);
- listView.setEmptyView(emptyView);
}
- photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItem(1, R.drawable.ic_ab_other);
+
+ fragmentView = new FrameLayout(context);
+
+ FrameLayout frameLayout = (FrameLayout) fragmentView;
+ frameLayout.setBackgroundColor(0xff000000);
+
+ listView = new ListView(context);
+ listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
+ listView.setClipToPadding(false);
+ listView.setHorizontalScrollBarEnabled(false);
+ listView.setVerticalScrollBarEnabled(false);
+ listView.setSelector(new ColorDrawable(0));
+ listView.setDividerHeight(0);
+ listView.setDivider(null);
+ listView.setDrawingCacheEnabled(false);
+ listView.setScrollingCacheEnabled(false);
+ frameLayout.addView(listView);
+ FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.bottomMargin = AndroidUtilities.dp(48);
+ listView.setLayoutParams(layoutParams);
+ listView.setAdapter(listAdapter = new ListAdapter(context));
+ AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
+
+ emptyView = new TextView(context);
+ emptyView.setTextColor(0xff808080);
+ emptyView.setTextSize(20);
+ emptyView.setGravity(Gravity.CENTER);
+ emptyView.setVisibility(View.GONE);
+ emptyView.setText(LocaleController.getString("NoPhotos", R.string.NoPhotos));
+ frameLayout.addView(emptyView);
+ layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.bottomMargin = AndroidUtilities.dp(48);
+ emptyView.setLayoutParams(layoutParams);
+ emptyView.setOnTouchListener(new View.OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ return true;
+ }
+ });
+
+ progressView = new FrameLayout(context);
+ progressView.setVisibility(View.GONE);
+ frameLayout.addView(progressView);
+ layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.bottomMargin = AndroidUtilities.dp(48);
+ progressView.setLayoutParams(layoutParams);
+
+ ProgressBar progressBar = new ProgressBar(context);
+ progressView.addView(progressBar);
+ layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
+ layoutParams.gravity = Gravity.CENTER;
+ progressView.setLayoutParams(layoutParams);
+
+ photoPickerBottomLayout = new PhotoPickerBottomLayout(context);
+ frameLayout.addView(photoPickerBottomLayout);
+ layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams();
+ layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
+ layoutParams.height = AndroidUtilities.dp(48);
+ layoutParams.gravity = Gravity.BOTTOM;
+ photoPickerBottomLayout.setLayoutParams(layoutParams);
+ photoPickerBottomLayout.cancelButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ finishFragment();
+ }
+ });
+ photoPickerBottomLayout.doneButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ sendSelectedPhotos();
+ finishFragment();
+ }
+ });
+
+ if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
+ progressView.setVisibility(View.VISIBLE);
+ listView.setEmptyView(null);
} else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
- }
+ progressView.setVisibility(View.GONE);
+ listView.setEmptyView(emptyView);
}
+ photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java
index 43e856ee..cf6b43b1 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoCropActivity.java
@@ -19,13 +19,12 @@ import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewGroup;
import android.widget.FrameLayout;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader;
-import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
+import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
@@ -432,44 +431,38 @@ public class PhotoCropActivity extends BaseFragment {
}
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackgroundColor(0xff333333);
- actionBar.setItemsBackground(R.drawable.bar_selector_picker);
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- actionBar.setAllowOverlayTitle(true);
- actionBar.setTitle(LocaleController.getString("CropImage", R.string.CropImage));
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- finishFragment();
- } else if (id == done_button) {
- if (delegate != null && !doneButtonPressed) {
- Bitmap bitmap = view.getBitmap();
- if (bitmap == imageToCrop) {
- sameBitmap = true;
- }
- delegate.didFinishEdit(bitmap, getArguments());
- doneButtonPressed = true;
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackgroundColor(0xff333333);
+ actionBar.setItemsBackground(R.drawable.bar_selector_picker);
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ actionBar.setAllowOverlayTitle(true);
+ actionBar.setTitle(LocaleController.getString("CropImage", R.string.CropImage));
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ finishFragment();
+ } else if (id == done_button) {
+ if (delegate != null && !doneButtonPressed) {
+ Bitmap bitmap = view.getBitmap();
+ if (bitmap == imageToCrop) {
+ sameBitmap = true;
}
- finishFragment();
+ delegate.didFinishEdit(bitmap, getArguments());
+ doneButtonPressed = true;
}
+ finishFragment();
}
- });
-
- ActionBarMenu menu = actionBar.createMenu();
- menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
-
- fragmentView = view = new PhotoCropView(getParentActivity());
- ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false);
- fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
- } else {
- ViewGroup parent = (ViewGroup)fragmentView.getParent();
- if (parent != null) {
- parent.removeView(fragmentView);
}
- }
+ });
+
+ ActionBarMenu menu = actionBar.createMenu();
+ menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
+
+ fragmentView = view = new PhotoCropView(context);
+ ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false);
+ fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
+
return fragmentView;
}
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java
index 3e92b919..333a106d 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java
@@ -36,6 +36,7 @@ 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;
@@ -50,13 +51,12 @@ 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.Utilities;
+import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
-import org.telegram.ui.Adapters.BaseFragmentAdapter;
-import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.PhotoPickerPhotoCell;
import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.PhotoPickerBottomLayout;
@@ -142,275 +142,269 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
@SuppressWarnings("unchecked")
@Override
- public View createView(LayoutInflater inflater) {
- if (fragmentView == null) {
- actionBar.setBackgroundColor(0xff333333);
- actionBar.setItemsBackground(R.drawable.bar_selector_picker);
- actionBar.setBackButtonImage(R.drawable.ic_ab_back);
- if (selectedAlbum != null) {
- actionBar.setTitle(selectedAlbum.bucketName);
- } else if (type == 0) {
- actionBar.setTitle(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle));
- } else if (type == 1) {
- actionBar.setTitle(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
- }
- actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
- @Override
- public void onItemClick(int id) {
- if (id == -1) {
- if (Build.VERSION.SDK_INT < 11) {
- listView.setAdapter(null);
- listView = null;
- listAdapter = null;
- }
- finishFragment();
+ public View createView(Context context, LayoutInflater inflater) {
+ actionBar.setBackgroundColor(0xff333333);
+ actionBar.setItemsBackground(R.drawable.bar_selector_picker);
+ actionBar.setBackButtonImage(R.drawable.ic_ab_back);
+ if (selectedAlbum != null) {
+ actionBar.setTitle(selectedAlbum.bucketName);
+ } else if (type == 0) {
+ actionBar.setTitle(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle));
+ } else if (type == 1) {
+ actionBar.setTitle(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
+ }
+ actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
+ @Override
+ public void onItemClick(int id) {
+ if (id == -1) {
+ if (Build.VERSION.SDK_INT < 11) {
+ listView.setAdapter(null);
+ listView = null;
+ listAdapter = null;
}
+ finishFragment();
}
- });
+ }
+ });
- if (selectedAlbum == null) {
- ActionBarMenu menu = actionBar.createMenu();
- searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
- @Override
- public void onSearchExpand() {
+ if (selectedAlbum == null) {
+ ActionBarMenu menu = actionBar.createMenu();
+ searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
+ @Override
+ public void onSearchExpand() {
- }
+ }
- @Override
- public boolean onSearchCollapse() {
- finishFragment();
- return false;
- }
+ @Override
+ public boolean onSearchCollapse() {
+ finishFragment();
+ return false;
+ }
- @Override
- public void onTextChanged(EditText editText) {
- if (editText.getText().length() == 0) {
- searchResult.clear();
- searchResultKeys.clear();
- lastSearchString = null;
- nextSearchBingString = null;
- giphySearchEndReached = true;
- searching = false;
- requestQueue.cancelAll("search");
- if (type == 0) {
- emptyView.setText(LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos));
- } else if (type == 1) {
- emptyView.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
- }
- updateSearchInterface();
- }
- }
-
- @Override
- public void onSearchPressed(EditText editText) {
- if (editText.getText().toString().length() == 0) {
- return;
- }
+ @Override
+ public void onTextChanged(EditText editText) {
+ if (editText.getText().length() == 0) {
searchResult.clear();
searchResultKeys.clear();
+ lastSearchString = null;
nextSearchBingString = null;
giphySearchEndReached = true;
+ searching = false;
+ requestQueue.cancelAll("search");
if (type == 0) {
- searchBingImages(editText.getText().toString(), 0, 53);
+ emptyView.setText(LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos));
} else if (type == 1) {
- searchGiphyImages(editText.getText().toString(), 0, 53);
- }
- lastSearchString = editText.getText().toString();
- if (lastSearchString.length() == 0) {
- lastSearchString = null;
- if (type == 0) {
- emptyView.setText(LocaleController.getString("NoRecentPhotos", R.string.NoRecentPhotos));
- } else if (type == 1) {
- emptyView.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
- }
- } else {
- emptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
+ emptyView.setText(LocaleController.getString("NoRecentGIFs", R.string.NoRecentGIFs));
}
updateSearchInterface();
}
- });
- }
-
- if (selectedAlbum == null) {
- if (type == 0) {
- searchItem.getSearchField().setHint(LocaleController.getString("SearchImagesTitle", R.string.SearchImagesTitle));
- } else if (type == 1) {
- searchItem.getSearchField().setHint(LocaleController.getString("SearchGifsTitle", R.string.SearchGifsTitle));
}
- }
- fragmentView = new FrameLayout(getParentActivity());
-
- FrameLayout frameLayout = (FrameLayout) fragmentView;
- frameLayout.setBackgroundColor(0xff000000);
-
- listView = new GridView(getParentActivity());
- listView.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4));
- listView.setClipToPadding(false);
- listView.setDrawSelectorOnTop(true);
- listView.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
- listView.setHorizontalScrollBarEnabled(false);
- listView.setVerticalScrollBarEnabled(false);
- listView.setNumColumns(GridView.AUTO_FIT);
- listView.setVerticalSpacing(AndroidUtilities.dp(4));
- listView.setHorizontalSpacing(AndroidUtilities.dp(4));
- listView.setSelector(R.drawable.list_selector);
- frameLayout.addView(listView);
- FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams();
- layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
- layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
- listView.setLayoutParams(layoutParams);
- listView.setAdapter(listAdapter = new ListAdapter(getParentActivity()));
- AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
- public void onItemClick(AdapterView> adapterView, View view, int i, long l) {
- ArrayList