mirror of
https://github.com/DrKLO/Telegram.git
synced 2025-01-03 09:49:15 +01:00
Different improvements
This commit is contained in:
parent
22a0c2aca6
commit
ad863779f7
18 changed files with 302 additions and 104 deletions
|
@ -80,7 +80,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 8
|
minSdkVersion 8
|
||||||
targetSdkVersion 19
|
targetSdkVersion 19
|
||||||
versionCode 355
|
versionCode 357
|
||||||
versionName "1.9.4"
|
versionName "1.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -831,6 +831,10 @@ public class ImageLoader {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void putImageToCache(BitmapDrawable bitmap, String key) {
|
||||||
|
memCache.put(key, bitmap);
|
||||||
|
}
|
||||||
|
|
||||||
public void loadImage(final TLRPC.FileLocation fileLocation, final String httpUrl, final ImageReceiver imageView, final int size, final boolean cacheOnly) {
|
public void loadImage(final TLRPC.FileLocation fileLocation, final String httpUrl, final ImageReceiver imageView, final int size, final boolean cacheOnly) {
|
||||||
if ((fileLocation == null && httpUrl == null) || imageView == null || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
|
if ((fileLocation == null && httpUrl == null) || imageView == null || (fileLocation != null && !(fileLocation instanceof TLRPC.TL_fileLocation) && !(fileLocation instanceof TLRPC.TL_fileEncryptedLocation))) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -616,7 +616,7 @@ public class MessageObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSecretMedia() {
|
public boolean isSecretMedia() {
|
||||||
return messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageOwner.ttl != 0;
|
return messageOwner.media instanceof TLRPC.TL_messageMediaPhoto && messageOwner.ttl != 0 && messageOwner.ttl <= 60;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setIsUnread(TLRPC.Message message, boolean unread) {
|
public static void setIsUnread(TLRPC.Message message, boolean unread) {
|
||||||
|
@ -672,12 +672,8 @@ public class MessageObject {
|
||||||
String str;
|
String str;
|
||||||
if (secondsLeft < 60) {
|
if (secondsLeft < 60) {
|
||||||
str = secondsLeft + "s";
|
str = secondsLeft + "s";
|
||||||
} else if (secondsLeft < 60 * 60) {
|
|
||||||
str = secondsLeft / 60 + "m";
|
|
||||||
} else if (secondsLeft < 60 * 60 * 24) {
|
|
||||||
str = secondsLeft / 60 / 60 + "h";
|
|
||||||
} else {
|
} else {
|
||||||
str = secondsLeft / 60 / 60 / 24 + "d";
|
str = secondsLeft / 60 + "m";
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import org.telegram.messenger.BuffersStorage;
|
import org.telegram.messenger.BuffersStorage;
|
||||||
import org.telegram.messenger.ByteBufferDesc;
|
import org.telegram.messenger.ByteBufferDesc;
|
||||||
|
@ -502,7 +503,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void didAddedNewTask(final int minDate) {
|
public void didAddedNewTask(final int minDate, final SparseArray<ArrayList<Integer>> mids) {
|
||||||
Utilities.stageQueue.postRunnable(new Runnable() {
|
Utilities.stageQueue.postRunnable(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -511,6 +512,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, mids);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getNewDeleteTask(final ArrayList<Integer> oldTask) {
|
public void getNewDeleteTask(final ArrayList<Integer> oldTask) {
|
||||||
|
@ -3552,7 +3559,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
newMessage.media.photo.date = newMessage.date;
|
newMessage.media.photo.date = newMessage.date;
|
||||||
newMessage.media.photo.caption = "";
|
newMessage.media.photo.caption = "";
|
||||||
newMessage.media.photo.geo = new TLRPC.TL_geoPointEmpty();
|
newMessage.media.photo.geo = new TLRPC.TL_geoPointEmpty();
|
||||||
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) {
|
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) {
|
||||||
TLRPC.TL_photoCachedSize small = new TLRPC.TL_photoCachedSize();
|
TLRPC.TL_photoCachedSize small = new TLRPC.TL_photoCachedSize();
|
||||||
small.w = decryptedMessage.media.thumb_w;
|
small.w = decryptedMessage.media.thumb_w;
|
||||||
small.h = decryptedMessage.media.thumb_h;
|
small.h = decryptedMessage.media.thumb_h;
|
||||||
|
@ -3581,7 +3588,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
}
|
}
|
||||||
newMessage.media = new TLRPC.TL_messageMediaVideo();
|
newMessage.media = new TLRPC.TL_messageMediaVideo();
|
||||||
newMessage.media.video = new TLRPC.TL_videoEncrypted();
|
newMessage.media.video = new TLRPC.TL_videoEncrypted();
|
||||||
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) {
|
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) {
|
||||||
newMessage.media.video.thumb = new TLRPC.TL_photoCachedSize();
|
newMessage.media.video.thumb = new TLRPC.TL_photoCachedSize();
|
||||||
newMessage.media.video.thumb.bytes = decryptedMessage.media.thumb;
|
newMessage.media.video.thumb.bytes = decryptedMessage.media.thumb;
|
||||||
newMessage.media.video.thumb.w = decryptedMessage.media.thumb_w;
|
newMessage.media.video.thumb.w = decryptedMessage.media.thumb_w;
|
||||||
|
@ -3623,7 +3630,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
|
||||||
newMessage.media.document.size = message.file.size;
|
newMessage.media.document.size = message.file.size;
|
||||||
newMessage.media.document.key = decryptedMessage.media.key;
|
newMessage.media.document.key = decryptedMessage.media.key;
|
||||||
newMessage.media.document.iv = decryptedMessage.media.iv;
|
newMessage.media.document.iv = decryptedMessage.media.iv;
|
||||||
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 5000 && decryptedMessage.media.thumb_w < 100 && decryptedMessage.media.thumb_h < 100) {
|
if (decryptedMessage.media.thumb.length != 0 && decryptedMessage.media.thumb.length <= 6000 && decryptedMessage.media.thumb_w <= 100 && decryptedMessage.media.thumb_h <= 100) {
|
||||||
newMessage.media.document.thumb = new TLRPC.TL_photoCachedSize();
|
newMessage.media.document.thumb = new TLRPC.TL_photoCachedSize();
|
||||||
newMessage.media.document.thumb.bytes = decryptedMessage.media.thumb;
|
newMessage.media.document.thumb.bytes = decryptedMessage.media.thumb;
|
||||||
newMessage.media.document.thumb.w = decryptedMessage.media.thumb_w;
|
newMessage.media.document.thumb.w = decryptedMessage.media.thumb_w;
|
||||||
|
|
|
@ -882,7 +882,7 @@ public class MessagesStorage {
|
||||||
state.dispose();
|
state.dispose();
|
||||||
database.commitTransaction();
|
database.commitTransaction();
|
||||||
database.executeFast(String.format(Locale.US, "UPDATE messages SET ttl = 0 WHERE mid IN(%s)", mids.toString())).stepThis().dispose();
|
database.executeFast(String.format(Locale.US, "UPDATE messages SET ttl = 0 WHERE mid IN(%s)", mids.toString())).stepThis().dispose();
|
||||||
MessagesController.getInstance().didAddedNewTask(minDate);
|
MessagesController.getInstance().didAddedNewTask(minDate, messages);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FileLog.e("tmessages", e);
|
FileLog.e("tmessages", e);
|
||||||
|
@ -2432,15 +2432,10 @@ public class MessagesStorage {
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMessageMediaType(TLRPC.Message message) {
|
private int getMessageMediaType(TLRPC.Message message) {
|
||||||
if (message.media == null) {
|
if (message.media instanceof TLRPC.TL_messageMediaPhoto && message.ttl != 0 && message.ttl <= 60) {
|
||||||
return 0;
|
|
||||||
} else if (message.media instanceof TLRPC.TL_messageMediaPhoto) {
|
|
||||||
return 1;
|
return 1;
|
||||||
} else if (message.media instanceof TLRPC.TL_messageMediaVideo) {
|
|
||||||
return 2;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast, final int downloadMask) {
|
private void putMessagesInternal(final ArrayList<TLRPC.Message> messages, final boolean withTransaction, final boolean isBroadcast, final int downloadMask) {
|
||||||
|
@ -2478,7 +2473,7 @@ public class MessagesStorage {
|
||||||
messagesIdsMap.put(message.id, dialog_id);
|
messagesIdsMap.put(message.id, dialog_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.ttl == 0 && (message.media instanceof TLRPC.TL_messageMediaVideo || message.media instanceof TLRPC.TL_messageMediaPhoto)) {
|
if (message.media instanceof TLRPC.TL_messageMediaVideo || message.media instanceof TLRPC.TL_messageMediaPhoto && (message.ttl == 0 || message.ttl > 60)) {
|
||||||
if (messageMediaIds.length() > 0) {
|
if (messageMediaIds.length() > 0) {
|
||||||
messageMediaIds.append(",");
|
messageMediaIds.append(",");
|
||||||
}
|
}
|
||||||
|
@ -2562,7 +2557,7 @@ public class MessagesStorage {
|
||||||
state3.step();
|
state3.step();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.ttl == 0 && (message.media instanceof TLRPC.TL_messageMediaVideo || message.media instanceof TLRPC.TL_messageMediaPhoto)) {
|
if (message.media instanceof TLRPC.TL_messageMediaVideo || message.media instanceof TLRPC.TL_messageMediaPhoto && (message.ttl == 0 || message.ttl > 60)) {
|
||||||
state2.requery();
|
state2.requery();
|
||||||
state2.bindInteger(1, messageId);
|
state2.bindInteger(1, messageId);
|
||||||
state2.bindLong(2, dialog_id);
|
state2.bindLong(2, dialog_id);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class NotificationCenter {
|
||||||
public static final int openedChatChanged = 29;
|
public static final int openedChatChanged = 29;
|
||||||
public static final int hideEmojiKeyboard = 30;
|
public static final int hideEmojiKeyboard = 30;
|
||||||
public static final int stopEncodingService = 31;
|
public static final int stopEncodingService = 31;
|
||||||
|
public static final int didCreatedNewDeleteTask = 32;
|
||||||
|
|
||||||
public static final int wallpapersDidLoaded = 171;
|
public static final int wallpapersDidLoaded = 171;
|
||||||
public static final int closeOtherAppActivities = 702;
|
public static final int closeOtherAppActivities = 702;
|
||||||
|
|
|
@ -9333,6 +9333,7 @@ public class TLRPC {
|
||||||
public byte[] auth_key;
|
public byte[] auth_key;
|
||||||
public int user_id;
|
public int user_id;
|
||||||
public int ttl;
|
public int ttl;
|
||||||
|
public int layer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FileLocation extends TLObject {
|
public static class FileLocation extends TLObject {
|
||||||
|
|
|
@ -118,6 +118,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
private CheckForTap pendingCheckForTap = null;
|
private CheckForTap pendingCheckForTap = null;
|
||||||
|
|
||||||
private int last_send_state = 0;
|
private int last_send_state = 0;
|
||||||
|
private int last_delete_date = 0;
|
||||||
|
|
||||||
private final class CheckForTap implements Runnable {
|
private final class CheckForTap implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -219,6 +220,9 @@ public class ChatBaseCell extends BaseCell {
|
||||||
if (last_send_state != currentMessageObject.messageOwner.send_state) {
|
if (last_send_state != currentMessageObject.messageOwner.send_state) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (last_delete_date != currentMessageObject.messageOwner.destroyTime) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
TLRPC.User newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
|
TLRPC.User newUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
|
||||||
TLRPC.FileLocation newPhoto = null;
|
TLRPC.FileLocation newPhoto = null;
|
||||||
|
@ -251,6 +255,7 @@ public class ChatBaseCell extends BaseCell {
|
||||||
public void setMessageObject(MessageObject messageObject) {
|
public void setMessageObject(MessageObject messageObject) {
|
||||||
currentMessageObject = messageObject;
|
currentMessageObject = messageObject;
|
||||||
last_send_state = messageObject.messageOwner.send_state;
|
last_send_state = messageObject.messageOwner.send_state;
|
||||||
|
last_delete_date = messageObject.messageOwner.destroyTime;
|
||||||
isPressed = false;
|
isPressed = false;
|
||||||
isCheckPressed = true;
|
isCheckPressed = true;
|
||||||
isAvatarVisible = false;
|
isAvatarVisible = false;
|
||||||
|
|
|
@ -42,8 +42,6 @@ import java.util.Locale;
|
||||||
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
public class ChatMediaCell extends ChatBaseCell implements MediaController.FileDownloadProgressListener {
|
||||||
|
|
||||||
public static interface ChatMediaCellDelegate {
|
public static interface ChatMediaCellDelegate {
|
||||||
public abstract boolean didPressedImage(ChatMediaCell cell);
|
|
||||||
public abstract void didUnpressedImage(ChatMediaCell cell);
|
|
||||||
public abstract void didClickedImage(ChatMediaCell cell);
|
public abstract void didClickedImage(ChatMediaCell cell);
|
||||||
public abstract void didPressedOther(ChatMediaCell cell);
|
public abstract void didPressedOther(ChatMediaCell cell);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +83,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
private boolean otherPressed = false;
|
private boolean otherPressed = false;
|
||||||
private int buttonX;
|
private int buttonX;
|
||||||
private int buttonY;
|
private int buttonY;
|
||||||
private boolean listenForUnpressed = false;
|
|
||||||
|
|
||||||
private StaticLayout infoLayout;
|
private StaticLayout infoLayout;
|
||||||
private int infoWidth;
|
private int infoWidth;
|
||||||
|
@ -212,10 +209,8 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listenForUnpressed = false;
|
if (imagePressed && currentMessageObject.isSecretMedia()) {
|
||||||
if (imagePressed && mediaDelegate != null && mediaDelegate.didPressedImage(this)) {
|
|
||||||
imagePressed = false;
|
imagePressed = false;
|
||||||
listenForUnpressed = true;
|
|
||||||
} else if (result) {
|
} else if (result) {
|
||||||
startCheckLongPress();
|
startCheckLongPress();
|
||||||
}
|
}
|
||||||
|
@ -242,8 +237,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
} else if (imagePressed) {
|
} else if (imagePressed) {
|
||||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||||
imagePressed = false;
|
imagePressed = false;
|
||||||
|
if (buttonState == -1 || buttonState == 2 || buttonState == 3) {
|
||||||
playSoundEffect(SoundEffectConstants.CLICK);
|
playSoundEffect(SoundEffectConstants.CLICK);
|
||||||
didClickedImage();
|
didClickedImage();
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
imagePressed = false;
|
imagePressed = false;
|
||||||
|
@ -277,14 +274,6 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (listenForUnpressed) {
|
|
||||||
if (event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
|
||||||
if (listenForUnpressed && mediaDelegate != null) {
|
|
||||||
mediaDelegate.didUnpressedImage(this);
|
|
||||||
}
|
|
||||||
listenForUnpressed = false;
|
|
||||||
}
|
|
||||||
result = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
@ -575,6 +564,10 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
w = timeWidthTotal;
|
w = timeWidthTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentMessageObject.isSecretMedia()) {
|
||||||
|
w = h = (int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
photoWidth = w;
|
photoWidth = w;
|
||||||
photoHeight = h;
|
photoHeight = h;
|
||||||
backgroundWidth = w + AndroidUtilities.dp(12);
|
backgroundWidth = w + AndroidUtilities.dp(12);
|
||||||
|
@ -785,7 +778,7 @@ public class ChatMediaCell extends ChatBaseCell implements MediaController.FileD
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSecretTimeText() {
|
private void updateSecretTimeText() {
|
||||||
if (currentMessageObject == null) {
|
if (currentMessageObject == null || currentMessageObject.isOut()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String str = currentMessageObject.getSecretTimeString();
|
String str = currentMessageObject.getSecretTimeString();
|
||||||
|
|
|
@ -32,6 +32,7 @@ import android.os.Bundle;
|
||||||
import android.provider.MediaStore;
|
import android.provider.MediaStore;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -175,6 +176,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
private String startVideoEdit = null;
|
private String startVideoEdit = null;
|
||||||
|
|
||||||
private Runnable openSecretPhotoRunnable = null;
|
private Runnable openSecretPhotoRunnable = null;
|
||||||
|
private float startX = 0;
|
||||||
|
private float startY = 0;
|
||||||
|
|
||||||
private final static int copy = 1;
|
private final static int copy = 1;
|
||||||
private final static int forward = 2;
|
private final static int forward = 2;
|
||||||
|
@ -188,6 +191,27 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
private final static int attach_location = 10;
|
private final static int attach_location = 10;
|
||||||
private final static int chat_menu_avatar = 11;
|
private final static int chat_menu_avatar = 11;
|
||||||
|
|
||||||
|
AdapterView.OnItemLongClickListener onItemLongClickListener = new AdapterView.OnItemLongClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onItemLongClick(AdapterView<?> adapter, View view, int position, long id) {
|
||||||
|
if (!actionBarLayer.isActionModeShowed()) {
|
||||||
|
createMenu(view, false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||||
|
if (actionBarLayer.isActionModeShowed()) {
|
||||||
|
processRowSelect(view);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
createMenu(view, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public ChatActivity(Bundle args) {
|
public ChatActivity(Bundle args) {
|
||||||
super(args);
|
super(args);
|
||||||
}
|
}
|
||||||
|
@ -350,6 +374,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenshotTook);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.screenshotTook);
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileNewChunkAvailable);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.FileNewChunkAvailable);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didCreatedNewDeleteTask);
|
||||||
|
|
||||||
super.onFragmentCreate();
|
super.onFragmentCreate();
|
||||||
|
|
||||||
|
@ -397,6 +422,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenshotTook);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.screenshotTook);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.blockedUsersDidLoaded);
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileNewChunkAvailable);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.FileNewChunkAvailable);
|
||||||
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
|
||||||
if (AndroidUtilities.isTablet()) {
|
if (AndroidUtilities.isTablet()) {
|
||||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
|
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
|
||||||
}
|
}
|
||||||
|
@ -746,17 +772,103 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
emptyView.setText(LocaleController.getString("GotAQuestion", R.string.GotAQuestion));
|
emptyView.setText(LocaleController.getString("GotAQuestion", R.string.GotAQuestion));
|
||||||
}
|
}
|
||||||
|
|
||||||
chatListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
|
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||||
|
chatListView.setOnItemClickListener(onItemClickListener);
|
||||||
|
|
||||||
|
final Rect scrollRect = new Rect();
|
||||||
|
|
||||||
|
chatListView.setOnInterceptTouchEventListener(new LayoutListView.OnInterceptTouchEventListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onItemLongClick(AdapterView<?> adapter, View view, int position, long id) {
|
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||||
if (!actionBarLayer.isActionModeShowed()) {
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
createMenu(view, false);
|
int x = (int)event.getX();
|
||||||
|
int y = (int)event.getY();
|
||||||
|
int count = chatListView.getChildCount();
|
||||||
|
Rect rect = new Rect();
|
||||||
|
for (int a = 0; a < count; a++) {
|
||||||
|
View view = chatListView.getChildAt(a);
|
||||||
|
int top = view.getTop();
|
||||||
|
int bottom = view.getBottom();
|
||||||
|
view.getLocalVisibleRect(rect);
|
||||||
|
if (top > y || bottom < y) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!(view instanceof ChatMediaCell)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final ChatMediaCell cell = (ChatMediaCell)view;
|
||||||
|
final MessageObject messageObject = cell.getMessageObject();
|
||||||
|
if (messageObject == null || !messageObject.isSecretMedia() || !cell.getPhotoImage().isInsideImage(x, y - top)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
startX = x;
|
||||||
|
startY = y;
|
||||||
|
openSecretPhotoRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (openSecretPhotoRunnable == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chatListView.requestDisallowInterceptTouchEvent(true);
|
||||||
|
chatListView.setOnItemLongClickListener(null);
|
||||||
|
chatListView.setOnItemClickListener(null);
|
||||||
|
chatListView.setLongClickable(false);
|
||||||
|
openSecretPhotoRunnable = null;
|
||||||
|
if (!messageObject.isOut() && messageObject.messageOwner.destroyTime == 0) {
|
||||||
|
MessagesController.getInstance().markMessageAsRead(dialog_id, messageObject.messageOwner.random_id);
|
||||||
|
messageObject.messageOwner.destroyTime = messageObject.messageOwner.ttl + ConnectionsManager.getInstance().getCurrentTime();
|
||||||
|
cell.invalidate();
|
||||||
|
}
|
||||||
|
SecretPhotoViewer.getInstance().setParentActivity(getParentActivity());
|
||||||
|
SecretPhotoViewer.getInstance().openPhoto(messageObject);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AndroidUtilities.RunOnUIThread(openSecretPhotoRunnable, 100);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final Rect scrollRect = new Rect();
|
chatListView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_POINTER_UP) {
|
||||||
|
if (openSecretPhotoRunnable != null) {
|
||||||
|
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||||
|
openSecretPhotoRunnable = null;
|
||||||
|
} else {
|
||||||
|
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||||
|
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||||
|
chatListView.setOnItemClickListener(onItemClickListener);
|
||||||
|
chatListView.setLongClickable(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
SecretPhotoViewer.getInstance().closePhoto();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (event.getAction() != MotionEvent.ACTION_DOWN) {
|
||||||
|
if (SecretPhotoViewer.getInstance().isVisible()) {
|
||||||
|
return true;
|
||||||
|
} else if (openSecretPhotoRunnable != null) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||||
|
if (Math.hypot(startX - event.getX(), startY - event.getY()) > AndroidUtilities.dp(5)) {
|
||||||
|
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||||
|
openSecretPhotoRunnable = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
||||||
|
openSecretPhotoRunnable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
chatListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
chatListView.setOnScrollListener(new AbsListView.OnScrollListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -856,17 +968,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chatListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
if (actionBarLayer.isActionModeShowed()) {
|
|
||||||
processRowSelect(view);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createMenu(view, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updateBottomOverlay();
|
updateBottomOverlay();
|
||||||
|
|
||||||
chatActivityEnterView.setContainerView(getParentActivity(), fragmentView);
|
chatActivityEnterView.setContainerView(getParentActivity(), fragmentView);
|
||||||
|
@ -2396,6 +2497,23 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
updateVisibleRows();
|
updateVisibleRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (id == NotificationCenter.didCreatedNewDeleteTask) {
|
||||||
|
SparseArray<ArrayList<Integer>> mids = (SparseArray<ArrayList<Integer>>)args[0];
|
||||||
|
boolean changed = false;
|
||||||
|
for(int i = 0; i < mids.size(); i++) {
|
||||||
|
int key = mids.keyAt(i);
|
||||||
|
ArrayList<Integer> arr = mids.get(key);
|
||||||
|
for (Integer mid : arr) {
|
||||||
|
MessageObject messageObject = messagesDict.get(mid);
|
||||||
|
if (messageObject != null) {
|
||||||
|
messageObject.messageOwner.destroyTime = key;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed) {
|
||||||
|
updateVisibleRows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2574,6 +2692,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chatListView.setOnItemLongClickListener(onItemLongClickListener);
|
||||||
|
chatListView.setOnItemClickListener(onItemClickListener);
|
||||||
|
chatListView.setLongClickable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3505,43 +3627,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||||
public void didPressedOther(ChatMediaCell cell) {
|
public void didPressedOther(ChatMediaCell cell) {
|
||||||
createMenu(cell, true);
|
createMenu(cell, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean didPressedImage(final ChatMediaCell cell) {
|
|
||||||
final MessageObject messageObject = cell.getMessageObject();
|
|
||||||
if (messageObject == null || !messageObject.isSecretMedia()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
openSecretPhotoRunnable = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (openSecretPhotoRunnable == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chatListView.requestDisallowInterceptTouchEvent(true);
|
|
||||||
openSecretPhotoRunnable = null;
|
|
||||||
if (!messageObject.isOut() && messageObject.messageOwner.destroyTime == 0) {
|
|
||||||
MessagesController.getInstance().markMessageAsRead(dialog_id, message.messageOwner.random_id);
|
|
||||||
messageObject.messageOwner.destroyTime = messageObject.messageOwner.ttl + ConnectionsManager.getInstance().getCurrentTime();
|
|
||||||
cell.invalidate();
|
|
||||||
}
|
|
||||||
SecretPhotoViewer.getInstance().setParentActivity(getParentActivity());
|
|
||||||
SecretPhotoViewer.getInstance().openPhoto(messageObject);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
AndroidUtilities.RunOnUIThread(openSecretPhotoRunnable, 100);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void didUnpressedImage(ChatMediaCell cell) {
|
|
||||||
if (openSecretPhotoRunnable != null) {
|
|
||||||
AndroidUtilities.CancelRunOnUIThread(openSecretPhotoRunnable);
|
|
||||||
openSecretPhotoRunnable = null;
|
|
||||||
} else {
|
|
||||||
SecretPhotoViewer.getInstance().closePhoto();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
public int getSelectedCount();
|
public int getSelectedCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FrameLayoutTouchListener extends FrameLayout {
|
private class FrameLayoutTouchListener extends FrameLayout {
|
||||||
public FrameLayoutTouchListener(Context context) {
|
public FrameLayoutTouchListener(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
}
|
}
|
||||||
|
@ -251,7 +251,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FrameLayoutDrawer extends FrameLayout {
|
private class FrameLayoutDrawer extends FrameLayout {
|
||||||
public FrameLayoutDrawer(Context context) {
|
public FrameLayoutDrawer(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
setWillNotDraw(false);
|
setWillNotDraw(false);
|
||||||
|
|
|
@ -11,27 +11,36 @@ package org.telegram.ui;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.Layout;
|
import android.text.Layout;
|
||||||
import android.text.StaticLayout;
|
import android.text.StaticLayout;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
|
import android.view.MotionEvent;
|
||||||
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import org.telegram.android.AndroidUtilities;
|
import org.telegram.android.AndroidUtilities;
|
||||||
|
import org.telegram.android.ImageLoader;
|
||||||
import org.telegram.android.ImageReceiver;
|
import org.telegram.android.ImageReceiver;
|
||||||
import org.telegram.android.MessageObject;
|
import org.telegram.android.MessageObject;
|
||||||
import org.telegram.android.NotificationCenter;
|
import org.telegram.android.NotificationCenter;
|
||||||
import org.telegram.messenger.ConnectionsManager;
|
import org.telegram.messenger.ConnectionsManager;
|
||||||
import org.telegram.messenger.FileLoader;
|
import org.telegram.messenger.FileLoader;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
|
import org.telegram.messenger.R;
|
||||||
import org.telegram.messenger.TLRPC;
|
import org.telegram.messenger.TLRPC;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class SecretPhotoViewer implements NotificationCenter.NotificationCenterDelegate {
|
public class SecretPhotoViewer implements NotificationCenter.NotificationCenterDelegate {
|
||||||
|
@ -48,6 +57,18 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class FrameLayoutTouchListener extends FrameLayout {
|
||||||
|
public FrameLayoutTouchListener(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
|
FileLog.e("tmessages", event.toString());
|
||||||
|
return super.onTouchEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class SecretDeleteTimer extends FrameLayout {
|
private class SecretDeleteTimer extends FrameLayout {
|
||||||
private String currentInfoString;
|
private String currentInfoString;
|
||||||
private int infoWidth;
|
private int infoWidth;
|
||||||
|
@ -55,6 +76,7 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
private StaticLayout infoLayout = null;
|
private StaticLayout infoLayout = null;
|
||||||
private Paint deleteProgressPaint;
|
private Paint deleteProgressPaint;
|
||||||
private RectF deleteProgressRect = new RectF();
|
private RectF deleteProgressRect = new RectF();
|
||||||
|
private Drawable drawable = null;
|
||||||
|
|
||||||
public SecretDeleteTimer(Context context) {
|
public SecretDeleteTimer(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
@ -66,6 +88,8 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
|
|
||||||
deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
deleteProgressPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
deleteProgressPaint.setColor(0xffe6e6e6);
|
deleteProgressPaint.setColor(0xffe6e6e6);
|
||||||
|
|
||||||
|
drawable = getResources().getDrawable(R.drawable.circle1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSecretTimeText() {
|
private void updateSecretTimeText() {
|
||||||
|
@ -88,14 +112,20 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
deleteProgressRect.set(getMeasuredWidth() - AndroidUtilities.dp(27), 0, getMeasuredWidth(), AndroidUtilities.dp(27));
|
deleteProgressRect.set(getMeasuredWidth() - AndroidUtilities.dp(30), AndroidUtilities.dp(2), getMeasuredWidth() - AndroidUtilities.dp(2), AndroidUtilities.dp(30));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
if (currentMessageObject == null) {
|
if (currentMessageObject == null || currentMessageObject.messageOwner.destroyTime == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (drawable != null) {
|
||||||
|
drawable.setBounds(getMeasuredWidth() - AndroidUtilities.dp(32), 0, getMeasuredWidth(), AndroidUtilities.dp(32));
|
||||||
|
drawable.draw(canvas);
|
||||||
|
}
|
||||||
|
|
||||||
long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance().getTimeDifference() * 1000;
|
long msTime = System.currentTimeMillis() + ConnectionsManager.getInstance().getTimeDifference() * 1000;
|
||||||
float progress = Math.max(0, (long)currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f);
|
float progress = Math.max(0, (long)currentMessageObject.messageOwner.destroyTime * 1000 - msTime) / (currentMessageObject.messageOwner.ttl * 1000.0f);
|
||||||
canvas.drawArc(deleteProgressRect, -90, -360 * progress, true, deleteProgressPaint);
|
canvas.drawArc(deleteProgressRect, -90, -360 * progress, true, deleteProgressPaint);
|
||||||
|
@ -107,7 +137,7 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
|
|
||||||
if (infoLayout != null) {
|
if (infoLayout != null) {
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.translate(getMeasuredWidth() - AndroidUtilities.dp(34) - infoWidth, AndroidUtilities.dp(5));
|
canvas.translate(getMeasuredWidth() - AndroidUtilities.dp(38) - infoWidth, AndroidUtilities.dp(7));
|
||||||
infoLayout.draw(canvas);
|
infoLayout.draw(canvas);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
@ -116,10 +146,11 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
|
|
||||||
private Activity parentActivity;
|
private Activity parentActivity;
|
||||||
private WindowManager.LayoutParams windowLayoutParams;
|
private WindowManager.LayoutParams windowLayoutParams;
|
||||||
private FrameLayout windowView;
|
private FrameLayoutTouchListener windowView;
|
||||||
private FrameLayoutDrawer containerView;
|
private FrameLayoutDrawer containerView;
|
||||||
private ImageReceiver centerImage = new ImageReceiver();
|
private ImageReceiver centerImage = new ImageReceiver();
|
||||||
private SecretDeleteTimer secretDeleteTimer;
|
private SecretDeleteTimer secretDeleteTimer;
|
||||||
|
private boolean isVisible = false;
|
||||||
|
|
||||||
private MessageObject currentMessageObject = null;
|
private MessageObject currentMessageObject = null;
|
||||||
|
|
||||||
|
@ -148,6 +179,22 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
if (markAsDeletedMessages.contains(currentMessageObject.messageOwner.id)) {
|
if (markAsDeletedMessages.contains(currentMessageObject.messageOwner.id)) {
|
||||||
closePhoto();
|
closePhoto();
|
||||||
}
|
}
|
||||||
|
} else if (id == NotificationCenter.didCreatedNewDeleteTask) {
|
||||||
|
if (currentMessageObject == null || secretDeleteTimer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SparseArray<ArrayList<Integer>> mids = (SparseArray<ArrayList<Integer>>)args[0];
|
||||||
|
for(int i = 0; i < mids.size(); i++) {
|
||||||
|
int key = mids.keyAt(i);
|
||||||
|
ArrayList<Integer> arr = mids.get(key);
|
||||||
|
for (Integer mid : arr) {
|
||||||
|
if (currentMessageObject.messageOwner.id == mid) {
|
||||||
|
currentMessageObject.messageOwner.destroyTime = key;
|
||||||
|
secretDeleteTimer.invalidate();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,9 +204,10 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
}
|
}
|
||||||
parentActivity = activity;
|
parentActivity = activity;
|
||||||
|
|
||||||
windowView = new FrameLayout(activity);
|
windowView = new FrameLayoutTouchListener(activity);
|
||||||
windowView.setBackgroundColor(0xff000000);
|
windowView.setBackgroundColor(0xff000000);
|
||||||
windowView.setFocusable(false);
|
windowView.setFocusable(true);
|
||||||
|
windowView.setFocusableInTouchMode(true);
|
||||||
|
|
||||||
containerView = new FrameLayoutDrawer(activity);
|
containerView = new FrameLayoutDrawer(activity);
|
||||||
containerView.setFocusable(false);
|
containerView.setFocusable(false);
|
||||||
|
@ -169,13 +217,22 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
layoutParams.height = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||||
containerView.setLayoutParams(layoutParams);
|
containerView.setLayoutParams(layoutParams);
|
||||||
|
containerView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_POINTER_UP || event.getAction() == MotionEvent.ACTION_CANCEL) {
|
||||||
|
closePhoto();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
secretDeleteTimer = new SecretDeleteTimer(activity);
|
secretDeleteTimer = new SecretDeleteTimer(activity);
|
||||||
containerView.addView(secretDeleteTimer);
|
containerView.addView(secretDeleteTimer);
|
||||||
layoutParams = (FrameLayout.LayoutParams)secretDeleteTimer.getLayoutParams();
|
layoutParams = (FrameLayout.LayoutParams)secretDeleteTimer.getLayoutParams();
|
||||||
layoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
|
layoutParams.gravity = Gravity.TOP | Gravity.RIGHT;
|
||||||
layoutParams.width = AndroidUtilities.dp(100);
|
layoutParams.width = AndroidUtilities.dp(100);
|
||||||
layoutParams.height = AndroidUtilities.dp(27);
|
layoutParams.height = AndroidUtilities.dp(32);
|
||||||
layoutParams.rightMargin = AndroidUtilities.dp(19);
|
layoutParams.rightMargin = AndroidUtilities.dp(19);
|
||||||
layoutParams.topMargin = AndroidUtilities.dp(19);
|
layoutParams.topMargin = AndroidUtilities.dp(19);
|
||||||
secretDeleteTimer.setLayoutParams(layoutParams);
|
secretDeleteTimer.setLayoutParams(layoutParams);
|
||||||
|
@ -197,13 +254,34 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesDeleted);
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.messagesDeleted);
|
||||||
|
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didCreatedNewDeleteTask);
|
||||||
|
|
||||||
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(messageObject.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize());
|
TLRPC.PhotoSize sizeFull = FileLoader.getClosestPhotoSizeWithSize(messageObject.messageOwner.media.photo.sizes, AndroidUtilities.getPhotoSize());
|
||||||
int size = sizeFull.size;
|
int size = sizeFull.size;
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
size = -1;
|
size = -1;
|
||||||
}
|
}
|
||||||
|
BitmapDrawable drawable = ImageLoader.getInstance().getImageFromMemory(sizeFull.location, null, null, null);
|
||||||
|
if (drawable == null) {
|
||||||
|
File file = FileLoader.getPathToAttach(sizeFull);
|
||||||
|
Bitmap bitmap = null;
|
||||||
|
try {
|
||||||
|
bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||||
|
} catch (Throwable e) {
|
||||||
|
ImageLoader.getInstance().clearMemory();
|
||||||
|
bitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
|
||||||
|
}
|
||||||
|
if (bitmap != null) {
|
||||||
|
drawable = new BitmapDrawable(bitmap);
|
||||||
|
ImageLoader.getInstance().putImageToCache(drawable, sizeFull.location.volume_id + "_" + sizeFull.location.local_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (drawable != null) {
|
||||||
|
centerImage.setImageBitmap(drawable);
|
||||||
|
} else {
|
||||||
centerImage.setImage(sizeFull.location, null, null, size, false);
|
centerImage.setImage(sizeFull.location, null, null, size, false);
|
||||||
|
}
|
||||||
|
|
||||||
currentMessageObject = messageObject;
|
currentMessageObject = messageObject;
|
||||||
|
|
||||||
AndroidUtilities.lockOrientation(parentActivity);
|
AndroidUtilities.lockOrientation(parentActivity);
|
||||||
|
@ -220,16 +298,28 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||||
wm.addView(windowView, windowLayoutParams);
|
wm.addView(windowView, windowLayoutParams);
|
||||||
secretDeleteTimer.invalidate();
|
secretDeleteTimer.invalidate();
|
||||||
|
isVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVisible() {
|
||||||
|
return isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closePhoto() {
|
public void closePhoto() {
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted);
|
||||||
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
|
||||||
if (parentActivity == null) {
|
if (parentActivity == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentMessageObject = null;
|
currentMessageObject = null;
|
||||||
|
isVisible = false;
|
||||||
AndroidUtilities.unlockOrientation(parentActivity);
|
AndroidUtilities.unlockOrientation(parentActivity);
|
||||||
|
AndroidUtilities.RunOnUIThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
centerImage.setImageBitmap((Bitmap)null);
|
centerImage.setImageBitmap((Bitmap)null);
|
||||||
|
}
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
if (windowView.getParent() != null) {
|
if (windowView.getParent() != null) {
|
||||||
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
WindowManager wm = (WindowManager) parentActivity.getSystemService(Context.WINDOW_SERVICE);
|
||||||
|
@ -242,6 +332,9 @@ public class SecretPhotoViewer implements NotificationCenter.NotificationCenterD
|
||||||
|
|
||||||
public void destroyPhotoViewer() {
|
public void destroyPhotoViewer() {
|
||||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted);
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.messagesDeleted);
|
||||||
|
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
|
||||||
|
isVisible = false;
|
||||||
|
currentMessageObject = null;
|
||||||
if (parentActivity == null || windowView == null) {
|
if (parentActivity == null || windowView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,17 @@ package org.telegram.ui.Views;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
|
|
||||||
public class LayoutListView extends ListView {
|
public class LayoutListView extends ListView {
|
||||||
|
|
||||||
|
public static interface OnInterceptTouchEventListener {
|
||||||
|
public abstract boolean onInterceptTouchEvent(MotionEvent event);
|
||||||
|
}
|
||||||
|
|
||||||
|
private OnInterceptTouchEventListener onInterceptTouchEventListener;
|
||||||
private int height = -1;
|
private int height = -1;
|
||||||
|
|
||||||
public LayoutListView(Context context) {
|
public LayoutListView(Context context) {
|
||||||
|
@ -29,6 +35,18 @@ public class LayoutListView extends ListView {
|
||||||
super(context, attrs, defStyle);
|
super(context, attrs, defStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnInterceptTouchEventListener(OnInterceptTouchEventListener listener) {
|
||||||
|
onInterceptTouchEventListener = listener;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||||
|
if (onInterceptTouchEventListener != null) {
|
||||||
|
return onInterceptTouchEventListener.onInterceptTouchEvent(ev);
|
||||||
|
}
|
||||||
|
return super.onInterceptTouchEvent(ev);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||||
View v = getChildAt(getChildCount() - 1);
|
View v = getChildAt(getChildCount() - 1);
|
||||||
|
|
BIN
TMessagesProj/src/main/res/drawable-hdpi/circle1.png
Executable file
BIN
TMessagesProj/src/main/res/drawable-hdpi/circle1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
TMessagesProj/src/main/res/drawable-ldpi/circle1.png
Executable file
BIN
TMessagesProj/src/main/res/drawable-ldpi/circle1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
TMessagesProj/src/main/res/drawable-mdpi/circle1.png
Executable file
BIN
TMessagesProj/src/main/res/drawable-mdpi/circle1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
TMessagesProj/src/main/res/drawable-xhdpi/circle1.png
Executable file
BIN
TMessagesProj/src/main/res/drawable-xhdpi/circle1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/circle1.png
Executable file
BIN
TMessagesProj/src/main/res/drawable-xxhdpi/circle1.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in a new issue