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) { ...@@ -17,7 +17,7 @@ tasks.withType(JavaCompile) {
} }
dependencies { 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 'com.google.android.gms:play-services:3.2.+'
compile 'net.hockeyapp.android:HockeySDK:3.0.1' compile 'net.hockeyapp.android:HockeySDK:3.0.1'
compile 'com.googlecode.mp4parser:isoparser:1.0.+' compile 'com.googlecode.mp4parser:isoparser:1.0.+'
...@@ -27,9 +27,6 @@ android { ...@@ -27,9 +27,6 @@ android {
compileSdkVersion 19 compileSdkVersion 19
buildToolsVersion '19.1.0' buildToolsVersion '19.1.0'
useAaptPngCruncher = true
useOldManifestMerger true
signingConfigs { signingConfigs {
debug { debug {
storeFile file("config/debug.keystore") storeFile file("config/debug.keystore")
...@@ -83,7 +80,7 @@ android { ...@@ -83,7 +80,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 19 targetSdkVersion 19
versionCode 307 versionCode 308
versionName "1.7.0" versionName "1.8.0"
} }
} }
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
</service> </service>
<service android:name="org.telegram.android.NotificationsService" android:enabled="true"/> <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"> <receiver android:name="org.telegram.android.AppStartReceiver" android:enabled="true">
<intent-filter> <intent-filter>
......
...@@ -225,4 +225,8 @@ public class AndroidUtilities { ...@@ -225,4 +225,8 @@ public class AndroidUtilities {
public static long makeBroadcastId(int id) { public static long makeBroadcastId(int id) {
return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL); return 0x0000000100000000L | ((long)id & 0x00000000FFFFFFFFL);
} }
public static void RunOnUIThread(Runnable runnable) {
ApplicationLoader.applicationHandler.post(runnable);
}
} }
...@@ -12,12 +12,11 @@ import android.content.BroadcastReceiver; ...@@ -12,12 +12,11 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
public class AppStartReceiver extends BroadcastReceiver { public class AppStartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
ApplicationLoader.startPushService(); 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; ...@@ -27,7 +27,6 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
...@@ -271,11 +270,11 @@ public class Emoji { ...@@ -271,11 +270,11 @@ public class Emoji {
Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, 0, width, height); Utilities.loadBitmap(imageFile.getAbsolutePath(), bitmap, imageResize, 0, width, height);
final EmojiBitmap emojiBitmap = new EmojiBitmap(bitmap, width, height); final EmojiBitmap emojiBitmap = new EmojiBitmap(bitmap, width, height);
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
emojiBmp[page] = emojiBitmap; emojiBmp[page] = emojiBitmap;
NotificationCenter.getInstance().postNotificationName(999); NotificationCenter.getInstance().postNotificationName(NotificationCenter.emojiDidLoaded);
} }
}); });
} catch(Throwable x) { } catch(Throwable x) {
......
...@@ -29,7 +29,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver { ...@@ -29,7 +29,7 @@ public class GcmBroadcastReceiver extends BroadcastReceiver {
FileLog.d("tmessages", "GCM received intent: " + intent); FileLog.d("tmessages", "GCM received intent: " + intent);
if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) { if (intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
ApplicationLoader.postInitApplication(); ApplicationLoader.postInitApplication();
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013. * Copyright Nikolai Kudashov, 2013.
*/ */
package org.telegram.ui.Views; package org.telegram.android;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
...@@ -16,7 +16,6 @@ import android.graphics.drawable.Drawable; ...@@ -16,7 +16,6 @@ import android.graphics.drawable.Drawable;
import android.view.View; import android.view.View;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
...@@ -29,13 +28,21 @@ public class ImageReceiver { ...@@ -29,13 +28,21 @@ public class ImageReceiver {
private String currentPath = null; private String currentPath = null;
private boolean isPlaceholder = false; private boolean isPlaceholder = false;
private Drawable currentImage = null; private Drawable currentImage = null;
public Integer TAG = null; private Integer tag = null;
public View parentView = null; private View parentView = null;
public int imageX = 0, imageY = 0, imageW = 0, imageH = 0; private int imageX = 0, imageY = 0, imageW = 0, imageH = 0;
public Rect drawRegion = new Rect(); private Rect drawRegion = new Rect();
private boolean isVisible = true; private boolean isVisible = true;
private boolean selfSetting = false; 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) { public void setImage(TLRPC.FileLocation path, String filter, Drawable placeholder) {
setImage(path, null, filter, placeholder, 0); setImage(path, null, filter, placeholder, 0);
...@@ -49,8 +56,8 @@ public class ImageReceiver { ...@@ -49,8 +56,8 @@ public class ImageReceiver {
setImage(null, path, filter, placeholder, 0); setImage(null, path, filter, placeholder, 0);
} }
public void setImage(TLRPC.FileLocation path, String httpUrl, String filter, Drawable placeholder, int size) { public void setImage(TLRPC.FileLocation fileLocation, 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))) { if ((fileLocation == null && httpUrl == null) || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
recycleBitmap(null); recycleBitmap(null);
currentPath = null; currentPath = null;
isPlaceholder = true; isPlaceholder = true;
...@@ -60,44 +67,44 @@ public class ImageReceiver { ...@@ -60,44 +67,44 @@ public class ImageReceiver {
last_placeholder = placeholder; last_placeholder = placeholder;
last_size = 0; last_size = 0;
currentImage = null; currentImage = null;
FileLoader.getInstance().cancelLoadingForImageView(this); ImageLoader.getInstance().cancelLoadingForImageView(this);
if (parentView != null) { if (parentView != null) {
parentView.invalidate(); parentView.invalidate();
} }
return; return;
} }
String key; String key;
if (path != null) { if (fileLocation != null) {
key = path.volume_id + "_" + path.local_id; key = fileLocation.volume_id + "_" + fileLocation.local_id;
} else { } else {
key = Utilities.MD5(httpUrl); key = Utilities.MD5(httpUrl);
} }
if (filter != null) { if (filter != null) {
key += "@" + filter; key += "@" + filter;
} }
Bitmap img = null; BitmapDrawable img = null;
if (currentPath != null) { if (currentPath != null) {
if (currentPath.equals(key)) { if (currentPath.equals(key)) {
if (currentImage != null) { if (currentImage != null) {
return; return;
} else { } else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter); img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
} }
} else { } else {
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter); img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
recycleBitmap(img); recycleBitmap(img);
} }
} }
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter); img = ImageLoader.getInstance().getImageFromMemory(fileLocation, httpUrl, filter);
currentPath = key; currentPath = key;
last_path = path; last_path = fileLocation;
last_httpUrl = httpUrl; last_httpUrl = httpUrl;
last_filter = filter; last_filter = filter;
last_placeholder = placeholder; last_placeholder = placeholder;
last_size = size; last_size = size;
if (img == null) { if (img == null) {
isPlaceholder = true; isPlaceholder = true;
FileLoader.getInstance().loadImage(path, httpUrl, this, filter, true, size); ImageLoader.getInstance().loadImage(fileLocation, httpUrl, this, size);
} else { } else {
selfSetting = true; selfSetting = true;
setImageBitmap(img, currentPath); setImageBitmap(img, currentPath);
...@@ -108,20 +115,20 @@ public class ImageReceiver { ...@@ -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)) { if (currentPath == null || !imgKey.equals(currentPath)) {
return; return;
} }
isPlaceholder = false; isPlaceholder = false;
FileLoader.getInstance().incrementUseCount(currentPath); ImageLoader.getInstance().incrementUseCount(currentPath);
currentImage = new BitmapDrawable(null, bitmap); currentImage = bitmap;
if (!selfSetting && parentView != null) { if (!selfSetting && parentView != null) {
parentView.invalidate(); parentView.invalidate();
} }
} }
public void setImageBitmap(Bitmap bitmap) { public void setImageBitmap(Bitmap bitmap) {
FileLoader.getInstance().cancelLoadingForImageView(this); ImageLoader.getInstance().cancelLoadingForImageView(this);
recycleBitmap(null); recycleBitmap(null);
if (bitmap != null) { if (bitmap != null) {
last_placeholder = new BitmapDrawable(null, bitmap); last_placeholder = new BitmapDrawable(null, bitmap);
...@@ -141,7 +148,7 @@ public class ImageReceiver { ...@@ -141,7 +148,7 @@ public class ImageReceiver {
} }
public void setImageBitmap(Drawable bitmap) { public void setImageBitmap(Drawable bitmap) {
FileLoader.getInstance().cancelLoadingForImageView(this); ImageLoader.getInstance().cancelLoadingForImageView(this);
recycleBitmap(null); recycleBitmap(null);
last_placeholder = bitmap; last_placeholder = bitmap;
isPlaceholder = true; isPlaceholder = true;
...@@ -160,18 +167,18 @@ public class ImageReceiver { ...@@ -160,18 +167,18 @@ public class ImageReceiver {
recycleBitmap(null); recycleBitmap(null);
} }
private void recycleBitmap(Bitmap newBitmap) { private void recycleBitmap(BitmapDrawable newBitmap) {
if (currentImage == null || isPlaceholder) { if (currentImage == null || isPlaceholder) {
return; return;
} }
if (currentImage instanceof BitmapDrawable) { if (currentImage instanceof BitmapDrawable) {
Bitmap bitmap = ((BitmapDrawable)currentImage).getBitmap(); if (currentImage != newBitmap) {
if (bitmap != null && bitmap != newBitmap) {
if (currentPath != null) { if (currentPath != null) {
boolean canDelete = FileLoader.getInstance().decrementUseCount(currentPath); Bitmap bitmap = ((BitmapDrawable) currentImage).getBitmap();
if (!FileLoader.getInstance().isInCache(currentPath)) { boolean canDelete = ImageLoader.getInstance().decrementUseCount(currentPath);
if (FileLoader.getInstance().runtimeHack != null) { if (!ImageLoader.getInstance().isInCache(currentPath)) {
FileLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight()); if (ImageLoader.getInstance().runtimeHack != null) {
ImageLoader.getInstance().runtimeHack.trackAlloc(bitmap.getRowBytes() * bitmap.getHeight());
} }
if (canDelete) { if (canDelete) {
currentImage = null; currentImage = null;
...@@ -242,7 +249,7 @@ public class ImageReceiver { ...@@ -242,7 +249,7 @@ public class ImageReceiver {
} }
} catch (Exception e) { } catch (Exception e) {
if (currentPath != null) { if (currentPath != null) {
FileLoader.getInstance().removeImage(currentPath); ImageLoader.getInstance().removeImage(currentPath);
currentPath = null; currentPath = null;
} }
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size); setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_size);
...@@ -276,4 +283,59 @@ public class ImageReceiver { ...@@ -276,4 +283,59 @@ public class ImageReceiver {
public boolean hasImage() { public boolean hasImage() {
return currentImage != null || last_placeholder != null || currentPath != null || last_httpUrl != null; 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 @@ ...@@ -6,9 +6,9 @@
* Copyright Nikolai Kudashov, 2013. * 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.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -22,7 +22,7 @@ import java.util.Map; ...@@ -22,7 +22,7 @@ import java.util.Map;
* overview. * overview.
*/ */
public class LruCache { public class LruCache {
private final LinkedHashMap<String, Bitmap> map; private final LinkedHashMap<String, BitmapDrawable> map;
private final LinkedHashMap<String, ArrayList<String>> mapFilters; private final LinkedHashMap<String, ArrayList<String>> mapFilters;
/** Size of this cache in units. Not necessarily the number of elements. */ /** Size of this cache in units. Not necessarily the number of elements. */
...@@ -44,7 +44,7 @@ public class LruCache { ...@@ -44,7 +44,7 @@ public class LruCache {
throw new IllegalArgumentException("maxSize <= 0"); throw new IllegalArgumentException("maxSize <= 0");
} }
this.maxSize = maxSize; 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>>(); this.mapFilters = new LinkedHashMap<String, ArrayList<String>>();
} }
...@@ -54,12 +54,12 @@ public class LruCache { ...@@ -54,12 +54,12 @@ public class LruCache {
* head of the queue. This returns null if a value is not cached and cannot * head of the queue. This returns null if a value is not cached and cannot
* be created. * be created.
*/ */
public final Bitmap get(String key) { public final BitmapDrawable get(String key) {
if (key == null) { if (key == null) {
throw new NullPointerException("key == null"); throw new NullPointerException("key == null");
} }
Bitmap mapValue; BitmapDrawable mapValue;
synchronized (this) { synchronized (this) {
mapValue = map.get(key); mapValue = map.get(key);
if (mapValue != null) { if (mapValue != null) {
...@@ -85,12 +85,12 @@ public class LruCache { ...@@ -85,12 +85,12 @@ public class LruCache {
* *
* @return the previous value mapped by {@code key}. * @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) { if (key == null || value == null) {
throw new NullPointerException("key == null || value == null"); throw new NullPointerException("key == null || value == null");
} }
Bitmap previous; BitmapDrawable previous;
synchronized (this) { synchronized (this) {
putCount++; putCount++;
size += safeSizeOf(key, value); size += safeSizeOf(key, value);
...@@ -125,7 +125,7 @@ public class LruCache { ...@@ -125,7 +125,7 @@ public class LruCache {
private void trimToSize(int maxSize) { private void trimToSize(int maxSize) {
while (true) { while (true) {
String key; String key;
Bitmap value; BitmapDrawable value;
synchronized (this) { synchronized (this) {
if (size < 0 || (map.isEmpty() && size != 0)) { if (size < 0 || (map.isEmpty() && size != 0)) {
throw new IllegalStateException(getClass().getName() throw new IllegalStateException(getClass().getName()
...@@ -136,7 +136,7 @@ public class LruCache { ...@@ -136,7 +136,7 @@ public class LruCache {
break; break;
} }
Map.Entry<String, Bitmap> toEvict = map.entrySet().iterator().next(); Map.Entry<String, BitmapDrawable> toEvict = map.entrySet().iterator().next();
key = toEvict.getKey(); key = toEvict.getKey();
value = toEvict.getValue(); value = toEvict.getValue();
map.remove(key); map.remove(key);
...@@ -164,12 +164,12 @@ public class LruCache { ...@@ -164,12 +164,12 @@ public class LruCache {
* *
* @return the previous value mapped by {@code key}. * @return the previous value mapped by {@code key}.
*/ */
public final Bitmap remove(String key) { public final BitmapDrawable remove(String key) {
if (key == null) { if (key == null) {
throw new NullPointerException("key == null"); throw new NullPointerException("key == null");
} }
Bitmap previous; BitmapDrawable previous;
synchronized (this) { synchronized (this) {
previous = map.remove(key); previous = map.remove(key);
if (previous != null) { if (previous != null) {
...@@ -214,9 +214,9 @@ public class LruCache { ...@@ -214,9 +214,9 @@ public class LruCache {
* this removal was caused by a {@link #put}. Otherwise it was caused by * this removal was caused by a {@link #put}. Otherwise it was caused by
* an eviction or a {@link #remove}. * 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); int result = sizeOf(key, value);
if (result < 0) { if (result < 0) {
throw new IllegalStateException("Negative size: " + key + "=" + value); throw new IllegalStateException("Negative size: " + key + "=" + value);
...@@ -231,7 +231,7 @@ public class LruCache { ...@@ -231,7 +231,7 @@ public class LruCache {
* *
* <p>An entry's size must not change while it is in the cache. * <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; return 1;
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Copyright Nikolai Kudashov, 2013. * Copyright Nikolai Kudashov, 2013.
*/ */
package org.telegram.objects; package org.telegram.android;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Paint; import android.graphics.Paint;
...@@ -16,13 +16,9 @@ import android.text.StaticLayout; ...@@ -16,13 +16,9 @@ import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.text.util.Linkify; import android.text.util.Linkify;
import org.telegram.android.AndroidUtilities; import org.telegram.messenger.FileLoader;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.android.LocaleController;
import org.telegram.messenger.TLObject;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.Emoji;
import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
...@@ -33,6 +29,11 @@ import java.util.Calendar; ...@@ -33,6 +29,11 @@ import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
public class MessageObject { 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 TLRPC.Message messageOwner;
public CharSequence messageText; public CharSequence messageText;
public int type; public int type;
...@@ -78,9 +79,12 @@ public class MessageObject { ...@@ -78,9 +79,12 @@ public class MessageObject {
if (message instanceof TLRPC.TL_messageService) { if (message instanceof TLRPC.TL_messageService) {
if (message.action != null) { 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) { 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 (message.action instanceof TLRPC.TL_messageActionChatCreate) {
if (isFromMe()) { if (isFromMe()) {
...@@ -104,9 +108,12 @@ public class MessageObject { ...@@ -104,9 +108,12 @@ public class MessageObject {
} }
} }
} else { } 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) { 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 (who != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
...@@ -121,9 +128,12 @@ public class MessageObject { ...@@ -121,9 +128,12 @@ public class MessageObject {
} }
} }
} else if (message.action instanceof TLRPC.TL_messageActionChatAddUser) { } 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) { 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 (whoUser != null && fromUser != null) {
if (isFromMe()) { if (isFromMe()) {
...@@ -389,50 +399,19 @@ public class MessageObject { ...@@ -389,50 +399,19 @@ public class MessageObject {
public String getFileName() { public String getFileName() {
if (messageOwner.media instanceof TLRPC.TL_messageMediaVideo) { 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) { } 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) { } 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) { } else if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes; ArrayList<TLRPC.PhotoSize> sizes = messageOwner.media.photo.sizes;
if (sizes.size() > 0) { if (sizes.size() > 0) {
TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800); TLRPC.PhotoSize sizeFull = PhotoObject.getClosestPhotoSizeWithSize(sizes, 800, 800);
if (sizeFull != null) { 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 ""; return "";
} }
......
...@@ -6,13 +6,62 @@ ...@@ -6,13 +6,62 @@
* Copyright Nikolai Kudashov, 2013. * Copyright Nikolai Kudashov, 2013.
*/ */
package org.telegram.messenger; package org.telegram.android;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
public class NotificationCenter { 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, ArrayList<Object>> observers = new HashMap<Integer, ArrayList<Object>>();
final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<Integer, 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 @@ ...@@ -6,13 +6,12 @@
* Copyright Nikolai Kudashov, 2013. * Copyright Nikolai Kudashov, 2013.
*/ */
package org.telegram.objects; package org.telegram.android;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.messenger.FileLoader;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -35,8 +34,8 @@ public class PhotoObject { ...@@ -35,8 +34,8 @@ public class PhotoObject {
if (preview == 2) { if (preview == 2) {
Utilities.blurBitmap(image, image.getWidth(), image.getHeight(), image.getRowBytes()); Utilities.blurBitmap(image, image.getWidth(), image.getHeight(), image.getRowBytes());
} }
if (FileLoader.getInstance().runtimeHack != null) { if (ImageLoader.getInstance().runtimeHack != null) {
FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); ImageLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight());
} }
} }
} }
......
...@@ -16,7 +16,6 @@ import android.os.Bundle; ...@@ -16,7 +16,6 @@ import android.os.Bundle;
import android.telephony.SmsMessage; import android.telephony.SmsMessage;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.NotificationCenter;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
......
...@@ -17,8 +17,10 @@ import android.os.Build; ...@@ -17,8 +17,10 @@ import android.os.Build;
import android.os.PowerManager; import android.os.PowerManager;
import android.util.Base64; import android.util.Base64;
import org.telegram.android.AndroidUtilities;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.android.NotificationCenter;
import org.telegram.ui.ApplicationLoader; import org.telegram.ui.ApplicationLoader;
import java.io.File; import java.io.File;
...@@ -456,7 +458,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -456,7 +458,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
datacenter = new Datacenter(); datacenter = new Datacenter();
datacenter.datacenterId = 5; datacenter.datacenterId = 5;
datacenter.addAddressAndPort("116.51.22.2", 443); datacenter.addAddressAndPort("149.154.171.5", 443);
datacenters.put(datacenter.datacenterId, datacenter); datacenters.put(datacenter.datacenterId, datacenter);
} else { } else {
Datacenter datacenter = new Datacenter(); Datacenter datacenter = new Datacenter();
...@@ -643,7 +645,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -643,7 +645,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public void bindRequestToGuid(final Long request, final int guid) { public void bindRequestToGuid(final Long request, final int guid) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
ArrayList<Long> requests = requestsByGuids.get(guid); ArrayList<Long> requests = requestsByGuids.get(guid);
...@@ -656,7 +658,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -656,7 +658,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
public void removeRequestInClass(final Long request) { public void removeRequestInClass(final Long request) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
Integer guid = requestsByClass.get(request); Integer guid = requestsByClass.get(request);
...@@ -964,6 +966,19 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -964,6 +966,19 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
return false; 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() { public static boolean isConnectedToWiFi() {
try { try {
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
...@@ -2094,7 +2109,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2094,7 +2109,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} else { } else {
if (resultContainer.result instanceof TLRPC.updates_Difference) { if (resultContainer.result instanceof TLRPC.updates_Difference) {
pushMessagesReceived = true; pushMessagesReceived = true;
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (wakeLock.isHeld()) { if (wakeLock.isHeld()) {
...@@ -2113,10 +2128,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2113,10 +2128,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) { if ((request.flags & RPCRequest.RPCRequestClassGeneric) != 0) {
if (UserConfig.isClientActivated()) { if (UserConfig.isClientActivated()) {
UserConfig.clearConfig(); UserConfig.clearConfig();
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
NotificationCenter.getInstance().postNotificationName(1234); NotificationCenter.getInstance().postNotificationName(NotificationCenter.appDidLogout);
} }
}); });
} }
...@@ -2272,7 +2287,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2272,7 +2287,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (paused) { if (paused) {
pushMessagesReceived = false; pushMessagesReceived = false;
} }
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
wakeLock.acquire(20000); wakeLock.acquire(20000);
...@@ -2281,7 +2296,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2281,7 +2296,7 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
resumeNetworkInternal(); resumeNetworkInternal();
} else { } else {
pushMessagesReceived = true; pushMessagesReceived = true;
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (wakeLock.isHeld()) { if (wakeLock.isHeld()) {
...@@ -2386,10 +2401,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2386,10 +2401,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
} }
} }
final int stateCopy = connectionState; final int stateCopy = connectionState;
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
NotificationCenter.getInstance().postNotificationName(703, stateCopy); NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
} }
}); });
} else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) { } else if ((connection.transportRequestClass & RPCRequest.RPCRequestClassPush) != 0) {
...@@ -2435,10 +2450,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection. ...@@ -2435,10 +2450,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (ConnectionsManager.getInstance().connectionState == 3 && !MessagesController.getInstance().gettingDifference && !MessagesController.getInstance().gettingDifferenceAgain) { if (ConnectionsManager.getInstance().connectionState == 3 && !MessagesController.getInstance().gettingDifference && !MessagesController.getInstance().gettingDifferenceAgain) {
ConnectionsManager.getInstance().connectionState = 0; ConnectionsManager.getInstance().connectionState = 0;
final int stateCopy = ConnectionsManager.getInstance().connectionState; final int stateCopy = ConnectionsManager.getInstance().connectionState;
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { 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. ...@@ -2451,10 +2466,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
if (connectionState == 1 || connectionState == 2) { if (connectionState == 1 || connectionState == 2) {
connectionState = 3; connectionState = 3;
final int stateCopy = connectionState; final int stateCopy = connectionState;
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
NotificationCenter.getInstance().postNotificationName(703, stateCopy); NotificationCenter.getInstance().postNotificationName(NotificationCenter.didUpdatedConnectionState, stateCopy);
} }
}); });
} }
......
...@@ -420,6 +420,7 @@ public class TLClassStore { ...@@ -420,6 +420,7 @@ public class TLClassStore {
classStore.put(TLRPC.TL_notifyChats.constructor, TLRPC.TL_notifyChats.class); classStore.put(TLRPC.TL_notifyChats.constructor, TLRPC.TL_notifyChats.class);
classStore.put(TLRPC.TL_notifyUsers.constructor, TLRPC.TL_notifyUsers.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_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_msg_container.constructor, TLRPC.TL_msg_container.class);
classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class); classStore.put(TLRPC.TL_fileEncryptedLocation.constructor, TLRPC.TL_fileEncryptedLocation.class);
......
...@@ -1988,17 +1988,6 @@ public class TLRPC { ...@@ -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 class TL_userContact extends User {
public static int constructor = 0xf2fb8319; public static int constructor = 0xf2fb8319;
...@@ -7443,6 +7432,32 @@ public class TLRPC { ...@@ -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 class TL_photos_uploadProfilePhoto extends TLObject {
public static int constructor = 0xd50f9c88; public static int constructor = 0xd50f9c88;
...@@ -8697,6 +8712,17 @@ public class TLRPC { ...@@ -8697,6 +8712,17 @@ public class TLRPC {
public ArrayList<Object> objects = new ArrayList<Object>(); 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 class TL_userEmpty extends User {
public static int constructor = 0x200250ba; public static int constructor = 0x200250ba;
...@@ -8860,6 +8886,7 @@ public class TLRPC { ...@@ -8860,6 +8886,7 @@ public class TLRPC {
public int last_message_date; public int last_message_date;
public long id; public long id;
public int last_read; public int last_read;
public int flags;
public void readParams(AbsSerializedData stream) { public void readParams(AbsSerializedData stream) {
peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32()); peer = (Peer)TLClassStore.Instance().TLdeserialize(stream, stream.readInt32());
......
...@@ -27,6 +27,7 @@ public class UserConfig { ...@@ -27,6 +27,7 @@ public class UserConfig {
public static int lastBroadcastId = -1; public static int lastBroadcastId = -1;
public static String contactsHash = ""; public static String contactsHash = "";
public static String importHash = ""; public static String importHash = "";
public static boolean blockedUsersLoaded = false;
private final static Integer sync = 1; private final static Integer sync = 1;
public static boolean saveIncomingPhotos = false; public static boolean saveIncomingPhotos = false;
public static int contactsVersion = 1; public static int contactsVersion = 1;
...@@ -59,6 +60,7 @@ public class UserConfig { ...@@ -59,6 +60,7 @@ public class UserConfig {
editor.putInt("contactsVersion", contactsVersion); editor.putInt("contactsVersion", contactsVersion);
editor.putInt("lastBroadcastId", lastBroadcastId); editor.putInt("lastBroadcastId", lastBroadcastId);
editor.putBoolean("registeredForInternalPush", registeredForInternalPush); editor.putBoolean("registeredForInternalPush", registeredForInternalPush);
editor.putBoolean("blockedUsersLoaded", blockedUsersLoaded);
if (currentUser != null) { if (currentUser != null) {
if (withFile) { if (withFile) {
SerializedData data = new SerializedData(); SerializedData data = new SerializedData();
...@@ -178,6 +180,7 @@ public class UserConfig { ...@@ -178,6 +180,7 @@ public class UserConfig {
contactsVersion = preferences.getInt("contactsVersion", 0); contactsVersion = preferences.getInt("contactsVersion", 0);
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);
String user = preferences.getString("user", null); String user = preferences.getString("user", null);
if (user != null) { if (user != null) {
byte[] userBytes = Base64.decode(user, Base64.DEFAULT); byte[] userBytes = Base64.decode(user, Base64.DEFAULT);
...@@ -201,6 +204,7 @@ public class UserConfig { ...@@ -201,6 +204,7 @@ public class UserConfig {
contactsVersion = 1; contactsVersion = 1;
lastBroadcastId = -1; lastBroadcastId = -1;
saveIncomingPhotos = false; saveIncomingPhotos = false;
blockedUsersLoaded = false;
saveConfig(true); saveConfig(true);
} }
} }
...@@ -62,7 +62,6 @@ import javax.crypto.Cipher; ...@@ -62,7 +62,6 @@ import javax.crypto.Cipher;
public class Utilities { public class Utilities {
public static Pattern pattern = Pattern.compile("[0-9]+"); public static Pattern pattern = Pattern.compile("[0-9]+");
public static SecureRandom random = new SecureRandom(); public static SecureRandom random = new SecureRandom();
private final static Integer lock = 1;
public static ArrayList<String> goodPrimes = new ArrayList<String>(); public static ArrayList<String> goodPrimes = new ArrayList<String>();
...@@ -501,12 +500,6 @@ public class Utilities { ...@@ -501,12 +500,6 @@ public class Utilities {
return true; return true;
} }
public static void RunOnUIThread(Runnable runnable) {
synchronized (lock) {
ApplicationLoader.applicationHandler.post(runnable);
}
}
public static int getColorIndex(int id) { public static int getColorIndex(int id) {
int[] arr; int[] arr;
if (id >= 0) { if (id >= 0) {
...@@ -759,7 +752,7 @@ public class Utilities { ...@@ -759,7 +752,7 @@ public class Utilities {
String result = firstName; String result = firstName;
if (result == null || result.length() == 0) { if (result == null || result.length() == 0) {
result = lastName; result = lastName;
} else if (result.length() != 0 && lastName.length() != 0) { } else if (result.length() != 0 && lastName != null && lastName.length() != 0) {
result += " " + lastName; result += " " + lastName;
} }
return result.trim(); return result.trim();
......
...@@ -86,7 +86,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter { ...@@ -86,7 +86,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter {
if (usersAsSections) { if (usersAsSections) {
if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) { if (section < ContactsController.getInstance().sortedUsersSectionsArray.size()) {
ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance().usersSectionsDict.get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); 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(); count = arr.size();
} }
} else { } else {
...@@ -106,7 +106,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter { ...@@ -106,7 +106,7 @@ public class ContactsActivityAdapter extends SectionedBaseAdapter {
} }
return convertView; 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(); count = ContactsController.getInstance().contacts.size();
} }
} }
......
...@@ -12,6 +12,7 @@ import android.content.Context; ...@@ -12,6 +12,7 @@ import android.content.Context;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.TLRPC; import org.telegram.messenger.TLRPC;
import org.telegram.android.ContactsController; import org.telegram.android.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
...@@ -67,7 +68,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -67,7 +68,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
} }
private void processSearch(final String query) { private void processSearch(final String query) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>(); final ArrayList<TLRPC.TL_contact> contactsCopy = new ArrayList<TLRPC.TL_contact>();
...@@ -85,7 +86,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -85,7 +86,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>(); ArrayList<CharSequence> resultArrayNames = new ArrayList<CharSequence>();
for (TLRPC.TL_contact contact : contactsCopy) { 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.first_name != null && user.first_name.toLowerCase().startsWith(q) || user.last_name != null && user.last_name.toLowerCase().startsWith(q)) {
if (user.id == UserConfig.getClientUserId()) { if (user.id == UserConfig.getClientUserId()) {
continue; continue;
...@@ -103,7 +104,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -103,7 +104,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
} }
private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) { private void updateSearchResults(final ArrayList<TLRPC.User> users, final ArrayList<CharSequence> names) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
searchResult = users; searchResult = users;
...@@ -161,7 +162,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter { ...@@ -161,7 +162,7 @@ public class ContactsActivitySearchAdapter extends BaseFragmentAdapter {
((ChatOrUserCell) view).useSeparator = i != searchResult.size() - 1; ((ChatOrUserCell) view).useSeparator = i != searchResult.size() - 1;
Object obj = searchResult.get(i); 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) { if (user != null) {
((ChatOrUserCell)view).setData(user, null, null, searchResultNames.get(i), null); ((ChatOrUserCell)view).setData(user, null, null, searchResultNames.get(i), null);
......
...@@ -30,7 +30,9 @@ import com.google.android.gms.gcm.GoogleCloudMessaging; ...@@ -30,7 +30,9 @@ 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.NotificationsService;
import org.telegram.android.SendMessagesHelper;
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;
...@@ -92,9 +94,11 @@ public class ApplicationLoader extends Application { ...@@ -92,9 +94,11 @@ public class ApplicationLoader extends Application {
UserConfig.loadConfig(); UserConfig.loadConfig();
if (UserConfig.getCurrentUser() != null) { 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().applyCountryPortNumber(UserConfig.getCurrentUser().phone);
ConnectionsManager.getInstance().initPushConnection(); ConnectionsManager.getInstance().initPushConnection();
MessagesController.getInstance().getBlockedUsers(true);
SendMessagesHelper.getInstance().checkUnsentMessages();
} }
ApplicationLoader app = (ApplicationLoader)ApplicationLoader.applicationContext; ApplicationLoader app = (ApplicationLoader)ApplicationLoader.applicationContext;
...@@ -102,6 +106,7 @@ public class ApplicationLoader extends Application { ...@@ -102,6 +106,7 @@ public class ApplicationLoader extends Application {
FileLog.e("tmessages", "app initied"); FileLog.e("tmessages", "app initied");
ContactsController.getInstance().checkAppAccount(); ContactsController.getInstance().checkAppAccount();
MediaController.getInstance();
} }
@Override @Override
...@@ -263,7 +268,7 @@ public class ApplicationLoader extends Application { ...@@ -263,7 +268,7 @@ public class ApplicationLoader extends Application {
UserConfig.registeredForPush = !isNew; UserConfig.registeredForPush = !isNew;
UserConfig.saveConfig(false); UserConfig.saveConfig(false);
if (UserConfig.getClientUserId() != 0) { if (UserConfig.getClientUserId() != 0) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
MessagesController.getInstance().registerForPush(regid); MessagesController.getInstance().registerForPush(regid);
......
...@@ -24,8 +24,8 @@ import org.telegram.messenger.TLRPC; ...@@ -24,8 +24,8 @@ import org.telegram.messenger.TLRPC;
import org.telegram.android.MessagesController; import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.objects.MessageObject; import org.telegram.android.MessageObject;
import org.telegram.ui.Views.ImageReceiver; import org.telegram.android.ImageReceiver;
import org.telegram.ui.Views.ProgressView; import org.telegram.ui.Views.ProgressView;
import org.telegram.ui.Views.SeekBar; import org.telegram.ui.Views.SeekBar;
...@@ -63,8 +63,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -63,8 +63,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
super(context, false); super(context, false);
TAG = MediaController.getInstance().generateObserverTag(); TAG = MediaController.getInstance().generateObserverTag();
avatarImage = new ImageReceiver(); avatarImage = new ImageReceiver(this);
avatarImage.parentView = this;
seekBar = new SeekBar(context); seekBar = new SeekBar(context);
seekBar.delegate = this; seekBar.delegate = this;
progressView = new ProgressView(); progressView = new ProgressView();
...@@ -120,7 +119,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -120,7 +119,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
buttonPressed = 1; buttonPressed = 1;
invalidate(); invalidate();
result = true; 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; avatarPressed = 1;
result = true; result = true;
} }
...@@ -149,7 +148,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -149,7 +148,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) { } else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
avatarPressed = 0; avatarPressed = 0;
} else if (event.getAction() == MotionEvent.ACTION_MOVE) { } 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; avatarPressed = 0;
} }
} }
...@@ -176,11 +175,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -176,11 +175,11 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
invalidate(); invalidate();
} }
} else if (buttonState == 2) { } else if (buttonState == 2) {
FileLoader.getInstance().loadFile(null, null, null, currentMessageObject.messageOwner.media.audio); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true);
buttonState = 3; buttonState = 3;
invalidate(); invalidate();
} else if (buttonState == 3) { } else if (buttonState == 3) {
FileLoader.getInstance().cancelLoadFile(null, null, null, currentMessageObject.messageOwner.media.audio); FileLoader.getInstance().cancelLoadFile(currentMessageObject.messageOwner.media.audio);
buttonState = 2; buttonState = 2;
invalidate(); invalidate();
} }
...@@ -211,7 +210,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -211,7 +210,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
public void downloadAudioIfNeed() { public void downloadAudioIfNeed() {
if (buttonState == 2) { if (buttonState == 2) {
FileLoader.getInstance().loadFile(null, null, null, currentMessageObject.messageOwner.media.audio); FileLoader.getInstance().loadFile(currentMessageObject.messageOwner.media.audio, true);
buttonState = 3; buttonState = 3;
invalidate(); invalidate();
} }
...@@ -236,7 +235,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -236,7 +235,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
progressView.setProgress(0); progressView.setProgress(0);
} else { } else {
buttonState = 3; buttonState = 3;
Float progress = FileLoader.getInstance().fileProgresses.get(fileName); Float progress = FileLoader.getInstance().getFileProgress(fileName);
if (progress != null) { if (progress != null) {
progressView.setProgress(progress); progressView.setProgress(progress);
} else { } else {
...@@ -260,6 +259,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -260,6 +259,9 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
@Override @Override
public void onProgressDownload(String fileName, float progress) { public void onProgressDownload(String fileName, float progress) {
progressView.setProgress(progress); progressView.setProgress(progress);
if (buttonState != 3) {
updateButtonState();
}
invalidate(); invalidate();
} }
...@@ -297,27 +299,27 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -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) { protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom); super.onLayout(changed, left, top, right, bottom);
int x;
if (currentMessageObject.isOut()) { if (currentMessageObject.isOut()) {
avatarImage.imageX = layoutWidth - backgroundWidth + AndroidUtilities.dp(9); x = layoutWidth - backgroundWidth + AndroidUtilities.dp(9);
seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(97); seekBarX = layoutWidth - backgroundWidth + AndroidUtilities.dp(97);
buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67); buttonX = layoutWidth - backgroundWidth + AndroidUtilities.dp(67);
timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(71); timeX = layoutWidth - backgroundWidth + AndroidUtilities.dp(71);
} else { } else {
if (isChat) { if (isChat) {
avatarImage.imageX = AndroidUtilities.dp(69); x = AndroidUtilities.dp(69);
seekBarX = AndroidUtilities.dp(158); seekBarX = AndroidUtilities.dp(158);
buttonX = AndroidUtilities.dp(128); buttonX = AndroidUtilities.dp(128);
timeX = AndroidUtilities.dp(132); timeX = AndroidUtilities.dp(132);
} else { } else {
avatarImage.imageX = AndroidUtilities.dp(16); x = AndroidUtilities.dp(16);
seekBarX = AndroidUtilities.dp(106); seekBarX = AndroidUtilities.dp(106);
buttonX = AndroidUtilities.dp(76); buttonX = AndroidUtilities.dp(76);
timeX = AndroidUtilities.dp(80); timeX = AndroidUtilities.dp(80);
} }
} }
avatarImage.imageY = AndroidUtilities.dp(9); avatarImage.setImageCoords(x, AndroidUtilities.dp(9), AndroidUtilities.dp(50), AndroidUtilities.dp(50));
avatarImage.imageW = AndroidUtilities.dp(50);
avatarImage.imageH = AndroidUtilities.dp(50);
seekBar.width = backgroundWidth - AndroidUtilities.dp(112); seekBar.width = backgroundWidth - AndroidUtilities.dp(112);
seekBar.height = AndroidUtilities.dp(30); seekBar.height = AndroidUtilities.dp(30);
...@@ -331,7 +333,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -331,7 +333,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
@Override @Override
protected boolean isUserDataChanged() { 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; TLRPC.FileLocation newPhoto = null;
if (avatarImage != null && newUser != null && newUser.photo != null) { if (avatarImage != null && newUser != null && newUser.photo != null) {
...@@ -348,7 +350,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -348,7 +350,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
if (uid == 0) { if (uid == 0) {
uid = messageObject.messageOwner.from_id; uid = messageObject.messageOwner.from_id;
} }
audioUser = MessagesController.getInstance().users.get(uid); audioUser = MessagesController.getInstance().getUser(uid);
if (audioUser != null) { if (audioUser != null) {
if (audioUser.photo != null) { if (audioUser.photo != null) {
currentPhoto = audioUser.photo.photo_small; currentPhoto = audioUser.photo.photo_small;
...@@ -379,7 +381,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega ...@@ -379,7 +381,7 @@ public class ChatAudioCell extends ChatBaseCell implements SeekBar.SeekBarDelega
return; 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(); canvas.save();
if (buttonState == 0 || buttonState == 1) { if (buttonState == 0 || buttonState == 1) {
......
...@@ -16,7 +16,7 @@ import android.view.MotionEvent; ...@@ -16,7 +16,7 @@ import android.view.MotionEvent;
import org.telegram.android.AndroidUtilities; import org.telegram.android.AndroidUtilities;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.objects.MessageObject; import org.telegram.android.MessageObject;
public class ChatMessageCell extends ChatBaseCell { public class ChatMessageCell extends ChatBaseCell {
......
...@@ -26,7 +26,7 @@ import org.telegram.android.MessagesController; ...@@ -26,7 +26,7 @@ import org.telegram.android.MessagesController;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities; import org.telegram.messenger.Utilities;
import org.telegram.ui.Views.ImageReceiver; import org.telegram.android.ImageReceiver;
public class ChatOrUserCell extends BaseCell { public class ChatOrUserCell extends BaseCell {
private static TextPaint namePaint; private static TextPaint namePaint;
...@@ -104,8 +104,7 @@ public class ChatOrUserCell extends BaseCell { ...@@ -104,8 +104,7 @@ public class ChatOrUserCell extends BaseCell {
} }
if (avatarImage == null) { if (avatarImage == null) {
avatarImage = new ImageReceiver(); avatarImage = new ImageReceiver(this);
avatarImage.parentView = this;
} }
if (cellLayout == null) { if (cellLayout == null) {
...@@ -404,10 +403,7 @@ public class ChatOrUserCell extends BaseCell { ...@@ -404,10 +403,7 @@ public class ChatOrUserCell extends BaseCell {
} else { } else {
avatarLeft = width - AndroidUtilities.dp(50 + (usePadding ? 11 : 0)); avatarLeft = width - AndroidUtilities.dp(50 + (usePadding ? 11 : 0));
} }
avatarImage.imageX = avatarLeft; avatarImage.setImageCoords(avatarLeft, avatarTop, AndroidUtilities.dp(50), AndroidUtilities.dp(50));
avatarImage.imageY = avatarTop;
avatarImage.imageW = AndroidUtilities.dp(50);
avatarImage.imageH = AndroidUtilities.dp(50);
double widthpx = 0; double widthpx = 0;
float left = 0; float left = 0;
......
...@@ -73,7 +73,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment { ...@@ -73,7 +73,7 @@ public class ChatProfileChangeNameActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.chat_profile_change_name_layout, container, false); 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); firstNameField = (EditText)fragmentView.findViewById(R.id.first_name_field);
if (chat_id > 0) { if (chat_id > 0) {
......
...@@ -314,7 +314,7 @@ public class CountrySelectActivity extends BaseFragment { ...@@ -314,7 +314,7 @@ public class CountrySelectActivity extends BaseFragment {
} }
private void updateSearchResults(final ArrayList<Country> arrCounties) { private void updateSearchResults(final ArrayList<Country> arrCounties) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
searchResult = arrCounties; searchResult = arrCounties;
......
...@@ -62,10 +62,10 @@ public class IdenticonActivity extends BaseFragment { ...@@ -62,10 +62,10 @@ public class IdenticonActivity extends BaseFragment {
fragmentView = inflater.inflate(R.layout.identicon_layout, container, false); fragmentView = inflater.inflate(R.layout.identicon_layout, container, false);
IdenticonView identiconView = (IdenticonView) fragmentView.findViewById(R.id.identicon_view); IdenticonView identiconView = (IdenticonView) 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().encryptedChats.get(chat_id); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id);
if (encryptedChat != null) { if (encryptedChat != null) {
identiconView.setBytes(encryptedChat.auth_key); 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))); textView.setText(Html.fromHtml(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name)));
} }
} else { } else {
...@@ -97,7 +97,7 @@ public class IdenticonActivity extends BaseFragment { ...@@ -97,7 +97,7 @@ public class IdenticonActivity extends BaseFragment {
if (fragmentView != null) { if (fragmentView != null) {
fragmentView.getViewTreeObserver().removeOnPreDrawListener(this); fragmentView.getViewTreeObserver().removeOnPreDrawListener(this);
} }
if (getParentActivity() == null) { if (getParentActivity() == null || fragmentView == null) {
return true; return true;
} }
LinearLayout layout = (LinearLayout)fragmentView; LinearLayout layout = (LinearLayout)fragmentView;
......
...@@ -257,7 +257,7 @@ public class LanguageSelectActivity extends BaseFragment { ...@@ -257,7 +257,7 @@ public class LanguageSelectActivity extends BaseFragment {
} }
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) { private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) {
Utilities.RunOnUIThread(new Runnable() { AndroidUtilities.RunOnUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
searchResult = arrCounties; 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