This commit is contained in:
B. Petersen
2016-11-29 15:17:13 +01:00
parent ca49e9899d
commit 072945b237
14 changed files with 37 additions and 434 deletions
@@ -502,10 +502,6 @@ public class AndroidUtilities {
return (cm / 2.54f) * (isX ? displayMetrics.xdpi : displayMetrics.ydpi);
}
public static int getPeerLayerVersion(int layer) {
return (layer >> 16) & 0xffff;
}
public static void runOnUIThread(Runnable runnable) {
runOnUIThread(runnable, 0);
}
@@ -583,78 +579,6 @@ public class AndroidUtilities {
}
}
/*
public static AlertDialog.Builder buildTTLAlert(final Context context, final TLRPC.EncryptedChat encryptedChat) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
final NumberPicker numberPicker = new NumberPicker(context);
numberPicker.setMinValue(0);
numberPicker.setMaxValue(20);
if (encryptedChat.ttl > 0 && encryptedChat.ttl < 16) {
numberPicker.setValue(encryptedChat.ttl);
} else if (encryptedChat.ttl == 30) {
numberPicker.setValue(16);
} else if (encryptedChat.ttl == 60) {
numberPicker.setValue(17);
} else if (encryptedChat.ttl == 60 * 60) {
numberPicker.setValue(18);
} else if (encryptedChat.ttl == 60 * 60 * 24) {
numberPicker.setValue(19);
} else if (encryptedChat.ttl == 60 * 60 * 24 * 7) {
numberPicker.setValue(20);
} else if (encryptedChat.ttl == 0) {
numberPicker.setValue(0);
}
numberPicker.setFormatter(new NumberPicker.Formatter() {
@Override
public String format(int value) {
if (value == 0) {
return LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever);
} else if (value >= 1 && value < 16) {
return AndroidUtilities.formatTTLString(value);
} else if (value == 16) {
return AndroidUtilities.formatTTLString(30);
} else if (value == 17) {
return AndroidUtilities.formatTTLString(60);
} else if (value == 18) {
return AndroidUtilities.formatTTLString(60 * 60);
} else if (value == 19) {
return AndroidUtilities.formatTTLString(60 * 60 * 24);
} else if (value == 20) {
return AndroidUtilities.formatTTLString(60 * 60 * 24 * 7);
}
return "";
}
});
builder.setView(numberPicker);
builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
int oldValue = encryptedChat.ttl;
which = numberPicker.getValue();
if (which >= 0 && which < 16) {
encryptedChat.ttl = which;
} else if (which == 16) {
encryptedChat.ttl = 30;
} else if (which == 17) {
encryptedChat.ttl = 60;
} else if (which == 18) {
encryptedChat.ttl = 60 * 60;
} else if (which == 19) {
encryptedChat.ttl = 60 * 60 * 24;
} else if (which == 20) {
encryptedChat.ttl = 60 * 60 * 24 * 7;
}
if (oldValue != encryptedChat.ttl) {
//SecretChatHelper.getInstance().sendTTLMessage(encryptedChat, null);
//MessagesStorage.getInstance().updateEncryptedChatTTL(encryptedChat);
}
}
});
return builder;
}
*/
public static void clearCursorDrawable(EditText editText) {
if (editText == null) {
return;
@@ -504,11 +504,6 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
private ExternalObserver externalObserver = null;
private InternalObserver internalObserver = null;
private long lastSecretChatEnterTime = 0;
private long lastSecretChatLeaveTime = 0;
private long lastMediaCheckTime = 0;
private TLRPC.EncryptedChat lastSecretChat = null;
private ArrayList<Long> lastSecretChatVisibleMessages = null;
private int startObserverToken = 0;
private StopMediaObserverRunnable stopMediaObserverRunnable = null;
@@ -9,18 +9,12 @@
package com.b44t.messenger;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.b44t.messenger.query.DraftQuery;
import com.b44t.messenger.query.MessagesQuery;
import com.b44t.messenger.query.SearchQuery;
import com.b44t.ui.ActionBar.BaseFragment;
import com.b44t.ui.ChatActivity;
import com.b44t.ui.ProfileActivity;
import java.util.ArrayList;
import java.util.Collections;
@@ -32,7 +26,6 @@ import java.util.concurrent.Semaphore;
public class MessagesController implements NotificationCenter.NotificationCenterDelegate {
private ConcurrentHashMap<Integer, TLRPC.Chat> chats = new ConcurrentHashMap<>(100, 1.0f, 2);
private ConcurrentHashMap<Integer, TLRPC.EncryptedChat> encryptedChats = new ConcurrentHashMap<>(10, 1.0f, 2);
private ConcurrentHashMap<Integer, TLRPC.User> users = new ConcurrentHashMap<>(100, 1.0f, 2);
private ConcurrentHashMap<String, TLRPC.User> usersByUsernames = new ConcurrentHashMap<>(100, 1.0f, 2);
@@ -376,10 +369,6 @@ public class MessagesController implements NotificationCenter.NotificationCenter
return chats.get(id);
}
public TLRPC.EncryptedChat getEncryptedChat(Integer id) {
return encryptedChats.get(id);
}
public void setLastCreatedDialogId(final long dialog_id, final boolean set) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
@@ -616,15 +605,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter
}
*/
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, TLRPC.EncryptedChat encryptedChat, final int channelId) {
}
public void deleteDialog(final long did, final int onlyHistory) {
deleteDialog(did, true, onlyHistory, 0);
}
private void deleteDialog(final long did, final boolean first, final int onlyHistory, final int max_id) {
public void deleteMessages(ArrayList<Integer> messages, ArrayList<Long> randoms, Object encryptedChat, final int channelId) {
}
@@ -544,46 +544,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter
if (document == null) {
return;
}
if ((int) peer == 0) {
int high_id = (int) (peer >> 32);
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(high_id);
if (encryptedChat == null) {
return;
}
if (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;
if (newDocument.mime_type == null) {
newDocument.mime_type = "";
}
document = newDocument;
} catch (Exception e) {
FileLog.e("messenger", e);
}
}
}
}
SendMessagesHelper.getInstance().sendMessageDocument((TLRPC.TL_document) document, null, null, peer, replyingMessageObject, null);
}
@@ -97,15 +97,6 @@ public class TLRPC {
public static class TL_geoPoint extends GeoPoint {
}
public static class SendMessageAction extends TLObject {
public int progress;
}
public static class PrivacyRule extends TLObject {
public ArrayList<Integer> users = new ArrayList<>();
}
public static class TL_messageMediaEmpty extends MessageMedia {
}
@@ -426,39 +417,6 @@ public class TLRPC {
public static class TL_userStatusRecently extends UserStatus {
}
public static class Update extends TLObject {
public int chat_id;
public int user_id;
public int date;
public int version;
public DraftMessage draft;
public int pts;
public byte[] data;
public int flags;
public String query;
public String offset;
public int channel_id;
public SendMessageAction action;
public boolean blocked;
public String location;
public boolean enabled;
public ArrayList<PrivacyRule> rules = new ArrayList<>();
public UserStatus status;
public int views;
public String type;
public MessageMedia media;
public String first_name;
public String last_name;
public String username;
public ArrayList<Integer> messages = new ArrayList<>();
public String phone;
public WebPage webpage;
public EncryptedChat chat;
public ArrayList<Long> order = new ArrayList<>();
public UserProfilePhoto photo;
public boolean previous;
}
public static class InputEncryptedFile extends TLObject {
public long id;
public int parts;
@@ -561,7 +519,6 @@ public class TLRPC {
public String username;
public boolean restricted;
public boolean signatures;
public String restriction_reason;
public boolean min;
public String address;
}
@@ -647,26 +604,6 @@ public class TLRPC {
public String name;
}
public static class Updates extends TLObject {
public ArrayList<Update> updates = new ArrayList<>();
public ArrayList<User> users = new ArrayList<>();
public ArrayList<Chat> chats = new ArrayList<>();
public int date;
public int seq;
public int flags;
public boolean out;
public boolean mentioned;
public boolean silent;
public int id;
public int user_id;
public String message;
public int pts;
public MessageMedia media;
public Update update;
public int from_id;
public int chat_id;
}
public static class WallPaper extends TLObject {
public int id;
public String title;
@@ -745,17 +682,6 @@ public class TLRPC {
public WebPage webpage;
}
public static class EncryptedChat extends TLObject {
public int id;
public int date;
public byte[] nonce;
public byte[] auth_key; //custom
public int user_id; //custom
public int ttl; //custom
public int layer; //custom
public byte[] key_hash; //custom
}
public static class Message extends TLObject {
public int id;
public int from_id;
@@ -19,21 +19,6 @@ public class UserObject {
}
public static String getUserName(TLRPC.User user) {
if (user == null || isDeleted(user)) {
return "ErrName";
}
String name = ContactsController.formatName(user.first_name, user.last_name);
return name.length() != 0 || user.phone == null || user.phone.length() == 0 ? name : ""/*PhoneFormat.getInstance().format("+" + user.phone)*/;
}
public static String getFirstName(TLRPC.User user) {
if (user == null || isDeleted(user)) {
return "DELETED";
}
String name = user.first_name;
if (name == null || name.length() == 0) {
name = user.last_name;
}
return name != null && name.length() > 0 ? name : "ErrFirstName";
return "ErrName"; // use MrContact.getName() instead
}
}
@@ -304,12 +304,4 @@ public class BaseFragment {
protected void onDialogDismiss(Dialog dialog) {
}
public Dialog getVisibleDialog() {
return visibleDialog;
}
public void setVisibleDialog(Dialog dialog) {
visibleDialog = dialog;
}
}
@@ -1019,7 +1019,7 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
TLRPC.User user = null;
TLRPC.Chat chat = null;
TLRPC.EncryptedChat encryptedChat = null;
final Object encryptedChat = null;
CharSequence username = null;
CharSequence name = null;
boolean isRecent = false;
@@ -1035,10 +1035,10 @@ public class DialogsSearchAdapter extends BaseSearchAdapterRecycler {
chat = (TLRPC.Chat) obj;
}
un = chat.username;
} else if (obj instanceof TLRPC.EncryptedChat) {
}/* else if (obj instanceof TLRPC.EncryptedChat) {
encryptedChat = MessagesController.getInstance().getEncryptedChat(((TLRPC.EncryptedChat) obj).id);
user = MessagesController.getInstance().getUser(encryptedChat.user_id);
}
}*/
if (isRecentSearchDisplayed()) {
isRecent = true;
@@ -269,19 +269,6 @@ public class DialogCell extends BaseCell {
//drawNameBot = false;
drawVerified = false;
/* EDIT BY MR
if (encryptedChat != null) {
drawNameLock = true;
nameLockTop = AndroidUtilities.dp(16.5f);
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + lockDrawable.getIntrinsicWidth();
} else {
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline) - lockDrawable.getIntrinsicWidth();
nameLeft = AndroidUtilities.dp(14);
}
} else
*/
{
if (m_mrChat.getType()==MrChat.MR_CHAT_GROUP) { // EDIT BY MR
//if (chat.id < 0 || ChatObject.isChannel(chat) && !chat.megagroup) {
@@ -51,7 +51,7 @@ public class ProfileSearchCell extends BaseCell {
private TLRPC.User user = null;
private TLRPC.Chat chat = null;
private TLRPC.EncryptedChat encryptedChat = null;
private final Object encryptedChat = null;
private long dialog_id;
private String lastName = null;
@@ -126,7 +126,7 @@ public class ProfileSearchCell extends BaseCell {
return super.onTouchEvent(event);
}
public void setData(TLObject object, TLRPC.EncryptedChat ec, CharSequence n, CharSequence s, boolean needCount) {
public void setData(TLObject object, Object ec, CharSequence n, CharSequence s, boolean needCount) {
currentName = n;
if (object instanceof TLRPC.User) {
user = (TLRPC.User) object;
@@ -135,7 +135,6 @@ public class ProfileSearchCell extends BaseCell {
chat = (TLRPC.Chat) object;
user = null;
}
encryptedChat = ec;
subLabel = s;
drawCount = needCount;
update(0);
@@ -176,18 +175,7 @@ public class ProfileSearchCell extends BaseCell {
drawNameGroup = false;
drawCheck = false;
/*if (encryptedChat != null) {
drawNameLock = true;
dialog_id = ((long) encryptedChat.id) << 32;
if (!LocaleController.isRTL) {
nameLockLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline);
nameLeft = AndroidUtilities.dp(AndroidUtilities.leftBaseline + 4) + lockDrawable.getIntrinsicWidth();
} else {
nameLockLeft = getMeasuredWidth() - AndroidUtilities.dp(AndroidUtilities.leftBaseline + 2) - lockDrawable.getIntrinsicWidth();
nameLeft = AndroidUtilities.dp(11);
}
nameLockTop = AndroidUtilities.dp(16.5f);
} else*/ {
{
if (chat != null) {
/*if (chat.id < 0) {
dialog_id = AndroidUtilities.makeBroadcastId(chat.id);
@@ -235,11 +223,7 @@ public class ProfileSearchCell extends BaseCell {
nameString = nameString2.replace('\n', ' ');
}
/*if (encryptedChat != null) {
currentNamePaint = nameEncryptedPaint;
} else*/ {
currentNamePaint = namePaint;
}
currentNamePaint = namePaint;
int onlineWidth;
int nameWidth;
@@ -52,7 +52,6 @@ import android.view.ViewTreeObserver;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -142,13 +141,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
protected TLRPC.Chat currentChat;
protected TLRPC.User currentUser; // originally currentChat<->currentUser was used to differ between normal or group chats
private final TLRPC.EncryptedChat currentEncryptedChat = null;
public MrChat m_mrChat = new MrChat(0);
private ArrayList<ChatMessageCell> chatMessageCellsCache = new ArrayList<>();
private final Dialog closeChatDialog = null;
private FrameLayout progressView;
private FrameLayout bottomOverlay;
protected ChatActivityEnterView chatActivityEnterView;
@@ -164,9 +161,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private FrameLayout emptyViewContainer;
private ArrayList<View> actionModeViews = new ArrayList<>();
private ChatAvatarContainer avatarContainer;
private TextView bottomOverlayText;
private NumberTextView selectedMessagesCountTextView;
private FrameLayout actionModeTitleContainer;
private SimpleTextView actionModeTextView;
private SimpleTextView actionModeSubTextView;
private RecyclerListView stickersListView;
@@ -223,8 +218,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean openSearchKeyboard;
private boolean waitingForReplyMessageLoad;
private boolean allowStickersPanel;
private boolean allowContextBotPanel;
private boolean allowContextBotPanelSecond = true;
@@ -252,7 +245,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private boolean scrollToTopUnReadOnResume;
private long dialog_id;
private int lastLoadIndex;
private final boolean isBroadcast = false;
private HashMap<Integer, MessageObject>[] selectedMessagesIds = new HashMap[]{new HashMap<>(), new HashMap<>()};
private HashMap<Integer, MessageObject>[] selectedMessagesCanCopyIds = new HashMap[]{new HashMap<>(), new HashMap<>()};
private ArrayList<Integer> waitingForLoad = new ArrayList<>();
@@ -276,7 +268,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final long mergeDialogId = 0;
private int startLoadFromMessageId;
private boolean needSelectFromMessageId;
private int returnToMessageId;
private int returnToLoadIndex;
@@ -852,7 +843,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
});
actionModeTitleContainer = new FrameLayout(context) {
FrameLayout actionModeTitleContainer = new FrameLayout(context) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
@@ -1601,7 +1592,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
mentionsAdapter.setParentFragment(this);
mentionsAdapter.setChatInfo(info);
mentionsAdapter.setNeedUsernames(currentChat != null);
mentionsAdapter.setNeedBotContext(currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46);
mentionsAdapter.setNeedBotContext(true);
mentionListView.setOnItemClickListener(mentionsOnItemClickListener = new RecyclerListView.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
@@ -1709,9 +1700,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatActivityEnterView = new ChatActivityEnterView(getParentActivity(), contentView, this, true);
chatActivityEnterView.setDialogId(dialog_id);
chatActivityEnterView.addToAttachLayout(menuItem);
//noinspection ResourceType
chatActivityEnterView.setId(id_chat_compose_panel);
//chatActivityEnterView.setAllowStickersAndGifs(currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 23, currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46);
chatActivityEnterView.setAllowStickersAndGifs(false, false); // for the moment, we have no stickers
contentView.addView(chatActivityEnterView, contentView.getChildCount() - 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
@@ -1828,7 +1820,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatActivityEnterView.invalidate();
}
if (getVisibility() != GONE) {
int height = getLayoutParams().height;
//int height = getLayoutParams().height;
if (chatListView != null) {
chatListView.setTranslationY(translationY);
}
@@ -1985,7 +1977,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
bottomOverlay.setPadding(0, AndroidUtilities.dp(3), 0, 0);
contentView.addView(bottomOverlay, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 51, Gravity.BOTTOM));
bottomOverlayText = new TextView(context);
TextView bottomOverlayText = new TextView(context);
bottomOverlayText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
bottomOverlayText.setTextColor(Theme.CHAT_BOTTOM_OVERLAY_TEXT_COLOR);
bottomOverlay.addView(bottomOverlayText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
@@ -2013,7 +2005,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
chatAdapter.updateRows();
if (loading && messages.isEmpty()) {
progressView.setVisibility(chatAdapter.botInfoRow == -1 ? View.VISIBLE : View.INVISIBLE);
progressView.setVisibility(View.VISIBLE);
chatListView.setEmptyView(null);
} else {
progressView.setVisibility(View.INVISIBLE);
@@ -2140,7 +2132,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
private void initStickers() {
if (chatActivityEnterView == null || getParentActivity() == null || stickersAdapter != null || currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 23) {
if (chatActivityEnterView == null || getParentActivity() == null || stickersAdapter != null ) {
return;
}
if (stickersAdapter != null) {
@@ -2367,7 +2359,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
return;
}
PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, currentEncryptedChat == null || AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) >= 46, ChatActivity.this);
PhotoAlbumPickerActivity fragment = new PhotoAlbumPickerActivity(false, true, ChatActivity.this);
fragment.setDelegate(new PhotoAlbumPickerActivity.PhotoAlbumPickerActivityDelegate() {
@Override
public void didSelectPhotos(ArrayList<String> photos, ArrayList<String> captions, ArrayList<MediaController.SearchImage> webPhotos) {
@@ -2621,7 +2613,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messagesByDays.clear();
waitingForLoad.clear();
progressView.setVisibility(chatAdapter.botInfoRow == -1 ? View.VISIBLE : View.INVISIBLE);
progressView.setVisibility(View.VISIBLE);
chatListView.setEmptyView(null);
for (int a = 0; a < 2; a++) {
messagesDict[a].clear();
@@ -2639,10 +2631,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
firstLoading = true;
loading = true;
loadingForward = false;
waitingForReplyMessageLoad = false;
startLoadFromMessageId = 0;
last_message_id = 0;
needSelectFromMessageId = false;
chatAdapter.notifyDataSetChanged();
}
@@ -2667,14 +2657,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return;
}
int count = chatListView.getChildCount();
int additionalTop = chatActivityEnterView.isTopViewVisible() ? AndroidUtilities.dp(48) : 0;
//int additionalTop = chatActivityEnterView.isTopViewVisible() ? AndroidUtilities.dp(48) : 0;
int height = chatListView.getMeasuredHeight();
for (int a = 0; a < count; a++) {
View view = chatListView.getChildAt(a);
if (view instanceof ChatMessageCell) {
ChatMessageCell messageCell = (ChatMessageCell) view;
int top = messageCell.getTop();
int bottom = messageCell.getBottom();
//int bottom = messageCell.getBottom();
int viewTop = top >= 0 ? 0 : -top;
int viewBottom = messageCell.getMeasuredHeight();
if (viewBottom > height) {
@@ -2767,7 +2757,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
int chatId = MrMailbox.createChatByContactId(fromId);
if( chatId != 0 ) {
Bundle args = new Bundle();
args.putInt("chat_id", (int)chatId);
args.putInt("chat_id", chatId);
presentFragment(new ChatActivity(args), true /*removeLast*/);
}
else {
@@ -2838,7 +2828,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
scrollToMessage = null;*/
waitingForLoad.clear();
waitingForReplyMessageLoad = true;
highlightMessageId = Integer.MAX_VALUE;
scrollToMessagePosition = -10000;
startLoadFromMessageId = id;
@@ -2848,7 +2837,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
returnToMessageId = fromMessageId;
returnToLoadIndex = loadIndex;
needSelectFromMessageId = select;
}
private void showPagedownButton(boolean show, boolean animated) {
@@ -2929,9 +2917,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (messageObject == null) {
return -1;
}
if (currentEncryptedChat == null) {
boolean isBroadcastError = isBroadcast && messageObject.getId() <= 0 && messageObject.isSendError();
if (!isBroadcast && messageObject.getId() <= 0 && messageObject.isOut() || isBroadcastError) {
{
if ( messageObject.getId() <= 0 && messageObject.isOut() ) {
if (messageObject.isSendError()) {
if (!messageObject.isMediaEmpty()) {
return 0;
@@ -2998,63 +2985,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
return 2;
}
}
} else {
if (messageObject.type == 6) {
return -1;
} else if (messageObject.isSendError()) {
if (!messageObject.isMediaEmpty()) {
return 0;
} else {
return 20;
}
} else if (messageObject.type == 10 || messageObject.type == 11) {
if (messageObject.getId() == 0 /*|| messageObject.isSending()*/) {
return -1;
} else {
return 1;
}
} else {
if (messageObject.isVoice()) {
return 2;
} else if (messageObject.isSticker()) {
TLRPC.InputStickerSet inputStickerSet = messageObject.getInputStickerSet();
if (inputStickerSet instanceof TLRPC.TL_inputStickerSetShortName) {
if (!StickersQuery.isStickerPackInstalled(inputStickerSet.short_name)) {
return 7;
}
}
} else if (messageObject.messageOwner.media instanceof TLRPC.TL_messageMediaPhoto || messageObject.getDocument() != null || messageObject.isMusic() || messageObject.isVideo()) {
boolean canSave = false;
if (messageObject.messageOwner.attachPath != null && messageObject.messageOwner.attachPath.length() != 0) {
File f = new File(messageObject.messageOwner.attachPath);
if (f.exists()) {
canSave = true;
}
}
if (!canSave) {
File f = FileLoader.getPathToMessage(messageObject.messageOwner);
if (f.exists()) {
canSave = true;
}
}
if (canSave) {
if (messageObject.getDocument() != null) {
String mime = messageObject.getDocument().mime_type;
if (mime != null && mime.endsWith("text/xml")) {
return 5;
}
}
if (messageObject.messageOwner.ttl <= 0) {
return 4;
}
}
} else if (messageObject.type == 12) {
return 8;
} else if (messageObject.isMediaEmpty()) {
return 3;
}
return 2;
}
}
}
@@ -3532,9 +3462,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (obj.getId() > 0) {
maxMessageId[loadIndex] = Math.min(obj.getId(), maxMessageId[loadIndex]);
minMessageId[loadIndex] = Math.max(obj.getId(), minMessageId[loadIndex]);
} else if (currentEncryptedChat != null) {
maxMessageId[loadIndex] = Math.max(obj.getId(), maxMessageId[loadIndex]);
minMessageId[loadIndex] = Math.min(obj.getId(), minMessageId[loadIndex]);
}
if (obj.messageOwner.date != 0) {
maxDate[loadIndex] = Math.max(maxDate[loadIndex], obj.messageOwner.date);
@@ -3720,15 +3647,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
first = false;
}
if (newRowsCount == 0 && currentEncryptedChat != null && !endReached[0]) {
first = true;
if (chatListView != null) {
chatListView.setEmptyView(null);
}
if (emptyViewContainer != null) {
emptyViewContainer.setVisibility(View.INVISIBLE);
}
} else {
{
if (progressView != null) {
progressView.setVisibility(View.INVISIBLE);
}
@@ -4147,12 +4066,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
waitingForLoad.add(lastLoadIndex);
MessagesController.getInstance().loadMessages(dialog_id, 30, 0, !cacheEndReached[0], minDate[0], classGuid, 0, 0, ChatObject.isChannel(currentChat), lastLoadIndex++);
loading = true;
} /*else {
if ( currentUser != null && currentUser.bot && botUser == null) {
botUser = "";
updateBottomOverlay();
}
}*/
}
}
if (updated && chatAdapter != null) {
removeUnreadPlane();
@@ -4275,13 +4189,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
messagesByDays.clear();
for (int a = 1; a >= 0; a--) {
messagesDict[a].clear();
if (currentEncryptedChat == null) {
maxMessageId[a] = Integer.MAX_VALUE;
minMessageId[a] = Integer.MIN_VALUE;
} else {
maxMessageId[a] = Integer.MIN_VALUE;
minMessageId[a] = Integer.MAX_VALUE;
}
maxDate[a] = Integer.MIN_VALUE;
minDate[a] = 0;
selectedMessagesIds[a].clear();
@@ -4293,7 +4202,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if ((Boolean) args[1]) {
if (chatAdapter != null) {
progressView.setVisibility(chatAdapter.botInfoRow == -1 ? View.VISIBLE : View.INVISIBLE);
progressView.setVisibility(View.VISIBLE);
chatListView.setEmptyView(null);
}
for (int a = 0; a < 2; a++) {
@@ -4305,7 +4214,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
firstLoading = true;
loading = true;
startLoadFromMessageId = 0;
needSelectFromMessageId = false;
waitingForLoad.add(lastLoadIndex);
MessagesController.getInstance().loadMessages(dialog_id, AndroidUtilities.isTablet() ? 30 : 20, 0, true, 0, classGuid, 2, 0, ChatObject.isChannel(currentChat), lastLoadIndex++);
} else {
@@ -4559,20 +4467,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
@Override
protected void onDialogDismiss(Dialog dialog) {
if (closeChatDialog != null && dialog == closeChatDialog) {
MessagesController.getInstance().deleteDialog(dialog_id, 0);
if (parentLayout != null && !parentLayout.fragmentsStack.isEmpty() && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) != this) {
BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1);
removeSelfFromStack();
fragment.finishFragment();
} else {
finishFragment();
}
}
}
private void updateBottomOverlay() {
// the bottom overlay is also used for going through search results, however, it would be nicer to add the button [^] [v] to the actionbar
// moreover, we ouse the bottom overlay for the "dead drop chat"
@@ -5029,8 +4923,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
boolean allowChatActions = true;
if (/*currentEncryptedChat != null && AndroidUtilities.getPeerLayerVersion(currentEncryptedChat.layer) < 46 ||*/
type == 1 && message.getDialogId() == mergeDialogId
|| currentEncryptedChat == null && message.getId() < 0
|| isBroadcast
|| message.getId() < 0
|| currentChat != null && (ChatObject.isNotInChat(currentChat)
|| ChatObject.isChannel(currentChat) && !currentChat.creator && !currentChat.editor && !currentChat.megagroup)) {
allowChatActions = false;
@@ -5053,7 +4946,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
items.add(LocaleController.getString("Delete", R.string.Delete));
options.add(1);
} else if (type == 1) {
if (currentChat != null /*&& !isBroadcast*/) {
if (currentChat != null ) {
if (allowChatActions) {
items.add(LocaleController.getString("Reply", R.string.Reply));
options.add(8);
@@ -5487,7 +5380,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
//boolean started = false;
for (int a = messages.size() - 1; a >= 0; a--) {
MessageObject messageObject = messages.get(a);
if ((currentEncryptedChat == null && messageObject.getId() > messageId || currentEncryptedChat != null && messageObject.getId() < messageId) && messageObject.isVoice() && (!playingUnreadMedia || messageObject.isContentUnread() && !messageObject.isOut())) {
if( (messageObject.getId() > messageId) && messageObject.isVoice() && (!playingUnreadMedia || (messageObject.isContentUnread() && !messageObject.isOut()))) {
messageObjects.add(messageObject);
}
}
@@ -5668,7 +5561,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private Context mContext;
private final boolean isBot = false;
private int rowCount;
private final int botInfoRow = -1;
private int loadingUpRow;
private int loadingDownRow;
private int messagesStartRow;
@@ -5932,9 +5824,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
});
/*if (currentEncryptedChat == null)*/ {
chatMessageCell.setAllowAssistant(true);
}
chatMessageCell.setAllowAssistant(true);
} else if (viewType == ROWTYPE_ACTION_CELL) {
view = new ChatActionCell(mContext);
((ChatActionCell) view).setDelegate(new ChatActionCell.ChatActionCellDelegate() {
@@ -5972,21 +5862,20 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
} else if (viewType == ROWTYPE_UNREAD_CELL) {
view = new ChatUnreadCell(mContext);
} else if (viewType == ROWTYPE_BOTINFO_CELL) {
// was: BotHelpCell
} else if (viewType == ROWTYPE_LOADING_CELL) {
view = new ChatLoadingCell(mContext);
}
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
if( view != null ) {
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
}
return new Holder(view);
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (position == botInfoRow) {
//BotHelpCell helpView = (BotHelpCell) holder.itemView;
//helpView.setText(!botInfo.isEmpty() ? botInfo.get(currentUser.id).description : null);
} else if (position == loadingDownRow || position == loadingUpRow) {
if (position == loadingDownRow || position == loadingUpRow) {
ChatLoadingCell loadingCell = (ChatLoadingCell) holder.itemView;
loadingCell.setProgressVisible(loadsCount > 1);
} else if (position >= messagesStartRow && position < messagesEndRow) {
@@ -6037,8 +5926,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (position >= messagesStartRow && position < messagesEndRow) {
return messages.get(messages.size() - (position - messagesStartRow) - 1).contentType;
// may be ROWTYPE_MESSAGE_CELL, ROWTYPE_ACTION_CELL, ROWTYPE_UNREAD_CELL,
} else if (position == botInfoRow) {
return ROWTYPE_BOTINFO_CELL;
}
return ROWTYPE_LOADING_CELL;
}
@@ -31,14 +31,6 @@ public class IdenticonDrawable extends Drawable {
return (data[bitOffset / 8] >> (bitOffset % 8)) & 0x3;
}
public void setEncryptedChat(TLRPC.EncryptedChat encryptedChat) {
data = encryptedChat.key_hash;
if (data == null) {
encryptedChat.key_hash = data = AndroidUtilities.calcAuthKeyHash(encryptedChat.auth_key);
}
invalidateSelf();
}
@Override
public void draw(Canvas canvas) {
if (data == null) {
@@ -926,13 +926,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
}
}
} else {
TLRPC.EncryptedChat chat = MessagesController.getInstance().getEncryptedChat(high_id);
TLRPC.User user = MessagesController.getInstance().getUser(chat.user_id);
if (user == null) {
return;
}
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)));
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@@ -995,9 +995,6 @@ public class PopupNotificationActivity extends Activity implements NotificationC
currentChat = MessagesController.getInstance().getChat(-lower_id);
currentUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id);
}
} else {
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int)(dialog_id >> 32));
currentUser = MessagesController.getInstance().getUser(encryptedChat.user_id);
}
if (currentChat != null && currentUser != null) {