New photo viewer(close by swipe down, not tested on 2.x), optimize emoji load, fixed audio notes and typing in secret chats
https://github.com/DrKLO/Telegram/pull/443
|
@ -3,7 +3,7 @@ buildscript {
|
|||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:0.10.+'
|
||||
classpath 'com.android.tools.build:gradle:0.11.+'
|
||||
}
|
||||
}
|
||||
apply plugin: 'android'
|
||||
|
@ -18,7 +18,6 @@ tasks.withType(JavaCompile) {
|
|||
|
||||
dependencies {
|
||||
compile 'com.android.support:support-v4:19.0.+'
|
||||
compile 'com.android.support:appcompat-v7:19.0.+'
|
||||
compile 'com.google.android.gms:play-services:4.1.+'
|
||||
compile 'net.hockeyapp.android:HockeySDK:3.0.1'
|
||||
}
|
||||
|
@ -82,7 +81,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 8
|
||||
targetSdkVersion 19
|
||||
versionCode 240
|
||||
versionCode 243
|
||||
versionName "1.4.15"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,11 +100,6 @@
|
|||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
<activity
|
||||
android:name="org.telegram.ui.GalleryImageViewer"
|
||||
android:theme="@style/Theme.TMessages.Gallery"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
</activity>
|
||||
|
||||
<receiver android:name="org.telegram.messenger.SmsListener">
|
||||
<intent-filter>
|
||||
|
|
Before Width: | Height: | Size: 626 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_0.jpg
Normal file
After Width: | Height: | Size: 135 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_1.jpg
Normal file
After Width: | Height: | Size: 76 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_2.jpg
Normal file
After Width: | Height: | Size: 151 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_3.jpg
Normal file
After Width: | Height: | Size: 80 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_4.jpg
Normal file
After Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 283 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_a_0.jpg
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_a_1.jpg
Normal file
After Width: | Height: | Size: 40 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_a_2.jpg
Normal file
After Width: | Height: | Size: 73 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_a_3.jpg
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji2.0x_a_4.jpg
Normal file
After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 1.1 MiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_0.jpg
Normal file
After Width: | Height: | Size: 237 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_1.jpg
Normal file
After Width: | Height: | Size: 132 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_2.jpg
Normal file
After Width: | Height: | Size: 270 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_3.jpg
Normal file
After Width: | Height: | Size: 144 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_4.jpg
Normal file
After Width: | Height: | Size: 249 KiB |
Before Width: | Height: | Size: 481 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_a_0.jpg
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_a_1.jpg
Normal file
After Width: | Height: | Size: 67 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_a_2.jpg
Normal file
After Width: | Height: | Size: 122 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_a_3.jpg
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
TMessagesProj/src/main/assets/emoji/emoji3.0x_a_4.jpg
Normal file
After Width: | Height: | Size: 102 KiB |
|
@ -184,10 +184,10 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
if (paused) {
|
||||
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
|
||||
nextSleepTimeout = 30000;
|
||||
FileLog.e("tmessages", "wakeup network in background by recieved push");
|
||||
FileLog.e("tmessages", "wakeup network in background by received push");
|
||||
} else if (ApplicationLoader.lastPauseTime != 0) {
|
||||
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "reset sleep timeout by recieved push");
|
||||
FileLog.e("tmessages", "reset sleep timeout by received push");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -849,7 +849,16 @@ public class ConnectionsManager implements Action.ActionDelegate, TcpConnection.
|
|||
public static boolean isNetworkOnline() {
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager)ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
NetworkInfo netInfo = cm.getActiveNetworkInfo();
|
||||
if (netInfo != null && netInfo.isConnected()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
netInfo = cm.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
|
||||
if (netInfo.isConnected()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (netInfo != null && netInfo.getState() == NetworkInfo.State.CONNECTED) {
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -34,8 +34,12 @@ public class Emoji {
|
|||
private static int drawImgSize, bigImgSize;
|
||||
private static boolean inited = false;
|
||||
private static Paint placeholderPaint;
|
||||
private static Bitmap emojiBmp = null;
|
||||
private static boolean loadingEmoji = false;
|
||||
private static Bitmap emojiBmp[] = new Bitmap[5];
|
||||
private static boolean loadingEmoji[] = new boolean[5];
|
||||
|
||||
private static final int[] cols = {
|
||||
13, 10, 15, 10, 14
|
||||
};
|
||||
|
||||
private static final char[] emojiChars = {
|
||||
0x00A9, 0x00AE, 0x203C, 0x2049, 0x2122, 0x2139, 0x2194, 0x2195, 0x2196, 0x2197,
|
||||
|
@ -199,19 +203,17 @@ public class Emoji {
|
|||
drawImgSize = Utilities.dp(20);
|
||||
bigImgSize = Utilities.dp(30);
|
||||
|
||||
int num = 0;
|
||||
for (int j = 1; j < data.length; j++) {
|
||||
for (int i = 0; i < data[j].length; i++) {
|
||||
Rect rect = new Rect((num % 29) * imgSize, (num / 29) * imgSize, (num % 29 + 1) * imgSize, (num / 29 + 1) * imgSize);
|
||||
rects.put(data[j][i], new DrawableInfo(rect));
|
||||
num++;
|
||||
Rect rect = new Rect((i % cols[j - 1]) * imgSize, (i / cols[j - 1]) * imgSize, (i % cols[j - 1] + 1) * imgSize, (i / cols[j - 1] + 1) * imgSize);
|
||||
rects.put(data[j][i], new DrawableInfo(rect, (byte)(j - 1)));
|
||||
}
|
||||
}
|
||||
placeholderPaint = new Paint();
|
||||
placeholderPaint.setColor(0x55000000);
|
||||
placeholderPaint.setColor(0x00000000);
|
||||
}
|
||||
|
||||
private static Bitmap loadEmoji() {
|
||||
private static Bitmap loadEmoji(final int page) {
|
||||
try {
|
||||
float scale = 1.0f;
|
||||
int imageResize = 1;
|
||||
|
@ -227,7 +229,7 @@ public class Emoji {
|
|||
scale = 3.0f;
|
||||
}
|
||||
|
||||
String imageName = String.format(Locale.US, "emoji%.01fx.jpg", scale);
|
||||
String imageName = String.format(Locale.US, "emoji%.01fx_%d.jpg", scale, page);
|
||||
File imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
|
||||
if (!imageFile.exists()) {
|
||||
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
|
||||
|
@ -242,7 +244,7 @@ public class Emoji {
|
|||
final Bitmap colorsBitmap = Bitmap.createBitmap(opts.outWidth / imageResize, opts.outHeight / imageResize, Bitmap.Config.ARGB_8888);
|
||||
Utilities.loadBitmap(imageFile.getAbsolutePath(), colorsBitmap, imageResize);
|
||||
|
||||
imageName = String.format(Locale.US, "emoji%.01fx_a.jpg", scale);
|
||||
imageName = String.format(Locale.US, "emoji%.01fx_a_%d.jpg", scale, page);
|
||||
imageFile = ApplicationLoader.applicationContext.getFileStreamPath(imageName);
|
||||
if (!imageFile.exists()) {
|
||||
InputStream is = ApplicationLoader.applicationContext.getAssets().open("emoji/" + imageName);
|
||||
|
@ -255,7 +257,7 @@ public class Emoji {
|
|||
Utilities.RunOnUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
emojiBmp = colorsBitmap;
|
||||
emojiBmp[page] = colorsBitmap;
|
||||
NotificationCenter.getInstance().postNotificationName(999);
|
||||
}
|
||||
});
|
||||
|
@ -267,15 +269,15 @@ public class Emoji {
|
|||
return null;
|
||||
}
|
||||
|
||||
private static void loadEmojiAsync() {
|
||||
if (loadingEmoji) {
|
||||
private static void loadEmojiAsync(final int page) {
|
||||
if (loadingEmoji[page]) {
|
||||
return;
|
||||
}
|
||||
loadingEmoji = true;
|
||||
loadingEmoji[page] = true;
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
loadEmoji();
|
||||
loadingEmoji = false;
|
||||
loadEmoji(page);
|
||||
loadingEmoji[page] = false;
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
@ -313,7 +315,7 @@ public class Emoji {
|
|||
}
|
||||
|
||||
public static class EmojiDrawable extends Drawable {
|
||||
Rect rect;
|
||||
private DrawableInfo info;
|
||||
boolean fullSize = false;
|
||||
private static Paint paint;
|
||||
|
||||
|
@ -322,14 +324,14 @@ public class Emoji {
|
|||
paint.setFlags(Paint.FILTER_BITMAP_FLAG | Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
|
||||
public EmojiDrawable(DrawableInfo info) {
|
||||
rect = info.rect;
|
||||
public EmojiDrawable(DrawableInfo i) {
|
||||
info = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (emojiBmp == null) {
|
||||
loadEmojiAsync();
|
||||
if (emojiBmp[info.page] == null) {
|
||||
loadEmojiAsync(info.page);
|
||||
canvas.drawRect(getBounds(), placeholderPaint);
|
||||
return;
|
||||
}
|
||||
|
@ -340,7 +342,7 @@ public class Emoji {
|
|||
b.top = cY - (fullSize ? bigImgSize : drawImgSize) / 2;
|
||||
b.bottom = cY + (fullSize ? bigImgSize : drawImgSize) / 2;
|
||||
if (!canvas.quickReject(b.left, b.top, b.right, b.bottom, Canvas.EdgeType.AA)) {
|
||||
canvas.drawBitmap(emojiBmp, rect, b, paint);
|
||||
canvas.drawBitmap(emojiBmp[info.page], info.rect, b, paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,9 +363,12 @@ public class Emoji {
|
|||
}
|
||||
|
||||
private static class DrawableInfo {
|
||||
Rect rect;
|
||||
public DrawableInfo(Rect rect) {
|
||||
this.rect = rect;
|
||||
public Rect rect;
|
||||
public byte page;
|
||||
|
||||
public DrawableInfo(Rect r, byte p) {
|
||||
rect = r;
|
||||
page = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,12 +93,7 @@ public class FileLoadOperation {
|
|||
}
|
||||
|
||||
public FileLoadOperation(TLRPC.Audio audioLocation) {
|
||||
if (audioLocation instanceof TLRPC.TL_audio) {
|
||||
location = new TLRPC.TL_inputAudioFileLocation();
|
||||
datacenter_id = audioLocation.dc_id;
|
||||
location.id = audioLocation.id;
|
||||
location.access_hash = audioLocation.access_hash;
|
||||
} else if (audioLocation instanceof TLRPC.TL_audioEncrypted) {
|
||||
if (audioLocation instanceof TLRPC.TL_audioEncrypted) {
|
||||
location = new TLRPC.TL_inputEncryptedFileLocation();
|
||||
location.id = audioLocation.id;
|
||||
location.access_hash = audioLocation.access_hash;
|
||||
|
@ -106,6 +101,11 @@ public class FileLoadOperation {
|
|||
iv = new byte[32];
|
||||
System.arraycopy(audioLocation.iv, 0, iv, 0, iv.length);
|
||||
key = audioLocation.key;
|
||||
} else if (audioLocation instanceof TLRPC.TL_audio) {
|
||||
location = new TLRPC.TL_inputAudioFileLocation();
|
||||
datacenter_id = audioLocation.dc_id;
|
||||
location.id = audioLocation.id;
|
||||
location.access_hash = audioLocation.access_hash;
|
||||
}
|
||||
ext = ".m4a";
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.os.ParcelFileDescriptor;
|
|||
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ImageReceiver;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -34,6 +33,7 @@ import java.util.HashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class FileLoader {
|
||||
public LruCache memCache;
|
||||
|
@ -132,10 +132,10 @@ public class FileLoader {
|
|||
|
||||
private class CacheImage {
|
||||
public String key;
|
||||
final public ArrayList<Object> imageViewArray = new ArrayList<Object>();
|
||||
final public ArrayList<ImageReceiver> imageViewArray = new ArrayList<ImageReceiver>();
|
||||
public FileLoadOperation loadOperation;
|
||||
|
||||
public void addImageView(Object imageView) {
|
||||
public void addImageView(ImageReceiver imageView) {
|
||||
synchronized (imageViewArray) {
|
||||
boolean exist = false;
|
||||
for (Object v : imageViewArray) {
|
||||
|
@ -166,9 +166,7 @@ public class FileLoader {
|
|||
synchronized (imageViewArray) {
|
||||
if (image != null) {
|
||||
for (Object imgView : imageViewArray) {
|
||||
if (imgView instanceof BackupImageView) {
|
||||
((BackupImageView)imgView).setImageBitmap(image, key);
|
||||
} else if (imgView instanceof ImageReceiver) {
|
||||
if (imgView instanceof ImageReceiver) {
|
||||
((ImageReceiver)imgView).setImageBitmap(image, key);
|
||||
}
|
||||
}
|
||||
|
@ -481,8 +479,22 @@ public class FileLoader {
|
|||
});
|
||||
}
|
||||
|
||||
public boolean isLoadingFile(String fileName) {
|
||||
return loadOperationPaths.containsKey(fileName);
|
||||
public boolean isLoadingFile(final String fileName) {
|
||||
final Semaphore semaphore = new Semaphore(0);
|
||||
final Boolean[] result = new Boolean[1];
|
||||
fileLoaderQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
result[0] = loadOperationPaths.containsKey(fileName);
|
||||
semaphore.release();
|
||||
}
|
||||
});
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
return result[0];
|
||||
}
|
||||
|
||||
public void loadFile(final TLRPC.Video video, final TLRPC.PhotoSize photo, final TLRPC.Document document, final TLRPC.Audio audio) {
|
||||
|
@ -676,34 +688,16 @@ public class FileLoader {
|
|||
memCache.evictAll();
|
||||
}
|
||||
|
||||
private Integer getTag(Object obj) {
|
||||
if (obj instanceof BackupImageView) {
|
||||
return (Integer)((BackupImageView)obj).getTag(R.string.CacheTag);
|
||||
} else if (obj instanceof ImageReceiver) {
|
||||
return ((ImageReceiver)obj).TAG;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void setTag(Object obj, Integer tag) {
|
||||
if (obj instanceof BackupImageView) {
|
||||
((BackupImageView)obj).setTag(R.string.CacheTag, tag);
|
||||
} else if (obj instanceof ImageReceiver) {
|
||||
((ImageReceiver)obj).TAG = tag;
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelLoadingForImageView(final Object imageView) {
|
||||
public void cancelLoadingForImageView(final ImageReceiver imageView) {
|
||||
if (imageView == null) {
|
||||
return;
|
||||
}
|
||||
fileLoaderQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Integer TAG = getTag(imageView);
|
||||
Integer TAG = imageView.TAG;
|
||||
if (TAG == null) {
|
||||
TAG = lastImageNum;
|
||||
setTag(imageView, TAG);
|
||||
imageView.TAG = TAG = lastImageNum;
|
||||
lastImageNum++;
|
||||
if (lastImageNum == Integer.MAX_VALUE) {
|
||||
lastImageNum = 0;
|
||||
|
@ -723,15 +717,15 @@ public class FileLoader {
|
|||
});
|
||||
}
|
||||
|
||||
public Bitmap getImageFromMemory(TLRPC.FileLocation url, Object imageView, String filter, boolean cancel) {
|
||||
public Bitmap getImageFromMemory(TLRPC.FileLocation url, ImageReceiver imageView, String filter, boolean cancel) {
|
||||
return getImageFromMemory(url, null, imageView, filter, cancel);
|
||||
}
|
||||
|
||||
public Bitmap getImageFromMemory(String url, Object imageView, String filter, boolean cancel) {
|
||||
public Bitmap getImageFromMemory(String url, ImageReceiver imageView, String filter, boolean cancel) {
|
||||
return getImageFromMemory(null, url, imageView, filter, cancel);
|
||||
}
|
||||
|
||||
public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, Object imageView, String filter, boolean cancel) {
|
||||
public Bitmap getImageFromMemory(TLRPC.FileLocation url, String httpUrl, ImageReceiver imageView, String filter, boolean cancel) {
|
||||
if (url == null && httpUrl == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -783,19 +777,19 @@ public class FileLoader {
|
|||
});
|
||||
}
|
||||
|
||||
public void loadImage(final String url, final Object imageView, final String filter, final boolean cancel) {
|
||||
public void loadImage(final String url, final ImageReceiver imageView, final String filter, final boolean cancel) {
|
||||
loadImage(null, url, imageView, filter, cancel, 0);
|
||||
}
|
||||
|
||||
public void loadImage(final TLRPC.FileLocation url, final Object imageView, final String filter, final boolean cancel) {
|
||||
public void loadImage(final TLRPC.FileLocation url, final ImageReceiver imageView, final String filter, final boolean cancel) {
|
||||
loadImage(url, null, imageView, filter, cancel, 0);
|
||||
}
|
||||
|
||||
public void loadImage(final TLRPC.FileLocation url, final Object imageView, final String filter, final boolean cancel, final int size) {
|
||||
public void loadImage(final TLRPC.FileLocation url, final ImageReceiver imageView, final String filter, final boolean cancel, final int size) {
|
||||
loadImage(url, null, imageView, filter, cancel, size);
|
||||
}
|
||||
|
||||
public void loadImage(final TLRPC.FileLocation url, final String httpUrl, final Object imageView, final String filter, final boolean cancel, final int size) {
|
||||
public void loadImage(final TLRPC.FileLocation url, final String httpUrl, final ImageReceiver imageView, final String filter, final boolean cancel, final int size) {
|
||||
if ((url == null && httpUrl == null) || imageView == null || (url != null && !(url instanceof TLRPC.TL_fileLocation) && !(url instanceof TLRPC.TL_fileEncryptedLocation))) {
|
||||
return;
|
||||
}
|
||||
|
@ -814,10 +808,9 @@ public class FileLoader {
|
|||
key += "@" + filter;
|
||||
}
|
||||
|
||||
Integer TAG = getTag(imageView);
|
||||
Integer TAG = imageView.TAG;
|
||||
if (TAG == null) {
|
||||
TAG = lastImageNum;
|
||||
setTag(imageView, TAG);
|
||||
TAG = imageView.TAG = lastImageNum;
|
||||
lastImageNum++;
|
||||
if (lastImageNum == Integer.MAX_VALUE)
|
||||
lastImageNum = 0;
|
||||
|
@ -878,8 +871,8 @@ public class FileLoader {
|
|||
if (arg3 != null) {
|
||||
loadOperationPaths.remove(arg3);
|
||||
}
|
||||
for (Object v : img.imageViewArray) {
|
||||
imageLoadingByKeys.remove(getTag(v));
|
||||
for (ImageReceiver v : img.imageViewArray) {
|
||||
imageLoadingByKeys.remove(v.TAG);
|
||||
}
|
||||
checkOperationsAndClear(img.loadOperation);
|
||||
imageLoading.remove(arg2);
|
||||
|
@ -906,8 +899,8 @@ public class FileLoader {
|
|||
if (arg3 != null) {
|
||||
loadOperationPaths.remove(arg3);
|
||||
}
|
||||
for (Object view : img.imageViewArray) {
|
||||
imageLoadingByKeys.remove(getTag(view));
|
||||
for (ImageReceiver view : img.imageViewArray) {
|
||||
imageLoadingByKeys.remove(view.TAG);
|
||||
imageLoading.remove(arg2);
|
||||
checkOperationsAndClear(operation);
|
||||
}
|
||||
|
|
|
@ -852,7 +852,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
|
||||
ArrayList<Long> keys = new ArrayList<Long>(printingUsers.keySet());
|
||||
for (Long key : keys) {
|
||||
if (key > 0) {
|
||||
if (key > 0 || key.intValue() == 0) {
|
||||
newPrintingStrings.put(key, LocaleController.getString("Typing", R.string.Typing));
|
||||
} else {
|
||||
ArrayList<PrintingUser> arr = printingUsers.get(key);
|
||||
|
@ -3937,26 +3937,30 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
} else if (update instanceof TLRPC.TL_updateEncryptedChatTyping) {
|
||||
long uid = ((long)update.chat_id) << 32;
|
||||
ArrayList<PrintingUser> arr = printingUsers.get(uid);
|
||||
if (arr == null) {
|
||||
arr = new ArrayList<PrintingUser>();
|
||||
printingUsers.put(uid, arr);
|
||||
}
|
||||
boolean exist = false;
|
||||
for (PrintingUser u : arr) {
|
||||
if (u.userId == update.user_id) {
|
||||
exist = true;
|
||||
u.lastTime = currentTime;
|
||||
break;
|
||||
TLRPC.EncryptedChat encryptedChat = getEncryptedChat(update.chat_id);
|
||||
if (encryptedChat != null) {
|
||||
update.user_id = encryptedChat.user_id;
|
||||
long uid = ((long) update.chat_id) << 32;
|
||||
ArrayList<PrintingUser> arr = printingUsers.get(uid);
|
||||
if (arr == null) {
|
||||
arr = new ArrayList<PrintingUser>();
|
||||
printingUsers.put(uid, arr);
|
||||
}
|
||||
boolean exist = false;
|
||||
for (PrintingUser u : arr) {
|
||||
if (u.userId == update.user_id) {
|
||||
exist = true;
|
||||
u.lastTime = currentTime;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
PrintingUser newUser = new PrintingUser();
|
||||
newUser.userId = update.user_id;
|
||||
newUser.lastTime = currentTime;
|
||||
arr.add(newUser);
|
||||
printChanged = true;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
PrintingUser newUser = new PrintingUser();
|
||||
newUser.userId = update.user_id;
|
||||
newUser.lastTime = currentTime;
|
||||
arr.add(newUser);
|
||||
printChanged = true;
|
||||
}
|
||||
} else if (update instanceof TLRPC.TL_updateEncryptedMessagesRead) {
|
||||
markAsReadEncrypted.put(update.chat_id, Math.max(update.max_date, update.date));
|
||||
|
@ -3970,22 +3974,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
} else if (update instanceof TLRPC.TL_updateEncryption) {
|
||||
final TLRPC.EncryptedChat newChat = update.chat;
|
||||
long dialog_id = ((long)newChat.id) << 32;
|
||||
TLRPC.EncryptedChat existingChat = encryptedChats.get(newChat.id);
|
||||
if (existingChat == null) {
|
||||
Semaphore semaphore = new Semaphore(0);
|
||||
ArrayList<TLObject> result = new ArrayList<TLObject>();
|
||||
MessagesStorage.getInstance().getEncryptedChat(newChat.id, semaphore, result);
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
if (result.size() == 2) {
|
||||
existingChat = (TLRPC.EncryptedChat)result.get(0);
|
||||
TLRPC.User user = (TLRPC.User)result.get(1);
|
||||
users.putIfAbsent(user.id, user);
|
||||
}
|
||||
}
|
||||
TLRPC.EncryptedChat existingChat = getEncryptedChat(newChat.id);
|
||||
|
||||
if (newChat instanceof TLRPC.TL_encryptedChatRequested && existingChat == null) {
|
||||
int user_id = newChat.participant_id;
|
||||
|
@ -4289,7 +4278,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
if (ApplicationLoader.lastPauseTime != 0) {
|
||||
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
|
||||
FileLog.e("tmessages", "reset sleep timeout by recieved message");
|
||||
FileLog.e("tmessages", "reset sleep timeout by received message");
|
||||
}
|
||||
if (messageObject == null) {
|
||||
return;
|
||||
|
@ -4654,12 +4643,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
}
|
||||
}
|
||||
|
||||
public TLRPC.Message decryptMessage(TLRPC.EncryptedMessage message) {
|
||||
TLRPC.EncryptedChat chat = encryptedChats.get(message.chat_id);
|
||||
public TLRPC.EncryptedChat getEncryptedChat(int chat_id) {
|
||||
TLRPC.EncryptedChat chat = encryptedChats.get(chat_id);
|
||||
if (chat == null) {
|
||||
Semaphore semaphore = new Semaphore(0);
|
||||
ArrayList<TLObject> result = new ArrayList<TLObject>();
|
||||
MessagesStorage.getInstance().getEncryptedChat(message.chat_id, semaphore, result);
|
||||
MessagesStorage.getInstance().getEncryptedChat(chat_id, semaphore, result);
|
||||
try {
|
||||
semaphore.acquire();
|
||||
} catch (Exception e) {
|
||||
|
@ -4672,6 +4661,11 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
|||
users.putIfAbsent(user.id, user);
|
||||
}
|
||||
}
|
||||
return chat;
|
||||
}
|
||||
|
||||
public TLRPC.Message decryptMessage(TLRPC.EncryptedMessage message) {
|
||||
TLRPC.EncryptedChat chat = getEncryptedChat(message.chat_id);
|
||||
if (chat == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@ public class NotificationCenter {
|
|||
|
||||
final private HashMap<Integer, ArrayList<Object>> observers = new HashMap<Integer, ArrayList<Object>>();
|
||||
|
||||
final private HashMap<String, Object> memCache = new HashMap<String, Object>();
|
||||
|
||||
final private HashMap<Integer, Object> removeAfterBroadcast = new HashMap<Integer, Object>();
|
||||
final private HashMap<Integer, Object> addAfterBroadcast = new HashMap<Integer, Object>();
|
||||
|
||||
|
@ -40,27 +38,6 @@ public class NotificationCenter {
|
|||
public abstract void didReceivedNotification(int id, Object... args);
|
||||
}
|
||||
|
||||
public void addToMemCache(int id, Object object) {
|
||||
addToMemCache(String.valueOf(id), object);
|
||||
}
|
||||
|
||||
public void addToMemCache(String id, Object object) {
|
||||
memCache.put(id, object);
|
||||
}
|
||||
|
||||
public Object getFromMemCache(int id) {
|
||||
return getFromMemCache(String.valueOf(id), null);
|
||||
}
|
||||
|
||||
public Object getFromMemCache(String id, Object defaultValue) {
|
||||
Object obj = memCache.get(id);
|
||||
if (obj != null) {
|
||||
memCache.remove(id);
|
||||
return obj;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void postNotificationName(int id, Object... args) {
|
||||
synchronized (observers) {
|
||||
broadcasting = true;
|
||||
|
|
|
@ -59,7 +59,6 @@ public class TcpConnection extends ConnectionContext {
|
|||
private boolean firstPacket;
|
||||
|
||||
private Timer reconnectTimer;
|
||||
private boolean tryWithNoNetworkAnyway = false;
|
||||
|
||||
public TcpConnection(int did) {
|
||||
if (selector == null) {
|
||||
|
@ -81,6 +80,43 @@ public class TcpConnection extends ConnectionContext {
|
|||
}
|
||||
|
||||
public void connect() {
|
||||
if (!ConnectionsManager.isNetworkOnline()) {
|
||||
synchronized (timerSync) {
|
||||
reconnectTimer = new Timer();
|
||||
reconnectTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
selector.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (timerSync) {
|
||||
if (reconnectTimer != null) {
|
||||
reconnectTimer.cancel();
|
||||
reconnectTimer = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
connect();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
if (delegate != null) {
|
||||
final TcpConnectionDelegate finalDelegate = delegate;
|
||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalDelegate.tcpConnectionClosed(TcpConnection.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
selector.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -94,14 +130,6 @@ public class TcpConnection extends ConnectionContext {
|
|||
hostAddress = datacenter.getCurrentAddress();
|
||||
hostPort = datacenter.getCurrentPort();
|
||||
|
||||
if(android.os.Build.VERSION.SDK_INT < 11) {
|
||||
if (!ConnectionsManager.isNetworkOnline() && !tryWithNoNetworkAnyway) {
|
||||
handleConnectionError(null);
|
||||
tryWithNoNetworkAnyway = true;
|
||||
return;
|
||||
}
|
||||
tryWithNoNetworkAnyway = false;
|
||||
}
|
||||
try {
|
||||
synchronized (timerSync) {
|
||||
if (reconnectTimer != null) {
|
||||
|
@ -637,28 +665,30 @@ public class TcpConnection extends ConnectionContext {
|
|||
}
|
||||
FileLog.d("tmessages", "Reconnect " + hostAddress + ":" + hostPort + " " + TcpConnection.this);
|
||||
try {
|
||||
reconnectTimer = new Timer();
|
||||
reconnectTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
selector.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (timerSync) {
|
||||
if (reconnectTimer != null) {
|
||||
reconnectTimer.cancel();
|
||||
reconnectTimer = null;
|
||||
synchronized (timerSync) {
|
||||
reconnectTimer = new Timer();
|
||||
reconnectTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
selector.scheduleTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
synchronized (timerSync) {
|
||||
if (reconnectTimer != null) {
|
||||
reconnectTimer.cancel();
|
||||
reconnectTimer = null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
FileLog.e("tmessages", e2);
|
||||
connect();
|
||||
}
|
||||
connect();
|
||||
}
|
||||
});
|
||||
}
|
||||
}, failedConnectionCount > 3 ? 500 : 300, failedConnectionCount > 3 ? 500 : 300);
|
||||
});
|
||||
}
|
||||
}, failedConnectionCount > 3 ? 500 : 300, failedConnectionCount > 3 ? 500 : 300);
|
||||
}
|
||||
} catch (Exception e3) {
|
||||
FileLog.e("tmessages", e3);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.content.ContentUris;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
|
@ -27,6 +28,7 @@ import android.text.Html;
|
|||
import android.text.SpannableStringBuilder;
|
||||
import android.util.Base64;
|
||||
import android.view.Display;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -72,6 +74,7 @@ public class Utilities {
|
|||
public static Pattern pattern = Pattern.compile("[0-9]+");
|
||||
public static SecureRandom random = new SecureRandom();
|
||||
private final static Integer lock = 1;
|
||||
private static int prevOrientation = -10;
|
||||
|
||||
private static boolean waitingForSms = false;
|
||||
private static final Integer smsLock = 2;
|
||||
|
@ -152,6 +155,47 @@ public class Utilities {
|
|||
public native static void aesIgeEncryption2(ByteBuffer _what, byte[] _key, byte[] _iv, boolean encrypt, boolean changeIv, int len);
|
||||
public native static void loadBitmap(String path, Bitmap bitmap, int scale);
|
||||
|
||||
public static void lockOrientation(Activity activity) {
|
||||
if (prevOrientation != -10) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
prevOrientation = activity.getRequestedOrientation();
|
||||
WindowManager manager = (WindowManager)activity.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_270) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else if (rotation == Surface.ROTATION_0) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void unlockOrientation(Activity activity) {
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
activity.setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWaitingForSms() {
|
||||
boolean value = false;
|
||||
synchronized (smsLock) {
|
||||
|
|
|
@ -152,10 +152,12 @@ public class ApplicationLoader extends Application {
|
|||
if (preferences.getBoolean("pushService", true)) {
|
||||
applicationContext.startService(new Intent(applicationContext, NotificationsService.class));
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0);
|
||||
AlarmManager alarm = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30000, pintent);
|
||||
if (android.os.Build.VERSION.SDK_INT >= 19) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0);
|
||||
AlarmManager alarm = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE);
|
||||
alarm.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 30000, pintent);
|
||||
}
|
||||
} else {
|
||||
stopPushService();
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.PhotoViewer;
|
||||
import org.telegram.ui.Views.GifDrawable;
|
||||
import org.telegram.ui.Views.ImageReceiver;
|
||||
import org.telegram.ui.Views.ProgressView;
|
||||
|
@ -39,7 +40,7 @@ import java.util.Locale;
|
|||
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
||||
|
||||
public static interface ChatMediaCellDelegate {
|
||||
public abstract void didPressedImage(ChatMediaCell cell, ImageReceiver imageReceiver);
|
||||
public abstract void didPressedImage(ChatMediaCell cell);
|
||||
}
|
||||
|
||||
private static Drawable placeholderInDrawable;
|
||||
|
@ -196,7 +197,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
if (currentMessageObject.type == 1) {
|
||||
if (buttonState == -1) {
|
||||
if (mediaDelegate != null) {
|
||||
mediaDelegate.didPressedImage(this, photoImage);
|
||||
mediaDelegate.didPressedImage(this);
|
||||
}
|
||||
} else if (buttonState == 0) {
|
||||
didPressedButton();
|
||||
|
@ -217,7 +218,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
}
|
||||
} else if (currentMessageObject.type == 4) {
|
||||
if (mediaDelegate != null) {
|
||||
mediaDelegate.didPressedImage(this, photoImage);
|
||||
mediaDelegate.didPressedImage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,7 +272,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
}
|
||||
} else if (buttonState == 3) {
|
||||
if (mediaDelegate != null) {
|
||||
mediaDelegate.didPressedImage(this, photoImage);
|
||||
mediaDelegate.didPressedImage(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -421,6 +422,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
updateButtonState();
|
||||
}
|
||||
|
||||
public ImageReceiver getPhotoImage() {
|
||||
return photoImage;
|
||||
}
|
||||
|
||||
public void updateButtonState() {
|
||||
String fileName = null;
|
||||
File cacheFile = null;
|
||||
|
@ -544,6 +549,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
|||
gifDrawable.draw(canvas);
|
||||
canvas.restore();
|
||||
} else {
|
||||
photoImage.setVisible(!PhotoViewer.getInstance().isShowingImage(currentMessageObject), false);
|
||||
photoImage.draw(canvas, photoImage.imageX, photoImage.imageY, photoWidth, photoHeight);
|
||||
drawTime = photoImage.getVisible();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
|
@ -26,7 +25,6 @@ import android.graphics.drawable.BitmapDrawable;
|
|||
import android.media.MediaPlayer;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.MediaStore;
|
||||
|
@ -103,7 +101,7 @@ import java.util.Comparator;
|
|||
import java.util.HashMap;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, DocumentSelectActivity.DocumentSelectActivityDelegate {
|
||||
public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLayout.SizeNotifierRelativeLayoutDelegate, NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, DocumentSelectActivity.DocumentSelectActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
|
||||
private View timeItem;
|
||||
private View menuItem;
|
||||
|
@ -180,7 +178,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
private float startedDraggingX = -1;
|
||||
private float distCanMove = Utilities.dp(80);
|
||||
private PowerManager.WakeLock mWakeLock = null;
|
||||
private int prevOrientation = -10;
|
||||
|
||||
private String currentPicturePath;
|
||||
|
||||
|
@ -411,14 +408,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
getParentActivity().setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
Utilities.unlockOrientation(getParentActivity());
|
||||
MediaController.getInstance().stopAudio();
|
||||
}
|
||||
|
||||
|
@ -496,18 +486,17 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
}
|
||||
presentFragment(new UserProfileActivity(args));
|
||||
} else if (currentChat != null) {
|
||||
if (info != null) {
|
||||
if (info instanceof TLRPC.TL_chatParticipantsForbidden) {
|
||||
return;
|
||||
}
|
||||
NotificationCenter.getInstance().addToMemCache(5, info);
|
||||
if (info != null && info instanceof TLRPC.TL_chatParticipantsForbidden) {
|
||||
return;
|
||||
}
|
||||
if (currentChat.participants_count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) {
|
||||
return;
|
||||
}
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("chat_id", currentChat.id);
|
||||
presentFragment(new ChatProfileActivity(args));
|
||||
ChatProfileActivity fragment = new ChatProfileActivity(args);
|
||||
fragment.setChatInfo(info);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
} else if (id == copy) {
|
||||
String str = "";
|
||||
|
@ -1066,30 +1055,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
try {
|
||||
prevOrientation = getParentActivity().getRequestedOrientation();
|
||||
WindowManager manager = (WindowManager)ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_270) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
getParentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
getParentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
getParentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else if (rotation == Surface.ROTATION_0) {
|
||||
getParentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
getParentActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
Utilities.lockOrientation(getParentActivity());
|
||||
|
||||
recordPanel.setVisibility(View.VISIBLE);
|
||||
recordTimeText.setText("00:00");
|
||||
|
@ -1128,14 +1094,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
FileLog.e("tmessages", e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
getParentActivity().setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
Utilities.unlockOrientation(getParentActivity());
|
||||
if(android.os.Build.VERSION.SDK_INT > 13) {
|
||||
recordPanel.animate().setInterpolator(new AccelerateDecelerateInterpolator()).setListener(new Animator.AnimatorListener() {
|
||||
@Override
|
||||
|
@ -3367,6 +3326,51 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
showAlertDialog(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
||||
if (messageObject == null) {
|
||||
return null;
|
||||
}
|
||||
int count = chatListView.getChildCount();
|
||||
|
||||
for (int a = 0; a < count; a++) {
|
||||
MessageObject messageToOpen = null;
|
||||
ImageReceiver imageReceiver = null;
|
||||
View view = chatListView.getChildAt(a);
|
||||
if (view instanceof ChatMediaCell) {
|
||||
ChatMediaCell cell = (ChatMediaCell)view;
|
||||
MessageObject message = cell.getMessageObject();
|
||||
if (message != null && message.messageOwner.id == messageObject.messageOwner.id) {
|
||||
messageToOpen = message;
|
||||
imageReceiver = cell.getPhotoImage();
|
||||
}
|
||||
} else if (view.getTag() != null) {
|
||||
Object tag = view.getTag();
|
||||
if (tag instanceof ChatListRowHolderEx) {
|
||||
ChatListRowHolderEx holder = (ChatListRowHolderEx)tag;
|
||||
if (holder.message != null && holder.message.messageOwner.id == messageObject.messageOwner.id) {
|
||||
messageToOpen = holder.message;
|
||||
imageReceiver = holder.photoImage.imageReceiver;
|
||||
view = holder.photoImage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messageToOpen != null) {
|
||||
int coords[] = new int[2];
|
||||
view.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.parentView = chatListView;
|
||||
object.imageReceiver = imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
return object;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class ChatAdapter extends BaseAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
@ -3517,7 +3521,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
if (view instanceof ChatMediaCell) {
|
||||
((ChatMediaCell)view).mediaDelegate = new ChatMediaCell.ChatMediaCellDelegate() {
|
||||
@Override
|
||||
public void didPressedImage(ChatMediaCell cell, ImageReceiver imageReceiver) {
|
||||
public void didPressedImage(ChatMediaCell cell) {
|
||||
MessageObject message = cell.getMessageObject();
|
||||
if (message.messageOwner.send_state == MessagesController.MESSAGE_SEND_STATE_SEND_ERROR) {
|
||||
createMenu(cell, false);
|
||||
|
@ -3526,12 +3530,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
return;
|
||||
}
|
||||
if (message.type == 1) {
|
||||
// int coords[] = new int[2];
|
||||
// cell.getLocationInWindow(coords);
|
||||
// PhotoViewer.getInstance().openPhoto(imageReceiver, coords[0], coords[1] - Utilities.statusBarHeight, chatListView);
|
||||
NotificationCenter.getInstance().addToMemCache(51, message);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(message, ChatActivity.this);
|
||||
} else if (message.type == 3) {
|
||||
try {
|
||||
File f = null;
|
||||
|
@ -3551,8 +3550,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
if (!isGoogleMapsInstalled()) {
|
||||
return;
|
||||
}
|
||||
NotificationCenter.getInstance().addToMemCache(0, message);
|
||||
presentFragment(new LocationActivity());
|
||||
LocationActivity fragment = new LocationActivity();
|
||||
fragment.setMessageObject(message);
|
||||
presentFragment(fragment);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -3641,7 +3641,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
|
||||
private PhotoObject photoObjectToSet = null;
|
||||
private File photoFile = null;
|
||||
private String photoFileName = null;
|
||||
private String photoFilter = null;
|
||||
|
||||
public void update() {
|
||||
|
@ -3683,6 +3682,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
photoImage.setImage(photo.photoOwner.location, "50_50", Utilities.getGroupAvatarForId(currentChat.id));
|
||||
}
|
||||
}
|
||||
photoImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(message), false);
|
||||
}
|
||||
} else if (type == 12 || type == 13) {
|
||||
TLRPC.User contactUser = MessagesController.getInstance().users.get(message.messageOwner.media.user_id);
|
||||
|
@ -3753,9 +3753,9 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
phoneTextView.setText(String.format("%.1f MB %s", document.size / 1024.0f / 1024.0f, ext));
|
||||
}
|
||||
if (document.thumb instanceof TLRPC.TL_photoSize) {
|
||||
|
||||
contactAvatar.setImage(document.thumb.location, "50_50", type == 8 ? R.drawable.doc_green : R.drawable.doc_blue);
|
||||
} else if (document.thumb instanceof TLRPC.TL_photoCachedSize) {
|
||||
|
||||
contactAvatar.setImage(document.thumb.location, "50_50", type == 8 ? R.drawable.doc_green : R.drawable.doc_blue);
|
||||
} else {
|
||||
if (type == 8) {
|
||||
contactAvatar.setImageResource(R.drawable.doc_green);
|
||||
|
@ -3843,12 +3843,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
if (file != null) {
|
||||
progressBarMap.remove(file);
|
||||
}
|
||||
String fileName = null;
|
||||
if (photoFileName != null) {
|
||||
fileName = photoFileName;
|
||||
} else {
|
||||
fileName = message.getFileName();
|
||||
}
|
||||
String fileName = message.getFileName();
|
||||
boolean load = false;
|
||||
if (message.type != 2 && message.type != 3 && message.messageOwner.attachPath != null && message.messageOwner.attachPath.length() != 0) {
|
||||
File f = new File(message.messageOwner.attachPath);
|
||||
|
@ -3895,9 +3890,6 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
addToLoadingFile(fileName, actionProgress);
|
||||
if (actionView != null) {
|
||||
actionView.setVisibility(View.VISIBLE);
|
||||
if (photoFileName != null) {
|
||||
actionCancelButton.setImageResource(R.drawable.photo_download_cancel_states);
|
||||
}
|
||||
}
|
||||
if (actionAttachButton != null) {
|
||||
actionAttachButton.setVisibility(View.GONE);
|
||||
|
@ -4160,9 +4152,7 @@ public class ChatActivity extends BaseFragment implements SizeNotifierRelativeLa
|
|||
}
|
||||
if (message != null) {
|
||||
if (message.type == 11) {
|
||||
NotificationCenter.getInstance().addToMemCache(51, message);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(message, ChatActivity.this);
|
||||
} else if (message.type == 8 || message.type == 9) {
|
||||
File f = null;
|
||||
String fileName = message.getFileName();
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.telegram.messenger.NotificationCenter;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Cells.ChatOrUserCell;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
|
@ -51,7 +52,7 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ChatProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate {
|
||||
public class ChatProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ContactsActivity.ContactsActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
private ListView listView;
|
||||
private ListAdapter listViewAdapter;
|
||||
private int chat_id;
|
||||
|
@ -90,7 +91,6 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
NotificationCenter.getInstance().addObserver(this, MessagesController.closeChats);
|
||||
|
||||
chat_id = getArguments().getInt("chat_id", 0);
|
||||
info = (TLRPC.ChatParticipants)NotificationCenter.getInstance().getFromMemCache(5);
|
||||
updateOnlineCount();
|
||||
MessagesController.getInstance().getMediaCount(-chat_id, classGuid, true);
|
||||
avatarUpdater.delegate = new AvatarUpdater.AvatarUpdaterDelegate() {
|
||||
|
@ -336,6 +336,37 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
||||
if (fileLocation == null) {
|
||||
return null;
|
||||
}
|
||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
||||
if (chat != null && chat.photo != null && chat.photo.photo_big != null) {
|
||||
TLRPC.FileLocation photoBig = chat.photo.photo_big;
|
||||
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
||||
int count = listView.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View view = listView.getChildAt(a);
|
||||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||
if (avatarImage != null) {
|
||||
int coords[] = new int[2];
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
object.size = -1;
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.updateInterfaces) {
|
||||
int mask = (Integer)args[0];
|
||||
|
@ -377,6 +408,10 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
|
||||
public void setChatInfo(TLRPC.ChatParticipants chatParticipants) {
|
||||
info = chatParticipants;
|
||||
}
|
||||
|
||||
private void updateVisibleRows(int mask) {
|
||||
if (listView == null) {
|
||||
return;
|
||||
|
@ -441,9 +476,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
if (action == 0) {
|
||||
TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id);
|
||||
if (chat.photo != null && chat.photo.photo_big != null) {
|
||||
NotificationCenter.getInstance().addToMemCache(53, chat.photo.photo_big);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, this);
|
||||
}
|
||||
} else if (action == 1) {
|
||||
avatarUpdater.openCamera();
|
||||
|
@ -606,10 +639,13 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
|
||||
TLRPC.FileLocation photo = null;
|
||||
TLRPC.FileLocation photoBig = null;
|
||||
if (chat.photo != null) {
|
||||
photo = chat.photo.photo_small;
|
||||
photoBig = chat.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", Utilities.getGroupAvatarForId(chat.id));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
return view;
|
||||
} else if (type == 1) {
|
||||
if (view == null) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -423,12 +422,10 @@ public class DocumentSelectActivity extends BaseFragment {
|
|||
imageView.setImageBitmap(null);
|
||||
typeTextView.setText(item.ext.toUpperCase().substring(0, Math.min(item.ext.length(), 4)));
|
||||
imageView.setImage(item.thumb, "55_42", 0);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
typeTextView.setVisibility(View.VISIBLE);
|
||||
} else if (item.icon != 0) {
|
||||
imageView.setImageResource(item.icon);
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
typeTextView.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
|
|
@ -103,7 +103,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
NotificationCenter.getInstance().addObserver(this, 701);
|
||||
NotificationCenter.getInstance().addObserver(this, 702);
|
||||
NotificationCenter.getInstance().addObserver(this, 703);
|
||||
NotificationCenter.getInstance().addObserver(this, GalleryImageViewer.needShowAllMedia);
|
||||
|
||||
statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null);
|
||||
statusBackground = statusView.findViewById(R.id.back_button_background);
|
||||
|
@ -601,7 +600,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
NotificationCenter.getInstance().removeObserver(this, 701);
|
||||
NotificationCenter.getInstance().removeObserver(this, 702);
|
||||
NotificationCenter.getInstance().removeObserver(this, 703);
|
||||
NotificationCenter.getInstance().removeObserver(this, GalleryImageViewer.needShowAllMedia);
|
||||
if (notificationView != null) {
|
||||
notificationView.hide(false);
|
||||
notificationView.destroy();
|
||||
|
@ -642,17 +640,13 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
startActivity(intent2);
|
||||
onFinish();
|
||||
finish();
|
||||
} else if (id == GalleryImageViewer.needShowAllMedia) {
|
||||
long dialog_id = (Long)args[0];
|
||||
if (dialog_id != 0) {
|
||||
Bundle args2 = new Bundle();
|
||||
args2.putLong("dialog_id", dialog_id);
|
||||
presentFragment(new MediaActivity(args2), false, true);
|
||||
}
|
||||
} else if (id == 658) {
|
||||
Integer push_user_id = (Integer)NotificationCenter.getInstance().getFromMemCache("push_user_id", 0);
|
||||
Integer push_chat_id = (Integer)NotificationCenter.getInstance().getFromMemCache("push_chat_id", 0);
|
||||
Integer push_enc_id = (Integer)NotificationCenter.getInstance().getFromMemCache("push_enc_id", 0);
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto(false);
|
||||
}
|
||||
Integer push_chat_id = (Integer)args[0];
|
||||
Integer push_user_id = (Integer)args[1];
|
||||
Integer push_enc_id = (Integer)args[2];
|
||||
|
||||
if (push_user_id != 0) {
|
||||
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
||||
|
@ -750,7 +744,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
@Override
|
||||
public void onBackPressed() {
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto();
|
||||
PhotoViewer.getInstance().closePhoto(true);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
@ -759,7 +753,7 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen
|
|||
@Override
|
||||
public boolean onPreIme() {
|
||||
if (PhotoViewer.getInstance().isVisible()) {
|
||||
PhotoViewer.getInstance().closePhoto();
|
||||
PhotoViewer.getInstance().closePhoto(true);
|
||||
return true;
|
||||
}
|
||||
return super.onPreIme();
|
||||
|
|
|
@ -60,7 +60,6 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
messageObject = (MessageObject)NotificationCenter.getInstance().getFromMemCache(0);
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.closeChats);
|
||||
if (messageObject != null) {
|
||||
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
||||
|
@ -294,6 +293,10 @@ public class LocationActivity extends BaseFragment implements NotificationCenter
|
|||
}
|
||||
}
|
||||
|
||||
public void setMessageObject(MessageObject message) {
|
||||
messageObject = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == MessagesController.updateInterfaces) {
|
||||
|
|
|
@ -10,7 +10,6 @@ package org.telegram.ui;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -32,6 +31,7 @@ import org.telegram.objects.MessageObject;
|
|||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.BackupImageView;
|
||||
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
||||
|
@ -39,7 +39,7 @@ import org.telegram.ui.Views.ActionBar.BaseFragment;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MediaActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
public class MediaActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
private GridView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private ArrayList<MessageObject> messages = new ArrayList<MessageObject>();
|
||||
|
@ -114,10 +114,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
NotificationCenter.getInstance().addToMemCache(54, messages);
|
||||
NotificationCenter.getInstance().addToMemCache(55, i);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(messages, i, MediaActivity.this);
|
||||
}
|
||||
});
|
||||
if (loading && messages.isEmpty()) {
|
||||
|
@ -266,6 +263,41 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
fixLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
||||
if (messageObject == null) {
|
||||
return null;
|
||||
}
|
||||
int count = listView.getChildCount();
|
||||
|
||||
for (int a = 0; a < count; a++) {
|
||||
View view = listView.getChildAt(a);
|
||||
BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image);
|
||||
if (imageView != null) {
|
||||
int num = (Integer)imageView.getTag();
|
||||
if (num < 0 || num >= messages.size()) {
|
||||
continue;
|
||||
}
|
||||
MessageObject message = messages.get(num);
|
||||
if (message != null && message.messageOwner.id == messageObject.messageOwner.id) {
|
||||
int coords[] = new int[2];
|
||||
imageView.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = imageView.imageReceiver;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// NotificationCenter.getInstance().addToMemCache(54, messages); TODO
|
||||
// NotificationCenter.getInstance().addToMemCache(55, i);
|
||||
|
||||
}
|
||||
|
||||
private void fixLayout() {
|
||||
if (listView != null) {
|
||||
ViewTreeObserver obs = listView.getViewTreeObserver();
|
||||
|
@ -351,20 +383,20 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
view.setLayoutParams(params);
|
||||
|
||||
BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image);
|
||||
imageView.setTag(i);
|
||||
|
||||
if (message.messageOwner.media != null && message.messageOwner.media.photo != null && !message.messageOwner.media.photo.sizes.isEmpty()) {
|
||||
ArrayList<TLRPC.PhotoSize> sizes = message.messageOwner.media.photo.sizes;
|
||||
boolean set = false;
|
||||
if (!set) {
|
||||
if (message.imagePreview != null) {
|
||||
imageView.setImageBitmap(message.imagePreview);
|
||||
} else {
|
||||
imageView.setImage(message.messageOwner.media.photo.sizes.get(0).location, null, R.drawable.photo_placeholder_in);
|
||||
}
|
||||
if (message.imagePreview != null) {
|
||||
imageView.setImageBitmap(message.imagePreview);
|
||||
} else {
|
||||
TLRPC.PhotoSize photoSize = PhotoObject.getClosestPhotoSizeWithSize(message.messageOwner.media.photo.sizes, 80, 80);
|
||||
imageView.setImage(photoSize.location, null, R.drawable.photo_placeholder_in);
|
||||
}
|
||||
} else {
|
||||
imageView.setImageResource(R.drawable.photo_placeholder_in);
|
||||
}
|
||||
imageView.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(message), false);
|
||||
} else if (type == 1) {
|
||||
MessageObject message = messages.get(i);
|
||||
if (view == null) {
|
||||
|
@ -378,6 +410,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
|
||||
TextView textView = (TextView)view.findViewById(R.id.chat_video_time);
|
||||
BackupImageView imageView = (BackupImageView)view.findViewById(R.id.media_photo_image);
|
||||
imageView.setTag(i);
|
||||
|
||||
if (message.messageOwner.media.video != null && message.messageOwner.media.video.thumb != null) {
|
||||
int duration = message.messageOwner.media.video.duration;
|
||||
|
@ -394,6 +427,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No
|
|||
textView.setVisibility(View.GONE);
|
||||
imageView.setImageResource(R.drawable.photo_placeholder_in);
|
||||
}
|
||||
imageView.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(message), false);
|
||||
} else if (type == 2) {
|
||||
if (view == null) {
|
||||
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.telegram.messenger.R;
|
|||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.UserConfig;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.objects.PhotoObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.AvatarUpdater;
|
||||
|
@ -61,7 +62,7 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
public class SettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
private ListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
|
@ -411,6 +412,38 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
return fragmentView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
||||
if (fileLocation == null) {
|
||||
return null;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId);
|
||||
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
||||
TLRPC.FileLocation photoBig = user.photo.photo_big;
|
||||
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
||||
int count = listView.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View view = listView.getChildAt(a);
|
||||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||
if (avatarImage != null) {
|
||||
int coords[] = new int[2];
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.user_id = UserConfig.clientUserId;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
object.size = -1;
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void performAskAQuestion() {
|
||||
final SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
int uid = preferences.getInt("support_id", 0);
|
||||
|
@ -638,10 +671,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
if (i == 0 && full) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.clientUserId);
|
||||
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
||||
NotificationCenter.getInstance().addToMemCache(56, user.id);
|
||||
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this);
|
||||
}
|
||||
} else if (i == 0 && !full || i == 1 && full) {
|
||||
avatarUpdater.openCamera();
|
||||
|
@ -714,10 +744,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
|
|||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||
avatarImage.processDetach = false;
|
||||
TLRPC.FileLocation photo = null;
|
||||
TLRPC.FileLocation photoBig = null;
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
photoBig = user.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, null, Utilities.getUserAvatarForId(user.id));
|
||||
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
}
|
||||
return view;
|
||||
} else if (type == 1) {
|
||||
|
|
|
@ -184,10 +184,8 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||
if (progressView != null) {
|
||||
progressView.setVisibility(View.GONE);
|
||||
}
|
||||
if (listView != null) {
|
||||
if (listView.getEmptyView() == null) {
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (listView != null && listView.getEmptyView() == null) {
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
|
@ -212,10 +210,8 @@ public class SettingsBlockedUsers extends BaseFragment implements NotificationCe
|
|||
if (progressView != null) {
|
||||
progressView.setVisibility(View.GONE);
|
||||
}
|
||||
if (listView != null) {
|
||||
if (listView.getEmptyView() == null) {
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (listView != null && listView.getEmptyView() == null) {
|
||||
listView.setEmptyView(emptyView);
|
||||
}
|
||||
if (listViewAdapter != null) {
|
||||
listViewAdapter.notifyDataSetChanged();
|
||||
|
|
|
@ -212,9 +212,13 @@ public class SettingsNotificationsActivity extends BaseFragment {
|
|||
SharedPreferences.Editor editor = preferences.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
listView.invalidateViews();
|
||||
Toast toast = Toast.makeText(getParentActivity(), R.string.ResetNotificationsText, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
if (getParentActivity() != null) {
|
||||
Toast toast = Toast.makeText(getParentActivity(), R.string.ResetNotificationsText, Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.telegram.messenger.NotificationCenter;
|
|||
import org.telegram.messenger.R;
|
||||
import org.telegram.messenger.RPCRequest;
|
||||
import org.telegram.messenger.Utilities;
|
||||
import org.telegram.objects.MessageObject;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
||||
|
@ -51,7 +52,7 @@ import org.telegram.ui.Views.IdenticonView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class UserProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate {
|
||||
public class UserProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
||||
private ListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
private int user_id;
|
||||
|
@ -452,6 +453,38 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
||||
if (fileLocation == null) {
|
||||
return null;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
||||
TLRPC.FileLocation photoBig = user.photo.photo_big;
|
||||
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
||||
int count = listView.getChildCount();
|
||||
for (int a = 0; a < count; a++) {
|
||||
View view = listView.getChildAt(a);
|
||||
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
||||
if (avatarImage != null) {
|
||||
int coords[] = new int[2];
|
||||
avatarImage.getLocationInWindow(coords);
|
||||
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
||||
object.viewX = coords[0];
|
||||
object.viewY = coords[1] - Utilities.statusBarHeight;
|
||||
object.parentView = listView;
|
||||
object.imageReceiver = avatarImage.imageReceiver;
|
||||
object.user_id = user_id;
|
||||
object.thumb = object.imageReceiver.getBitmap();
|
||||
object.size = -1;
|
||||
return object;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createActionBarMenu() {
|
||||
ActionBarMenu menu = actionBarLayer.createMenu();
|
||||
menu.clearItems();
|
||||
|
@ -557,10 +590,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
public void onClick(View view) {
|
||||
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
||||
if (user.photo != null && user.photo.photo_big != null) {
|
||||
NotificationCenter.getInstance().addToMemCache(56, user_id);
|
||||
NotificationCenter.getInstance().addToMemCache(53, user.photo.photo_big);
|
||||
Intent intent = new Intent(getParentActivity(), GalleryImageViewer.class);
|
||||
getParentActivity().startActivity(intent);
|
||||
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, UserProfileActivity.this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -576,10 +606,13 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen
|
|||
onlineText.setText(LocaleController.formatUserStatus(user));
|
||||
|
||||
TLRPC.FileLocation photo = null;
|
||||
TLRPC.FileLocation photoBig = null;
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
photoBig = user.photo.photo_big;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id));
|
||||
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
||||
return view;
|
||||
} else if (type == 1) {
|
||||
if (view == null) {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import org.telegram.objects.MessageObject;
|
||||
|
||||
public abstract class AbstractGalleryActivity extends PausableActivity {
|
||||
public abstract void topBtn();
|
||||
public abstract void didShowMessageObject(MessageObject obj);
|
||||
}
|
|
@ -111,12 +111,13 @@ public class ActionBar extends FrameLayout {
|
|||
currentLayer.setBackLayoutVisible(currentLayer.isSearchFieldVisible || currentBackOverlay == null ? VISIBLE : INVISIBLE);
|
||||
}
|
||||
if (currentBackOverlay != null) {
|
||||
currentBackOverlay.setVisibility(currentLayer.isSearchFieldVisible ? GONE : VISIBLE);
|
||||
ViewGroup.LayoutParams layoutParams = currentBackOverlay.getLayoutParams();
|
||||
if (currentLayer != null) {
|
||||
currentBackOverlay.setVisibility(currentLayer.isSearchFieldVisible ? GONE : VISIBLE);
|
||||
currentLayer.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
layoutParams.width = Math.min(currentBackOverlayWidth, currentLayer.getBackLayoutWidth());
|
||||
} else {
|
||||
currentBackOverlay.setVisibility(VISIBLE);
|
||||
layoutParams.width = LayoutParams.WRAP_CONTENT;
|
||||
}
|
||||
if (layoutParams.width != 0) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.animation.AnimatorSet;
|
|||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -21,7 +20,6 @@ import android.view.ActionMode;
|
|||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.VelocityTracker;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -51,7 +49,6 @@ public class ActionBarActivity extends Activity {
|
|||
private boolean maybeStartTracking = false;
|
||||
protected boolean startedTracking = false;
|
||||
private int startedTrackingX;
|
||||
private int prevOrientation = -10;
|
||||
protected boolean animationInProgress = false;
|
||||
private VelocityTracker velocityTracker = null;
|
||||
private boolean beginTrackingSent = false;
|
||||
|
@ -206,14 +203,7 @@ public class ActionBarActivity extends Activity {
|
|||
}
|
||||
}
|
||||
containerViewBack.setVisibility(View.GONE);
|
||||
try {
|
||||
if (prevOrientation != -10) {
|
||||
setRequestedOrientation(prevOrientation);
|
||||
prevOrientation = -10;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
Utilities.unlockOrientation(this);
|
||||
startedTracking = false;
|
||||
animationInProgress = false;
|
||||
}
|
||||
|
@ -244,30 +234,7 @@ public class ActionBarActivity extends Activity {
|
|||
}
|
||||
lastFragment.onResume();
|
||||
|
||||
try {
|
||||
prevOrientation = getRequestedOrientation();
|
||||
WindowManager manager = (WindowManager)getSystemService(Activity.WINDOW_SERVICE);
|
||||
if (manager != null && manager.getDefaultDisplay() != null) {
|
||||
int rotation = manager.getDefaultDisplay().getRotation();
|
||||
if (rotation == Surface.ROTATION_270) {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
} else if (rotation == Surface.ROTATION_90) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else if (rotation == Surface.ROTATION_0) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
if (Build.VERSION.SDK_INT >= 9) {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
Utilities.lockOrientation(this);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent ev) {
|
||||
|
|
|
@ -26,8 +26,14 @@ import org.telegram.messenger.Utilities;
|
|||
|
||||
public class ActionBarLayer extends FrameLayout {
|
||||
|
||||
public interface ActionBarMenuOnItemClick {
|
||||
public abstract void onItemClick(int id);
|
||||
public static class ActionBarMenuOnItemClick {
|
||||
public void onItemClick(int id) {
|
||||
|
||||
}
|
||||
|
||||
public boolean canOpenMenu() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private FrameLayout backButtonFrameLayout;
|
||||
|
|
|
@ -75,7 +75,9 @@ public class ActionBarMenu extends LinearLayout {
|
|||
public void onClick(View view) {
|
||||
ActionBarMenuItem item = (ActionBarMenuItem)view;
|
||||
if (item.hasSubMenu()) {
|
||||
item.toggleSubMenu();
|
||||
if (parentActionBarLayer.actionBarMenuOnItemClick.canOpenMenu()) {
|
||||
item.toggleSubMenu();
|
||||
}
|
||||
} else if (item.isSearchField()) {
|
||||
parentActionBarLayer.onSearchFieldVisibilityChanged(item.toggleSearch());
|
||||
} else {
|
||||
|
|
|
@ -79,6 +79,7 @@ public class ActionBarMenuItem extends ImageView {
|
|||
layoutParams.width = Utilities.dp(196);
|
||||
layoutParams.height = Utilities.density >= 3 ? 2 : 1;
|
||||
delimeter.setLayoutParams(layoutParams);
|
||||
delimeter.setTag(100 + id);
|
||||
}
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setTextColor(0xff000000);
|
||||
|
@ -255,4 +256,26 @@ public class ActionBarMenuItem extends ImageView {
|
|||
popupWindow.update(this, parentActionBar.getMeasuredWidth() - popupLayout.getMeasuredWidth() - getLeft() - parentMenu.getLeft(), 0, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public void hideSubItem(int id) {
|
||||
View view = popupLayout.findViewWithTag(id);
|
||||
if (view != null) {
|
||||
view.setVisibility(GONE);
|
||||
}
|
||||
view = popupLayout.findViewWithTag(100 + id);
|
||||
if (view != null) {
|
||||
view.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void showSubItem(int id) {
|
||||
View view = popupLayout.findViewWithTag(id);
|
||||
if (view != null) {
|
||||
view.setVisibility(VISIBLE);
|
||||
}
|
||||
view = popupLayout.findViewWithTag(100 + id);
|
||||
if (view != null) {
|
||||
view.setVisibility(VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,43 +8,40 @@
|
|||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.NinePatchDrawable;
|
||||
import android.os.Build;
|
||||
import android.widget.ImageView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import org.telegram.messenger.TLRPC;
|
||||
import org.telegram.messenger.FileLoader;
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.Utilities;
|
||||
|
||||
public class BackupImageView extends ImageView {
|
||||
boolean makeRequest = true;
|
||||
public String currentPath;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class BackupImageView extends View {
|
||||
public ImageReceiver imageReceiver;
|
||||
public boolean processDetach = true;
|
||||
private boolean isPlaceholder;
|
||||
private boolean ignoreLayout = true;
|
||||
|
||||
TLRPC.FileLocation last_path;
|
||||
String last_httpUrl;
|
||||
String last_filter;
|
||||
int last_placeholder;
|
||||
Bitmap last_placeholderBitmap;
|
||||
int last_size;
|
||||
|
||||
public BackupImageView(android.content.Context context) {
|
||||
public BackupImageView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public BackupImageView(android.content.Context context, android.util.AttributeSet attrs) {
|
||||
public BackupImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public BackupImageView(android.content.Context context, android.util.AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
public BackupImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
imageReceiver = new ImageReceiver();
|
||||
imageReceiver.parentView = new WeakReference<View>(this);
|
||||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String filter, int placeholder) {
|
||||
|
@ -68,135 +65,42 @@ public class BackupImageView extends ImageView {
|
|||
}
|
||||
|
||||
public void setImage(TLRPC.FileLocation path, String httpUrl, String filter, int placeholder, Bitmap placeholderBitmap, int size) {
|
||||
if ((path == null && httpUrl == null) || (path != null && !(path instanceof TLRPC.TL_fileLocation) && !(path instanceof TLRPC.TL_fileEncryptedLocation))) {
|
||||
recycleBitmap(null);
|
||||
currentPath = null;
|
||||
isPlaceholder = true;
|
||||
|
||||
last_path = null;
|
||||
last_httpUrl = null;
|
||||
last_filter = null;
|
||||
last_placeholder = 0;
|
||||
last_size = 0;
|
||||
last_placeholderBitmap = null;
|
||||
|
||||
FileLoader.getInstance().cancelLoadingForImageView(this);
|
||||
if (placeholder != 0) {
|
||||
setImageResourceMy(placeholder);
|
||||
} else if (placeholderBitmap != null) {
|
||||
setImageBitmapMy(placeholderBitmap);
|
||||
}
|
||||
return;
|
||||
}
|
||||
String key;
|
||||
if (path != null) {
|
||||
key = path.volume_id + "_" + path.local_id;
|
||||
} else {
|
||||
key = Utilities.MD5(httpUrl);
|
||||
}
|
||||
if (filter != null) {
|
||||
key += "@" + filter;
|
||||
}
|
||||
Bitmap img;
|
||||
if (currentPath != null) {
|
||||
if (currentPath.equals(key)) {
|
||||
return;
|
||||
} else {
|
||||
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true);
|
||||
recycleBitmap(img);
|
||||
}
|
||||
} else {
|
||||
img = FileLoader.getInstance().getImageFromMemory(path, httpUrl, this, filter, true);
|
||||
}
|
||||
currentPath = key;
|
||||
last_path = path;
|
||||
last_httpUrl = httpUrl;
|
||||
last_filter = filter;
|
||||
last_placeholder = placeholder;
|
||||
last_placeholderBitmap = placeholderBitmap;
|
||||
last_size = size;
|
||||
if (img == null) {
|
||||
isPlaceholder = true;
|
||||
if (placeholder != 0) {
|
||||
setImageResourceMy(placeholder);
|
||||
} else if (placeholderBitmap != null) {
|
||||
setImageBitmapMy(placeholderBitmap);
|
||||
}
|
||||
FileLoader.getInstance().loadImage(path, httpUrl, this, filter, true, size);
|
||||
} else {
|
||||
setImageBitmap(img, currentPath);
|
||||
Drawable placeholderDrawable = null;
|
||||
if (placeholderBitmap != null) {
|
||||
placeholderDrawable = new BitmapDrawable(null, placeholderBitmap);
|
||||
} else if (placeholder != 0) {
|
||||
placeholderDrawable = getResources().getDrawable(placeholder);
|
||||
}
|
||||
imageReceiver.setImage(path, httpUrl, filter, placeholderDrawable, size);
|
||||
}
|
||||
|
||||
public void setImageBitmap(Bitmap bitmap, String imgKey) {
|
||||
if (currentPath == null || !imgKey.equals(currentPath)) {
|
||||
return;
|
||||
}
|
||||
isPlaceholder = false;
|
||||
FileLoader.getInstance().incrementUseCount(currentPath);
|
||||
if (ignoreLayout) {
|
||||
makeRequest = false;
|
||||
}
|
||||
super.setImageBitmap(bitmap);
|
||||
if (ignoreLayout) {
|
||||
makeRequest = true;
|
||||
}
|
||||
public void setImageBitmap(Bitmap bitmap) {
|
||||
imageReceiver.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
public void clearImage() {
|
||||
recycleBitmap(null);
|
||||
}
|
||||
|
||||
private void recycleBitmap(Bitmap newBitmap) {
|
||||
Drawable drawable = getDrawable();
|
||||
if (drawable == null || isPlaceholder) {
|
||||
return;
|
||||
}
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
|
||||
if (bitmap != null && bitmap != 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());
|
||||
}
|
||||
if (canDelete) {
|
||||
setImageBitmap(null);
|
||||
if (Build.VERSION.SDK_INT < 11) {
|
||||
bitmap.recycle();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
setImageBitmap(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (drawable instanceof NinePatchDrawable) {
|
||||
|
||||
}
|
||||
public void setImageResource(int resId) {
|
||||
imageReceiver.setImageBitmap(getResources().getDrawable(resId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (processDetach) {
|
||||
recycleBitmap(null);
|
||||
imageReceiver.clearImage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
try {
|
||||
super.onDraw(canvas);
|
||||
} catch (Exception e) {
|
||||
FileLoader.getInstance().removeImage(currentPath);
|
||||
currentPath = null;
|
||||
setImage(last_path, last_httpUrl, last_filter, last_placeholder, last_placeholderBitmap, last_size);
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
imageReceiver.imageX = 0;
|
||||
imageReceiver.imageY = 0;
|
||||
imageReceiver.imageW = getWidth();
|
||||
imageReceiver.imageH = getHeight();
|
||||
imageReceiver.draw(canvas, 0, 0, imageReceiver.imageW, imageReceiver.imageH);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
public void setImageResourceMy(int resId) {
|
||||
if (ignoreLayout) {
|
||||
makeRequest = false;
|
||||
|
@ -207,25 +111,7 @@ public class BackupImageView extends ImageView {
|
|||
}
|
||||
}
|
||||
|
||||
public void setImageResource(int resId) {
|
||||
if (resId != 0) {
|
||||
recycleBitmap(null);
|
||||
}
|
||||
currentPath = null;
|
||||
last_path = null;
|
||||
last_httpUrl = null;
|
||||
last_filter = null;
|
||||
last_placeholder = 0;
|
||||
last_size = 0;
|
||||
last_placeholderBitmap = null;
|
||||
if (ignoreLayout) {
|
||||
makeRequest = false;
|
||||
}
|
||||
super.setImageResource(resId);
|
||||
if (ignoreLayout) {
|
||||
makeRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setImageBitmapMy(Bitmap bitmap) {
|
||||
if (ignoreLayout) {
|
||||
|
@ -238,29 +124,5 @@ public class BackupImageView extends ImageView {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setImageBitmap(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
recycleBitmap(null);
|
||||
}
|
||||
currentPath = null;
|
||||
last_path = null;
|
||||
last_httpUrl = null;
|
||||
last_filter = null;
|
||||
last_placeholder = 0;
|
||||
last_size = 0;
|
||||
last_placeholderBitmap = null;
|
||||
if (ignoreLayout) {
|
||||
makeRequest = false;
|
||||
}
|
||||
super.setImageBitmap(bitmap);
|
||||
if (ignoreLayout) {
|
||||
makeRequest = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void requestLayout() {
|
||||
if (makeRequest) {
|
||||
super.requestLayout();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.4.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013-2014.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
public class ClippingImageView extends View {
|
||||
private int clipBottom;
|
||||
private int clipLeft;
|
||||
private int clipRight;
|
||||
private int clipTop;
|
||||
private Rect drawRect;
|
||||
private Paint paint;
|
||||
private Bitmap bmp;
|
||||
private onDrawListener drawListener;
|
||||
|
||||
public static interface onDrawListener {
|
||||
public abstract void onDraw();
|
||||
}
|
||||
|
||||
public ClippingImageView(Context context) {
|
||||
super(context);
|
||||
paint = new Paint();
|
||||
paint.setFilterBitmap(true);
|
||||
drawRect = new Rect();
|
||||
}
|
||||
|
||||
public int getClipBottom() {
|
||||
return clipBottom;
|
||||
}
|
||||
|
||||
public int getClipHorizontal() {
|
||||
return clipRight;
|
||||
}
|
||||
|
||||
public int getClipLeft() {
|
||||
return clipLeft;
|
||||
}
|
||||
|
||||
public int getClipRight() {
|
||||
return clipRight;
|
||||
}
|
||||
|
||||
public int getClipTop() {
|
||||
return clipTop;
|
||||
}
|
||||
|
||||
public void onDraw(Canvas canvas) {
|
||||
if (bmp != null) {
|
||||
if (drawListener != null && getScaleY() != 1) {
|
||||
drawListener.onDraw();
|
||||
}
|
||||
canvas.save();
|
||||
canvas.clipRect(clipLeft / getScaleY(), clipTop / getScaleY(), getWidth() - clipRight / getScaleY(), getHeight() - clipBottom / getScaleY());
|
||||
drawRect.set(0, 0, getWidth(), getHeight());
|
||||
canvas.drawBitmap(this.bmp, null, drawRect, this.paint);
|
||||
canvas.restore();
|
||||
}
|
||||
}
|
||||
|
||||
public void setClipBottom(int value) {
|
||||
clipBottom = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setClipHorizontal(int value) {
|
||||
clipRight = value;
|
||||
clipLeft = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setClipLeft(int value) {
|
||||
clipLeft = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setClipRight(int value) {
|
||||
clipRight = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setClipTop(int value) {
|
||||
clipTop = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setClipVertical(int value) {
|
||||
clipBottom = value;
|
||||
clipTop = value;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setImageBitmap(Bitmap bitmap) {
|
||||
bmp = bitmap;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setOnDrawListener(onDrawListener listener) {
|
||||
drawListener = listener;
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
|
||||
public class GalleryViewPager extends ViewPager {
|
||||
PointF last;
|
||||
public PZSImageView mCurrentView;
|
||||
|
||||
public GalleryViewPager(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public GalleryViewPager(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
private float[] handleMotionEvent(MotionEvent event) {
|
||||
switch (event.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
last = new PointF(event.getX(0), event.getY(0));
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
case MotionEvent.ACTION_UP:
|
||||
PointF curr = new PointF(event.getX(0), event.getY(0));
|
||||
return new float[] { curr.x - last.x, curr.y - last.y };
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
try {
|
||||
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||
super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
if (mCurrentView == null) {
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
float[] difference = handleMotionEvent(event);
|
||||
|
||||
if (difference != null && mCurrentView.getOnRightSide() && difference[0] < 0) {
|
||||
return super.onTouchEvent(event);
|
||||
} else if (difference != null && mCurrentView.getOnLeftSide() && difference[0] > 0) {
|
||||
return super.onTouchEvent(event);
|
||||
} else if (difference == null && (mCurrentView.getOnLeftSide() || mCurrentView.getOnRightSide())) {
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
getAdapter().notifyDataSetChanged();
|
||||
} catch (Exception e2) {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
try {
|
||||
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
|
||||
super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
if (mCurrentView == null) {
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
float[] difference = handleMotionEvent(event);
|
||||
|
||||
if (difference != null && difference.length > 0 && mCurrentView.getOnRightSide() && difference[0] < 0) {
|
||||
return super.onInterceptTouchEvent(event);
|
||||
} else if (difference != null && difference.length > 0 && mCurrentView.getOnLeftSide() && difference[0] > 0) {
|
||||
return super.onInterceptTouchEvent(event);
|
||||
} else if ((difference == null || difference.length == 0) && (mCurrentView.getOnLeftSide() || mCurrentView.getOnRightSide())) {
|
||||
return super.onInterceptTouchEvent(event);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -108,7 +108,7 @@ public class ImageReceiver {
|
|||
isPlaceholder = false;
|
||||
FileLoader.getInstance().incrementUseCount(currentPath);
|
||||
currentImage = new BitmapDrawable(null, bitmap);
|
||||
if (!selfSetting && parentView.get() != null) {
|
||||
if (!selfSetting && parentView != null && parentView.get() != null) {
|
||||
if (imageW != 0) {
|
||||
parentView.get().invalidate(imageX, imageY, imageX + imageW, imageY + imageH);
|
||||
} else {
|
||||
|
@ -120,7 +120,12 @@ public class ImageReceiver {
|
|||
public void setImageBitmap(Bitmap bitmap) {
|
||||
FileLoader.getInstance().cancelLoadingForImageView(this);
|
||||
recycleBitmap(null);
|
||||
last_placeholder = new BitmapDrawable(null, bitmap);
|
||||
if (bitmap != null) {
|
||||
last_placeholder = new BitmapDrawable(null, bitmap);
|
||||
} else {
|
||||
last_placeholder = null;
|
||||
}
|
||||
isPlaceholder = true;
|
||||
currentPath = null;
|
||||
last_path = null;
|
||||
last_httpUrl = null;
|
||||
|
@ -175,13 +180,14 @@ public class ImageReceiver {
|
|||
}
|
||||
|
||||
public void draw(Canvas canvas, int x, int y, int w, int h) {
|
||||
if (!isVisible) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (currentImage != null) {
|
||||
int bitmapW = currentImage.getIntrinsicWidth();
|
||||
int bitmapH = currentImage.getIntrinsicHeight();
|
||||
Drawable bitmapDrawable = currentImage;
|
||||
if (bitmapDrawable == null && last_placeholder != null && last_placeholder instanceof BitmapDrawable) {
|
||||
bitmapDrawable = last_placeholder;
|
||||
}
|
||||
if (bitmapDrawable != null) {
|
||||
int bitmapW = bitmapDrawable.getIntrinsicWidth();
|
||||
int bitmapH = bitmapDrawable.getIntrinsicHeight();
|
||||
float scaleW = bitmapW / (float)w;
|
||||
float scaleH = bitmapH / (float)h;
|
||||
|
||||
|
@ -196,19 +202,25 @@ public class ImageReceiver {
|
|||
bitmapH /= scaleW;
|
||||
drawRegion.set(x, y - (bitmapH - h) / 2, x + w, y + (bitmapH + h) / 2);
|
||||
}
|
||||
currentImage.setBounds(drawRegion);
|
||||
currentImage.draw(canvas);
|
||||
bitmapDrawable.setBounds(drawRegion);
|
||||
if (isVisible) {
|
||||
bitmapDrawable.draw(canvas);
|
||||
}
|
||||
|
||||
canvas.restore();
|
||||
} else {
|
||||
drawRegion.set(x, y, x + w, y + h);
|
||||
currentImage.setBounds(drawRegion);
|
||||
currentImage.draw(canvas);
|
||||
bitmapDrawable.setBounds(drawRegion);
|
||||
if (isVisible) {
|
||||
bitmapDrawable.draw(canvas);
|
||||
}
|
||||
}
|
||||
} else if (last_placeholder != null) {
|
||||
drawRegion.set(x, y, x + w, y + h);
|
||||
last_placeholder.setBounds(drawRegion);
|
||||
last_placeholder.draw(canvas);
|
||||
if (isVisible) {
|
||||
last_placeholder.draw(canvas);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (currentPath != null) {
|
||||
|
@ -229,18 +241,24 @@ public class ImageReceiver {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void setVisible(boolean value) {
|
||||
public void setVisible(boolean value, boolean invalidate) {
|
||||
if (isVisible == value) {
|
||||
return;
|
||||
}
|
||||
isVisible = value;
|
||||
View parent = parentView.get();
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
if (invalidate) {
|
||||
View parent = parentView.get();
|
||||
if (parent != null) {
|
||||
parent.invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
public boolean hasImage() {
|
||||
return currentImage != null || last_placeholder != null || currentPath != null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,16 +106,7 @@ public class NotificationView extends LinearLayout {
|
|||
}
|
||||
hide(true);
|
||||
|
||||
if (currentChatId != 0) {
|
||||
NotificationCenter.getInstance().addToMemCache("push_chat_id", currentChatId);
|
||||
}
|
||||
if (currentUserId != 0) {
|
||||
NotificationCenter.getInstance().addToMemCache("push_user_id", currentUserId);
|
||||
}
|
||||
if (currentEncId != 0) {
|
||||
NotificationCenter.getInstance().addToMemCache("push_enc_id", currentEncId);
|
||||
}
|
||||
NotificationCenter.getInstance().postNotificationName(658);
|
||||
NotificationCenter.getInstance().postNotificationName(658, currentChatId, currentUserId, currentEncId);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,550 +0,0 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.FloatMath;
|
||||
import android.util.TypedValue;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.GestureDetector.SimpleOnGestureListener;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.R;
|
||||
|
||||
public class PZSImageView extends BackupImageView {
|
||||
|
||||
enum ImageScaleType {
|
||||
FitCenter, TopCrop, CenterCrop
|
||||
}
|
||||
|
||||
public ImageScaleType defaultScaleType = ImageScaleType.FitCenter;
|
||||
public ImageScaleType doubleTapScaleType = ImageScaleType.TopCrop;
|
||||
|
||||
// private static final String TAG = "GalleryImageView";
|
||||
|
||||
// wrapped motion event code.
|
||||
protected static final int PZS_ACTION_INIT = 100;
|
||||
protected static final int PZS_ACTION_SCALE = 1001;
|
||||
protected static final int PZS_ACTION_TRANSLATE = 1002;
|
||||
protected static final int PZS_ACTION_SCALE_TO_TRANSLATE = 1003;
|
||||
protected static final int PZS_ACTION_TRANSLATE_TO_SCALE = 1004;
|
||||
protected static final int PZS_ACTION_FIT_CENTER = 1005;
|
||||
protected static final int PZS_ACTION_CENTER_CROP = 1006;
|
||||
protected static final int PZS_ACTION_TO_LEFT_SIDE = 1007;
|
||||
protected static final int PZS_ACTION_TO_RIGHT_SIDE = 1008;
|
||||
protected static final int PZS_ACTION_TOP_CROP = 1009;
|
||||
protected static final int PZS_ACTION_CANCEL = -1;
|
||||
|
||||
private final static float MAX_SCALE_TO_SCREEN = 2.f;
|
||||
private final static float MIN_SCALE_TO_SCREEN = 1.f;
|
||||
|
||||
private static final float MIN_SCALE_SPAN = 10.f;
|
||||
|
||||
// calculated min / max scale ratio based on image & screen size.
|
||||
private float mMinScaleFactor = 1.f;
|
||||
private float mMaxScaleFactor = 2.f;
|
||||
|
||||
public boolean isVideo = false;
|
||||
private boolean mIsFirstDraw = true; // check flag to calculate necessary
|
||||
// init values.
|
||||
private int mImageWidth; // current set image width
|
||||
private int mImageHeight; // current set image height
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public TextView videoText = null;
|
||||
|
||||
public PZSImageView(Context context) {
|
||||
super(context);
|
||||
mContext = context;
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
public PZSImageView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
public PZSImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
mContext = context;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
// should use matrix scale type.
|
||||
setScaleType(ScaleType.MATRIX);
|
||||
Matrix mat = getImageMatrix();
|
||||
mat.reset();
|
||||
setImageMatrix(mat);
|
||||
|
||||
gd = new GestureDetector(mContext, new SimpleOnGestureListener() {
|
||||
|
||||
/*@Override
|
||||
public boolean onDoubleTap(MotionEvent event) {
|
||||
int action = parseDoubleTapMotionEvent(event);
|
||||
touchAction(action, event);
|
||||
return true; // indicate event was handled
|
||||
}*/
|
||||
|
||||
@Override
|
||||
public boolean onSingleTapConfirmed(MotionEvent ev) {
|
||||
((AbstractGalleryActivity) mContext).topBtn();
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
videoText = new TextView(getContext());
|
||||
videoText.setTextColor(0xffffffff);
|
||||
videoText.setBackgroundColor(0x66000000);
|
||||
videoText.setGravity(Gravity.CENTER);
|
||||
videoText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
|
||||
videoText.setText(LocaleController.getString("NoChats", R.string.NoChats));
|
||||
videoText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
|
||||
}
|
||||
|
||||
GestureDetector gd;
|
||||
|
||||
@Override
|
||||
public void setImageBitmap(Bitmap bitmap, String imgKey) {
|
||||
super.setImageBitmap(bitmap, imgKey);
|
||||
mIsFirstDraw = true;
|
||||
if (bitmap != null) {
|
||||
mImageWidth = bitmap.getWidth();
|
||||
mImageHeight = bitmap.getHeight();
|
||||
} else {
|
||||
mImageWidth = getWidth();
|
||||
mImageHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageBitmap(Bitmap bitmap) {
|
||||
super.setImageBitmap(bitmap);
|
||||
mIsFirstDraw = true;
|
||||
if (bitmap != null) {
|
||||
mImageWidth = bitmap.getWidth();
|
||||
mImageHeight = bitmap.getHeight();
|
||||
} else {
|
||||
mImageWidth = getWidth();
|
||||
mImageHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
public void setImageBitmapMy(Bitmap bitmap) {
|
||||
super.setImageBitmapMy(bitmap);
|
||||
mIsFirstDraw = true;
|
||||
if (bitmap != null) {
|
||||
mImageWidth = bitmap.getWidth();
|
||||
mImageHeight = bitmap.getHeight();
|
||||
} else {
|
||||
mImageWidth = getWidth();
|
||||
mImageHeight = getHeight();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
mIsFirstDraw = true;
|
||||
if (getDrawable() == null) {
|
||||
mImageHeight = h;
|
||||
mImageWidth = w;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
|
||||
if (mIsFirstDraw) {
|
||||
mIsFirstDraw = false;
|
||||
if (defaultScaleType == ImageScaleType.FitCenter)
|
||||
fitCenter();
|
||||
else if (defaultScaleType == ImageScaleType.TopCrop)
|
||||
topCrop();
|
||||
else if (defaultScaleType == ImageScaleType.CenterCrop)
|
||||
centerCrop();
|
||||
calculateScaleFactorLimit();
|
||||
validateMatrix();
|
||||
}
|
||||
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
|
||||
try {
|
||||
super.onDraw(canvas);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
FileLog.e("tmessages", "trying draw " + currentPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculateScaleFactorLimit() {
|
||||
|
||||
// set max / min scale factor.
|
||||
mMaxScaleFactor = Math.max(getHeight() * MAX_SCALE_TO_SCREEN
|
||||
/ mImageHeight, getWidth() * MAX_SCALE_TO_SCREEN / mImageWidth);
|
||||
|
||||
mMinScaleFactor = Math.min(getHeight() * MIN_SCALE_TO_SCREEN
|
||||
/ mImageHeight, getWidth() * MIN_SCALE_TO_SCREEN / mImageWidth);
|
||||
|
||||
if (getDrawable() == null) {
|
||||
mMaxScaleFactor = mMinScaleFactor;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (gd.onTouchEvent(event)) {
|
||||
return true;
|
||||
}
|
||||
int action = parseMotionEvent(event);
|
||||
touchAction(action, event);
|
||||
return true; // indicate event was handled
|
||||
}
|
||||
|
||||
private void touchAction(int action, MotionEvent event) {
|
||||
switch (action) {
|
||||
case PZS_ACTION_INIT:
|
||||
initGestureAction(event.getX(), event.getY());
|
||||
break;
|
||||
case PZS_ACTION_SCALE:
|
||||
handleScale(event);
|
||||
break;
|
||||
case PZS_ACTION_TRANSLATE:
|
||||
handleTranslate(event);
|
||||
break;
|
||||
case PZS_ACTION_TRANSLATE_TO_SCALE:
|
||||
initGestureAction(event.getX(), event.getY());
|
||||
break;
|
||||
case PZS_ACTION_SCALE_TO_TRANSLATE:
|
||||
int activeIndex = (event.getActionIndex() == 0 ? 1 : 0);
|
||||
initGestureAction(event.getX(activeIndex), event.getY(activeIndex));
|
||||
break;
|
||||
case PZS_ACTION_FIT_CENTER:
|
||||
fitCenter();
|
||||
initGestureAction(event.getX(), event.getY());
|
||||
break;
|
||||
case PZS_ACTION_CENTER_CROP:
|
||||
centerCrop();
|
||||
initGestureAction(event.getX(), event.getY());
|
||||
break;
|
||||
case PZS_ACTION_TOP_CROP:
|
||||
topCrop();
|
||||
initGestureAction(event.getX(), event.getY());
|
||||
break;
|
||||
case PZS_ACTION_TO_LEFT_SIDE:
|
||||
toLeftSide();
|
||||
break;
|
||||
case PZS_ACTION_TO_RIGHT_SIDE:
|
||||
toRightSide();
|
||||
break;
|
||||
case PZS_ACTION_CANCEL:
|
||||
break;
|
||||
}
|
||||
|
||||
// check current position of bitmap.
|
||||
validateMatrix();
|
||||
updateMatrix();
|
||||
}
|
||||
|
||||
private int parseDoubleTapMotionEvent(MotionEvent ev) {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
float scaleNow = values[Matrix.MSCALE_X];
|
||||
float scaleX = (getWidth() - getPaddingLeft() - getPaddingRight())
|
||||
/ (float) mImageWidth;
|
||||
float scaleY = (getHeight() - getPaddingTop() - getPaddingBottom())
|
||||
/ (float) mImageHeight;
|
||||
if (scaleNow >= Math.max(scaleX, scaleY))
|
||||
return PZS_ACTION_FIT_CENTER;
|
||||
else if (scaleNow < Math.max(scaleX, scaleY)) {
|
||||
if (doubleTapScaleType == ImageScaleType.FitCenter)
|
||||
return PZS_ACTION_FIT_CENTER;
|
||||
else if (doubleTapScaleType == ImageScaleType.TopCrop)
|
||||
return PZS_ACTION_TOP_CROP;
|
||||
else if (doubleTapScaleType == ImageScaleType.CenterCrop)
|
||||
return PZS_ACTION_CENTER_CROP;
|
||||
|
||||
}
|
||||
return PZS_ACTION_FIT_CENTER;
|
||||
}
|
||||
|
||||
private int parseMotionEvent(MotionEvent ev) {
|
||||
|
||||
switch (ev.getAction() & MotionEvent.ACTION_MASK) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
return PZS_ACTION_INIT;
|
||||
case MotionEvent.ACTION_POINTER_DOWN:
|
||||
// more than one pointer is pressed...
|
||||
return PZS_ACTION_TRANSLATE_TO_SCALE;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_POINTER_UP:
|
||||
if (ev.getPointerCount() == 2) {
|
||||
return PZS_ACTION_SCALE_TO_TRANSLATE;
|
||||
} else {
|
||||
return PZS_ACTION_INIT;
|
||||
}
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
if (ev.getPointerCount() == 1)
|
||||
return PZS_ACTION_TRANSLATE;
|
||||
else if (ev.getPointerCount() == 2)
|
||||
return PZS_ACTION_SCALE;
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ///////////////////////////////////////////////
|
||||
// Related matrix calculation stuffs.
|
||||
// ///////////////////////////////////////////////
|
||||
|
||||
private Matrix mCurrentMatrix = new Matrix();
|
||||
private Matrix mSavedMatrix = new Matrix();
|
||||
|
||||
// Remember some things for zooming
|
||||
private PointF mStartPoint = new PointF();
|
||||
private PointF mMidPoint = new PointF();
|
||||
private float mInitScaleSpan = 1f;
|
||||
|
||||
protected void initGestureAction(float x, float y) {
|
||||
mSavedMatrix.set(mCurrentMatrix);
|
||||
mStartPoint.set(x, y);
|
||||
mInitScaleSpan = 0.f;
|
||||
}
|
||||
|
||||
protected void handleScale(MotionEvent event) {
|
||||
if (isVideo) {
|
||||
return;
|
||||
}
|
||||
float newSpan = spacing(event);
|
||||
|
||||
// if two finger is too close, pointer index is bumped.. so just ignore
|
||||
// it.
|
||||
if (newSpan < MIN_SCALE_SPAN)
|
||||
return;
|
||||
|
||||
if (mInitScaleSpan == 0.f) {
|
||||
// init values. scale gesture action is just started.
|
||||
mInitScaleSpan = newSpan;
|
||||
midPoint(mMidPoint, event);
|
||||
} else {
|
||||
float scale = normalizeScaleFactor(mSavedMatrix, newSpan,
|
||||
mInitScaleSpan);
|
||||
mCurrentMatrix.set(mSavedMatrix);
|
||||
mCurrentMatrix.postScale(scale, scale, mMidPoint.x, mMidPoint.y);
|
||||
}
|
||||
}
|
||||
|
||||
private float normalizeScaleFactor(Matrix curMat, float newSpan,
|
||||
float stdSpan) {
|
||||
|
||||
float values[] = new float[9];
|
||||
curMat.getValues(values);
|
||||
float scale = values[Matrix.MSCALE_X];
|
||||
|
||||
if (stdSpan == newSpan) {
|
||||
return scale;
|
||||
} else {
|
||||
float newScaleFactor = newSpan / stdSpan;
|
||||
float candinateScale = scale * newScaleFactor;
|
||||
|
||||
if (candinateScale > mMaxScaleFactor) {
|
||||
return mMaxScaleFactor / scale;
|
||||
} else if (candinateScale < mMinScaleFactor) {
|
||||
return mMinScaleFactor / scale;
|
||||
} else {
|
||||
return newScaleFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleTranslate(MotionEvent event) {
|
||||
mCurrentMatrix.set(mSavedMatrix);
|
||||
mCurrentMatrix.postTranslate(event.getX() - mStartPoint.x, event.getY()
|
||||
- mStartPoint.y);
|
||||
}
|
||||
|
||||
private RectF mTraslateLimitRect = new RectF(); // reuse instance.
|
||||
|
||||
public boolean getOnLeftSide() {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
float tranX = values[Matrix.MTRANS_X];
|
||||
return tranX >= mTraslateLimitRect.right;
|
||||
}
|
||||
|
||||
public boolean getOnRightSide() {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
float tranX = values[Matrix.MTRANS_X];
|
||||
return tranX <= mTraslateLimitRect.left;
|
||||
}
|
||||
|
||||
private void validateMatrix() {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
|
||||
// get current matrix values.
|
||||
float scale = values[Matrix.MSCALE_X];
|
||||
float tranX = values[Matrix.MTRANS_X];
|
||||
float tranY = values[Matrix.MTRANS_Y];
|
||||
|
||||
int imageHeight = (int) (scale * mImageHeight);
|
||||
int imageWidth = (int) (scale * mImageWidth);
|
||||
if (imageHeight == 0 || imageWidth == 0) {
|
||||
imageHeight = getHeight();
|
||||
imageWidth = getWidth();
|
||||
}
|
||||
|
||||
mTraslateLimitRect.setEmpty();
|
||||
// don't think about optimize code. first, just write code case by case.
|
||||
|
||||
// check TOP & BOTTOM
|
||||
if (imageHeight > getHeight()) {
|
||||
// image height is taller than view
|
||||
mTraslateLimitRect.top = getHeight() - imageHeight
|
||||
- getPaddingTop() - getPaddingBottom();
|
||||
mTraslateLimitRect.bottom = 0.f;
|
||||
} else {
|
||||
mTraslateLimitRect.top = mTraslateLimitRect.bottom = (getHeight()
|
||||
- imageHeight - getPaddingTop() - getPaddingBottom()) / 2.f;
|
||||
}
|
||||
|
||||
// check LEFT & RIGHT
|
||||
if (imageWidth > getWidth()) {
|
||||
// image width is longer than view
|
||||
mTraslateLimitRect.left = getWidth() - imageWidth
|
||||
- getPaddingRight() - getPaddingLeft();
|
||||
mTraslateLimitRect.right = 0.f;
|
||||
} else {
|
||||
mTraslateLimitRect.left = mTraslateLimitRect.right = (getWidth()
|
||||
- imageWidth - getPaddingLeft() - getPaddingRight()) / 2.f;
|
||||
}
|
||||
|
||||
float newTranX = tranX;
|
||||
newTranX = Math.max(newTranX, mTraslateLimitRect.left);
|
||||
newTranX = Math.min(newTranX, mTraslateLimitRect.right);
|
||||
|
||||
float newTranY = tranY;
|
||||
newTranY = Math.max(newTranY, mTraslateLimitRect.top);
|
||||
newTranY = Math.min(newTranY, mTraslateLimitRect.bottom);
|
||||
|
||||
values[Matrix.MTRANS_X] = newTranX;
|
||||
values[Matrix.MTRANS_Y] = newTranY;
|
||||
mCurrentMatrix.setValues(values);
|
||||
|
||||
if (!mTraslateLimitRect.contains(tranX, tranY)) {
|
||||
// set new start point.
|
||||
mStartPoint.offset(tranX - newTranX, tranY - newTranY);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateMatrix() {
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
protected void fitCenter() {
|
||||
// move image to center....
|
||||
mCurrentMatrix.reset();
|
||||
|
||||
float scaleX = (getWidth() - getPaddingLeft() - getPaddingRight())
|
||||
/ (float) mImageWidth;
|
||||
float scaleY = (getHeight() - getPaddingTop() - getPaddingBottom())
|
||||
/ (float) mImageHeight;
|
||||
float scale = Math.min(scaleX, scaleY);
|
||||
|
||||
float dx = (getWidth() - getPaddingLeft() - getPaddingRight() - mImageWidth
|
||||
* scale) / 2.f;
|
||||
float dy = (getHeight() - getPaddingTop() - getPaddingBottom() - mImageHeight
|
||||
* scale) / 2.f;
|
||||
mCurrentMatrix.postScale(scale, scale);
|
||||
mCurrentMatrix.postTranslate(dx, dy);
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
public void toLeftSide() {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
float tranX = values[Matrix.MTRANS_X];
|
||||
mCurrentMatrix.postTranslate(mTraslateLimitRect.right - tranX, 0);
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
public void toRightSide() {
|
||||
float values[] = new float[9];
|
||||
mCurrentMatrix.getValues(values);
|
||||
float tranX = values[Matrix.MTRANS_X];
|
||||
mCurrentMatrix.postTranslate(mTraslateLimitRect.left - tranX, 0);
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
protected void centerCrop() {
|
||||
mCurrentMatrix.reset();
|
||||
|
||||
float scaleX = (getWidth() - getPaddingLeft() - getPaddingRight())
|
||||
/ (float) mImageWidth;
|
||||
float scaleY = (getHeight() - getPaddingTop() - getPaddingBottom())
|
||||
/ (float) mImageHeight;
|
||||
float scale = Math.max(scaleX, scaleY);
|
||||
|
||||
float dx = (getWidth() - getPaddingLeft() - getPaddingRight() - mImageWidth
|
||||
* scale) / 2.f;
|
||||
float dy = (getHeight() - getPaddingTop() - getPaddingBottom() - mImageHeight
|
||||
* scale) / 2.f;
|
||||
|
||||
mCurrentMatrix.postScale(scale, scale);
|
||||
mCurrentMatrix.postTranslate(dx, dy);
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
protected void topCrop() {
|
||||
mCurrentMatrix.reset();
|
||||
|
||||
float scaleX = (getWidth() - getPaddingLeft() - getPaddingRight())
|
||||
/ (float) mImageWidth;
|
||||
float scaleY = (getHeight() - getPaddingTop() - getPaddingBottom())
|
||||
/ (float) mImageHeight;
|
||||
float scale = Math.max(scaleX, scaleY);
|
||||
|
||||
mCurrentMatrix.postScale(scale, scale);
|
||||
mCurrentMatrix.postTranslate(0, 0);
|
||||
setImageMatrix(mCurrentMatrix);
|
||||
}
|
||||
|
||||
/** Determine the space between the first two fingers */
|
||||
private float spacing(MotionEvent event) {
|
||||
// ...
|
||||
float x = event.getX(0) - event.getX(1);
|
||||
float y = event.getY(0) - event.getY(1);
|
||||
return FloatMath.sqrt(x * x + y * y);
|
||||
}
|
||||
|
||||
/** Calculate the mid point of the first two fingers */
|
||||
private void midPoint(PointF point, MotionEvent event) {
|
||||
// ...
|
||||
float x = event.getX(0) + event.getX(1);
|
||||
float y = event.getY(0) + event.getY(1);
|
||||
point.set(x / 2, y / 2);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* This is the source code of Telegram for Android v. 1.3.2.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
*
|
||||
* Copyright Nikolai Kudashov, 2013.
|
||||
*/
|
||||
|
||||
package org.telegram.ui.Views;
|
||||
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
|
||||
import org.telegram.ui.ApplicationLoader;
|
||||
|
||||
public class PausableActivity extends ActionBarActivity {
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
ApplicationLoader.lastPauseTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
ApplicationLoader.resetLastPauseTime();
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#dd000000" />
|
||||
</shape>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/photocancel_pressed"
|
||||
android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/photocancel" />
|
||||
</selector>
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/photoload_pressed"
|
||||
android:state_pressed="true" />
|
||||
<item android:drawable="@drawable/photoload" />
|
||||
</selector>
|
|
@ -1,87 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="#00000000"
|
||||
android:layout_gravity="top">
|
||||
|
||||
<org.telegram.ui.Views.GalleryViewPager
|
||||
android:id="@+id/gallery_view_pager"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="top"/>
|
||||
|
||||
<ProgressBar
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="3dp"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:progress="50"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:id="@+id/action_progress"
|
||||
android:max="100"
|
||||
android:progressDrawable="@drawable/photo_progress"
|
||||
android:layout_marginBottom="48dp"
|
||||
android:layout_marginLeft="6dp"
|
||||
android:layout_marginRight="6dp"/>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="#dd000000"
|
||||
android:id="@+id/gallery_view_bottom_view">
|
||||
|
||||
<ImageView
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="50dp"
|
||||
android:src="@drawable/ic_ab_share_white"
|
||||
android:scaleType="center"
|
||||
android:id="@+id/gallery_view_share_button"
|
||||
android:background="@drawable/list_selector"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="50dp"
|
||||
android:src="@drawable/ic_ab_delete_white"
|
||||
android:scaleType="center"
|
||||
android:layout_gravity="right"
|
||||
android:id="@+id/gallery_view_delete_button"
|
||||
android:background="@drawable/list_selector"/>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:textSize="17dp"
|
||||
android:maxLines="1"
|
||||
android:textColor="#ffffff"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="2dp"
|
||||
android:id="@+id/gallery_view_name_text"
|
||||
android:layout_gravity="top"/>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_marginLeft="60dp"
|
||||
android:layout_marginRight="60dp"
|
||||
android:layout_marginTop="26dp"
|
||||
android:gravity="center"
|
||||
android:textColor="#b8bdbe"
|
||||
android:textSize="14dp"
|
||||
android:id="@+id/gallery_view_time_text"
|
||||
android:layout_gravity="top"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_marginTop="-70dp"
|
||||
android:id="@+id/fake_title_view"
|
||||
android:textSize="18dp"
|
||||
android:layout_gravity="top|left"/>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<org.telegram.ui.Views.PZSImageView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/page_image"/>
|
||||
|
||||
<TextView android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="26dp"
|
||||
android:textColor="#ffffff"
|
||||
android:background="@drawable/system_black"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:clickable="true"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/action_button"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
@ -24,48 +24,12 @@
|
|||
<item name="android:actionBarItemBackground">@drawable/bar_selector</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.TMessages.Gallery" parent="Theme.AppCompat">
|
||||
<item name="android:actionBarStyle">@style/ActionBar.Transparent.TMessages.Gallery</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:colorBackground">@color/gallery_background_color</item>
|
||||
<item name="android:windowBackground">@color/gallery_background_color</item>
|
||||
<item name="android:homeAsUpIndicator">@drawable/ab_icon_up_gallery</item>
|
||||
<item name="android:actionOverflowButtonStyle">@style/ActionBar.Transparent.TMessages.Gallery.ActionButtonOverflow</item>
|
||||
<item name="android:listChoiceBackgroundIndicator">@drawable/list_selector</item>
|
||||
<item name="android:editTextStyle">@style/Theme.TMessages.EditText</item>
|
||||
|
||||
<item name="actionBarStyle">@style/ActionBar.Transparent.TMessages.Gallery</item>
|
||||
<item name="windowActionBarOverlay">true</item>
|
||||
<item name="homeAsUpIndicator">@drawable/ab_icon_up_gallery</item>
|
||||
<item name="actionOverflowButtonStyle">@style/ActionBar.Transparent.TMessages.Gallery.ActionButtonOverflow</item>
|
||||
<item name="listChoiceBackgroundIndicator">@drawable/list_selector</item>
|
||||
|
||||
<!--<item name="android:windowIsTranslucent">true</item>-->
|
||||
<!--<item name="android:backgroundDimEnabled">false</item>-->
|
||||
</style>
|
||||
|
||||
<!--ACTION BAR-->
|
||||
|
||||
<style name="ActionBar.Transparent.TMessages.Start" parent="android:style/Widget.Holo.Light.ActionBar">
|
||||
<item name="android:background">@color/header</item>
|
||||
<item name="android:logo">@drawable/transparent</item>
|
||||
<item name="android:titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||
<item name="android:subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
||||
<item name="android:title">""</item>
|
||||
|
||||
<item name="background">@color/header</item>
|
||||
<item name="logo">@drawable/transparent</item>
|
||||
<item name="title">""</item>
|
||||
<item name="titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||
<item name="subtitleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Subtitle</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBar.Transparent.TMessages.Gallery" parent="Widget.AppCompat.Light.ActionBar">
|
||||
<item name="android:background">#dd000000</item>
|
||||
<item name="android:titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||
|
||||
<item name="background">@drawable/gallery_action_bar</item>
|
||||
<item name="titleTextStyle">@style/ActionBar.Transparent.TMessages.Gallery.Title</item>
|
||||
</style>
|
||||
|
||||
<!--ACTION BAR ITEMS-->
|
||||
|
@ -75,18 +39,6 @@
|
|||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBar.Transparent.TMessages.Gallery.ActionButtonOverflow" parent="Widget.AppCompat.ActionButton.Overflow">
|
||||
<item name="android:src">@drawable/ic_ab_other_white</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBar.Transparent.TMessages.Gallery.Title" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
|
||||
<item name="android:textColor">#ffffffff</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBar.Transparent.TMessages.Gallery.Subtitle" parent="TextAppearance.AppCompat.Widget.ActionBar.Subtitle">
|
||||
<item name="android:textColor">#ffd7e8f7</item>
|
||||
</style>
|
||||
|
||||
<!--LIST VIEW-->
|
||||
|
||||
<style name="Theme.TMessages.ListView" parent="@android:style/Widget.ListView">
|
||||
|
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,6 +1,6 @@
|
|||
#Fri Mar 21 14:56:25 MSK 2014
|
||||
#Mon Jun 09 01:00:32 MSK 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
|
||||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
|
||||
|
|