2013-10-25 17:19:00 +02:00
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
* This is the source code of Telegram for Android v. 5.x.x.
|
2013-10-25 17:19:00 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
2019-01-23 18:03:33 +01:00
|
|
|
* Copyright Nikolai Kudashov, 2013-2018.
|
2013-10-25 17:19:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.Manifest;
|
2017-12-08 18:35:59 +01:00
|
|
|
import android.animation.Animator;
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
import android.animation.AnimatorSet;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
import android.animation.StateListAnimator;
|
2015-05-21 23:27:27 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.annotation.TargetApi;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Dialog;
|
2015-04-09 20:00:14 +02:00
|
|
|
import android.content.Context;
|
2019-01-23 18:03:33 +01:00
|
|
|
import android.content.Intent;
|
2018-07-30 04:07:02 +02:00
|
|
|
import android.content.SharedPreferences;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.content.res.Configuration;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.graphics.Outline;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
|
|
|
import android.graphics.drawable.Drawable;
|
2019-01-23 18:03:33 +01:00
|
|
|
import android.net.Uri;
|
2014-10-31 20:02:29 +01:00
|
|
|
import android.os.Build;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.os.Bundle;
|
2017-12-08 18:35:59 +01:00
|
|
|
import android.text.TextUtils;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.Gravity;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.View;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.view.ViewOutlineProvider;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.ViewTreeObserver;
|
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
2017-12-08 18:35:59 +01:00
|
|
|
import android.view.animation.DecelerateInterpolator;
|
2014-06-04 01:31:48 +02:00
|
|
|
import android.widget.EditText;
|
2018-07-30 04:07:02 +02:00
|
|
|
import android.widget.FrameLayout;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.widget.ImageView;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2016-03-06 02:49:31 +01:00
|
|
|
import org.telegram.messenger.BuildVars;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.ChatObject;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.DataQuery;
|
2016-06-24 12:27:15 +02:00
|
|
|
import org.telegram.messenger.DialogObject;
|
2015-10-29 18:10:07 +01:00
|
|
|
import org.telegram.messenger.ImageLoader;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.MessageObject;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.SharedConfig;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.UserObject;
|
2019-01-23 18:03:33 +01:00
|
|
|
import org.telegram.messenger.XiaomiUtilities;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.support.widget.LinearLayoutManager;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.support.widget.LinearSmoothScrollerMiddle;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.support.widget.RecyclerView;
|
2014-11-21 11:59:05 +01:00
|
|
|
import org.telegram.messenger.FileLog;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.tgnet.ConnectionsManager;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.tgnet.TLObject;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.tgnet.TLRPC;
|
|
|
|
import org.telegram.messenger.ContactsController;
|
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2013-10-25 17:19:00 +02:00
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.UserConfig;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2015-05-21 23:27:27 +02:00
|
|
|
import org.telegram.ui.ActionBar.BottomSheet;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.ThemeDescription;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.Adapters.DialogsAdapter;
|
|
|
|
import org.telegram.ui.Adapters.DialogsSearchAdapter;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Cells.AccountSelectCell;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.Cells.DialogsEmptyCell;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Cells.DividerCell;
|
|
|
|
import org.telegram.ui.Cells.DrawerActionCell;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Cells.DrawerAddCell;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Cells.DrawerProfileCell;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Cells.DrawerUserCell;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Cells.GraySectionCell;
|
|
|
|
import org.telegram.ui.Cells.HashtagSearchCell;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.ui.Cells.HintDialogCell;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Cells.LoadingCell;
|
2015-08-13 11:23:31 +02:00
|
|
|
import org.telegram.ui.Cells.ProfileSearchCell;
|
2014-11-10 12:05:22 +01:00
|
|
|
import org.telegram.ui.Cells.UserCell;
|
2014-02-04 19:36:55 +01:00
|
|
|
import org.telegram.ui.Cells.DialogCell;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
import org.telegram.ui.ActionBar.MenuDrawable;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Components.AlertsCreator;
|
|
|
|
import org.telegram.ui.Components.AnimatedArrowDrawable;
|
|
|
|
import org.telegram.ui.Components.AvatarDrawable;
|
|
|
|
import org.telegram.ui.Components.BackupImageView;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.Components.ChatActivityEnterView;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.CombinedDrawable;
|
|
|
|
import org.telegram.ui.Components.FragmentContextView;
|
2015-05-21 23:27:27 +02:00
|
|
|
import org.telegram.ui.Components.EmptyTextProgressView;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.Components.JoinGroupAlert;
|
2015-05-21 23:27:27 +02:00
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Components.ProxyDrawable;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.RadialProgressView;
|
2015-05-21 23:27:27 +02:00
|
|
|
import org.telegram.ui.Components.RecyclerListView;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
|
|
|
import org.telegram.ui.Components.StickersAlert;
|
2019-01-23 18:03:33 +01:00
|
|
|
import org.telegram.ui.Components.UndoView;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
2015-05-21 23:27:27 +02:00
|
|
|
|
|
|
|
private RecyclerListView listView;
|
|
|
|
private LinearLayoutManager layoutManager;
|
2014-11-13 21:10:14 +01:00
|
|
|
private DialogsAdapter dialogsAdapter;
|
|
|
|
private DialogsSearchAdapter dialogsSearchAdapter;
|
2015-05-21 23:27:27 +02:00
|
|
|
private EmptyTextProgressView searchEmptyView;
|
2017-03-31 01:58:05 +02:00
|
|
|
private RadialProgressView progressView;
|
2015-02-26 02:32:51 +01:00
|
|
|
private ActionBarMenuItem passcodeItem;
|
2018-07-30 04:07:02 +02:00
|
|
|
private ActionBarMenuItem proxyItem;
|
|
|
|
private ProxyDrawable proxyDrawable;
|
2014-11-06 22:34:47 +01:00
|
|
|
private ImageView floatingButton;
|
2019-01-23 18:03:33 +01:00
|
|
|
private FrameLayout floatingButtonContainer;
|
|
|
|
private UndoView undoView;
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
private float additionalFloatingTranslation;
|
|
|
|
|
|
|
|
//private ImageView unreadFloatingButton;
|
|
|
|
//private FrameLayout unreadFloatingButtonContainer;
|
|
|
|
//private TextView unreadFloatingButtonCounter;
|
|
|
|
//private int currentUnreadCount;
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
private AnimatedArrowDrawable arrowDrawable;
|
2017-03-31 01:58:05 +02:00
|
|
|
private RecyclerView sideMenu;
|
2017-12-08 18:35:59 +01:00
|
|
|
private ChatActivityEnterView commentView;
|
2018-07-30 04:07:02 +02:00
|
|
|
private ActionBarMenuItem switchItem;
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private AlertDialog permissionDialog;
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean askAboutContacts = true;
|
|
|
|
|
|
|
|
private boolean proxyItemVisisble;
|
2019-01-23 18:03:33 +01:00
|
|
|
private boolean closeSearchFieldOnHide;
|
|
|
|
private long searchDialogId;
|
|
|
|
private TLObject searchObject;
|
2015-10-29 18:10:07 +01:00
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
private int prevPosition;
|
|
|
|
private int prevTop;
|
|
|
|
private boolean scrollUpdated;
|
|
|
|
private boolean floatingHidden;
|
|
|
|
private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator();
|
2014-10-31 20:02:29 +01:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private boolean checkPermission = true;
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private int currentConnectionState;
|
|
|
|
|
2014-06-04 01:31:48 +02:00
|
|
|
private String selectAlertString;
|
2014-10-04 17:56:09 +02:00
|
|
|
private String selectAlertStringGroup;
|
2015-06-29 19:12:11 +02:00
|
|
|
private String addToGroupAlertString;
|
|
|
|
private int dialogsType;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public static boolean dialogsLoaded[] = new boolean[UserConfig.MAX_ACCOUNT_COUNT];
|
2015-05-21 23:27:27 +02:00
|
|
|
private boolean searching;
|
|
|
|
private boolean searchWas;
|
|
|
|
private boolean onlySelect;
|
2015-03-19 00:09:45 +01:00
|
|
|
private String searchString;
|
2015-05-21 23:27:27 +02:00
|
|
|
private long openedDialogId;
|
2016-10-11 13:57:01 +02:00
|
|
|
private boolean cantSendToChannels;
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean allowSwitchAccount;
|
2019-03-03 21:40:48 +01:00
|
|
|
private boolean checkCanWrite;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
private DialogsActivityDelegate delegate;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
public interface DialogsActivityDelegate {
|
2017-12-08 18:35:59 +01:00
|
|
|
void didSelectDialogs(DialogsActivity fragment, ArrayList<Long> dids, CharSequence message, boolean param);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
public DialogsActivity(Bundle args) {
|
2014-06-04 01:31:48 +02:00
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
|
|
|
super.onFragmentCreate();
|
2015-02-01 19:51:02 +01:00
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
if (getArguments() != null) {
|
2014-06-04 01:31:48 +02:00
|
|
|
onlySelect = arguments.getBoolean("onlySelect", false);
|
2016-10-11 13:57:01 +02:00
|
|
|
cantSendToChannels = arguments.getBoolean("cantSendToChannels", false);
|
2015-06-29 19:12:11 +02:00
|
|
|
dialogsType = arguments.getInt("dialogsType", 0);
|
2014-06-04 01:31:48 +02:00
|
|
|
selectAlertString = arguments.getString("selectAlertString");
|
2014-10-04 17:56:09 +02:00
|
|
|
selectAlertStringGroup = arguments.getString("selectAlertStringGroup");
|
2015-06-29 19:12:11 +02:00
|
|
|
addToGroupAlertString = arguments.getString("addToGroupAlertString");
|
2018-07-30 04:07:02 +02:00
|
|
|
allowSwitchAccount = arguments.getBoolean("allowSwitchAccount");
|
2019-03-03 21:40:48 +01:00
|
|
|
checkCanWrite = arguments.getBoolean("checkCanWrite", true);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dialogsType == 0) {
|
|
|
|
askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true);
|
|
|
|
SharedConfig.loadProxyList();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
|
|
|
|
if (searchString == null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();
|
|
|
|
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogsNeedReload);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!onlySelect) {
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeSearchByActiveAction);
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged);
|
|
|
|
}
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.encryptedChatUpdated);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.contactsDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.openedChatChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messageReceivedByAck);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messageSendError);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.needReloadRecentDialogsSearch);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.replyMessagesDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.reloadHints);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didUpdateConnectionState);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.dialogsUnreadCounterChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.needDeleteDialog);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetPasscode);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!dialogsLoaded[currentAccount]) {
|
|
|
|
MessagesController.getInstance(currentAccount).loadGlobalNotificationsSettings();
|
|
|
|
MessagesController.getInstance(currentAccount).loadDialogs(0, 100, true);
|
|
|
|
MessagesController.getInstance(currentAccount).loadHintDialogs();
|
|
|
|
ContactsController.getInstance(currentAccount).checkInviteText();
|
|
|
|
MessagesController.getInstance(currentAccount).loadPinnedDialogs(0, null);
|
|
|
|
DataQuery.getInstance(currentAccount).loadRecents(DataQuery.TYPE_FAVE, false, true, false);
|
|
|
|
DataQuery.getInstance(currentAccount).checkFeaturedStickers();
|
|
|
|
dialogsLoaded[currentAccount] = true;
|
2013-12-20 20:25:49 +01:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2015-03-19 00:09:45 +01:00
|
|
|
if (searchString == null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.dialogsNeedReload);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!onlySelect) {
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeSearchByActiveAction);
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.proxySettingsChanged);
|
|
|
|
}
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.contactsDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.openedChatChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messageReceivedByAck);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messageSendError);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.needReloadRecentDialogsSearch);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.replyMessagesDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.reloadHints);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.didUpdateConnectionState);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.dialogsUnreadCounterChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.needDeleteDialog);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetPasscode);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onDestroy();
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
if (undoView != null) {
|
|
|
|
undoView.hide(true, false);
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
delegate = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-07-22 20:56:37 +02:00
|
|
|
public View createView(final Context context) {
|
2015-04-09 20:00:14 +02:00
|
|
|
searching = false;
|
|
|
|
searchWas = false;
|
|
|
|
|
2018-08-27 10:33:11 +02:00
|
|
|
AndroidUtilities.runOnUIThread(() -> Theme.createChatResources(context, false));
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
ActionBarMenu menu = actionBar.createMenu();
|
|
|
|
if (!onlySelect && searchString == null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyDrawable = new ProxyDrawable(context);
|
|
|
|
proxyItem = menu.addItem(2, proxyDrawable);
|
2015-05-21 23:27:27 +02:00
|
|
|
passcodeItem = menu.addItem(1, R.drawable.lock_close);
|
2015-04-09 20:00:14 +02:00
|
|
|
updatePasscodeButton();
|
2018-07-30 04:07:02 +02:00
|
|
|
updateProxyButton(false);
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
final ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() {
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
|
|
|
public void onSearchExpand() {
|
|
|
|
searching = true;
|
2018-07-30 04:07:02 +02:00
|
|
|
if (switchItem != null) {
|
|
|
|
switchItem.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
if (proxyItem != null && proxyItemVisisble) {
|
|
|
|
proxyItem.setVisibility(View.GONE);
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
if (listView != null) {
|
2015-03-19 00:09:45 +01:00
|
|
|
if (searchString != null) {
|
2015-05-21 23:27:27 +02:00
|
|
|
listView.setEmptyView(searchEmptyView);
|
2015-06-29 19:12:11 +02:00
|
|
|
progressView.setVisibility(View.GONE);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setVisibility(View.GONE);
|
|
|
|
//unreadFloatingButtonContainer.setVisibility(View.GONE);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
updatePasscodeButton();
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
2015-06-29 19:12:11 +02:00
|
|
|
public boolean canCollapseSearch() {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (switchItem != null) {
|
|
|
|
switchItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (proxyItem != null && proxyItemVisisble) {
|
|
|
|
proxyItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
if (searchString != null) {
|
|
|
|
finishFragment();
|
|
|
|
return false;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSearchCollapse() {
|
2015-04-09 20:00:14 +02:00
|
|
|
searching = false;
|
|
|
|
searchWas = false;
|
2015-05-21 23:27:27 +02:00
|
|
|
if (listView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
listView.setEmptyView(progressView);
|
2017-12-08 18:35:59 +01:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setVisibility(View.VISIBLE);
|
|
|
|
/*if (currentUnreadCount != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
unreadFloatingButtonContainer.setVisibility(View.VISIBLE);
|
|
|
|
unreadFloatingButtonContainer.setTranslationY(AndroidUtilities.dp(74));
|
2019-01-23 18:03:33 +01:00
|
|
|
}*/
|
2015-04-09 20:00:14 +02:00
|
|
|
floatingHidden = true;
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setTranslationY(AndroidUtilities.dp(100));
|
2015-04-09 20:00:14 +02:00
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
if (listView.getAdapter() != dialogsAdapter) {
|
|
|
|
listView.setAdapter(dialogsAdapter);
|
2015-04-09 20:00:14 +02:00
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
if (dialogsSearchAdapter != null) {
|
2015-08-13 11:23:31 +02:00
|
|
|
dialogsSearchAdapter.searchDialogs(null);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
updatePasscodeButton();
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
|
|
|
public void onTextChanged(EditText editText) {
|
|
|
|
String text = editText.getText().toString();
|
2015-08-13 11:23:31 +02:00
|
|
|
if (text.length() != 0 || dialogsSearchAdapter != null && dialogsSearchAdapter.hasRecentRearch()) {
|
2015-04-09 20:00:14 +02:00
|
|
|
searchWas = true;
|
2015-11-26 22:04:02 +01:00
|
|
|
if (dialogsSearchAdapter != null && listView.getAdapter() != dialogsSearchAdapter) {
|
2015-05-21 23:27:27 +02:00
|
|
|
listView.setAdapter(dialogsSearchAdapter);
|
2015-04-09 20:00:14 +02:00
|
|
|
dialogsSearchAdapter.notifyDataSetChanged();
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
if (searchEmptyView != null && listView.getEmptyView() != searchEmptyView) {
|
2015-06-29 19:12:11 +02:00
|
|
|
progressView.setVisibility(View.GONE);
|
2015-05-21 23:27:27 +02:00
|
|
|
searchEmptyView.showTextView();
|
|
|
|
listView.setEmptyView(searchEmptyView);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
if (dialogsSearchAdapter != null) {
|
2015-08-13 11:23:31 +02:00
|
|
|
dialogsSearchAdapter.searchDialogs(text);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
item.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
|
2015-04-09 20:00:14 +02:00
|
|
|
if (onlySelect) {
|
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
2017-12-08 18:35:59 +01:00
|
|
|
if (dialogsType == 3 && selectAlertString == null) {
|
|
|
|
actionBar.setTitle(LocaleController.getString("ForwardTo", R.string.ForwardTo));
|
|
|
|
} else {
|
|
|
|
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
} else {
|
2015-03-19 00:09:45 +01:00
|
|
|
if (searchString != null) {
|
2015-04-09 20:00:14 +02:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
|
|
|
} else {
|
|
|
|
actionBar.setBackButtonDrawable(new MenuDrawable());
|
2014-11-19 11:32:27 +01:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
if (BuildVars.DEBUG_VERSION) {
|
2018-07-30 04:07:02 +02:00
|
|
|
actionBar.setTitle("Telegram Beta"/*LocaleController.getString("AppNameBeta", R.string.AppNameBeta)*/);
|
2016-03-06 02:49:31 +01:00
|
|
|
} else {
|
|
|
|
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
actionBar.setSupportsHolidayImage(true);
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
actionBar.setTitleActionRunnable(() -> {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
listView.smoothScrollToPosition(0);
|
2018-07-30 04:07:02 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
if (allowSwitchAccount && UserConfig.getActivatedAccountsCount() > 1) {
|
|
|
|
switchItem = menu.addItemWithWidth(1, 0, AndroidUtilities.dp(56));
|
|
|
|
AvatarDrawable avatarDrawable = new AvatarDrawable();
|
|
|
|
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
|
|
|
|
|
|
|
|
BackupImageView imageView = new BackupImageView(context);
|
|
|
|
imageView.setRoundRadius(AndroidUtilities.dp(18));
|
|
|
|
switchItem.addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.CENTER));
|
|
|
|
|
|
|
|
TLRPC.User user = UserConfig.getInstance(currentAccount).getCurrentUser();
|
|
|
|
avatarDrawable.setInfo(user);
|
|
|
|
TLRPC.FileLocation avatar;
|
|
|
|
if (user.photo != null && user.photo.photo_small != null && user.photo.photo_small.volume_id != 0 && user.photo.photo_small.local_id != 0) {
|
|
|
|
avatar = user.photo.photo_small;
|
|
|
|
} else {
|
|
|
|
avatar = null;
|
|
|
|
}
|
|
|
|
imageView.getImageReceiver().setCurrentAccount(currentAccount);
|
2019-01-23 18:03:33 +01:00
|
|
|
imageView.setImage(avatar, "50_50", avatarDrawable, user);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
TLRPC.User u = UserConfig.getInstance(a).getCurrentUser();
|
|
|
|
if (u != null) {
|
|
|
|
AccountSelectCell cell = new AccountSelectCell(context);
|
|
|
|
cell.setAccount(a, true);
|
|
|
|
switchItem.addSubItem(10 + a, cell, AndroidUtilities.dp(230), AndroidUtilities.dp(48));
|
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
|
|
|
actionBar.setAllowOverlayTitle(true);
|
|
|
|
|
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
|
|
|
if (onlySelect) {
|
|
|
|
finishFragment();
|
|
|
|
} else if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().openDrawer(false);
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
} else if (id == 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedConfig.appLocked = !SharedConfig.appLocked;
|
|
|
|
SharedConfig.saveConfig();
|
2015-04-09 20:00:14 +02:00
|
|
|
updatePasscodeButton();
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (id == 2) {
|
|
|
|
presentFragment(new ProxyListActivity());
|
|
|
|
} else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DialogsActivityDelegate oldDelegate = delegate;
|
|
|
|
LaunchActivity launchActivity = (LaunchActivity) getParentActivity();
|
|
|
|
launchActivity.switchToAccount(id - 10, true);
|
|
|
|
|
|
|
|
DialogsActivity dialogsActivity = new DialogsActivity(arguments);
|
|
|
|
dialogsActivity.setDelegate(oldDelegate);
|
|
|
|
launchActivity.presentFragment(dialogsActivity, false, true);
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
if (sideMenu != null) {
|
|
|
|
sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
sideMenu.getAdapter().notifyDataSetChanged();
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(context) {
|
|
|
|
|
|
|
|
int inputFieldHeight = 0;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
|
|
|
|
setMeasuredDimension(widthSize, heightSize);
|
|
|
|
heightSize -= getPaddingTop();
|
|
|
|
|
|
|
|
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
|
|
|
|
|
|
|
int keyboardSize = getKeyboardHeight();
|
|
|
|
int childCount = getChildCount();
|
|
|
|
|
|
|
|
if (commentView != null) {
|
|
|
|
measureChildWithMargins(commentView, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
|
|
|
Object tag = commentView.getTag();
|
|
|
|
if (tag != null && tag.equals(2)) {
|
|
|
|
if (keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow) {
|
|
|
|
heightSize -= commentView.getEmojiPadding();
|
|
|
|
}
|
|
|
|
inputFieldHeight = commentView.getMeasuredHeight();
|
|
|
|
} else {
|
|
|
|
inputFieldHeight = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < childCount; i++) {
|
|
|
|
View child = getChildAt(i);
|
|
|
|
if (child == null || child.getVisibility() == GONE || child == commentView || child == actionBar) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (child == listView || child == progressView || child == searchEmptyView) {
|
|
|
|
int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY);
|
|
|
|
int contentHeightSpec = MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize - inputFieldHeight + AndroidUtilities.dp(2)), MeasureSpec.EXACTLY);
|
|
|
|
child.measure(contentWidthSpec, contentHeightSpec);
|
|
|
|
} else if (commentView != null && commentView.isPopupView(child)) {
|
|
|
|
if (AndroidUtilities.isInMultiwindow) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(320), heightSize - inputFieldHeight - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
|
|
|
|
} else {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - inputFieldHeight - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
final int count = getChildCount();
|
|
|
|
|
|
|
|
int paddingBottom;
|
|
|
|
Object tag = commentView != null ? commentView.getTag() : null;
|
|
|
|
if (tag != null && tag.equals(2)) {
|
|
|
|
paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? commentView.getEmojiPadding() : 0;
|
|
|
|
} else {
|
|
|
|
paddingBottom = 0;
|
|
|
|
}
|
|
|
|
setBottomClip(paddingBottom);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
final View child = getChildAt(i);
|
|
|
|
if (child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
|
|
|
|
|
|
|
final int width = child.getMeasuredWidth();
|
|
|
|
final int height = child.getMeasuredHeight();
|
|
|
|
|
|
|
|
int childLeft;
|
|
|
|
int childTop;
|
|
|
|
|
|
|
|
int gravity = lp.gravity;
|
|
|
|
if (gravity == -1) {
|
|
|
|
gravity = Gravity.TOP | Gravity.LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
|
|
|
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
|
|
|
|
|
|
|
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
|
|
|
case Gravity.CENTER_HORIZONTAL:
|
|
|
|
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.RIGHT:
|
|
|
|
childLeft = r - width - lp.rightMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.LEFT:
|
|
|
|
default:
|
|
|
|
childLeft = lp.leftMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (verticalGravity) {
|
|
|
|
case Gravity.TOP:
|
|
|
|
childTop = lp.topMargin + getPaddingTop();
|
|
|
|
break;
|
|
|
|
case Gravity.CENTER_VERTICAL:
|
|
|
|
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.BOTTOM:
|
|
|
|
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
childTop = lp.topMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (commentView != null && commentView.isPopupView(child)) {
|
|
|
|
if (AndroidUtilities.isInMultiwindow) {
|
|
|
|
childTop = commentView.getTop() - child.getMeasuredHeight() + AndroidUtilities.dp(1);
|
|
|
|
} else {
|
|
|
|
childTop = commentView.getBottom();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyHeightChanged();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
fragmentView = contentView;
|
2015-05-21 23:27:27 +02:00
|
|
|
|
|
|
|
listView = new RecyclerListView(context);
|
|
|
|
listView.setVerticalScrollBarEnabled(true);
|
|
|
|
listView.setItemAnimator(null);
|
|
|
|
listView.setInstantClick(true);
|
|
|
|
listView.setLayoutAnimation(null);
|
2016-06-24 12:27:15 +02:00
|
|
|
listView.setTag(4);
|
2015-05-21 23:27:27 +02:00
|
|
|
layoutManager = new LinearLayoutManager(context) {
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
2015-05-21 23:27:27 +02:00
|
|
|
public boolean supportsPredictiveItemAnimations() {
|
|
|
|
return false;
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
|
|
|
LinearSmoothScrollerMiddle linearSmoothScroller = new LinearSmoothScrollerMiddle(recyclerView.getContext());
|
|
|
|
linearSmoothScroller.setTargetPosition(position);
|
|
|
|
startSmoothScroll(linearSmoothScroller);
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
};
|
|
|
|
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
|
|
|
listView.setLayoutManager(layoutManager);
|
2017-03-31 01:58:05 +02:00
|
|
|
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
|
2017-12-08 18:35:59 +01:00
|
|
|
contentView.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2018-08-27 10:33:11 +02:00
|
|
|
listView.setOnItemClickListener((view, position) -> {
|
|
|
|
if (listView == null || listView.getAdapter() == null || getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2018-08-27 10:33:11 +02:00
|
|
|
long dialog_id = 0;
|
|
|
|
int message_id = 0;
|
|
|
|
boolean isGlobalSearch = false;
|
|
|
|
RecyclerView.Adapter adapter = listView.getAdapter();
|
|
|
|
if (adapter == dialogsAdapter) {
|
|
|
|
TLObject object = dialogsAdapter.getItem(position);
|
|
|
|
if (object instanceof TLRPC.User) {
|
|
|
|
dialog_id = ((TLRPC.User) object).id;
|
|
|
|
} else if (object instanceof TLRPC.TL_dialog) {
|
|
|
|
dialog_id = ((TLRPC.TL_dialog) object).id;
|
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlChat) {
|
|
|
|
dialog_id = -((TLRPC.TL_recentMeUrlChat) object).chat_id;
|
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlUser) {
|
|
|
|
dialog_id = ((TLRPC.TL_recentMeUrlUser) object).user_id;
|
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlChatInvite) {
|
|
|
|
TLRPC.TL_recentMeUrlChatInvite chatInvite = (TLRPC.TL_recentMeUrlChatInvite) object;
|
|
|
|
TLRPC.ChatInvite invite = chatInvite.chat_invite;
|
|
|
|
if (invite.chat == null && (!invite.channel || invite.megagroup) || invite.chat != null && (!ChatObject.isChannel(invite.chat) || invite.chat.megagroup)) {
|
|
|
|
String hash = chatInvite.url;
|
|
|
|
int index = hash.indexOf('/');
|
|
|
|
if (index > 0) {
|
|
|
|
hash = hash.substring(index + 1);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
showDialog(new JoinGroupAlert(getParentActivity(), invite, hash, DialogsActivity.this));
|
2017-12-08 18:35:59 +01:00
|
|
|
return;
|
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (invite.chat != null) {
|
|
|
|
dialog_id = -invite.chat.id;
|
2015-04-09 20:00:14 +02:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
return;
|
2015-12-09 19:27:52 +01:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlStickerSet) {
|
|
|
|
TLRPC.StickerSet stickerSet = ((TLRPC.TL_recentMeUrlStickerSet) object).set.set;
|
|
|
|
TLRPC.TL_inputStickerSetID set = new TLRPC.TL_inputStickerSetID();
|
|
|
|
set.id = stickerSet.id;
|
|
|
|
set.access_hash = stickerSet.access_hash;
|
|
|
|
showDialog(new StickersAlert(getParentActivity(), DialogsActivity.this, set, null, null));
|
|
|
|
return;
|
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlUnknown) {
|
|
|
|
return;
|
|
|
|
} else {
|
2015-04-09 20:00:14 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else if (adapter == dialogsSearchAdapter) {
|
|
|
|
Object obj = dialogsSearchAdapter.getItem(position);
|
|
|
|
isGlobalSearch = dialogsSearchAdapter.isGlobalSearch(position);
|
|
|
|
if (obj instanceof TLRPC.User) {
|
|
|
|
dialog_id = ((TLRPC.User) obj).id;
|
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
searchDialogId = dialog_id;
|
|
|
|
searchObject = (TLRPC.User) obj;
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
} else if (obj instanceof TLRPC.Chat) {
|
|
|
|
if (((TLRPC.Chat) obj).id > 0) {
|
|
|
|
dialog_id = -((TLRPC.Chat) obj).id;
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
dialog_id = AndroidUtilities.makeBroadcastId(((TLRPC.Chat) obj).id);
|
|
|
|
}
|
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
searchDialogId = dialog_id;
|
|
|
|
searchObject = (TLRPC.Chat) obj;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else if (obj instanceof TLRPC.EncryptedChat) {
|
|
|
|
dialog_id = ((long) ((TLRPC.EncryptedChat) obj).id) << 32;
|
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
searchDialogId = dialog_id;
|
|
|
|
searchObject = (TLRPC.EncryptedChat) obj;
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
} else if (obj instanceof MessageObject) {
|
|
|
|
MessageObject messageObject = (MessageObject) obj;
|
|
|
|
dialog_id = messageObject.getDialogId();
|
|
|
|
message_id = messageObject.getId();
|
|
|
|
dialogsSearchAdapter.addHashtagsFromMessage(dialogsSearchAdapter.getLastSearchString());
|
|
|
|
} else if (obj instanceof String) {
|
2019-01-23 18:03:33 +01:00
|
|
|
actionBar.openSearchField((String) obj, false);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onlySelect) {
|
|
|
|
if (dialogsAdapter.hasSelectedDialogs()) {
|
|
|
|
dialogsAdapter.addOrRemoveSelectedDialog(dialog_id, view);
|
|
|
|
updateSelectedCount();
|
2015-04-09 20:00:14 +02:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
didSelectResult(dialog_id, true, false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
int lower_part = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
|
|
|
} else {
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
if (message_id != 0) {
|
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_part);
|
|
|
|
if (chat != null && chat.migrated_to != null) {
|
|
|
|
args.putInt("migrated_to", lower_part);
|
|
|
|
lower_part = -chat.migrated_to.channel_id;
|
2015-11-26 22:04:02 +01:00
|
|
|
}
|
2014-11-24 15:14:40 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
args.putInt("chat_id", -lower_part);
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
args.putInt("enc_id", high_id);
|
|
|
|
}
|
|
|
|
if (message_id != 0) {
|
|
|
|
args.putInt("message_id", message_id);
|
|
|
|
} else if (!isGlobalSearch) {
|
2019-01-23 18:03:33 +01:00
|
|
|
closeSearch();
|
|
|
|
} else {
|
|
|
|
if (searchObject != null) {
|
|
|
|
dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
|
|
|
searchObject = null;
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (openedDialogId == dialog_id && adapter != dialogsSearchAdapter) {
|
|
|
|
return;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId = dialog_id);
|
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (searchString != null) {
|
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
|
|
|
|
presentFragment(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
presentFragment(new ChatActivity(args));
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
|
|
|
});
|
2018-07-30 04:07:02 +02:00
|
|
|
listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
2018-07-30 04:07:02 +02:00
|
|
|
public boolean onItemClick(View view, int position, float x, float y) {
|
2017-12-08 18:35:59 +01:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!AndroidUtilities.isTablet() && !onlySelect && view instanceof DialogCell) {
|
|
|
|
DialogCell cell = (DialogCell) view;
|
|
|
|
if (cell.isPointInsideAvatar(x, y)) {
|
|
|
|
long dialog_id = cell.getDialogId();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
int lower_part = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
|
|
|
int message_id = cell.getMessageId();
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (high_id == 1) {
|
|
|
|
args.putInt("chat_id", lower_part);
|
|
|
|
} else {
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
if (message_id != 0) {
|
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_part);
|
|
|
|
if (chat != null && chat.migrated_to != null) {
|
|
|
|
args.putInt("migrated_to", lower_part);
|
|
|
|
lower_part = -chat.migrated_to.channel_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
args.putInt("chat_id", -lower_part);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (message_id != 0) {
|
|
|
|
args.putInt("message_id", message_id);
|
|
|
|
}
|
|
|
|
if (searchString != null) {
|
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
|
|
|
|
presentFragmentAsPreview(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
presentFragmentAsPreview(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
RecyclerView.Adapter adapter = listView.getAdapter();
|
|
|
|
if (adapter == dialogsSearchAdapter) {
|
|
|
|
Object item = dialogsSearchAdapter.getItem(position);
|
|
|
|
if (item instanceof String || dialogsSearchAdapter.isRecentSearchDisplayed()) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.getString("ClearSearch", R.string.ClearSearch));
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> {
|
|
|
|
if (dialogsSearchAdapter.isRecentSearchDisplayed()) {
|
|
|
|
dialogsSearchAdapter.clearRecentSearch();
|
|
|
|
} else {
|
|
|
|
dialogsSearchAdapter.clearRecentHashtags();
|
2015-03-26 18:34:47 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
return true;
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
return false;
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
final TLRPC.TL_dialog dialog;
|
2019-03-03 21:40:48 +01:00
|
|
|
ArrayList<TLRPC.TL_dialog> dialogs = getDialogsArray(dialogsType, currentAccount);
|
2015-06-29 19:12:11 +02:00
|
|
|
if (position < 0 || position >= dialogs.size()) {
|
2015-10-29 18:10:07 +01:00
|
|
|
return false;
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
dialog = dialogs.get(position);
|
2017-12-08 18:35:59 +01:00
|
|
|
if (onlySelect) {
|
|
|
|
if (dialogsType != 3 || selectAlertString != null) {
|
|
|
|
return false;
|
2015-11-26 22:04:02 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
dialogsAdapter.addOrRemoveSelectedDialog(dialog.id, view);
|
|
|
|
updateSelectedCount();
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
final long selectedDialog = dialog.id;
|
2017-12-08 18:35:59 +01:00
|
|
|
final boolean pinned = dialog.pinned;
|
|
|
|
|
|
|
|
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
|
|
|
|
int lower_id = (int) selectedDialog;
|
|
|
|
int high_id = (int) (selectedDialog >> 32);
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
final boolean hasUnread = dialog.unread_count != 0 || dialog.unread_mark;
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
if (DialogObject.isChannel(dialog)) {
|
2018-07-30 04:07:02 +02:00
|
|
|
final TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id);
|
2017-12-08 18:35:59 +01:00
|
|
|
CharSequence items[];
|
|
|
|
int icons[] = new int[]{
|
|
|
|
dialog.pinned ? R.drawable.chats_unpin : R.drawable.chats_pin,
|
2018-07-30 04:07:02 +02:00
|
|
|
hasUnread ? R.drawable.menu_read : R.drawable.menu_unread,
|
2019-01-23 18:03:33 +01:00
|
|
|
R.drawable.chats_clear,
|
2017-12-08 18:35:59 +01:00
|
|
|
R.drawable.chats_leave
|
|
|
|
};
|
2018-07-30 04:07:02 +02:00
|
|
|
if (MessagesController.getInstance(currentAccount).isProxyDialog(dialog.id)) {
|
|
|
|
items = new CharSequence[]{
|
|
|
|
null,
|
|
|
|
hasUnread ? LocaleController.getString("MarkAsRead", R.string.MarkAsRead) : LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread),
|
2019-01-23 18:03:33 +01:00
|
|
|
LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache),
|
2018-07-30 04:07:02 +02:00
|
|
|
null};
|
|
|
|
} else if (chat != null && chat.megagroup) {
|
2017-12-08 18:35:59 +01:00
|
|
|
items = new CharSequence[]{
|
2019-01-23 18:03:33 +01:00
|
|
|
dialog.pinned ? LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop) : LocaleController.getString("PinToTop", R.string.PinToTop),
|
2018-07-30 04:07:02 +02:00
|
|
|
hasUnread ? LocaleController.getString("MarkAsRead", R.string.MarkAsRead) : LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread),
|
2019-01-23 18:03:33 +01:00
|
|
|
TextUtils.isEmpty(chat.username) ? LocaleController.getString("ClearHistory", R.string.ClearHistory) : LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache),
|
2017-12-08 18:35:59 +01:00
|
|
|
LocaleController.getString("LeaveMegaMenu", R.string.LeaveMegaMenu)};
|
|
|
|
} else {
|
|
|
|
items = new CharSequence[]{
|
2019-01-23 18:03:33 +01:00
|
|
|
dialog.pinned ? LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop) : LocaleController.getString("PinToTop", R.string.PinToTop),
|
2018-07-30 04:07:02 +02:00
|
|
|
hasUnread ? LocaleController.getString("MarkAsRead", R.string.MarkAsRead) : LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread),
|
2019-01-23 18:03:33 +01:00
|
|
|
LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache),
|
2017-12-08 18:35:59 +01:00
|
|
|
LocaleController.getString("LeaveChannelMenu", R.string.LeaveChannelMenu)};
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setItems(items, icons, (d, which) -> {
|
|
|
|
if (which == 0) {
|
2019-01-23 18:03:33 +01:00
|
|
|
if (!dialog.pinned && !MessagesController.getInstance(currentAccount).canPinDialog(false)) {
|
|
|
|
AlertsCreator.showSimpleAlert(DialogsActivity.this, LocaleController.formatString("PinToTopLimitReached", R.string.PinToTopLimitReached, LocaleController.formatPluralString("Chats", MessagesController.getInstance(currentAccount).maxPinnedDialogsCount)));
|
|
|
|
return;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (MessagesController.getInstance(currentAccount).pinDialog(selectedDialog, !pinned, null, 0) && !pinned) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
listView.smoothScrollToPosition(0);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (which == 1) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (hasUnread) {
|
|
|
|
MessagesController.getInstance(currentAccount).markMentionsAsRead(selectedDialog);
|
|
|
|
MessagesController.getInstance(currentAccount).markDialogAsRead(selectedDialog, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, true);
|
2015-11-26 22:04:02 +01:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
MessagesController.getInstance(currentAccount).markDialogAsUnread(selectedDialog, null, 0);
|
|
|
|
}
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
AlertsCreator.createClearOrDeleteDialogAlert(DialogsActivity.this, which == 2, chat, null, lower_id == 0, () -> {
|
|
|
|
if (which == 2 && (!chat.megagroup || !TextUtils.isEmpty(chat.username))) {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(selectedDialog, 2);
|
2015-12-09 19:27:52 +01:00
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
undoView.showWithAction(selectedDialog, which == 2, () -> {
|
|
|
|
if (which == 2) {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(selectedDialog, 1);
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteUserFromChat((int) -selectedDialog, UserConfig.getInstance(currentAccount).getCurrentUser(), null);
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats, selectedDialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
});
|
2015-12-09 19:27:52 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
BottomSheet sheet = builder.create();
|
|
|
|
showDialog(sheet);
|
|
|
|
sheet.setItemColor(3, Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogRedIcon));
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
|
|
|
final boolean isChat = lower_id < 0 && high_id != 1;
|
2019-01-23 18:03:33 +01:00
|
|
|
TLRPC.User user;
|
|
|
|
TLRPC.Chat chat = isChat ? MessagesController.getInstance(currentAccount).getChat(-lower_id) : null;
|
|
|
|
if (lower_id == 0) {
|
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentAccount).getEncryptedChat(high_id);
|
2019-02-08 03:30:32 +01:00
|
|
|
if (encryptedChat != null) {
|
|
|
|
user = MessagesController.getInstance(currentAccount).getUser(encryptedChat.user_id);
|
|
|
|
} else {
|
|
|
|
user = new TLRPC.TL_userEmpty();
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
user = !isChat && lower_id > 0 && high_id != 1 ? MessagesController.getInstance(currentAccount).getUser(lower_id) : null;
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2019-03-03 21:40:48 +01:00
|
|
|
final boolean isBot = user != null && user.bot && !MessagesController.isSupportUser(user);
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
builder.setItems(new CharSequence[]{
|
2019-01-23 18:03:33 +01:00
|
|
|
dialog.pinned ? LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop) : LocaleController.getString("PinToTop", R.string.PinToTop),
|
2018-07-30 04:07:02 +02:00
|
|
|
hasUnread ? LocaleController.getString("MarkAsRead", R.string.MarkAsRead) : LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread),
|
2019-01-23 18:03:33 +01:00
|
|
|
LocaleController.getString("ClearHistory", R.string.ClearHistory),
|
2017-12-08 18:35:59 +01:00
|
|
|
isChat ? LocaleController.getString("DeleteChat", R.string.DeleteChat) : isBot ? LocaleController.getString("DeleteAndStop", R.string.DeleteAndStop) : LocaleController.getString("Delete", R.string.Delete)
|
|
|
|
}, new int[]{
|
|
|
|
dialog.pinned ? R.drawable.chats_unpin : R.drawable.chats_pin,
|
2018-07-30 04:07:02 +02:00
|
|
|
hasUnread ? R.drawable.menu_read : R.drawable.menu_unread,
|
2019-01-23 18:03:33 +01:00
|
|
|
R.drawable.chats_clear,
|
2017-12-08 18:35:59 +01:00
|
|
|
isChat ? R.drawable.chats_leave : R.drawable.chats_delete
|
2018-08-27 10:33:11 +02:00
|
|
|
}, (d, which) -> {
|
|
|
|
if (which == 0) {
|
2019-01-23 18:03:33 +01:00
|
|
|
if (!dialog.pinned && !MessagesController.getInstance(currentAccount).canPinDialog(lower_id == 0)) {
|
|
|
|
AlertsCreator.showSimpleAlert(DialogsActivity.this, LocaleController.formatString("PinToTopLimitReached", R.string.PinToTopLimitReached, LocaleController.formatPluralString("Chats", MessagesController.getInstance(currentAccount).maxPinnedDialogsCount)));
|
|
|
|
return;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (MessagesController.getInstance(currentAccount).pinDialog(selectedDialog, !pinned, null, 0) && !pinned) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
listView.smoothScrollToPosition(0);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (which == 1) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (hasUnread) {
|
|
|
|
MessagesController.getInstance(currentAccount).markMentionsAsRead(selectedDialog);
|
|
|
|
MessagesController.getInstance(currentAccount).markDialogAsRead(selectedDialog, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, true);
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).markDialogAsUnread(selectedDialog, null, 0);
|
|
|
|
}
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
AlertsCreator.createClearOrDeleteDialogAlert(DialogsActivity.this, which == 2, chat, user, lower_id == 0, () -> undoView.showWithAction(selectedDialog, which == 2, () -> {
|
|
|
|
if (which != 2) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (isChat) {
|
|
|
|
TLRPC.Chat currentChat = MessagesController.getInstance(currentAccount).getChat((int) -selectedDialog);
|
|
|
|
if (currentChat != null && ChatObject.isNotInChat(currentChat)) {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(selectedDialog, 0);
|
2015-09-24 22:52:02 +02:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
MessagesController.getInstance(currentAccount).deleteUserFromChat((int) -selectedDialog, MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()), null);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(selectedDialog, 0);
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (isBot) {
|
|
|
|
MessagesController.getInstance(currentAccount).blockUser((int) selectedDialog);
|
|
|
|
}
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats, selectedDialog);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(selectedDialog, 1);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
}));
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
BottomSheet sheet = builder.create();
|
|
|
|
showDialog(sheet);
|
|
|
|
sheet.setItemColor(3, Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogRedIcon));
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
return true;
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLongClickRelease() {
|
|
|
|
finishPreviewFragment();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMove(float dx, float dy) {
|
|
|
|
movePreviewFragment(dy);
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
searchEmptyView = new EmptyTextProgressView(context);
|
2015-06-29 19:12:11 +02:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2015-05-21 23:27:27 +02:00
|
|
|
searchEmptyView.setShowAtCenter(true);
|
|
|
|
searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
|
2017-12-08 18:35:59 +01:00
|
|
|
contentView.addView(searchEmptyView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
progressView = new RadialProgressView(context);
|
2015-06-29 19:12:11 +02:00
|
|
|
progressView.setVisibility(View.GONE);
|
2017-12-08 18:35:59 +01:00
|
|
|
contentView.addView(progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer = new FrameLayout(context);
|
|
|
|
floatingButtonContainer.setVisibility(onlySelect ? View.GONE : View.VISIBLE);
|
|
|
|
contentView.addView(floatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 0));
|
|
|
|
floatingButtonContainer.setOnClickListener(v -> {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("destroyAfterSelect", true);
|
|
|
|
presentFragment(new ContactsActivity(args));
|
|
|
|
});
|
|
|
|
|
2015-05-21 23:27:27 +02:00
|
|
|
floatingButton = new ImageView(context);
|
|
|
|
floatingButton.setScaleType(ImageView.ScaleType.CENTER);
|
2017-03-31 01:58:05 +02:00
|
|
|
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
|
|
|
|
if (Build.VERSION.SDK_INT < 21) {
|
|
|
|
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
|
|
|
|
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
|
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
|
|
|
|
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
drawable = combinedDrawable;
|
|
|
|
}
|
|
|
|
floatingButton.setBackgroundDrawable(drawable);
|
|
|
|
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
|
2015-05-21 23:27:27 +02:00
|
|
|
floatingButton.setImageResource(R.drawable.floating_pencil);
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
StateListAnimator animator = new StateListAnimator();
|
2019-01-23 18:03:33 +01:00
|
|
|
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
|
|
|
|
animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
|
2015-05-21 23:27:27 +02:00
|
|
|
floatingButton.setStateListAnimator(animator);
|
|
|
|
floatingButton.setOutlineProvider(new ViewOutlineProvider() {
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@Override
|
|
|
|
public void getOutline(View view, Outline outline) {
|
|
|
|
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.addView(floatingButton, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60), (Build.VERSION.SDK_INT >= 21 ? 56 : 60), Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0));
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
/*unreadFloatingButtonContainer = new FrameLayout(context);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (onlySelect) {
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
unreadFloatingButtonContainer.setVisibility(currentUnreadCount != 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
|
unreadFloatingButtonContainer.setTag(currentUnreadCount != 0 ? 1 : null);
|
|
|
|
}
|
|
|
|
contentView.addView(unreadFloatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 14 + 60 + 7));
|
2018-08-27 10:33:11 +02:00
|
|
|
unreadFloatingButtonContainer.setOnClickListener(view -> {
|
|
|
|
if (listView.getAdapter() == dialogsAdapter) {
|
|
|
|
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (firstVisibleItem == 0) {
|
|
|
|
ArrayList<TLRPC.TL_dialog> array = getDialogsArray();
|
|
|
|
for (int a = array.size() - 1; a >= 0; a--) {
|
|
|
|
TLRPC.TL_dialog dialog = array.get(a);
|
|
|
|
if ((dialog.unread_count != 0 || dialog.unread_mark) && !MessagesController.getInstance(currentAccount).isDialogMuted(dialog.id)) {
|
|
|
|
listView.smoothScrollToPosition(a);
|
|
|
|
break;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int middle = listView.getMeasuredHeight() / 2;
|
|
|
|
boolean found = false;
|
|
|
|
for (int b = 0, count = listView.getChildCount(); b < count; b++) {
|
|
|
|
View child = listView.getChildAt(b);
|
|
|
|
if (child instanceof DialogCell) {
|
|
|
|
if (child.getTop() <= middle && child.getBottom() >= middle) {
|
|
|
|
RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
|
|
|
|
if (holder != null) {
|
|
|
|
ArrayList<TLRPC.TL_dialog> array = getDialogsArray();
|
|
|
|
for (int a = Math.min(holder.getAdapterPosition(), array.size()) - 1; a >= 0; a--) {
|
|
|
|
TLRPC.TL_dialog dialog = array.get(a);
|
|
|
|
if ((dialog.unread_count != 0 || dialog.unread_mark) && !MessagesController.getInstance(currentAccount).isDialogMuted(dialog.id)) {
|
|
|
|
found = true;
|
|
|
|
listView.smoothScrollToPosition(a);
|
|
|
|
break;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
break;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
listView.smoothScrollToPosition(0);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
unreadFloatingButton = new ImageView(context);
|
|
|
|
unreadFloatingButton.setScaleType(ImageView.ScaleType.CENTER);
|
|
|
|
|
|
|
|
drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionUnreadBackground), Theme.getColor(Theme.key_chats_actionUnreadPressedBackground));
|
|
|
|
if (Build.VERSION.SDK_INT < 21) {
|
|
|
|
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
|
|
|
|
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
|
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
|
|
|
|
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
drawable = combinedDrawable;
|
|
|
|
}
|
|
|
|
unreadFloatingButton.setBackgroundDrawable(drawable);
|
2019-01-23 18:03:33 +01:00
|
|
|
unreadFloatingButton.setImageDrawable(arrowDrawable = new AnimatedArrowDrawable(0xffffffff, false));
|
2018-07-30 04:07:02 +02:00
|
|
|
unreadFloatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionUnreadIcon), PorterDuff.Mode.MULTIPLY));
|
|
|
|
unreadFloatingButton.setPadding(0, AndroidUtilities.dp(4), 0, 0);
|
|
|
|
arrowDrawable.setAnimationProgress(1.0f);
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
StateListAnimator animator = new StateListAnimator();
|
2019-01-23 18:03:33 +01:00
|
|
|
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(unreadFloatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
|
|
|
|
animator.addState(new int[]{}, ObjectAnimator.ofFloat(unreadFloatingButton, View.TRANSLATION_Z, AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
|
2018-07-30 04:07:02 +02:00
|
|
|
unreadFloatingButton.setStateListAnimator(animator);
|
|
|
|
unreadFloatingButton.setOutlineProvider(new ViewOutlineProvider() {
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@Override
|
|
|
|
public void getOutline(View view, Outline outline) {
|
|
|
|
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
unreadFloatingButtonContainer.addView(unreadFloatingButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 10, 13, 10, 0));
|
|
|
|
|
|
|
|
unreadFloatingButtonCounter = new TextView(context);
|
|
|
|
unreadFloatingButtonCounter.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
unreadFloatingButtonCounter.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
|
|
|
if (currentUnreadCount > 0) {
|
|
|
|
unreadFloatingButtonCounter.setText(String.format("%d", currentUnreadCount));
|
|
|
|
}
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
unreadFloatingButtonCounter.setElevation(AndroidUtilities.dp(5));
|
|
|
|
unreadFloatingButtonCounter.setOutlineProvider(new ViewOutlineProvider() {
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@Override
|
|
|
|
public void getOutline(View view, Outline outline) {
|
|
|
|
outline.setEmpty();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-03-03 21:40:48 +01:00
|
|
|
unreadFloatingButtonCounter.setColors(Theme.getColor(Theme.key_chat_goDownButtonCounter));
|
2018-07-30 04:07:02 +02:00
|
|
|
unreadFloatingButtonCounter.setGravity(Gravity.CENTER);
|
|
|
|
unreadFloatingButtonCounter.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(11.5f), Theme.getColor(Theme.key_chat_goDownButtonCounterBackground)));
|
|
|
|
unreadFloatingButtonCounter.setMinWidth(AndroidUtilities.dp(23));
|
|
|
|
unreadFloatingButtonCounter.setPadding(AndroidUtilities.dp(8), 0, AndroidUtilities.dp(8), AndroidUtilities.dp(1));
|
2019-01-23 18:03:33 +01:00
|
|
|
unreadFloatingButtonContainer.addView(unreadFloatingButtonCounter, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 23, Gravity.TOP | Gravity.CENTER_HORIZONTAL));*/
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2015-05-21 23:27:27 +02:00
|
|
|
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
private boolean scrollingManually;
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
2015-05-21 23:27:27 +02:00
|
|
|
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
|
|
|
if (searching && searchWas) {
|
|
|
|
AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
|
|
|
|
}
|
|
|
|
scrollingManually = true;
|
|
|
|
} else {
|
|
|
|
scrollingManually = false;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
@Override
|
2015-05-21 23:27:27 +02:00
|
|
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
|
|
|
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
|
|
|
int visibleItemCount = Math.abs(layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
|
|
|
|
int totalItemCount = recyclerView.getAdapter().getItemCount();
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
if (searching && searchWas) {
|
2015-05-21 23:27:27 +02:00
|
|
|
if (visibleItemCount > 0 && layoutManager.findLastVisibleItemPosition() == totalItemCount - 1 && !dialogsSearchAdapter.isMessagesSearchEndReached()) {
|
2015-04-09 20:00:14 +02:00
|
|
|
dialogsSearchAdapter.loadMoreSearchMessages();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (visibleItemCount > 0) {
|
2019-03-03 21:40:48 +01:00
|
|
|
if (layoutManager.findLastVisibleItemPosition() >= getDialogsArray(dialogsType, currentAccount).size() - 10) {
|
2018-07-30 04:07:02 +02:00
|
|
|
boolean fromCache = !MessagesController.getInstance(currentAccount).dialogsEndReached;
|
|
|
|
if (fromCache || !MessagesController.getInstance(currentAccount).serverDialogsEndReached) {
|
|
|
|
MessagesController.getInstance(currentAccount).loadDialogs(-1, 100, fromCache);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2014-05-25 00:47:05 +02:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
//checkUnreadButton(true);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
if (floatingButtonContainer.getVisibility() != View.GONE) {
|
2015-05-21 23:27:27 +02:00
|
|
|
final View topChild = recyclerView.getChildAt(0);
|
2015-04-09 20:00:14 +02:00
|
|
|
int firstViewTop = 0;
|
|
|
|
if (topChild != null) {
|
|
|
|
firstViewTop = topChild.getTop();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
boolean goingDown;
|
|
|
|
boolean changed = true;
|
|
|
|
if (prevPosition == firstVisibleItem) {
|
|
|
|
final int topDelta = prevTop - firstViewTop;
|
|
|
|
goingDown = firstViewTop < prevTop;
|
|
|
|
changed = Math.abs(topDelta) > 1;
|
|
|
|
} else {
|
|
|
|
goingDown = firstVisibleItem > prevPosition;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (changed && scrollUpdated && (goingDown || !goingDown && scrollingManually)) {
|
2015-04-09 20:00:14 +02:00
|
|
|
hideFloatingButton(goingDown);
|
2014-11-06 22:34:47 +01:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
prevPosition = firstVisibleItem;
|
|
|
|
prevTop = firstViewTop;
|
|
|
|
scrollUpdated = true;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
|
|
|
|
2015-05-21 23:27:27 +02:00
|
|
|
if (searchString == null) {
|
2017-12-08 18:35:59 +01:00
|
|
|
dialogsAdapter = new DialogsAdapter(context, dialogsType, onlySelect);
|
2015-05-21 23:27:27 +02:00
|
|
|
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
|
|
|
}
|
|
|
|
listView.setAdapter(dialogsAdapter);
|
|
|
|
}
|
|
|
|
int type = 0;
|
|
|
|
if (searchString != null) {
|
|
|
|
type = 2;
|
|
|
|
} else if (!onlySelect) {
|
|
|
|
type = 1;
|
|
|
|
}
|
2015-08-13 11:23:31 +02:00
|
|
|
dialogsSearchAdapter = new DialogsSearchAdapter(context, type, dialogsType);
|
2016-05-25 23:49:47 +02:00
|
|
|
dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() {
|
2015-05-21 23:27:27 +02:00
|
|
|
@Override
|
|
|
|
public void searchStateChanged(boolean search) {
|
|
|
|
if (searching && searchWas && searchEmptyView != null) {
|
|
|
|
if (search) {
|
|
|
|
searchEmptyView.showProgress();
|
|
|
|
} else {
|
|
|
|
searchEmptyView.showTextView();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
@Override
|
2017-12-08 18:35:59 +01:00
|
|
|
public void didPressedOnSubDialog(long did) {
|
2016-05-25 23:49:47 +02:00
|
|
|
if (onlySelect) {
|
2017-12-08 18:35:59 +01:00
|
|
|
if (dialogsAdapter.hasSelectedDialogs()) {
|
|
|
|
dialogsAdapter.addOrRemoveSelectedDialog(did, null);
|
|
|
|
updateSelectedCount();
|
2019-01-23 18:03:33 +01:00
|
|
|
closeSearch();
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
|
|
|
didSelectResult(did, true, false);
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
} else {
|
2017-12-08 18:35:59 +01:00
|
|
|
int lower_id = (int) did;
|
2016-05-25 23:49:47 +02:00
|
|
|
Bundle args = new Bundle();
|
2017-12-08 18:35:59 +01:00
|
|
|
if (lower_id > 0) {
|
|
|
|
args.putInt("user_id", lower_id);
|
2016-05-25 23:49:47 +02:00
|
|
|
} else {
|
2017-12-08 18:35:59 +01:00
|
|
|
args.putInt("chat_id", -lower_id);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
closeSearch();
|
2016-05-25 23:49:47 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId = did);
|
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (searchString != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
|
2016-05-25 23:49:47 +02:00
|
|
|
presentFragment(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (MessagesController.getInstance(currentAccount).checkCanOpenChat(args, DialogsActivity.this)) {
|
2016-05-25 23:49:47 +02:00
|
|
|
presentFragment(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needRemoveHint(final int did) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(did);
|
2016-05-25 23:49:47 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.formatString("ChatHintsDelete", R.string.ChatHintsDelete, ContactsController.formatName(user.first_name, user.last_name)));
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> DataQuery.getInstance(currentAccount).removePeer(did));
|
2016-05-25 23:49:47 +02:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
});
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
listView.setEmptyView(progressView);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (searchString != null) {
|
2019-01-23 18:03:33 +01:00
|
|
|
actionBar.openSearchField(searchString, false);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
if (!onlySelect && dialogsType == 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
FragmentContextView fragmentLocationContextView = new FragmentContextView(context, this, true);
|
|
|
|
contentView.addView(fragmentLocationContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
|
|
|
|
|
|
|
|
FragmentContextView fragmentContextView = new FragmentContextView(context, this, false);
|
|
|
|
contentView.addView(fragmentContextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
|
|
|
|
fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
|
|
|
|
} else if (dialogsType == 3 && selectAlertString == null) {
|
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onDestroy();
|
|
|
|
}
|
|
|
|
commentView = new ChatActivityEnterView(getParentActivity(), contentView, null, false);
|
|
|
|
commentView.setAllowStickersAndGifs(false, false);
|
|
|
|
commentView.setForceShowSendButton(true, false);
|
|
|
|
commentView.setVisibility(View.GONE);
|
|
|
|
contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM));
|
|
|
|
commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
|
|
|
|
@Override
|
|
|
|
public void onMessageSend(CharSequence message) {
|
|
|
|
if (delegate == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ArrayList<Long> selectedDialogs = dialogsAdapter.getSelectedDialogs();
|
|
|
|
if (selectedDialogs.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, message, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSwitchRecordMode(boolean video) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
|
|
|
public void onTextSelectionChanged(int start, int end) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickersExpandedChange() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
@Override
|
|
|
|
public void onPreAudioVideoRecord() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextChanged(final CharSequence text, boolean bigChange) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
|
|
|
public void onTextSpansChanged(CharSequence text) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
@Override
|
|
|
|
public void needSendTyping() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttachButtonHidden() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttachButtonShow() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMessageEditEnd(boolean loading) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onWindowSizeChanged(int size) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickersTab(boolean opened) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didPressedAttachButton() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needStartRecordVideo(int state) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needChangeVideoPreviewState(int state, float seekProgress) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needStartRecordAudio(int state) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needShowMediaBanHint() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
undoView = new UndoView(context) {
|
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
|
|
|
float diff = getMeasuredHeight() - translationY;
|
|
|
|
if (!floatingHidden) {
|
|
|
|
floatingButtonContainer.setTranslationY(floatingButtonContainer.getTranslationY() + additionalFloatingTranslation - diff);
|
|
|
|
}
|
|
|
|
additionalFloatingTranslation = diff;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
contentView.addView(undoView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT));
|
|
|
|
|
|
|
|
/*if (!onlySelect) {
|
2018-07-30 04:07:02 +02:00
|
|
|
checkUnreadCount(false);
|
2019-01-23 18:03:33 +01:00
|
|
|
}*/
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 18:00:42 +02:00
|
|
|
super.onResume();
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onResume();
|
|
|
|
}
|
2014-11-13 21:10:14 +01:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.notifyDataSetChanged();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
if (checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
|
|
|
|
Activity activity = getParentActivity();
|
|
|
|
if (activity != null) {
|
|
|
|
checkPermission = false;
|
|
|
|
if (activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED || activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
2019-02-08 03:30:32 +01:00
|
|
|
if (askAboutContacts && UserConfig.getInstance(currentAccount).syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) {
|
2018-08-27 10:33:11 +02:00
|
|
|
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
|
|
|
|
askAboutContacts = param != 0;
|
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit();
|
|
|
|
askForPermissons(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
showDialog(permissionDialog = builder.create());
|
|
|
|
} else if (activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showDialog(permissionDialog = builder.create());
|
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
askForPermissons(true);
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (!onlySelect && XiaomiUtilities.isMIUI() && Build.VERSION.SDK_INT >= 19 && !XiaomiUtilities.isCustomPermissionGranted(XiaomiUtilities.OP_SHOW_WHEN_LOCKED)) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (MessagesController.getGlobalNotificationsSettings().getBoolean("askedAboutMiuiLockscreen", false)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
showDialog(new AlertDialog.Builder(getParentActivity())
|
|
|
|
.setTitle(LocaleController.getString("AppName", R.string.AppName))
|
|
|
|
.setMessage(LocaleController.getString("PermissionXiaomiLockscreen", R.string.PermissionXiaomiLockscreen))
|
|
|
|
.setPositiveButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
|
|
|
|
Intent intent = XiaomiUtilities.getPermissionManagerIntent();
|
|
|
|
if (intent != null) {
|
|
|
|
try {
|
|
|
|
getParentActivity().startActivity(intent);
|
|
|
|
} catch (Exception x) {
|
|
|
|
try {
|
|
|
|
intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
|
|
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
|
|
|
|
getParentActivity().startActivity(intent);
|
|
|
|
} catch (Exception xx) {
|
|
|
|
FileLog.e(xx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.setNegativeButton(LocaleController.getString("ContactsPermissionAlertNotNow", R.string.ContactsPermissionAlertNotNow), (dialog, which) -> MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askedAboutMiuiLockscreen", true).commit())
|
|
|
|
.create());
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onResume();
|
|
|
|
}
|
2019-02-08 03:30:32 +01:00
|
|
|
if (undoView != null) {
|
|
|
|
undoView.hide(true, false);
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
@Override
|
|
|
|
protected void onBecomeFullyHidden() {
|
|
|
|
if (closeSearchFieldOnHide) {
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
if (searchObject != null) {
|
|
|
|
dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
|
|
|
searchObject = null;
|
|
|
|
}
|
|
|
|
closeSearchFieldOnHide = false;
|
|
|
|
}
|
|
|
|
if (undoView != null) {
|
|
|
|
undoView.hide(true, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void closeSearch() {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
if (searchObject != null) {
|
|
|
|
dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
|
|
|
searchObject = null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
closeSearchFieldOnHide = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*private void checkUnreadCount(boolean animated) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!BuildVars.DEBUG_PRIVATE_VERSION) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int newCount = MessagesController.getInstance(currentAccount).unreadUnmutedDialogs;
|
|
|
|
if (newCount != currentUnreadCount) {
|
|
|
|
currentUnreadCount = newCount;
|
|
|
|
if (unreadFloatingButtonContainer != null) {
|
|
|
|
if (currentUnreadCount > 0) {
|
|
|
|
unreadFloatingButtonCounter.setText(String.format("%d", currentUnreadCount));
|
|
|
|
}
|
|
|
|
checkUnreadButton(animated);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkUnreadButton(boolean animated) {
|
|
|
|
if (!onlySelect && listView.getAdapter() == dialogsAdapter) {
|
|
|
|
boolean found = false;
|
|
|
|
if (currentUnreadCount > 0) {
|
|
|
|
int middle = listView.getMeasuredHeight() / 2;
|
|
|
|
int firstVisibleItem = layoutManager.findFirstVisibleItemPosition();
|
|
|
|
int count = listView.getChildCount();
|
|
|
|
int unreadOnScreen = 0;
|
|
|
|
for (int b = 0; b < count; b++) {
|
|
|
|
View child = listView.getChildAt(b);
|
|
|
|
if (child instanceof DialogCell) {
|
|
|
|
if (((DialogCell) child).isUnread()) {
|
|
|
|
unreadOnScreen++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int b = 0; b < count; b++) {
|
|
|
|
View child = listView.getChildAt(b);
|
|
|
|
if (child instanceof DialogCell) {
|
|
|
|
if (child.getTop() <= middle && child.getBottom() >= middle) {
|
|
|
|
RecyclerListView.Holder holder = (RecyclerListView.Holder) listView.findContainingViewHolder(child);
|
|
|
|
if (holder != null) {
|
|
|
|
ArrayList<TLRPC.TL_dialog> array = getDialogsArray();
|
|
|
|
if (firstVisibleItem == 0) {
|
|
|
|
if (unreadOnScreen != currentUnreadCount) {
|
|
|
|
for (int a = holder.getAdapterPosition() + 1, size = array.size(); a < size; a++) {
|
|
|
|
TLRPC.TL_dialog dialog = array.get(a);
|
|
|
|
if ((dialog.unread_count != 0 || dialog.unread_mark) && !MessagesController.getInstance(currentAccount).isDialogMuted(dialog.id)) {
|
|
|
|
arrowDrawable.setAnimationProgressAnimated(1.0f);
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
found = true;
|
|
|
|
arrowDrawable.setAnimationProgressAnimated(0.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (found) {
|
|
|
|
if (unreadFloatingButtonContainer.getTag() == null) {
|
|
|
|
unreadFloatingButtonContainer.setTag(1);
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.VISIBLE);
|
|
|
|
if (animated) {
|
|
|
|
unreadFloatingButtonContainer.animate().alpha(1.0f).setDuration(200).setInterpolator(new DecelerateInterpolator()).setListener(null).start();
|
|
|
|
} else {
|
|
|
|
unreadFloatingButtonContainer.setAlpha(1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (unreadFloatingButtonContainer.getTag() != null) {
|
|
|
|
unreadFloatingButtonContainer.setTag(null);
|
|
|
|
if (animated) {
|
|
|
|
unreadFloatingButtonContainer.animate().alpha(0.0f).setDuration(200).setInterpolator(new DecelerateInterpolator()).setListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
} else {
|
|
|
|
unreadFloatingButtonContainer.setAlpha(0.0f);
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
}*/
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
private void updateProxyButton(boolean animated) {
|
|
|
|
if (proxyDrawable == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
|
|
String proxyAddress = preferences.getString("proxy_ip", "");
|
|
|
|
boolean proxyEnabled;
|
|
|
|
if ((proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || MessagesController.getInstance(currentAccount).blockedCountry && !SharedConfig.proxyList.isEmpty()) {
|
|
|
|
if (!actionBar.isSearchFieldVisible()) {
|
|
|
|
proxyItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
proxyDrawable.setConnected(proxyEnabled, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated);
|
|
|
|
proxyItemVisisble = true;
|
|
|
|
} else {
|
|
|
|
proxyItem.setVisibility(View.GONE);
|
|
|
|
proxyItemVisisble = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
private void updateSelectedCount() {
|
|
|
|
if (commentView == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!dialogsAdapter.hasSelectedDialogs()) {
|
|
|
|
if (dialogsType == 3 && selectAlertString == null) {
|
|
|
|
actionBar.setTitle(LocaleController.getString("ForwardTo", R.string.ForwardTo));
|
|
|
|
} else {
|
|
|
|
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
|
|
|
}
|
|
|
|
if (commentView.getTag() != null) {
|
|
|
|
commentView.hidePopup(false);
|
|
|
|
commentView.closeKeyboard();
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
2019-01-23 18:03:33 +01:00
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, 0, commentView.getMeasuredHeight()));
|
2017-12-08 18:35:59 +01:00
|
|
|
animatorSet.setDuration(180);
|
|
|
|
animatorSet.setInterpolator(new DecelerateInterpolator());
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
commentView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
animatorSet.start();
|
|
|
|
commentView.setTag(null);
|
|
|
|
listView.requestLayout();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (commentView.getTag() == null) {
|
|
|
|
commentView.setFieldText("");
|
|
|
|
commentView.setVisibility(View.VISIBLE);
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
2019-01-23 18:03:33 +01:00
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, commentView.getMeasuredHeight(), 0));
|
2017-12-08 18:35:59 +01:00
|
|
|
animatorSet.setDuration(180);
|
|
|
|
animatorSet.setInterpolator(new DecelerateInterpolator());
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
commentView.setTag(2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
animatorSet.start();
|
|
|
|
commentView.setTag(1);
|
|
|
|
}
|
|
|
|
actionBar.setTitle(LocaleController.formatPluralString("Recipient", dialogsAdapter.getSelectedDialogs().size()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
@TargetApi(Build.VERSION_CODES.M)
|
2018-07-30 04:07:02 +02:00
|
|
|
private void askForPermissons(boolean alert) {
|
2015-10-29 18:10:07 +01:00
|
|
|
Activity activity = getParentActivity();
|
|
|
|
if (activity == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ArrayList<String> permissons = new ArrayList<>();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (UserConfig.getInstance(currentAccount).syncContacts && askAboutContacts && activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
if (alert) {
|
2018-08-27 10:33:11 +02:00
|
|
|
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
|
|
|
|
askAboutContacts = param != 0;
|
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit();
|
|
|
|
askForPermissons(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
});
|
|
|
|
showDialog(permissionDialog = builder.create());
|
|
|
|
return;
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
permissons.add(Manifest.permission.READ_CONTACTS);
|
|
|
|
permissons.add(Manifest.permission.WRITE_CONTACTS);
|
|
|
|
permissons.add(Manifest.permission.GET_ACCOUNTS);
|
|
|
|
}
|
|
|
|
if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
permissons.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
|
|
permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (permissons.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
String[] items = permissons.toArray(new String[permissons.size()]);
|
2017-07-23 19:29:17 +02:00
|
|
|
try {
|
|
|
|
activity.requestPermissions(items, 1);
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDialogDismiss(Dialog dialog) {
|
|
|
|
super.onDialogDismiss(dialog);
|
2019-02-08 03:30:32 +01:00
|
|
|
if (permissionDialog != null && dialog == permissionDialog && getParentActivity() != null && askAboutContacts) {
|
2018-07-30 04:07:02 +02:00
|
|
|
askForPermissons(false);
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
2019-01-23 18:03:33 +01:00
|
|
|
if (!onlySelect && floatingButtonContainer != null) {
|
|
|
|
floatingButtonContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
2014-11-06 22:34:47 +01:00
|
|
|
@Override
|
|
|
|
public void onGlobalLayout() {
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setTranslationY((floatingHidden ? AndroidUtilities.dp(100) : -additionalFloatingTranslation));
|
|
|
|
//unreadFloatingButtonContainer.setTranslationY(floatingHidden ? AndroidUtilities.dp(74) : 0);
|
|
|
|
floatingButtonContainer.setClickable(!floatingHidden);
|
|
|
|
if (floatingButtonContainer != null) {
|
|
|
|
floatingButtonContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
2014-11-06 22:34:47 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
if (requestCode == 1) {
|
|
|
|
for (int a = 0; a < permissions.length; a++) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (grantResults.length <= a) {
|
2015-10-29 18:10:07 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
switch (permissions[a]) {
|
|
|
|
case Manifest.permission.READ_CONTACTS:
|
2018-07-30 04:07:02 +02:00
|
|
|
if (grantResults[a] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
ContactsController.getInstance(currentAccount).forceImportContacts();
|
|
|
|
} else {
|
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).commit();
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
break;
|
|
|
|
case Manifest.permission.WRITE_EXTERNAL_STORAGE:
|
2018-07-30 04:07:02 +02:00
|
|
|
if (grantResults[a] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
ImageLoader.getInstance().checkMediaPaths();
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
@SuppressWarnings("unchecked")
|
2018-07-30 04:07:02 +02:00
|
|
|
public void didReceivedNotification(int id, int account, Object... args) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (id == NotificationCenter.dialogsNeedReload) {
|
2019-01-23 18:03:33 +01:00
|
|
|
//checkUnreadCount(true);
|
2014-11-20 15:45:33 +01:00
|
|
|
if (dialogsAdapter != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (dialogsAdapter.isDataSetChanged() || args.length > 0) {
|
2015-02-26 02:32:51 +01:00
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
|
|
|
} else {
|
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_NEW_MESSAGE);
|
|
|
|
}
|
2014-11-20 15:45:33 +01:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
if (listView != null) {
|
2014-11-21 11:59:05 +01:00
|
|
|
try {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (listView.getAdapter() == dialogsAdapter) {
|
2015-06-29 19:12:11 +02:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2015-05-21 23:27:27 +02:00
|
|
|
listView.setEmptyView(progressView);
|
2014-11-17 03:44:57 +01:00
|
|
|
} else {
|
2014-11-21 11:59:05 +01:00
|
|
|
if (searching && searchWas) {
|
2015-05-21 23:27:27 +02:00
|
|
|
listView.setEmptyView(searchEmptyView);
|
2014-11-21 11:59:05 +01:00
|
|
|
} else {
|
2015-06-29 19:12:11 +02:00
|
|
|
searchEmptyView.setVisibility(View.GONE);
|
2017-12-08 18:35:59 +01:00
|
|
|
listView.setEmptyView(null);
|
2014-11-21 11:59:05 +01:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
progressView.setVisibility(View.GONE);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2014-11-21 11:59:05 +01:00
|
|
|
} catch (Exception e) {
|
2017-12-08 18:35:59 +01:00
|
|
|
FileLog.e(e);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.emojiDidLoad) {
|
2016-03-16 13:26:32 +01:00
|
|
|
updateVisibleRows(0);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (id == NotificationCenter.closeSearchByActiveAction) {
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.proxySettingsChanged) {
|
|
|
|
updateProxyButton(false);
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.updateInterfaces) {
|
2018-07-30 04:07:02 +02:00
|
|
|
Integer mask = (Integer) args[0];
|
|
|
|
updateVisibleRows(mask);
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0 || (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
|
2019-01-23 18:03:33 +01:00
|
|
|
//checkUnreadCount(true);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.appDidLogout) {
|
2018-07-30 04:07:02 +02:00
|
|
|
dialogsLoaded[currentAccount] = false;
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.encryptedChatUpdated) {
|
2014-02-04 19:36:55 +01:00
|
|
|
updateVisibleRows(0);
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.contactsDidLoad) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (dialogsType == 0 && MessagesController.getInstance(currentAccount).dialogs.isEmpty()) {
|
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
updateVisibleRows(0);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
} else if (id == NotificationCenter.openedChatChanged) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
2015-05-21 23:27:27 +02:00
|
|
|
boolean close = (Boolean) args[1];
|
|
|
|
long dialog_id = (Long) args[0];
|
2014-09-30 00:48:11 +02:00
|
|
|
if (close) {
|
|
|
|
if (dialog_id == openedDialogId) {
|
|
|
|
openedDialogId = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
openedDialogId = dialog_id;
|
|
|
|
}
|
2014-11-19 11:32:27 +01:00
|
|
|
if (dialogsAdapter != null) {
|
|
|
|
dialogsAdapter.setOpenedDialogId(openedDialogId);
|
|
|
|
}
|
2014-11-11 23:16:17 +01:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2015-02-01 19:51:02 +01:00
|
|
|
} else if (id == NotificationCenter.notificationsSettingsUpdated) {
|
2015-02-26 02:32:51 +01:00
|
|
|
updateVisibleRows(0);
|
|
|
|
} else if (id == NotificationCenter.messageReceivedByAck || id == NotificationCenter.messageReceivedByServer || id == NotificationCenter.messageSendError) {
|
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SEND_STATE);
|
|
|
|
} else if (id == NotificationCenter.didSetPasscode) {
|
|
|
|
updatePasscodeButton();
|
2017-03-31 01:58:05 +02:00
|
|
|
} else if (id == NotificationCenter.needReloadRecentDialogsSearch) {
|
2015-09-24 22:52:02 +02:00
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.loadRecentSearch();
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.replyMessagesDidLoad) {
|
2018-07-30 04:07:02 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_MESSAGE_TEXT);
|
2016-05-25 23:49:47 +02:00
|
|
|
} else if (id == NotificationCenter.reloadHints) {
|
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
dialogsSearchAdapter.notifyDataSetChanged();
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.didUpdateConnectionState) {
|
2018-07-30 04:07:02 +02:00
|
|
|
int state = ConnectionsManager.getInstance(account).getConnectionState();
|
|
|
|
if (currentConnectionState != state) {
|
|
|
|
currentConnectionState = state;
|
|
|
|
updateProxyButton(true);
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.dialogsUnreadCounterChanged) {
|
|
|
|
/*if (!onlySelect) {
|
|
|
|
int count = (Integer) args[0];
|
|
|
|
currentUnreadCount = count;
|
|
|
|
if (count != 0) {
|
|
|
|
unreadFloatingButtonCounter.setText(String.format("%d", count));
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.VISIBLE);
|
|
|
|
unreadFloatingButtonContainer.setTag(1);
|
|
|
|
unreadFloatingButtonContainer.animate().alpha(1.0f).setDuration(200).setInterpolator(new DecelerateInterpolator()).setListener(null).start();
|
|
|
|
} else {
|
|
|
|
unreadFloatingButtonContainer.setTag(null);
|
|
|
|
unreadFloatingButtonContainer.animate().alpha(0.0f).setDuration(200).setInterpolator(new DecelerateInterpolator()).setListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
unreadFloatingButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
}*/
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.needDeleteDialog) {
|
|
|
|
if (undoView != null) {
|
|
|
|
long dialogId = (Long) args[0];
|
|
|
|
TLRPC.User user = (TLRPC.User) args[1];
|
|
|
|
TLRPC.Chat chat = (TLRPC.Chat) args[2];
|
|
|
|
undoView.showWithAction(dialogId, false, () -> {
|
|
|
|
if (chat != null) {
|
|
|
|
if (ChatObject.isNotInChat(chat)) {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(dialogId, 0);
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteUserFromChat((int) -dialogId, MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId()), null);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
MessagesController.getInstance(currentAccount).deleteDialog(dialogId, 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-03 21:40:48 +01:00
|
|
|
public static ArrayList<TLRPC.TL_dialog> getDialogsArray(int dialogsType, int currentAccount) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (dialogsType == 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return MessagesController.getInstance(currentAccount).dialogs;
|
2015-06-29 19:12:11 +02:00
|
|
|
} else if (dialogsType == 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return MessagesController.getInstance(currentAccount).dialogsServerOnly;
|
2015-06-29 19:12:11 +02:00
|
|
|
} else if (dialogsType == 2) {
|
2019-03-03 21:40:48 +01:00
|
|
|
return MessagesController.getInstance(currentAccount).dialogsCanAddUsers;
|
2017-12-08 18:35:59 +01:00
|
|
|
} else if (dialogsType == 3) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return MessagesController.getInstance(currentAccount).dialogsForward;
|
2019-02-08 03:30:32 +01:00
|
|
|
} else if (dialogsType == 4) {
|
|
|
|
return MessagesController.getInstance(currentAccount).dialogsUsersOnly;
|
|
|
|
} else if (dialogsType == 5) {
|
|
|
|
return MessagesController.getInstance(currentAccount).dialogsChannelsOnly;
|
2019-03-03 21:40:48 +01:00
|
|
|
} else if (dialogsType == 6) {
|
|
|
|
return MessagesController.getInstance(currentAccount).dialogsGroupsOnly;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
public void setSideMenu(RecyclerView recyclerView) {
|
|
|
|
sideMenu = recyclerView;
|
|
|
|
sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
}
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
private void updatePasscodeButton() {
|
|
|
|
if (passcodeItem == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (SharedConfig.passcodeHash.length() != 0 && !searching) {
|
2015-02-26 02:32:51 +01:00
|
|
|
passcodeItem.setVisibility(View.VISIBLE);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (SharedConfig.appLocked) {
|
2015-02-26 02:32:51 +01:00
|
|
|
passcodeItem.setIcon(R.drawable.lock_close);
|
|
|
|
} else {
|
|
|
|
passcodeItem.setIcon(R.drawable.lock_open);
|
2015-02-01 19:51:02 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
passcodeItem.setVisibility(View.GONE);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
private void hideFloatingButton(boolean hide) {
|
|
|
|
if (floatingHidden == hide) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
floatingHidden = hide;
|
2018-07-30 04:07:02 +02:00
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
2019-01-23 18:03:33 +01:00
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(floatingButtonContainer, View.TRANSLATION_Y, (floatingHidden ? AndroidUtilities.dp(100) : -additionalFloatingTranslation))/*,
|
|
|
|
ObjectAnimator.ofFloat(unreadFloatingButtonContainer, View.TRANSLATION_Y, floatingHidden ? AndroidUtilities.dp(74) : 0)*/);
|
2018-07-30 04:07:02 +02:00
|
|
|
animatorSet.setDuration(300);
|
|
|
|
animatorSet.setInterpolator(floatingInterpolator);
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setClickable(!hide);
|
2018-07-30 04:07:02 +02:00
|
|
|
animatorSet.start();
|
2014-11-06 22:34:47 +01:00
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
private void updateVisibleRows(int mask) {
|
2015-05-21 23:27:27 +02:00
|
|
|
if (listView == null) {
|
2014-02-04 19:36:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
int count = listView.getChildCount();
|
2014-02-04 19:36:55 +01:00
|
|
|
for (int a = 0; a < count; a++) {
|
2015-05-21 23:27:27 +02:00
|
|
|
View child = listView.getChildAt(a);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (child instanceof DialogCell) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (listView.getAdapter() != dialogsSearchAdapter) {
|
|
|
|
DialogCell cell = (DialogCell) child;
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) {
|
|
|
|
cell.checkCurrentDialogIndex();
|
|
|
|
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
|
|
|
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
|
|
|
}
|
|
|
|
} else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
|
|
|
if (dialogsType == 0 && AndroidUtilities.isTablet()) {
|
|
|
|
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cell.update(mask);
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-10 12:05:22 +01:00
|
|
|
} else if (child instanceof UserCell) {
|
|
|
|
((UserCell) child).update(mask);
|
2015-08-13 11:23:31 +02:00
|
|
|
} else if (child instanceof ProfileSearchCell) {
|
|
|
|
((ProfileSearchCell) child).update(mask);
|
2016-05-25 23:49:47 +02:00
|
|
|
} else if (child instanceof RecyclerListView) {
|
|
|
|
RecyclerListView innerListView = (RecyclerListView) child;
|
|
|
|
int count2 = innerListView.getChildCount();
|
|
|
|
for (int b = 0; b < count2; b++) {
|
|
|
|
View child2 = innerListView.getChildAt(b);
|
|
|
|
if (child2 instanceof HintDialogCell) {
|
2019-01-23 18:03:33 +01:00
|
|
|
((HintDialogCell) child2).update(mask);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) {
|
|
|
|
delegate = dialogsActivityDelegate;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
public void setSearchString(String string) {
|
|
|
|
searchString = string;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isMainDialogList() {
|
|
|
|
return delegate == null && searchString == null;
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
|
2014-07-10 23:15:39 +02:00
|
|
|
private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) {
|
2019-03-03 21:40:48 +01:00
|
|
|
if (addToGroupAlertString == null && checkCanWrite) {
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((int) dialog_id < 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-(int) dialog_id);
|
|
|
|
if (ChatObject.isChannel(chat) && !chat.megagroup && (cantSendToChannels || !ChatObject.isCanWriteToChannel(-(int) dialog_id, currentAccount))) {
|
2017-03-31 01:58:05 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.getString("ChannelCantSendMessage", R.string.ChannelCantSendMessage));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
return;
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (useAlert && (selectAlertString != null && selectAlertStringGroup != null || addToGroupAlertString != null)) {
|
2014-06-14 10:36:01 +02:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-04-02 19:36:57 +02:00
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
2015-05-21 23:27:27 +02:00
|
|
|
int lower_part = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
2013-10-25 17:19:00 +02:00
|
|
|
if (lower_part != 0) {
|
2014-07-27 12:53:00 +02:00
|
|
|
if (high_id == 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(lower_part);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-10-04 17:56:09 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, chat.title));
|
2014-07-27 00:28:33 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (lower_part == UserConfig.getInstance(currentAccount).getClientUserId()) {
|
2017-12-08 18:35:59 +01:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, LocaleController.getString("SavedMessages", R.string.SavedMessages)));
|
|
|
|
} else if (lower_part > 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(lower_part);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)));
|
2014-07-27 12:53:00 +02:00
|
|
|
} else if (lower_part < 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_part);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (addToGroupAlertString != null) {
|
|
|
|
builder.setMessage(LocaleController.formatStringSimple(addToGroupAlertString, chat.title));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertStringGroup, chat.title));
|
|
|
|
}
|
2014-07-27 00:28:33 +02:00
|
|
|
}
|
2014-02-04 19:36:55 +01:00
|
|
|
}
|
2014-07-27 12:53:00 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.EncryptedChat chat = MessagesController.getInstance(currentAccount).getEncryptedChat(high_id);
|
|
|
|
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(chat.user_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
builder.setMessage(LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> didSelectResult(dialog_id, false, false));
|
2015-03-19 00:09:45 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2015-05-21 23:27:27 +02:00
|
|
|
showDialog(builder.create());
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
|
|
|
if (delegate != null) {
|
2017-12-08 18:35:59 +01:00
|
|
|
ArrayList<Long> dids = new ArrayList<>();
|
|
|
|
dids.add(dialog_id);
|
|
|
|
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
|
2013-10-25 17:19:00 +02:00
|
|
|
delegate = null;
|
|
|
|
} else {
|
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public ThemeDescription[] getThemeDescriptions() {
|
2018-08-27 10:33:11 +02:00
|
|
|
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
|
|
|
|
if (listView != null) {
|
|
|
|
int count = listView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = listView.getChildAt(a);
|
|
|
|
if (child instanceof ProfileSearchCell) {
|
|
|
|
((ProfileSearchCell) child).update(0);
|
|
|
|
} else if (child instanceof DialogCell) {
|
|
|
|
((DialogCell) child).update(0);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
if (dialogsSearchAdapter != null) {
|
|
|
|
RecyclerListView recyclerListView = dialogsSearchAdapter.getInnerListView();
|
|
|
|
if (recyclerListView != null) {
|
|
|
|
int count = recyclerListView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = recyclerListView.getChildAt(a);
|
|
|
|
if (child instanceof HintDialogCell) {
|
|
|
|
((HintDialogCell) child).update();
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
return new ThemeDescription[]{
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite),
|
|
|
|
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault),
|
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault),
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, new Drawable[]{Theme.dialogs_holidayDrawable}, null, Theme.key_actionBarDefaultTitle),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector),
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch),
|
|
|
|
new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder),
|
|
|
|
|
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector),
|
|
|
|
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider),
|
|
|
|
|
|
|
|
new ThemeDescription(searchEmptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder),
|
|
|
|
new ThemeDescription(searchEmptyView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle),
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DialogsEmptyCell.class}, new String[]{"emptyTextView1"}, null, null, null, Theme.key_emptyListPlaceholder),
|
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DialogsEmptyCell.class}, new String[]{"emptyTextView2"}, null, null, null, Theme.key_emptyListPlaceholder),
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
new ThemeDescription(floatingButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionIcon),
|
|
|
|
new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chats_actionBackground),
|
|
|
|
new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chats_actionPressedBackground),
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
/*new ThemeDescription(unreadFloatingButtonCounter, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chat_goDownButtonCounterBackground),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(unreadFloatingButtonCounter, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_chat_goDownButtonCounter),
|
|
|
|
new ThemeDescription(unreadFloatingButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionUnreadIcon),
|
|
|
|
new ThemeDescription(unreadFloatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chats_actionUnreadBackground),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(unreadFloatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chats_actionUnreadPressedBackground),*/
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.avatar_broadcastDrawable, Theme.avatar_savedDrawable}, null, Theme.key_avatar_text),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundSaved),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_countGrayPaint, null, null, Theme.key_chats_unreadCounterMuted),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_countTextPaint, null, null, Theme.key_chats_unreadCounterText),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, Theme.dialogs_namePaint, null, null, Theme.key_chats_name),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, Theme.dialogs_nameEncryptedPaint, null, null, Theme.key_chats_secretName),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_lockDrawable}, null, Theme.key_chats_secretIcon),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_groupDrawable, Theme.dialogs_broadcastDrawable, Theme.dialogs_botDrawable}, null, Theme.key_chats_nameIcon),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_pinnedDrawable}, null, Theme.key_chats_pinnedIcon),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_messagePaint, null, null, Theme.key_chats_message),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_nameMessage),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_draft),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_attachMessage),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_messagePrintingPaint, null, null, Theme.key_chats_actionMessage),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_timePaint, null, null, Theme.key_chats_date),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_pinnedPaint, null, null, Theme.key_chats_pinnedOverlay),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_tabletSeletedPaint, null, null, Theme.key_chats_tabletSelectedOverlay),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_checkDrawable, Theme.dialogs_halfCheckDrawable}, null, Theme.key_chats_sentCheck),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_clockDrawable}, null, Theme.key_chats_sentClock),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, Theme.dialogs_errorPaint, null, null, Theme.key_chats_sentError),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_errorDrawable}, null, Theme.key_chats_sentErrorIcon),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedCheckDrawable}, null, Theme.key_chats_verifiedCheck),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedDrawable}, null, Theme.key_chats_verifiedBackground),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_muteDrawable}, null, Theme.key_chats_muteIcon),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(listView, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_mentionDrawable}, null, Theme.key_chats_mentionIcon),
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_chats_menuBackground),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuName),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuPhone),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuPhoneCats),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuCloudBackgroundCats),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chat_serviceBackground),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuTopShadow),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_avatar_backgroundActionBarBlue),
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerActionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemIcon),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerActionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText),
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerUserCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText),
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_unreadCounterText),
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_unreadCounter),
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_menuBackground),
|
|
|
|
new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerAddCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemIcon),
|
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DrawerAddCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText),
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(sideMenu, 0, new Class[]{DividerCell.class}, Theme.dividerPaint, null, null, Theme.key_divider),
|
|
|
|
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{LoadingCell.class}, new String[]{"progressBar"}, null, null, null, Theme.key_progressCircle),
|
|
|
|
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_offlinePaint, null, null, Theme.key_windowBackgroundWhiteGrayText3),
|
|
|
|
new ThemeDescription(listView, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_onlinePaint, null, null, Theme.key_windowBackgroundWhiteBlueText3),
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(listView, 0, new Class[]{GraySectionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_graySectionText),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{GraySectionCell.class}, null, null, null, Theme.key_graySection),
|
|
|
|
|
|
|
|
new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HashtagSearchCell.class}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
|
|
|
|
|
|
|
new ThemeDescription(progressView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle),
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(dialogsSearchAdapter != null ? dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter),
|
|
|
|
new ThemeDescription(dialogsSearchAdapter != null ? dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countGrayPaint, null, null, Theme.key_chats_unreadCounterMuted),
|
|
|
|
new ThemeDescription(dialogsSearchAdapter != null ? dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countTextPaint, null, null, Theme.key_chats_unreadCounterText),
|
|
|
|
new ThemeDescription(dialogsSearchAdapter != null ? dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(dialogsSearchAdapter != null ? dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, null, null, null, Theme.key_chats_onlineCircle),
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, null, null, null, Theme.key_inappPlayerBackground),
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"playButton"}, null, null, null, Theme.key_inappPlayerPlayPause),
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_inappPlayerTitle),
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_FASTSCROLL, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_inappPlayerPerformer),
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"closeButton"}, null, null, null, Theme.key_inappPlayerClose),
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, null, null, null, Theme.key_returnToCallBackground),
|
|
|
|
new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_returnToCallText),
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(undoView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_undo_background),
|
|
|
|
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, null, null, null, Theme.key_undo_cancelColor),
|
|
|
|
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"undoTextView"}, null, null, null, Theme.key_undo_cancelColor),
|
|
|
|
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"infoTextView"}, null, null, null, Theme.key_undo_infoColor),
|
|
|
|
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"textPaint"}, null, null, null, Theme.key_undo_infoColor),
|
|
|
|
new ThemeDescription(undoView, 0, new Class[]{UndoView.class}, new String[]{"progressPaint"}, null, null, null, Theme.key_undo_infoColor),
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBackground),
|
2017-07-08 18:32:04 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBackgroundGray),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlack),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextLink),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLinkSelection),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue2),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue3),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue4),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextRed),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextRed2),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray2),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray3),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray4),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogIcon),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRedIcon),
|
2017-03-31 01:58:05 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextHint),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogInputField),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogInputFieldActivated),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareCheck),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareUnchecked),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareDisabled),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRadioBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRadioBackgroundChecked),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogProgressCircle),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogButton),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogButtonSelector),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogScrollGlow),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRoundCheckBox),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRoundCheckBoxCheck),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBadgeBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBadgeText),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLineProgress),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLineProgressBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogGrayLine),
|
2019-01-23 18:03:33 +01:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialog_inlineProgressBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialog_inlineProgress),
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBar),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarSelector),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarTitle),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarTop),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarSubtitle),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarItems),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_background),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_time),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progressBackground),
|
2018-07-30 04:07:02 +02:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progressCachedBackground),
|
2017-12-08 18:35:59 +01:00
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progress),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_placeholder),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_placeholderBackground),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_button),
|
|
|
|
new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_buttonActive),
|
2017-03-31 01:58:05 +02:00
|
|
|
};
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|