Update to 2.3.2

This commit is contained in:
DrKLO 2015-01-09 15:50:15 +03:00
parent 4e03bc1a75
commit 213c2269c0
14 changed files with 234 additions and 66 deletions

View file

@ -82,7 +82,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 8 minSdkVersion 8
targetSdkVersion 21 targetSdkVersion 21
versionCode 414 versionCode 415
versionName "2.3.1" versionName "2.3.2"
} }
} }

View file

@ -87,7 +87,11 @@ LOCAL_SRC_FILES := \
include $(BUILD_STATIC_LIBRARY) include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_ARM_MODE := thumb
else
LOCAL_ARM_MODE := arm
endif
LOCAL_MODULE := sqlite LOCAL_MODULE := sqlite
LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 LOCAL_CFLAGS := -w -std=gnu99 -O2 -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0 LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -DHAVE_STRCHRNUL=0
@ -106,7 +110,11 @@ LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT -DUSE_ALLOCA
LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math LOCAL_CFLAGS += -DANDROID_NDK -DDISABLE_IMPORTGL -fno-strict-aliasing -fprefetch-loop-arrays -DAVOID_TABLES -DANDROID_TILE_BASED_DECODE -DANDROID_ARMV6_IDCT -ffast-math
LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops LOCAL_CPPFLAGS := -DBSD=1 -ffast-math -O2 -funroll-loops
LOCAL_LDLIBS := -ljnigraphics -llog LOCAL_LDLIBS := -ljnigraphics -llog
LOCAL_ARM_MODE := arm ifeq ($(TARGET_ARCH_ABI),armeabi)
LOCAL_ARM_MODE := thumb
else
LOCAL_ARM_MODE := arm
endif
LOCAL_SRC_FILES := \ LOCAL_SRC_FILES := \
./opus/src/opus.c \ ./opus/src/opus.c \

View file

@ -1350,9 +1350,13 @@ public class MediaController implements NotificationCenter.NotificationCenterDel
fileDecodingQueue.postRunnable(new Runnable() { fileDecodingQueue.postRunnable(new Runnable() {
@Override @Override
public void run() { public void run() {
if (playingMessageObject != null && playingMessageObject.audioProgress != 0) { try {
lastPlayPcm = (long)(currentTotalPcmDuration * playingMessageObject.audioProgress); if (playingMessageObject != null && playingMessageObject.audioProgress != 0) {
seekOpusFile(playingMessageObject.audioProgress); lastPlayPcm = (long)(currentTotalPcmDuration * playingMessageObject.audioProgress);
seekOpusFile(playingMessageObject.audioProgress);
}
} catch (Exception e) {
FileLog.e("tmessages", e);
} }
synchronized (playerSync) { synchronized (playerSync) {
freePlayerBuffers.addAll(usedPlayerBuffers); freePlayerBuffers.addAll(usedPlayerBuffers);

View file

@ -60,6 +60,8 @@ public class MessagesController implements NotificationCenter.NotificationCenter
private ArrayList<Integer> loadingFullChats = new ArrayList<>(); private ArrayList<Integer> loadingFullChats = new ArrayList<>();
private ArrayList<Integer> loadedFullChats = new ArrayList<>(); private ArrayList<Integer> loadedFullChats = new ArrayList<>();
private ArrayList<Integer> reloadingMessages = new ArrayList<>();
private boolean gettingNewDeleteTask = false; private boolean gettingNewDeleteTask = false;
private int currentDeletingTaskTime = 0; private int currentDeletingTaskTime = 0;
private ArrayList<Integer> currentDeletingTaskMids = null; private ArrayList<Integer> currentDeletingTaskMids = null;
@ -314,6 +316,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
loadedFullUsers.clear(); loadedFullUsers.clear();
loadingFullUsers.clear(); loadingFullUsers.clear();
loadedFullUsers.clear(); loadedFullUsers.clear();
reloadingMessages.clear();
updatesStartWaitTime = 0; updatesStartWaitTime = 0;
currentDeletingTaskTime = 0; currentDeletingTaskTime = 0;
@ -548,6 +551,47 @@ public class MessagesController implements NotificationCenter.NotificationCenter
ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid); ConnectionsManager.getInstance().bindRequestToGuid(reqId, classGuid);
} }
private void reloadMessages(final ArrayList<Integer> mids, final long dialog_id) {
final TLRPC.TL_messages_getMessages req = new TLRPC.TL_messages_getMessages();
for (Integer mid : mids) {
if (reloadingMessages.contains(mid)) {
continue;
}
req.id.add(mid);
}
if (req.id.isEmpty()) {
return;
}
reloadingMessages.addAll(req.id);
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
@Override
public void run(TLObject response, TLRPC.TL_error error) {
if (error == null) {
TLRPC.messages_Messages messagesRes = (TLRPC.messages_Messages) response;
MessagesStorage.getInstance().putMessages(messagesRes, dialog_id);
final ArrayList<MessageObject> objects = new ArrayList<>();
ArrayList<Integer> messagesToReload = null;
for (TLRPC.Message message : messagesRes.messages) {
message.dialog_id = dialog_id;
final HashMap<Integer, TLRPC.User> usersLocal = new HashMap<>();
for (TLRPC.User u : messagesRes.users) {
usersLocal.put(u.id, u);
}
objects.add(new MessageObject(message, usersLocal, 2));
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.replaceMessagesObjects, dialog_id, objects);
}
});
}
reloadingMessages.removeAll(req.id);
}
});
}
protected void processNewDifferenceParams(int seq, int pts, int date) { protected void processNewDifferenceParams(int seq, int pts, int date) {
if (MessagesStorage.lastSeqValue + 1 == seq) { if (MessagesStorage.lastSeqValue + 1 == seq) {
if (seq != -1) { if (seq != -1) {
@ -1443,9 +1487,21 @@ public class MessagesController implements NotificationCenter.NotificationCenter
usersLocal.put(u.id, u); usersLocal.put(u.id, u);
} }
final ArrayList<MessageObject> objects = new ArrayList<>(); final ArrayList<MessageObject> objects = new ArrayList<>();
ArrayList<Integer> messagesToReload = null;
for (TLRPC.Message message : messagesRes.messages) { for (TLRPC.Message message : messagesRes.messages) {
message.dialog_id = dialog_id; message.dialog_id = dialog_id;
objects.add(new MessageObject(message, usersLocal, 2)); objects.add(new MessageObject(message, usersLocal, 2));
if (isCache && message.media instanceof TLRPC.TL_messageMediaUnsupported) {
if (message.media.bytes.length == 0 || message.media.bytes.length == 1 && message.media.bytes[0] < TLRPC.LAYER) {
if (messagesToReload == null) {
messagesToReload = new ArrayList<>();
}
messagesToReload.add(message.id);
}
}
}
if (messagesToReload != null) {
reloadMessages(messagesToReload, dialog_id);
} }
AndroidUtilities.runOnUIThread(new Runnable() { AndroidUtilities.runOnUIThread(new Runnable() {
@Override @Override

View file

@ -2734,6 +2734,8 @@ public class MessagesStorage {
int downloadMediaMask = 0; int downloadMediaMask = 0;
for (TLRPC.Message message : messages) { for (TLRPC.Message message : messages) {
fixUnsupportedMedia(message);
long dialog_id = message.dialog_id; long dialog_id = message.dialog_id;
if (dialog_id == 0) { if (dialog_id == 0) {
if (message.to_id.chat_id != 0) { if (message.to_id.chat_id != 0) {
@ -3499,6 +3501,15 @@ public class MessagesStorage {
} }
} }
private void fixUnsupportedMedia(TLRPC.Message message) {
if (message != null && message.media instanceof TLRPC.TL_messageMediaUnsupported && message.media.bytes != null) {
if (message.media.bytes.length == 0) {
message.media.bytes = new byte[1];
message.media.bytes[0] = TLRPC.LAYER;
}
}
}
public void putMessages(final TLRPC.messages_Messages messages, final long dialog_id) { public void putMessages(final TLRPC.messages_Messages messages, final long dialog_id) {
if (messages.messages.isEmpty()) { if (messages.messages.isEmpty()) {
return; return;
@ -3512,6 +3523,7 @@ public class MessagesStorage {
SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"); SQLitePreparedStatement state = database.executeFast("REPLACE INTO messages VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media VALUES(?, ?, ?, ?)"); SQLitePreparedStatement state2 = database.executeFast("REPLACE INTO media VALUES(?, ?, ?, ?)");
for (TLRPC.Message message : messages.messages) { for (TLRPC.Message message : messages.messages) {
fixUnsupportedMedia(message);
state.requery(); state.requery();
ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize()); ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
message.serializeToStream(data); message.serializeToStream(data);
@ -3680,6 +3692,7 @@ public class MessagesStorage {
uid = -dialog.peer.chat_id; uid = -dialog.peer.chat_id;
} }
TLRPC.Message message = new_dialogMessage.get(dialog.top_message); TLRPC.Message message = new_dialogMessage.get(dialog.top_message);
fixUnsupportedMedia(message);
ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize()); ByteBufferDesc data = buffersStorage.getFreeBuffer(message.getObjectSize());
message.serializeToStream(data); message.serializeToStream(data);

View file

@ -47,6 +47,7 @@ public class NotificationCenter {
public static final int privacyRulesUpdated = totalEvents++; public static final int privacyRulesUpdated = totalEvents++;
public static final int updateMessageMedia = totalEvents++; public static final int updateMessageMedia = totalEvents++;
public static final int recentImagesDidLoaded = totalEvents++; public static final int recentImagesDidLoaded = totalEvents++;
public static final int replaceMessagesObjects = totalEvents++;
public static final int httpFileDidLoaded = totalEvents++; public static final int httpFileDidLoaded = totalEvents++;
public static final int httpFileDidFailedLoad = totalEvents++; public static final int httpFileDidFailedLoad = totalEvents++;

View file

@ -38,7 +38,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class SecretChatHelper { public class SecretChatHelper {
public static final int CURRENT_SECRET_CHAT_LAYER = 20; public static final int CURRENT_SECRET_CHAT_LAYER = 23;
private ArrayList<Integer> sendingNotifyLayer = new ArrayList<>(); private ArrayList<Integer> sendingNotifyLayer = new ArrayList<>();
private HashMap<Integer, ArrayList<TLRPC.TL_decryptedMessageHolder>> secretHolesQueue = new HashMap<>(); private HashMap<Integer, ArrayList<TLRPC.TL_decryptedMessageHolder>> secretHolesQueue = new HashMap<>();

View file

@ -1032,38 +1032,57 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
reqSend.media.user_id = user.id; reqSend.media.user_id = user.id;
SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, null, null); SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, null, null);
} else if (type == 7) { } else if (type == 7) {
reqSend.media = new TLRPC.TL_decryptedMessageMediaDocument(); boolean isSticker = false;
reqSend.media.size = document.size; for (TLRPC.DocumentAttribute attribute : document.attributes) {
if (!(document.thumb instanceof TLRPC.TL_photoSizeEmpty)) { if (attribute instanceof TLRPC.TL_documentAttributeSticker) {
reqSend.media.thumb = document.thumb.bytes; isSticker = true;
reqSend.media.thumb_h = document.thumb.h;
reqSend.media.thumb_w = document.thumb.w;
} else {
reqSend.media.thumb = new byte[0];
reqSend.media.thumb_h = 0;
reqSend.media.thumb_w = 0;
}
reqSend.media.file_name = FileLoader.getDocumentFileName(document);
reqSend.media.mime_type = document.mime_type;
if (document.access_hash == 0) {
DelayedMessage delayedMessage = new DelayedMessage();
delayedMessage.originalPath = originalPath;
delayedMessage.sendEncryptedRequest = reqSend;
delayedMessage.type = 2;
delayedMessage.obj = newMsgObj;
delayedMessage.encryptedChat = encryptedChat;
if (path != null && path.length() > 0 && path.startsWith("http")) {
delayedMessage.httpLocation = path;
} }
delayedMessage.documentLocation = document; }
performSendDelayedMessage(delayedMessage); if (isSticker) {
reqSend.media = new TLRPC.TL_decryptedMessageMediaExternalDocument();
reqSend.media.id = document.id;
reqSend.media.date = document.date;
reqSend.media.mime_type = document.mime_type;
reqSend.media.size = document.size;
((TLRPC.TL_decryptedMessageMediaExternalDocument) reqSend.media).thumbImage = document.thumb;
reqSend.media.dc_id = document.dc_id;
reqSend.media.attributes = document.attributes;
SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, null, null);
} else { } else {
TLRPC.TL_inputEncryptedFile encryptedFile = new TLRPC.TL_inputEncryptedFile(); reqSend.media = new TLRPC.TL_decryptedMessageMediaDocument();
encryptedFile.id = document.id; reqSend.media.size = document.size;
encryptedFile.access_hash = document.access_hash; if (!(document.thumb instanceof TLRPC.TL_photoSizeEmpty)) {
reqSend.media.key = document.key; reqSend.media.thumb = document.thumb.bytes;
reqSend.media.iv = document.iv; reqSend.media.thumb_h = document.thumb.h;
SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, encryptedFile, null); reqSend.media.thumb_w = document.thumb.w;
} else {
reqSend.media.thumb = new byte[0];
reqSend.media.thumb_h = 0;
reqSend.media.thumb_w = 0;
}
reqSend.media.file_name = FileLoader.getDocumentFileName(document);
reqSend.media.mime_type = document.mime_type;
if (document.access_hash == 0) {
DelayedMessage delayedMessage = new DelayedMessage();
delayedMessage.originalPath = originalPath;
delayedMessage.sendEncryptedRequest = reqSend;
delayedMessage.type = 2;
delayedMessage.obj = newMsgObj;
delayedMessage.encryptedChat = encryptedChat;
if (path != null && path.length() > 0 && path.startsWith("http")) {
delayedMessage.httpLocation = path;
}
delayedMessage.documentLocation = document;
performSendDelayedMessage(delayedMessage);
} else {
TLRPC.TL_inputEncryptedFile encryptedFile = new TLRPC.TL_inputEncryptedFile();
encryptedFile.id = document.id;
encryptedFile.access_hash = document.access_hash;
reqSend.media.key = document.key;
reqSend.media.iv = document.iv;
SecretChatHelper.getInstance().performSendEncryptedRequest(reqSend, newMsgObj.messageOwner, encryptedChat, encryptedFile, null);
}
} }
} else if (type == 8) { } else if (type == 8) {
if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) { if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 17) {
@ -1544,6 +1563,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
} }
boolean isEncrypted = (int)dialog_id == 0; boolean isEncrypted = (int)dialog_id == 0;
boolean allowSticker = !isEncrypted;
String name = f.getName(); String name = f.getName();
if (name == null) { if (name == null) {
@ -1591,7 +1611,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
FileLog.e("tmessages", e); FileLog.e("tmessages", e);
} }
} }
if (document.mime_type.equals("image/webp") && !isEncrypted) { if (document.mime_type.equals("image/webp") && allowSticker) {
BitmapFactory.Options bmOptions = new BitmapFactory.Options(); BitmapFactory.Options bmOptions = new BitmapFactory.Options();
try { try {
bmOptions.inJustDecodeBounds = true; bmOptions.inJustDecodeBounds = true;

View file

@ -14,8 +14,9 @@ import java.util.Locale;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class TLRPC { public class TLRPC {
public static int MESSAGE_FLAG_UNREAD = 1; public static final int MESSAGE_FLAG_UNREAD = 1;
public static int MESSAGE_FLAG_OUT = 2; public static final int MESSAGE_FLAG_OUT = 2;
public static final int LAYER = 22;
public static class ChatPhoto extends TLObject { public static class ChatPhoto extends TLObject {
public FileLocation photo_small; public FileLocation photo_small;
@ -10831,7 +10832,7 @@ public class TLRPC {
public static class invokeWithLayer extends TLObject { public static class invokeWithLayer extends TLObject {
public static int constructor = 0xda9b0d0d; public static int constructor = 0xda9b0d0d;
public int layer = 22; public int layer = LAYER;
public TLObject query; public TLObject query;
public void serializeToStream(AbsSerializedData stream) { public void serializeToStream(AbsSerializedData stream) {

View file

@ -210,15 +210,17 @@ public class StickersAdapter extends RecyclerView.Adapter implements Notificatio
} }
final HashMap<String, ArrayList<TLRPC.Document>> result = new HashMap<>(); final HashMap<String, ArrayList<TLRPC.Document>> result = new HashMap<>();
for (TLRPC.TL_stickerPack stickerPack : res.packs) { for (TLRPC.TL_stickerPack stickerPack : res.packs) {
ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon); if (stickerPack != null && stickerPack.emoticon != null) {
for (Long id : stickerPack.documents) { ArrayList<TLRPC.Document> arrayList = result.get(stickerPack.emoticon);
TLRPC.Document document = documents.get(id); for (Long id : stickerPack.documents) {
if (document != null) { TLRPC.Document document = documents.get(id);
if (arrayList == null) { if (document != null) {
arrayList = new ArrayList<>(); if (arrayList == null) {
result.put(stickerPack.emoticon, arrayList); arrayList = new ArrayList<>();
result.put(stickerPack.emoticon, arrayList);
}
arrayList.add(document);
} }
arrayList.add(document);
} }
} }
} }

View file

@ -93,6 +93,7 @@ import org.telegram.ui.Components.TimerDrawable;
import org.telegram.ui.Components.TypingDotsDrawable; import org.telegram.ui.Components.TypingDotsDrawable;
import java.io.File; import java.io.File;
import java.io.RandomAccessFile;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -444,6 +445,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().addObserver(this, NotificationCenter.didCreatedNewDeleteTask); NotificationCenter.getInstance().addObserver(this, NotificationCenter.didCreatedNewDeleteTask);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted); NotificationCenter.getInstance().addObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateMessageMedia); NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance().addObserver(this, NotificationCenter.replaceMessagesObjects);
super.onFragmentCreate(); super.onFragmentCreate();
@ -502,6 +504,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.didCreatedNewDeleteTask);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioDidStarted); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.audioDidStarted);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateMessageMedia); NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateMessageMedia);
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.replaceMessagesObjects);
if (AndroidUtilities.isTablet()) { if (AndroidUtilities.isTablet()) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true); NotificationCenter.getInstance().postNotificationName(NotificationCenter.openedChatChanged, dialog_id, true);
} }
@ -1222,7 +1225,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
stickersAdapter.destroy(); stickersAdapter.destroy();
} }
if (currentEncryptedChat == null) { if (currentEncryptedChat == null || currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 23) {
stickersListView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); stickersListView.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0);
stickersListView.setAdapter(stickersAdapter = new StickersAdapter(getParentActivity(), new StickersAdapter.StickersAdapterDelegate() { stickersListView.setAdapter(stickersAdapter = new StickersAdapter(getParentActivity(), new StickersAdapter.StickersAdapterDelegate() {
@Override @Override
@ -1269,6 +1272,36 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onItemClick(View view, int position) { public void onItemClick(View view, int position) {
TLRPC.Document document = stickersAdapter.getItem(position); TLRPC.Document document = stickersAdapter.getItem(position);
if (document instanceof TLRPC.TL_document) { if (document instanceof TLRPC.TL_document) {
if (currentEncryptedChat != null && document.thumb instanceof TLRPC.TL_photoSize) {
File file = FileLoader.getPathToAttach(document.thumb, true);
if (file.exists()) {
try {
int len = (int)file.length();
byte[] arr = new byte[(int)file.length()];
RandomAccessFile reader = new RandomAccessFile(file, "r");
reader.readFully(arr);
TLRPC.TL_document newDocument = new TLRPC.TL_document();
newDocument.thumb = new TLRPC.TL_photoCachedSize();
newDocument.thumb.location = document.thumb.location;
newDocument.thumb.size = document.thumb.size;
newDocument.thumb.w = document.thumb.w;
newDocument.thumb.h = document.thumb.h;
newDocument.thumb.type = document.thumb.type;
newDocument.thumb.bytes = arr;
newDocument.id = document.id;
newDocument.access_hash = document.access_hash;
newDocument.date = document.date;
newDocument.mime_type = document.mime_type;
newDocument.size = document.size;
newDocument.dc_id = document.dc_id;
newDocument.attributes = document.attributes;
document = newDocument;
} catch (Exception e) {
FileLog.e("tmessages", e);
}
}
}
SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, dialog_id); SendMessagesHelper.getInstance().sendMessage((TLRPC.TL_document) document, null, null, dialog_id);
} }
chatActivityEnterView.setFieldText(""); chatActivityEnterView.setFieldText("");
@ -2661,6 +2694,25 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
existMessageObject.generateThumbs(false, 1); existMessageObject.generateThumbs(false, 1);
} }
updateVisibleRows(); updateVisibleRows();
} else if (id == NotificationCenter.replaceMessagesObjects) {
if (dialog_id == (long) args[0]) {
boolean changed = false;
ArrayList<MessageObject> messageObjects = (ArrayList<MessageObject>) args[1];
for (MessageObject messageObject : messageObjects) {
MessageObject old = messagesDict.get(messageObject.messageOwner.id);
if (old != null) {
messagesDict.put(old.messageOwner.id, messageObject);
int idx = messages.indexOf(old);
if (idx >= 0) {
messages.set(idx, messageObject);
changed = true;
}
}
}
if (changed) {
chatAdapter.notifyDataSetChanged();
}
}
} }
} }
@ -3098,15 +3150,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop()); chatListView.setSelectionFromTop(messages.size() - 1, -100000 - chatListView.getPaddingTop());
} }
} else if (option == 1) { } else if (option == 1) {
ArrayList<Integer> ids = new ArrayList<>(); final MessageObject finalSelectedObject = selectedObject;
ids.add(selectedObject.messageOwner.id); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
removeUnreadPlane(true); builder.setMessage(LocaleController.formatString("AreYouSureDeleteMessages", R.string.AreYouSureDeleteMessages, LocaleController.formatPluralString("messages", 1)));
ArrayList<Long> random_ids = null; builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
if (currentEncryptedChat != null && selectedObject.messageOwner.random_id != 0 && selectedObject.type != 10) { builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
random_ids = new ArrayList<>(); @Override
random_ids.add(selectedObject.messageOwner.random_id); public void onClick(DialogInterface dialogInterface, int i) {
} ArrayList<Integer> ids = new ArrayList<>();
MessagesController.getInstance().deleteMessages(ids, random_ids, currentEncryptedChat); ids.add(finalSelectedObject.messageOwner.id);
removeUnreadPlane(true);
ArrayList<Long> random_ids = null;
if (currentEncryptedChat != null && finalSelectedObject.messageOwner.random_id != 0 && finalSelectedObject.type != 10) {
random_ids = new ArrayList<>();
random_ids.add(finalSelectedObject.messageOwner.random_id);
}
MessagesController.getInstance().deleteMessages(ids, random_ids, currentEncryptedChat);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showAlertDialog(builder);
} else if (option == 2) { } else if (option == 2) {
forwaringMessage = selectedObject; forwaringMessage = selectedObject;
Bundle args = new Bundle(); Bundle args = new Bundle();

View file

@ -123,7 +123,7 @@
<string name="NotificationMessageMap">%1$s قام بإرسال موقع لك</string> <string name="NotificationMessageMap">%1$s قام بإرسال موقع لك</string>
<string name="NotificationMessageDocument">%1$s قام بإرسال مستند لك</string> <string name="NotificationMessageDocument">%1$s قام بإرسال مستند لك</string>
<string name="NotificationMessageAudio">%1$s قام بإرسال مقطع صوتي لك</string> <string name="NotificationMessageAudio">%1$s قام بإرسال مقطع صوتي لك</string>
<string name="NotificationMessageSticker">%1$s sent you an sticker</string> <string name="NotificationMessageSticker">%1$s قام بإرسال ملصق</string>
<string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string> <string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string>
<string name="NotificationMessageGroupNoText">%1$s قام بإرسال رسالة للمجموعة %2$s</string> <string name="NotificationMessageGroupNoText">%1$s قام بإرسال رسالة للمجموعة %2$s</string>
<string name="NotificationMessageGroupPhoto">%1$s قام بإرسال صورة للمجموعة %2$s</string> <string name="NotificationMessageGroupPhoto">%1$s قام بإرسال صورة للمجموعة %2$s</string>
@ -132,7 +132,7 @@
<string name="NotificationMessageGroupMap">%1$s قام بإرسال موقع للمجموعة %2$s</string> <string name="NotificationMessageGroupMap">%1$s قام بإرسال موقع للمجموعة %2$s</string>
<string name="NotificationMessageGroupDocument">%1$s قام بإرسال مستند للمجموعة %2$s</string> <string name="NotificationMessageGroupDocument">%1$s قام بإرسال مستند للمجموعة %2$s</string>
<string name="NotificationMessageGroupAudio">%1$s قام بإرسال مقطع صوتي للمجموعة %2$s</string> <string name="NotificationMessageGroupAudio">%1$s قام بإرسال مقطع صوتي للمجموعة %2$s</string>
<string name="NotificationMessageGroupSticker">%1$s sent an sticker to the group %2$s</string> <string name="NotificationMessageGroupSticker">%1$s قام بإرسال ملصق للمجموعة %2$s</string>
<string name="NotificationInvitedToGroup">%1$s قام بدعوتك للمجموعة %2$s</string> <string name="NotificationInvitedToGroup">%1$s قام بدعوتك للمجموعة %2$s</string>
<string name="NotificationEditedGroupName">%1$s قام بتعديل اسم المجموعة %2$s</string> <string name="NotificationEditedGroupName">%1$s قام بتعديل اسم المجموعة %2$s</string>
<string name="NotificationEditedGroupPhoto">%1$s قام بتغيير صورة المجموعة %2$s</string> <string name="NotificationEditedGroupPhoto">%1$s قام بتغيير صورة المجموعة %2$s</string>
@ -309,7 +309,7 @@
<string name="NoPhotos">لا توجد صور حتى الآن</string> <string name="NoPhotos">لا توجد صور حتى الآن</string>
<string name="PleaseDownload">فضلًا، قم بتنزيل الوسائط أولًا</string> <string name="PleaseDownload">فضلًا، قم بتنزيل الوسائط أولًا</string>
<string name="NoRecentPhotos">لا توجد صور حديثة</string> <string name="NoRecentPhotos">لا توجد صور حديثة</string>
<string name="NoRecentGIFs">لا توجد صور حديثة</string> <string name="NoRecentGIFs">لا يوجد صور متحركة حديثة</string>
<string name="SearchImages">البحث على الإنترنت</string> <string name="SearchImages">البحث على الإنترنت</string>
<string name="SearchGifs">البحث عن صور متحركة</string> <string name="SearchGifs">البحث عن صور متحركة</string>
<string name="SearchImagesTitle">البحث على الإنترنت</string> <string name="SearchImagesTitle">البحث على الإنترنت</string>
@ -419,7 +419,7 @@
<string name="AttachLocation">موقع</string> <string name="AttachLocation">موقع</string>
<string name="AttachContact">جهة اتصال</string> <string name="AttachContact">جهة اتصال</string>
<string name="AttachDocument">مستند</string> <string name="AttachDocument">مستند</string>
<string name="AttachSticker">Sticker</string> <string name="AttachSticker">ملصق</string>
<string name="AttachAudio">مقطع صوتي</string> <string name="AttachAudio">مقطع صوتي</string>
<string name="FromYou">أنت</string> <string name="FromYou">أنت</string>
<string name="ActionTakeScreenshootYou">أنت أخذت لقطة للشاشة !</string> <string name="ActionTakeScreenshootYou">أنت أخذت لقطة للشاشة !</string>

View file

@ -123,7 +123,7 @@
<string name="NotificationMessageMap">%1$s sent you a location</string> <string name="NotificationMessageMap">%1$s sent you a location</string>
<string name="NotificationMessageDocument">%1$s sent you a document</string> <string name="NotificationMessageDocument">%1$s sent you a document</string>
<string name="NotificationMessageAudio">%1$s sent you an audio</string> <string name="NotificationMessageAudio">%1$s sent you an audio</string>
<string name="NotificationMessageSticker">%1$s sent you an sticker</string> <string name="NotificationMessageSticker">%1$s sent you a sticker</string>
<string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string> <string name="NotificationMessageGroupText">%1$s @ %2$s: %3$s</string>
<string name="NotificationMessageGroupNoText">%1$s sent a message to the group %2$s</string> <string name="NotificationMessageGroupNoText">%1$s sent a message to the group %2$s</string>
<string name="NotificationMessageGroupPhoto">%1$s sent a photo to the group %2$s</string> <string name="NotificationMessageGroupPhoto">%1$s sent a photo to the group %2$s</string>
@ -132,7 +132,7 @@
<string name="NotificationMessageGroupMap">%1$s sent a location to the group %2$s</string> <string name="NotificationMessageGroupMap">%1$s sent a location to the group %2$s</string>
<string name="NotificationMessageGroupDocument">%1$s sent a document to the group %2$s</string> <string name="NotificationMessageGroupDocument">%1$s sent a document to the group %2$s</string>
<string name="NotificationMessageGroupAudio">%1$s sent an audio to the group %2$s</string> <string name="NotificationMessageGroupAudio">%1$s sent an audio to the group %2$s</string>
<string name="NotificationMessageGroupSticker">%1$s sent an sticker to the group %2$s</string> <string name="NotificationMessageGroupSticker">%1$s sent a sticker to the group %2$s</string>
<string name="NotificationInvitedToGroup">%1$s invited you to the group %2$s</string> <string name="NotificationInvitedToGroup">%1$s invited you to the group %2$s</string>
<string name="NotificationEditedGroupName">%1$s edited the group\'s %2$s name</string> <string name="NotificationEditedGroupName">%1$s edited the group\'s %2$s name</string>
<string name="NotificationEditedGroupPhoto">%1$s edited the group\'s %2$s photo</string> <string name="NotificationEditedGroupPhoto">%1$s edited the group\'s %2$s photo</string>