Update to 2.7.0.1 (492)

This commit is contained in:
rafalense 2015-04-13 19:46:02 +02:00
parent f07c7df1fa
commit d0d035cda2
145 changed files with 7879 additions and 6279 deletions

View File

@ -89,7 +89,7 @@ android {
applicationId "org.telegram.plus" applicationId "org.telegram.plus"
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 22 targetSdkVersion 22
versionCode 475 versionCode 492
versionName "2.6.1.1" versionName "2.7.0.1"
} }
} }

View File

@ -104,7 +104,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_PRELINK_MODULE := false LOCAL_PRELINK_MODULE := false
LOCAL_STATIC_LIBRARIES := webp sqlite 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 := -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 += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -fno-math-errno
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math

View File

@ -419,6 +419,11 @@ JNIEXPORT void Java_org_telegram_messenger_Utilities_calcCDT(JNIEnv *env, jclass
free(cdfsMin); 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) { 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; AndroidBitmapInfo info;

View File

@ -39,8 +39,6 @@
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!--
<uses-permission android:name="org.telegram.plus.android.provider.ACCESS" />-->
<application <application
android:name=".ApplicationLoader" android:name=".ApplicationLoader"

View File

@ -9,12 +9,9 @@
package org.telegram.android; package org.telegram.android;
import android.app.Activity; import android.app.Activity;
import android.app.AlarmManager;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -30,8 +27,8 @@ import android.os.Environment;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.Spanned; import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log;
import android.util.StateSet; import android.util.StateSet;
import android.view.Display; import android.view.Display;
import android.view.Surface; import android.view.Surface;
@ -44,7 +41,6 @@ import android.widget.EditText;
import android.widget.ListView; import android.widget.ListView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
@ -52,17 +48,17 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
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.ui.Components.ForegroundDetector; import org.telegram.ui.Components.ForegroundDetector;
import org.telegram.ui.Components.NumberPicker; import org.telegram.ui.Components.NumberPicker;
import org.telegram.ui.Components.TypefaceSpan; import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.LaunchActivity;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.channels.FileChannel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Hashtable; import java.util.Hashtable;
@ -559,21 +555,51 @@ public class AndroidUtilities {
} }
} }
public static Spannable replaceBold(String str) { public static Spannable replaceTags(String str) {
int start; try {
int start = -1;
int startColor = -1;
int end = -1;
StringBuilder stringBuilder = new StringBuilder(str);
while ((start = stringBuilder.indexOf("<br>")) != -1) {
stringBuilder.replace(start, start + 4, "\n");
}
while ((start = stringBuilder.indexOf("<br/>")) != -1) {
stringBuilder.replace(start, start + 5, "\n");
}
ArrayList<Integer> bolds = new ArrayList<>(); ArrayList<Integer> bolds = new ArrayList<>();
while ((start = str.indexOf("<b>")) != -1) { ArrayList<Integer> colors = new ArrayList<>();
int end = str.indexOf("</b>") - 3; while ((start = stringBuilder.indexOf("<b>")) != -1 || (startColor = stringBuilder.indexOf("<c")) != -1) {
str = str.replaceFirst("<b>", "").replaceFirst("</b>", ""); if (start != -1) {
stringBuilder.replace(start, start + 3, "");
end = stringBuilder.indexOf("</b>");
stringBuilder.replace(end, end + 4, "");
bolds.add(start); bolds.add(start);
bolds.add(end); bolds.add(end);
} else if (startColor != -1) {
stringBuilder.replace(startColor, startColor + 2, "");
end = stringBuilder.indexOf(">", startColor);
int color = Color.parseColor(stringBuilder.substring(startColor, end));
stringBuilder.replace(startColor, end + 1, "");
end = stringBuilder.indexOf("</c>");
stringBuilder.replace(end, end + 4, "");
colors.add(startColor);
colors.add(end);
colors.add(color);
} }
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(str); }
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(stringBuilder);
for (int a = 0; a < bolds.size() / 2; a++) { for (int a = 0; a < bolds.size() / 2; a++) {
TypefaceSpan span = new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); spannableStringBuilder.setSpan(new TypefaceSpan(AndroidUtilities.getTypeface("fonts/rmedium.ttf")), bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
stringBuilder.setSpan(span, bolds.get(a * 2), bolds.get(a * 2 + 1), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
} }
return stringBuilder; 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 new SpannableStringBuilder(str);
} }
public static boolean needShowPasscode(boolean reset) { 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()); (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) { /*public static void turnOffHardwareAcceleration(Window window) {
if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) { if (window == null || Build.MODEL == null || Build.VERSION.SDK_INT < 11) {
return; return;
@ -606,7 +687,13 @@ public class AndroidUtilities {
//PLUS //PLUS
public static int getIntColor(String key){ public static int getIntColor(String key){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(THEME_PREFS, THEME_PREFS_MODE); 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){ public static int getIntDef(String key, int def){
@ -755,162 +842,6 @@ public class AndroidUtilities {
return d; 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(){ public static int getDefBubbleColor(){
int color = 0xffb2dfdb;//0xff80cbc4; int color = 0xffb2dfdb;//0xff80cbc4;
if(getIntColor("themeColor") != 0xff009688){ if(getIntColor("themeColor") != 0xff009688){
@ -918,6 +849,7 @@ public class AndroidUtilities {
} }
return color; return color;
} }
/* /*
static void modifyXMLfile(File preffile,String sname){ static void modifyXMLfile(File preffile,String sname){
try { try {

View File

@ -22,6 +22,7 @@ import android.provider.ContactsContract;
import android.util.SparseArray; import android.util.SparseArray;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildVars; import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -31,7 +32,6 @@ import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -1773,7 +1773,7 @@ public class ContactsController {
} }
public static String formatName(String firstName, String lastName) { public static String formatName(String firstName, String lastName) {
String result = null; String result = "";
if (LocaleController.nameDisplayOrder == 1) { if (LocaleController.nameDisplayOrder == 1) {
result = firstName; result = firstName;
if (result == null || result.length() == 0) { if (result == null || result.length() == 0) {

View File

@ -8,11 +8,6 @@
package org.telegram.android; 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.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.graphics.Canvas; import android.graphics.Canvas;
@ -27,9 +22,14 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities; 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 { public class Emoji {
private static HashMap<Long, DrawableInfo> rects = new HashMap<>(); private static HashMap<Long, DrawableInfo> rects = new HashMap<>();
@ -401,12 +401,17 @@ public class Emoji {
if (cs == null || cs.length() == 0) { if (cs == null || cs.length() == 0) {
return cs; return cs;
} }
Spannable s; Spannable s;
if (cs instanceof Spannable) { if (cs instanceof Spannable) {
s = (Spannable)cs; s = (Spannable)cs;
} else { } else {
s = Spannable.Factory.getInstance().newSpannable(cs); 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; long buf = 0;
int emojiCount = 0; int emojiCount = 0;
try { try {

View File

@ -26,6 +26,7 @@ import android.os.Environment;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.provider.MediaStore; import android.provider.MediaStore;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.DispatchQueue; import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -33,7 +34,6 @@ import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
@ -645,9 +645,13 @@ public class ImageLoader {
} else { } else {
opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inPreferredConfig = Bitmap.Config.RGB_565;
} }
//if (Build.VERSION.SDK_INT < 21) {
// opts.inPurgeable = true;
//}
opts.inDither = false; opts.inDither = false;
if (mediaId != null) { 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 (image == null) {
if (isWebp) { if (isWebp) {
@ -1143,6 +1147,19 @@ public class ImageLoader {
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", 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 { } else {
FileLog.e("tmessages", "this Android can't rename files"); 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 != null && photoSize.bytes != null && photoSize.bytes.length != 0) {
if (photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) { if (photoSize.location instanceof TLRPC.TL_fileLocationUnavailable) {
@ -2018,6 +2044,13 @@ public class ImageLoader {
message.media.video.thumb = newPhotoSize; message.media.video.thumb = newPhotoSize;
} else if (message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
message.media.document.thumb = newPhotoSize; 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;
}
}
} }
} }
} }

View File

@ -22,9 +22,9 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLObject; import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate { public class ImageReceiver implements NotificationCenter.NotificationCenterDelegate {
@ -224,10 +224,6 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setImageBitmap(bitmap != null ? new BitmapDrawable(null, bitmap) : null); setImageBitmap(bitmap != null ? new BitmapDrawable(null, bitmap) : null);
} }
public void setDisableRecycle(boolean value) {
disableRecycle = value;
}
public void setImageBitmap(Drawable bitmap) { public void setImageBitmap(Drawable bitmap) {
ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0); ImageLoader.getInstance().cancelLoadingForImageReceiver(this, 0);
recycleBitmap(null, false); recycleBitmap(null, false);
@ -497,10 +493,18 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
return imageX; return imageX;
} }
public int getImageX2() {
return imageX + imageW;
}
public int getImageY() { public int getImageY() {
return imageY; return imageY;
} }
public int getImageY2() {
return imageY + imageH;
}
public int getImageWidth() { public int getImageWidth() {
return imageW; return imageW;
} }
@ -682,7 +686,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
if (newKey != null) { if (newKey != null) {
newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey); newBitmap = ImageLoader.getInstance().getImageFromMemory(newKey);
} }
if (key == null || image == null || image == newBitmap || disableRecycle) { if (key == null || image == null || image == newBitmap) {
return; return;
} }
Bitmap bitmap = image.getBitmap(); Bitmap bitmap = image.getBitmap();

View File

@ -19,12 +19,12 @@ import android.text.format.DateFormat;
import android.util.Xml; import android.util.Xml;
import org.telegram.android.time.FastDateFormat; import org.telegram.android.time.FastDateFormat;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParser;
import java.io.File; 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()); "tr", "vi", "wo", "yo", "zh", "bo", "dz", "id", "jv", "ka", "km", "kn", "ms", "th"}, new PluralRules_None());
LocaleInfo localeInfo = new LocaleInfo(); 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.name = "العربية";
localeInfo.nameEnglish = "Arabic"; localeInfo.nameEnglish = "Arabic";
localeInfo.shortName = "ar"; localeInfo.shortName = "ar";
@ -181,6 +220,14 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, 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 = new LocaleInfo();
localeInfo.name = "Hrvatski"; localeInfo.name = "Hrvatski";
localeInfo.nameEnglish = "Croatian"; localeInfo.nameEnglish = "Croatian";
@ -189,29 +236,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, 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 = new LocaleInfo();
localeInfo.name = "Français"; localeInfo.name = "Français";
localeInfo.nameEnglish = "French"; localeInfo.nameEnglish = "French";
@ -226,22 +250,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, 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 = new LocaleInfo();
localeInfo.name = "Polski"; localeInfo.name = "Polski";
localeInfo.nameEnglish = "Polish"; localeInfo.nameEnglish = "Polish";
@ -250,6 +258,21 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo); languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Русский";
localeInfo.nameEnglish = "Russian";
localeInfo.shortName = "ru";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Türkçe";
localeInfo.nameEnglish = "Turkish";
localeInfo.shortName = "tr";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo(); localeInfo = new LocaleInfo();
localeInfo.name = "Português (Brasil)"; localeInfo.name = "Português (Brasil)";
localeInfo.nameEnglish = "Portuguese (Brazil)"; localeInfo.nameEnglish = "Portuguese (Brazil)";
@ -266,21 +289,6 @@ public class LocaleController {
sortedLanguages.add(localeInfo); sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo); languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Русский";
localeInfo.nameEnglish = "Russian";
localeInfo.shortName = "ru";
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo();
localeInfo.name = "Türkçe";
localeInfo.nameEnglish = "Turkish";
localeInfo.shortName = "tr";
localeInfo.pathToFile = null;
sortedLanguages.add(localeInfo);
languagesDict.put(localeInfo.shortName, localeInfo);
localeInfo = new LocaleInfo(); localeInfo = new LocaleInfo();
localeInfo.name = "한국어"; localeInfo.name = "한국어";
localeInfo.nameEnglish = "Korean"; localeInfo.nameEnglish = "Korean";

View File

@ -48,6 +48,7 @@ import org.telegram.android.video.InputSurface;
import org.telegram.android.video.MP4Builder; import org.telegram.android.video.MP4Builder;
import org.telegram.android.video.Mp4Movie; import org.telegram.android.video.Mp4Movie;
import org.telegram.android.video.OutputSurface; import org.telegram.android.video.OutputSurface;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.DispatchQueue; import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
@ -56,7 +57,6 @@ import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.Cells.ChatMediaCell; import org.telegram.ui.Cells.ChatMediaCell;
import org.telegram.ui.Components.GifDrawable; 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))) { if (proximitySensor != null && audioTrackPlayer == null && audioPlayer == null || isPaused || (useFrontSpeaker == (event.values[0] < proximitySensor.getMaximumRange() / 10))) {
return; 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; ignoreProximity = true;
useFrontSpeaker = event.values[0] < proximitySensor.getMaximumRange() / 10; useFrontSpeaker = newValue;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker); NotificationCenter.getInstance().postNotificationName(NotificationCenter.audioRouteChanged, useFrontSpeaker);
MessageObject currentMessageObject = playingMessageObject; MessageObject currentMessageObject = playingMessageObject;
float progress = playingMessageObject.audioProgress; float progress = playingMessageObject.audioProgress;

View File

@ -8,6 +8,7 @@
package org.telegram.android; package org.telegram.android;
import android.content.SharedPreferences;
import android.graphics.Paint; import android.graphics.Paint;
import android.text.Layout; import android.text.Layout;
import android.text.Spannable; import android.text.Spannable;
@ -18,11 +19,12 @@ import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.URLSpanNoUnderline; import org.telegram.ui.Components.URLSpanNoUnderline;
@ -41,6 +43,7 @@ public class MessageObject {
public TLRPC.Message messageOwner; public TLRPC.Message messageOwner;
public CharSequence messageText; public CharSequence messageText;
public CharSequence linkDescription;
public MessageObject replyMessageObject; public MessageObject replyMessageObject;
public int type; public int type;
public int contentType; public int contentType;
@ -76,16 +79,17 @@ public class MessageObject {
textPaint.setColor(0xff000000); textPaint.setColor(0xff000000);
textPaint.linkColor = 0xff316f9f; 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)); textPaint.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
textPaintLeft.setColor(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000)); textPaintLeft.setColor(themePrefs.getInt("chatLTextColor", 0xff000000));
textPaintLeft.linkColor = AndroidUtilities.getIntDarkerColor("chatLTextColor", -0x10); textPaintLeft.linkColor = themePrefs.getInt("chatLLinkColor", def);
textPaintLeft.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); textPaintLeft.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
textPaint = textPaintLeft; textPaint = textPaintLeft;
textPaintRight.setColor(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000)); textPaintRight.setColor(themePrefs.getInt("chatRTextColor", 0xff000000));
textPaintRight.linkColor = AndroidUtilities.getIntDarkerColor("chatRTextColor", -0x10); textPaintRight.linkColor = themePrefs.getInt("chatRLinkColor", def);
textPaintRight.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize)); textPaintRight.setTextSize(AndroidUtilities.dp(MessagesController.getInstance().fontSize));
messageOwner = message; messageOwner = message;
@ -96,6 +100,7 @@ public class MessageObject {
if(isOut()){ if(isOut()){
textPaint = textPaintRight; textPaint = textPaintRight;
textPaint.linkColor = themePrefs.getInt("chatRLinkColor", def);
} }
if (message instanceof TLRPC.TL_messageService) { if (message instanceof TLRPC.TL_messageService) {
@ -288,7 +293,7 @@ public class MessageObject {
messageText = LocaleController.formatString("YouCreatedBroadcastList", R.string.YouCreatedBroadcastList); 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) { if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto); messageText = LocaleController.getString("AttachPhoto", R.string.AttachPhoto);
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
@ -324,22 +329,22 @@ public class MessageObject {
messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageText = Emoji.replaceEmoji(messageText, textPaint.getFontMetricsInt(), AndroidUtilities.dp(20));
if (message instanceof TLRPC.TL_message || message instanceof TLRPC.TL_messageForwarded_old2) { 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; 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; contentType = type = 1;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaGeo) { } else if (message.media instanceof TLRPC.TL_messageMediaGeo) {
contentType = 1; contentType = 1;
type = 4; type = 4;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaVideo) { } else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
contentType = 1; contentType = 1;
type = 3; type = 3;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaContact) { } else if (message.media instanceof TLRPC.TL_messageMediaContact) {
contentType = 3; contentType = 3;
type = 12; type = 12;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaUnsupported) { } else if (message.media instanceof TLRPC.TL_messageMediaUnsupported) {
contentType = type = 0; contentType = type = 0;
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaDocument) { } else if (message.media instanceof TLRPC.TL_messageMediaDocument) {
contentType = 1; contentType = 1;
if (message.media.document.mime_type != null) { 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)) { 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 { } else {
type = 9; type = 9;
} }
} else if (message.media != null && message.media instanceof TLRPC.TL_messageMediaAudio) { } else if (message.media instanceof TLRPC.TL_messageMediaAudio) {
contentType = type = 2; contentType = type = 2;
} }
} else if (message instanceof TLRPC.TL_messageService) { } else if (message instanceof TLRPC.TL_messageService) {
@ -448,6 +453,24 @@ public class MessageObject {
photoObject.location = messageOwner.media.document.thumb.location; 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; 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() { private void generateLayout() {
if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) { if (type != 0 || messageOwner.to_id == null || messageText == null || messageText.length() == 0) {
return; return;
} }
generateLinkDescription();
textLayoutBlocks = new ArrayList<>(); textLayoutBlocks = new ArrayList<>();
if (messageText instanceof Spannable && containsUrls(messageText)) { if (messageText instanceof Spannable && containsUrls(messageText)) {
@ -796,7 +832,7 @@ public class MessageObject {
} }
public boolean isSending() { 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() { public boolean isSendError() {
@ -804,7 +840,7 @@ public class MessageObject {
} }
public boolean isSent() { 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() { public String getSecretTimeString() {
@ -959,4 +995,12 @@ public class MessageObject {
public boolean isReply() { 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; 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;
}
} }

View File

@ -13,10 +13,10 @@ import android.app.AlertDialog;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
import android.os.Build; import android.os.Build;
import android.text.Html;
import android.util.Base64; import android.util.Base64;
import android.util.SparseArray; import android.util.SparseArray;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -28,7 +28,6 @@ import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import java.util.ArrayList; import java.util.ArrayList;
@ -179,7 +178,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
public void updateConfig(final TLRPC.TL_config config) { public void updateConfig(final TLRPC.TL_config config) {
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() { //TODO use new config params
@Override @Override
public void run() { public void run() {
maxBroadcastCount = config.broadcast_size_max; maxBroadcastCount = config.broadcast_size_max;
@ -1307,12 +1306,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (label.length() != 0) { if (label.length() != 0) {
if (count > 1) { if (count > 1) {
if (arr.size() > 2) { 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 { } 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 { } 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) { for (TLRPC.Message message : messagesRes.messages) {
message.dialog_id = dialog_id; message.dialog_id = dialog_id;
objects.add(new MessageObject(message, usersLocal, true)); 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 (message.media.bytes.length == 0 || message.media.bytes.length == 1 && message.media.bytes[0] < TLRPC.LAYER) {
if (messagesToReload == null) { if (messagesToReload == null) {
messagesToReload = new ArrayList<>(); messagesToReload = new ArrayList<>();
} }
messagesToReload.add(message.id); 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) { if (messagesToReload != null) {
@ -1941,7 +1949,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
} }
public long createChat(String title, ArrayList<Integer> selectedContacts, final TLRPC.InputFile uploadedAvatar, boolean isBroadcast) { public long createChat(String title, ArrayList<Integer> selectedContacts, boolean isBroadcast) {
if (isBroadcast) { if (isBroadcast) {
TLRPC.TL_chat chat = new TLRPC.TL_chat(); TLRPC.TL_chat chat = new TLRPC.TL_chat();
chat.id = UserConfig.lastBroadcastId; chat.id = UserConfig.lastBroadcastId;
@ -2015,35 +2023,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}); });
return; return;
} }
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; final TLRPC.Updates updates = (TLRPC.Updates) response;
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true); processUpdates(updates, false);
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
putUsers(res.users, false); putUsers(updates.users, false);
putChats(res.chats, false); putChats(updates.chats, false);
final ArrayList<MessageObject> messagesObj = new ArrayList<>(); TLRPC.Chat chat = null;
messagesObj.add(new MessageObject(res.message, users, true)); if (updates.chats != null && !updates.chats.isEmpty()) {
TLRPC.Chat chat = res.chats.get(0); NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, updates.chats.get(0).id);
updateInterfaceWithMessages(-chat.id, messagesObj); } else {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidFailCreate);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.chatDidCreated, chat.id);
if (uploadedAvatar != null) {
changeChatAvatar(chat.id, uploadedAvatar);
} }
} }
}); });
final ArrayList<TLRPC.Message> 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,48 +2060,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) { if (error != null) {
return; return;
} }
processUpdates((TLRPC.Updates) response, false);
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<MessageObject> 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);
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<TLRPC.Message> 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 { } else {
@ -2150,57 +2103,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) { if (error != null) {
return; 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()) { if (user.id == UserConfig.getClientUserId()) {
res.chats = null;
}
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
putUsers(res.users, false); MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
putChats(res.chats, false);
if (user.id != UserConfig.getClientUserId()) {
final ArrayList<MessageObject> 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);
}
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<TLRPC.Message> 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);
} }
} }
}); });
@ -2243,32 +2154,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) { if (error != null) {
return; return;
} }
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; processUpdates((TLRPC.Updates) response, false);
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<MessageObject> 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<TLRPC.Message> 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 { } else {
@ -2298,34 +2184,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (error != null) { if (error != null) {
return; return;
} }
final TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; processUpdates((TLRPC.Updates) response, false);
MessagesStorage.getInstance().putUsersAndChats(res.users, res.chats, true, true);
final ArrayList<TLRPC.Message> 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<MessageObject> 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);
}
} }
}); });
} }
@ -2617,6 +2476,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
req.pts = MessagesStorage.lastPtsValue; req.pts = MessagesStorage.lastPtsValue;
req.date = MessagesStorage.lastDateValue; req.date = MessagesStorage.lastDateValue;
req.qts = MessagesStorage.lastQtsValue; 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); FileLog.e("tmessages", "start getDifference with date = " + MessagesStorage.lastDateValue + " pts = " + MessagesStorage.lastPtsValue + " seq = " + MessagesStorage.lastSeqValue);
if (ConnectionsManager.getInstance().getConnectionState() == 0) { if (ConnectionsManager.getInstance().getConnectionState() == 0) {
ConnectionsManager.getInstance().setConnectionState(3); ConnectionsManager.getInstance().setConnectionState(3);
@ -2681,7 +2543,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
Integer oldId = entry.getKey(); Integer oldId = entry.getKey();
SendMessagesHelper.getInstance().processSentMessage(oldId); SendMessagesHelper.getInstance().processSentMessage(oldId);
Integer newId = entry.getValue(); 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 user = getUser(updates.user_id);
TLRPC.User user2 = null; TLRPC.User user2 = null;
if (user == null) {
user = MessagesStorage.getInstance().getUserSync(updates.user_id);
putUser(user, true);
}
boolean needFwdUser = false; boolean needFwdUser = false;
if (updates.fwd_from_id != 0) { if (updates.fwd_from_id != 0) {
user2 = getUser(updates.fwd_from_id); user2 = getUser(updates.fwd_from_id);
if (user2 == null) {
user2 = MessagesStorage.getInstance().getUserSync(updates.fwd_from_id);
putUser(user2, true);
}
needFwdUser = true; needFwdUser = true;
} }
@ -2870,7 +2741,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
if (updates instanceof TLRPC.TL_updateShortMessage) { if (updates instanceof TLRPC.TL_updateShortMessage) {
missingData = user == null || needFwdUser && user2 == null; missingData = user == null || needFwdUser && user2 == null;
} else { } 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) { if (user != null && user.status != null && user.status.expires <= 0) {
onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime()); onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime());
@ -3036,7 +2912,9 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} }
if (processUpdate) { if (processUpdate) {
processUpdateArray(updates.updates, updates.users, updates.chats); processUpdateArray(updates.updates, updates.users, updates.chats);
if (updates.date != 0) {
MessagesStorage.lastDateValue = updates.date; MessagesStorage.lastDateValue = updates.date;
}
if (updates.seq != 0) { if (updates.seq != 0) {
MessagesStorage.lastSeqValue = updates.seq; MessagesStorage.lastSeqValue = updates.seq;
} }
@ -3113,6 +2991,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
long currentTime = System.currentTimeMillis(); long currentTime = System.currentTimeMillis();
final HashMap<Long, ArrayList<MessageObject>> messages = new HashMap<>(); final HashMap<Long, ArrayList<MessageObject>> messages = new HashMap<>();
final HashMap<Long, TLRPC.WebPage> webPages = new HashMap<>();
final ArrayList<MessageObject> pushMessages = new ArrayList<>(); final ArrayList<MessageObject> pushMessages = new ArrayList<>();
final ArrayList<TLRPC.Message> messagesArr = new ArrayList<>(); final ArrayList<TLRPC.Message> messagesArr = new ArrayList<>();
final HashMap<Integer, Integer> markAsReadMessagesInbox = new HashMap<>(); final HashMap<Integer, Integer> markAsReadMessagesInbox = new HashMap<>();
@ -3305,6 +3184,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
} else if (update instanceof TLRPC.TL_updateActivation) { } else if (update instanceof TLRPC.TL_updateActivation) {
//DEPRECATED //DEPRECATED
} else if (update instanceof TLRPC.TL_updateNewAuthorization) { } 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(); TLRPC.TL_messageService newMessage = new TLRPC.TL_messageService();
newMessage.action = new TLRPC.TL_messageActionLoginUnknownLocation(); newMessage.action = new TLRPC.TL_messageActionLoginUnknownLocation();
newMessage.action.title = update.device; newMessage.action.title = update.device;
@ -3438,6 +3323,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
pushMessages.add(obj); pushMessages.add(obj);
} else if (update instanceof TLRPC.TL_updatePrivacy) { } else if (update instanceof TLRPC.TL_updatePrivacy) {
updatesOnMainThread.add(update); updatesOnMainThread.add(update);
} else if (update instanceof TLRPC.TL_updateWebPage) {
webPages.put(update.webpage.id, update.webpage);
} }
} }
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
@ -3618,6 +3505,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter
MessagesStorage.getInstance().updateUsers(dbUsers, false, true, true); MessagesStorage.getInstance().updateUsers(dbUsers, false, true, true);
} }
if (!webPages.isEmpty()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceivedWebpagesInUpdates, webPages);
}
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
for (HashMap.Entry<Long, ArrayList<MessageObject>> entry : messages.entrySet()) { for (HashMap.Entry<Long, ArrayList<MessageObject>> entry : messages.entrySet()) {
Long key = entry.getKey(); 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() || !markAsReadEncrypted.isEmpty()) {
if (!markAsReadMessagesInbox.isEmpty() || !markAsReadMessagesOutbox.isEmpty()) { if (!markAsReadMessagesInbox.isEmpty() || !markAsReadMessagesOutbox.isEmpty()) {
MessagesStorage.getInstance().updateDialogsWithReadedMessages(markAsReadMessagesInbox, true); MessagesStorage.getInstance().updateDialogsWithReadedMessages(markAsReadMessagesInbox, true);

View File

@ -18,6 +18,7 @@ import org.telegram.SQLite.SQLiteCursor;
import org.telegram.SQLite.SQLiteDatabase; import org.telegram.SQLite.SQLiteDatabase;
import org.telegram.SQLite.SQLitePreparedStatement; import org.telegram.SQLite.SQLitePreparedStatement;
import org.telegram.android.query.SharedMediaQuery; import org.telegram.android.query.SharedMediaQuery;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuffersStorage; import org.telegram.messenger.BuffersStorage;
import org.telegram.messenger.ByteBufferDesc; import org.telegram.messenger.ByteBufferDesc;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
@ -29,7 +30,6 @@ import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import java.io.File; import java.io.File;
import java.util.ArrayList; 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 web_recent_v3(id TEXT, type INTEGER, image_url TEXT, thumb_url TEXT, local_url TEXT, width INTEGER, height INTEGER, size INTEGER, date INTEGER, PRIMARY KEY (id, type));").stepThis().dispose();
database.executeFast("CREATE TABLE stickers(id INTEGER PRIMARY KEY, data BLOB, date INTEGER);").stepThis().dispose(); database.executeFast("CREATE TABLE stickers(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 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_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(); 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(); database.executeFast("CREATE TABLE keyvalue(id TEXT PRIMARY KEY, value TEXT)").stepThis().dispose();
//version //version
database.executeFast("PRAGMA user_version = 15").stepThis().dispose(); database.executeFast("PRAGMA user_version = 16").stepThis().dispose();
} else { } else {
try { try {
SQLiteCursor cursor = database.queryFinalized("SELECT seq, pts, date, qts, lsv, sg, pbytes FROM params WHERE id = 1"); 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"); int version = database.executeInt("PRAGMA user_version");
if (version < 15) { if (version < 16) {
updateDbToLastVersion(version); updateDbToLastVersion(version);
} }
} }
@ -379,6 +380,11 @@ public class MessagesStorage {
database.executeFast("PRAGMA user_version = 15").stepThis().dispose(); database.executeFast("PRAGMA user_version = 15").stepThis().dispose();
version = 15; 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) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
@ -2660,6 +2666,79 @@ public class MessagesStorage {
return -1; return -1;
} }
public void putWebPages(final HashMap<Long, TLRPC.WebPage> 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<Integer> mids = new ArrayList<>();
while (cursor.next()) {
mids.add(cursor.intValue(0));
}
cursor.dispose();
if (mids.isEmpty()) {
return;
}
final ArrayList<TLRPC.Message> 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<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast, final int downloadMask) { private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast, final int downloadMask) {
try { try {
if (withTransaction) { if (withTransaction) {
@ -2677,6 +2756,7 @@ public class MessagesStorage {
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)"); SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media_v2 VALUES(?, ?, ?, ?, ?)");
SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO randoms VALUES(?, ?)"); SQLitePreparedStatement state3 = database.executeFast("REPLACE INTO randoms VALUES(?, ?)");
SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?)"); SQLitePreparedStatement state4 = database.executeFast("REPLACE INTO download_queue VALUES(?, ?, ?, ?)");
SQLitePreparedStatement state5 = database.executeFast("REPLACE INTO webpage_pending VALUES(?, ?)");
for (TLRPC.Message message : messages) { for (TLRPC.Message message : messages) {
long dialog_id = message.dialog_id; long dialog_id = message.dialog_id;
@ -2810,15 +2890,23 @@ public class MessagesStorage {
state2.bindByteBuffer(5, data.buffer); state2.bindByteBuffer(5, data.buffer);
state2.step(); 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); 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) { 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; int type = 0;
long id = 0; long id = 0;
TLObject object = null; TLObject object = null;
if (message.media instanceof TLRPC.TL_messageMediaAudio) { 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; id = message.media.audio.id;
type = MediaController.AUTODOWNLOAD_MASK_AUDIO; type = MediaController.AUTODOWNLOAD_MASK_AUDIO;
object = message.media.audio; object = message.media.audio;
@ -2864,6 +2952,7 @@ public class MessagesStorage {
state2.dispose(); state2.dispose();
state3.dispose(); state3.dispose();
state4.dispose(); state4.dispose();
state5.dispose();
state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)"); state = database.executeFast("REPLACE INTO dialogs(did, date, unread_count, last_mid) VALUES(?, ?, ?, ?)");
for (HashMap.Entry<Long, TLRPC.Message> pair : messagesMap.entrySet()) { for (HashMap.Entry<Long, TLRPC.Message> pair : messagesMap.entrySet()) {
@ -3543,11 +3632,19 @@ public class MessagesStorage {
} }
private void fixUnsupportedMedia(TLRPC.Message message) { 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) { if (message.media.bytes.length == 0) {
message.media.bytes = new byte[1]; message.media.bytes = new byte[1];
message.media.bytes[0] = TLRPC.LAYER; 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) { public TLRPC.User getUser(final int user_id) {
TLRPC.User user = null; TLRPC.User user = null;
try { try {

View File

@ -23,7 +23,7 @@ import java.util.zip.ZipFile;
public class NativeLoader { 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_NAME = "tmessages." + LIB_VERSION;
private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so";
private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so";

View File

@ -49,9 +49,13 @@ public class NotificationCenter {
public static final int recentImagesDidLoaded = totalEvents++; public static final int recentImagesDidLoaded = totalEvents++;
public static final int replaceMessagesObjects = totalEvents++; public static final int replaceMessagesObjects = totalEvents++;
public static final int didSetPasscode = totalEvents++; public static final int didSetPasscode = totalEvents++;
public static final int didSetTwoStepPassword = totalEvents++;
public static final int screenStateChanged = totalEvents++; public static final int screenStateChanged = totalEvents++;
public static final int appSwitchedToForeground = totalEvents++; public static final int appSwitchedToForeground = totalEvents++;
public static final int didLoadedReplyMessages = 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 httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++;
@ -64,7 +68,6 @@ public class NotificationCenter {
public static final int didReceiveSmsCode = totalEvents++; public static final int didReceiveSmsCode = totalEvents++;
public static final int emojiDidLoaded = totalEvents++; public static final int emojiDidLoaded = totalEvents++;
public static final int appDidLogout = totalEvents++; public static final int appDidLogout = totalEvents++;
public static final int needPasswordEnter = totalEvents++;
public static final int FileDidUpload = totalEvents++; public static final int FileDidUpload = totalEvents++;
public static final int FileDidFailUpload = totalEvents++; public static final int FileDidFailUpload = totalEvents++;

View File

@ -17,10 +17,10 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.media.AudioManager; import android.media.AudioManager;
import android.media.MediaPlayer; import android.media.MediaPlayer;
import android.media.SoundPool;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
@ -31,6 +31,7 @@ import android.support.v4.app.RemoteInput;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.DispatchQueue; import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -39,7 +40,6 @@ import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject; import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PopupNotificationActivity; import org.telegram.ui.PopupNotificationActivity;
@ -70,11 +70,10 @@ public class NotificationsController {
private int lastOnlineFromOtherDevice = 0; private int lastOnlineFromOtherDevice = 0;
private boolean inChatSoundEnabled = true; private boolean inChatSoundEnabled = true;
private SoundPool soundPool;
private int inChatOutgoingSound;
private long lastSoundPlay; private long lastSoundPlay;
private MediaPlayer mediaPlayer; private MediaPlayer mediaPlayerIn;
private String lastMediaPlayerUri; private MediaPlayer mediaPlayerOut;
protected AudioManager audioManager;
private static volatile NotificationsController Instance = null; private static volatile NotificationsController Instance = null;
public static NotificationsController getInstance() { public static NotificationsController getInstance() {
@ -96,9 +95,8 @@ public class NotificationsController {
inChatSoundEnabled = preferences.getBoolean("EnableInChatSound", true); inChatSoundEnabled = preferences.getBoolean("EnableInChatSound", true);
try { try {
soundPool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 0); audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(Context.AUDIO_SERVICE);
inChatOutgoingSound = soundPool.load(ApplicationLoader.applicationContext, R.raw.sound_out, 1); //mediaPlayer = new MediaPlayer();
mediaPlayer = new MediaPlayer();
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", 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); msg = LocaleController.formatString("NotificationUnrecognizedDevice", R.string.NotificationUnrecognizedDevice, UserConfig.getCurrentUser().first_name, date, messageObject.messageOwner.action.title, messageObject.messageOwner.action.address);
} }
} else { } else {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) { if (messageObject.isMediaEmpty()) {
if (!shortMessage) { if (!shortMessage) {
if (messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) { if (messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.message); msg = LocaleController.formatString("NotificationMessageText", R.string.NotificationMessageText, ContactsController.formatName(user.first_name, user.last_name), messageObject.messageOwner.message);
@ -240,7 +238,7 @@ public class NotificationsController {
msg = messageObject.messageText.toString(); msg = messageObject.messageText.toString();
} }
} else { } else {
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty) { if (messageObject.isMediaEmpty()) {
if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) { if (!shortMessage && messageObject.messageOwner.message != null && messageObject.messageOwner.message.length() != 0) {
msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, ContactsController.formatName(user.first_name, user.last_name), chat.title, messageObject.messageOwner.message); msg = LocaleController.formatString("NotificationMessageGroupText", R.string.NotificationMessageGroupText, ContactsController.formatName(user.first_name, user.last_name), chat.title, messageObject.messageOwner.message);
} else { } else {
@ -416,6 +414,7 @@ public class NotificationsController {
inAppPriority = preferences.getBoolean("EnableInAppPriority", false); inAppPriority = preferences.getBoolean("EnableInAppPriority", false);
vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0); vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0);
priority_override = preferences.getInt("priority_" + dialog_id, 3); priority_override = preferences.getInt("priority_" + dialog_id, 3);
boolean vibrateOnlyIfSilent = false;
choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null); choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null);
if (chat_id != 0) { if (chat_id != 0) {
@ -445,6 +444,10 @@ public class NotificationsController {
priority = priority_override; 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) { if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) {
needVibrate = vibrate_override; needVibrate = vibrate_override;
} }
@ -461,6 +464,16 @@ public class NotificationsController {
priority = 1; 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); Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
@ -852,13 +865,53 @@ public class NotificationsController {
if (!inChatSoundEnabled) { if (!inChatSoundEnabled) {
return; return;
} }
if (lastSoundPlay > System.currentTimeMillis() - 1800) { try {
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; return;
} }
try { try {
String choosenSoundPath = null; 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(); String defaultPath = Settings.System.DEFAULT_NOTIFICATION_URI.getPath();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE);
choosenSoundPath = preferences.getString("sound_path_" + openned_dialog_id, null); choosenSoundPath = preferences.getString("sound_path_" + openned_dialog_id, null);
boolean isChat = (int)(openned_dialog_id) < 0; boolean isChat = (int)(openned_dialog_id) < 0;
if (isChat) { if (isChat) {
@ -888,7 +941,7 @@ public class NotificationsController {
mediaPlayer.prepare(); mediaPlayer.prepare();
} }
mediaPlayer.start(); mediaPlayer.start();
} }*/
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
@ -899,10 +952,33 @@ public class NotificationsController {
return; return;
} }
try { try {
soundPool.play(inChatOutgoingSound, 1, 1, 1, 0, 1); if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
return;
}
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", 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<MessageObject> messageObjects, boolean isLast) { public void processNewMessages(ArrayList<MessageObject> messageObjects, boolean isLast) {
@ -1145,7 +1221,7 @@ public class NotificationsController {
try { try {
ContentValues cv = new ContentValues(); ContentValues cv = new ContentValues();
//cv.put("tag", "org.telegram.messenger/org.telegram.ui.LaunchActivity"); //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); cv.put("count", count);
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv); context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -119,7 +119,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -224,7 +224,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -252,7 +252,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -283,7 +283,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -312,7 +312,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -343,7 +343,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -375,7 +375,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -406,7 +406,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -436,7 +436,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -464,7 +464,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -500,7 +500,7 @@ public class SecretChatHelper {
reqSend = new TLRPC.TL_decryptedMessageService(); reqSend = new TLRPC.TL_decryptedMessageService();
} else { } else {
reqSend = new TLRPC.TL_decryptedMessageService_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
@ -659,7 +659,7 @@ public class SecretChatHelper {
int myLayer = Math.max(17, AndroidUtilities.getMyLayerVersion(chat.layer)); int myLayer = Math.max(17, AndroidUtilities.getMyLayerVersion(chat.layer));
layer.layer = Math.min(myLayer, AndroidUtilities.getPeerLayerVersion(chat.layer)); layer.layer = Math.min(myLayer, AndroidUtilities.getPeerLayerVersion(chat.layer));
layer.message = req; 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); Utilities.random.nextBytes(layer.random_bytes);
toEncryptObject = layer; toEncryptObject = layer;
@ -795,7 +795,7 @@ public class SecretChatHelper {
@Override @Override
public void run() { public void run() {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; 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); SendMessagesHelper.getInstance().processSentMessage(newMsgObj.id);
if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) { if (newMsgObj.media instanceof TLRPC.TL_messageMediaVideo) {
SendMessagesHelper.getInstance().stopVideoService(attachPath); SendMessagesHelper.getInstance().stopVideoService(attachPath);
@ -1104,10 +1104,7 @@ public class SecretChatHelper {
} }
byte[] salt = new byte[256]; byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { Utilities.random.nextBytes(salt);
salt[a] = (byte) (Utilities.random.nextDouble() * 256);
}
BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes); BigInteger p = new BigInteger(1, MessagesStorage.secretPBytes);
BigInteger g_b = BigInteger.valueOf(MessagesStorage.secretG); BigInteger g_b = BigInteger.valueOf(MessagesStorage.secretG);
g_b = g_b.modPow(new BigInteger(1, salt), p); g_b = g_b.modPow(new BigInteger(1, salt), p);
@ -1409,9 +1406,7 @@ public class SecretChatHelper {
return; return;
} }
final byte[] salt = new byte[256]; final byte[] salt = new byte[256];
for (int a = 0; a < 256; a++) { Utilities.random.nextBytes(salt);
salt[a] = (byte) (Utilities.random.nextDouble() * 256);
}
BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG); BigInteger i_g_a = BigInteger.valueOf(MessagesStorage.secretG);
i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes)); i_g_a = i_g_a.modPow(new BigInteger(1, salt), new BigInteger(1, MessagesStorage.secretPBytes));

View File

@ -19,6 +19,7 @@ import android.provider.MediaStore;
import android.webkit.MimeTypeMap; import android.webkit.MimeTypeMap;
import android.widget.Toast; import android.widget.Toast;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
@ -28,7 +29,6 @@ import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.messenger.ApplicationLoader;
import java.io.File; import java.io.File;
import java.io.RandomAccessFile; import java.io.RandomAccessFile;
@ -447,7 +447,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (messageObject == null) { if (messageObject == null) {
return; 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) { if (messageObject.messageOwner.media.photo instanceof TLRPC.TL_photo) {
sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did, messageObject.replyMessageObject); sendMessage((TLRPC.TL_photo) messageObject.messageOwner.media.photo, null, null, did, messageObject.replyMessageObject);
} else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) { } else if (messageObject.messageOwner.media.audio instanceof TLRPC.TL_audio) {
@ -471,14 +471,18 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
sendMessage(messageObject, did); sendMessage(messageObject, did);
} }
} else if (messageObject.messageOwner.message != null) { } 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 { } else {
sendMessage(messageObject, did); sendMessage(messageObject, did);
} }
} }
public void sendMessage(TLRPC.User user, long peer, MessageObject reply_to_msg) { 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<MessageObject> messages, long peer) { public void sendMessage(ArrayList<MessageObject> messages, long peer) {
@ -567,26 +571,32 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
req.id = ids; req.id = ids;
final ArrayList<TLRPC.Message> newMsgObjArr = arr; final ArrayList<TLRPC.Message> newMsgObjArr = arr;
final HashMap<Long, TLRPC.Message> messagesByRandomIdsFinal = messagesByRandomIds;
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) { if (error == null) {
final TLRPC.messages_StatedMessages res = (TLRPC.messages_StatedMessages) response; HashMap<Integer, Long> newMessagesByIds = new HashMap<>();
if (newMsgObjArr.size() != res.messages.size()) { TLRPC.Updates updates = (TLRPC.Updates) response;
MessagesController.getInstance().getDifference(); for (int a = 0; a < updates.updates.size(); a++) {
return; 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--;
} }
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++) { for (TLRPC.Update update : updates.updates) {
TLRPC.Message message = res.messages.get(a); if (update instanceof TLRPC.TL_updateNewMessage) {
final TLRPC.Message newMsgObj = newMsgObjArr.get(a); 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) { if (newMsgObj == null) {
continue; continue;
} }
newMsgObjArr.remove(newMsgObj);
final int oldId = newMsgObj.id; final int oldId = newMsgObj.id;
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>(); final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
sentMessages.add(message); sentMessages.add(message);
@ -601,7 +611,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
@Override @Override
public void run() { public void run() {
newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT; newMsgObj.send_state = MessageObject.MESSAGE_SEND_STATE_SENT;
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, newMsgObj.id, newMsgObj, false);
processSentMessage(oldId); processSentMessage(oldId);
removeFromSendingMessages(oldId); removeFromSendingMessages(oldId);
} }
@ -612,7 +622,9 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
}); });
} }
} else { }
}
}
for (final TLRPC.Message newMsgObj : newMsgObjArr) { for (final TLRPC.Message newMsgObj : newMsgObjArr) {
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id); MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() {
@ -629,7 +641,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
}); });
} }
} }
}
}, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress, ConnectionsManager.DEFAULT_DATACENTER_ID); }, null, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassCanCompress, ConnectionsManager.DEFAULT_DATACENTER_ID);
if (a != messages.size() - 1) { if (a != messages.size() - 1) {
@ -644,38 +655,38 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
public void sendMessage(MessageObject message) { 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) { 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) { 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) { 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); 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) { 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) { 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) { 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) { 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) { if (peer == 0) {
return; return;
} }
@ -741,7 +752,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} else { } else {
newMsg = new TLRPC.TL_message(); newMsg = new TLRPC.TL_message();
} }
if (encryptedChat != null || webPage == null) {
newMsg.media = new TLRPC.TL_messageMediaEmpty(); newMsg.media = new TLRPC.TL_messageMediaEmpty();
} else {
newMsg.media = new TLRPC.TL_messageMediaWebPage();
newMsg.media.webpage = webPage;
}
type = 0; type = 0;
newMsg.message = message; newMsg.message = message;
} else if (lat != null && lon != null) { } else if (lat != null && lon != null) {
@ -860,6 +876,8 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (lower_id != 0) { if (lower_id != 0) {
if (high_id == 1) { if (high_id == 1) {
if (currentChatInfo == null) { if (currentChatInfo == null) {
MessagesStorage.getInstance().markMessageAsSendError(newMsg.id);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageSendError, newMsg.id);
processSentMessage(newMsg.id); processSentMessage(newMsg.id);
return; return;
} }
@ -932,9 +950,14 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (encryptedChat == null) { if (encryptedChat == null) {
if (sendToPeers != null) { if (sendToPeers != null) {
TLRPC.TL_messages_sendBroadcast reqSend = new TLRPC.TL_messages_sendBroadcast(); TLRPC.TL_messages_sendBroadcast reqSend = new TLRPC.TL_messages_sendBroadcast();
ArrayList<Long> random_ids = new ArrayList<>();
for (int a = 0; a < sendToPeers.size(); a++) {
random_ids.add(Utilities.random.nextLong());
}
reqSend.message = message; reqSend.message = message;
reqSend.contacts = sendToPeers; reqSend.contacts = sendToPeers;
reqSend.media = new TLRPC.TL_inputMediaEmpty(); reqSend.media = new TLRPC.TL_inputMediaEmpty();
reqSend.random_id = random_ids;
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null); performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
} else { } else {
TLRPC.TL_messages_sendMessage reqSend = new TLRPC.TL_messages_sendMessage(); TLRPC.TL_messages_sendMessage reqSend = new TLRPC.TL_messages_sendMessage();
@ -942,8 +965,12 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.peer = sendToPeer; reqSend.peer = sendToPeer;
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
if (reply_to_msg != null) { if (reply_to_msg != null) {
reqSend.flags |= 1;
reqSend.reply_to_msg_id = reply_to_msg.getId(); reqSend.reply_to_msg_id = reply_to_msg.getId();
} }
if (!searchLinks) {
reqSend.flags |= 2;
}
performSendMessageRequest(reqSend, newMsgObj.messageOwner, null); performSendMessageRequest(reqSend, newMsgObj.messageOwner, null);
} }
} else { } else {
@ -953,7 +980,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.ttl = newMsg.ttl; reqSend.ttl = newMsg.ttl;
} else { } else {
reqSend = new TLRPC.TL_decryptedMessage_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
@ -1065,8 +1092,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (sendToPeers != null) { if (sendToPeers != null) {
TLRPC.TL_messages_sendBroadcast request = new TLRPC.TL_messages_sendBroadcast(); TLRPC.TL_messages_sendBroadcast request = new TLRPC.TL_messages_sendBroadcast();
ArrayList<Long> random_ids = new ArrayList<>();
for (int a = 0; a < sendToPeers.size(); a++) {
random_ids.add(Utilities.random.nextLong());
}
request.contacts = sendToPeers; request.contacts = sendToPeers;
request.media = inputMedia; request.media = inputMedia;
request.random_id = random_ids;
request.message = ""; request.message = "";
if (delayedMessage != null) { if (delayedMessage != null) {
delayedMessage.sendRequest = request; delayedMessage.sendRequest = request;
@ -1078,6 +1110,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
request.random_id = newMsg.random_id; request.random_id = newMsg.random_id;
request.media = inputMedia; request.media = inputMedia;
if (reply_to_msg != null) { if (reply_to_msg != null) {
request.flags |= 1;
request.reply_to_msg_id = reply_to_msg.getId(); request.reply_to_msg_id = reply_to_msg.getId();
} }
if (delayedMessage != null) { if (delayedMessage != null) {
@ -1121,7 +1154,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.ttl = newMsg.ttl; reqSend.ttl = newMsg.ttl;
} else { } else {
reqSend = new TLRPC.TL_decryptedMessage_old(); 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); Utilities.random.nextBytes(reqSend.random_bytes);
} }
reqSend.random_id = newMsg.random_id; reqSend.random_id = newMsg.random_id;
@ -1424,47 +1457,43 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() { ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override @Override
public void run(TLObject response, TLRPC.TL_error error) { public void run(TLObject response, TLRPC.TL_error error) {
boolean isSentError = false;
if (error == null) { if (error == null) {
final int oldId = newMsgObj.id; final int oldId = newMsgObj.id;
final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast; final boolean isBroadcast = req instanceof TLRPC.TL_messages_sendBroadcast;
final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>(); final ArrayList<TLRPC.Message> sentMessages = new ArrayList<>();
final String attachPath = newMsgObj.attachPath; 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) { if (response instanceof TLRPC.messages_SentMessage) {
TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response; TLRPC.messages_SentMessage res = (TLRPC.messages_SentMessage) response;
newMsgObj.id = res.id; newMsgObj.local_id = newMsgObj.id = res.id;
newMsgObj.date = res.date; newMsgObj.date = res.date;
newMsgObj.media = res.media;
if (res instanceof TLRPC.TL_messages_sentMessage) { if (res instanceof TLRPC.TL_messages_sentMessage) {
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count); MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.date, res.pts_count);
} else if (res instanceof TLRPC.TL_messages_sentMessageLink) { } else if (res instanceof TLRPC.TL_messages_sentMessageLink) {
MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date, res.pts_count); MessagesController.getInstance().processNewDifferenceParams(res.seq, res.pts, res.date, res.pts_count);
} }
} else if (response instanceof TLRPC.messages_StatedMessage) { sentMessages.add(newMsgObj);
TLRPC.messages_StatedMessage res = (TLRPC.messages_StatedMessage) response; } else if (response instanceof TLRPC.Updates) {
sentMessages.add(res.message); TLRPC.TL_updateNewMessage newMessage = null;
newMsgObj.id = res.message.id; for (TLRPC.Update update : ((TLRPC.Updates) response).updates) {
processSentMessage(newMsgObj, res.message, originalPath); if (update instanceof TLRPC.TL_updateNewMessage) {
if (res instanceof TLRPC.TL_messages_statedMessage) { newMessage = (TLRPC.TL_updateNewMessage) update;
MessagesController.getInstance().processNewDifferenceParams(-1, res.pts, res.message.date, res.pts_count); break;
} 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;
}
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;
}
}
if (!isSentError) {
MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -1489,7 +1518,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload); NotificationCenter.getInstance().postNotificationName(NotificationCenter.dialogsNeedReload);
} }
NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj); NotificationCenter.getInstance().postNotificationName(NotificationCenter.messageReceivedByServer, oldId, (isBroadcast ? oldId : newMsgObj.id), newMsgObj, mediaUpdated);
processSentMessage(oldId); processSentMessage(oldId);
removeFromSendingMessages(oldId); removeFromSendingMessages(oldId);
} }
@ -1499,7 +1528,11 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
} }
}); });
}
} else { } else {
isSentError = true;
}
if (isSentError) {
MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id); MessagesStorage.getInstance().markMessageAsSendError(newMsgObj.id);
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() {
@Override @Override
@ -1810,8 +1843,13 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
if (bmOptions.outWidth != 0 && bmOptions.outHeight != 0 && bmOptions.outWidth <= 800 && bmOptions.outHeight <= 800) { if (bmOptions.outWidth != 0 && bmOptions.outHeight != 0 && bmOptions.outWidth <= 800 && bmOptions.outHeight <= 800) {
TLRPC.TL_documentAttributeSticker attributeSticker = new TLRPC.TL_documentAttributeSticker(); TLRPC.TL_documentAttributeSticker attributeSticker = null;
if (isEncrypted) {
attributeSticker = new TLRPC.TL_documentAttributeSticker_old();
} else {
attributeSticker = new TLRPC.TL_documentAttributeSticker();
attributeSticker.alt = ""; attributeSticker.alt = "";
}
document.attributes.add(attributeSticker); document.attributes.add(attributeSticker);
TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize(); TLRPC.TL_documentAttributeImageSize attributeImageSize = new TLRPC.TL_documentAttributeImageSize();
attributeImageSize.w = bmOptions.outWidth; attributeImageSize.w = bmOptions.outWidth;

View File

@ -31,7 +31,7 @@ public class WearReplyReceiver extends BroadcastReceiver {
if (dialog_id == 0 || max_id == 0) { if (dialog_id == 0 || max_id == 0) {
return; 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); MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
} }
} }

View File

@ -33,13 +33,13 @@ import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; 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.LocaleController;
import org.telegram.android.MediaController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NativeLoader; import org.telegram.android.NativeLoader;
import org.telegram.android.NotificationsService;
import org.telegram.android.ScreenReceiver; import org.telegram.android.ScreenReceiver;
import org.telegram.android.SendMessagesHelper;
import org.telegram.ui.Components.ForegroundDetector; import org.telegram.ui.Components.ForegroundDetector;
import java.io.File; import java.io.File;
@ -66,6 +66,8 @@ public class ApplicationLoader extends Application {
public static volatile boolean isScreenOn = false; public static volatile boolean isScreenOn = false;
public static volatile boolean mainInterfacePaused = true; public static volatile boolean mainInterfacePaused = true;
public static boolean SHOW_ANDROID_EMOJI;
public static boolean isCustomTheme() { public static boolean isCustomTheme() {
return isCustomTheme; return isCustomTheme;
} }
@ -193,6 +195,9 @@ public class ApplicationLoader extends Application {
applicationHandler = new Handler(applicationContext.getMainLooper()); applicationHandler = new Handler(applicationContext.getMainLooper());
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
SHOW_ANDROID_EMOJI = preferences.getBoolean("showAndroidEmoji", false);
startPushService(); startPushService();
} }

View File

@ -1037,11 +1037,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
for (int i = 0; i < runningRequests.size(); i++) { for (int i = 0; i < runningRequests.size(); i++) {
RPCRequest request = runningRequests.get(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; int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) { if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID) { if (movingToDatacenterId != DEFAULT_DATACENTER_ID) {
@ -1244,11 +1239,6 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
continue; continue;
} }
if (UserConfig.waitingForPasswordEnter && (request.flags & RPCRequest.RPCRequestClassWithoutLogin) == 0) {
FileLog.e("tmessages", "skip request " + request.rawRequest + ", need password enter");
continue;
}
int datacenterId = request.runningDatacenterId; int datacenterId = request.runningDatacenterId;
if (datacenterId == DEFAULT_DATACENTER_ID) { if (datacenterId == DEFAULT_DATACENTER_ID) {
if (movingToDatacenterId != DEFAULT_DATACENTER_ID && (request.flags & RPCRequest.RPCRequestClassEnableUnauthorized) == 0) { 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); request.completionBlock.run(resultContainer.result, null);
} }
} }
@ -2194,7 +2180,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (implicitError != null && implicitError.code == 401) { if (implicitError != null && implicitError.code == 401) {
isError = true; isError = true;
if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) { if (implicitError.text != null && implicitError.text.contains("SESSION_PASSWORD_NEEDED")) {
UserConfig.setWaitingForPasswordEnter(true); /*UserConfig.setWaitingForPasswordEnter(true); TODO
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
if (UserConfig.isClientActivated()) { if (UserConfig.isClientActivated()) {
discardResponse = true; discardResponse = true;
@ -2204,7 +2190,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter); NotificationCenter.getInstance().postNotificationName(NotificationCenter.needPasswordEnter);
} }
}); });
} }*/
} else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) { } else if (datacenter.datacenterId == currentDatacenterId || datacenter.datacenterId == movingToDatacenterId) {
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0 && UserConfig.isClientActivated()) {
UserConfig.clearConfig(); UserConfig.clearConfig();

View File

@ -33,6 +33,7 @@ public class FileLoader {
public static final int MEDIA_DIR_VIDEO = 2; public static final int MEDIA_DIR_VIDEO = 2;
public static final int MEDIA_DIR_DOCUMENT = 3; public static final int MEDIA_DIR_DOCUMENT = 3;
public static final int MEDIA_DIR_CACHE = 4; public static final int MEDIA_DIR_CACHE = 4;
public static final int MEDIA_DIR_THEME = 5;
private HashMap<Integer, File> mediaDirs = null; private HashMap<Integer, File> mediaDirs = null;
private volatile DispatchQueue fileLoaderQueue = new DispatchQueue("fileUploadQueue"); private volatile DispatchQueue fileLoaderQueue = new DispatchQueue("fileUploadQueue");

View File

@ -63,7 +63,7 @@ public class RPCRequest {
boolean initRequest = false; boolean initRequest = false;
ArrayList<Long> respondsToMessageIds = new ArrayList<Long>(); ArrayList<Long> respondsToMessageIds = new ArrayList<>();
public void addRespondMessageId(long messageId) { public void addRespondMessageId(long messageId) {
respondsToMessageIds.add(messageId); respondsToMessageIds.add(messageId);

View File

@ -124,8 +124,6 @@ public class TLClassStore {
classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class); classStore.put(TLRPC.TL_boolTrue.constructor, TLRPC.TL_boolTrue.class);
classStore.put(TLRPC.TL_boolFalse.constructor, TLRPC.TL_boolFalse.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_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_inputNotifyChats.constructor, TLRPC.TL_inputNotifyChats.class);
classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class); classStore.put(TLRPC.TL_inputNotifyPeer.constructor, TLRPC.TL_inputNotifyPeer.class);
classStore.put(TLRPC.TL_inputNotifyUsers.constructor, TLRPC.TL_inputNotifyUsers.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_contactFound.constructor, TLRPC.TL_contactFound.class);
classStore.put(TLRPC.TL_inputFileBig.constructor, TLRPC.TL_inputFileBig.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_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_userFull.constructor, TLRPC.TL_userFull.class);
classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class); classStore.put(TLRPC.TL_updates_state.constructor, TLRPC.TL_updates_state.class);
classStore.put(TLRPC.TL_resPQ.constructor, TLRPC.TL_resPQ.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_contactLinkHasPhone.constructor, TLRPC.TL_contactLinkHasPhone.class);
classStore.put(TLRPC.TL_contactLinkContact.constructor, TLRPC.TL_contactLinkContact.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_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_messageMediaUnsupported_old.constructor, TLRPC.TL_messageMediaUnsupported_old.class);
classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class); classStore.put(TLRPC.TL_userSelf_old2.constructor, TLRPC.TL_userSelf_old2.class);

File diff suppressed because it is too large Load Diff

View File

@ -30,7 +30,6 @@ public class UserConfig {
private final static Object sync = new Object(); private final static Object sync = new Object();
public static boolean saveIncomingPhotos = false; public static boolean saveIncomingPhotos = false;
public static int contactsVersion = 1; public static int contactsVersion = 1;
public static boolean waitingForPasswordEnter = false;
public static String passcodeHash = ""; public static String passcodeHash = "";
public static boolean appLocked = false; public static boolean appLocked = false;
public static int passcodeType = 0; public static int passcodeType = 0;
@ -67,7 +66,6 @@ public class UserConfig {
editor.putInt("lastBroadcastId", lastBroadcastId); editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush); editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded); editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
editor.putBoolean("waitingForPasswordEnter", waitingForPasswordEnter);
editor.putString("passcodeHash1", passcodeHash); editor.putString("passcodeHash1", passcodeHash);
editor.putBoolean("appLocked", appLocked); editor.putBoolean("appLocked", appLocked);
editor.putInt("passcodeType", passcodeType); 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() { public static int getClientUserId() {
synchronized (sync) { synchronized (sync) {
return currentUser != null ? currentUser.id : 0; return currentUser != null ? currentUser.id : 0;
@ -208,7 +194,6 @@ public class UserConfig {
lastBroadcastId = preferences.getInt("lastBroadcastId", -1); lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false); registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false); blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false);
waitingForPasswordEnter = preferences.getBoolean("waitingForPasswordEnter", false);
passcodeHash = preferences.getString("passcodeHash1", ""); passcodeHash = preferences.getString("passcodeHash1", "");
appLocked = preferences.getBoolean("appLocked", false); appLocked = preferences.getBoolean("appLocked", false);
passcodeType = preferences.getInt("passcodeType", 0); passcodeType = preferences.getInt("passcodeType", 0);
@ -231,7 +216,6 @@ public class UserConfig {
currentUser = null; currentUser = null;
registeredForInternalPush = false; registeredForInternalPush = false;
registeredForPush = false; registeredForPush = false;
waitingForPasswordEnter = false;
contactsHash = ""; contactsHash = "";
importHash = ""; importHash = "";
lastSendMessageId = -210000; lastSendMessageId = -210000;

View File

@ -9,6 +9,8 @@
package org.telegram.messenger; package org.telegram.messenger;
import android.app.Activity; import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.ContentUris; import android.content.ContentUris;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -24,12 +26,17 @@ import android.provider.MediaStore;
import android.text.Html; import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.util.Base64; 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.CrashManager;
import net.hockeyapp.android.CrashManagerListener; import net.hockeyapp.android.CrashManagerListener;
import net.hockeyapp.android.UpdateManager; import net.hockeyapp.android.UpdateManager;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.ui.LaunchActivity;
import org.xmlpull.v1.XmlPullParser;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -50,6 +57,7 @@ import java.security.spec.RSAPublicKeySpec;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
@ -111,6 +119,7 @@ public class Utilities {
public native static long doPQNative(long _what); 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 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 blurBitmap(Object bitmap, int radius);
public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer); public native static void calcCDT(ByteBuffer hsvBuffer, int width, int height, ByteBuffer buffer);
public native static Bitmap loadWebpImage(ByteBuffer buffer, int len, BitmapFactory.Options options); 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) { public static String bytesToHex(byte[] bytes) {
if (bytes == null) {
return "";
}
char[] hexChars = new char[bytes.length * 2]; char[] hexChars = new char[bytes.length * 2];
int v; int v;
for (int j = 0; j < bytes.length; j++) { for (int j = 0; j < bytes.length; j++) {
@ -159,6 +171,9 @@ public class Utilities {
} }
public static byte[] hexToBytes(String hex) { public static byte[] hexToBytes(String hex) {
if (hex == null) {
return null;
}
int len = hex.length(); int len = hex.length();
byte[] data = new byte[len / 2]; byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) { for (int i = 0; i < len; i += 2) {
@ -670,7 +685,7 @@ public class Utilities {
} }
wholeString = wholeString.trim(); wholeString = wholeString.trim();
String lower = " " + wholeString.toLowerCase(); 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 index = -1;
int lastIndex = 0; int lastIndex = 0;
while ((index = lower.indexOf(" " + q, lastIndex)) != -1) { while ((index = lower.indexOf(" " + q, lastIndex)) != -1) {
@ -768,4 +783,256 @@ public class Utilities {
UpdateManager.register(context, BuildVars.HOCKEY_APP_HASH); 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<String, String> 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<String, String> getXmlFileStrings(File file) {
FileInputStream stream = null;
try {
HashMap<String, String> 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;
}
//
} }

View File

@ -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<TLRPC.User> 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;
}
}
}

View File

@ -8,9 +8,7 @@
package org.telegram.ui.ActionBar; package org.telegram.ui.ActionBar;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -123,18 +121,10 @@ public class ActionBar extends FrameLayout {
} }
int x = 0; int x = 0;
if (backButtonImageView != null) { if (backButtonImageView != null && backButtonImageView.getVisibility() == VISIBLE) {
if (AndroidUtilities.isTablet()) { x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 80 : 72);
x = AndroidUtilities.dp(80);
} else { } else {
x = AndroidUtilities.dp(72); x = AndroidUtilities.dp(AndroidUtilities.isTablet() ? 26 : 18);
}
} else {
if (AndroidUtilities.isTablet()) {
x = AndroidUtilities.dp(26);
} else {
x = AndroidUtilities.dp(18);
}
} }
if (menu != null) { if (menu != null) {
@ -204,17 +194,31 @@ public class ActionBar extends FrameLayout {
} }
public void setBackButtonDrawable(Drawable drawable) { public void setBackButtonDrawable(Drawable drawable) {
boolean reposition = false;
if (backButtonImageView == null) { if (backButtonImageView == null) {
createBackButtonImage(); createBackButtonImage();
} else {
reposition = true;
} }
backButtonImageView.setVisibility(drawable == null ? GONE : VISIBLE);
backButtonImageView.setImageDrawable(drawable); backButtonImageView.setImageDrawable(drawable);
if (reposition) {
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
} }
public void setBackButtonImage(int resource) { public void setBackButtonImage(int resource) {
boolean reposition = false;
if (backButtonImageView == null) { if (backButtonImageView == null) {
createBackButtonImage(); createBackButtonImage();
} else {
reposition = true;
} }
backButtonImageView.setVisibility(resource == 0 ? GONE : VISIBLE);
backButtonImageView.setImageResource(resource); backButtonImageView.setImageResource(resource);
if (reposition) {
positionTitle(getMeasuredWidth(), getMeasuredHeight());
}
} }
private void createSubtitleTextView() { private void createSubtitleTextView() {
@ -236,7 +240,7 @@ public class ActionBar extends FrameLayout {
createSubtitleTextView(); createSubtitleTextView();
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE); subTitleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
subTitleTextView.setText(value); subTitleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
@ -278,7 +282,7 @@ public class ActionBar extends FrameLayout {
} }
if (titleTextView != null) { if (titleTextView != null) {
lastTitle = value; lastTitle = value;
titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : GONE); titleTextView.setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(value); titleTextView.setText(value);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }
@ -355,7 +359,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.RIGHT; layoutParams.gravity = Gravity.RIGHT;
actionMode.setLayoutParams(layoutParams); actionMode.setLayoutParams(layoutParams);
actionMode.setVisibility(GONE); actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar) { if (occupyStatusBar) {
actionModeTop = new View(getContext()); actionModeTop = new View(getContext());
@ -366,7 +370,7 @@ public class ActionBar extends FrameLayout {
layoutParams.width = LayoutParams.FILL_PARENT; layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
actionModeTop.setLayoutParams(layoutParams); actionModeTop.setLayoutParams(layoutParams);
actionModeTop.setVisibility(GONE); actionModeTop.setVisibility(INVISIBLE);
} }
return actionMode; return actionMode;
@ -392,9 +396,9 @@ public class ActionBar extends FrameLayout {
if (actionMode == null) { if (actionMode == null) {
return; return;
} }
actionMode.setVisibility(GONE); actionMode.setVisibility(INVISIBLE);
if (occupyStatusBar && actionModeTop != null) { if (occupyStatusBar && actionModeTop != null) {
actionModeTop.setVisibility(GONE); actionModeTop.setVisibility(INVISIBLE);
} }
if (titleFrameLayout != null) { if (titleFrameLayout != null) {
titleFrameLayout.setVisibility(VISIBLE); titleFrameLayout.setVisibility(VISIBLE);
@ -411,10 +415,10 @@ public class ActionBar extends FrameLayout {
protected void onSearchFieldVisibilityChanged(boolean visible) { protected void onSearchFieldVisibilityChanged(boolean visible) {
isSearchFieldVisible = visible; isSearchFieldVisible = visible;
if (titleTextView != null) { if (titleTextView != null) {
titleTextView.setVisibility(visible ? GONE : VISIBLE); titleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
} }
if (subTitleTextView != null) { if (subTitleTextView != null) {
subTitleTextView.setVisibility(visible ? GONE : VISIBLE); subTitleTextView.setVisibility(visible ? INVISIBLE : VISIBLE);
} }
Drawable drawable = backButtonImageView.getDrawable(); Drawable drawable = backButtonImageView.getDrawable();
if (drawable != null && drawable instanceof MenuDrawable) { if (drawable != null && drawable instanceof MenuDrawable) {
@ -471,7 +475,7 @@ public class ActionBar extends FrameLayout {
createTitleTextView(); createTitleTextView();
} }
if (titleTextView != null) { if (titleTextView != null) {
titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : GONE); titleTextView.setVisibility(textToSet != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE);
titleTextView.setText(textToSet); titleTextView.setText(textToSet);
positionTitle(getMeasuredWidth(), getMeasuredHeight()); positionTitle(getMeasuredWidth(), getMeasuredHeight());
} }

View File

@ -303,7 +303,7 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
} }
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
//AndroidUtilities.unlockOrientation(parentActivity); //AndroidUtilities.unlockOrientation(parentActivity);
startedTracking = false; startedTracking = false;
animationInProgress = false; animationInProgress = false;
@ -321,7 +321,15 @@ public class ActionBarLayout extends FrameLayout {
beginTrackingSent = false; beginTrackingSent = false;
BaseFragment lastFragment = fragmentsStack.get(fragmentsStack.size() - 2); 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(); ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) { if (parent != null) {
parent.removeView(fragmentView); parent.removeView(fragmentView);
@ -342,7 +350,7 @@ public class ActionBarLayout extends FrameLayout {
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
if (fragmentView.getBackground() == null) { if (!lastFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
lastFragment.onResume(); lastFragment.onResume();
@ -372,7 +380,7 @@ public class ActionBarLayout extends FrameLayout {
int dx = Math.max(0, (int) (ev.getX() - startedTrackingX)); int dx = Math.max(0, (int) (ev.getX() - startedTrackingX));
int dy = Math.abs((int) ev.getY() - startedTrackingY); int dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev); 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); prepareForMoving(ev);
} else if (startedTracking) { } else if (startedTracking) {
if (!beginTrackingSent) { if (!beginTrackingSent) {
@ -531,7 +539,7 @@ public class ActionBarLayout extends FrameLayout {
} }
} }
} }
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
} }
public boolean presentFragment(BaseFragment fragment) { 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; final BaseFragment currentFragment = !fragmentsStack.isEmpty() ? fragmentsStack.get(fragmentsStack.size() - 1) : null;
fragment.setParentLayout(this); 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 (fragment.needAddActionBar() && fragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
fragment.actionBar.setOccupyStatusBar(false); fragment.actionBar.setOccupyStatusBar(false);
@ -576,7 +592,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentsStack.add(fragment); fragmentsStack.add(fragment);
fragment.onResume(); fragment.onResume();
currentActionBar = fragment.actionBar; currentActionBar = fragment.actionBar;
if (fragmentView.getBackground() == null) { if (!fragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
@ -707,7 +723,7 @@ public class ActionBarLayout extends FrameLayout {
fragment.onFragmentDestroy(); fragment.onFragmentDestroy();
fragment.setParentLayout(null); fragment.setParentLayout(null);
fragmentsStack.remove(fragment); fragmentsStack.remove(fragment);
containerViewBack.setVisibility(View.GONE); containerViewBack.setVisibility(View.INVISIBLE);
bringChildToFront(containerView); bringChildToFront(containerView);
} }
@ -733,7 +749,15 @@ public class ActionBarLayout extends FrameLayout {
containerView.setVisibility(View.VISIBLE); containerView.setVisibility(View.VISIBLE);
previousFragment.setParentLayout(this); 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 (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
@ -752,7 +776,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume(); previousFragment.onResume();
currentActionBar = previousFragment.actionBar; currentActionBar = previousFragment.actionBar;
if (fragmentView.getBackground() == null) { if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
@ -804,9 +828,9 @@ public class ActionBarLayout extends FrameLayout {
@Override @Override
public void run() { public void run() {
removeFragmentFromStack(currentFragment); removeFragmentFromStack(currentFragment);
setVisibility(GONE); setVisibility(INVISIBLE);
if (backgroundView != null) { if (backgroundView != null) {
backgroundView.setVisibility(GONE); backgroundView.setVisibility(INVISIBLE);
} }
if (drawerLayoutContainer != null) { if (drawerLayoutContainer != null) {
drawerLayoutContainer.setAllowOpenDrawer(true, false); drawerLayoutContainer.setAllowOpenDrawer(true, false);
@ -843,9 +867,9 @@ public class ActionBarLayout extends FrameLayout {
currentAnimation.start(); currentAnimation.start();
} else { } else {
removeFragmentFromStack(currentFragment); removeFragmentFromStack(currentFragment);
setVisibility(GONE); setVisibility(INVISIBLE);
if (backgroundView != null) { 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); BaseFragment previousFragment = fragmentsStack.get(fragmentsStack.size() - 1);
previousFragment.setParentLayout(this); 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 (previousFragment.needAddActionBar() && previousFragment.actionBar != null) {
if (removeActionBarExtraHeight) { if (removeActionBarExtraHeight) {
previousFragment.actionBar.setOccupyStatusBar(false); previousFragment.actionBar.setOccupyStatusBar(false);
@ -876,7 +908,7 @@ public class ActionBarLayout extends FrameLayout {
fragmentView.setLayoutParams(layoutParams); fragmentView.setLayoutParams(layoutParams);
previousFragment.onResume(); previousFragment.onResume();
currentActionBar = previousFragment.actionBar; currentActionBar = previousFragment.actionBar;
if (fragmentView.getBackground() == null) { if (!previousFragment.hasOwnBackground && fragmentView.getBackground() == null) {
fragmentView.setBackgroundColor(0xffffffff); fragmentView.setBackgroundColor(0xffffffff);
} }
} }

View File

@ -10,6 +10,7 @@ package org.telegram.ui.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
@ -34,6 +35,7 @@ public class BaseFragment {
protected int classGuid = 0; protected int classGuid = 0;
protected Bundle arguments; protected Bundle arguments;
protected boolean swipeBackEnabled = true; protected boolean swipeBackEnabled = true;
protected boolean hasOwnBackground = false;
public BaseFragment() { public BaseFragment() {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
@ -44,7 +46,7 @@ public class BaseFragment {
classGuid = ConnectionsManager.getInstance().generateClassGuid(); classGuid = ConnectionsManager.getInstance().generateClassGuid();
} }
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
return null; return null;
} }
@ -205,9 +207,9 @@ public class BaseFragment {
return true; return true;
} }
public void showAlertDialog(AlertDialog.Builder builder) { public AlertDialog showAlertDialog(AlertDialog.Builder builder) {
if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) { if (parentLayout == null || parentLayout.checkTransitionAnimation() || parentLayout.animationInProgress || parentLayout.startedTracking) {
return; return null;
} }
try { try {
if (visibleDialog != null) { if (visibleDialog != null) {
@ -242,9 +244,11 @@ public class BaseFragment {
onDialogDismiss(); onDialogDismiss();
} }
}); });
return visibleDialog;
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
return null;
} }
protected void onDialogDismiss() { protected void onDialogDismiss() {

View File

@ -301,7 +301,7 @@ public class DrawerLayoutContainer extends FrameLayout {
float dx = (int) (ev.getX() - startedTrackingX); float dx = (int) (ev.getX() - startedTrackingX);
float dy = Math.abs((int) ev.getY() - startedTrackingY); float dy = Math.abs((int) ev.getY() - startedTrackingY);
velocityTracker.addMovement(ev); 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); prepareForDrawerOpen(ev);
startedTrackingX = (int) ev.getX(); startedTrackingX = (int) ev.getX();
requestDisallowInterceptTouchEvent(true); requestDisallowInterceptTouchEvent(true);

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Adapters; package org.telegram.ui.Adapters;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
@ -19,6 +20,7 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.AnimationCompat.ViewProxy;
@ -181,6 +183,9 @@ public class ContactsAdapter extends BaseSectionsAdapter {
@Override @Override
public View getItemView(int section, int position, View convertView, ViewGroup parent) { public View getItemView(int section, int position, View convertView, ViewGroup parent) {
int type = getItemViewType(section, position); 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 (type == 4) {
if (convertView == null) { if (convertView == null) {
convertView = new DividerCell(mContext); convertView = new DividerCell(mContext);
@ -192,43 +197,43 @@ public class ContactsAdapter extends BaseSectionsAdapter {
convertView = new GreySectionCell(mContext); convertView = new GreySectionCell(mContext);
((GreySectionCell) convertView).setText(LocaleController.getString("Contacts", R.string.Contacts).toUpperCase()); ((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).setText(String.format(Locale.US, " %d " + LocaleController.getString("Contacts", R.string.Contacts).toUpperCase(), arr0.size()));
((GreySectionCell) convertView).setBackgroundColor(AndroidUtilities.getIntDef("contactsRowColor", 0xffffffff)); ((GreySectionCell) convertView).setBackgroundColor(themePrefs.getInt("contactsRowColor", 0xffffffff));
((GreySectionCell) convertView).setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff737373)); ((GreySectionCell) convertView).setTextColor(cColorGrey);
} }
} else if (type == 2) { } else if (type == 2) {
if (convertView == null) { if (convertView == null) {
convertView = new TextCell(mContext); convertView = new TextCell(mContext);
} }
TextCell actionCell = (TextCell) convertView; TextCell actionCell = (TextCell) convertView;
actionCell.setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000)); actionCell.setTextColor(cColorBlack);
if (needPhonebook) { if (needPhonebook) {
//actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite); //actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), R.drawable.menu_invite);
Drawable invite = mContext.getResources().getDrawable(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); actionCell.setTextAndIcon(LocaleController.getString("InviteFriends", R.string.InviteFriends), invite);
} else { } else {
if (position == 0) { if (position == 0) {
//actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup); //actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), R.drawable.menu_newgroup);
Drawable newGroup = mContext.getResources().getDrawable(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); actionCell.setTextAndIcon(LocaleController.getString("NewGroup", R.string.NewGroup), newGroup);
} else if (position == 1) { } else if (position == 1) {
//actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret); //actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), R.drawable.menu_secret);
Drawable secret = mContext.getResources().getDrawable(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); actionCell.setTextAndIcon(LocaleController.getString("NewSecretChat", R.string.NewSecretChat), secret);
} else if (position == 2) { } else if (position == 2) {
//actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast); //actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), R.drawable.menu_broadcast);
Drawable broadcast = mContext.getResources().getDrawable(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); actionCell.setTextAndIcon(LocaleController.getString("NewBroadcastList", R.string.NewBroadcastList), broadcast);
} }
} }
} else if (type == 1) { } else if (type == 1) {
if (convertView == null) { if (convertView == null) {
convertView = new TextCell(mContext); convertView = new TextCell(mContext);
((TextCell) convertView).setTextColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000)); ((TextCell) convertView).setTextColor(cColorBlack);
((TextCell) convertView).setTextSize(AndroidUtilities.getIntDef("contactsNameSize", 16)); ((TextCell) convertView).setTextSize(themePrefs.getInt("contactsNameSize", 16));
} }
ContactsController.Contact contact = ContactsController.getInstance().phoneBookContacts.get(position); ContactsController.Contact contact = ContactsController.getInstance().phoneBookContacts.get(position);
if (contact.first_name != null && contact.last_name != null) { if (contact.first_name != null && contact.last_name != null) {
@ -242,9 +247,9 @@ public class ContactsAdapter extends BaseSectionsAdapter {
if (convertView == null) { if (convertView == null) {
convertView = new UserCell(mContext, 58); convertView = new UserCell(mContext, 58);
//((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0); //((UserCell) convertView).setStatusColors(0xffa8a8a8, 0xff3b84c0);
((UserCell) convertView).setStatusColors(AndroidUtilities.getIntDef("contactsStatusColor", 0xffa8a8a8), AndroidUtilities.getIntDef("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15))); ((UserCell) convertView).setStatusColors(themePrefs.getInt("contactsStatusColor", 0xffa8a8a8), themePrefs.getInt("contactsOnlineColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
((UserCell) convertView).setNameColor(AndroidUtilities.getIntDef("contactsNameColor", 0xff000000)); ((UserCell) convertView).setNameColor(cColorBlack);
((UserCell) convertView).setAvatarRadius(AndroidUtilities.getIntDef("contactsAvatarRadius", 32)); ((UserCell) convertView).setAvatarRadius(themePrefs.getInt("contactsAvatarRadius", 32));
} }
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section - (onlyUsers ? 0 : 1))); ArrayList<TLRPC.TL_contact> 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; return convertView;
} }

View File

@ -73,7 +73,7 @@ public class CountrySearchAdapter extends BaseFragmentAdapter {
return; return;
} }
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
ArrayList<Country> resultArray = new ArrayList<Country>(); ArrayList<Country> resultArray = new ArrayList<>();
String n = query.substring(0, 1); String n = query.substring(0, 1);
ArrayList<Country> arr = countries.get(n.toUpperCase()); ArrayList<Country> arr = countries.get(n.toUpperCase());

View File

@ -9,7 +9,6 @@
package org.telegram.ui.Adapters; package org.telegram.ui.Adapters;
import android.content.Context; import android.content.Context;
import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -348,7 +347,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
user.status.expires = cursor.intValue(7); user.status.expires = cursor.intValue(7);
} }
if (found == 1) { if (found == 1) {
dialogSearchResult.name = Html.fromHtml("<font color=\"#00a60e\">" + ContactsController.formatName(user.first_name, user.last_name) + "</font>"); dialogSearchResult.name = AndroidUtilities.replaceTags("<c#ff00a60e>" + ContactsController.formatName(user.first_name, user.last_name) + "</c>");
} else { } else {
dialogSearchResult.name = Utilities.generateSearchName("@" + user.username, null, "@" + q); dialogSearchResult.name = Utilities.generateSearchName("@" + user.username, null, "@" + q);
} }
@ -534,6 +533,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
notifyDataSetChanged(); notifyDataSetChanged();
return; return;
} }
searchResultMessages.clear();
searchResultHashtags.clear(); searchResultHashtags.clear();
for (HashtagObject hashtagObject : hashtags) { for (HashtagObject hashtagObject : hashtags) {
searchResultHashtags.add(hashtagObject.hashtag); searchResultHashtags.add(hashtagObject.hashtag);
@ -666,14 +666,15 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
int localCount = searchResult.size(); int localCount = searchResult.size();
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1; 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); ((ProfileSearchCell) view).useSeparator = (i != getCount() - 1 && i != localCount - 1 && i != localCount + globalCount - 1);
Object obj = getItem(i); Object obj = getItem(i);
if (obj instanceof TLRPC.User) { if (obj instanceof TLRPC.User) {
user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id); /*user = MessagesController.getInstance().getUser(((TLRPC.User) obj).id);
if (user == null) { if (user == null) {
user = (TLRPC.User) obj; user = (TLRPC.User) obj;
} }*/
user = (TLRPC.User) obj;
} else if (obj instanceof TLRPC.Chat) { } else if (obj instanceof TLRPC.Chat) {
chat = MessagesController.getInstance().getChat(((TLRPC.Chat) obj).id); chat = MessagesController.getInstance().getChat(((TLRPC.Chat) obj).id);
} else if (obj instanceof TLRPC.EncryptedChat) { } else if (obj instanceof TLRPC.EncryptedChat) {
@ -697,8 +698,8 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
foundUserName = foundUserName.substring(1); foundUserName = foundUserName.substring(1);
} }
try { try {
username = Html.fromHtml(String.format("<font color=" + hexDarkColor + ">@%s</font>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length()))); //username = AndroidUtilities.replaceTags(String.format("<c#ff4d83b3>@%s</c>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
//username = Html.fromHtml(String.format("<font color=\"#4d83b3\">@%s</font>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length()))); username = AndroidUtilities.replaceTags(String.format("<c" + hexDarkColor + ">@%s</c>%s", user.username.substring(0, foundUserName.length()), user.username.substring(foundUserName.length())));
} catch (Exception e) { } catch (Exception e) {
username = user.username; username = user.username;
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
@ -730,6 +731,9 @@ public class DialogsSearchAdapter extends BaseSearchAdapter {
@Override @Override
public int getItemViewType(int i) { public int getItemViewType(int i) {
if (!searchResultHashtags.isEmpty()) {
return i == 0 ? 1 : 4;
}
int localCount = searchResult.size(); int localCount = searchResult.size();
int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1; int globalCount = globalSearch.isEmpty() ? 0 : globalSearch.size() + 1;
int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1; int messagesCount = searchResultMessages.isEmpty() ? 0 : searchResultMessages.size() + 1;

View File

@ -26,16 +26,16 @@ import android.widget.TextView;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.messenger.TLRPC;
import org.telegram.ui.Cells.TextInfoCell;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; 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 { public class BlockedUsersActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
@ -64,8 +64,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers)); actionBar.setTitle(LocaleController.getString("BlockedUsers", R.string.BlockedUsers));
@ -89,10 +88,10 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItem(block_user, R.drawable.plus); menu.addItem(block_user, R.drawable.plus);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
emptyTextView = new TextView(getParentActivity()); emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080); emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -111,14 +110,14 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
} }
}); });
progressView = new FrameLayout(getParentActivity()); progressView = new FrameLayout(context);
frameLayout.addView(progressView); frameLayout.addView(progressView);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(getParentActivity()); ProgressBar progressBar = new ProgressBar(context);
progressView.addView(progressBar); progressView.addView(progressBar);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
@ -126,12 +125,12 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
layoutParams.gravity = Gravity.CENTER; layoutParams.gravity = Gravity.CENTER;
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listViewAdapter = new ListAdapter(context));
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT >= 11) {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT); listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
} }
@ -161,7 +160,7 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
selectedUserId = MessagesController.getInstance().blockedUsers.get(i); selectedUserId = MessagesController.getInstance().blockedUsers.get(i);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {LocaleController.getString("Unblock", R.string.Unblock)}; CharSequence[] items = new CharSequence[]{LocaleController.getString("Unblock", R.string.Unblock)};
builder.setItems(items, new DialogInterface.OnClickListener() { builder.setItems(items, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
@ -184,12 +183,6 @@ public class BlockedUsersActivity extends BaseFragment implements NotificationCe
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
} }
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -32,8 +33,8 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.PhotoViewer;
public class ChatActionCell extends BaseCell { public class ChatActionCell extends BaseCell {
@ -268,13 +269,14 @@ public class ChatActionCell extends BaseCell {
} }
private void updateTheme(){ 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); textPaint.setColor(color);
if(color != 0xffffffff){ if(color != 0xffffffff){
textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50); textPaint.linkColor = AndroidUtilities.getIntDarkerColor("chatDateColor", -0x50);
} }
textPaint.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatDateSize", 16)));//16 textPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatDateSize", 16)));//16
backgroundWhite.setColorFilter(AndroidUtilities.getIntDef("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY); backgroundWhite.setColorFilter(themePrefs.getInt("chatDateBubbleColor", 0x59000000), PorterDuff.Mode.MULTIPLY);
} }
@Override @Override

View File

@ -10,12 +10,12 @@ package org.telegram.ui.Cells;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.Layout; import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
@ -26,15 +26,15 @@ import android.view.SoundEffectConstants;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.Emoji; import org.telegram.android.Emoji;
import org.telegram.android.ImageReceiver;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.android.MessageObject; import org.telegram.messenger.TLRPC;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
public class ChatBaseCell extends BaseCell { public class ChatBaseCell extends BaseCell {
@ -84,18 +84,10 @@ public class ChatBaseCell extends BaseCell {
private static TextPaint timeMediaPaint; private static TextPaint timeMediaPaint;
private static TextPaint namePaint; private static TextPaint namePaint;
private static TextPaint forwardNamePaint; private static TextPaint forwardNamePaint;
private static TextPaint replyNamePaint; protected static TextPaint replyNamePaint;
private static TextPaint replyTextPaint; protected static TextPaint replyTextPaint;
private static Paint replyLinePaint; 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 backgroundWidth = 100;
protected int layoutWidth; protected int layoutWidth;
@ -176,16 +168,6 @@ public class ChatBaseCell extends BaseCell {
backgroundBlack = getResources().getDrawable(R.drawable.system_black); backgroundBlack = getResources().getDrawable(R.drawable.system_black);
backgroundBlue = getResources().getDrawable(R.drawable.system_blue); 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 = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
timePaintIn.setTextSize(AndroidUtilities.dp(12)); timePaintIn.setTextSize(AndroidUtilities.dp(12));
timePaintIn.setColor(0xffa1aab3); timePaintIn.setColor(0xffa1aab3);
@ -210,6 +192,8 @@ public class ChatBaseCell extends BaseCell {
replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); replyTextPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
replyTextPaint.setTextSize(AndroidUtilities.dp(14)); replyTextPaint.setTextSize(AndroidUtilities.dp(14));
replyTextPaint.linkColor = 0xff316f9f;
//replyTextPaint.linkColor = AndroidUtilities.getIntTColor("chatLLinkColor");
replyLinePaint = new Paint(); replyLinePaint = new Paint();
} }
@ -218,36 +202,49 @@ public class ChatBaseCell extends BaseCell {
avatarDrawable = new AvatarDrawable(); avatarDrawable = new AvatarDrawable();
replyImageReceiver = new ImageReceiver(this); replyImageReceiver = new ImageReceiver(this);
//Chat Photo //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); avatarImage.setRoundRadius(radius);
avatarDrawable.setRadius(radius); avatarDrawable.setRadius(radius);
} }
private void updateTheme(){ 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 lColor = AndroidUtilities.getDefBubbleColor();
int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15); int dColor = AndroidUtilities.getIntDarkerColor("themeColor", 0x15);
backgroundDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY); int rBubbleColor = themePrefs.getInt("chatRBubbleColor", lColor);
backgroundMediaDrawableOutWhite.setColorFilter(AndroidUtilities.getIntDef("chatRBubbleColor", lColor), PorterDuff.Mode.MULTIPLY); int rBubbleSColor = AndroidUtilities.getIntDarkerColor("chatRBubbleColor", 0x15);
backgroundDrawableIn.setColorFilter(AndroidUtilities.getIntDef("chatLBubbleColor",0xffffffff), PorterDuff.Mode.MULTIPLY); int lBubbleColor = themePrefs.getInt("chatLBubbleColor", 0xffffffff);
backgroundMediaDrawableIn.setColorFilter(AndroidUtilities.getIntDef("chatLBubbleColor",0xffffffff), PorterDuff.Mode.MULTIPLY);
int checksColor = AndroidUtilities.getIntDef("chatChecksColor", tColor); backgroundDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN);
checkDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); backgroundMediaDrawableOut.setColorFilter(rBubbleColor, PorterDuff.Mode.SRC_IN);
halfCheckDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); backgroundDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN);
clockDrawableWhite.setColorFilter(checksColor, PorterDuff.Mode.MULTIPLY); backgroundMediaDrawableOutSelected.setColorFilter(rBubbleSColor, PorterDuff.Mode.SRC_IN);
timePaintOut.setColor(AndroidUtilities.getIntDef("chatRTimeColor",dColor)); backgroundDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY);
timePaintOut.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12))); backgroundMediaDrawableIn.setColorFilter(lBubbleColor, PorterDuff.Mode.MULTIPLY);
timePaintIn.setColor(AndroidUtilities.getIntDef("chatLTimeColor", 0xffa1aab3));
timePaintIn.setTextSize(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatTimeSize", 12))); 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); int bColor = AndroidUtilities.getIntAlphaColor("chatLBubbleColor", 0xffffffff, 0.9f);
if(currentMessageObject.isOut()){ if(currentMessageObject.isOut()){
bColor = AndroidUtilities.getIntAlphaColor("chatRBubbleColor", lColor, 0.9f); bColor = AndroidUtilities.getIntAlphaColor("chatRBubbleColor", lColor, 0.9f);
linkColor = themePrefs.getInt("chatRLinkColor", tColor);
} }
mediaBackgroundWhiteDrawable.setColorFilter(bColor, PorterDuff.Mode.MULTIPLY); mediaBackgroundDrawable.setColorFilter(bColor, PorterDuff.Mode.SRC_IN);
mediaBackgroundDrawable = mediaBackgroundWhiteDrawable;
replyTextPaint.linkColor = linkColor;
} }
@Override @Override
@ -417,7 +414,7 @@ public class ChatBaseCell extends BaseCell {
forwardedNameWidth = getMaxNameWidth(); forwardedNameWidth = getMaxNameWidth();
CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END); CharSequence str = TextUtils.ellipsize(currentForwardNameString.replace("\n", " "), forwardNamePaint, forwardedNameWidth - AndroidUtilities.dp(40), TextUtils.TruncateAt.END);
str = Html.fromHtml(String.format("%s<br>%s <b>%s</b>", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str)); str = AndroidUtilities.replaceTags(String.format("%s\n%s <b>%s</b>", LocaleController.getString("ForwardedMessage", R.string.ForwardedMessage), LocaleController.getString("From", R.string.From), str));
forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); forwardedNameLayout = new StaticLayout(str, forwardNamePaint, forwardedNameWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
if (forwardedNameLayout.getLineCount() > 1) { if (forwardedNameLayout.getLineCount() > 1) {
forwardedNameWidth = Math.max((int) Math.ceil(forwardedNameLayout.getLineWidth(0)), (int) Math.ceil(forwardedNameLayout.getLineWidth(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 (currentMessageObject.isOut()) {
if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) { if (isPressed() && isCheckPressed || !isCheckPressed && isPressed || isHighlighted) {
if (!media) { if (!media) {
currentBackgroundDrawable = backgroundDrawableOutWhiteSelected;//backgroundDrawableOutSelected; currentBackgroundDrawable = backgroundDrawableOutSelected;
} else { } else {
currentBackgroundDrawable = backgroundMediaDrawableOutWhiteSelected;//backgroundMediaDrawableOutSelected; currentBackgroundDrawable = backgroundMediaDrawableOutSelected;
} }
} else { } else {
if (!media) { if (!media) {
currentBackgroundDrawable = backgroundDrawableOutWhite;//backgroundDrawableOut; currentBackgroundDrawable = backgroundDrawableOut;
} else { } else {
currentBackgroundDrawable = backgroundMediaDrawableOutWhite;//backgroundMediaDrawableOut; currentBackgroundDrawable = backgroundMediaDrawableOut;
} }
} }
setDrawableBounds(currentBackgroundDrawable, layoutWidth - backgroundWidth - (!media ? 0 : AndroidUtilities.dp(9)), AndroidUtilities.dp(1), backgroundWidth, layoutHeight - AndroidUtilities.dp(2)); 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); onAfterBackgroundDraw(canvas);
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
if (drawName && nameLayout != null) { if (drawName && nameLayout != null) {
canvas.save(); canvas.save();
canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10)); canvas.translate(currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19) - nameOffsetX, AndroidUtilities.dp(10));
if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){ if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){
namePaint.setColor(AndroidUtilities.getIntDef("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); namePaint.setColor(themePrefs.getInt("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
}else{ }else{
namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id)); namePaint.setColor(AvatarDrawable.getNameColorForId(currentUser.id));
} }
@ -737,11 +734,11 @@ public class ChatBaseCell extends BaseCell {
forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0)); forwardNameY = AndroidUtilities.dp(10 + (drawName ? 19 : 0));
if (currentMessageObject.isOut()) { if (currentMessageObject.isOut()) {
//forwardNamePaint.setColor(0xff4a923c); //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); forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(10);
} else { } else {
//forwardNamePaint.setColor(0xff006fc8); //forwardNamePaint.setColor(0xff006fc8);
forwardNamePaint.setColor(AndroidUtilities.getIntDef("chatForwardColor", 0xff006fc8)); forwardNamePaint.setColor(themePrefs.getInt("chatForwardColor", 0xff006fc8));
forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19); forwardNameX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(19);
} }
canvas.save(); canvas.save();
@ -774,13 +771,13 @@ public class ChatBaseCell extends BaseCell {
back.draw(canvas); back.draw(canvas);
} else { } else {
if (currentMessageObject.isOut()) { 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); replyLinePaint.setColor(color);//0xff8dc97a);
replyNamePaint.setColor(color);//0xff61a349); replyNamePaint.setColor(color);//0xff61a349);
replyTextPaint.setColor(color);//0xff70b15c); replyTextPaint.setColor(color);//0xff70b15c);
replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); replyStartX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11);
} else { } else {
int color = AndroidUtilities.getIntDef("chatForwardColor", 0xff999999); int color = themePrefs.getInt("chatForwardColor", 0xff999999);
replyLinePaint.setColor(color);//0xff6c9fd2); replyLinePaint.setColor(color);//0xff6c9fd2);
replyNamePaint.setColor(color);//0xff377aae); replyNamePaint.setColor(color);//0xff377aae);
replyTextPaint.setColor(color);//0xff999999); replyTextPaint.setColor(color);//0xff999999);
@ -857,7 +854,7 @@ public class ChatBaseCell extends BaseCell {
} }
if (drawClock) { if (drawClock) {
clockDrawable = clockMediaDrawable = clockDrawableWhite; clockDrawable = clockMediaDrawable;
if (!media) { if (!media) {
setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight()); setDrawableBounds(clockDrawable, layoutWidth - AndroidUtilities.dp(18.5f) - clockDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - clockDrawable.getIntrinsicHeight());
clockDrawable.draw(canvas); clockDrawable.draw(canvas);
@ -878,7 +875,7 @@ public class ChatBaseCell extends BaseCell {
} }
} else { } else {
if (drawCheck2) { if (drawCheck2) {
checkDrawable = checkMediaDrawable = checkDrawableWhite; checkDrawable = checkMediaDrawable;
if (!media) { if (!media) {
if (drawCheck1) { if (drawCheck1) {
setDrawableBounds(checkDrawable, layoutWidth - AndroidUtilities.dp(22.5f) - checkDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - checkDrawable.getIntrinsicHeight()); 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) { if (drawCheck1) {
halfCheckDrawable = halfCheckMediaDrawable = halfCheckDrawableWhite; halfCheckDrawable = halfCheckMediaDrawable;
if (!media) { if (!media) {
setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight()); setDrawableBounds(halfCheckDrawable, layoutWidth - AndroidUtilities.dp(18) - halfCheckDrawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(8.5f) - halfCheckDrawable.getIntrinsicHeight());
halfCheckDrawable.draw(canvas); halfCheckDrawable.draw(canvas);

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -25,21 +26,22 @@ import android.view.SoundEffectConstants;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader; import org.telegram.android.ImageLoader;
import org.telegram.android.ImageReceiver;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.SendMessagesHelper; import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.android.MediaController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.android.MessageObject;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.GifDrawable;
import org.telegram.ui.Components.RadialProgress; import org.telegram.ui.Components.RadialProgress;
import org.telegram.ui.PhotoViewer; import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Components.GifDrawable;
import org.telegram.android.ImageReceiver;
import java.io.File; import java.io.File;
import java.util.Locale; 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); 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); 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); 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)); infoWidth = (int) Math.ceil(senderPaint.measureText(currentInfoString));
infoLayout = new StaticLayout(currentInfoString, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); infoLayout = new StaticLayout(currentInfoString, senderPaint, infoWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
} }
if(!isChat)infoLayout = null;
infoLayout2 = null; infoLayout2 = null;
} }
nameLayout = null; nameLayout = null;
@ -941,23 +944,24 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
radialProgress.setHideCurrentDrawable(false); 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) { if (currentMessageObject.type == 9) {
Drawable menuDrawable = null; Drawable menuDrawable = null;
int color = AndroidUtilities.getIntDef("chatRTextColor", 0xff000000); int color = themePrefs.getInt("chatRTextColor", 0xff000000);
if (currentMessageObject.isOut()) { if (currentMessageObject.isOut()) {
//infoPaint.setColor(0xff70b15c); //infoPaint.setColor(0xff70b15c);
infoPaint.setColor(color); infoPaint.setColor(color);
docBackPaint.setColor(0xffdaf5c3); 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; menuDrawable = docMenuOutDrawable = docMenuWhiteDrawable;
namePaint.setColor(color); namePaint.setColor(color);
} else { } else {
color = AndroidUtilities.getIntDef("chatLTextColor", 0xff000000); color = themePrefs.getInt("chatLTextColor", 0xff000000);
//infoPaint.setColor(0xffa1adbb); //infoPaint.setColor(0xffa1adbb);
infoPaint.setColor(color); infoPaint.setColor(color);
docBackPaint.setColor(0xffebf0f5); docBackPaint.setColor(0xffebf0f5);
docMenuWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.MULTIPLY); docMenuWhiteDrawable.setColorFilter(themePrefs.getInt("chatLTimeColor", 0xffa1adbb), PorterDuff.Mode.MULTIPLY);
menuDrawable = docMenuInDrawable = docMenuWhiteDrawable; menuDrawable = docMenuInDrawable = docMenuWhiteDrawable;
namePaint.setColor(color); namePaint.setColor(color);
} }
@ -1023,8 +1027,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
} }
radialProgress.onDraw(canvas); radialProgress.onDraw(canvas);
if(AndroidUtilities.getBoolPref("chatMemberColorCheck")){ if(themePrefs.getBoolean("chatMemberColorCheck", false)){
senderPaint.setColor(AndroidUtilities.getIntDef("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); senderPaint.setColor(themePrefs.getInt("chatMemberColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
}else{ }else{
//if(currentMessageObject.type == 9){ //if(currentMessageObject.type == 9){
senderPaint.setColor(AvatarDrawable.getNameColorForId(MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id).id)); 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) )) { } else if (infoLayout != null && (buttonState == 1 || buttonState == 0 || buttonState == 3 || currentMessageObject.isSecretPhoto() || currentMessageObject.type == 1 || (buttonState == 2 && currentMessageObject.type == 8) )) {
//infoPaint.setColor(0xffffffff); //infoPaint.setColor(0xffffffff);
if(currentMessageObject.isOut()){ if(currentMessageObject.isOut()){
infoPaint.setColor(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000)); int color = themePrefs.getInt("chatRTextColor", 0xff000000);
videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatRTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY); infoPaint.setColor(color);
videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
}else{ }else{
infoPaint.setColor(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000)); int color = themePrefs.getInt("chatLTextColor", 0xff000000);
videoIconDrawable.setColorFilter(AndroidUtilities.getIntDef("chatLTextColor", 0xff000000), PorterDuff.Mode.MULTIPLY); infoPaint.setColor(color);
videoIconDrawable.setColorFilter(color, PorterDuff.Mode.MULTIPLY);
} }
if (currentMessageObject.type == 1){ if (currentMessageObject.type == 1){
setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20)); setDrawableBounds(mediaBackgroundDrawable, photoImage.getImageX() + AndroidUtilities.dp(4), photoImage.getImageY() + AndroidUtilities.dp(4), infoWidth + AndroidUtilities.dp(8) + infoOffset, AndroidUtilities.dp(20));

View File

@ -9,35 +9,130 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Canvas; 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.Spannable;
import android.text.SpannableStringBuilder;
import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.style.ClickableSpan; import android.text.style.ClickableSpan;
import android.view.MotionEvent; import android.view.MotionEvent;
import org.telegram.android.AndroidUtilities; 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.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 org.telegram.ui.Components.URLSpanNoUnderline;
import java.util.Locale;
public class ChatMessageCell extends ChatBaseCell { public class ChatMessageCell extends ChatBaseCell {
private int textX, textY; private int textX, textY;
private int totalHeight = 0; private int totalHeight = 0;
private ClickableSpan pressedLink; private ClickableSpan pressedLink;
private int linkBlockNum;
private MyPath urlPath = new MyPath();
private boolean linkPreviewPressed;
private static Paint urlPaint;
private int lastVisibleBlockNum = 0; private int lastVisibleBlockNum = 0;
private int firstVisibleBlockNum = 0; private int firstVisibleBlockNum = 0;
private int totalVisibleBlocksCount = 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) { public ChatMessageCell(Context context) {
super(context); super(context);
drawForwardedName = true; 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 @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
boolean result = false;
if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !isPressed) { if (currentMessageObject != null && currentMessageObject.textLayoutBlocks != null && !currentMessageObject.textLayoutBlocks.isEmpty() && currentMessageObject.messageText instanceof Spannable && !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 x = (int)event.getX();
int y = (int)event.getY(); int y = (int)event.getY();
if (x >= textX && y >= textY && x <= textX + currentMessageObject.textWidth && y <= textY + currentMessageObject.textHeight) { 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) { if (left <= x && left + block.textLayout.getLineWidth(line) >= x) {
Spannable buffer = (Spannable)currentMessageObject.messageText; Spannable buffer = (Spannable)currentMessageObject.messageText;
ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
if (link.length != 0) { if (link.length != 0) {
if (event.getAction() == MotionEvent.ACTION_DOWN) { if (event.getAction() == MotionEvent.ACTION_DOWN) {
resetPressedLink();
pressedLink = link[0]; 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 { } else {
if (link[0] == pressedLink) { if (link[0] == pressedLink) {
try { try {
@ -76,30 +179,98 @@ public class ChatMessageCell extends ChatBaseCell {
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
return true; resetPressedLink();
result = true;
} }
} }
} else { } else {
pressedLink = null; resetPressedLink();
} }
} else { } else {
pressedLink = null; resetPressedLink();
} }
} catch (Exception e) { } catch (Exception e) {
pressedLink = null; resetPressedLink();
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else { } 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 { } else {
pressedLink = null; resetPressedLink();
}
} }
} else { } else {
pressedLink = null; resetPressedLink();
} }
return super.onTouchEvent(event); } 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 {
resetPressedLink();
}
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
resetPressedLink();
}
} else {
resetPressedLink();
}
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) { public void setVisiblePart(int position, int height) {
@ -137,6 +308,51 @@ public class ChatMessageCell extends ChatBaseCell {
return left1 <= right2; 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 @Override
public void setMessageObject(MessageObject messageObject) { public void setMessageObject(MessageObject messageObject) {
if (currentMessageObject != messageObject || isUserDataChanged()) { if (currentMessageObject != messageObject || isUserDataChanged()) {
@ -144,7 +360,21 @@ public class ChatMessageCell extends ChatBaseCell {
firstVisibleBlockNum = 0; firstVisibleBlockNum = 0;
lastVisibleBlockNum = 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; int maxWidth;
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
@ -182,7 +412,215 @@ public class ChatMessageCell extends ChatBaseCell {
timeMore += AndroidUtilities.dp(20.5f); 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); totalHeight += AndroidUtilities.dp(14);
backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth) + AndroidUtilities.dp(29); backgroundWidth = Math.max(maxChildWidth, messageObject.lastLineWidth) + AndroidUtilities.dp(29);
} else { } else {
@ -217,7 +655,7 @@ public class ChatMessageCell extends ChatBaseCell {
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {
super.onDraw(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; return;
} }
@ -229,13 +667,17 @@ public class ChatMessageCell extends ChatBaseCell {
textY = AndroidUtilities.dp(10) + namesOffset; textY = AndroidUtilities.dp(10) + namesOffset;
} }
if (firstVisibleBlockNum >= 0) {
for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) { for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
if (a >= currentMessageObject.textLayoutBlocks.size()) { if (a >= currentMessageObject.textLayoutBlocks.size()) {
break; break;
} }
MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(a); MessageObject.TextLayoutBlock block = currentMessageObject.textLayoutBlocks.get(a);
canvas.save(); canvas.save();
canvas.translate(textX - (int)Math.ceil(block.textXOffset), textY + block.textYOffset); canvas.translate(textX - (int) Math.ceil(block.textXOffset), textY + block.textYOffset);
if (pressedLink != null && a == linkBlockNum) {
canvas.drawPath(urlPath, urlPaint);
}
try { try {
block.textLayout.draw(canvas); block.textLayout.draw(canvas);
} catch (Exception e) { } catch (Exception e) {
@ -244,4 +686,112 @@ public class ChatMessageCell extends ChatBaseCell {
canvas.restore(); canvas.restore();
} }
} }
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();
}
}
}
}
} }

View File

@ -8,32 +8,30 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.Layout; import android.text.Layout;
import android.text.StaticLayout; import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.TextUtils; import android.text.TextUtils;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController; import org.telegram.android.AndroidUtilities;
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.ContactsController;
import org.telegram.android.Emoji; 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.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; import org.telegram.ui.Components.AvatarDrawable;
public class DialogCell extends BaseCell { public class DialogCell extends BaseCell {
@ -145,6 +143,7 @@ public class DialogCell extends BaseCell {
messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); messagePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
messagePaint.setTextSize(AndroidUtilities.dp(16)); messagePaint.setTextSize(AndroidUtilities.dp(16));
messagePaint.setColor(0xff8f8f8f); messagePaint.setColor(0xff8f8f8f);
messagePaint.linkColor = 0xff8f8f8f;
linePaint = new Paint(); linePaint = new Paint();
linePaint.setColor(0xffdcdcdc); linePaint.setColor(0xffdcdcdc);
@ -376,13 +375,15 @@ public class DialogCell extends BaseCell {
} }
} }
checkMessage = false; checkMessage = false;
String hexColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntColor("themeColor"))); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
String hexMsgColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDef("chatsMessageColor",0xff8f8f8f))); int defColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
String hexDarkColor = String.format("#%06X", (0xFFFFFF & AndroidUtilities.getIntDef("chatsMemberColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15)))); String hexColor = String.format("#%08X", (0xFFFFFFFF & defColor));
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { 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; currentMessagePaint = messagePrintingPaint;
//messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#4d83b3>%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("<c#ff4d83b3>%s:</c> <c#ff4d83b3>%s</c>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=" + hexColor + ">%s:</font> <font color=" + hexColor + ">%s</font>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("<c" + hexColor + ">%s:</c> <c" + hexColor + ">%s</c>", name, message.messageText)), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} else { } else {
if (message.messageOwner.message != null) { if (message.messageOwner.message != null) {
String mess = message.messageOwner.message; String mess = message.messageOwner.message;
@ -390,13 +391,13 @@ public class DialogCell extends BaseCell {
mess = mess.substring(0, 150); mess = mess.substring(0, 150);
} }
mess = mess.replace("\n", " "); mess = mess.replace("\n", " ");
//messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=#4d83b3>%s:</font> <font color=#808080>%s</font>", name, mess.replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); //messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("<c#ff4d83b3>%s:</c> <c#ff808080>%s</c>", name, mess.replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
messageString = Emoji.replaceEmoji(Html.fromHtml(String.format("<font color=" + hexDarkColor + ">%s:</font> <font color=" + hexMsgColor + ">%s</font>", name, mess.replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20)); messageString = Emoji.replaceEmoji(AndroidUtilities.replaceTags(String.format("<c" + hexDarkColor + ">%s:</c> <c" + hexMsgColor + ">%s</c>", name, mess.replace("<", "&lt;").replace(">", "&gt;"))), messagePaint.getFontMetricsInt(), AndroidUtilities.dp(20));
} }
} }
} else { } else {
messageString = message.messageText; messageString = message.messageText;
if (message.messageOwner.media != null && !(message.messageOwner.media instanceof TLRPC.TL_messageMediaEmpty)) { if (message.messageOwner.media != null && !message.isMediaEmpty()) {
currentMessagePaint = messagePrintingPaint; currentMessagePaint = messagePrintingPaint;
} }
} }
@ -775,7 +776,7 @@ public class DialogCell extends BaseCell {
private void updateTheme(){ private void updateTheme(){
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int tColor = AndroidUtilities.getIntColor("themeColor"); int tColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15); int dColor = AndroidUtilities.getIntDarkerColor("themeColor",0x15);
namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17))); namePaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsNameSize", 17)));
@ -791,10 +792,10 @@ public class DialogCell extends BaseCell {
messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f)); messagePaint.setColor(themePrefs.getInt("chatsMessageColor", 0xff8f8f8f));
messagePrintingPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsMessageSize", 16))); 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.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.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsTimeSize", 13)));
timePaint.setColor(themePrefs.getInt("chatsTimeColor", 0xff999999)); timePaint.setColor(themePrefs.getInt("chatsTimeColor", 0xff999999));
@ -802,9 +803,9 @@ public class DialogCell extends BaseCell {
countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13))); countPaint.setTextSize(AndroidUtilities.dp(themePrefs.getInt("chatsCountSize", 13)));
countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff)); countPaint.setColor(themePrefs.getInt("chatsCountColor", 0xffffffff));
checkWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY); checkWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY);
halfCheckWhiteDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY); halfCheckWhiteDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.MULTIPLY);
clockDrawable.setColorFilter(AndroidUtilities.getIntDef("chatsChecksColor",AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.SRC_IN); clockDrawable.setColorFilter(themePrefs.getInt("chatsChecksColor", tColor), PorterDuff.Mode.SRC_IN);
countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY); countWhiteDrawable.setColorFilter(themePrefs.getInt("chatsCountBGColor", tColor), PorterDuff.Mode.MULTIPLY);
lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY); lockWhiteDrawable.setColorFilter(dColor, PorterDuff.Mode.MULTIPLY);
@ -819,7 +820,7 @@ public class DialogCell extends BaseCell {
linePaint.setColor(themePrefs.getInt("chatsDividerColor", 0xffdcdcdc)); 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(avatarImage != null)avatarImage.setRoundRadius(radius);
if(avatarDrawable != null)avatarDrawable.setRadius(radius); if(avatarDrawable != null)avatarDrawable.setRadius(radius);

View File

@ -17,7 +17,6 @@ import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.R;
public class DrawerActionCell extends FrameLayout { public class DrawerActionCell extends FrameLayout {

View File

@ -10,6 +10,7 @@ package org.telegram.ui.Cells;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -64,7 +65,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
shadowView.setLayoutParams(layoutParams); shadowView.setLayoutParams(layoutParams);
avatarImageView = new BackupImageView(context); avatarImageView = new BackupImageView(context);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
addView(avatarImageView); addView(avatarImageView);
layoutParams = (LayoutParams) avatarImageView.getLayoutParams(); layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(64); layoutParams.width = AndroidUtilities.dp(64);
@ -197,11 +198,11 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
object.viewX = coords[0]; object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = avatarImageView; object.parentView = avatarImageView;
object.imageReceiver = avatarImageView.imageReceiver; object.imageReceiver = avatarImageView.getImageReceiver();
object.user_id = UserConfig.getClientUserId(); object.user_id = UserConfig.getClientUserId();
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
object.size = -1; object.size = -1;
object.radius = avatarImageView.imageReceiver.getRoundRadius(); object.radius = avatarImageView.getImageReceiver().getRoundRadius();
return object; return object;
} }
} }
@ -218,7 +219,7 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
@Override @Override
public void willHidePhotoViewer() { public void willHidePhotoViewer() {
avatarImageView.imageReceiver.setVisible(true, true); avatarImageView.getImageReceiver().setVisible(true, true);
} }
@Override @Override
@ -237,23 +238,24 @@ public class DrawerProfileCell extends FrameLayout implements PhotoViewer.PhotoV
public int getSelectedCount() { return 0; } public int getSelectedCount() { return 0; }
private void updateTheme(){ 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); int dColor = AndroidUtilities.getIntDarkerColor("themeColor",-0x40);
setBackgroundColor(AndroidUtilities.getIntDef("drawerHeaderColor", tColor)); setBackgroundColor(themePrefs.getInt("drawerHeaderColor", tColor));
nameTextView.setTextColor(AndroidUtilities.getIntDef("drawerNameColor", 0xffffffff)); nameTextView.setTextColor(themePrefs.getInt("drawerNameColor", 0xffffffff));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("drawerNameSize", 15)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("drawerNameSize", 15));
phoneTextView.setTextColor(AndroidUtilities.getIntDef("drawerPhoneColor", dColor)); phoneTextView.setTextColor(themePrefs.getInt("drawerPhoneColor", dColor));
phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("drawerPhoneSize", 13)); phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("drawerPhoneSize", 13));
TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId()); TLRPC.User user = MessagesController.getInstance().getUser(UserConfig.getClientUserId());
TLRPC.FileLocation photo = null; TLRPC.FileLocation photo = null;
if (user != null && user.photo != null && user.photo.photo_small != null ) { if (user != null && user.photo != null && user.photo.photo_small != null ) {
photo = user.photo.photo_small; photo = user.photo.photo_small;
} }
AvatarDrawable avatarDrawable = new AvatarDrawable(user); AvatarDrawable avatarDrawable = new AvatarDrawable(user);
avatarDrawable.setColor(AndroidUtilities.getIntDef("drawerAvatarColor",AndroidUtilities.getIntDarkerColor("themeColor", 0x15))); avatarDrawable.setColor(themePrefs.getInt("drawerAvatarColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("drawerAvatarRadius", 32)); int radius = AndroidUtilities.dp(themePrefs.getInt("drawerAvatarRadius", 32));
avatarDrawable.setRadius(radius); avatarDrawable.setRadius(radius);
avatarImageView.imageReceiver.setRoundRadius(radius); avatarImageView.getImageReceiver().setRoundRadius(radius);
avatarImageView.setImage(photo, "50_50", avatarDrawable); avatarImageView.setImage(photo, "50_50", avatarDrawable);
if(AndroidUtilities.getBoolMain("hideMobile")){ if(AndroidUtilities.getBoolMain("hideMobile")){
phoneTextView.setVisibility(GONE); phoneTextView.setVisibility(GONE);

View File

@ -117,7 +117,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
for (int a = 0; a < 4; a++) { for (int a = 0; a < 4; a++) {
albumViews[a] = new AlbumView(context); albumViews[a] = new AlbumView(context);
addView(albumViews[a]); addView(albumViews[a]);
albumViews[a].setVisibility(GONE); albumViews[a].setVisibility(INVISIBLE);
albumViews[a].setTag(a); albumViews[a].setTag(a);
albumViews[a].setOnClickListener(new OnClickListener() { albumViews[a].setOnClickListener(new OnClickListener() {
@Override @Override
@ -132,7 +132,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
public void setAlbumsCount(int count) { public void setAlbumsCount(int count) {
for (int a = 0; a < albumViews.length; a++) { for (int a = 0; a < albumViews.length; a++) {
albumViews[a].setVisibility(a < count ? VISIBLE : GONE); albumViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE);
} }
albumsCount = count; albumsCount = count;
} }
@ -156,7 +156,7 @@ public class PhotoPickerAlbumsCell extends FrameLayoutFixed {
albumView.nameTextView.setText(albumEntry.bucketName); albumView.nameTextView.setText(albumEntry.bucketName);
albumView.countTextView.setText(String.format("%d", albumEntry.photos.size())); albumView.countTextView.setText(String.format("%d", albumEntry.photos.size()));
} else { } else {
albumViews[a].setVisibility(GONE); albumViews[a].setVisibility(INVISIBLE);
} }
} }

View File

@ -30,6 +30,7 @@ import org.telegram.messenger.UserConfig;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
public class ProfileSearchCell extends BaseCell { public class ProfileSearchCell extends BaseCell {
private static TextPaint namePaint; private static TextPaint namePaint;
private static TextPaint nameEncryptedPaint; private static TextPaint nameEncryptedPaint;
private static TextPaint onlinePaint; private static TextPaint onlinePaint;
@ -79,7 +80,8 @@ public class ProfileSearchCell extends BaseCell {
if (namePaint == null) { if (namePaint == null) {
namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); namePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
namePaint.setTextSize(AndroidUtilities.dp(17)); namePaint.setTextSize(AndroidUtilities.dp(17));
namePaint.setColor(0xff212121); //namePaint.setColor(0xff212121);
namePaint.setColor(AndroidUtilities.getIntDef("chatsNameColor", 0xff212121));
namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); namePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG); nameEncryptedPaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);

View File

@ -106,11 +106,11 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
extTextView.setLayoutParams(layoutParams); extTextView.setLayoutParams(layoutParams);
thumbImageView = new BackupImageView(context); thumbImageView = new BackupImageView(context);
thumbImageView.imageReceiver.setDelegate(new ImageReceiver.ImageReceiverDelegate() { thumbImageView.getImageReceiver().setDelegate(new ImageReceiver.ImageReceiverDelegate() {
@Override @Override
public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) { public void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb) {
extTextView.setVisibility(set ? GONE : VISIBLE); extTextView.setVisibility(set ? INVISIBLE : VISIBLE);
placeholderImabeView.setVisibility(set ? GONE : VISIBLE); placeholderImabeView.setVisibility(set ? INVISIBLE : VISIBLE);
} }
}); });
addView(thumbImageView); addView(thumbImageView);
@ -143,7 +143,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
nameTextView.setLayoutParams(layoutParams); nameTextView.setLayoutParams(layoutParams);
statusImageView = new ImageView(context); statusImageView = new ImageView(context);
statusImageView.setVisibility(GONE); statusImageView.setVisibility(INVISIBLE);
addView(statusImageView); addView(statusImageView);
layoutParams = (LayoutParams) statusImageView.getLayoutParams(); layoutParams = (LayoutParams) statusImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.width = LayoutParams.WRAP_CONTENT;
@ -184,7 +184,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2); checkBox = new CheckBox(context, R.drawable.round_check2);
checkBox.setVisibility(GONE); checkBox.setVisibility(INVISIBLE);
addView(checkBox); addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams(); layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22); layoutParams.width = AndroidUtilities.dp(22);
@ -229,13 +229,13 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
extTextView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE);
extTextView.setText(type); extTextView.setText(type);
} else { } else {
extTextView.setVisibility(GONE); extTextView.setVisibility(INVISIBLE);
} }
if (resId == 0) { if (resId == 0) {
placeholderImabeView.setImageResource(getThumbForNameOrMime(text, type)); placeholderImabeView.setImageResource(getThumbForNameOrMime(text, type));
placeholderImabeView.setVisibility(VISIBLE); placeholderImabeView.setVisibility(VISIBLE);
} else { } else {
placeholderImabeView.setVisibility(GONE); placeholderImabeView.setVisibility(INVISIBLE);
} }
if (thumb != null || resId != 0) { if (thumb != null || resId != 0) {
if (thumb != null) { if (thumb != null) {
@ -245,7 +245,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
} }
thumbImageView.setVisibility(VISIBLE); thumbImageView.setVisibility(VISIBLE);
} else { } else {
thumbImageView.setVisibility(GONE); thumbImageView.setVisibility(INVISIBLE);
} }
} }
@ -277,7 +277,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
nameTextView.setText(name); nameTextView.setText(name);
extTextView.setText((idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase()); extTextView.setText((idx = name.lastIndexOf(".")) == -1 ? "" : name.substring(idx + 1).toLowerCase());
if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty) { if (document.messageOwner.media.document.thumb instanceof TLRPC.TL_photoSizeEmpty) {
thumbImageView.setVisibility(GONE); thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null); thumbImageView.setImageBitmap(null);
} else { } else {
thumbImageView.setVisibility(VISIBLE); thumbImageView.setVisibility(VISIBLE);
@ -291,7 +291,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
dateTextView.setText(""); dateTextView.setText("");
placeholderImabeView.setVisibility(VISIBLE); placeholderImabeView.setVisibility(VISIBLE);
extTextView.setVisibility(VISIBLE); extTextView.setVisibility(VISIBLE);
thumbImageView.setVisibility(GONE); thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null); thumbImageView.setImageBitmap(null);
} }
@ -312,7 +312,7 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
} }
loaded = false; loaded = false;
if (fileName == null) { if (fileName == null) {
statusImageView.setVisibility(GONE); statusImageView.setVisibility(INVISIBLE);
dateTextView.setPadding(0, 0, 0, 0); dateTextView.setPadding(0, 0, 0, 0);
loading = false; loading = false;
loaded = true; loaded = true;
@ -331,15 +331,15 @@ public class SharedDocumentCell extends FrameLayout implements MediaController.
} }
progressView.setProgress(progress, false); progressView.setProgress(progress, false);
} else { } else {
progressView.setVisibility(GONE); progressView.setVisibility(INVISIBLE);
} }
} }
} else { } else {
loading = false; loading = false;
loaded = true; loaded = true;
progressView.setVisibility(GONE); progressView.setVisibility(INVISIBLE);
progressView.setProgress(0, false); progressView.setProgress(0, false);
statusImageView.setVisibility(GONE); statusImageView.setVisibility(INVISIBLE);
dateTextView.setPadding(0, 0, 0, 0); dateTextView.setPadding(0, 0, 0, 0);
MediaController.getInstance().removeLoadingFileObserver(this); MediaController.getInstance().removeLoadingFileObserver(this);
} }

View File

@ -55,8 +55,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
super(context); super(context);
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.imageReceiver.setNeedsQualityThumb(true); imageView.getImageReceiver().setNeedsQualityThumb(true);
imageView.imageReceiver.setShouldGenerateQualityThumb(true); imageView.getImageReceiver().setShouldGenerateQualityThumb(true);
addView(imageView); addView(imageView);
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = LayoutParams.MATCH_PARENT; layoutParams.width = LayoutParams.MATCH_PARENT;
@ -105,7 +105,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
selector.setLayoutParams(layoutParams); selector.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2); checkBox = new CheckBox(context, R.drawable.round_check2);
checkBox.setVisibility(GONE); checkBox.setVisibility(INVISIBLE);
addView(checkBox); addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams(); layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22); layoutParams.width = AndroidUtilities.dp(22);
@ -134,7 +134,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
for (int a = 0; a < 6; a++) { for (int a = 0; a < 6; a++) {
photoVideoViews[a] = new PhotoVideoView(context); photoVideoViews[a] = new PhotoVideoView(context);
addView(photoVideoViews[a]); addView(photoVideoViews[a]);
photoVideoViews[a].setVisibility(GONE); photoVideoViews[a].setVisibility(INVISIBLE);
photoVideoViews[a].setTag(a); photoVideoViews[a].setTag(a);
photoVideoViews[a].setOnClickListener(new OnClickListener() { photoVideoViews[a].setOnClickListener(new OnClickListener() {
@Override @Override
@ -164,7 +164,7 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
public void setItemsCount(int count) { public void setItemsCount(int count) {
for (int a = 0; a < photoVideoViews.length; a++) { for (int a = 0; a < photoVideoViews.length; a++) {
photoVideoViews[a].setVisibility(a < count ? VISIBLE : GONE); photoVideoViews[a].setVisibility(a < count ? VISIBLE : INVISIBLE);
} }
itemsCount = count; itemsCount = count;
} }
@ -202,8 +202,8 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
photoVideoViews[a].setVisibility(VISIBLE); photoVideoViews[a].setVisibility(VISIBLE);
PhotoVideoView photoVideoView = photoVideoViews[a]; PhotoVideoView photoVideoView = photoVideoViews[a];
photoVideoView.imageView.imageReceiver.setParentMessageObject(messageObject); photoVideoView.imageView.getImageReceiver().setParentMessageObject(messageObject);
photoVideoView.imageView.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(messageObject), false); photoVideoView.imageView.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(messageObject), false);
if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo && messageObject.messageOwner.media.video != null) { if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaVideo && messageObject.messageOwner.media.video != null) {
photoVideoView.videoInfoContainer.setVisibility(VISIBLE); photoVideoView.videoInfoContainer.setVisibility(VISIBLE);
int duration = messageObject.messageOwner.media.video.duration; int duration = messageObject.messageOwner.media.video.duration;
@ -217,15 +217,15 @@ public class SharedPhotoVideoCell extends FrameLayoutFixed {
photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); 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()) { } 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); 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); photoVideoView.imageView.setImage(null, null, null, ApplicationLoader.applicationContext.getResources().getDrawable(R.drawable.photo_placeholder_in), null, photoSize.location, "b", 0);
} else { } else {
photoVideoView.videoInfoContainer.setVisibility(GONE); photoVideoView.videoInfoContainer.setVisibility(INVISIBLE);
photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in); photoVideoView.imageView.setImageResource(R.drawable.photo_placeholder_in);
} }
} else { } else {
photoVideoViews[a].setVisibility(GONE); photoVideoViews[a].setVisibility(INVISIBLE);
messageObjects[a] = null; messageObjects[a] = null;
} }
} }

View File

@ -26,9 +26,7 @@ public class StickerCell extends FrameLayoutFixed {
super(context); super(context);
imageView = new BackupImageView(context); imageView = new BackupImageView(context);
imageView.imageReceiver.setAspectFit(true); imageView.setAspectFit(true);
imageView.imageReceiver.setDisableRecycle(true);
imageView.processDetach = false;
addView(imageView); addView(imageView);
LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) imageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(66); layoutParams.width = AndroidUtilities.dp(66);
@ -45,8 +43,8 @@ public class StickerCell extends FrameLayoutFixed {
@Override @Override
public void setPressed(boolean pressed) { public void setPressed(boolean pressed) {
if (imageView.imageReceiver.getPressed() != pressed) { if (imageView.getImageReceiver().getPressed() != pressed) {
imageView.imageReceiver.setPressed(pressed); imageView.getImageReceiver().setPressed(pressed);
imageView.invalidate(); imageView.invalidate();
} }
super.setPressed(pressed); super.setPressed(pressed);

View File

@ -98,17 +98,17 @@ public class TextCell extends FrameLayout {
public void setText(String text) { public void setText(String text) {
textView.setText(text); textView.setText(text);
imageView.setVisibility(GONE); imageView.setVisibility(INVISIBLE);
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
} }
public void setTextAndIcon(String text, int resId) { public void setTextAndIcon(String text, int resId) {
textView.setText(text); textView.setText(text);
imageView.setImageResource(resId); imageView.setImageResource(resId);
imageView.setVisibility(VISIBLE); imageView.setVisibility(VISIBLE);
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
} }
public void setTextSize(int size) { public void setTextSize(int size) {
@ -131,15 +131,15 @@ public class TextCell extends FrameLayout {
textView.setText(text); textView.setText(text);
valueTextView.setText(value); valueTextView.setText(value);
valueTextView.setVisibility(VISIBLE); valueTextView.setVisibility(VISIBLE);
imageView.setVisibility(GONE); imageView.setVisibility(INVISIBLE);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
} }
public void setTextAndValueDrawable(String text, Drawable drawable) { public void setTextAndValueDrawable(String text, Drawable drawable) {
textView.setText(text); textView.setText(text);
valueImageView.setVisibility(VISIBLE); valueImageView.setVisibility(VISIBLE);
valueImageView.setImageDrawable(drawable); valueImageView.setImageDrawable(drawable);
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
imageView.setVisibility(GONE); imageView.setVisibility(INVISIBLE);
} }
} }

View File

@ -83,7 +83,7 @@ public class TextDetailCell extends FrameLayout {
public void setTextAndValue(String text, String value) { public void setTextAndValue(String text, String value) {
textView.setText(text); textView.setText(text);
valueTextView.setText(value); valueTextView.setText(value);
imageView.setVisibility(GONE); imageView.setVisibility(INVISIBLE);
} }
public void setTextAndValueAndIcon(String text, String value, int resId) { public void setTextAndValueAndIcon(String text, String value, int resId) {

View File

@ -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);
}
}
}

View File

@ -15,7 +15,6 @@ import android.widget.FrameLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
public class TextInfoCell extends FrameLayout { public class TextInfoCell extends FrameLayout {

View File

@ -25,10 +25,10 @@ public class TextInfoPrivacyCell extends FrameLayout {
super(context); super(context);
textView = new TextView(context); textView = new TextView(context);
textView.setTextColor(0xffa3a3a3); textView.setTextColor(0xff808080);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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); addView(textView);
LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) textView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.width = LayoutParams.WRAP_CONTENT;

View File

@ -75,7 +75,7 @@ public class TextSettingsCell extends FrameLayout {
valueImageView = new ImageView(context); valueImageView = new ImageView(context);
valueImageView.setScaleType(ImageView.ScaleType.CENTER); valueImageView.setScaleType(ImageView.ScaleType.CENTER);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
addView(valueImageView); addView(valueImageView);
layoutParams = (LayoutParams) valueImageView.getLayoutParams(); layoutParams = (LayoutParams) valueImageView.getLayoutParams();
layoutParams.width = LayoutParams.WRAP_CONTENT; layoutParams.width = LayoutParams.WRAP_CONTENT;
@ -110,20 +110,20 @@ public class TextSettingsCell extends FrameLayout {
public void setText(String text, boolean divider) { public void setText(String text, boolean divider) {
textView.setText(text); textView.setText(text);
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
needDivider = divider; needDivider = divider;
setWillNotDraw(!divider); setWillNotDraw(!divider);
} }
public void setTextAndValue(String text, String value, boolean divider) { public void setTextAndValue(String text, String value, boolean divider) {
textView.setText(text); textView.setText(text);
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
if (value != null) { if (value != null) {
valueTextView.setText(value); valueTextView.setText(value);
valueTextView.setVisibility(VISIBLE); valueTextView.setVisibility(VISIBLE);
} else { } else {
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
} }
needDivider = divider; needDivider = divider;
setWillNotDraw(!divider); setWillNotDraw(!divider);
@ -131,12 +131,12 @@ public class TextSettingsCell extends FrameLayout {
public void setTextAndIcon(String text, int resId, boolean divider) { public void setTextAndIcon(String text, int resId, boolean divider) {
textView.setText(text); textView.setText(text);
valueTextView.setVisibility(GONE); valueTextView.setVisibility(INVISIBLE);
if (resId != 0) { if (resId != 0) {
valueImageView.setVisibility(VISIBLE); valueImageView.setVisibility(VISIBLE);
valueImageView.setImageResource(resId); valueImageView.setImageResource(resId);
} else { } else {
valueImageView.setVisibility(GONE); valueImageView.setVisibility(INVISIBLE);
} }
needDivider = divider; needDivider = divider;
setWillNotDraw(!divider); setWillNotDraw(!divider);

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Cells; package org.telegram.ui.Cells;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
@ -21,6 +22,7 @@ import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
@ -61,7 +63,7 @@ public class UserCell extends FrameLayout {
super(context); super(context);
avatarImageView = new BackupImageView(context); avatarImageView = new BackupImageView(context);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(24)); avatarImageView.setRoundRadius(AndroidUtilities.dp(24));
addView(avatarImageView); addView(avatarImageView);
LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams(); LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(48); layoutParams.width = AndroidUtilities.dp(48);
@ -120,7 +122,7 @@ public class UserCell extends FrameLayout {
imageView.setLayoutParams(layoutParams); imageView.setLayoutParams(layoutParams);
checkBox = new CheckBox(context, R.drawable.round_check2); checkBox = new CheckBox(context, R.drawable.round_check2);
checkBox.setVisibility(GONE); checkBox.setVisibility(INVISIBLE);
addView(checkBox); addView(checkBox);
layoutParams = (LayoutParams) checkBox.getLayoutParams(); layoutParams = (LayoutParams) checkBox.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(22); layoutParams.width = AndroidUtilities.dp(22);
@ -207,7 +209,7 @@ public class UserCell extends FrameLayout {
return; return;
} }
} }
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
avatarDrawable.setInfo(currentUser); avatarDrawable.setInfo(currentUser);
if (currentUser.status != null) { if (currentUser.status != null) {
lastStatus = currentUser.status.expires; lastStatus = currentUser.status.expires;
@ -222,7 +224,7 @@ public class UserCell extends FrameLayout {
} else { } else {
nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name)); nameTextView.setText(ContactsController.formatName(currentUser.first_name, currentUser.last_name));
nameTextView.setTextColor(nameColor); nameTextView.setTextColor(nameColor);
nameTextView.setTextSize(AndroidUtilities.getIntDef("contactsNameSize", 17)); nameTextView.setTextSize(themePrefs.getInt("contactsNameSize", 17));
} }
if (currrntStatus != null) { if (currrntStatus != null) {
statusTextView.setText(currrntStatus); statusTextView.setText(currrntStatus);
@ -236,13 +238,13 @@ public class UserCell extends FrameLayout {
statusTextView.setTextColor(statusColor); statusTextView.setTextColor(statusColor);
} }
} }
statusTextView.setTextSize(AndroidUtilities.getIntDef("contactsStatusSize", 14)); statusTextView.setTextSize(themePrefs.getInt("contactsStatusSize", 14));
imageView.setVisibility(currentDrawable == 0 ? GONE : VISIBLE); imageView.setVisibility(currentDrawable == 0 ? INVISIBLE : VISIBLE);
imageView.setImageResource(currentDrawable); imageView.setImageResource(currentDrawable);
if(curDrawable != null)imageView.setImageDrawable(curDrawable); if(curDrawable != null)imageView.setImageDrawable(curDrawable);
//int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("contactsAvatarRadius", 32)); //int radius = AndroidUtilities.dp(themePrefs.getInt("contactsAvatarRadius", 32));
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(radius)); avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(radius));
avatarDrawable.setRadius(AndroidUtilities.dp(radius)); avatarDrawable.setRadius(AndroidUtilities.dp(radius));
avatarImageView.setImage(photo, "50_50", avatarDrawable); avatarImageView.setImage(photo, "50_50", avatarDrawable);

View File

@ -9,6 +9,7 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
@ -27,10 +28,10 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
@ -56,9 +57,7 @@ public class ChangeChatNameActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName)); 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); 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)); fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() { 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.setText(currentChat.title);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797); firstNameField.setHintTextColor(0xff979797);
@ -116,7 +115,7 @@ public class ChangeChatNameActivity extends BaseFragment {
}); });
((LinearLayout) fragmentView).addView(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.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36); layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.leftMargin = AndroidUtilities.dp(24);
@ -130,12 +129,7 @@ public class ChangeChatNameActivity extends BaseFragment {
firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName)); firstNameField.setHint(LocaleController.getString("EnterListName", R.string.EnterListName));
} }
firstNameField.setSelection(firstNameField.length()); firstNameField.setSelection(firstNameField.length());
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -9,6 +9,7 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.text.InputType; import android.text.InputType;
@ -26,14 +27,14 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; 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.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest; import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
@ -49,8 +50,7 @@ public class ChangeNameActivity extends BaseFragment {
private final static int done_button = 1; private final static int done_button = 1;
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName)); actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
@ -76,7 +76,7 @@ public class ChangeNameActivity extends BaseFragment {
user = UserConfig.getCurrentUser(); user = UserConfig.getCurrentUser();
} }
fragmentView = new LinearLayout(getParentActivity()); fragmentView = new LinearLayout(context);
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() { 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.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121); firstNameField.setTextColor(0xff212121);
@ -100,7 +100,7 @@ public class ChangeNameActivity extends BaseFragment {
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName)); firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
AndroidUtilities.clearCursorDrawable(firstNameField); AndroidUtilities.clearCursorDrawable(firstNameField);
((LinearLayout) fragmentView).addView(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.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36); layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24); 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.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xff979797); lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff212121); lastNameField.setTextColor(0xff212121);
@ -133,7 +133,7 @@ public class ChangeNameActivity extends BaseFragment {
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName)); lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
AndroidUtilities.clearCursorDrawable(lastNameField); AndroidUtilities.clearCursorDrawable(lastNameField);
((LinearLayout) fragmentView).addView(lastNameField); ((LinearLayout) fragmentView).addView(lastNameField);
layoutParams = (LinearLayout.LayoutParams)lastNameField.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(16); layoutParams.topMargin = AndroidUtilities.dp(16);
layoutParams.height = AndroidUtilities.dp(36); layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.leftMargin = AndroidUtilities.dp(24);
@ -156,12 +156,7 @@ public class ChangeNameActivity extends BaseFragment {
firstNameField.setSelection(firstNameField.length()); firstNameField.setSelection(firstNameField.length());
lastNameField.setText(user.last_name); lastNameField.setText(user.last_name);
} }
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -26,7 +26,6 @@ import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -102,8 +101,7 @@ public class ChangePhoneActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName)); actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@ -120,11 +118,11 @@ public class ChangePhoneActivity extends BaseFragment {
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = new ScrollView(getParentActivity()); fragmentView = new ScrollView(context);
ScrollView scrollView = (ScrollView) fragmentView; ScrollView scrollView = (ScrollView) fragmentView;
scrollView.setFillViewport(true); scrollView.setFillViewport(true);
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
scrollView.addView(frameLayout); scrollView.addView(frameLayout);
ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) frameLayout.getLayoutParams(); ScrollView.LayoutParams layoutParams = (ScrollView.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams.width = ScrollView.LayoutParams.MATCH_PARENT;
@ -132,7 +130,7 @@ public class ChangePhoneActivity extends BaseFragment {
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
frameLayout.setLayoutParams(layoutParams); frameLayout.setLayoutParams(layoutParams);
views[0] = new PhoneView(getParentActivity()); views[0] = new PhoneView(context);
views[0].setVisibility(View.VISIBLE); views[0].setVisibility(View.VISIBLE);
frameLayout.addView(views[0]); frameLayout.addView(views[0]);
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams(); FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) views[0].getLayoutParams();
@ -144,7 +142,7 @@ public class ChangePhoneActivity extends BaseFragment {
layoutParams1.gravity = Gravity.TOP | Gravity.LEFT; layoutParams1.gravity = Gravity.TOP | Gravity.LEFT;
views[0].setLayoutParams(layoutParams1); views[0].setLayoutParams(layoutParams1);
views[1] = new LoginActivitySmsView(getParentActivity()); views[1] = new LoginActivitySmsView(context);
views[1].setVisibility(View.GONE); views[1].setVisibility(View.GONE);
frameLayout.addView(views[1]); frameLayout.addView(views[1]);
layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams(); layoutParams1 = (FrameLayout.LayoutParams) views[1].getLayoutParams();
@ -158,10 +156,10 @@ public class ChangePhoneActivity extends BaseFragment {
try { try {
if (views[0] == null || views[1] == null) { 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++) { for (int a = 0; a < views.length; a++) {
if (views[a] == null) { 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()); actionBar.setTitle(views[0].getHeaderName());
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -9,13 +9,13 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
@ -35,8 +35,7 @@ import org.telegram.ui.ActionBar.BaseFragment;
public class ChangePhoneHelpActivity extends BaseFragment { public class ChangePhoneHelpActivity extends BaseFragment {
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); 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() { fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
@ -68,7 +67,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
RelativeLayout relativeLayout = (RelativeLayout) fragmentView; RelativeLayout relativeLayout = (RelativeLayout) fragmentView;
ScrollView scrollView = new ScrollView(getParentActivity()); ScrollView scrollView = new ScrollView(context);
relativeLayout.addView(scrollView); relativeLayout.addView(scrollView);
RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams(); RelativeLayout.LayoutParams layoutParams3 = (RelativeLayout.LayoutParams) scrollView.getLayoutParams();
layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT; layoutParams3.width = RelativeLayout.LayoutParams.MATCH_PARENT;
@ -76,7 +75,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParams3.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
scrollView.setLayoutParams(layoutParams3); scrollView.setLayoutParams(layoutParams3);
LinearLayout linearLayout = new LinearLayout(getParentActivity()); LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20)); linearLayout.setPadding(0, AndroidUtilities.dp(20), 0, AndroidUtilities.dp(20));
scrollView.addView(linearLayout); scrollView.addView(linearLayout);
@ -85,28 +84,28 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT; layoutParams.height = ScrollView.LayoutParams.WRAP_CONTENT;
linearLayout.setLayoutParams(layoutParams); linearLayout.setLayoutParams(layoutParams);
ImageView imageView = new ImageView(getParentActivity()); ImageView imageView = new ImageView(context);
imageView.setImageResource(R.drawable.phone_change); imageView.setImageResource(R.drawable.phone_change);
linearLayout.addView(imageView); linearLayout.addView(imageView);
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams)imageView.getLayoutParams(); LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) imageView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
imageView.setLayoutParams(layoutParams2); imageView.setLayoutParams(layoutParams2);
TextView textView = new TextView(getParentActivity()); TextView textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setTextColor(0xff212121); textView.setTextColor(0xff212121);
try { try {
textView.setText(AndroidUtilities.replaceBold(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp))); textView.setText(AndroidUtilities.replaceTags(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)));
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp)); textView.setText(LocaleController.getString("PhoneNumberHelp", R.string.PhoneNumberHelp));
} }
linearLayout.addView(textView); linearLayout.addView(textView);
layoutParams2 = (LinearLayout.LayoutParams)textView.getLayoutParams(); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; layoutParams2.gravity = Gravity.CENTER_HORIZONTAL;
@ -115,7 +114,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
layoutParams2.topMargin = AndroidUtilities.dp(56); layoutParams2.topMargin = AndroidUtilities.dp(56);
textView.setLayoutParams(layoutParams2); textView.setLayoutParams(layoutParams2);
textView = new TextView(getParentActivity()); textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
textView.setGravity(Gravity.CENTER_HORIZONTAL); textView.setGravity(Gravity.CENTER_HORIZONTAL);
//textView.setTextColor(0xff4d83b3); //textView.setTextColor(0xff4d83b3);
@ -124,7 +123,7 @@ public class ChangePhoneHelpActivity extends BaseFragment {
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10)); textView.setPadding(0, AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10));
linearLayout.addView(textView); linearLayout.addView(textView);
layoutParams2 = (LinearLayout.LayoutParams)textView.getLayoutParams(); layoutParams2 = (LinearLayout.LayoutParams) textView.getLayoutParams();
layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams2.height = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams2.gravity = Gravity.CENTER_HORIZONTAL; 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; return fragmentView;
} }
} }

View File

@ -11,11 +11,11 @@ package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.text.Editable; import android.text.Editable;
import android.text.Html;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.TypedValue; import android.util.TypedValue;
@ -62,8 +62,7 @@ public class ChangeUsernameActivity extends BaseFragment {
private final static int done_button = 1; private final static int done_button = 1;
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("Username", R.string.Username)); actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
@ -86,7 +85,7 @@ public class ChangeUsernameActivity extends BaseFragment {
user = UserConfig.getCurrentUser(); user = UserConfig.getCurrentUser();
} }
fragmentView = new LinearLayout(getParentActivity()); fragmentView = new LinearLayout(context);
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL); ((LinearLayout) fragmentView).setOrientation(LinearLayout.VERTICAL);
fragmentView.setOnTouchListener(new View.OnTouchListener() { 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.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121); firstNameField.setTextColor(0xff212121);
@ -122,7 +121,7 @@ public class ChangeUsernameActivity extends BaseFragment {
}); });
((LinearLayout) fragmentView).addView(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.topMargin = AndroidUtilities.dp(24);
layoutParams.height = AndroidUtilities.dp(36); layoutParams.height = AndroidUtilities.dp(36);
layoutParams.leftMargin = AndroidUtilities.dp(24); layoutParams.leftMargin = AndroidUtilities.dp(24);
@ -135,11 +134,11 @@ public class ChangeUsernameActivity extends BaseFragment {
firstNameField.setSelection(firstNameField.length()); firstNameField.setSelection(firstNameField.length());
} }
checkTextView = new TextView(getParentActivity()); checkTextView = new TextView(context);
checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); checkTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); checkTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
((LinearLayout) fragmentView).addView(checkTextView); ((LinearLayout) fragmentView).addView(checkTextView);
layoutParams = (LinearLayout.LayoutParams)checkTextView.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams) checkTextView.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(12); layoutParams.topMargin = AndroidUtilities.dp(12);
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
@ -148,13 +147,13 @@ public class ChangeUsernameActivity extends BaseFragment {
layoutParams.rightMargin = AndroidUtilities.dp(24); layoutParams.rightMargin = AndroidUtilities.dp(24);
checkTextView.setLayoutParams(layoutParams); checkTextView.setLayoutParams(layoutParams);
TextView helpTextView = new TextView(getParentActivity()); TextView helpTextView = new TextView(context);
helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); helpTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
helpTextView.setTextColor(0xff6d6d72); helpTextView.setTextColor(0xff6d6d72);
helpTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT); 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); ((LinearLayout) fragmentView).addView(helpTextView);
layoutParams = (LinearLayout.LayoutParams)helpTextView.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams) helpTextView.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(10); layoutParams.topMargin = AndroidUtilities.dp(10);
layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
@ -181,12 +180,7 @@ public class ChangeUsernameActivity extends BaseFragment {
}); });
checkTextView.setVisibility(View.GONE); checkTextView.setVisibility(View.GONE);
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

File diff suppressed because it is too large Load Diff

View File

@ -19,22 +19,23 @@ import android.provider.MediaStore;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader; import org.telegram.android.ImageLoader;
import org.telegram.android.MediaController; import org.telegram.android.MediaController;
import org.telegram.messenger.TLRPC; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
import org.telegram.ui.PhotoAlbumPickerActivity; import org.telegram.ui.PhotoAlbumPickerActivity;
import org.telegram.ui.PhotoCropActivity; import org.telegram.ui.PhotoCropActivity;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.PhotoViewer; import org.telegram.ui.PhotoViewer;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
public class AvatarUpdater implements NotificationCenter.NotificationCenterDelegate, PhotoCropActivity.PhotoEditActivityDelegate { public class AvatarUpdater implements NotificationCenter.NotificationCenterDelegate, PhotoCropActivity.PhotoEditActivityDelegate {
public String currentPicturePath; public String currentPicturePath;
private TLRPC.PhotoSize smallPhoto; private TLRPC.PhotoSize smallPhoto;
private TLRPC.PhotoSize bigPhoto; private TLRPC.PhotoSize bigPhoto;

View File

@ -20,10 +20,9 @@ import org.telegram.android.ImageReceiver;
import org.telegram.messenger.TLObject; import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
public class BackupImageView extends View { public class BackupImageView extends View {
public ImageReceiver imageReceiver;
public boolean processDetach = true; private ImageReceiver imageReceiver;
public BackupImageView(Context context) { public BackupImageView(Context context) {
super(context); super(context);
@ -91,13 +90,23 @@ public class BackupImageView extends View {
imageReceiver.setImageBitmap(drawable); 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 @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();
if (processDetach) {
imageReceiver.clearImage(); imageReceiver.clearImage();
} }
}
@Override @Override
protected void onDraw(Canvas canvas) { protected void onDraw(Canvas canvas) {

View File

@ -12,7 +12,6 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Build; import android.os.Build;
@ -20,12 +19,10 @@ import android.os.PowerManager;
import android.text.Editable; import android.text.Editable;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.view.WindowManager;
@ -50,7 +47,6 @@ import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; 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.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.messenger.ApplicationLoader;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -68,7 +63,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
public interface ChatActivityEnterViewDelegate { public interface ChatActivityEnterViewDelegate {
void onMessageSend(String message); void onMessageSend(String message);
void needSendTyping(); void needSendTyping();
void onTextChanged(CharSequence text); void onTextChanged(CharSequence text, boolean bigChange);
void onAttachButtonHidden(); void onAttachButtonHidden();
void onAttachButtonShow(); void onAttachButtonShow();
void onWindowSizeChanged(int size); void onWindowSizeChanged(int size);
@ -111,11 +106,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
private long dialog_id; private long dialog_id;
private boolean ignoreTextChange; private boolean ignoreTextChange;
private MessageObject replyingMessageObject; private MessageObject replyingMessageObject;
private TLRPC.WebPage messageWebPage;
private boolean messageWebPageSearch;
private ChatActivityEnterViewDelegate delegate; private ChatActivityEnterViewDelegate delegate;
private float topViewAnimation; private float topViewAnimation;
private boolean topViewShowed;
private boolean needShowTopView; private boolean needShowTopView;
private boolean allowShowTopView; private boolean allowShowTopView;
private AnimatorSetProxy currentTopViewAnimation;
public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) { public ChatActivityEnterView(Activity context, SizeNotifierRelativeLayout parent, BaseFragment fragment, boolean isChat) {
super(context); super(context);
@ -161,7 +160,9 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
emojiButton = new ImageView(context); emojiButton = new ImageView(context);
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles); //emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
Drawable emoji = parentActivity.getResources().getDrawable(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.setImageDrawable(emoji);
emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); emojiButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0); emojiButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(1), 0, 0);
@ -244,12 +245,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
@Override @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()); String message = getTrimmedString(charSequence.toString());
checkSendButton(true); checkSendButton(true);
if (delegate != null) { 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) { 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.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//audioSendButton.setImageResource(R.drawable.mic_button_states); //audioSendButton.setImageResource(R.drawable.mic_button_states);
//audioSendButton.setBackgroundColor(0xffffffff); //audioSendButton.setBackgroundColor(0xffffffff);
audioSendButton.setSoundEffectsEnabled(false);
Drawable mic = parentActivity.getResources().getDrawable(R.drawable.mic); 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.setImageDrawable(mic);
audioSendButton.setBackgroundColor(0x00000000); audioSendButton.setBackgroundColor(0x00000000);
audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0); audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
@ -425,7 +430,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
updateAudioRecordIntefrace(); updateAudioRecordIntefrace();
audioSendButton.getParent().requestDisallowInterceptTouchEvent(true); audioSendButton.getParent().requestDisallowInterceptTouchEvent(true);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) { } 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); audioSendButton.setImageDrawable(mic);
startedDraggingX = -1; startedDraggingX = -1;
MediaController.getInstance().stopRecording(true); MediaController.getInstance().stopRecording(true);
@ -480,6 +485,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
sendButton.setVisibility(View.INVISIBLE); sendButton.setVisibility(View.INVISIBLE);
sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE); sendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
sendButton.setImageResource(R.drawable.ic_send); sendButton.setImageResource(R.drawable.ic_send);
sendButton.setSoundEffectsEnabled(false);
ViewProxy.setScaleX(sendButton, 0.1f); ViewProxy.setScaleX(sendButton, 0.1f);
ViewProxy.setScaleY(sendButton, 0.1f); ViewProxy.setScaleY(sendButton, 0.1f);
ViewProxy.setAlpha(sendButton, 0.0f); ViewProxy.setAlpha(sendButton, 0.0f);
@ -502,13 +508,15 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
private void updateTheme() { 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); 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); sendButton.setImageDrawable(send);
messageEditText.setTextColor(AndroidUtilities.getIntDef("chatEditTextColor",0xff000000)); messageEditText.setTextColor(themePrefs.getInt("chatEditTextColor", 0xff000000));
messageEditText.setHintTextColor(AndroidUtilities.getIntAlphaColor("chatEditTextColor", 0xff000000, 0.35f)); messageEditText.setHintTextColor(AndroidUtilities.getIntAlphaColor("chatEditTextColor", 0xff000000, 0.35f));
messageEditText.setTextSize(AndroidUtilities.getIntDef("chatEditTextSize",18)); messageEditText.setTextSize(themePrefs.getInt("chatEditTextSize", 18));
int color = AndroidUtilities.getIntDef("chatEditTextBGColor", 0xffffffff); int color = themePrefs.getInt("chatEditTextBGColor", 0xffffffff);
setBackgroundColor(color); setBackgroundColor(color);
textFieldContainer.setBackgroundColor(color); textFieldContainer.setBackgroundColor(color);
} }
@ -530,6 +538,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
public void setTopViewAnimation(float progress) { public void setTopViewAnimation(float progress) {
topViewAnimation = progress;
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams();
layoutParams2.topMargin = AndroidUtilities.dp(2) + (int) (topView.getLayoutParams().height * progress); layoutParams2.topMargin = AndroidUtilities.dp(2) + (int) (topView.getLayoutParams().height * progress);
textFieldContainer.setLayoutParams(layoutParams2); textFieldContainer.setLayoutParams(layoutParams2);
@ -545,75 +554,85 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
public void showTopView(boolean animated) { public void showTopView(boolean animated) {
if (topView == null) { if (topView == null || topViewShowed) {
return; return;
} }
needShowTopView = true; needShowTopView = true;
topViewShowed = true;
if (allowShowTopView) { if (allowShowTopView) {
topView.setVisibility(VISIBLE); topView.setVisibility(VISIBLE);
float resumeValue = 0.0f;
if (currentTopViewAnimation != null) {
resumeValue = topViewAnimation;
currentTopViewAnimation.cancel();
currentTopViewAnimation = null;
}
if (animated) { if (animated) {
if (keyboardVisible || emojiPopup != null && emojiPopup.isShowing()) { if (keyboardVisible || emojiPopup != null && emojiPopup.isShowing()) {
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); currentTopViewAnimation = new AnimatorSetProxy();
animatorSetProxy.playTogether( currentTopViewAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 0.0f, 1.0f) ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 1.0f)
); );
animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() { currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override @Override
public void onAnimationEnd(Object animation) { public void onAnimationEnd(Object animation) {
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); if (animation == currentTopViewAnimation) {
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height; setTopViewAnimation(1.0f);
textFieldContainer.setLayoutParams(layoutParams2);
if (!forceShowSendButton) { if (!forceShowSendButton) {
openKeyboard(); openKeyboard();
}
currentTopViewAnimation = null;
} }
} }
}); });
animatorSetProxy.setDuration(200); currentTopViewAnimation.setDuration(200);
animatorSetProxy.start(); currentTopViewAnimation.start();
} else { } else {
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(1.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
textFieldContainer.setLayoutParams(layoutParams2);
if (!forceShowSendButton) { if (!forceShowSendButton) {
openKeyboard(); openKeyboard();
} }
} }
} else { } else {
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(1.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
textFieldContainer.setLayoutParams(layoutParams2);
} }
} }
} }
public void hideTopView(boolean animated) { public void hideTopView(final boolean animated) {
if (topView == null) { if (topView == null || !topViewShowed) {
return; return;
} }
topViewShowed = false;
needShowTopView = false; needShowTopView = false;
if (allowShowTopView) { if (allowShowTopView) {
float resumeValue = 1.0f;
if (currentTopViewAnimation != null) {
resumeValue = topViewAnimation;
currentTopViewAnimation.cancel();
currentTopViewAnimation = null;
}
if (animated) { if (animated) {
AnimatorSetProxy animatorSetProxy = new AnimatorSetProxy(); currentTopViewAnimation = new AnimatorSetProxy();
animatorSetProxy.playTogether( currentTopViewAnimation.playTogether(
ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", 1.0f, 0.0f) ObjectAnimatorProxy.ofFloat(ChatActivityEnterView.this, "topViewAnimation", resumeValue, 0.0f)
); );
animatorSetProxy.addListener(new AnimatorListenerAdapterProxy() { currentTopViewAnimation.addListener(new AnimatorListenerAdapterProxy() {
@Override @Override
public void onAnimationEnd(Object animation) { public void onAnimationEnd(Object animation) {
if (animation == currentTopViewAnimation) {
topView.setVisibility(GONE); topView.setVisibility(GONE);
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(0.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2); currentTopViewAnimation = null;
textFieldContainer.setLayoutParams(layoutParams2); }
} }
}); });
animatorSetProxy.setDuration(200); currentTopViewAnimation.setDuration(200);
animatorSetProxy.start(); currentTopViewAnimation.start();
} else { } else {
topView.setVisibility(GONE); topView.setVisibility(GONE);
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(0.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2);
textFieldContainer.setLayoutParams(layoutParams2);
} }
} }
} }
@ -632,9 +651,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
allowShowTopView = false; allowShowTopView = false;
if (needShowTopView) { if (needShowTopView) {
topView.setVisibility(View.GONE); topView.setVisibility(View.GONE);
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(0.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2);
textFieldContainer.setLayoutParams(layoutParams2);
} }
} }
} else { } else {
@ -642,9 +659,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
allowShowTopView = true; allowShowTopView = true;
if (needShowTopView) { if (needShowTopView) {
topView.setVisibility(View.VISIBLE); topView.setVisibility(View.VISIBLE);
LayoutParams layoutParams2 = (LayoutParams) textFieldContainer.getLayoutParams(); setTopViewAnimation(1.0f);
layoutParams2.topMargin = AndroidUtilities.dp(2) + topView.getLayoutParams().height;
textFieldContainer.setLayoutParams(layoutParams2);
} }
} }
} }
@ -682,6 +697,11 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
replyingMessageObject = messageObject; replyingMessageObject = messageObject;
} }
public void setWebPage(TLRPC.WebPage webPage, boolean searchWebPages) {
messageWebPage = webPage;
messageWebPageSearch = searchWebPages;
}
private void sendMessage() { private void sendMessage() {
if (parentFragment != null) { if (parentFragment != null) {
String action = null; String action = null;
@ -720,7 +740,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
int count = (int) Math.ceil(text.length() / 4096.0f); int count = (int) Math.ceil(text.length() / 4096.0f);
for (int a = 0; a < count; a++) { for (int a = 0; a < count; a++) {
String mess = text.substring(a * 4096, Math.min((a + 1) * 4096, text.length())); 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; return true;
} }
@ -991,6 +1011,8 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
private void showEmojiPopup(boolean show) { 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 (show) {
if (emojiPopup == null) { if (emojiPopup == null) {
if (parentActivity == null) { if (parentActivity == null) {
@ -1076,7 +1098,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight); sizeNotifierRelativeLayout.setPadding(0, 0, 0, currentHeight);
//emojiButton.setImageResource(R.drawable.ic_msg_panel_hide); //emojiButton.setImageResource(R.drawable.ic_msg_panel_hide);
Drawable hide = parentActivity.getResources().getDrawable(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); emojiButton.setImageDrawable(hide);
onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom()); onWindowSizeChanged(sizeNotifierRelativeLayout.getHeight() - sizeNotifierRelativeLayout.getPaddingBottom());
} }
@ -1095,14 +1117,14 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
} }
//emojiButton.setImageResource(R.drawable.ic_msg_panel_kb); //emojiButton.setImageResource(R.drawable.ic_msg_panel_kb);
Drawable kb = parentActivity.getResources().getDrawable(R.drawable.ic_msg_panel_kb_white); 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); emojiButton.setImageDrawable(kb);
return; return;
} }
if (emojiButton != null) { if (emojiButton != null) {
//emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles); //emojiButton.setImageResource(R.drawable.ic_msg_panel_smiles);
Drawable emoji = parentActivity.getResources().getDrawable(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); emojiButton.setImageDrawable(emoji);
} }
if (emojiPopup != null) { if (emojiPopup != null) {
@ -1147,7 +1169,7 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
messageEditText.setSelection(messageEditText.getText().length()); messageEditText.setSelection(messageEditText.getText().length());
ignoreTextChange = false; ignoreTextChange = false;
if (delegate != null) { if (delegate != null) {
delegate.onTextChanged(messageEditText.getText()); delegate.onTextChanged(messageEditText.getText(), true);
} }
} }
@ -1229,7 +1251,6 @@ public class ChatActivityEnterView extends FrameLayoutFixed implements Notificat
@Override @Override
public void onSizeChanged(int height, boolean isWidthGreater) { public void onSizeChanged(int height, boolean isWidthGreater) {
if (height > AndroidUtilities.dp(50) && keyboardVisible) { if (height > AndroidUtilities.dp(50) && keyboardVisible) {
//if (height > AndroidUtilities.dp(50) ) {
if (isWidthGreater) { if (isWidthGreater) {
keyboardHeightLand = height; keyboardHeightLand = height;
ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit(); ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0).edit().putInt("kbd_height_land3", keyboardHeightLand).commit();

View File

@ -22,6 +22,7 @@ import org.telegram.messenger.FileLog;
import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.AnimationCompat.ViewProxy;
public class ClippingImageView extends View { public class ClippingImageView extends View {
private int clipBottom; private int clipBottom;
private int clipLeft; private int clipLeft;
private int clipRight; private int clipRight;
@ -79,7 +80,7 @@ public class ClippingImageView extends View {
} }
public void onDraw(Canvas canvas) { public void onDraw(Canvas canvas) {
if (getVisibility() == GONE || getVisibility() == INVISIBLE) { if (getVisibility() != VISIBLE) {
return; return;
} }
if (bmp != null) { if (bmp != null) {

View File

@ -9,6 +9,7 @@
package org.telegram.ui.Components; package org.telegram.ui.Components;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
@ -26,12 +27,14 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.Emoji; import org.telegram.android.Emoji;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import java.util.ArrayList; import java.util.ArrayList;
public class EmojiView extends LinearLayout { public class EmojiView extends LinearLayout {
private ArrayList<EmojiGridAdapter> adapters = new ArrayList<EmojiGridAdapter>();
private ArrayList<EmojiGridAdapter> adapters = new ArrayList<>();
private int[] icons = { private int[] icons = {
R.drawable.ic_emoji_recent, R.drawable.ic_emoji_recent,
R.drawable.ic_emoji_smile, R.drawable.ic_emoji_smile,
@ -42,7 +45,7 @@ public class EmojiView extends LinearLayout {
private Listener listener; private Listener listener;
private ViewPager pager; private ViewPager pager;
private FrameLayout recentsWrap; private FrameLayout recentsWrap;
private ArrayList<GridView> views = new ArrayList<GridView>(); private ArrayList<GridView> views = new ArrayList<>();
public EmojiView(Context paramContext) { public EmojiView(Context paramContext) {
super(paramContext); super(paramContext);
@ -63,7 +66,7 @@ public class EmojiView extends LinearLayout {
if (this.pager.getCurrentItem() == 0) { if (this.pager.getCurrentItem() == 0) {
return; return;
} }
ArrayList<Long> localArrayList = new ArrayList<Long>(); ArrayList<Long> localArrayList = new ArrayList<>();
long[] currentRecent = Emoji.data[0]; long[] currentRecent = Emoji.data[0];
boolean was = false; boolean was = false;
for (long aCurrentRecent : currentRecent) { for (long aCurrentRecent : currentRecent) {
@ -163,12 +166,13 @@ public class EmojiView extends LinearLayout {
} }
private void updateTheme(PagerSlidingTabStrip tabs) { private void updateTheme(PagerSlidingTabStrip tabs) {
setBackgroundColor(AndroidUtilities.getIntDef("chatEmojiViewBGColor",0xff222222)); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
tabs.setIndicatorColor(AndroidUtilities.getIntDef("chatEmojiViewTabColor",AndroidUtilities.getIntDarkerColor("themeColor",0x15)));//0xff33b5e5 setBackgroundColor(themePrefs.getInt("chatEmojiViewBGColor", 0xff222222));
tabs.setIndicatorColor(themePrefs.getInt("chatEmojiViewTabColor",AndroidUtilities.getIntDarkerColor("themeColor",0x15)));//0xff33b5e5
} }
private void saveRecents() { private void saveRecents() {
ArrayList<Long> localArrayList = new ArrayList<Long>(); ArrayList<Long> localArrayList = new ArrayList<>();
long[] arrayOfLong = Emoji.data[0]; long[] arrayOfLong = Emoji.data[0];
int i = arrayOfLong.length; int i = arrayOfLong.length;
for (int j = 0; ; j++) { for (int j = 0; ; j++) {

View File

@ -19,7 +19,8 @@ import org.telegram.messenger.FileLog;
import java.util.ArrayList; import java.util.ArrayList;
public class FrameLayoutFixed extends FrameLayout { public class FrameLayoutFixed extends FrameLayout {
private final ArrayList<View> mMatchParentChildren = new ArrayList<View>(1);
private final ArrayList<View> mMatchParentChildren = new ArrayList<>(1);
public FrameLayoutFixed(Context context) { public FrameLayoutFixed(Context context) {
super(context); super(context);
@ -110,7 +111,7 @@ public class FrameLayoutFixed extends FrameLayout {
} }
setMeasuredDimension(resolveSizeAndStateFixed(maxWidth, widthMeasureSpec, childState), setMeasuredDimension(resolveSizeAndStateFixed(maxWidth, widthMeasureSpec, childState),
resolveSizeAndStateFixed(maxHeight, heightMeasureSpec, childState << MEASURED_HEIGHT_STATE_SHIFT)); resolveSizeAndStateFixed(maxHeight, heightMeasureSpec, childState << 16));
count = mMatchParentChildren.size(); count = mMatchParentChildren.size();
if (count > 1) { if (count > 1) {

View File

@ -14,6 +14,7 @@ import android.graphics.Paint;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
public class ProgressView { public class ProgressView {
private Paint innerPaint; private Paint innerPaint;
private Paint outerPaint; private Paint outerPaint;

View File

@ -33,14 +33,17 @@ public class SizeNotifierRelativeLayout extends RelativeLayout {
public SizeNotifierRelativeLayout(Context context) { public SizeNotifierRelativeLayout(Context context) {
super(context); super(context);
setWillNotDraw(false);
} }
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs) { public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs) {
super(context, attrs); super(context, attrs);
setWillNotDraw(false);
} }
public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle) { public SizeNotifierRelativeLayout(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); super(context, attrs, defStyle);
setWillNotDraw(false);
} }
public void setBackgroundImage(int resourceId) { public void setBackgroundImage(int resourceId) {

View File

@ -49,4 +49,8 @@ public class SlideView extends LinearLayout {
public void restoreStateParams(Bundle bundle) { public void restoreStateParams(Bundle bundle) {
} }
public boolean needBackButton() {
return false;
}
} }

View File

@ -29,6 +29,7 @@ import java.util.ArrayList;
@TargetApi(10) @TargetApi(10)
public class VideoTimelineView extends View { public class VideoTimelineView extends View {
private long videoLength = 0; private long videoLength = 0;
private float progressLeft = 0; private float progressLeft = 0;
private float progressRight = 1; private float progressRight = 1;
@ -39,7 +40,7 @@ public class VideoTimelineView extends View {
private float pressDx = 0; private float pressDx = 0;
private MediaMetadataRetriever mediaMetadataRetriever = null; private MediaMetadataRetriever mediaMetadataRetriever = null;
private VideoTimelineViewDelegate delegate = null; private VideoTimelineViewDelegate delegate = null;
private ArrayList<Bitmap> frames = new ArrayList<Bitmap>(); private ArrayList<Bitmap> frames = new ArrayList<>();
private AsyncTask<Integer, Integer, Bitmap> currentTask = null; private AsyncTask<Integer, Integer, Bitmap> currentTask = null;
private static final Object sync = new Object(); private static final Object sync = new Object();
private long frameTimeOffset = 0; private long frameTimeOffset = 0;

View File

@ -9,6 +9,7 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.text.InputType; import android.text.InputType;
@ -19,7 +20,6 @@ import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -27,20 +27,20 @@ import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -74,15 +74,11 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override @Override
public void onFragmentDestroy() { public void onFragmentDestroy() {
super.onFragmentDestroy(); super.onFragmentDestroy();
if (avatarImage != null) {
avatarImage.setImageDrawable(null);
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
if (addContact) { if (addContact) {
@ -111,9 +107,9 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = new ScrollView(getParentActivity()); fragmentView = new ScrollView(context);
LinearLayout linearLayout = new LinearLayout(getParentActivity()); LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setOrientation(LinearLayout.VERTICAL);
((ScrollView) fragmentView).addView(linearLayout); ((ScrollView) fragmentView).addView(linearLayout);
ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
@ -127,7 +123,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
} }
}); });
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
linearLayout.addView(frameLayout); linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.topMargin = AndroidUtilities.dp(24); layoutParams.topMargin = AndroidUtilities.dp(24);
@ -137,9 +133,8 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams.height = LinearLayout.LayoutParams.WRAP_CONTENT;
frameLayout.setLayoutParams(layoutParams); frameLayout.setLayoutParams(layoutParams);
avatarImage = new BackupImageView(getParentActivity()); avatarImage = new BackupImageView(context);
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30)); avatarImage.setRoundRadius(AndroidUtilities.dp(30));
avatarImage.processDetach = false;
frameLayout.addView(avatarImage); frameLayout.addView(avatarImage);
FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
@ -147,7 +142,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
layoutParams3.height = AndroidUtilities.dp(60); layoutParams3.height = AndroidUtilities.dp(60);
avatarImage.setLayoutParams(layoutParams3); avatarImage.setLayoutParams(layoutParams3);
nameTextView = new TextView(getParentActivity()); nameTextView = new TextView(context);
nameTextView.setTextColor(0xff212121); nameTextView.setTextColor(0xff212121);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
nameTextView.setLines(1); nameTextView.setLines(1);
@ -166,7 +161,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
nameTextView.setLayoutParams(layoutParams3); nameTextView.setLayoutParams(layoutParams3);
onlineTextView = new TextView(getParentActivity()); onlineTextView = new TextView(context);
onlineTextView.setTextColor(0xff999999); onlineTextView.setTextColor(0xff999999);
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setLines(1); onlineTextView.setLines(1);
@ -184,7 +179,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
onlineTextView.setLayoutParams(layoutParams3); onlineTextView.setLayoutParams(layoutParams3);
firstNameField = new EditText(getParentActivity()); firstNameField = new EditText(context);
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
firstNameField.setHintTextColor(0xff979797); firstNameField.setHintTextColor(0xff979797);
firstNameField.setTextColor(0xff212121); firstNameField.setTextColor(0xff212121);
@ -216,7 +211,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
} }
}); });
lastNameField = new EditText(getParentActivity()); lastNameField = new EditText(context);
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
lastNameField.setHintTextColor(0xff979797); lastNameField.setHintTextColor(0xff979797);
lastNameField.setTextColor(0xff212121); lastNameField.setTextColor(0xff212121);
@ -259,13 +254,6 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
lastNameField.setText(user.last_name); lastNameField.setText(user.last_name);
} }
updateAvatarLayout();
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -299,6 +287,7 @@ public class ContactAddActivity extends BaseFragment implements NotificationCent
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
updateAvatarLayout();
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
boolean animations = preferences.getBoolean("view_animations", true); boolean animations = preferences.getBoolean("view_animations", true);
if (!animations) { if (!animations) {

View File

@ -9,10 +9,9 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -33,23 +32,23 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; 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.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.android.SecretChatHelper;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.messenger.TLRPC;
import org.telegram.ui.Adapters.ContactsAdapter;
import org.telegram.ui.Adapters.SearchAdapter;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment; 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 org.telegram.ui.Components.LetterSectionsListView;
import java.util.ArrayList; import java.util.ArrayList;
@ -118,8 +117,8 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
searching = false; searching = false;
searchWas = false; searchWas = false;
@ -182,7 +181,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
if (listView != null) { if (listView != null) {
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
searchListViewAdapter.notifyDataSetChanged(); searchListViewAdapter.notifyDataSetChanged();
if(android.os.Build.VERSION.SDK_INT >= 11) { if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false); listView.setFastScrollAlwaysVisible(false);
} }
listView.setFastScrollEnabled(false); listView.setFastScrollEnabled(false);
@ -197,12 +196,12 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
}); });
item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
searchListViewAdapter = new SearchAdapter(getParentActivity(), ignoreUsers, allowUsernameSearch); searchListViewAdapter = new SearchAdapter(context, ignoreUsers, allowUsernameSearch);
listViewAdapter = new ContactsAdapter(getParentActivity(), onlyUsers, needPhonebook, ignoreUsers); 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.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout); ((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.setTextColor(0xff808080);
emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -230,7 +229,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1); emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
emptyTextLayout.addView(frameLayout); emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -238,7 +237,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1); frameLayout.setLayoutParams(layoutParams1);
listView = new LetterSectionsListView(getParentActivity()); listView = new LetterSectionsListView(context);
listView.setEmptyView(emptyTextLayout); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); 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; return fragmentView;
} }

View File

@ -8,12 +8,12 @@
package org.telegram.ui; package org.telegram.ui;
import android.content.Context;
import android.os.Build; import android.os.Build;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.EditText; import android.widget.EditText;
@ -25,13 +25,13 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.R; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment; 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; import org.telegram.ui.Components.LetterSectionsListView;
public class CountrySelectActivity extends BaseFragment { public class CountrySelectActivity extends BaseFragment {
@ -61,8 +61,7 @@ public class CountrySelectActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry)); actionBar.setTitle(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
@ -108,7 +107,7 @@ public class CountrySelectActivity extends BaseFragment {
searchWas = true; searchWas = true;
if (listView != null) { if (listView != null) {
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
if(android.os.Build.VERSION.SDK_INT >= 11) { if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false); listView.setFastScrollAlwaysVisible(false);
} }
listView.setFastScrollEnabled(false); listView.setFastScrollEnabled(false);
@ -125,12 +124,12 @@ public class CountrySelectActivity extends BaseFragment {
searching = false; searching = false;
searchWas = false; searchWas = false;
listViewAdapter = new CountryAdapter(getParentActivity()); listViewAdapter = new CountryAdapter(context);
searchListViewAdapter = new CountrySearchAdapter(getParentActivity(), listViewAdapter.getCountries()); searchListViewAdapter = new CountrySearchAdapter(context, listViewAdapter.getCountries());
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(context);
emptyTextLayout.setVisibility(View.INVISIBLE); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout); ((FrameLayout) fragmentView).addView(emptyTextLayout);
@ -146,7 +145,7 @@ public class CountrySelectActivity extends BaseFragment {
} }
}); });
emptyTextView = new TextView(getParentActivity()); emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080); emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -158,7 +157,7 @@ public class CountrySelectActivity extends BaseFragment {
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1); emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
emptyTextLayout.addView(frameLayout); emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -166,7 +165,7 @@ public class CountrySelectActivity extends BaseFragment {
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1); frameLayout.setLayoutParams(layoutParams1);
listView = new LetterSectionsListView(getParentActivity()); listView = new LetterSectionsListView(context);
listView.setEmptyView(emptyTextLayout); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
@ -223,12 +222,7 @@ public class CountrySelectActivity extends BaseFragment {
} }
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -29,16 +29,16 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; 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.AnimatorSetProxy;
import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy; import org.telegram.ui.AnimationCompat.ObjectAnimatorProxy;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Cells.SharedDocumentCell; import org.telegram.ui.Cells.SharedDocumentCell;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -128,7 +128,7 @@ public class DocumentSelectActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (!receiverRegistered) { if (!receiverRegistered) {
receiverRegistered = true; receiverRegistered = true;
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
@ -145,7 +145,6 @@ public class DocumentSelectActivity extends BaseFragment {
getParentActivity().registerReceiver(receiver, filter); getParentActivity().registerReceiver(receiver, filter);
} }
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile)); actionBar.setTitle(LocaleController.getString("SelectFile", R.string.SelectFile));
@ -189,7 +188,7 @@ public class DocumentSelectActivity extends BaseFragment {
} }
}); });
actionMode.addView(selectedMessagesCountTextView); actionMode.addView(selectedMessagesCountTextView);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
layoutParams.weight = 1; layoutParams.weight = 1;
layoutParams.width = 0; layoutParams.width = 0;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; 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))); 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); fragmentView = inflater.inflate(R.layout.document_select_layout, null, false);
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(context);
emptyView = (TextView)fragmentView.findViewById(R.id.searchEmptyView); emptyView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
emptyView.setOnTouchListener(new View.OnTouchListener() { emptyView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
return true; return true;
} }
}); });
listView = (ListView)fragmentView.findViewById(R.id.listView); listView = (ListView) fragmentView.findViewById(R.id.listView);
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
listView.setAdapter(listAdapter); listView.setAdapter(listAdapter);
@ -350,12 +349,7 @@ public class DocumentSelectActivity extends BaseFragment {
}); });
listRoots(); listRoots();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -9,6 +9,7 @@
package org.telegram.ui; package org.telegram.ui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
@ -29,7 +30,6 @@ import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -39,21 +39,21 @@ import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.LocaleController; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.android.LocaleController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.Adapters.ContactsAdapter; import org.telegram.messenger.TLRPC;
import org.telegram.ui.Adapters.SearchAdapter;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.BaseFragment; 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.Cells.UserCell;
import org.telegram.ui.Components.LetterSectionsListView; import org.telegram.ui.Components.LetterSectionsListView;
@ -142,8 +142,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
searching = false; searching = false;
searchWas = false; searchWas = false;
@ -186,17 +185,17 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
searchListViewAdapter = new SearchAdapter(getParentActivity(), null, false); searchListViewAdapter = new SearchAdapter(context, null, false);
searchListViewAdapter.setCheckedMap(selectedContacts); searchListViewAdapter.setCheckedMap(selectedContacts);
searchListViewAdapter.setUseUserCell(true); searchListViewAdapter.setUseUserCell(true);
listViewAdapter = new ContactsAdapter(getParentActivity(), true, false, null); listViewAdapter = new ContactsAdapter(context, true, false, null);
listViewAdapter.setCheckedMap(selectedContacts); listViewAdapter.setCheckedMap(selectedContacts);
fragmentView = new LinearLayout(getParentActivity()); fragmentView = new LinearLayout(context);
LinearLayout linearLayout = (LinearLayout) fragmentView; LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setOrientation(LinearLayout.VERTICAL);
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
linearLayout.addView(frameLayout); linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -204,7 +203,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.gravity = Gravity.TOP; layoutParams.gravity = Gravity.TOP;
frameLayout.setLayoutParams(layoutParams); frameLayout.setLayoutParams(layoutParams);
userSelectEditText = new EditText(getParentActivity()); userSelectEditText = new EditText(context);
userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); userSelectEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
userSelectEditText.setHintTextColor(0xff979797); userSelectEditText.setHintTextColor(0xff979797);
userSelectEditText.setTextColor(0xff212121); userSelectEditText.setTextColor(0xff212121);
@ -295,7 +294,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
if (listView != null) { if (listView != null) {
listView.setAdapter(searchListViewAdapter); listView.setAdapter(searchListViewAdapter);
searchListViewAdapter.notifyDataSetChanged(); searchListViewAdapter.notifyDataSetChanged();
if(android.os.Build.VERSION.SDK_INT >= 11) { if (android.os.Build.VERSION.SDK_INT >= 11) {
listView.setFastScrollAlwaysVisible(false); listView.setFastScrollAlwaysVisible(false);
} }
listView.setFastScrollEnabled(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.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
linearLayout.addView(emptyTextLayout); 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.setTextColor(0xff808080);
emptyTextView.setTextSize(20); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -350,7 +349,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.weight = 0.5f; layoutParams.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams); emptyTextView.setLayoutParams(layoutParams);
FrameLayout frameLayout2 = new FrameLayout(getParentActivity()); FrameLayout frameLayout2 = new FrameLayout(context);
emptyTextLayout.addView(frameLayout2); emptyTextLayout.addView(frameLayout2);
layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams) frameLayout2.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -358,7 +357,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen
layoutParams.weight = 0.5f; layoutParams.weight = 0.5f;
frameLayout2.setLayoutParams(layoutParams); frameLayout2.setLayoutParams(layoutParams);
listView = new LetterSectionsListView(getParentActivity()); listView = new LetterSectionsListView(context);
listView.setEmptyView(emptyTextLayout); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); 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; return fragmentView;
} }

View File

@ -29,23 +29,23 @@ import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.android.LocaleController; 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.MessagesController;
import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; 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.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.GreySectionCell; import org.telegram.ui.Cells.GreySectionCell;
import org.telegram.ui.Cells.UserCell; 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.AvatarDrawable;
import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.AvatarUpdater;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.FrameLayoutFixed; import org.telegram.ui.Components.FrameLayoutFixed;
import java.util.ArrayList; import java.util.ArrayList;
@ -138,8 +138,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
if (isBroadcast) { if (isBroadcast) {
@ -163,7 +162,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
donePressed = true; donePressed = true;
if (isBroadcast) { if (isBroadcast) {
MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, uploadedAvatar, isBroadcast); MessagesController.getInstance().createChat(nameTextView.getText().toString(), selectedContacts, isBroadcast);
} else { } else {
if (avatarUpdater.uploadingAvatar != null) { if (avatarUpdater.uploadingAvatar != null) {
createAfterUpload = true; createAfterUpload = true;
@ -173,7 +172,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCanceledOnTouchOutside(false);
progressDialog.setCancelable(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() { progressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
@Override @Override
@ -197,11 +196,11 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = new LinearLayout(getParentActivity()); fragmentView = new LinearLayout(context);
LinearLayout linearLayout = (LinearLayout) fragmentView; LinearLayout linearLayout = (LinearLayout) fragmentView;
linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setOrientation(LinearLayout.VERTICAL);
FrameLayout frameLayout = new FrameLayoutFixed(getParentActivity()); FrameLayout frameLayout = new FrameLayoutFixed(context);
linearLayout.addView(frameLayout); linearLayout.addView(frameLayout);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -209,8 +208,8 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
frameLayout.setLayoutParams(layoutParams); frameLayout.setLayoutParams(layoutParams);
avatarImage = new BackupImageView(getParentActivity()); avatarImage = new BackupImageView(context);
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(32)); avatarImage.setRoundRadius(AndroidUtilities.dp(32));
avatarDrawable.setInfo(5, null, null, isBroadcast); avatarDrawable.setInfo(5, null, null, isBroadcast);
avatarImage.setImageDrawable(avatarDrawable); avatarImage.setImageDrawable(avatarDrawable);
frameLayout.addView(avatarImage); frameLayout.addView(avatarImage);
@ -260,7 +259,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}); });
} }
nameTextView = new EditText(getParentActivity()); nameTextView = new EditText(context);
nameTextView.setHint(isBroadcast ? LocaleController.getString("EnterListName", R.string.EnterListName) : LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder)); nameTextView.setHint(isBroadcast ? LocaleController.getString("EnterListName", R.string.EnterListName) : LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder));
if (nameToSet != null) { if (nameToSet != null) {
nameTextView.setText(nameToSet); nameTextView.setText(nameToSet);
@ -303,26 +302,21 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
}); });
} }
GreySectionCell sectionCell = new GreySectionCell(getParentActivity()); GreySectionCell sectionCell = new GreySectionCell(context);
sectionCell.setText(LocaleController.formatPluralString("Members", selectedContacts.size())); sectionCell.setText(LocaleController.formatPluralString("Members", selectedContacts.size()));
linearLayout.addView(sectionCell); linearLayout.addView(sectionCell);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listAdapter = new ListAdapter(context));
linearLayout.addView(listView); linearLayout.addView(listView);
layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams(); layoutParams = (LinearLayout.LayoutParams) listView.getLayoutParams();
layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams.height = LinearLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -336,7 +330,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati
avatarImage.setImage(avatar, "50_50", avatarDrawable); avatarImage.setImage(avatar, "50_50", avatarDrawable);
if (createAfterUpload) { if (createAfterUpload) {
FileLog.e("tmessages", "avatar did uploaded"); 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); FileLog.e("tmessages", e);
} }
} }
int chat_id = (Integer)args[0];
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
Bundle args2 = new Bundle(); Bundle args2 = new Bundle();
args2.putInt("chat_id", (Integer)args[0]); args2.putInt("chat_id", chat_id);
presentFragment(new ChatActivity(args2), true); presentFragment(new ChatActivity(args2), true);
if (uploadedAvatar != null) {
MessagesController.getInstance().changeChatAvatar(chat_id, uploadedAvatar);
}
} }
}); });
} }

View File

@ -10,23 +10,22 @@ package org.telegram.ui;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.Surface; import android.view.Surface;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.IdenticonDrawable;
@ -45,8 +44,7 @@ public class IdenticonActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
@ -62,14 +60,14 @@ public class IdenticonActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.identicon_layout, null, false); fragmentView = inflater.inflate(R.layout.identicon_layout, null, false);
ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view); ImageView identiconView = (ImageView) fragmentView.findViewById(R.id.identicon_view);
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text); TextView textView = (TextView) fragmentView.findViewById(R.id.identicon_text);
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
if (encryptedChat != null) { if (encryptedChat != null) {
IdenticonDrawable drawable = new IdenticonDrawable(); IdenticonDrawable drawable = new IdenticonDrawable();
identiconView.setImageDrawable(drawable); identiconView.setImageDrawable(drawable);
drawable.setEncryptedChat(encryptedChat); drawable.setEncryptedChat(encryptedChat);
TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); 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))); textView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
} }
fragmentView.setOnTouchListener(new View.OnTouchListener() { fragmentView.setOnTouchListener(new View.OnTouchListener() {
@ -78,12 +76,7 @@ public class IdenticonActivity extends BaseFragment {
return true; return true;
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -19,7 +19,6 @@ import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.support.v4.view.PagerAdapter; import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.text.Html;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window; import android.view.Window;
@ -255,7 +254,7 @@ public class IntroActivity extends Activity {
container.addView(view, 0); container.addView(view, 0);
headerTextView.setText(getString(titles[position])); headerTextView.setText(getString(titles[position]));
messageTextView.setText(Html.fromHtml(getString(messages[position]))); messageTextView.setText(AndroidUtilities.replaceTags(getString(messages[position])));
return view; return view;
} }

View File

@ -25,16 +25,16 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment; 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.ArrayList;
import java.util.Timer; import java.util.Timer;
@ -52,8 +52,7 @@ public class LanguageSelectActivity extends BaseFragment {
public ArrayList<LocaleController.LocaleInfo> searchResult; public ArrayList<LocaleController.LocaleInfo> searchResult;
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
searching = false; searching = false;
searchWas = false; searchWas = false;
@ -104,12 +103,12 @@ public class LanguageSelectActivity extends BaseFragment {
}); });
item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(context);
searchListViewAdapter = new SearchAdapter(getParentActivity()); searchListViewAdapter = new SearchAdapter(context);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
LinearLayout emptyTextLayout = new LinearLayout(getParentActivity()); LinearLayout emptyTextLayout = new LinearLayout(context);
emptyTextLayout.setVisibility(View.INVISIBLE); emptyTextLayout.setVisibility(View.INVISIBLE);
emptyTextLayout.setOrientation(LinearLayout.VERTICAL); emptyTextLayout.setOrientation(LinearLayout.VERTICAL);
((FrameLayout) fragmentView).addView(emptyTextLayout); ((FrameLayout) fragmentView).addView(emptyTextLayout);
@ -125,7 +124,7 @@ public class LanguageSelectActivity extends BaseFragment {
} }
}); });
emptyTextView = new TextView(getParentActivity()); emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080); emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -137,7 +136,7 @@ public class LanguageSelectActivity extends BaseFragment {
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
emptyTextView.setLayoutParams(layoutParams1); emptyTextView.setLayoutParams(layoutParams1);
FrameLayout frameLayout = new FrameLayout(getParentActivity()); FrameLayout frameLayout = new FrameLayout(context);
emptyTextLayout.addView(frameLayout); emptyTextLayout.addView(frameLayout);
layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams(); layoutParams1 = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams1.width = LinearLayout.LayoutParams.MATCH_PARENT;
@ -145,7 +144,7 @@ public class LanguageSelectActivity extends BaseFragment {
layoutParams1.weight = 0.5f; layoutParams1.weight = 0.5f;
frameLayout.setLayoutParams(layoutParams1); frameLayout.setLayoutParams(layoutParams1);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setEmptyView(emptyTextLayout); listView.setEmptyView(emptyTextLayout);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
@ -232,12 +231,7 @@ public class LanguageSelectActivity extends BaseFragment {
public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) { public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -99,8 +99,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen)); actionBar.setTitle(LocaleController.getString("PrivacyLastSeen", R.string.PrivacyLastSeen));
@ -142,13 +141,13 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
doneButton.setVisibility(View.GONE); doneButton.setVisibility(View.GONE);
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xfff0f0f0); frameLayout.setBackgroundColor(0xfff0f0f0);
ListView listView = new ListView(getParentActivity()); ListView listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -237,12 +236,7 @@ public class LastSeenActivity extends BaseFragment implements NotificationCenter
} }
} }
}); });
} else {
ViewGroup parent = (ViewGroup) fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -75,8 +75,7 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
if (isAlwaysShare) { if (isAlwaysShare) {
@ -116,10 +115,10 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItem(block_user, R.drawable.plus); menu.addItem(block_user, R.drawable.plus);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
TextView emptyTextView = new TextView(getParentActivity()); TextView emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff808080); emptyTextView.setTextColor(0xff808080);
emptyTextView.setTextSize(20); emptyTextView.setTextSize(20);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
@ -138,12 +137,12 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
} }
}); });
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setEmptyView(emptyTextView); listView.setEmptyView(emptyTextView);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setAdapter(listViewAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listViewAdapter = new ListAdapter(context));
if (Build.VERSION.SDK_INT >= 11) { if (Build.VERSION.SDK_INT >= 11) {
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT); listView.setVerticalScrollbarPosition(LocaleController.isRTL ? ListView.SCROLLBAR_POSITION_LEFT : ListView.SCROLLBAR_POSITION_RIGHT);
} }
@ -173,12 +172,12 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
selectedUserId = uidArray.get(i); selectedUserId = uidArray.get(i);
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[] {LocaleController.getString("Delete", R.string.Delete)}; CharSequence[] items = new CharSequence[]{LocaleController.getString("Delete", R.string.Delete)};
builder.setItems(items, new DialogInterface.OnClickListener() { builder.setItems(items, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) { if (i == 0) {
uidArray.remove((Integer)selectedUserId); uidArray.remove((Integer) selectedUserId);
listViewAdapter.notifyDataSetChanged(); listViewAdapter.notifyDataSetChanged();
if (delegate != null) { if (delegate != null) {
delegate.didUpdatedUserList(uidArray, false); delegate.didUpdatedUserList(uidArray, false);
@ -190,12 +189,7 @@ public class LastSeenUsersActivity extends BaseFragment implements NotificationC
return true; return true;
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -22,7 +22,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcelable; import android.os.Parcelable;
import android.provider.ContactsContract; import android.provider.ContactsContract;
import android.util.Log;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -39,27 +38,26 @@ import android.widget.ListView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast; import android.widget.Toast;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; 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.MessagesController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter;
import org.telegram.android.SendMessagesHelper; import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest; import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject; import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
import org.telegram.ui.ActionBar.ActionBarLayout; import org.telegram.ui.ActionBar.ActionBarLayout;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.ActionBar.DrawerLayoutContainer;
import org.telegram.ui.Adapters.DrawerLayoutAdapter;
import org.telegram.ui.Components.PasscodeView; import org.telegram.ui.Components.PasscodeView;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -110,7 +108,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
ApplicationLoader.postInitApplication(); ApplicationLoader.postInitApplication();
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) { if (!UserConfig.isClientActivated()) {
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -211,7 +209,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
int viewX = location[0]; int viewX = location[0];
int viewY = location[1]; 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; return false;
} else { } else {
if (!layersActionBarLayout.fragmentsStack.isEmpty()) { 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.mainUserInfoChanged);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().addObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didUpdatedConnectionState);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.needPasswordEnter);
if (Build.VERSION.SDK_INT < 14) { if (Build.VERSION.SDK_INT < 14) {
NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged); NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenStateChanged);
} else { } else {
@ -370,18 +367,13 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) { if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity()); actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false); drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else {
if (UserConfig.isWaitingForPasswordEnter()) {
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else { } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true, false); drawerLayoutContainer.setAllowOpenDrawer(true, false);
} }
}
try { try {
if (savedInstanceState != null) { if (savedInstanceState != null) {
@ -438,7 +430,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else { } else {
allowOpen = actionBarLayout.fragmentsStack.size() <= 1; 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; allowOpen = false;
} }
drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false); drawerLayoutContainer.setAllowOpenDrawer(allowOpen, false);
@ -503,7 +495,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
documentsUrisArray = null; documentsUrisArray = null;
contactsToSend = 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 != null && intent.getAction() != null && !restore) {
if (Intent.ACTION_SEND.equals(intent.getAction())) { if (Intent.ACTION_SEND.equals(intent.getAction())) {
boolean error = false; boolean error = false;
@ -891,38 +883,28 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
if (!pushOpened && !isNew) { if (!pushOpened && !isNew) {
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) { if (!UserConfig.isClientActivated()) {
if (layersActionBarLayout.fragmentsStack.isEmpty()) { if (layersActionBarLayout.fragmentsStack.isEmpty()) {
layersActionBarLayout.addFragmentToStack(new LoginActivity()); layersActionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false); drawerLayoutContainer.setAllowOpenDrawer(false, false);
} }
} else { } else {
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
if (UserConfig.isWaitingForPasswordEnter()) {
layersActionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true, false); drawerLayoutContainer.setAllowOpenDrawer(true, false);
} }
} }
}
} else { } else {
if (actionBarLayout.fragmentsStack.isEmpty()) { if (actionBarLayout.fragmentsStack.isEmpty()) {
if (!UserConfig.isClientActivated() && !UserConfig.isWaitingForPasswordEnter()) { if (!UserConfig.isClientActivated()) {
actionBarLayout.addFragmentToStack(new LoginActivity()); actionBarLayout.addFragmentToStack(new LoginActivity());
drawerLayoutContainer.setAllowOpenDrawer(false, false); drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else {
if (UserConfig.isWaitingForPasswordEnter()) {
actionBarLayout.addFragmentToStack(new AccountPasswordActivity(1));
drawerLayoutContainer.setAllowOpenDrawer(false, false);
} else { } else {
actionBarLayout.addFragmentToStack(new MessagesActivity(null)); actionBarLayout.addFragmentToStack(new MessagesActivity(null));
drawerLayoutContainer.setAllowOpenDrawer(true, false); drawerLayoutContainer.setAllowOpenDrawer(true, false);
} }
} }
} }
}
actionBarLayout.showLastFragment(); actionBarLayout.showLastFragment();
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
layersActionBarLayout.showLastFragment(); layersActionBarLayout.showLastFragment();
@ -1028,7 +1010,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mainUserInfoChanged);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeOtherAppActivities);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didUpdatedConnectionState);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.needPasswordEnter);
if (Build.VERSION.SDK_INT < 14) { if (Build.VERSION.SDK_INT < 14) {
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenStateChanged); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenStateChanged);
} else { } else {
@ -1245,28 +1226,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
} else if (id == NotificationCenter.mainUserInfoChanged) { } else if (id == NotificationCenter.mainUserInfoChanged) {
drawerLayoutAdapter.notifyDataSetChanged(); 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) { } else if (id == NotificationCenter.screenStateChanged) {
if (!ApplicationLoader.mainInterfacePaused) { if (!ApplicationLoader.mainInterfacePaused) {
if (!ApplicationLoader.isScreenOn) { if (!ApplicationLoader.isScreenOn) {
@ -1479,7 +1438,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override @Override
public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) { public boolean needPresentFragment(BaseFragment fragment, boolean removeLast, boolean forceWithoutAnimation, ActionBarLayout layout) {
if (AndroidUtilities.isTablet()) { 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) { if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment; MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) { if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
@ -1548,7 +1507,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (layout != layersActionBarLayout) { } else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE); layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false, true); drawerLayoutContainer.setAllowOpenDrawer(false, true);
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) { if (fragment instanceof LoginActivity) {
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE); shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000); shadowTablet.setBackgroundColor(0x00000000);
@ -1560,7 +1519,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
return true; return true;
} else { } else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false); drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false);
return true; return true;
} }
} }
@ -1568,7 +1527,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
@Override @Override
public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) { public boolean needAddFragmentToStack(BaseFragment fragment, ActionBarLayout layout) {
if (AndroidUtilities.isTablet()) { 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) { if (fragment instanceof MessagesActivity) {
MessagesActivity messagesActivity = (MessagesActivity)fragment; MessagesActivity messagesActivity = (MessagesActivity)fragment;
if (messagesActivity.isMainDialogList() && layout != actionBarLayout) { if (messagesActivity.isMainDialogList() && layout != actionBarLayout) {
@ -1613,7 +1572,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} else if (layout != layersActionBarLayout) { } else if (layout != layersActionBarLayout) {
layersActionBarLayout.setVisibility(View.VISIBLE); layersActionBarLayout.setVisibility(View.VISIBLE);
drawerLayoutContainer.setAllowOpenDrawer(false, true); drawerLayoutContainer.setAllowOpenDrawer(false, true);
if (fragment instanceof LoginActivity || fragment instanceof AccountPasswordActivity) { if (fragment instanceof LoginActivity) {
backgroundTablet.setVisibility(View.VISIBLE); backgroundTablet.setVisibility(View.VISIBLE);
shadowTabletSide.setVisibility(View.GONE); shadowTabletSide.setVisibility(View.GONE);
shadowTablet.setBackgroundColor(0x00000000); shadowTablet.setBackgroundColor(0x00000000);
@ -1625,7 +1584,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
} }
return true; return true;
} else { } else {
drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity) && !(fragment instanceof AccountPasswordActivity), false); drawerLayoutContainer.setAllowOpenDrawer(!(fragment instanceof LoginActivity), false);
return true; return true;
} }
} }

View File

@ -13,14 +13,12 @@ import android.location.Location;
import android.location.LocationManager; import android.location.LocationManager;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import com.google.android.gms.maps.CameraUpdate; import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer; import com.google.android.gms.maps.MapsInitializer;
import com.google.android.gms.maps.model.BitmapDescriptorFactory; import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng; 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.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.TLRPC;
import org.telegram.android.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import java.util.List; import java.util.List;
public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class LocationActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
private GoogleMap googleMap; private GoogleMap googleMap;
private TextView distanceTextView; private TextView distanceTextView;
private Marker userMarker; private Marker userMarker;
@ -88,14 +87,10 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (mapView != null) { if (mapView != null) {
mapView.onDestroy(); mapView.onDestroy();
} }
if (avatarImageView != null) {
avatarImageView.setImageDrawable(null);
}
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
if (messageObject != null) { if (messageObject != null) {
@ -147,13 +142,12 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
fragmentView = inflater.inflate(R.layout.location_attach_layout, null, false); fragmentView = inflater.inflate(R.layout.location_attach_layout, null, false);
} }
avatarImageView = (BackupImageView)fragmentView.findViewById(R.id.location_avatar_view); avatarImageView = (BackupImageView) fragmentView.findViewById(R.id.location_avatar_view);
if (avatarImageView != null) { if (avatarImageView != null) {
avatarImageView.processDetach = false; avatarImageView.setRoundRadius(AndroidUtilities.dp(32));
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(32));
} }
nameTextView = (TextView)fragmentView.findViewById(R.id.location_name_label); nameTextView = (TextView) fragmentView.findViewById(R.id.location_name_label);
distanceTextView = (TextView)fragmentView.findViewById(R.id.location_distance_label); distanceTextView = (TextView) fragmentView.findViewById(R.id.location_distance_label);
View bottomView = fragmentView.findViewById(R.id.location_bottom_view); View bottomView = fragmentView.findViewById(R.id.location_bottom_view);
TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button); TextView sendButton = (TextView) fragmentView.findViewById(R.id.location_send_button);
if (sendButton != null) { if (sendButton != null) {
@ -161,10 +155,10 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
sendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); sendButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
} }
mapView = (MapView)fragmentView.findViewById(R.id.map_view); mapView = (MapView) fragmentView.findViewById(R.id.map_view);
mapView.onCreate(null); mapView.onCreate(null);
try { try {
MapsInitializer.initialize(getParentActivity()); MapsInitializer.initialize(context);
googleMap = mapView.getMap(); googleMap = mapView.getMap();
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
@ -233,7 +227,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
} }
if (messageObject != null) { if (messageObject != null) {
updateUserData();
userLocation = new Location("network"); userLocation = new Location("network");
userLocation.setLatitude(messageObject.messageOwner.media.geo.lat); userLocation.setLatitude(messageObject.messageOwner.media.geo.lat);
userLocation.setLongitude(messageObject.messageOwner.media.geo._long); userLocation.setLongitude(messageObject.messageOwner.media.geo._long);
@ -246,12 +239,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
positionMarker(myLocation); positionMarker(myLocation);
} }
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -297,7 +285,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (userLocation != null && distanceTextView != null) { if (userLocation != null && distanceTextView != null) {
float distance = location.distanceTo(userLocation); float distance = location.distanceTo(userLocation);
if (distance < 1000) { 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 { } else {
distanceTextView.setText(String.format("%.2f %s", distance / 1000.0f, LocaleController.getString("KMetersAway", R.string.KMetersAway))); 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 @Override
public void didReceivedNotification(int id, Object... args) { public void didReceivedNotification(int id, Object... args) {
if (id == NotificationCenter.updateInterfaces) { 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) { if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
updateUserData(); updateUserData();
} }
@ -353,6 +341,7 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
if (mapView != null) { if (mapView != null) {
mapView.onResume(); mapView.onResume();
} }
updateUserData();
} }
@Override @Override

View File

@ -40,23 +40,24 @@ import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.android.query.SharedMediaQuery; import org.telegram.android.query.SharedMediaQuery;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest; import org.telegram.messenger.RPCRequest;
import org.telegram.messenger.TLObject; import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; 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.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.ActionBarPopupWindow; 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.BaseFragmentAdapter;
import org.telegram.ui.Adapters.BaseSectionsAdapter; import org.telegram.ui.Adapters.BaseSectionsAdapter;
import org.telegram.ui.AnimationCompat.AnimatorSetProxy; 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.SharedMediaSectionCell;
import org.telegram.ui.Cells.SharedPhotoVideoCell; import org.telegram.ui.Cells.SharedPhotoVideoCell;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.SectionsListView; import org.telegram.ui.Components.SectionsListView;
import java.io.File; import java.io.File;
@ -216,8 +216,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setTitle(""); actionBar.setTitle("");
actionBar.setAllowOverlayTitle(false); actionBar.setAllowOverlayTitle(false);
@ -288,7 +287,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() { fragment.setDelegate(new MessagesActivity.MessagesActivityDelegate() {
@Override @Override
public void didSelectDialog(MessagesActivity fragment, long did, boolean param) { public void didSelectDialog(MessagesActivity fragment, long did, boolean param) {
int lower_part = (int)did; int lower_part = (int) did;
if (lower_part != 0) { if (lower_part != 0) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putBoolean("scrollToTopOnResume", true); args.putBoolean("scrollToTopOnResume", true);
@ -312,7 +311,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
ChatActivity chatActivity = new ChatActivity(args); ChatActivity chatActivity = new ChatActivity(args);
presentFragment(chatActivity, true); presentFragment(chatActivity, true);
chatActivity.showReplyForMessageObjectOrForward(true, null, fmessages, false); chatActivity.showReplyPanel(true, null, fmessages, null, false, false);
if (!AndroidUtilities.isTablet()) { if (!AndroidUtilities.isTablet()) {
removeSelfFromStack(); removeSelfFromStack();
@ -372,7 +371,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
searchItem.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); searchItem.getSearchField().setHint(LocaleController.getString("Search", R.string.Search));
searchItem.setVisibility(View.GONE); searchItem.setVisibility(View.GONE);
dropDownContainer = new ActionBarMenuItem(getParentActivity(), menu, R.drawable.bar_selector); dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector);
dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.setSubMenuOpenSide(1);
dropDownContainer.addSubItem(shared_media_item, LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle), 0); dropDownContainer.addSubItem(shared_media_item, LocaleController.getString("SharedMediaTitle", R.string.SharedMediaTitle), 0);
dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0); dropDownContainer.addSubItem(files_item, LocaleController.getString("DocumentsTitle", R.string.DocumentsTitle), 0);
@ -391,7 +390,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
}); });
dropDown = new TextView(getParentActivity()); dropDown = new TextView(context);
dropDown.setGravity(Gravity.LEFT); dropDown.setGravity(Gravity.LEFT);
dropDown.setSingleLine(true); dropDown.setSingleLine(true);
dropDown.setLines(1); dropDown.setLines(1);
@ -429,7 +428,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
}); });
actionMode.addView(selectedMessagesCountTextView); actionMode.addView(selectedMessagesCountTextView);
LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams)selectedMessagesCountTextView.getLayoutParams(); LinearLayout.LayoutParams layoutParams1 = (LinearLayout.LayoutParams) selectedMessagesCountTextView.getLayoutParams();
layoutParams1.weight = 1; layoutParams1.weight = 1;
layoutParams1.width = 0; layoutParams1.width = 0;
layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT; layoutParams1.height = LinearLayout.LayoutParams.MATCH_PARENT;
@ -440,14 +439,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
actionModeViews.add(actionMode.addItem(delete, R.drawable.ic_ab_fwd_delete, 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()); photoVideoAdapter = new SharedPhotoVideoAdapter(context);
documentsAdapter = new SharedDocumentsAdapter(getParentActivity()); documentsAdapter = new SharedDocumentsAdapter(context);
documentsSearchAdapter = new DocumentsSearchAdapter(getParentActivity()); documentsSearchAdapter = new DocumentsSearchAdapter(context);
FrameLayout frameLayout; FrameLayout frameLayout;
fragmentView = frameLayout = new FrameLayout(getParentActivity()); fragmentView = frameLayout = new FrameLayout(context);
listView = new SectionsListView(getParentActivity()); listView = new SectionsListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setDrawSelectorOnTop(true); listView.setDrawSelectorOnTop(true);
@ -509,10 +508,10 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
}); });
for (int a = 0; a < 6; a++) { for (int a = 0; a < 6; a++) {
cellCache.add(new SharedPhotoVideoCell(getParentActivity())); cellCache.add(new SharedPhotoVideoCell(context));
} }
emptyView = new LinearLayout(getParentActivity()); emptyView = new LinearLayout(context);
emptyView.setOrientation(LinearLayout.VERTICAL); emptyView.setOrientation(LinearLayout.VERTICAL);
emptyView.setGravity(Gravity.CENTER); emptyView.setGravity(Gravity.CENTER);
emptyView.setVisibility(View.GONE); emptyView.setVisibility(View.GONE);
@ -529,14 +528,14 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
} }
}); });
emptyImageView = new ImageView(getParentActivity()); emptyImageView = new ImageView(context);
emptyView.addView(emptyImageView); emptyView.addView(emptyImageView);
layoutParams1 = (LinearLayout.LayoutParams) emptyImageView.getLayoutParams(); layoutParams1 = (LinearLayout.LayoutParams) emptyImageView.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams1.height = LinearLayout.LayoutParams.WRAP_CONTENT;
emptyImageView.setLayoutParams(layoutParams1); emptyImageView.setLayoutParams(layoutParams1);
emptyTextView = new TextView(getParentActivity()); emptyTextView = new TextView(context);
emptyTextView.setTextColor(0xff8a8a8a); emptyTextView.setTextColor(0xff8a8a8a);
emptyTextView.setGravity(Gravity.CENTER); emptyTextView.setGravity(Gravity.CENTER);
emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17); emptyTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
@ -549,7 +548,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
layoutParams1.gravity = Gravity.CENTER; layoutParams1.gravity = Gravity.CENTER;
emptyTextView.setLayoutParams(layoutParams1); emptyTextView.setLayoutParams(layoutParams1);
progressView = new LinearLayout(getParentActivity()); progressView = new LinearLayout(context);
progressView.setGravity(Gravity.CENTER); progressView.setGravity(Gravity.CENTER);
progressView.setOrientation(LinearLayout.VERTICAL); progressView.setOrientation(LinearLayout.VERTICAL);
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
@ -560,7 +559,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(getParentActivity()); ProgressBar progressBar = new ProgressBar(context);
progressView.addView(progressBar); progressView.addView(progressBar);
layoutParams1 = (LinearLayout.LayoutParams) progressBar.getLayoutParams(); layoutParams1 = (LinearLayout.LayoutParams) progressBar.getLayoutParams();
layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT; layoutParams1.width = LinearLayout.LayoutParams.WRAP_CONTENT;
@ -568,12 +567,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
progressBar.setLayoutParams(layoutParams1); progressBar.setLayoutParams(layoutParams1);
switchToCurrentSelectedMode(); switchToCurrentSelectedMode();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -742,7 +736,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
object.viewX = coords[0]; object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = listView; object.parentView = listView;
object.imageReceiver = imageView.imageReceiver; object.imageReceiver = imageView.getImageReceiver();
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
return object; return object;
} }

View File

@ -10,20 +10,16 @@ package org.telegram.ui;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.StateListAnimator; import android.animation.StateListAnimator;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Outline; import android.graphics.Outline;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -34,7 +30,6 @@ import android.view.ViewTreeObserver;
import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
@ -43,29 +38,29 @@ import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject; 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.MessagesController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; 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.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.MenuDrawable; 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; import java.util.ArrayList;
@ -165,15 +160,14 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
searching = false; searching = false;
searchWas = false; searchWas = false;
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
if (!onlySelect && searchString == null) { if (!onlySelect && searchString == null) {
Drawable lock = getParentActivity().getResources().getDrawable(R.drawable.lock_close); 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); passcodeItem = menu.addItem(passcode_menu_item, lock);
updatePasscodeButton(); updatePasscodeButton();
} }
@ -257,11 +251,11 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} }
}); });
item.getSearchField().setHint(LocaleController.getString("Search", R.string.Search)); 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) { if (onlySelect) {
//actionBar.setBackButtonImage(R.drawable.ic_ab_back); //actionBar.setBackButtonImage(R.drawable.ic_ab_back);
Drawable back = getParentActivity().getResources().getDrawable(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.setBackButtonDrawable(back);
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
} else { } else {
@ -294,7 +288,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
fragmentView = inflater.inflate(R.layout.messages_list, null, false); fragmentView = inflater.inflate(R.layout.messages_list, null, false);
if (searchString == null) { if (searchString == null) {
dialogsAdapter = new DialogsAdapter(getParentActivity(), serverOnly); dialogsAdapter = new DialogsAdapter(context, serverOnly);
if (AndroidUtilities.isTablet() && openedDialogId != 0) { if (AndroidUtilities.isTablet() && openedDialogId != 0) {
dialogsAdapter.setOpenedDialogId(openedDialogId); dialogsAdapter.setOpenedDialogId(openedDialogId);
} }
@ -305,7 +299,7 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} else if (!onlySelect) { } else if (!onlySelect) {
type = 1; type = 1;
} }
dialogsSearchAdapter = new DialogsSearchAdapter(getParentActivity(), type); dialogsSearchAdapter = new DialogsSearchAdapter(context, type);
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() { dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.MessagesActivitySearchAdapterDelegate() {
@Override @Override
public void searchStateChanged(boolean search) { 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) { if (dialogsAdapter != null) {
messagesListView.setAdapter(dialogsAdapter); 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.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); String help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp);
if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) { if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
help = help.replace("\n", " "); help = help.replace("\n", " ");
} }
textView.setText(help); 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)); textView.setText(LocaleController.getString("NoResult", R.string.NoResult));
floatingButton = (ImageView) fragmentView.findViewById(R.id.floating_button); floatingButton = (ImageView) fragmentView.findViewById(R.id.floating_button);
@ -358,8 +352,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
floatingButton.setScaleType(ImageView.ScaleType.CENTER); floatingButton.setScaleType(ImageView.ScaleType.CENTER);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator(); 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[]{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[]{}, ObjectAnimator.ofFloat(floatingButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButton.setStateListAnimator(animator); floatingButton.setStateListAnimator(animator);
floatingButton.setOutlineProvider(new ViewOutlineProvider() { floatingButton.setOutlineProvider(new ViewOutlineProvider() {
@Override @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.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(14) : 0;
layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(14); layoutParams.rightMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(14);
layoutParams.gravity = (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM; 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; dialog_id = ((TLRPC.User) obj).id;
if (dialogsSearchAdapter.isGlobalSearch(i)) { if (dialogsSearchAdapter.isGlobalSearch(i)) {
ArrayList<TLRPC.User> users = new ArrayList<>(); ArrayList<TLRPC.User> users = new ArrayList<>();
users.add((TLRPC.User)obj); users.add((TLRPC.User) obj);
MessagesController.getInstance().putUsers(users, false); MessagesController.getInstance().putUsers(users, false);
MessagesStorage.getInstance().putUsersAndChats(users, null, false, true); 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); dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
} }
} else if (obj instanceof TLRPC.EncryptedChat) { } 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) { } else if (obj instanceof MessageObject) {
MessageObject messageObject = (MessageObject)obj; MessageObject messageObject = (MessageObject) obj;
dialog_id = messageObject.getDialogId(); dialog_id = messageObject.getDialogId();
message_id = messageObject.getId(); message_id = messageObject.getId();
dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString()); dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString());
@ -443,8 +437,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
didSelectResult(dialog_id, true, false); didSelectResult(dialog_id, true, false);
} else { } else {
Bundle args = new Bundle(); Bundle args = new Bundle();
int lower_part = (int)dialog_id; int lower_part = (int) dialog_id;
int high_id = (int)(dialog_id >> 32); int high_id = (int) (dialog_id >> 32);
if (lower_part != 0) { if (lower_part != 0) {
if (high_id == 1) { if (high_id == 1) {
args.putInt("chat_id", lower_part); args.putInt("chat_id", lower_part);
@ -527,8 +521,8 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
int lower_id = (int)selectedDialog; int lower_id = (int) selectedDialog;
int high_id = (int)(selectedDialog >> 32); int high_id = (int) (selectedDialog >> 32);
final boolean isChat = lower_id < 0 && high_id != 1; final boolean isChat = lower_id < 0 && high_id != 1;
builder.setItems(new CharSequence[]{LocaleController.getString("ClearHistory", R.string.ClearHistory), 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() { builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, which == 0);
if (which != 0) { if (which != 0) {
if (isChat) { if (isChat) {
MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null); MessagesController.getInstance().deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), null);
} else {
MessagesController.getInstance().deleteDialog(selectedDialog, 0, false);
} }
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats, selectedDialog); 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) { if (searchString != null) {
actionBar.openSearchField(searchString); actionBar.openSearchField(searchString);
} }
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -642,24 +634,10 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
} }
private void updateTheme(){ private void updateTheme(){
updateActionBarTitle(); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
actionBar.setBackgroundColor(AndroidUtilities.getIntDef("chatsHeaderColor", AndroidUtilities.getIntColor("themeColor"))); int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
Drawable floatingDrawableWhite = fragmentView.getResources().getDrawable(R.drawable.floating_white); //UpdateupdateActionBarTitle
floatingDrawableWhite.setColorFilter(AndroidUtilities.getIntDef("chatsFloatingBGColor", AndroidUtilities.getIntColor("themeColor")), PorterDuff.Mode.MULTIPLY); int value = themePrefs.getInt("chatsHeaderTitle", 0);
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);
String title = LocaleController.getString("AppName", R.string.AppName); String title = LocaleController.getString("AppName", R.string.AppName);
TLRPC.User user = UserConfig.getCurrentUser(); TLRPC.User user = UserConfig.getCurrentUser();
if( value == 1){ if( value == 1){
@ -676,7 +654,21 @@ public class MessagesActivity extends BaseFragment implements NotificationCenter
title = ""; title = "";
} }
actionBar.setTitle(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 @Override

View File

@ -29,24 +29,24 @@ import android.widget.Toast;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.NotificationsController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.android.NotificationsController;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.RPCRequest; 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.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.HeaderCell; import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCheckCell; import org.telegram.ui.Cells.TextCheckCell;
import org.telegram.ui.Cells.TextColorCell; import org.telegram.ui.Cells.TextColorCell;
import org.telegram.ui.Cells.TextDetailSettingsCell; import org.telegram.ui.Cells.TextDetailSettingsCell;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.ColorPickerView; import org.telegram.ui.Components.ColorPickerView;
public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { public class NotificationsSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -156,8 +156,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
@ -170,10 +169,10 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} }
}); });
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -182,7 +181,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
listView.setAdapter(new ListAdapter(getParentActivity())); listView.setAdapter(new ListAdapter(context));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
@ -363,9 +362,9 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
return; return;
} }
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater li = (LayoutInflater) getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_color_dialog_layout, null, false); view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker); final ColorPickerView colorPickerView = (ColorPickerView) view.findViewById(R.id.color_picker);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (i == messageLedRow) { if (i == messageLedRow) {
@ -409,7 +408,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) { } else if (i == messagePopupNotificationRow || i == groupPopupNotificationRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification)); builder.setTitle(LocaleController.getString("PopupNotification", R.string.PopupNotification));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("NoPopup", R.string.NoPopup), LocaleController.getString("NoPopup", R.string.NoPopup),
LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn), LocaleController.getString("OnlyWhenScreenOn", R.string.OnlyWhenScreenOn),
LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff), LocaleController.getString("OnlyWhenScreenOff", R.string.OnlyWhenScreenOff),
@ -435,11 +434,12 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (i == messageVibrateRow || i == groupVibrateRow) { } else if (i == messageVibrateRow || i == groupVibrateRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate)); builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
LocaleController.getString("Default", R.string.Default), LocaleController.getString("Default", R.string.Default),
LocaleController.getString("Short", R.string.Short), LocaleController.getString("Short", R.string.Short),
LocaleController.getString("Long", R.string.Long) LocaleController.getString("Long", R.string.Long),
LocaleController.getString("OnlyIfSilent", R.string.OnlyIfSilent)
}, new DialogInterface.OnClickListener() { }, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -457,6 +457,8 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
editor.putInt(param, 1); editor.putInt(param, 1);
} else if (which == 3) { } else if (which == 3) {
editor.putInt(param, 3); editor.putInt(param, 3);
} else if (which == 4) {
editor.putInt(param, 4);
} }
editor.commit(); editor.commit();
if (listView != null) { if (listView != null) {
@ -469,7 +471,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (i == messagePriorityRow || i == groupPriorityRow) { } else if (i == messagePriorityRow || i == groupPriorityRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority)); builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault),
LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh),
LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax) LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax)
@ -492,7 +494,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (i == repeatRow) { } else if (i == repeatRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications)); builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled), LocaleController.getString("RepeatDisabled", R.string.RepeatDisabled),
LocaleController.formatPluralString("Minutes", 5), LocaleController.formatPluralString("Minutes", 5),
LocaleController.formatPluralString("Minutes", 10), LocaleController.formatPluralString("Minutes", 10),
@ -532,12 +534,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} }
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -574,7 +571,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone); Ringtone rng = RingtoneManager.getRingtone(getParentActivity(), ringtone);
if (rng != null) { if (rng != null) {
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
name = LocaleController.getString("Default", R.string.Default); name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
} else { } else {
name = rng.getTitle(getParentActivity()); name = rng.getTitle(getParentActivity());
} }
@ -721,9 +718,9 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
textCell.setMultilineDetail(false); textCell.setMultilineDetail(false);
String value = null; String value = null;
if (i == messageSoundRow) { 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) { } 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")) { if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", R.string.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); textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), true);
} else if (value == 3) { } else if (value == 3) {
textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true); 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) { } else if (i == repeatRow) {
textCell.setMultilineDetail(false); textCell.setMultilineDetail(false);

View File

@ -55,9 +55,6 @@ import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter; 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.TextCheckCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell; import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.Cells.TextSettingsCell; import org.telegram.ui.Cells.TextSettingsCell;
@ -111,8 +108,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
if (type != 3) { if (type != 3) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
} }
@ -138,17 +134,21 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} }
}); });
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
if (type != 0) { if (type != 0) {
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
titleTextView = new TextView(getParentActivity()); titleTextView = new TextView(context);
titleTextView.setTextColor(0xff757575); titleTextView.setTextColor(0xff757575);
if (type == 1) { if (type == 1) {
if (UserConfig.passcodeHash.length() != 0) {
titleTextView.setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode)); titleTextView.setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode));
} else {
titleTextView.setText(LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode));
}
} else { } else {
titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode)); titleTextView.setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode));
} }
@ -162,7 +162,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
layoutParams.topMargin = AndroidUtilities.dp(38); layoutParams.topMargin = AndroidUtilities.dp(38);
titleTextView.setLayoutParams(layoutParams); titleTextView.setLayoutParams(layoutParams);
passwordEditText = new EditText(getParentActivity()); passwordEditText = new EditText(context);
passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
passwordEditText.setTextColor(0xff000000); passwordEditText.setTextColor(0xff000000);
passwordEditText.setMaxLines(1); passwordEditText.setMaxLines(1);
@ -251,7 +251,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} }
if (type == 1) { if (type == 1) {
dropDownContainer = new ActionBarMenuItem(getParentActivity(), menu, R.drawable.bar_selector); dropDownContainer = new ActionBarMenuItem(context, menu, R.drawable.bar_selector);
dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.setSubMenuOpenSide(1);
dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0);
dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0);
@ -270,7 +270,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} }
}); });
dropDown = new TextView(getParentActivity()); dropDown = new TextView(context);
dropDown.setGravity(Gravity.LEFT); dropDown.setGravity(Gravity.LEFT);
dropDown.setSingleLine(true); dropDown.setSingleLine(true);
dropDown.setLines(1); dropDown.setLines(1);
@ -297,7 +297,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} else { } else {
actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode));
frameLayout.setBackgroundColor(0xfff0f0f0); frameLayout.setBackgroundColor(0xfff0f0f0);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -308,7 +308,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.gravity = Gravity.TOP; layoutParams.gravity = Gravity.TOP;
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listAdapter = new ListAdapter(context));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
@ -396,12 +396,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} }
}); });
} }
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -526,7 +521,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} catch (Exception e) { } catch (Exception e) {
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
shakeTextView(2, 0); AndroidUtilities.shakeTextView(titleTextView, 2, 0);
passwordEditText.setText(""); passwordEditText.setText("");
return; 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() { private void onPasscodeError() {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
@ -575,7 +553,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
if (v != null) { if (v != null) {
v.vibrate(200); v.vibrate(200);
} }
shakeTextView(2, 0); AndroidUtilities.shakeTextView(titleTextView, 2, 0);
} }
private void fixLayoutInternal() { private void fixLayoutInternal() {

View File

@ -95,8 +95,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackgroundColor(0xff333333); actionBar.setBackgroundColor(0xff333333);
actionBar.setItemsBackground(R.drawable.bar_selector_picker); actionBar.setItemsBackground(R.drawable.bar_selector_picker);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
@ -123,12 +122,12 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItem(1, R.drawable.ic_ab_other); menu.addItem(1, R.drawable.ic_ab_other);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xff000000); frameLayout.setBackgroundColor(0xff000000);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4)); listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), AndroidUtilities.dp(4));
listView.setClipToPadding(false); listView.setClipToPadding(false);
listView.setHorizontalScrollBarEnabled(false); listView.setHorizontalScrollBarEnabled(false);
@ -144,10 +143,10 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.bottomMargin = AndroidUtilities.dp(48); layoutParams.bottomMargin = AndroidUtilities.dp(48);
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listAdapter = new ListAdapter(context));
AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333); AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
emptyView = new TextView(getParentActivity()); emptyView = new TextView(context);
emptyView.setTextColor(0xff808080); emptyView.setTextColor(0xff808080);
emptyView.setTextSize(20); emptyView.setTextSize(20);
emptyView.setGravity(Gravity.CENTER); emptyView.setGravity(Gravity.CENTER);
@ -166,7 +165,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
} }
}); });
progressView = new FrameLayout(getParentActivity()); progressView = new FrameLayout(context);
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
frameLayout.addView(progressView); frameLayout.addView(progressView);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
@ -175,7 +174,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
layoutParams.bottomMargin = AndroidUtilities.dp(48); layoutParams.bottomMargin = AndroidUtilities.dp(48);
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(getParentActivity()); ProgressBar progressBar = new ProgressBar(context);
progressView.addView(progressBar); progressView.addView(progressBar);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
@ -183,7 +182,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
layoutParams.gravity = Gravity.CENTER; layoutParams.gravity = Gravity.CENTER;
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
photoPickerBottomLayout = new PhotoPickerBottomLayout(getParentActivity()); photoPickerBottomLayout = new PhotoPickerBottomLayout(context);
frameLayout.addView(photoPickerBottomLayout); frameLayout.addView(photoPickerBottomLayout);
layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
@ -212,12 +211,7 @@ public class PhotoAlbumPickerActivity extends BaseFragment implements Notificati
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
} }
photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -19,13 +19,12 @@ import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ImageLoader; import org.telegram.android.ImageLoader;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
@ -432,8 +431,7 @@ public class PhotoCropActivity extends BaseFragment {
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackgroundColor(0xff333333); actionBar.setBackgroundColor(0xff333333);
actionBar.setItemsBackground(R.drawable.bar_selector_picker); actionBar.setItemsBackground(R.drawable.bar_selector_picker);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
@ -461,15 +459,10 @@ public class PhotoCropActivity extends BaseFragment {
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
fragmentView = view = new PhotoCropView(getParentActivity()); fragmentView = view = new PhotoCropView(context);
((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false); ((PhotoCropView) fragmentView).freeform = getArguments().getBoolean("freeform", false);
fragmentView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); 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);
}
}
return fragmentView; return fragmentView;
} }

View File

@ -36,6 +36,7 @@ import org.json.JSONObject;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController; import org.telegram.android.MediaController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.android.volley.AuthFailureError; import org.telegram.android.volley.AuthFailureError;
@ -50,13 +51,12 @@ import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.MessageObject;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem; 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.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.Cells.PhotoPickerPhotoCell; import org.telegram.ui.Cells.PhotoPickerPhotoCell;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.Components.PhotoPickerBottomLayout; import org.telegram.ui.Components.PhotoPickerBottomLayout;
@ -142,8 +142,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackgroundColor(0xff333333); actionBar.setBackgroundColor(0xff333333);
actionBar.setItemsBackground(R.drawable.bar_selector_picker); actionBar.setItemsBackground(R.drawable.bar_selector_picker);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
@ -239,12 +238,12 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
} }
} }
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xff000000); frameLayout.setBackgroundColor(0xff000000);
listView = new GridView(getParentActivity()); listView = new GridView(context);
listView.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4)); listView.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4));
listView.setClipToPadding(false); listView.setClipToPadding(false);
listView.setDrawSelectorOnTop(true); listView.setDrawSelectorOnTop(true);
@ -261,7 +260,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
listView.setAdapter(listAdapter = new ListAdapter(getParentActivity())); listView.setAdapter(listAdapter = new ListAdapter(context));
AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333); AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
@ -311,7 +310,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
}); });
} }
emptyView = new TextView(getParentActivity()); emptyView = new TextView(context);
emptyView.setTextColor(0xff808080); emptyView.setTextColor(0xff808080);
emptyView.setTextSize(20); emptyView.setTextSize(20);
emptyView.setGravity(Gravity.CENTER); emptyView.setGravity(Gravity.CENTER);
@ -359,7 +358,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
} }
}); });
progressView = new FrameLayout(getParentActivity()); progressView = new FrameLayout(context);
progressView.setVisibility(View.GONE); progressView.setVisibility(View.GONE);
frameLayout.addView(progressView); frameLayout.addView(progressView);
layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
@ -368,7 +367,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48); layoutParams.bottomMargin = singlePhoto ? 0 : AndroidUtilities.dp(48);
progressView.setLayoutParams(layoutParams); progressView.setLayoutParams(layoutParams);
ProgressBar progressBar = new ProgressBar(getParentActivity()); ProgressBar progressBar = new ProgressBar(context);
progressView.addView(progressBar); progressView.addView(progressBar);
layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) progressBar.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT; layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
@ -379,7 +378,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
updateSearchInterface(); updateSearchInterface();
} }
photoPickerBottomLayout = new PhotoPickerBottomLayout(getParentActivity()); photoPickerBottomLayout = new PhotoPickerBottomLayout(context);
frameLayout.addView(photoPickerBottomLayout); frameLayout.addView(photoPickerBottomLayout);
layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) photoPickerBottomLayout.getLayoutParams();
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
@ -405,12 +404,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
listView.setEmptyView(emptyView); listView.setEmptyView(emptyView);
photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true); photoPickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -488,7 +482,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
object.viewX = coords[0]; object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = listView; object.parentView = listView;
object.imageReceiver = cell.photoImage.imageReceiver; object.imageReceiver = cell.photoImage.getImageReceiver();
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
cell.checkBox.setVisibility(View.GONE); cell.checkBox.setVisibility(View.GONE);
return object; return object;
@ -534,7 +528,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
public Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) { public Bitmap getThumbForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation, int index) {
PhotoPickerPhotoCell cell = getCellForIndex(index); PhotoPickerPhotoCell cell = getCellForIndex(index);
if (cell != null) { if (cell != null) {
return cell.photoImage.imageReceiver.getBitmap(); return cell.photoImage.getImageReceiver().getBitmap();
} }
return null; return null;
} }
@ -1057,7 +1051,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen
cell.checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false); cell.checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false);
showing = PhotoViewer.getInstance().isShowingImage(photoEntry.thumbUrl); showing = PhotoViewer.getInstance().isShowingImage(photoEntry.thumbUrl);
} }
imageView.imageReceiver.setVisible(!showing, false); imageView.getImageReceiver().setVisible(!showing, false);
cell.checkBox.setVisibility(singlePhoto || showing ? View.GONE : View.VISIBLE); cell.checkBox.setVisibility(singlePhoto || showing ? View.GONE : View.VISIBLE);
} else if (viewType == 1) { } else if (viewType == 1) {
if (view == null) { if (view == null) {

View File

@ -31,21 +31,21 @@ import android.widget.FrameLayout;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController; import org.telegram.android.MediaController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.android.NotificationCenter;
import org.telegram.android.NotificationsController; import org.telegram.android.NotificationsController;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.MessageObject;
import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.AvatarDrawable;
@ -207,7 +207,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
@Override @Override
public void onTextChanged(CharSequence text) { public void onTextChanged(CharSequence text, boolean big) {
} }
@ -265,8 +265,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
avatarContainer.setLayoutParams(layoutParams2); avatarContainer.setLayoutParams(layoutParams2);
avatarImageView = new BackupImageView(this); avatarImageView = new BackupImageView(this);
avatarImageView.imageReceiver.setRoundRadius(AndroidUtilities.dp(21)); avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
avatarImageView.processDetach = false;
avatarContainer.addView(avatarImageView); avatarContainer.addView(avatarImageView);
layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams(); layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
layoutParams2.width = AndroidUtilities.dp(42); layoutParams2.width = AndroidUtilities.dp(42);
@ -550,7 +549,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
TextView messageText = (TextView)view.findViewById(R.id.message_text); TextView messageText = (TextView)view.findViewById(R.id.message_text);
BackupImageView imageView = (BackupImageView) view.findViewById(R.id.message_image); BackupImageView imageView = (BackupImageView) view.findViewById(R.id.message_image);
imageView.imageReceiver.setAspectFit(true); imageView.setAspectFit(true);
if (messageObject.type == 1) { if (messageObject.type == 1) {
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
@ -987,6 +986,7 @@ public class PopupNotificationActivity extends Activity implements NotificationC
} }
ConnectionsManager.getInstance().setAppPaused(false, false); ConnectionsManager.getInstance().setAppPaused(false, false);
fixLayout(); fixLayout();
checkAndUpdateAvatar();
wakeLock.acquire(7000); wakeLock.acquire(7000);
} }

View File

@ -21,13 +21,10 @@ import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MediaController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter; import org.telegram.android.NotificationCenter;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
@ -56,10 +53,10 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
private int lastSeenRow; private int lastSeenRow;
private int lastSeenDetailRow; private int lastSeenDetailRow;
private int securitySectionRow; private int securitySectionRow;
private int terminateSessionsRow; private int sessionsRow;
private int passwordRow; private int passwordRow;
private int passcodeRow; private int passcodeRow;
private int terminateSessionsDetailRow; private int sessionsDetailRow;
private int deleteAccountSectionRow; private int deleteAccountSectionRow;
private int deleteAccountRow; private int deleteAccountRow;
private int deleteAccountDetailRow; private int deleteAccountDetailRow;
@ -80,12 +77,12 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
lastSeenDetailRow = rowCount++; lastSeenDetailRow = rowCount++;
securitySectionRow = rowCount++; securitySectionRow = rowCount++;
passcodeRow = rowCount++; passcodeRow = rowCount++;
terminateSessionsRow = rowCount++; passwordRow = rowCount++;
terminateSessionsDetailRow = rowCount++; sessionsRow = rowCount++;
sessionsDetailRow = rowCount++;
deleteAccountSectionRow = rowCount++; deleteAccountSectionRow = rowCount++;
deleteAccountRow = rowCount++; deleteAccountRow = rowCount++;
deleteAccountDetailRow = rowCount++; deleteAccountDetailRow = rowCount++;
passwordRow = -1;
NotificationCenter.getInstance().addObserver(this, NotificationCenter.privacyRulesUpdated); NotificationCenter.getInstance().addObserver(this, NotificationCenter.privacyRulesUpdated);
@ -99,8 +96,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings)); actionBar.setTitle(LocaleController.getString("PrivacySettings", R.string.PrivacySettings));
@ -113,13 +109,13 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} }
}); });
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
frameLayout.setBackgroundColor(0xfff0f0f0); frameLayout.setBackgroundColor(0xfff0f0f0);
ListView listView = new ListView(getParentActivity()); ListView listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -136,53 +132,15 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == blockedRow) { if (i == blockedRow) {
presentFragment(new BlockedUsersActivity()); presentFragment(new BlockedUsersActivity());
} else if (i == terminateSessionsRow) { } else if (i == sessionsRow) {
if (getParentActivity() == null) { presentFragment(new SessionsActivity());
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setMessage(LocaleController.getString("AreYouSureSessions", R.string.AreYouSureSessions));
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_auth_resetAuthorizations req = new TLRPC.TL_auth_resetAuthorizations();
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() {
if (getParentActivity() == null) {
return;
}
if (error == null && response instanceof TLRPC.TL_boolTrue) {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), Toast.LENGTH_SHORT);
toast.show();
} else {
Toast toast = Toast.makeText(getParentActivity(), LocaleController.getString("UnknownError", R.string.UnknownError), Toast.LENGTH_SHORT);
toast.show();
}
}
});
UserConfig.registeredForPush = false;
UserConfig.registeredForInternalPush = false;
UserConfig.saveConfig(false);
MessagesController.getInstance().registerForPush(UserConfig.pushString);
ConnectionsManager.getInstance().initPushConnection();
}
});
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (i == deleteAccountRow) { } else if (i == deleteAccountRow) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle)); builder.setTitle(LocaleController.getString("DeleteAccountTitle", R.string.DeleteAccountTitle));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.formatPluralString("Months", 1), LocaleController.formatPluralString("Months", 1),
LocaleController.formatPluralString("Months", 3), LocaleController.formatPluralString("Months", 3),
LocaleController.formatPluralString("Months", 6), LocaleController.formatPluralString("Months", 6),
@ -235,7 +193,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} else if (i == lastSeenRow) { } else if (i == lastSeenRow) {
presentFragment(new LastSeenActivity()); presentFragment(new LastSeenActivity());
} else if (i == passwordRow) { } else if (i == passwordRow) {
presentFragment(new AccountPasswordActivity(0)); presentFragment(new TwoStepVerificationActivity(0));
} else if (i == passcodeRow) { } else if (i == passcodeRow) {
if (UserConfig.passcodeHash.length() > 0) { if (UserConfig.passcodeHash.length() > 0) {
presentFragment(new PasscodeActivity(2)); presentFragment(new PasscodeActivity(2));
@ -255,12 +213,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} }
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -344,7 +297,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
@Override @Override
public boolean isEnabled(int i) { public boolean isEnabled(int i) {
return i == passcodeRow || i == passwordRow || i == blockedRow || i == terminateSessionsRow || i == lastSeenRow && !ContactsController.getInstance().getLoadingLastSeenInfo() || i == deleteAccountRow && !ContactsController.getInstance().getLoadingDeleteInfo() || return i == passcodeRow || i == passwordRow || i == blockedRow || i == sessionsRow || i == lastSeenRow && !ContactsController.getInstance().getLoadingLastSeenInfo() || i == deleteAccountRow && !ContactsController.getInstance().getLoadingDeleteInfo() ||
i == hideMobileNumberRow; i == hideMobileNumberRow;
} }
@ -379,10 +332,10 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
TextSettingsCell textCell = (TextSettingsCell) view; TextSettingsCell textCell = (TextSettingsCell) view;
if (i == blockedRow) { if (i == blockedRow) {
textCell.setText(LocaleController.getString("BlockedUsers", R.string.BlockedUsers), true); textCell.setText(LocaleController.getString("BlockedUsers", R.string.BlockedUsers), true);
} else if (i == terminateSessionsRow) { } else if (i == sessionsRow) {
textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false); textCell.setText(LocaleController.getString("SessionsTitle", R.string.SessionsTitle), false);
} else if (i == passwordRow) { } else if (i == passwordRow) {
textCell.setText(LocaleController.getString("Password", R.string.Password), true); textCell.setText(LocaleController.getString("TwoStepVerification", R.string.TwoStepVerification), true);
} else if (i == passcodeRow) { } else if (i == passcodeRow) {
textCell.setText(LocaleController.getString("Passcode", R.string.Passcode), true); textCell.setText(LocaleController.getString("Passcode", R.string.Passcode), true);
} else if (i == lastSeenRow) { } else if (i == lastSeenRow) {
@ -419,8 +372,8 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
} else if (i == lastSeenDetailRow) { } else if (i == lastSeenDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("LastSeenHelp", R.string.LastSeenHelp)); ((TextInfoPrivacyCell) view).setText(LocaleController.getString("LastSeenHelp", R.string.LastSeenHelp));
view.setBackgroundResource(R.drawable.greydivider); view.setBackgroundResource(R.drawable.greydivider);
} else if (i == terminateSessionsDetailRow) { } else if (i == sessionsDetailRow) {
((TextInfoPrivacyCell) view).setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp)); ((TextInfoPrivacyCell) view).setText(LocaleController.getString("SessionsInfo", R.string.SessionsInfo));
view.setBackgroundResource(R.drawable.greydivider); view.setBackgroundResource(R.drawable.greydivider);
} }
} else if (type == 2) { } else if (type == 2) {
@ -444,7 +397,7 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
if (i == hideMobileNumberRow) { if (i == hideMobileNumberRow) {
textCell.setTextAndCheck(LocaleController.getString("HideMobile", R.string.HideMobile), preferences.getBoolean("hideMobile", false), false); textCell.setTextAndCheck(LocaleController.getString("HideMobile", R.string.HideMobile), preferences.getBoolean("hideMobile", false), true);
} }
} }
return view; return view;
@ -452,11 +405,11 @@ public class PrivacySettingsActivity extends BaseFragment implements Notificatio
@Override @Override
public int getItemViewType(int i) { public int getItemViewType(int i) {
if (i == lastSeenRow || i == blockedRow || i == deleteAccountRow || i == terminateSessionsRow || i == passwordRow || i == passcodeRow) { if (i == lastSeenRow || i == blockedRow || i == deleteAccountRow || i == sessionsRow || i == passwordRow || i == passcodeRow) {
return 0; return 0;
} else if (i == deleteAccountDetailRow || i == lastSeenDetailRow || i == terminateSessionsDetailRow) { } else if (i == deleteAccountDetailRow || i == lastSeenDetailRow || i == sessionsDetailRow) {
return 1; return 1;
} else if (i == securitySectionRow || i == deleteAccountSectionRow || i == privacySectionRow ) { } else if (i == securitySectionRow || i == deleteAccountSectionRow || i == privacySectionRow) {
return 2; return 2;
} else if (i == hideMobileNumberRow) { } else if (i == hideMobileNumberRow) {
return 3; return 3;

View File

@ -14,6 +14,7 @@ import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Outline; import android.graphics.Outline;
@ -22,7 +23,6 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -38,24 +38,28 @@ import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.android.AndroidUtilities;
import org.telegram.PhoneFormat.PhoneFormat; import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.LocaleController; import org.telegram.android.LocaleController;
import org.telegram.android.MessageObject;
import org.telegram.android.MessagesController;
import org.telegram.android.MessagesStorage; import org.telegram.android.MessagesStorage;
import org.telegram.android.NotificationCenter;
import org.telegram.android.SecretChatHelper; import org.telegram.android.SecretChatHelper;
import org.telegram.android.SendMessagesHelper; import org.telegram.android.SendMessagesHelper;
import org.telegram.android.query.SharedMediaQuery; import org.telegram.android.query.SharedMediaQuery;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.ConnectionsManager; import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.android.MessageObject; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.ActionBarMenu;
import org.telegram.ui.ActionBar.ActionBarMenuItem;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Adapters.BaseFragmentAdapter; import org.telegram.ui.Adapters.BaseFragmentAdapter;
import org.telegram.ui.AnimationCompat.ViewProxy; import org.telegram.ui.AnimationCompat.ViewProxy;
import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.DividerCell;
@ -64,13 +68,9 @@ import org.telegram.ui.Cells.ShadowSectionCell;
import org.telegram.ui.Cells.TextCell; import org.telegram.ui.Cells.TextCell;
import org.telegram.ui.Cells.TextDetailCell; import org.telegram.ui.Cells.TextDetailCell;
import org.telegram.ui.Cells.UserCell; import org.telegram.ui.Cells.UserCell;
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.AvatarDrawable;
import org.telegram.ui.Components.AvatarUpdater; import org.telegram.ui.Components.AvatarUpdater;
import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.BackupImageView;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.Components.IdenticonDrawable; import org.telegram.ui.Components.IdenticonDrawable;
import java.util.ArrayList; import java.util.ArrayList;
@ -210,9 +210,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override @Override
public void onFragmentDestroy() { public void onFragmentDestroy() {
super.onFragmentDestroy(); super.onFragmentDestroy();
if (avatarImage != null) {
avatarImage.setImageDrawable(null);
}
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.mediaCountDidLoaded);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
@ -229,13 +226,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 ? 5 : chat_id)); actionBar.setBackgroundColor(AvatarDrawable.getProfileBackColorForId(user_id != 0 ? 5 : chat_id));
actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 ? 5 : chat_id)); actionBar.setItemsBackground(AvatarDrawable.getButtonColorForId(user_id != 0 ? 5 : chat_id));
//actionBar.setBackButtonImage(R.drawable.ic_ab_back); //actionBar.setBackButtonImage(R.drawable.ic_ab_back);
Drawable back = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
back.setColorFilter(AndroidUtilities.getIntDef("profileHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); Drawable back = context.getResources().getDrawable(R.drawable.ic_ab_back);
back.setColorFilter(themePrefs.getInt("profileHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
actionBar.setBackButtonDrawable(back); actionBar.setBackButtonDrawable(back);
actionBar.setExtraHeight(AndroidUtilities.dp(88), false); actionBar.setExtraHeight(AndroidUtilities.dp(88), false);
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
@ -349,14 +346,13 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
createActionBarMenu(); createActionBarMenu();
listAdapter = new ListAdapter(getParentActivity()); listAdapter = new ListAdapter(context);
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
avatarImage = new BackupImageView(getParentActivity()); avatarImage = new BackupImageView(context);
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(30)); avatarImage.setRoundRadius(AndroidUtilities.dp(30));
avatarImage.processDetach = false;
actionBar.addView(avatarImage); actionBar.addView(avatarImage);
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
@ -385,7 +381,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
}); });
nameTextView = new TextView(getParentActivity()); nameTextView = new TextView(context);
nameTextView.setTextColor(0xffffffff); nameTextView.setTextColor(0xffffffff);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
nameTextView.setLines(1); nameTextView.setLines(1);
@ -404,7 +400,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
nameTextView.setLayoutParams(layoutParams); nameTextView.setLayoutParams(layoutParams);
onlineTextView = new TextView(getParentActivity()); onlineTextView = new TextView(context);
//onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? 5 : chat_id)); //onlineTextView.setTextColor(AvatarDrawable.getProfileTextColorForId(user_id != 0 ? 5 : chat_id));
onlineTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor",-0x40)); onlineTextView.setTextColor(AndroidUtilities.getIntDarkerColor("themeColor",-0x40));
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
@ -423,7 +419,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM;
onlineTextView.setLayoutParams(layoutParams); onlineTextView.setLayoutParams(layoutParams);
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -452,7 +448,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
presentFragment(new MediaActivity(args)); presentFragment(new MediaActivity(args));
} else if (i == settingsKeyRow) { } else if (i == settingsKeyRow) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt("chat_id", (int)(dialog_id >> 32)); args.putInt("chat_id", (int) (dialog_id >> 32));
presentFragment(new IdenticonActivity(args)); presentFragment(new IdenticonActivity(args));
} else if (i == settingsTimerRow) { } else if (i == settingsTimerRow) {
if (getParentActivity() == null) { if (getParentActivity() == null) {
@ -487,7 +483,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setItems(new CharSequence[] {LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() { builder.setItems(new CharSequence[]{LocaleController.getString("Call", R.string.Call), LocaleController.getString("Copy", R.string.Copy)}, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(DialogInterface dialogInterface, int i) {
if (i == 0) { if (i == 0) {
@ -499,11 +495,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} else if (i == 1) { } else if (i == 1) {
if(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE); android.text.ClipboardManager clipboard = (android.text.ClipboardManager) ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
clipboard.setText("+" + user.phone); clipboard.setText("+" + user.phone);
} else { } 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", "+" + user.phone); android.content.ClipData clip = android.content.ClipData.newPlainText("label", "+" + user.phone);
clipboard.setPrimaryClip(clip); clipboard.setPrimaryClip(clip);
} }
@ -568,29 +564,29 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
frameLayout.addView(actionBar); frameLayout.addView(actionBar);
if (user_id != 0 || chat_id >= 0 && !currentChat.left) { if (user_id != 0 || chat_id >= 0 && !currentChat.left) {
writeButton = new ImageView(getParentActivity()); writeButton = new ImageView(context);
//writeButton.setBackgroundResource(R.drawable.floating_user_states); //writeButton.setBackgroundResource(R.drawable.floating_user_states);
Drawable profile = getParentActivity().getResources().getDrawable(R.drawable.floating3_profile); Drawable profile = context.getResources().getDrawable(R.drawable.floating3_profile);
profile.setColorFilter(AndroidUtilities.getIntDef("profileRowColor", 0xffffffff), PorterDuff.Mode.SRC_IN); profile.setColorFilter(themePrefs.getInt("profileRowColor", 0xffffffff), PorterDuff.Mode.SRC_IN);
writeButton.setBackgroundDrawable(profile); writeButton.setBackgroundDrawable(profile);
writeButton.setScaleType(ImageView.ScaleType.CENTER); writeButton.setScaleType(ImageView.ScaleType.CENTER);
if (user_id != 0) { if (user_id != 0) {
//writeButton.setImageResource(R.drawable.floating_message); //writeButton.setImageResource(R.drawable.floating_message);
Drawable message = getParentActivity().getResources().getDrawable(R.drawable.floating_message); Drawable message = context.getResources().getDrawable(R.drawable.floating_message);
message.setColorFilter(AndroidUtilities.getIntDef("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN); message.setColorFilter(themePrefs.getInt("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN);
writeButton.setImageDrawable(message); writeButton.setImageDrawable(message);
writeButton.setPadding(0, AndroidUtilities.dp(3), 0, 0); writeButton.setPadding(0, AndroidUtilities.dp(3), 0, 0);
} else if (chat_id != 0) { } else if (chat_id != 0) {
//writeButton.setImageResource(R.drawable.floating_camera); //writeButton.setImageResource(R.drawable.floating_camera);
Drawable camera = getParentActivity().getResources().getDrawable(R.drawable.floating_camera); Drawable camera = context.getResources().getDrawable(R.drawable.floating_camera);
camera.setColorFilter(AndroidUtilities.getIntDef("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN); camera.setColorFilter(themePrefs.getInt("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN);
writeButton.setImageDrawable(camera); writeButton.setImageDrawable(camera);
} }
frameLayout.addView(writeButton); frameLayout.addView(writeButton);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator(); StateListAnimator animator = new StateListAnimator();
animator.addState(new int[] {android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200)); animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[] {}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200)); animator.addState(new int[]{}, ObjectAnimator.ofFloat(writeButton, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
writeButton.setStateListAnimator(animator); writeButton.setStateListAnimator(animator);
writeButton.setOutlineProvider(new ViewOutlineProvider() { writeButton.setOutlineProvider(new ViewOutlineProvider() {
@Override @Override
@ -663,13 +659,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
}); });
updateProfileData();
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -748,7 +737,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
} }
avatarImage.imageReceiver.setRoundRadius(AndroidUtilities.dp(avatarSize / 2)); avatarImage.setRoundRadius(AndroidUtilities.dp(avatarSize / 2));
layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams(); layoutParams = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
layoutParams.width = AndroidUtilities.dp(avatarSize); layoutParams.width = AndroidUtilities.dp(avatarSize);
layoutParams.height = AndroidUtilities.dp(avatarSize); layoutParams.height = AndroidUtilities.dp(avatarSize);
@ -904,6 +893,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
if (listAdapter != null) { if (listAdapter != null) {
listAdapter.notifyDataSetChanged(); listAdapter.notifyDataSetChanged();
} }
updateProfileData();
fixLayout(); fixLayout();
} }
@ -939,11 +929,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
object.viewX = coords[0]; object.viewX = coords[0];
object.viewY = coords[1] - AndroidUtilities.statusBarHeight; object.viewY = coords[1] - AndroidUtilities.statusBarHeight;
object.parentView = avatarImage; object.parentView = avatarImage;
object.imageReceiver = avatarImage.imageReceiver; object.imageReceiver = avatarImage.getImageReceiver();
object.user_id = user_id; object.user_id = user_id;
object.thumb = object.imageReceiver.getBitmap(); object.thumb = object.imageReceiver.getBitmap();
object.size = -1; object.size = -1;
object.radius = avatarImage.imageReceiver.getRoundRadius(); object.radius = avatarImage.getImageReceiver().getRoundRadius();
return object; return object;
} }
return null; return null;
@ -959,7 +949,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override @Override
public void willHidePhotoViewer() { public void willHidePhotoViewer() {
avatarImage.imageReceiver.setVisible(true, true); avatarImage.getImageReceiver().setVisible(true, true);
} }
@Override @Override
@ -1059,7 +1049,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.closeChats);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats);
MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info); MessagesController.getInstance().deleteUserFromChat(chat_id, MessagesController.getInstance().getUser(UserConfig.getClientUserId()), info);
MessagesController.getInstance().deleteDialog(-chat_id, 0, false);
finishFragment(); finishFragment();
} }
} }
@ -1133,7 +1122,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
//Profile photo //Profile photo
//int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32)); //int radius = AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32));
int radius = AndroidUtilities.dp(32); int radius = AndroidUtilities.dp(32);
avatarImage.imageReceiver.setRoundRadius(radius); avatarImage.setRoundRadius(radius);
avatarDrawable.setRadius(radius); avatarDrawable.setRadius(radius);
avatarImage.setImage(photo, "50_50", avatarDrawable); avatarImage.setImage(photo, "50_50", avatarDrawable);
@ -1144,7 +1133,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
onlineTextView.setText(LocaleController.formatUserStatus(user)); onlineTextView.setText(LocaleController.formatUserStatus(user));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
} else if (chat_id != 0) { } else if (chat_id != 0) {
TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id); TLRPC.Chat chat = MessagesController.getInstance().getChat(chat_id);
if (chat != null) { if (chat != null) {
@ -1158,7 +1147,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
if (count != 0 && onlineCount > 1) { if (count != 0 && onlineCount > 1) {
onlineTextView.setText(Html.fromHtml(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount)))); onlineTextView.setText(String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("Online", onlineCount)));
} else { } else {
onlineTextView.setText(LocaleController.formatPluralString("Members", count)); onlineTextView.setText(LocaleController.formatPluralString("Members", count));
} }
@ -1173,28 +1162,31 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
//int radius = AndroidUtilities.getIntDef("chatAvatarRadius", 32); //int radius = AndroidUtilities.getIntDef("chatAvatarRadius", 32);
int radius = AndroidUtilities.dp(32); int radius = AndroidUtilities.dp(32);
AvatarDrawable avatarDrawable = new AvatarDrawable(chat, true); AvatarDrawable avatarDrawable = new AvatarDrawable(chat, true);
avatarImage.imageReceiver.setRoundRadius(radius); avatarImage.getImageReceiver().setRoundRadius(radius);
avatarDrawable.setRadius(radius); avatarDrawable.setRadius(radius);
avatarImage.setImage(photo, "50_50", avatarDrawable); avatarImage.setImage(photo, "50_50", avatarDrawable);
//avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat, true)); //avatarImage.setImage(photo, "50_50", new AvatarDrawable(chat, true));
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false); avatarImage.getImageReceiver().setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
} }
} }
private void updateTheme(){ private void updateTheme(){
actionBar.setBackgroundColor(AndroidUtilities.getIntDef("profileHeaderColor", AndroidUtilities.getIntColor("themeColor"))); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
nameTextView.setTextColor(AndroidUtilities.getIntDef("profileNameColor", 0xffffffff)); int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("profileNameSize", 18)); actionBar.setBackgroundColor(themePrefs.getInt("profileHeaderColor", def));
onlineTextView.setTextColor(AndroidUtilities.getIntDef("profileStatusColor", AndroidUtilities.getIntDarkerColor("themeColor",-0x40))); nameTextView.setTextColor(themePrefs.getInt("profileNameColor", 0xffffffff));
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, AndroidUtilities.getIntDef("profileStatusSize", 14)); nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("profileNameSize", 18));
onlineTextView.setTextColor(themePrefs.getInt("profileStatusColor", AndroidUtilities.getIntDarkerColor("themeColor", -0x40)));
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, themePrefs.getInt("profileStatusSize", 14));
} }
private void createActionBarMenu() { private void createActionBarMenu() {
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();
menu.clearItems(); menu.clearItems();
Drawable dots = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_other); Drawable dots = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_other);
dots.setColorFilter(AndroidUtilities.getIntDef("profileHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY); SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
dots.setColorFilter(themePrefs.getInt("profileHeaderIconsColor", 0xffffffff), PorterDuff.Mode.MULTIPLY);
if (user_id != 0) { if (user_id != 0) {
if (ContactsController.getInstance().contactsDict.get(user_id) == null) { if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
TLRPC.User user = MessagesController.getInstance().getUser(user_id); TLRPC.User user = MessagesController.getInstance().getUser(user_id);
@ -1305,6 +1297,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
@Override @Override
public View getView(int i, View view, ViewGroup viewGroup) { public View getView(int i, View view, ViewGroup viewGroup) {
int type = getItemViewType(i); int type = getItemViewType(i);
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int def = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
if (type == 0) { if (type == 0) {
if (view == null) { if (view == null) {
view = new EmptyCell(mContext); view = new EmptyCell(mContext);
@ -1328,8 +1322,8 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
view = new TextDetailCell(mContext); view = new TextDetailCell(mContext);
} }
TextDetailCell textDetailCell = (TextDetailCell) view; TextDetailCell textDetailCell = (TextDetailCell) view;
textDetailCell.setTextColor(AndroidUtilities.getIntDef("profileTitleColor", 0xff212121)); textDetailCell.setTextColor(themePrefs.getInt("profileTitleColor", 0xff212121));
textDetailCell.setValueColor(AndroidUtilities.getIntDef("profileSummaryColor", 0xff8a8a8a)); textDetailCell.setValueColor(themePrefs.getInt("profileSummaryColor", 0xff8a8a8a));
if (i == phoneRow) { if (i == phoneRow) {
String text; String text;
if (user.phone != null && user.phone.length() != 0) { if (user.phone != null && user.phone.length() != 0) {
@ -1339,7 +1333,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
//textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey); //textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), R.drawable.phone_grey);
Drawable ph = mContext.getResources().getDrawable(R.drawable.phone_grey); Drawable ph = mContext.getResources().getDrawable(R.drawable.phone_grey);
ph.setColorFilter(AndroidUtilities.getIntDef("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN); ph.setColorFilter(themePrefs.getInt("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN);
textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), ph); textDetailCell.setTextAndValueAndIcon(text, LocaleController.getString("PhoneMobile", R.string.PhoneMobile), ph);
} else if (i == usernameRow) { } else if (i == usernameRow) {
String text; String text;
@ -1356,7 +1350,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} }
TextCell textCell = (TextCell) view; TextCell textCell = (TextCell) view;
//textCell.setTextColor(0xff212121); //textCell.setTextColor(0xff212121);
textCell.setTextColor(AndroidUtilities.getIntDef("profileTitleColor", 0xff212121)); textCell.setTextColor(themePrefs.getInt("profileTitleColor", 0xff212121));
if (i == sharedMediaRow) { if (i == sharedMediaRow) {
String value; String value;
if (totalMediaCount == -1) { if (totalMediaCount == -1) {
@ -1365,7 +1359,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
value = String.format("%d", totalMediaCount); value = String.format("%d", totalMediaCount);
} }
textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value); textCell.setTextAndValue(LocaleController.getString("SharedMedia", R.string.SharedMedia), value);
textCell.setValueColor(AndroidUtilities.getIntDef("profileTitleColor", AndroidUtilities.getIntColor("themeColor"))); textCell.setValueColor(themePrefs.getInt("profileTitleColor", def));
} else if (i == settingsTimerRow) { } else if (i == settingsTimerRow) {
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
String value; String value;
@ -1378,12 +1372,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
} else if (i == settingsNotificationsRow) { } else if (i == settingsNotificationsRow) {
//textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list); //textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), R.drawable.profile_list);
Drawable pf = mContext.getResources().getDrawable(R.drawable.profile_list); Drawable pf = mContext.getResources().getDrawable(R.drawable.profile_list);
pf.setColorFilter(AndroidUtilities.getIntDef("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN); pf.setColorFilter(themePrefs.getInt("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN);
textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), pf); textCell.setTextAndIcon(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds), pf);
} else if (i == startSecretChatRow) { } else if (i == startSecretChatRow) {
textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); textCell.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
//textCell.setTextColor(0xff37a919); //textCell.setTextColor(0xff37a919);
textCell.setTextColor(AndroidUtilities.getIntDef("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor",0x15))); textCell.setTextColor(themePrefs.getInt("profileTitleColor", AndroidUtilities.getIntDarkerColor("themeColor", 0x15)));
} else if (i == settingsKeyRow) { } else if (i == settingsKeyRow) {
IdenticonDrawable identiconDrawable = new IdenticonDrawable(); IdenticonDrawable identiconDrawable = new IdenticonDrawable();
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
@ -1397,21 +1391,21 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
TLRPC.TL_chatParticipant part = info.participants.get(sortedUsers.get(i - emptyRowChat2 - 1)); TLRPC.TL_chatParticipant part = info.participants.get(sortedUsers.get(i - emptyRowChat2 - 1));
((UserCell)view).setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0); ((UserCell)view).setData(MessagesController.getInstance().getUser(part.user_id), null, null, i == emptyRowChat2 + 1 ? R.drawable.menu_newgroup : 0);
((UserCell)view).setNameColor(AndroidUtilities.getIntDef("profileTitleColor", 0xff212121)); ((UserCell)view).setNameColor(themePrefs.getInt("profileTitleColor", 0xff212121));
((UserCell)view).setStatusColors(AndroidUtilities.getIntDef("profileSummaryColor", 0xff8a8a8a),AndroidUtilities.getIntDarkerColor("themeColor",-0x40)); ((UserCell)view).setStatusColors(themePrefs.getInt("profileSummaryColor", 0xff8a8a8a),AndroidUtilities.getIntDarkerColor("themeColor",-0x40));
if(i == emptyRowChat2 + 1){ if(i == emptyRowChat2 + 1){
Drawable newGroup = mContext.getResources().getDrawable(R.drawable.menu_newgroup); Drawable newGroup = mContext.getResources().getDrawable(R.drawable.menu_newgroup);
newGroup.setColorFilter(AndroidUtilities.getIntDef("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN); newGroup.setColorFilter(themePrefs.getInt("profileTitleColor", 0xff737373), PorterDuff.Mode.SRC_IN);
((UserCell)view).setImageDrawable(newGroup); ((UserCell)view).setImageDrawable(newGroup);
} }
//((UserCell) view).setAvatarRadius(AndroidUtilities.dp(AndroidUtilities.getIntDef("chatAvatarRadius", 32))); //((UserCell) view).setAvatarRadius(AndroidUtilities.dp(themePrefs.getInt("chatAvatarRadius", 32)));
} else if (type == 5) { } else if (type == 5) {
if (view == null) { if (view == null) {
view = new ShadowSectionCell(mContext); view = new ShadowSectionCell(mContext);
} }
view.setBackgroundColor(AndroidUtilities.getIntDef("profileRowColor", 0xffffffff)); view.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff));
} }
viewGroup.setBackgroundColor(AndroidUtilities.getIntDef("profileRowColor", 0xffffffff)); viewGroup.setBackgroundColor(themePrefs.getInt("profileRowColor", 0xffffffff));
return view; return view;
} }

View File

@ -95,8 +95,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} }
@Override @Override
public View createView(LayoutInflater inflater) { public View createView(Context context, LayoutInflater inflater) {
if (fragmentView == null) {
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true); actionBar.setAllowOverlayTitle(true);
actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds)); actionBar.setTitle(LocaleController.getString("NotificationsAndSounds", R.string.NotificationsAndSounds));
@ -109,10 +108,10 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} }
}); });
fragmentView = new FrameLayout(getParentActivity()); fragmentView = new FrameLayout(context);
FrameLayout frameLayout = (FrameLayout) fragmentView; FrameLayout frameLayout = (FrameLayout) fragmentView;
listView = new ListView(getParentActivity()); listView = new ListView(context);
listView.setDivider(null); listView.setDivider(null);
listView.setDividerHeight(0); listView.setDividerHeight(0);
listView.setVerticalScrollBarEnabled(false); listView.setVerticalScrollBarEnabled(false);
@ -122,14 +121,14 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.width = FrameLayout.LayoutParams.MATCH_PARENT;
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT; layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
listView.setLayoutParams(layoutParams); listView.setLayoutParams(layoutParams);
listView.setAdapter(new ListAdapter(getParentActivity())); listView.setAdapter(new ListAdapter(context));
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
if (i == settingsVibrateRow) { if (i == settingsVibrateRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate)); builder.setTitle(LocaleController.getString("Vibrate", R.string.Vibrate));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled), LocaleController.getString("VibrationDisabled", R.string.VibrationDisabled),
LocaleController.getString("SettingsDefault", R.string.SettingsDefault), LocaleController.getString("SettingsDefault", R.string.SettingsDefault),
LocaleController.getString("SystemDefault", R.string.SystemDefault), LocaleController.getString("SystemDefault", R.string.SystemDefault),
@ -289,15 +288,15 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
return; return;
} }
LayoutInflater li = (LayoutInflater)getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); LayoutInflater li = (LayoutInflater) getParentActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = li.inflate(R.layout.settings_color_dialog_layout, null, false); view = li.inflate(R.layout.settings_color_dialog_layout, null, false);
final ColorPickerView colorPickerView = (ColorPickerView)view.findViewById(R.id.color_picker); final ColorPickerView colorPickerView = (ColorPickerView) view.findViewById(R.id.color_picker);
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
if (preferences.contains("color_" + dialog_id)) { if (preferences.contains("color_" + dialog_id)) {
colorPickerView.setOldCenterColor(preferences.getInt("color_" + dialog_id, 0xff00ff00)); colorPickerView.setOldCenterColor(preferences.getInt("color_" + dialog_id, 0xff00ff00));
} else { } else {
if ((int)dialog_id < 0) { if ((int) dialog_id < 0) {
colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00)); colorPickerView.setOldCenterColor(preferences.getInt("GroupLed", 0xff00ff00));
} else { } else {
colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00)); colorPickerView.setOldCenterColor(preferences.getInt("MessagesLed", 0xff00ff00));
@ -341,7 +340,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} else if (i == settingsPriorityRow) { } else if (i == settingsPriorityRow) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority)); builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority));
builder.setItems(new CharSequence[] { builder.setItems(new CharSequence[]{
LocaleController.getString("SettingsDefault", R.string.SettingsDefault), LocaleController.getString("SettingsDefault", R.string.SettingsDefault),
LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault),
LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh),
@ -433,12 +432,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
// //
} }
}); });
} else {
ViewGroup parent = (ViewGroup)fragmentView.getParent();
if (parent != null) {
parent.removeView(fragmentView);
}
}
return fragmentView; return fragmentView;
} }
@ -454,7 +448,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone); Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
if (rng != null) { if (rng != null) {
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) { if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
name = LocaleController.getString("Default", R.string.Default); name = LocaleController.getString("SoundDefault", R.string.SoundDefault);
} else { } else {
name = rng.getTitle(getParentActivity()); name = rng.getTitle(getParentActivity());
} }
@ -594,7 +588,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
} }
// //
} else if (i == settingsSoundRow) { } else if (i == settingsSoundRow) {
String value = preferences.getString("sound_" + dialog_id, LocaleController.getString("Default", R.string.Default)); String value = preferences.getString("sound_" + dialog_id, LocaleController.getString("SoundDefault", R.string.SoundDefault));
if (value.equals("NoSound")) { if (value.equals("NoSound")) {
value = LocaleController.getString("NoSound", R.string.NoSound); value = LocaleController.getString("NoSound", R.string.NoSound);
} }

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