Commit fc46daa5 authored by DrKLO's avatar DrKLO

A lot of features (may be unstable, don't upload to markets)

Blocked contacts
Media auto download
Repeat notifications every hour
Vibration patterns
Resend messages after app restart
parent 8f7652bb
......@@ -17,7 +17,7 @@ tasks.withType(JavaCompile) {
}
dependencies {
compile 'com.android.support:support-v4:19.0.+'
compile 'com.android.support:support-v4:20.0.+'
compile 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile 'com.googlecode.mp4parser:isoparser:1.0.+'
......@@ -27,9 +27,6 @@ android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
useAaptPngCruncher = true
useOldManifestMerger true
signingConfigs {
debug {
storeFile file("config/debug.keystore")
......@@ -83,7 +80,7 @@ android {
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 307
versionName "1.7.0"
versionCode 308
versionName "1.8.0"
}
}
......@@ -138,6 +138,7 @@
</service>
<service android:name="org.telegram.android.NotificationsService" android:enabled="true"/>
<service android:name="org.telegram.android.NotificationRepeat" android:exported="false"/>
<receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true">
<intent-filter>
......
......@@ -225,4 +225,8 @@ public class AndroidUtilities {
public static long makeBroadcastId(int id) {
return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL);
}
public static void RunOnUIThread(Runnable runnable) {
ApplicationLoader.applicationHandler.post(runnable);
}
}
......@@ -12,12 +12,11 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
public class AppStartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.startPushService();
......
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.android;
import org.telegram.messenger.TLObject;
public class DownloadObject {
public TLObject object;
public int type;
public long id;
}
......@@ -27,7 +27,6 @@ import android.view.ViewGroup;
import android.widget.TextView;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader;
......@@ -271,11 +270,11 @@ public class Emoji {
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, 0, width, height);
final EmojiBitmap emojiBitmap = new EmojiBitmap(bitmap, width, height);
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
emojiBmp[page] = emojiBitmap;
NotificationCenter.getInstance().postNotificationName(999);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.emojiDidLoaded);
}
});
} catch(Throwable x) {
......
......@@ -29,7 +29,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
FileLog.d("tmessages", "GCM received intent: " + intent);
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
ApplicationLoader.postInitApplication();
......
......@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.ui.Views;
package org.telegram.android;
import android.graphics.Bitmap;
import android.graphics.Canvas;
......@@ -16,7 +16,6 @@ import android.graphics.drawable.Drawable;
import android.view.View;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities;
......@@ -29,13 +28,21 @@ public class ImageReceiver {
private String currentPath = null;
private boolean isPlaceholder = false;
private Drawable currentImage = null;
public Integer TAG = null;
public View parentView = null;
public int imageX = 0, imageY = 0, imageW = 0, imageH = 0;
public Rect drawRegion = new Rect();
private Integer tag = null;
private View parentView = null;
private int imageX = 0, imageY = 0, imageW = 0, imageH = 0;
private Rect drawRegion = new Rect();
private boolean isVisible = true;
private boolean selfSetting = false;
public boolean isAspectFit = false;
private boolean isAspectFit = false;
public ImageReceiver() {
}
public ImageReceiver(View view) {
parentView = view;
}
public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) {
setImage(path, null, filter, placeholder, 0);
......@@ -49,8 +56,8 @@ public class ImageReceiver {
setImage(null, path, filter, placeholder, 0);
}
public void setImage(TLRPC.FileLocation path, String httpUrl, String filter, Drawable placeholder, int size) {
if ((path == null && httpUrl == null) || (path != null && !(path instanceof TLRPC.TL_fileLocation) && !(path instanceof TLRPC.TL_fileEncryptedLocation))) {
public void setImage(TLRPC.FileLocation fileLocation, String httpUrl, String filter, Drawable placeholder, int size) {
if ((fileLocation == null && httpUrl == null) || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
recycleBitmap(null);
currentPath = null;
isPlaceholder = true;
......@@ -60,44 +67,44 @@ public class ImageReceiver {
last_placeholder = placeholder;
last_size = 0;
currentImage = null;
FileLoader.getInstance().cancelLoadingForImageView(this);
ImageLoader.getInstance().cancelLoadingForImageView(this);
if (parentView != null) {
parentView.invalidate();
}
return;
}
String key;
if (path != null) {
key = path.volume_id + "_" + path.local_id;
if (fileLocation != null) {
key = fileLocation.volume_id + "_" + fileLocation.local_id;
} else {
key = Utilities.MD5(httpUrl);
}
if (filter != null) {
key += "@" + filter;
}
Bitmap img = null;
BitmapDrawable img = null;
if (currentPath != null) {
if (currentPath.equals(key)) {
if (currentImage != null) {
return;
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
}
} else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
recycleBitmap(img);
}
}
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter);
img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
currentPath = key;
last_path = path;
last_path = fileLocation;
last_httpUrl = httpUrl;
last_filter = filter;
last_placeholder = placeholder;
last_size = size;
if (img == null) {
isPlaceholder = true;
FileLoader.getInstance().loadImage(path, httpUrl, this, filter, true, size);
ImageLoader.getInstance().loadImage(fileLocation, httpUrl, this, size);
} else {
selfSetting = true;
setImageBitmap(img, currentPath);
......@@ -108,20 +115,20 @@ public class ImageReceiver {
}
}
public void setImageBitmap(Bitmap bitmap, String imgKey) {
public void setImageBitmap(BitmapDrawable bitmap, String imgKey) {
if (currentPath == null || !imgKey.equals(currentPath)) {
return;
}
isPlaceholder = false;
FileLoader.getInstance().incrementUseCount(currentPath);
currentImage = new BitmapDrawable(null, bitmap);
ImageLoader.getInstance().incrementUseCount(currentPath);
currentImage = bitmap;
if (!selfSetting && parentView != null) {
parentView.invalidate();
}
}
public void setImageBitmap(Bitmap bitmap) {
FileLoader.getInstance().cancelLoadingForImageView(this);
ImageLoader.getInstance().cancelLoadingForImageView(this);
recycleBitmap(null);
if (bitmap != null) {
last_placeholder = new BitmapDrawable(null, bitmap);
......@@ -141,7 +148,7 @@ public class ImageReceiver {
}
public void setImageBitmap(Drawable bitmap) {
FileLoader.getInstance().cancelLoadingForImageView(this);
ImageLoader.getInstance().cancelLoadingForImageView(this);
recycleBitmap(null);
last_placeholder = bitmap;
isPlaceholder = true;
......@@ -160,18 +167,18 @@ public class ImageReceiver {
recycleBitmap(null);
}
private void recycleBitmap(Bitmap newBitmap) {
private void recycleBitmap(BitmapDrawable newBitmap) {
if (currentImage == null || isPlaceholder) {
return;
}
if (currentImage instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable)currentImage).getBitmap();
if (bitmap != null && bitmap != newBitmap) {
if (currentImage != newBitmap) {
if (currentPath != null) {
boolean canDelete = FileLoader.getInstance().decrementUseCount(currentPath);
if (!FileLoader.getInstance().isInCache(currentPath)) {
if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight());
Bitmap bitmap = ((BitmapDrawable) currentImage).getBitmap();
boolean canDelete = ImageLoader.getInstance().decrementUseCount(currentPath);
if (!ImageLoader.getInstance().isInCache(currentPath)) {
if (ImageLoader.getInstance().runtimeHack != null) {
ImageLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight());
}
if (canDelete) {
currentImage = null;
......@@ -242,7 +249,7 @@ public class ImageReceiver {
}
} catch (Exception e) {
if (currentPath != null) {
FileLoader.getInstance().removeImage(currentPath);
ImageLoader.getInstance().removeImage(currentPath);
currentPath = null;
}
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
......@@ -276,4 +283,59 @@ public class ImageReceiver {
public boolean hasImage() {
return currentImage != null || last_placeholder != null || currentPath != null || last_httpUrl != null;
}
public void setAspectFit(boolean value) {
isAspectFit = value;
}
public void setParentView(View view) {
parentView = view;
}
protected Integer getTag() {
return tag;
}
protected void setTag(Integer tag) {
this.tag = tag;
}
public void setImageCoords(int x, int y, int width, int height) {
imageX = x;
imageY = y;
imageW = width;
imageH = height;
}
public int getImageX() {
return imageX;
}
public int getImageY() {
return imageY;
}
public int getImageWidth() {
return imageW;
}
public int getImageHeight() {
return imageH;
}
public boolean isInsideImage(float x, float y) {
return x >= imageX && x <= imageX + imageW && y >= imageY && y <= imageY + imageH;
}
public Rect getDrawRegion() {
return drawRegion;
}
public String getFilter() {
return last_filter;
}
public String getKey() {
return currentPath;
}
}
......@@ -6,9 +6,9 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.messenger;
package org.telegram.android;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
......@@ -22,7 +22,7 @@ import java.util.Map;
* overview.
*/
public class LruCache {
private final LinkedHashMap<String, Bitmap> map;
private final LinkedHashMap<String, BitmapDrawable> map;
private final LinkedHashMap<String, ArrayList<String>> mapFilters;
/** Size of this cache in units. Not necessarily the number of elements. */
......@@ -44,7 +44,7 @@ public class LruCache {
throw new IllegalArgumentException("maxSize <= 0");
}
this.maxSize = maxSize;
this.map = new LinkedHashMap<String, Bitmap>(0, 0.75f, true);
this.map = new LinkedHashMap<String, BitmapDrawable>(0, 0.75f, true);
this.mapFilters = new LinkedHashMap<String, ArrayList<String>>();
}
......@@ -54,12 +54,12 @@ public class LruCache {
* head of the queue. This returns null if a value is not cached and cannot
* be created.
*/
public final Bitmap get(String key) {
public final BitmapDrawable get(String key) {
if (key == null) {
throw new NullPointerException("key == null");
}
Bitmap mapValue;
BitmapDrawable mapValue;
synchronized (this) {
mapValue = map.get(key);
if (mapValue != null) {
......@@ -85,12 +85,12 @@ public class LruCache {
*
* @return the previous value mapped by {@code key}.
*/
public Bitmap put(String key, Bitmap value) {
public BitmapDrawable put(String key, BitmapDrawable value) {
if (key == null || value == null) {
throw new NullPointerException("key == null || value == null");
}
Bitmap previous;
BitmapDrawable previous;
synchronized (this) {
putCount++;
size += safeSizeOf(key, value);
......@@ -125,7 +125,7 @@ public class LruCache {
private void trimToSize(int maxSize) {
while (true) {
String key;
Bitmap value;
BitmapDrawable value;
synchronized (this) {
if (size < 0 || (map.isEmpty() && size != 0)) {
throw new IllegalStateException(getClass().getName()
......@@ -136,7 +136,7 @@ public class LruCache {
break;
}
Map.Entry<String, Bitmap> toEvict = map.entrySet().iterator().next();
Map.Entry<String, BitmapDrawable> toEvict = map.entrySet().iterator().next();
key = toEvict.getKey();
value = toEvict.getValue();
map.remove(key);
......@@ -164,12 +164,12 @@ public class LruCache {
*
* @return the previous value mapped by {@code key}.
*/
public final Bitmap remove(String key) {
public final BitmapDrawable remove(String key) {
if (key == null) {
throw new NullPointerException("key == null");
}
Bitmap previous;
BitmapDrawable previous;
synchronized (this) {
previous = map.remove(key);
if (previous != null) {
......@@ -214,9 +214,9 @@ public class LruCache {
* this removal was caused by a {@link #put}. Otherwise it was caused by
* an eviction or a {@link #remove}.
*/
protected void entryRemoved(boolean evicted, String key, Bitmap oldValue, Bitmap newValue) {}
protected void entryRemoved(boolean evicted, String key, BitmapDrawable oldValue, BitmapDrawable newValue) {}
private int safeSizeOf(String key, Bitmap value) {
private int safeSizeOf(String key, BitmapDrawable value) {
int result = sizeOf(key, value);
if (result < 0) {
throw new IllegalStateException("Negative size: " + key + "=" + value);
......@@ -231,7 +231,7 @@ public class LruCache {
*
* <p>An entry's size must not change while it is in the cache.
*/
protected int sizeOf(String key, Bitmap value) {
protected int sizeOf(String key, BitmapDrawable value) {
return 1;
}
......
......@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.objects;
package org.telegram.android;
import android.graphics.Bitmap;
import android.graphics.Paint;
......@@ -16,13 +16,9 @@ import android.text.StaticLayout;
import android.text.TextPaint;
import android.text.util.Linkify;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC;
import org.telegram.android.Emoji;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
......@@ -33,6 +29,11 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
public class MessageObject {
public static final int MESSAGE_SEND_STATE_SENDING = 1;
public static final int MESSAGE_SEND_STATE_SENT = 0;
public static final int MESSAGE_SEND_STATE_SEND_ERROR = 2;
public TLRPC.Message messageOwner;
public CharSequence messageText;
public int type;
......@@ -78,9 +79,12 @@ public class MessageObject {
if (message instanceof TLRPC.TL_messageService) {
if (message.action != null) {
TLRPC.User fromUser = users.get(message.from_id);
TLRPC.User fromUser = null;
if (users != null) {
fromUser = users.get(message.from_id);
}
if (fromUser == null) {
fromUser = MessagesController.getInstance().users.get(message.from_id);
fromUser = MessagesController.getInstance().getUser(message.from_id);
}
if (message.action instanceof TLRPC.TL_messageActionChatCreate) {
if (isFromMe()) {
......@@ -104,9 +108,12 @@ public class MessageObject {
}
}
} else {
TLRPC.User who = users.get(message.action.user_id);
TLRPC.User who = null;
if (users != null) {
who = users.get(message.action.user_id);
}
if (who == null) {
MessagesController.getInstance().users.get(message.action.user_id);
who = MessagesController.getInstance().getUser(message.action.user_id);
}
if (who != null && fromUser != null) {
if (isFromMe()) {
......@@ -121,9 +128,12 @@ public class MessageObject {
}
}
} else if (message.action instanceof TLRPC.TL_messageActionChatAddUser) {
TLRPC.User whoUser = users.get(message.action.user_id);
TLRPC.User whoUser = null;
if (users != null) {
whoUser = users.get(message.action.user_id);
}
if (whoUser == null) {
MessagesController.getInstance().users.get(message.action.user_id);
whoUser = MessagesController.getInstance().getUser(message.action.user_id);
}
if (whoUser != null && fromUser != null) {
if (isFromMe()) {
......@@ -389,50 +399,19 @@ public class MessageObject {
public String getFileName() {
if (messageOwner.media instanceof TLRPC.TL_messageMediaVideo) {
return getAttachFileName(messageOwner.media.video);
return FileLoader.getAttachFileName(messageOwner.media.video);
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
return getAttachFileName(messageOwner.media.document);
return FileLoader.getAttachFileName(messageOwner.media.document);
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaAudio) {
return getAttachFileName(messageOwner.media.audio);
return FileLoader.getAttachFileName(messageOwner.media.audio);
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
if (sizes.size() > 0) {
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
if (sizeFull != null) {
return getAttachFileName(sizeFull);
}
return FileLoader.getAttachFileName(sizeFull);
}
}
return "";
}
public static String getAttachFileName(TLObject attach) {
if (attach instanceof TLRPC.Video) {
TLRPC.Video video = (TLRPC.Video)attach;
return video.dc_id + "_" + video.id + ".mp4";
} else if (attach instanceof TLRPC.Document) {
TLRPC.Document document = (TLRPC.Document)attach;
String ext = document.file_name;
int idx = -1;
if (ext == null || (idx = ext.lastIndexOf(".")) == -1) {
ext = "";
} else {
ext = ext.substring(idx);
}
if (ext.length() > 1) {
return document.dc_id + "_" + document.id + ext;
} else {
return document.dc_id + "_" + document.id;
}
} else if (attach instanceof TLRPC.PhotoSize) {
TLRPC.PhotoSize photo = (TLRPC.PhotoSize)attach;
if (photo.location == null) {
return "";
}
return photo.location.volume_id + "_" + photo.location.local_id + ".jpg";
} else if (attach instanceof TLRPC.Audio) {
TLRPC.Audio audio = (TLRPC.Audio)attach;
return audio.dc_id + "_" + audio.id + ".m4a";
}
return "";
}
......
......@@ -6,13 +6,62 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.messenger;
package org.telegram.android;
import java.util.ArrayList;
import java.util.HashMap;
public class NotificationCenter {
public static final int didReceivedNewMessages = 1;
public static final int updateInterfaces = 3;
public static final int dialogsNeedReload = 4;
public static final int closeChats = 5;
public static final int messagesDeleted = 6;
public static final int messagesReaded = 7;
public static final int messagesDidLoaded = 8;
public static final int messageReceivedByAck = 9;
public static final int messageReceivedByServer = 10;
public static final int messageSendError = 11;
public static final int reloadSearchResults = 12;
public static final int contactsDidLoaded = 13;
public static final int chatDidCreated = 15;
public static final int chatDidFailCreate = 16;
public static final int chatInfoDidLoaded = 17;
public static final int mediaDidLoaded = 18;
public static final int mediaCountDidLoaded = 20;
public static final int encryptedChatUpdated = 21;
public static final int messagesReadedEncrypted = 22;
public static final int encryptedChatCreated = 23;
public static final int userPhotosLoaded = 24;
public static final int removeAllMessagesFromDialog = 25;
public static final int notificationsSettingsUpdated = 26;
public static final int pushMessagesUpdated = 27;
public static final int blockedUsersDidLoaded = 28;
public static final int wallpapersDidLoaded = 171;
public static final int closeOtherAppActivities = 702;
public static final int didUpdatedConnectionState = 703;
public static final int emojiDidLoaded = 999;
public static final int appDidLogout = 1234;
public static final int FileDidUpload = 10000;
public static final int FileDidFailUpload = 10001;
public static final int FileUploadProgressChanged = 10002;
public static final int FileLoadProgressChanged = 10003;
public static final int FileDidLoaded = 10004;
public static final int FileDidFailedLoad = 10005;
public final static int audioProgressDidChanged = 50001;
public final static int audioDidReset = 50002;
public final static int recordProgressChanged = 50003;
public final static int recordStarted = 50004;
public final static int recordStartError = 50005;
public final static int recordStopped = 50006;
public final static int screenshotTook = 50007;
public final static int albumsDidLoaded = 50008;
public final static int audioDidSent = 50009;
final private HashMap<Integer, ArrayList<Object>> observers = new HashMap<Integer, ArrayList<Object>>();
final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<Integer, Object>();
......
/*
* This is the source code of Telegram for Android v. 1.7.x.
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
* Copyright Nikolai Kudashov, 2013-2014.
*/
package org.telegram.android;
import android.app.IntentService;
import android.content.Intent;
import org.telegram.messenger.Utilities;
public class NotificationRepeat extends IntentService {
public NotificationRepeat() {
super("NotificationRepeat");
}
@Override
protected void onHandleIntent(Intent intent) {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationsController.getInstance().repeatNotificationMaybe();
}
});
}
}
......@@ -6,13 +6,12 @@
* Copyright Nikolai Kudashov, 2013.
*/
package org.telegram.objects;
package org.telegram.android;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.Utilities;
import java.util.ArrayList;
......@@ -35,8 +34,8 @@ public class PhotoObject {
if (preview == 2) {
Utilities.blurBitmap(image, image.getWidth(), image.getHeight(), image.getRowBytes());
}
if (FileLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
if (ImageLoader.getInstance().runtimeHack != null) {
ImageLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
}
}
}
......
......@@ -16,7 +16,6 @@ import android.os.Bundle;
import android.telephony.SmsMessage;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......
......@@ -17,8 +17,10 @@ import android.os.Build;
import android.os.PowerManager;
import android.util.Base64;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.ui.ApplicationLoader;
import java.io.File;
......@@ -456,7 +458,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter();
datacenter.datacenterId = 5;
datacenter.addAddressAndPort("116.51.22.2", 443);
datacenter.addAddressAndPort("149.154.171.5", 443);
datacenters.put(datacenter.datacenterId, datacenter);
} else {
Datacenter datacenter = new Datacenter();
......@@ -643,7 +645,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
public void bindRequestToGuid(final Long request, final int guid) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
ArrayList<Long> requests = requestsByGuids.get(guid);
......@@ -656,7 +658,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
public void removeRequestInClass(final Long request) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
Integer guid = requestsByClass.get(request);
......@@ -964,6 +966,19 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
return false;
}
public static boolean isRoaming() {
try {
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null) {
return netInfo.isRoaming();
}
} catch(Exception e) {
FileLog.e("tmessages", e);
}
return false;
}
public static boolean isConnectedToWiFi() {
try {
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
......@@ -2094,7 +2109,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} else {
if (resultContainer.result instanceof TLRPC.updates_Difference) {
pushMessagesReceived = true;
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (wakeLock.isHeld()) {
......@@ -2113,10 +2128,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
if (UserConfig.isClientActivated()) {
UserConfig.clearConfig();
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(1234);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
}
});
}
......@@ -2272,7 +2287,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (paused) {
pushMessagesReceived = false;
}
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
wakeLock.acquire(20000);
......@@ -2281,7 +2296,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
resumeNetworkInternal();
} else {
pushMessagesReceived = true;
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
if (wakeLock.isHeld()) {
......@@ -2386,10 +2401,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
}
}
final int stateCopy = connectionState;
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(703, stateCopy);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
}
});
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
......@@ -2435,10 +2450,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (ConnectionsManager.getInstance().connectionState == 3 && !MessagesController.getInstance().gettingDifference && !MessagesController.getInstance().gettingDifferenceAgain) {
ConnectionsManager.getInstance().connectionState = 0;
final int stateCopy = ConnectionsManager.getInstance().connectionState;
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(703, stateCopy);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
}
});
}
......@@ -2451,10 +2466,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (connectionState == 1 || connectionState == 2) {
connectionState = 3;
final int stateCopy = connectionState;
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(703, stateCopy);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
}
});
}
......
......@@ -420,6 +420,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_notifyChats.constructor, TLRPC.TL_notifyChats.class);
classStore.put(TLRPC.TL_notifyUsers.constructor, TLRPC.TL_notifyUsers.class);
classStore.put(TLRPC.TL_notifyPeer.constructor, TLRPC.TL_notifyPeer.class);
classStore.put(TLRPC.TL_photos_deletePhotos.constructor, TLRPC.TL_photos_deletePhotos.class);
classStore.put(TLRPC.TL_msg_container.constructor, TLRPC.TL_msg_container.class);
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);
......
......@@ -1988,17 +1988,6 @@ public class TLRPC {
}
}
public static class User extends TLObject {
public int id;
public String first_name;
public String last_name;
public long access_hash;
public String phone;
public UserProfilePhoto photo;
public UserStatus status;
public boolean inactive;
}
public static class TL_userContact extends User {
public static int constructor = 0xf2fb8319;
......@@ -7443,6 +7432,32 @@ public class TLRPC {
}
}
public static class TL_photos_deletePhotos extends TLObject {
public static int constructor = 0x87cf7f2f;
public ArrayList<InputPhoto> id = new ArrayList<InputPhoto>();
public Class responseClass () {
return Vector.class;
}
public void parseVector(Vector vector, AbsSerializedData data) {
int size = data.readInt32();
for (int a = 0; a < size; a++) {
vector.objects.add(data.readInt64());
}
}
public void serializeToStream(AbsSerializedData stream) {
stream.writeInt32(constructor);
stream.writeInt32(0x1cb5c415);
stream.writeInt32(id.size());
for (InputPhoto inputPhoto : id) {
inputPhoto.serializeToStream(stream);
}
}
}
public static class TL_photos_uploadProfilePhoto extends TLObject {
public static int constructor = 0xd50f9c88;
......@@ -8697,6 +8712,17 @@ public class TLRPC {
public ArrayList<Object> objects = new ArrayList<Object>();
}
public static class User extends TLObject {
public int id;
public String first_name;
public String last_name;
public long access_hash;
public String phone;
public UserProfilePhoto photo;
public UserStatus status;
public boolean inactive;
}
public static class TL_userEmpty extends User {
public static int constructor = 0x200250ba;
......@@ -8860,6 +8886,7 @@ public class TLRPC {
public int last_message_date;
public long id;
public int last_read;
public int flags;
public void readParams(AbsSerializedData stream) {
peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
......
......@@ -27,6 +27,7 @@ public class UserConfig {
public static int lastBroadcastId = -1;
public static String contactsHash = "";
public static String importHash = "";
public static boolean blockedUsersLoaded = false;
private final static Integer sync = 1;
public static boolean saveIncomingPhotos = false;
public static int contactsVersion = 1;
......@@ -59,6 +60,7 @@ public class UserConfig {
editor.putInt("contactsVersion", contactsVersion);
editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
if (currentUser != null) {
if (withFile) {
SerializedData data = new SerializedData();
......@@ -178,6 +180,7 @@ public class UserConfig {
contactsVersion = preferences.getInt("contactsVersion", 0);
lastBroadcastId = preferences.getInt("lastBroadcastId", -1);
registeredForInternalPush = preferences.getBoolean("registeredForInternalPush", false);
blockedUsersLoaded = preferences.getBoolean("blockedUsersLoaded", false);
String user = preferences.getString("user", null);
if (user != null) {
byte[] userBytes = Base64.decode(user, Base64.DEFAULT);
......@@ -201,6 +204,7 @@ public class UserConfig {
contactsVersion = 1;
lastBroadcastId = -1;
saveIncomingPhotos = false;
blockedUsersLoaded = false;
saveConfig(true);
}
}
......@@ -62,7 +62,6 @@ import javax.crypto.Cipher;
public class Utilities {
public static Pattern pattern = Pattern.compile("[0-9]+");
public static SecureRandom random = new SecureRandom();
private final static Integer lock = 1;
public static ArrayList<String> goodPrimes = new ArrayList<String>();
......@@ -501,12 +500,6 @@ public class Utilities {
return true;
}
public static void RunOnUIThread(Runnable runnable) {
synchronized (lock) {
ApplicationLoader.applicationHandler.post(runnable);
}
}
public static int getColorIndex(int id) {
int[] arr;
if (id >= 0) {
......@@ -759,7 +752,7 @@ public class Utilities {
String result = firstName;
if (result == null || result.length() == 0) {
result = lastName;
} else if (result.length() != 0 && lastName.length() != 0) {
} else if (result.length() != 0 && lastName != null && lastName.length() != 0) {
result += " " + lastName;
}
return result.trim();
......
......@@ -86,7 +86,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter {
if (usersAsSections) {
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section));
user = MessagesController.getInstance().users.get(arr.get(position).user_id);
user = MessagesController.getInstance().getUser(arr.get(position).user_id);
count = arr.size();
}
} else {
......@@ -106,7 +106,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter {
}
return convertView;
}
user = MessagesController.getInstance().users.get(ContactsController.getInstance().contacts.get(position - 1).user_id);
user = MessagesController.getInstance().getUser(ContactsController.getInstance().contacts.get(position - 1).user_id);
count = ContactsController.getInstance().contacts.size();
}
}
......
......@@ -12,6 +12,7 @@ import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog;
......@@ -67,7 +68,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
}
private void processSearch(final String query) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
......@@ -85,7 +86,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
for (TLRPC.TL_contact contact : contactsCopy) {
TLRPC.User user = MessagesController.getInstance().users.get(contact.user_id);
TLRPC.User user = MessagesController.getInstance().getUser(contact.user_id);
if (user.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.getClientUserId()) {
continue;
......@@ -103,7 +104,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
}
private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
searchResult = users;
......@@ -161,7 +162,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
((ChatOrUserCell) view).useSeparator = i != searchResult.size() - 1;
Object obj = searchResult.get(i);
TLRPC.User user = MessagesController.getInstance().users.get(((TLRPC.User)obj).id);
TLRPC.User user = MessagesController.getInstance().getUser(((TLRPC.User)obj).id);
if (user != null) {
((ChatOrUserCell)view).setData(user, null, null, searchResultNames.get(i), null);
......
......@@ -30,7 +30,9 @@ import com.google.android.gms.gcm.GoogleCloudMessaging;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController;
import org.telegram.android.MediaController;
import org.telegram.android.NotificationsService;
import org.telegram.android.SendMessagesHelper;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.ConnectionsManager;
import org.telegram.messenger.FileLog;
......@@ -92,9 +94,11 @@ public class ApplicationLoader extends Application {
UserConfig.loadConfig();
if (UserConfig.getCurrentUser() != null) {
MessagesController.getInstance().users.put(UserConfig.getClientUserId(), UserConfig.getCurrentUser());
MessagesController.getInstance().putUser(UserConfig.getCurrentUser(), true);
ConnectionsManager.getInstance().applyCountryPortNumber(UserConfig.getCurrentUser().phone);
ConnectionsManager.getInstance().initPushConnection();
MessagesController.getInstance().getBlockedUsers(true);
SendMessagesHelper.getInstance().checkUnsentMessages();
}
ApplicationLoader app = (ApplicationLoader)ApplicationLoader.applicationContext;
......@@ -102,6 +106,7 @@ public class ApplicationLoader extends Application {
FileLog.e("tmessages", "app initied");
ContactsController.getInstance().checkAppAccount();
MediaController.getInstance();
}
@Override
......@@ -263,7 +268,7 @@ public class ApplicationLoader extends Application {
UserConfig.registeredForPush = !isNew;
UserConfig.saveConfig(false);
if (UserConfig.getClientUserId() != 0) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
MessagesController.getInstance().registerForPush(regid);
......
......@@ -24,8 +24,8 @@ import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.objects.MessageObject;
import org.telegram.ui.Views.ImageReceiver;
import org.telegram.android.MessageObject;
import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.ProgressView;
import org.telegram.ui.Views.SeekBar;
......@@ -63,8 +63,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
super(context, false);
TAG = MediaController.getInstance().generateObserverTag();
avatarImage = new ImageReceiver();
avatarImage.parentView = this;
avatarImage = new ImageReceiver(this);
seekBar = new SeekBar(context);
seekBar.delegate = this;
progressView = new ProgressView();
......@@ -120,7 +119,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
buttonPressed = 1;
invalidate();
result = true;
} else if (x >= avatarImage.imageX && x <= avatarImage.imageX + avatarImage.imageW && y >= avatarImage.imageY && y <= avatarImage.imageY + avatarImage.imageH) {
} else if (avatarImage.isInsideImage(x, y)) {
avatarPressed = 1;
result = true;
}
......@@ -149,7 +148,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
avatarPressed = 0;
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (!(x >= avatarImage.imageX && x <= avatarImage.imageX + avatarImage.imageW && y >= avatarImage.imageY && y <= avatarImage.imageY + avatarImage.imageH)) {
if (!avatarImage.isInsideImage(x, y)) {
avatarPressed = 0;
}
}
......@@ -176,11 +175,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate();
}
} else if (buttonState == 2) {
FileLoader.getInstance().loadFile(null, null, null, currentMessageObject.messageOwner.media.audio);
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true);
buttonState = 3;
invalidate();
} else if (buttonState == 3) {
FileLoader.getInstance().cancelLoadFile(null, null, null, currentMessageObject.messageOwner.media.audio);
FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
buttonState = 2;
invalidate();
}
......@@ -211,7 +210,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
public void downloadAudioIfNeed() {
if (buttonState == 2) {
FileLoader.getInstance().loadFile(null, null, null, currentMessageObject.messageOwner.media.audio);
FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true);
buttonState = 3;
invalidate();
}
......@@ -236,7 +235,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
progressView.setProgress(0);
} else {
buttonState = 3;
Float progress = FileLoader.getInstance().fileProgresses.get(fileName);
Float progress = FileLoader.getInstance().getFileProgress(fileName);
if (progress != null) {
progressView.setProgress(progress);
} else {
......@@ -260,6 +259,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
@Override
public void onProgressDownload(String fileName, float progress) {
progressView.setProgress(progress);
if (buttonState != 3) {
updateButtonState();
}
invalidate();
}
......@@ -297,27 +299,27 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
int x;
if (currentMessageObject.isOut()) {
avatarImage.imageX = layoutWidth - backgroundWidth + AndroidUtilities.dp(9);
x = layoutWidth - backgroundWidth + AndroidUtilities.dp(9);
seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(97);
buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67);
timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(71);
} else {
if (isChat) {
avatarImage.imageX = AndroidUtilities.dp(69);
x = AndroidUtilities.dp(69);
seekBarX = AndroidUtilities.dp(158);
buttonX = AndroidUtilities.dp(128);
timeX = AndroidUtilities.dp(132);
} else {
avatarImage.imageX = AndroidUtilities.dp(16);
x = AndroidUtilities.dp(16);
seekBarX = AndroidUtilities.dp(106);
buttonX = AndroidUtilities.dp(76);
timeX = AndroidUtilities.dp(80);
}
}
avatarImage.imageY = AndroidUtilities.dp(9);
avatarImage.imageW = AndroidUtilities.dp(50);
avatarImage.imageH = AndroidUtilities.dp(50);
avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(50), AndroidUtilities.dp(50));
seekBar.width = backgroundWidth - AndroidUtilities.dp(112);
seekBar.height = AndroidUtilities.dp(30);
......@@ -331,7 +333,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
@Override
protected boolean isUserDataChanged() {
TLRPC.User newUser = MessagesController.getInstance().users.get(currentMessageObject.messageOwner.media.audio.user_id);
TLRPC.User newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.media.audio.user_id);
TLRPC.FileLocation newPhoto = null;
if (avatarImage != null && newUser != null && newUser.photo != null) {
......@@ -348,7 +350,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if (uid == 0) {
uid = messageObject.messageOwner.from_id;
}
audioUser = MessagesController.getInstance().users.get(uid);
audioUser = MessagesController.getInstance().getUser(uid);
if (audioUser != null) {
if (audioUser.photo != null) {
currentPhoto = audioUser.photo.photo_small;
......@@ -379,7 +381,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
return;
}
avatarImage.draw(canvas, avatarImage.imageX, avatarImage.imageY, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
avatarImage.draw(canvas, avatarImage.getImageX(), avatarImage.getImageY(), AndroidUtilities.dp(50), AndroidUtilities.dp(50));
canvas.save();
if (buttonState == 0 || buttonState == 1) {
......
......@@ -16,7 +16,7 @@ import android.view.MotionEvent;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog;
import org.telegram.objects.MessageObject;
import org.telegram.android.MessageObject;
public class ChatMessageCell extends ChatBaseCell {
......
......@@ -26,7 +26,7 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.ImageReceiver;
import org.telegram.android.ImageReceiver;
public class ChatOrUserCell extends BaseCell {
private static TextPaint namePaint;
......@@ -104,8 +104,7 @@ public class ChatOrUserCell extends BaseCell {
}
if (avatarImage == null) {
avatarImage = new ImageReceiver();
avatarImage.parentView = this;
avatarImage = new ImageReceiver(this);
}
if (cellLayout == null) {
......@@ -404,10 +403,7 @@ public class ChatOrUserCell extends BaseCell {
} else {
avatarLeft = width - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
}
avatarImage.imageX = avatarLeft;
avatarImage.imageY = avatarTop;
avatarImage.imageW = AndroidUtilities.dp(50);
avatarImage.imageH = AndroidUtilities.dp(50);
avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
double widthpx = 0;
float left = 0;
......
......@@ -73,7 +73,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false);
TLRPC.Chat currentChat = MessagesController.getInstance().chats.get(chat_id);
TLRPC.Chat currentChat = MessagesController.getInstance().getChat(chat_id);
firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
if (chat_id > 0) {
......
......@@ -314,7 +314,7 @@ public class CountrySelectActivity extends BaseFragment {
}
private void updateSearchResults(final ArrayList<Country> arrCounties) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
searchResult = arrCounties;
......
......@@ -62,10 +62,10 @@ public class IdenticonActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view);
TextView textView = (TextView)fragmentView.findViewById(R.id.identicon_text);
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().encryptedChats.get(chat_id);
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
if (encryptedChat != null) {
identiconView.setBytes(encryptedChat.auth_key);
TLRPC.User user = MessagesController.getInstance().users.get(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)));
}
} else {
......@@ -97,7 +97,7 @@ public class IdenticonActivity extends BaseFragment {
if (fragmentView != null) {
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
}
if (getParentActivity() == null) {
if (getParentActivity() == null || fragmentView == null) {
return true;
}
LinearLayout layout = (LinearLayout)fragmentView;
......
......@@ -257,7 +257,7 @@ public class LanguageSelectActivity extends BaseFragment {
}
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) {
Utilities.RunOnUIThread(new Runnable() {
AndroidUtilities.RunOnUIThread(new Runnable() {
@Override
public void run() {
searchResult = arrCounties;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment