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;
|
2019-12-31 14:08:08 +01:00
|
|
|
import android.animation.ValueAnimator;
|
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-05-14 14:08:05 +02:00
|
|
|
import android.content.DialogInterface;
|
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;
|
2020-06-04 18:47:15 +02:00
|
|
|
import android.graphics.Bitmap;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.graphics.Canvas;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.graphics.Outline;
|
2019-06-04 12:14:50 +02:00
|
|
|
import android.graphics.Paint;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.graphics.Rect;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.graphics.RectF;
|
2020-06-04 18:47:15 +02:00
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
2017-03-31 01:58:05 +02:00
|
|
|
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;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.util.Property;
|
|
|
|
import android.util.StateSet;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.Gravity;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.view.HapticFeedbackConstants;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.KeyEvent;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.view.MotionEvent;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.VelocityTracker;
|
2013-10-25 17:19:00 +02:00
|
|
|
import android.view.View;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.ViewConfiguration;
|
2019-12-31 14:08:08 +01:00
|
|
|
import android.view.ViewGroup;
|
2015-02-01 19:51:02 +01:00
|
|
|
import android.view.ViewOutlineProvider;
|
2020-10-01 03:59:32 +02:00
|
|
|
import android.view.ViewParent;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.ViewTreeObserver;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.WindowManager;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
2017-12-08 18:35:59 +01:00
|
|
|
import android.view.animation.DecelerateInterpolator;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.animation.Interpolator;
|
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;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.ScrollView;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
import androidx.annotation.NonNull;
|
2020-09-30 15:48:47 +02:00
|
|
|
import androidx.core.graphics.ColorUtils;
|
2021-01-28 15:15:51 +01:00
|
|
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import androidx.recyclerview.widget.LinearSmoothScrollerCustom;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
2020-12-23 08:48:30 +01:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.AccountInstance;
|
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;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.ChatObject;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.ContactsController;
|
2016-06-24 12:27:15 +02:00
|
|
|
import org.telegram.messenger.DialogObject;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.FileLog;
|
2015-10-29 18:10:07 +01:00
|
|
|
import org.telegram.messenger.ImageLoader;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.ImageLocation;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.MediaDataController;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.MessageObject;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.NotificationsController;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.R;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.SharedConfig;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.messenger.UserConfig;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.UserObject;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.Utilities;
|
2019-01-23 18:03:33 +01:00
|
|
|
import org.telegram.messenger.XiaomiUtilities;
|
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;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.BackDrawable;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
|
|
|
import org.telegram.ui.ActionBar.MenuDrawable;
|
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
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;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.Adapters.FiltersView;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Cells.AccountSelectCell;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.Cells.ArchiveHintInnerCell;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.ui.Cells.DialogCell;
|
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;
|
2020-10-09 19:35:17 +02:00
|
|
|
import org.telegram.ui.Cells.DrawerActionCheckCell;
|
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;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.Cells.ShadowSectionCell;
|
2019-07-18 15:01:39 +02:00
|
|
|
import org.telegram.ui.Cells.TextCell;
|
2021-01-28 15:15:51 +01:00
|
|
|
import org.telegram.ui.Cells.TextInfoPrivacyCell;
|
2014-11-10 12:05:22 +01:00
|
|
|
import org.telegram.ui.Cells.UserCell;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Components.AlertsCreator;
|
|
|
|
import org.telegram.ui.Components.AnimatedArrowDrawable;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.ui.Components.AnimationProperties;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Components.AvatarDrawable;
|
|
|
|
import org.telegram.ui.Components.BackupImageView;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.Components.Bulletin;
|
|
|
|
import org.telegram.ui.Components.BulletinFactory;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.Components.ChatActivityEnterView;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.Components.ChatAvatarContainer;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.CombinedDrawable;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.Components.CubicBezierInterpolator;
|
|
|
|
import org.telegram.ui.Components.DialogsItemAnimator;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.Components.EditTextBoldCursor;
|
|
|
|
import org.telegram.ui.Components.FilterTabsView;
|
|
|
|
import org.telegram.ui.Components.FiltersListBottomSheet;
|
2021-01-28 15:15:51 +01:00
|
|
|
import org.telegram.ui.Components.FlickerLoadingView;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.FragmentContextView;
|
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;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.ui.Components.NumberTextView;
|
|
|
|
import org.telegram.ui.Components.PacmanAnimation;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.Components.ProxyDrawable;
|
2020-06-25 17:29:04 +02:00
|
|
|
import org.telegram.ui.Components.PullForegroundDrawable;
|
2019-07-18 15:01:39 +02:00
|
|
|
import org.telegram.ui.Components.RLottieDrawable;
|
2020-12-23 08:48:30 +01:00
|
|
|
import org.telegram.ui.Components.RLottieImageView;
|
2019-12-31 14:08:08 +01:00
|
|
|
import org.telegram.ui.Components.RecyclerAnimationScrollHelper;
|
2015-05-21 23:27:27 +02:00
|
|
|
import org.telegram.ui.Components.RecyclerListView;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.Components.SearchViewPager;
|
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;
|
2020-12-23 08:48:30 +01:00
|
|
|
import org.telegram.ui.Components.ViewPagerFixed;
|
2021-02-23 12:53:38 +01:00
|
|
|
import org.webrtc.RecyclerItemsEnterAnimator;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2021-02-04 18:59:00 +01:00
|
|
|
import kotlin.Unit;
|
|
|
|
import tw.nekomimi.nekogram.BottomBuilder;
|
2019-09-05 19:23:29 +02:00
|
|
|
import tw.nekomimi.nekogram.NekoConfig;
|
2020-06-25 17:29:04 +02:00
|
|
|
import tw.nekomimi.nekogram.utils.PrivacyUtil;
|
|
|
|
import tw.nekomimi.nekogram.utils.ProxyUtil;
|
2020-12-13 19:41:07 +01:00
|
|
|
import tw.nekomimi.nekogram.utils.UpdateUtil;
|
2020-07-26 18:07:20 +02:00
|
|
|
import tw.nekomimi.nekogram.utils.VibrateUtil;
|
2019-06-11 10:40:16 +02:00
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
private boolean canShowFilterTabsView;
|
|
|
|
private boolean filterTabsViewIsVisible;
|
2021-01-28 15:15:51 +01:00
|
|
|
private int initialSearchType = -1;
|
|
|
|
|
|
|
|
public void setShowSearch(String query, int i) {
|
|
|
|
if (!searching) {
|
|
|
|
initialSearchType = i;
|
|
|
|
actionBar.openSearchField(query, false);
|
|
|
|
} else {
|
|
|
|
if (!searchItem.getSearchField().getText().toString().equals(query)) {
|
|
|
|
searchItem.getSearchField().setText(query);
|
|
|
|
}
|
|
|
|
if (searchViewPager.getTabsView().getCurrentTabId() != i) {
|
|
|
|
searchViewPager.getTabsView().scrollToTab(i, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private class ViewPage extends FrameLayout {
|
|
|
|
private DialogsRecyclerView listView;
|
|
|
|
private LinearLayoutManager layoutManager;
|
|
|
|
private DialogsAdapter dialogsAdapter;
|
|
|
|
private ItemTouchHelper itemTouchhelper;
|
|
|
|
private SwipeController swipeController;
|
|
|
|
private int selectedType;
|
|
|
|
private PullForegroundDrawable pullForegroundDrawable;
|
|
|
|
private RecyclerAnimationScrollHelper scrollHelper;
|
|
|
|
private int dialogsType;
|
|
|
|
private int archivePullViewState;
|
2021-01-28 15:15:51 +01:00
|
|
|
private FlickerLoadingView progressView;
|
2020-03-30 14:00:09 +02:00
|
|
|
private int lastItemsCount;
|
2020-04-30 21:07:00 +02:00
|
|
|
private DialogsItemAnimator dialogsItemAnimator;
|
2021-02-23 12:53:38 +01:00
|
|
|
private RecyclerItemsEnterAnimator recyclerItemsEnterAnimator;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
public ViewPage(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isDefaultDialogType() {
|
|
|
|
return dialogsType == 0 || dialogsType == 7 || dialogsType == 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
private ViewPagerFixed.TabsView searchTabsView;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ViewPage[] viewPages;
|
2020-09-30 15:48:47 +02:00
|
|
|
private FiltersView filtersView;
|
2015-02-26 02:32:51 +01:00
|
|
|
private ActionBarMenuItem passcodeItem;
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean passcodeItemVisible;
|
2018-07-30 04:07:02 +02:00
|
|
|
private ActionBarMenuItem proxyItem;
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean proxyItemVisible;
|
2020-06-25 17:29:04 +02:00
|
|
|
private ActionBarMenuItem scanItem;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ActionBarMenuItem searchItem;
|
|
|
|
private ActionBarMenuItem doneItem;
|
2018-07-30 04:07:02 +02:00
|
|
|
private ProxyDrawable proxyDrawable;
|
2020-12-23 08:48:30 +01:00
|
|
|
private RLottieImageView floatingButton;
|
2019-01-23 18:03:33 +01:00
|
|
|
private FrameLayout floatingButtonContainer;
|
2020-09-30 15:48:47 +02:00
|
|
|
private ChatAvatarContainer avatarContainer;
|
2019-05-14 14:08:05 +02:00
|
|
|
private UndoView[] undoView = new UndoView[2];
|
2020-03-30 14:00:09 +02:00
|
|
|
private FilterTabsView filterTabsView;
|
|
|
|
private boolean askingForPermissions;
|
2021-01-28 15:15:51 +01:00
|
|
|
private RLottieDrawable passcodeDrawable;
|
|
|
|
private RLottieDrawable passcodeDrawable2;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private SearchViewPager searchViewPager;
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
private View blurredView;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private Paint scrimPaint;
|
|
|
|
private View scrimView;
|
|
|
|
private boolean scrimViewSelected;
|
|
|
|
private int[] scrimViewLocation = new int[2];
|
|
|
|
private AnimatorSet scrimAnimatorSet;
|
|
|
|
private ActionBarPopupWindow scrimPopupWindow;
|
|
|
|
private ActionBarMenuSubItem[] scrimPopupWindowItems;
|
|
|
|
|
|
|
|
private int initialDialogsType;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
private boolean checkingImportDialog;
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
private int messagesCount;
|
2020-01-23 07:15:40 +01:00
|
|
|
private int hasPoll;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private PacmanAnimation pacmanAnimation;
|
|
|
|
|
|
|
|
private DialogCell slidingView;
|
|
|
|
private DialogCell movingView;
|
|
|
|
private boolean allowMoving;
|
|
|
|
private boolean movingWas;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ArrayList<MessagesController.DialogFilter> movingDialogFilters = new ArrayList<>();
|
2019-05-14 14:08:05 +02:00
|
|
|
private boolean waitingForScrollFinished;
|
|
|
|
private boolean allowSwipeDuringCurrentTouch;
|
2019-12-31 14:08:08 +01:00
|
|
|
private boolean updatePullAfterScroll;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
private MenuDrawable menuDrawable;
|
|
|
|
private BackDrawable backDrawable;
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private Paint actionBarDefaultPaint = new Paint();
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private NumberTextView selectedDialogsCountTextView;
|
|
|
|
private ArrayList<View> actionModeViews = new ArrayList<>();
|
|
|
|
private ActionBarMenuItem deleteItem;
|
|
|
|
private ActionBarMenuItem pinItem;
|
2019-09-10 12:56:11 +02:00
|
|
|
private ActionBarMenuItem muteItem;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ActionBarMenuItem archive2Item;
|
|
|
|
private ActionBarMenuSubItem pin2Item;
|
2020-06-04 18:47:15 +02:00
|
|
|
private ActionBarMenuSubItem addToFolderItem;
|
|
|
|
private ActionBarMenuSubItem removeFromFolderItem;
|
2019-09-10 12:56:11 +02:00
|
|
|
private ActionBarMenuSubItem archiveItem;
|
2019-05-14 14:08:05 +02:00
|
|
|
private ActionBarMenuSubItem clearItem;
|
|
|
|
private ActionBarMenuSubItem readItem;
|
2020-02-13 19:26:53 +01:00
|
|
|
private ActionBarMenuSubItem blockItem;
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
private float additionalFloatingTranslation;
|
2019-12-31 14:08:08 +01:00
|
|
|
private float floatingButtonTranslation;
|
|
|
|
private float floatingButtonHideProgress;
|
|
|
|
|
|
|
|
private AnimatorSet searchAnimator;
|
2020-03-30 14:00:09 +02:00
|
|
|
private Animator tabsAlphaAnimator;
|
2020-09-30 15:48:47 +02:00
|
|
|
private float searchAnimationProgress;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
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
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private FragmentContextView fragmentLocationContextView;
|
|
|
|
private FragmentContextView fragmentContextView;
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
private ArrayList<TLRPC.Dialog> frozenDialogsList;
|
2019-05-14 14:08:05 +02:00
|
|
|
private boolean dialogsListFrozen;
|
|
|
|
private int dialogRemoveFinished;
|
|
|
|
private int dialogInsertFinished;
|
|
|
|
private int dialogChangeFinished;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private AlertDialog permissionDialog;
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean askAboutContacts = true;
|
|
|
|
|
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;
|
2021-01-28 15:15:51 +01:00
|
|
|
private boolean floatingForceVisible;
|
2014-11-06 22:34:47 +01:00
|
|
|
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;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean disableActionBarScrolling;
|
|
|
|
|
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;
|
2019-07-18 15:01:39 +02:00
|
|
|
private boolean resetDelegate = true;
|
2013-10-25 17:19:00 +02:00
|
|
|
|
2019-05-14 14:08:05 +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;
|
2020-09-30 15:48:47 +02:00
|
|
|
private String initialSearchString;
|
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;
|
2019-12-31 14:08:08 +01:00
|
|
|
private boolean afterSignup;
|
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
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private ArrayList<Long> selectedDialogs = new ArrayList<>();
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private int canReadCount;
|
|
|
|
private int canPinCount;
|
|
|
|
private int canMuteCount;
|
|
|
|
private int canUnmuteCount;
|
|
|
|
private int canClearCacheCount;
|
2020-02-13 19:26:53 +01:00
|
|
|
private int canReportSpamCount;
|
2020-03-30 14:00:09 +02:00
|
|
|
private int canUnarchiveCount;
|
2020-04-30 21:07:00 +02:00
|
|
|
private boolean canDeletePsaSelected;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
private int topPadding;
|
2021-02-06 12:40:02 +01:00
|
|
|
private int lastMeasuredTopPadding;
|
2019-05-14 14:08:05 +02:00
|
|
|
private int folderId;
|
|
|
|
|
|
|
|
private final static int pin = 100;
|
|
|
|
private final static int read = 101;
|
|
|
|
private final static int delete = 102;
|
|
|
|
private final static int clear = 103;
|
|
|
|
private final static int mute = 104;
|
|
|
|
private final static int archive = 105;
|
2020-02-13 19:26:53 +01:00
|
|
|
private final static int block = 106;
|
2020-03-30 14:00:09 +02:00
|
|
|
private final static int archive2 = 107;
|
|
|
|
private final static int pin2 = 108;
|
2020-06-04 18:47:15 +02:00
|
|
|
private final static int add_to_folder = 109;
|
|
|
|
private final static int remove_from_folder = 110;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
private final static int ARCHIVE_ITEM_STATE_PINNED = 0;
|
|
|
|
private final static int ARCHIVE_ITEM_STATE_SHOWED = 1;
|
|
|
|
private final static int ARCHIVE_ITEM_STATE_HIDDEN = 2;
|
|
|
|
|
|
|
|
private long startArchivePullingTime;
|
2019-06-04 12:14:50 +02:00
|
|
|
private boolean scrollingManually;
|
2019-12-31 14:08:08 +01:00
|
|
|
private boolean canShowHiddenArchive;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private AnimatorSet tabsAnimation;
|
|
|
|
private boolean tabsAnimationInProgress;
|
|
|
|
private boolean animatingForward;
|
|
|
|
private float additionalOffset;
|
|
|
|
private boolean backAnimation;
|
|
|
|
private int maximumVelocity;
|
|
|
|
private boolean startedTracking;
|
|
|
|
private boolean maybeStartTracking;
|
|
|
|
private static final Interpolator interpolator = t -> {
|
|
|
|
--t;
|
|
|
|
return t * t * t * t * t + 1.0F;
|
|
|
|
};
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private int animationIndex = -1;
|
|
|
|
private boolean searchIsShowed;
|
|
|
|
private boolean searchWasFullyShowed;
|
|
|
|
private boolean whiteActionBar;
|
2021-01-28 15:15:51 +01:00
|
|
|
private boolean searchFiltersWasShowed;
|
2020-09-30 15:48:47 +02:00
|
|
|
private float progressToActionMode;
|
2020-12-23 08:48:30 +01:00
|
|
|
private ValueAnimator actionBarColorAnimator;
|
|
|
|
|
|
|
|
private ValueAnimator filtersTabAnimator;
|
|
|
|
private float filterTabsProgress;
|
|
|
|
private float filterTabsMoveFrom;
|
|
|
|
private float tabsYOffset;
|
|
|
|
private float scrollAdditionalOffset;
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
public final Property<DialogsActivity, Float> SCROLL_Y = new AnimationProperties.FloatProperty<DialogsActivity>("animationValue") {
|
|
|
|
@Override
|
|
|
|
public void setValue(DialogsActivity object, float value) {
|
|
|
|
object.setScrollY(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Float get(DialogsActivity object) {
|
|
|
|
return actionBar.getTranslationY();
|
|
|
|
}
|
|
|
|
};
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-06-04 12:14:50 +02:00
|
|
|
private class ContentView extends SizeNotifierFrameLayout {
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private Paint actionBarSearchPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
private Paint windowBackgroundPaint = new Paint();
|
2019-05-14 14:08:05 +02:00
|
|
|
private int inputFieldHeight;
|
|
|
|
|
|
|
|
public ContentView(Context context) {
|
2020-09-30 15:48:47 +02:00
|
|
|
super(context);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private int startedTrackingPointerId;
|
|
|
|
private int startedTrackingX;
|
|
|
|
private int startedTrackingY;
|
|
|
|
private VelocityTracker velocityTracker;
|
|
|
|
private boolean globalIgnoreLayout;
|
|
|
|
private int[] pos = new int[2];
|
|
|
|
|
|
|
|
private boolean prepareForMoving(MotionEvent ev, boolean forward) {
|
|
|
|
int id = filterTabsView.getNextPageId(forward);
|
|
|
|
if (id < 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
|
maybeStartTracking = false;
|
|
|
|
startedTracking = true;
|
|
|
|
startedTrackingX = (int) (ev.getX() + additionalOffset);
|
|
|
|
actionBar.setEnabled(false);
|
|
|
|
filterTabsView.setEnabled(false);
|
|
|
|
viewPages[1].selectedType = id;
|
|
|
|
viewPages[1].setVisibility(View.VISIBLE);
|
|
|
|
animatingForward = forward;
|
|
|
|
showScrollbars(false);
|
|
|
|
switchToCurrentSelectedMode(true);
|
|
|
|
if (forward) {
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
|
|
|
|
} else {
|
|
|
|
viewPages[1].setTranslationX(-viewPages[0].getMeasuredWidth());
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setPadding(int left, int top, int right, int bottom) {
|
|
|
|
topPadding = top;
|
2020-09-30 15:48:47 +02:00
|
|
|
updateContextViewPosition();
|
|
|
|
if (whiteActionBar && searchViewPager != null) {
|
|
|
|
searchViewPager.setTranslationY(topPadding - lastMeasuredTopPadding);
|
|
|
|
} else {
|
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean checkTabsAnimationInProgress() {
|
|
|
|
if (tabsAnimationInProgress) {
|
|
|
|
boolean cancel = false;
|
|
|
|
if (backAnimation) {
|
|
|
|
if (Math.abs(viewPages[0].getTranslationX()) < 1) {
|
|
|
|
viewPages[0].setTranslationX(0);
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth() * (animatingForward ? 1 : -1));
|
|
|
|
cancel = true;
|
|
|
|
}
|
|
|
|
} else if (Math.abs(viewPages[1].getTranslationX()) < 1) {
|
|
|
|
viewPages[0].setTranslationX(viewPages[0].getMeasuredWidth() * (animatingForward ? -1 : 1));
|
|
|
|
viewPages[1].setTranslationX(0);
|
|
|
|
cancel = true;
|
|
|
|
}
|
|
|
|
if (cancel) {
|
|
|
|
showScrollbars(true);
|
|
|
|
if (tabsAnimation != null) {
|
|
|
|
tabsAnimation.cancel();
|
|
|
|
tabsAnimation = null;
|
|
|
|
}
|
|
|
|
tabsAnimationInProgress = false;
|
|
|
|
}
|
|
|
|
return tabsAnimationInProgress;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public int getActionBarFullHeight() {
|
|
|
|
float h = actionBar.getHeight();
|
|
|
|
float filtersTabsHeight = 0;
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() != GONE) {
|
2020-12-23 08:48:30 +01:00
|
|
|
filtersTabsHeight = filterTabsView.getMeasuredHeight() - (1f - filterTabsProgress) * filterTabsView.getMeasuredHeight();
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
float searchTabsHeight = 0;
|
|
|
|
if (searchTabsView != null && searchTabsView.getVisibility() != View.GONE) {
|
|
|
|
searchTabsHeight = searchTabsView.getMeasuredHeight();
|
|
|
|
}
|
|
|
|
h += filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress;
|
|
|
|
return (int) h;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (child == fragmentContextView && fragmentContextView.isCallStyle()) {
|
2020-12-23 08:48:30 +01:00
|
|
|
return true;
|
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
if (child == blurredView) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
boolean result;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (child == viewPages[0] || (viewPages.length > 1 && child == viewPages[1]) || child == fragmentContextView || child == fragmentLocationContextView || child == searchViewPager) {
|
2020-09-30 15:48:47 +02:00
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(0, -getY() + actionBar.getY() + getActionBarFullHeight(), getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
result = super.drawChild(canvas, child, drawingTime);
|
|
|
|
canvas.restore();
|
|
|
|
} else {
|
|
|
|
result = super.drawChild(canvas, child, drawingTime);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (child == actionBar && parentLayout != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
int y = (int) (actionBar.getY() + getActionBarFullHeight());
|
|
|
|
parentLayout.drawHeaderShadow(canvas, (int) (255 * (1f - searchAnimationProgress)), y);
|
|
|
|
if (searchAnimationProgress > 0) {
|
|
|
|
if (searchAnimationProgress < 1) {
|
|
|
|
int a = Theme.dividerPaint.getAlpha();
|
|
|
|
Theme.dividerPaint.setAlpha((int) (a * searchAnimationProgress));
|
|
|
|
canvas.drawLine(0, y, getMeasuredWidth(), y, Theme.dividerPaint);
|
|
|
|
Theme.dividerPaint.setAlpha(a);
|
|
|
|
} else {
|
|
|
|
canvas.drawLine(0, y, getMeasuredWidth(), y, Theme.dividerPaint);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void dispatchDraw(Canvas canvas) {
|
2020-09-30 15:48:47 +02:00
|
|
|
int actionBarHeight = getActionBarFullHeight();
|
|
|
|
int top;
|
|
|
|
if (inPreviewMode) {
|
|
|
|
top = AndroidUtilities.statusBarHeight;
|
|
|
|
} else {
|
2020-10-30 11:26:29 +01:00
|
|
|
top = (int) (-getY() + actionBar.getY());
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
if (whiteActionBar) {
|
|
|
|
if (searchAnimationProgress == 1f) {
|
|
|
|
actionBarSearchPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
if (searchTabsView != null) {
|
|
|
|
searchTabsView.setTranslationY(0);
|
|
|
|
searchTabsView.setAlpha(1f);
|
|
|
|
if (filtersView != null) {
|
|
|
|
filtersView.setTranslationY(0);
|
|
|
|
filtersView.setAlpha(1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (searchAnimationProgress == 0) {
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
filterTabsView.setTranslationY(actionBar.getTranslationY());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
canvas.drawRect(0, top, getMeasuredWidth(), top + actionBarHeight, searchAnimationProgress == 1f ? actionBarSearchPaint : actionBarDefaultPaint);
|
|
|
|
if (searchAnimationProgress > 0 && searchAnimationProgress < 1f) {
|
|
|
|
actionBarSearchPaint.setColor(ColorUtils.blendARGB(Theme.getColor(folderId == 0 ? Theme.key_actionBarDefault : Theme.key_actionBarDefaultArchived), Theme.getColor(Theme.key_windowBackgroundWhite), searchAnimationProgress));
|
|
|
|
if (searchIsShowed || !searchWasFullyShowed) {
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(0, top, getMeasuredWidth(), top + actionBarHeight);
|
|
|
|
float cX = getMeasuredWidth() - AndroidUtilities.dp(24);
|
|
|
|
int statusBarH = actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0;
|
|
|
|
float cY = statusBarH + (actionBar.getMeasuredHeight() - statusBarH) / 2f;
|
|
|
|
canvas.drawCircle(cX, cY, getMeasuredWidth() * 1.3f * searchAnimationProgress, actionBarSearchPaint);
|
|
|
|
canvas.restore();
|
|
|
|
} else {
|
|
|
|
canvas.drawRect(0, top, getMeasuredWidth(), top + actionBarHeight, actionBarSearchPaint);
|
|
|
|
}
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
filterTabsView.setTranslationY(actionBarHeight - (actionBar.getHeight() + filterTabsView.getMeasuredHeight()));
|
|
|
|
}
|
|
|
|
if (searchTabsView != null) {
|
|
|
|
float y = actionBarHeight - (actionBar.getHeight() + searchTabsView.getMeasuredHeight());
|
|
|
|
float alpha = searchAnimationProgress < 0.5f ? 0 : (searchAnimationProgress - 0.5f) / 0.5f;
|
|
|
|
searchTabsView.setTranslationY(y);
|
|
|
|
searchTabsView.setAlpha(alpha);
|
|
|
|
if (filtersView != null) {
|
|
|
|
filtersView.setTranslationY(y);
|
|
|
|
filtersView.setAlpha(alpha);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!inPreviewMode) {
|
|
|
|
if (progressToActionMode > 0) {
|
|
|
|
actionBarSearchPaint.setColor(ColorUtils.blendARGB(Theme.getColor(folderId == 0 ? Theme.key_actionBarDefault : Theme.key_actionBarDefaultArchived), Theme.getColor(Theme.key_windowBackgroundWhite), progressToActionMode));
|
|
|
|
canvas.drawRect(0, top, getMeasuredWidth(), top + actionBarHeight, actionBarSearchPaint);
|
|
|
|
} else {
|
|
|
|
canvas.drawRect(0, top, getMeasuredWidth(), top + actionBarHeight, actionBarDefaultPaint);
|
|
|
|
}
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
tabsYOffset = 0;
|
|
|
|
if (filtersTabAnimator != null && filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
2021-02-06 12:40:02 +01:00
|
|
|
tabsYOffset = -(1f - filterTabsProgress) * filterTabsView.getMeasuredHeight();
|
2020-12-23 08:48:30 +01:00
|
|
|
filterTabsView.setTranslationY(actionBar.getTranslationY() + tabsYOffset);
|
|
|
|
filterTabsView.setAlpha(filterTabsProgress);
|
|
|
|
viewPages[0].setTranslationY(-(1f - filterTabsProgress) * filterTabsMoveFrom);
|
|
|
|
} else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
filterTabsView.setTranslationY(actionBar.getTranslationY());
|
|
|
|
filterTabsView.setAlpha(1f);
|
|
|
|
}
|
|
|
|
updateContextViewPosition();
|
2020-03-30 14:00:09 +02:00
|
|
|
super.dispatchDraw(canvas);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (whiteActionBar && searchAnimationProgress > 0 && searchAnimationProgress < 1f && searchTabsView != null) {
|
|
|
|
windowBackgroundPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
windowBackgroundPaint.setAlpha((int) (windowBackgroundPaint.getAlpha() * searchAnimationProgress));
|
|
|
|
canvas.drawRect(0, top + actionBarHeight, getMeasuredWidth(), top + actionBar.getMeasuredHeight() + searchTabsView.getMeasuredHeight(), windowBackgroundPaint);
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (fragmentContextView != null && fragmentContextView.isCallStyle()) {
|
2020-12-23 08:48:30 +01:00
|
|
|
canvas.save();
|
|
|
|
canvas.translate(fragmentContextView.getX(), fragmentContextView.getY());
|
|
|
|
fragmentContextView.setDrawOverlay(true);
|
|
|
|
fragmentContextView.draw(canvas);
|
|
|
|
fragmentContextView.setDrawOverlay(false);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
if (blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
|
|
|
|
if (blurredView.getAlpha() != 1f) {
|
|
|
|
if (blurredView.getAlpha() != 0) {
|
|
|
|
canvas.saveLayerAlpha(blurredView.getLeft(), blurredView.getTop(), blurredView.getRight(), blurredView.getBottom(), (int) (255 * blurredView.getAlpha()), Canvas.ALL_SAVE_FLAG);
|
|
|
|
canvas.translate(blurredView.getLeft(), blurredView.getTop());
|
|
|
|
blurredView.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
blurredView.draw(canvas);
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (scrimView != null) {
|
|
|
|
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), scrimPaint);
|
|
|
|
canvas.save();
|
|
|
|
getLocationInWindow(pos);
|
|
|
|
canvas.translate(scrimViewLocation[0] - pos[0], scrimViewLocation[1] - (Build.VERSION.SDK_INT < 21 ? AndroidUtilities.statusBarHeight : 0));
|
|
|
|
scrimView.draw(canvas);
|
|
|
|
if (scrimViewSelected) {
|
|
|
|
Drawable drawable = filterTabsView.getSelectorDrawable();
|
|
|
|
canvas.translate(-scrimViewLocation[0], -drawable.getIntrinsicHeight() - 1);
|
|
|
|
drawable.draw(canvas);
|
|
|
|
}
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
|
|
|
|
setMeasuredDimension(widthSize, heightSize);
|
|
|
|
heightSize -= getPaddingTop();
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (doneItem != null) {
|
|
|
|
LayoutParams layoutParams = (LayoutParams) doneItem.getLayoutParams();
|
|
|
|
layoutParams.topMargin = actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0;
|
|
|
|
layoutParams.height = ActionBar.getCurrentActionBarHeight();
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
int keyboardSize = measureKeyboardHeight();
|
2019-05-14 14:08:05 +02:00
|
|
|
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;
|
|
|
|
}
|
2020-02-13 19:26:53 +01:00
|
|
|
|
|
|
|
if (SharedConfig.smoothKeyboard && commentView.isPopupShowing()) {
|
2020-09-30 15:48:47 +02:00
|
|
|
fragmentView.setTranslationY(0);
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a] != null) {
|
|
|
|
viewPages[a].setTranslationY(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!onlySelect) {
|
|
|
|
actionBar.setTranslationY(0);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setTranslationY(0);
|
2020-02-13 19:26:53 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < childCount; i++) {
|
|
|
|
View child = getChildAt(i);
|
|
|
|
if (child == null || child.getVisibility() == GONE || child == commentView || child == actionBar) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (child instanceof ViewPage) {
|
|
|
|
int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY);
|
|
|
|
int h;
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - AndroidUtilities.dp(44) - topPadding;
|
|
|
|
} else {
|
2020-04-10 16:47:50 +02:00
|
|
|
h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - ((onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward)) ? 0 : actionBar.getMeasuredHeight()) - topPadding;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
if (filtersTabAnimator != null && filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
h += filterTabsMoveFrom;
|
|
|
|
} else {
|
|
|
|
child.setTranslationY(0);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
child.measure(contentWidthSpec, View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h), View.MeasureSpec.EXACTLY));
|
|
|
|
child.setPivotX(child.getMeasuredWidth() / 2);
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (child == searchViewPager) {
|
|
|
|
searchViewPager.setTranslationY(0);
|
2019-05-14 14:08:05 +02:00
|
|
|
int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY);
|
2020-09-30 15:48:47 +02:00
|
|
|
int h = View.MeasureSpec.getSize(heightMeasureSpec) + keyboardSize;
|
2020-10-01 11:01:48 +02:00
|
|
|
int contentHeightSpec = View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward) ? 0 : actionBar.getMeasuredHeight()) - topPadding) - (searchTabsView == null ? 0 : AndroidUtilities.dp(44)), View.MeasureSpec.EXACTLY);
|
2019-05-14 14:08:05 +02:00
|
|
|
child.measure(contentWidthSpec, contentHeightSpec);
|
2019-12-31 14:08:08 +01:00
|
|
|
child.setPivotX(child.getMeasuredWidth() / 2);
|
2019-05-14 14:08:05 +02:00
|
|
|
} else if (commentView != null && commentView.isPopupView(child)) {
|
|
|
|
if (AndroidUtilities.isInMultiwindow) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
child.measure(View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(320), heightSize - inputFieldHeight - AndroidUtilities.statusBarHeight + getPaddingTop()), View.MeasureSpec.EXACTLY));
|
|
|
|
} else {
|
|
|
|
child.measure(View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(heightSize - inputFieldHeight - AndroidUtilities.statusBarHeight + getPaddingTop(), View.MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
child.measure(View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, View.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;
|
2020-09-30 15:48:47 +02:00
|
|
|
int keyboardSize = measureKeyboardHeight();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (tag != null && tag.equals(2)) {
|
2020-02-13 19:26:53 +01:00
|
|
|
paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? commentView.getEmojiPadding() : 0;
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
paddingBottom = 0;
|
|
|
|
}
|
|
|
|
setBottomClip(paddingBottom);
|
2020-09-30 15:48:47 +02:00
|
|
|
lastMeasuredTopPadding = topPadding;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
final View child = getChildAt(i);
|
|
|
|
if (child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final FrameLayout.LayoutParams lp = (FrameLayout.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();
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (child == filterTabsView || child == searchTabsView || child == filtersView) {
|
2020-03-30 14:00:09 +02:00
|
|
|
childTop = actionBar.getMeasuredHeight();
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (child == searchViewPager) {
|
2020-10-01 11:01:48 +02:00
|
|
|
childTop = (onlySelect && !(initialDialogsType == 3 && NekoConfig.showTabsOnForward) ? 0 : actionBar.getMeasuredHeight()) + topPadding + (searchTabsView == null ? 0 : AndroidUtilities.dp(44));
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (child instanceof ViewPage) {
|
2020-04-08 10:16:23 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
childTop = AndroidUtilities.dp(44);
|
|
|
|
} else {
|
|
|
|
childTop = actionBar.getMeasuredHeight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
childTop += topPadding;
|
|
|
|
} else if (child instanceof FragmentContextView) {
|
|
|
|
childTop += actionBar.getMeasuredHeight();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setKeyboardHeight(keyboardSize);
|
2019-05-14 14:08:05 +02:00
|
|
|
notifyHeightChanged();
|
2020-09-30 15:48:47 +02:00
|
|
|
updateContextViewPosition();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
|
|
int action = ev.getActionMasked();
|
2019-12-31 14:08:08 +01:00
|
|
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
allowMoving = true;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
return checkTabsAnimationInProgress() || filterTabsView != null && filterTabsView.isAnimatingIndicator() || onTouchEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
|
|
|
if (maybeStartTracking && !startedTracking) {
|
|
|
|
onTouchEvent(null);
|
|
|
|
}
|
|
|
|
super.requestDisallowInterceptTouchEvent(disallowIntercept);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent ev) {
|
2020-06-25 17:29:04 +02:00
|
|
|
if (filterTabsView != null && !filterTabsView.isEditing() && !searching &&
|
2020-03-30 14:00:09 +02:00
|
|
|
!parentLayout.checkTransitionAnimation() && !parentLayout.isInPreviewMode() && !parentLayout.isPreviewOpenAnimationInProgress() && !parentLayout.getDrawerLayoutContainer().isDrawerOpened() &&
|
|
|
|
(ev == null || startedTracking || ev.getY() > actionBar.getMeasuredHeight() + actionBar.getTranslationY())) {
|
|
|
|
if (ev != null) {
|
|
|
|
if (velocityTracker == null) {
|
|
|
|
velocityTracker = VelocityTracker.obtain();
|
|
|
|
}
|
|
|
|
velocityTracker.addMovement(ev);
|
|
|
|
}
|
|
|
|
if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && checkTabsAnimationInProgress()) {
|
|
|
|
startedTracking = true;
|
|
|
|
startedTrackingPointerId = ev.getPointerId(0);
|
|
|
|
startedTrackingX = (int) ev.getX();
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(false);
|
|
|
|
if (animatingForward) {
|
|
|
|
if (startedTrackingX < viewPages[0].getMeasuredWidth() + viewPages[0].getTranslationX()) {
|
|
|
|
additionalOffset = viewPages[0].getTranslationX();
|
|
|
|
} else {
|
|
|
|
ViewPage page = viewPages[0];
|
|
|
|
viewPages[0] = viewPages[1];
|
|
|
|
viewPages[1] = page;
|
|
|
|
animatingForward = false;
|
|
|
|
additionalOffset = viewPages[0].getTranslationX();
|
|
|
|
filterTabsView.selectTabWithId(viewPages[0].selectedType, 1f);
|
|
|
|
filterTabsView.selectTabWithId(viewPages[1].selectedType, additionalOffset / viewPages[0].getMeasuredWidth());
|
|
|
|
switchToCurrentSelectedMode(true);
|
2020-12-23 08:48:30 +01:00
|
|
|
viewPages[0].dialogsAdapter.resume();
|
|
|
|
viewPages[1].dialogsAdapter.pause();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (startedTrackingX < viewPages[1].getMeasuredWidth() + viewPages[1].getTranslationX()) {
|
|
|
|
ViewPage page = viewPages[0];
|
|
|
|
viewPages[0] = viewPages[1];
|
|
|
|
viewPages[1] = page;
|
|
|
|
animatingForward = true;
|
|
|
|
additionalOffset = viewPages[0].getTranslationX();
|
|
|
|
filterTabsView.selectTabWithId(viewPages[0].selectedType, 1f);
|
|
|
|
filterTabsView.selectTabWithId(viewPages[1].selectedType, -additionalOffset / viewPages[0].getMeasuredWidth());
|
|
|
|
switchToCurrentSelectedMode(true);
|
2020-12-23 08:48:30 +01:00
|
|
|
viewPages[0].dialogsAdapter.resume();
|
|
|
|
viewPages[1].dialogsAdapter.pause();
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
|
|
|
additionalOffset = viewPages[0].getTranslationX();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tabsAnimation.removeAllListeners();
|
|
|
|
tabsAnimation.cancel();
|
|
|
|
tabsAnimationInProgress = false;
|
|
|
|
} else if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
additionalOffset = 0;
|
|
|
|
}
|
|
|
|
if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && !startedTracking && !maybeStartTracking && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
startedTrackingPointerId = ev.getPointerId(0);
|
|
|
|
maybeStartTracking = true;
|
|
|
|
startedTrackingX = (int) ev.getX();
|
|
|
|
startedTrackingY = (int) ev.getY();
|
|
|
|
velocityTracker.clear();
|
|
|
|
} else if (ev != null && ev.getAction() == MotionEvent.ACTION_MOVE && ev.getPointerId(0) == startedTrackingPointerId) {
|
|
|
|
int dx = (int) (ev.getX() - startedTrackingX + additionalOffset);
|
|
|
|
int dy = Math.abs((int) ev.getY() - startedTrackingY);
|
|
|
|
if (startedTracking && (animatingForward && dx > 0 || !animatingForward && dx < 0)) {
|
|
|
|
if (!prepareForMoving(ev, dx < 0)) {
|
|
|
|
maybeStartTracking = true;
|
|
|
|
startedTracking = false;
|
|
|
|
viewPages[0].setTranslationX(0);
|
|
|
|
viewPages[1].setTranslationX(animatingForward ? viewPages[0].getMeasuredWidth() : -viewPages[0].getMeasuredWidth());
|
|
|
|
filterTabsView.selectTabWithId(viewPages[1].selectedType, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (maybeStartTracking && !startedTracking) {
|
|
|
|
float touchSlop = AndroidUtilities.getPixelsInCM(0.3f, true);
|
|
|
|
int dxLocal = (int) (ev.getX() - startedTrackingX);
|
|
|
|
if (Math.abs(dxLocal) >= touchSlop && Math.abs(dxLocal) > dy) {
|
|
|
|
prepareForMoving(ev, dx < 0);
|
|
|
|
}
|
|
|
|
} else if (startedTracking) {
|
|
|
|
viewPages[0].setTranslationX(dx);
|
|
|
|
if (animatingForward) {
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth() + dx);
|
|
|
|
} else {
|
|
|
|
viewPages[1].setTranslationX(dx - viewPages[0].getMeasuredWidth());
|
|
|
|
}
|
|
|
|
float scrollProgress = Math.abs(dx) / (float) viewPages[0].getMeasuredWidth();
|
|
|
|
filterTabsView.selectTabWithId(viewPages[1].selectedType, scrollProgress);
|
|
|
|
}
|
|
|
|
} else if (ev == null || ev.getPointerId(0) == startedTrackingPointerId && (ev.getAction() == MotionEvent.ACTION_CANCEL || ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_POINTER_UP)) {
|
|
|
|
velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
|
|
|
|
float velX;
|
|
|
|
float velY;
|
|
|
|
if (ev != null && ev.getAction() != MotionEvent.ACTION_CANCEL) {
|
|
|
|
velX = velocityTracker.getXVelocity();
|
|
|
|
velY = velocityTracker.getYVelocity();
|
|
|
|
if (!startedTracking) {
|
|
|
|
if (Math.abs(velX) >= 3000 && Math.abs(velX) > Math.abs(velY)) {
|
|
|
|
prepareForMoving(ev, velX < 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
velX = 0;
|
|
|
|
velY = 0;
|
|
|
|
}
|
|
|
|
if (startedTracking) {
|
|
|
|
float x = viewPages[0].getX();
|
|
|
|
tabsAnimation = new AnimatorSet();
|
|
|
|
if (additionalOffset != 0) {
|
|
|
|
if (Math.abs(velX) > 1500) {
|
|
|
|
backAnimation = animatingForward ? velX > 0 : velX < 0;
|
|
|
|
} else {
|
|
|
|
if (animatingForward) {
|
|
|
|
backAnimation = (viewPages[1].getX() > (viewPages[0].getMeasuredWidth() >> 1));
|
|
|
|
} else {
|
|
|
|
backAnimation = (viewPages[0].getX() < (viewPages[0].getMeasuredWidth() >> 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
backAnimation = Math.abs(x) < viewPages[0].getMeasuredWidth() / 3.0f && (Math.abs(velX) < 3500 || Math.abs(velX) < Math.abs(velY));
|
|
|
|
}
|
|
|
|
float distToMove;
|
|
|
|
float dx;
|
|
|
|
if (backAnimation) {
|
|
|
|
dx = Math.abs(x);
|
|
|
|
if (animatingForward) {
|
|
|
|
tabsAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(viewPages[0], View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(viewPages[1], View.TRANSLATION_X, viewPages[1].getMeasuredWidth())
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
tabsAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(viewPages[0], View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(viewPages[1], View.TRANSLATION_X, -viewPages[1].getMeasuredWidth())
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
dx = viewPages[0].getMeasuredWidth() - Math.abs(x);
|
|
|
|
if (animatingForward) {
|
|
|
|
tabsAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(viewPages[0], View.TRANSLATION_X, -viewPages[0].getMeasuredWidth()),
|
|
|
|
ObjectAnimator.ofFloat(viewPages[1], View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
tabsAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(viewPages[0], View.TRANSLATION_X, viewPages[0].getMeasuredWidth()),
|
|
|
|
ObjectAnimator.ofFloat(viewPages[1], View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tabsAnimation.setInterpolator(interpolator);
|
|
|
|
|
|
|
|
int width = getMeasuredWidth();
|
|
|
|
int halfWidth = width / 2;
|
|
|
|
float distanceRatio = Math.min(1.0f, 1.0f * dx / (float) width);
|
|
|
|
float distance = (float) halfWidth + (float) halfWidth * AndroidUtilities.distanceInfluenceForSnapDuration(distanceRatio);
|
|
|
|
velX = Math.abs(velX);
|
|
|
|
int duration;
|
|
|
|
if (velX > 0) {
|
|
|
|
duration = 4 * Math.round(1000.0f * Math.abs(distance / velX));
|
|
|
|
} else {
|
|
|
|
float pageDelta = dx / getMeasuredWidth();
|
|
|
|
duration = (int) ((pageDelta + 1.0f) * 100.0f);
|
|
|
|
}
|
|
|
|
duration = Math.max(150, Math.min(duration, 600));
|
|
|
|
|
|
|
|
tabsAnimation.setDuration(duration);
|
|
|
|
tabsAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animator) {
|
|
|
|
tabsAnimation = null;
|
|
|
|
if (!backAnimation) {
|
|
|
|
ViewPage tempPage = viewPages[0];
|
|
|
|
viewPages[0] = viewPages[1];
|
|
|
|
viewPages[1] = tempPage;
|
|
|
|
filterTabsView.selectTabWithId(viewPages[0].selectedType, 1.0f);
|
|
|
|
updateCounters(false);
|
2020-12-23 08:48:30 +01:00
|
|
|
viewPages[0].dialogsAdapter.resume();
|
|
|
|
viewPages[1].dialogsAdapter.pause();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
if (parentLayout != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
viewPages[1].setVisibility(View.GONE);
|
|
|
|
showScrollbars(true);
|
|
|
|
tabsAnimationInProgress = false;
|
|
|
|
maybeStartTracking = false;
|
|
|
|
actionBar.setEnabled(true);
|
|
|
|
filterTabsView.setEnabled(true);
|
|
|
|
checkListLoad(viewPages[0]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
tabsAnimation.start();
|
|
|
|
tabsAnimationInProgress = true;
|
|
|
|
startedTracking = false;
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed);
|
2020-03-30 14:00:09 +02:00
|
|
|
maybeStartTracking = false;
|
|
|
|
actionBar.setEnabled(true);
|
|
|
|
filterTabsView.setEnabled(true);
|
|
|
|
}
|
|
|
|
if (velocityTracker != null) {
|
|
|
|
velocityTracker.recycle();
|
|
|
|
velocityTracker = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return startedTracking;
|
|
|
|
}
|
|
|
|
return false;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasOverlappingRendering() {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static float viewOffset = 0.0f;
|
|
|
|
|
|
|
|
public class DialogsRecyclerView extends RecyclerListView {
|
|
|
|
|
|
|
|
private boolean firstLayout = true;
|
|
|
|
private boolean ignoreLayout;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ViewPage parentPage;
|
|
|
|
private int appliedPaddingTop;
|
2020-12-23 08:48:30 +01:00
|
|
|
private int lastTop;
|
|
|
|
private int lastListPadding;
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
public DialogsRecyclerView(Context context, ViewPage page) {
|
2019-12-31 14:08:08 +01:00
|
|
|
super(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage = page;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
2021-01-30 07:18:23 +01:00
|
|
|
@Override
|
|
|
|
protected boolean updateEmptyViewAnimated() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
public void setViewsOffset(float viewOffset) {
|
|
|
|
DialogsActivity.viewOffset = viewOffset;
|
|
|
|
int n = getChildCount();
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
getChildAt(i).setTranslationY(viewOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectorPosition != NO_POSITION) {
|
2020-03-30 14:00:09 +02:00
|
|
|
View v = getLayoutManager().findViewByPosition(selectorPosition);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (v != null) {
|
|
|
|
selectorRect.set(v.getLeft(), (int) (v.getTop() + viewOffset), v.getRight(), (int) (v.getBottom() + viewOffset));
|
|
|
|
selectorDrawable.setBounds(selectorRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getViewOffset() {
|
|
|
|
return viewOffset;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void addView(View child, int index, ViewGroup.LayoutParams params) {
|
|
|
|
super.addView(child, index, params);
|
|
|
|
child.setTranslationY(viewOffset);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void removeView(View view) {
|
|
|
|
super.removeView(view);
|
|
|
|
view.setTranslationY(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDraw(Canvas canvas) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentPage.pullForegroundDrawable != null && viewOffset != 0) {
|
|
|
|
int pTop = getPaddingTop();
|
|
|
|
if (pTop != 0) {
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(0, pTop);
|
|
|
|
}
|
|
|
|
parentPage.pullForegroundDrawable.drawOverScroll(canvas);
|
|
|
|
if (pTop != 0) {
|
|
|
|
canvas.restore();
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
super.onDraw(canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void dispatchDraw(Canvas canvas) {
|
2021-02-23 12:53:38 +01:00
|
|
|
parentPage.recyclerItemsEnterAnimator.dispatchDraw();
|
2019-12-31 14:08:08 +01:00
|
|
|
super.dispatchDraw(canvas);
|
|
|
|
if (slidingView != null && pacmanAnimation != null) {
|
|
|
|
pacmanAnimation.draw(canvas, slidingView.getTop() + slidingView.getMeasuredHeight() / 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setAdapter(RecyclerView.Adapter adapter) {
|
|
|
|
super.setAdapter(adapter);
|
|
|
|
firstLayout = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkIfAdapterValid() {
|
2020-03-30 14:00:09 +02:00
|
|
|
RecyclerView.Adapter adapter = getAdapter();
|
|
|
|
if (parentPage.lastItemsCount != adapter.getItemCount()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
ignoreLayout = true;
|
2020-03-30 14:00:09 +02:00
|
|
|
adapter.notifyDataSetChanged();
|
2019-12-31 14:08:08 +01:00
|
|
|
ignoreLayout = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-30 14:00:09 +02:00
|
|
|
protected void onMeasure(int widthSpec, int heightSpec) {
|
|
|
|
int t = 0;
|
2020-04-08 10:16:23 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
t = AndroidUtilities.dp(44);
|
|
|
|
} else {
|
|
|
|
t = actionBar.getMeasuredHeight();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int pos = parentPage.layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (pos != RecyclerView.NO_POSITION) {
|
|
|
|
RecyclerView.ViewHolder holder = parentPage.listView.findViewHolderForAdapterPosition(pos);
|
|
|
|
if (holder != null) {
|
|
|
|
int top = holder.itemView.getTop();
|
|
|
|
|
|
|
|
ignoreLayout = true;
|
|
|
|
parentPage.layoutManager.scrollToPositionWithOffset(pos, (int) (top - lastListPadding + scrollAdditionalOffset));
|
|
|
|
ignoreLayout = false;
|
|
|
|
}
|
|
|
|
}
|
2020-12-23 19:00:15 +01:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-03-30 14:00:09 +02:00
|
|
|
ignoreLayout = true;
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) {
|
|
|
|
t = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0);
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
t = inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
setTopGlowOffset(t);
|
|
|
|
setPadding(0, t, 0, 0);
|
2021-01-28 15:15:51 +01:00
|
|
|
parentPage.progressView.setPaddingTop(t);
|
2020-03-30 14:00:09 +02:00
|
|
|
ignoreLayout = false;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (firstLayout && getMessagesController().dialogsLoaded) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentPage.dialogsType == 0 && hasHiddenArchive()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
ignoreLayout = true;
|
2020-03-30 14:00:09 +02:00
|
|
|
LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
|
|
|
|
layoutManager.scrollToPositionWithOffset(1, (int) actionBar.getTranslationY());
|
2019-12-31 14:08:08 +01:00
|
|
|
ignoreLayout = false;
|
|
|
|
}
|
|
|
|
firstLayout = false;
|
|
|
|
}
|
|
|
|
checkIfAdapterValid();
|
|
|
|
super.onMeasure(widthSpec, heightSpec);
|
2020-04-08 10:16:23 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (appliedPaddingTop != t && viewPages != null && viewPages.length > 1) {
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
super.onLayout(changed, l, t, r, b);
|
2020-12-23 08:48:30 +01:00
|
|
|
lastListPadding = getPaddingTop();
|
|
|
|
lastTop = t;
|
|
|
|
scrollAdditionalOffset = 0;
|
|
|
|
|
2020-04-30 21:07:00 +02:00
|
|
|
if ((dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) && !parentPage.dialogsItemAnimator.isRunning()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
onDialogAnimationFinished();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestLayout() {
|
|
|
|
if (ignoreLayout) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
super.requestLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void toggleArchiveHidden(boolean action, DialogCell dialogCell) {
|
|
|
|
SharedConfig.toggleArchiveHidden();
|
|
|
|
if (SharedConfig.archiveHidden) {
|
|
|
|
waitingForScrollFinished = true;
|
|
|
|
if (dialogCell != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
disableActionBarScrolling = true;
|
|
|
|
smoothScrollBy(0, (dialogCell.getMeasuredHeight() + (dialogCell.getTop() - getPaddingTop())), CubicBezierInterpolator.EASE_OUT);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (action) {
|
|
|
|
updatePullAfterScroll = true;
|
|
|
|
} else {
|
|
|
|
updatePullState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getUndoView().showWithAction(0, UndoView.ACTION_ARCHIVE_HIDDEN, null, null);
|
|
|
|
} else {
|
|
|
|
getUndoView().showWithAction(0, UndoView.ACTION_ARCHIVE_PINNED, null, null);
|
|
|
|
updatePullState();
|
|
|
|
if (action && dialogCell != null) {
|
|
|
|
dialogCell.resetPinnedArchiveState();
|
|
|
|
dialogCell.invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updatePullState() {
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.archivePullViewState = SharedConfig.archiveHidden ? ARCHIVE_ITEM_STATE_HIDDEN : ARCHIVE_ITEM_STATE_PINNED;
|
|
|
|
if (parentPage.pullForegroundDrawable != null) {
|
|
|
|
parentPage.pullForegroundDrawable.setWillDraw(parentPage.archivePullViewState != ARCHIVE_ITEM_STATE_PINNED);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent e) {
|
2020-07-26 10:03:38 +02:00
|
|
|
if (fastScrollAnimationRunning || waitingForScrollFinished || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int action = e.getAction();
|
|
|
|
if (action == MotionEvent.ACTION_DOWN) {
|
2020-03-30 14:00:09 +02:00
|
|
|
setOverScrollMode(View.OVER_SCROLL_ALWAYS);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!parentPage.itemTouchhelper.isIdle() && parentPage.swipeController.swipingFolder) {
|
|
|
|
parentPage.swipeController.swipeFolderBack = true;
|
|
|
|
if (parentPage.itemTouchhelper.checkHorizontalSwipe(null, ItemTouchHelper.LEFT) != 0) {
|
2019-12-31 14:08:08 +01:00
|
|
|
toggleArchiveHidden(false, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean result = super.onTouchEvent(e);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentPage.dialogsType == 0 && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) && parentPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && hasHiddenArchive()) {
|
|
|
|
LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager();
|
2019-12-31 14:08:08 +01:00
|
|
|
int currentPosition = layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (currentPosition == 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
int pTop = getPaddingTop();
|
2019-12-31 14:08:08 +01:00
|
|
|
View view = layoutManager.findViewByPosition(currentPosition);
|
|
|
|
int height = (int) (AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72) * PullForegroundDrawable.SNAP_HEIGHT);
|
2020-03-30 14:00:09 +02:00
|
|
|
int diff = (view.getTop() - pTop) + view.getMeasuredHeight();
|
2019-12-31 14:08:08 +01:00
|
|
|
if (view != null) {
|
|
|
|
long pullingTime = System.currentTimeMillis() - startArchivePullingTime;
|
|
|
|
if (diff < height || pullingTime < PullForegroundDrawable.minPullingTime) {
|
2020-03-30 14:00:09 +02:00
|
|
|
disableActionBarScrolling = true;
|
|
|
|
smoothScrollBy(0, diff, CubicBezierInterpolator.EASE_OUT_QUINT);
|
|
|
|
parentPage.archivePullViewState = ARCHIVE_ITEM_STATE_HIDDEN;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentPage.archivePullViewState != ARCHIVE_ITEM_STATE_SHOWED) {
|
|
|
|
if (getViewOffset() == 0) {
|
|
|
|
disableActionBarScrolling = true;
|
|
|
|
smoothScrollBy(0, (view.getTop() - pTop), CubicBezierInterpolator.EASE_OUT_QUINT);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
if (!canShowHiddenArchive) {
|
|
|
|
canShowHiddenArchive = true;
|
2020-07-26 18:07:20 +02:00
|
|
|
if (!NekoConfig.disableVibration) {
|
|
|
|
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentPage.pullForegroundDrawable != null) {
|
|
|
|
parentPage.pullForegroundDrawable.colorize(true);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
((DialogCell) view).startOutAnimation();
|
2020-03-30 15:25:47 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED;
|
2020-02-20 13:35:34 +01:00
|
|
|
|
|
|
|
if (NekoConfig.openArchiveOnPull) {
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
// Open the folder.
|
|
|
|
// Delay was taken from PullForegroundDrawable::startOutAnimation().
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("folderId", 1); // 1 is the ID of the archive folder.
|
|
|
|
args.putBoolean("onlySelect", onlySelect);
|
|
|
|
DialogsActivity dialogsActivity = new DialogsActivity(args);
|
|
|
|
dialogsActivity.setDelegate(delegate);
|
|
|
|
presentFragment(dialogsActivity, onlySelect);
|
|
|
|
}, 200);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (getViewOffset() != 0) {
|
|
|
|
ValueAnimator valueAnimator = ValueAnimator.ofFloat(getViewOffset(), 0f);
|
|
|
|
valueAnimator.addUpdateListener(animation -> setViewsOffset((float) animation.getAnimatedValue()));
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
valueAnimator.setDuration(Math.max(100, (long) (350f - 120f * (getViewOffset() / PullForegroundDrawable.getMaxOverscroll()))));
|
2019-12-31 14:08:08 +01:00
|
|
|
valueAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
|
2020-03-30 14:00:09 +02:00
|
|
|
setScrollEnabled(false);
|
2019-12-31 14:08:08 +01:00
|
|
|
valueAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
super.onAnimationEnd(animation);
|
2020-03-30 14:00:09 +02:00
|
|
|
setScrollEnabled(true);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
valueAnimator.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent e) {
|
2020-07-26 10:03:38 +02:00
|
|
|
if (fastScrollAnimationRunning || waitingForScrollFinished || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (e.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
allowSwipeDuringCurrentTouch = !actionBar.isActionModeShowed();
|
|
|
|
checkIfAdapterValid();
|
|
|
|
}
|
|
|
|
return super.onInterceptTouchEvent(e);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private class SwipeController extends ItemTouchHelper.Callback {
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
private RectF buttonInstance;
|
|
|
|
private RecyclerView.ViewHolder currentItemViewHolder;
|
|
|
|
private boolean swipingFolder;
|
|
|
|
private boolean swipeFolderBack;
|
2020-03-30 14:00:09 +02:00
|
|
|
private ViewPage parentPage;
|
|
|
|
|
|
|
|
public SwipeController(ViewPage page) {
|
|
|
|
parentPage = page;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
|
2020-04-30 21:07:00 +02:00
|
|
|
if (waitingForDialogsAnimationEnd(parentPage) || parentLayout != null && parentLayout.isInPreviewMode()) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (swipingFolder && swipeFolderBack) {
|
|
|
|
swipingFolder = false;
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!onlySelect && parentPage.isDefaultDialogType() && slidingView == null && viewHolder.itemView instanceof DialogCell) {
|
2019-05-14 14:08:05 +02:00
|
|
|
DialogCell dialogCell = (DialogCell) viewHolder.itemView;
|
|
|
|
long dialogId = dialogCell.getDialogId();
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(dialogId);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!allowMoving || dialog == null || !isDialogPinned(dialog) || DialogObject.isFolderDialogId(dialogId)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
movingView = (DialogCell) viewHolder.itemView;
|
|
|
|
movingView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
return makeMovementFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0);
|
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE || !allowSwipeDuringCurrentTouch || dialogId == getUserConfig().clientUserId || dialogId == 777000 || getMessagesController().isPromoDialog(dialogId, false) && getMessagesController().promoDialogType != MessagesController.PROMO_TYPE_PSA) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
swipeFolderBack = false;
|
|
|
|
swipingFolder = SharedConfig.archiveHidden && DialogObject.isFolderDialogId(dialogCell.getDialogId());
|
|
|
|
dialogCell.setSliding(true);
|
|
|
|
return makeMovementFlags(0, ItemTouchHelper.LEFT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) {
|
|
|
|
if (!(target.itemView instanceof DialogCell)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
DialogCell dialogCell = (DialogCell) target.itemView;
|
|
|
|
long dialogId = dialogCell.getDialogId();
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(dialogId);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (dialog == null || !isDialogPinned(dialog) || DialogObject.isFolderDialogId(dialogId)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int fromIndex = source.getAdapterPosition();
|
|
|
|
int toIndex = target.getAdapterPosition();
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.dialogsAdapter.notifyItemMoved(fromIndex, toIndex);
|
2019-05-14 14:08:05 +02:00
|
|
|
updateDialogIndices();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) {
|
|
|
|
MessagesController.DialogFilter filter = getMessagesController().selectedDialogFilter[viewPages[0].dialogsType == 8 ? 1 : 0];
|
|
|
|
if (!movingDialogFilters.contains(filter)) {
|
|
|
|
movingDialogFilters.add(filter);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
movingWas = true;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int convertToAbsoluteDirection(int flags, int layoutDirection) {
|
|
|
|
if (swipeFolderBack) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return super.convertToAbsoluteDirection(flags, layoutDirection);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
|
|
|
|
if (viewHolder != null) {
|
|
|
|
DialogCell dialogCell = (DialogCell) viewHolder.itemView;
|
|
|
|
long dialogId = dialogCell.getDialogId();
|
|
|
|
if (DialogObject.isFolderDialogId(dialogId)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.listView.toggleArchiveHidden(false, dialogCell);
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-01-30 07:18:23 +01:00
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(dialogId);
|
|
|
|
if (dialog == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
slidingView = dialogCell;
|
|
|
|
int position = viewHolder.getAdapterPosition();
|
2020-03-30 14:00:09 +02:00
|
|
|
int count = parentPage.dialogsAdapter.getItemCount();
|
2019-05-14 14:08:05 +02:00
|
|
|
Runnable finishRunnable = () -> {
|
2019-12-31 20:46:59 +01:00
|
|
|
if (frozenDialogsList == null) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-30 07:18:23 +01:00
|
|
|
frozenDialogsList.remove(dialog);
|
2019-05-14 14:08:05 +02:00
|
|
|
int pinnedNum = dialog.pinnedNum;
|
|
|
|
slidingView = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.listView.invalidate();
|
|
|
|
int lastItemPosition = parentPage.layoutManager.findLastVisibleItemPosition();
|
2019-12-31 14:08:08 +01:00
|
|
|
if (lastItemPosition == count - 1) {
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.layoutManager.findViewByPosition(lastItemPosition).requestLayout();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
if (getMessagesController().isPromoDialog(dialog.id, false)) {
|
|
|
|
getMessagesController().hidePromoDialog();
|
|
|
|
parentPage.dialogsItemAnimator.prepareForRemove();
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.lastItemsCount--;
|
|
|
|
parentPage.dialogsAdapter.notifyItemRemoved(position);
|
2019-05-14 14:08:05 +02:00
|
|
|
dialogRemoveFinished = 2;
|
2020-04-30 21:07:00 +02:00
|
|
|
} else {
|
|
|
|
int added = getMessagesController().addDialogToFolder(dialog.id, folderId == 0 ? 1 : 0, -1, 0);
|
|
|
|
if (added != 2 || position != 0) {
|
|
|
|
parentPage.dialogsItemAnimator.prepareForRemove();
|
|
|
|
parentPage.lastItemsCount--;
|
|
|
|
parentPage.dialogsAdapter.notifyItemRemoved(position);
|
|
|
|
dialogRemoveFinished = 2;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
if (folderId == 0) {
|
|
|
|
if (added == 2) {
|
|
|
|
parentPage.dialogsItemAnimator.prepareForRemove();
|
|
|
|
if (position == 0) {
|
|
|
|
dialogChangeFinished = 2;
|
2019-05-14 14:08:05 +02:00
|
|
|
setDialogsListFrozen(true);
|
2020-04-30 21:07:00 +02:00
|
|
|
parentPage.dialogsAdapter.notifyItemChanged(0);
|
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.lastItemsCount++;
|
2020-04-30 21:07:00 +02:00
|
|
|
parentPage.dialogsAdapter.notifyItemInserted(0);
|
|
|
|
if (!SharedConfig.archiveHidden && parentPage.layoutManager.findFirstVisibleItemPosition() == 0) {
|
|
|
|
disableActionBarScrolling = true;
|
|
|
|
parentPage.listView.smoothScrollBy(0, -AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getDialogsArray(currentAccount, parentPage.dialogsType, folderId, false);
|
|
|
|
frozenDialogsList.add(0, dialogs.get(0));
|
|
|
|
} else if (added == 1) {
|
|
|
|
RecyclerView.ViewHolder holder = parentPage.listView.findViewHolderForAdapterPosition(0);
|
|
|
|
if (holder != null && holder.itemView instanceof DialogCell) {
|
|
|
|
DialogCell cell = (DialogCell) holder.itemView;
|
|
|
|
cell.checkCurrentDialogIndex(true);
|
|
|
|
cell.animateArchiveAvatar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
|
|
|
boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden;
|
|
|
|
if (!hintShowed) {
|
2020-06-25 17:29:04 +02:00
|
|
|
preferences.edit().putBoolean("archivehint_l", true).apply();
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
|
|
|
getUndoView().showWithAction(dialog.id, hintShowed ? UndoView.ACTION_ARCHIVE : UndoView.ACTION_ARCHIVE_HINT, null, () -> {
|
|
|
|
dialogsListFrozen = true;
|
|
|
|
getMessagesController().addDialogToFolder(dialog.id, 0, pinnedNum, 0);
|
|
|
|
dialogsListFrozen = false;
|
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getMessagesController().getDialogs(0);
|
|
|
|
int index = dialogs.indexOf(dialog);
|
|
|
|
if (index >= 0) {
|
|
|
|
ArrayList<TLRPC.Dialog> archivedDialogs = getMessagesController().getDialogs(1);
|
|
|
|
if (!archivedDialogs.isEmpty() || index != 1) {
|
|
|
|
dialogInsertFinished = 2;
|
2019-05-14 14:08:05 +02:00
|
|
|
setDialogsListFrozen(true);
|
2020-04-30 21:07:00 +02:00
|
|
|
parentPage.dialogsItemAnimator.prepareForRemove();
|
|
|
|
parentPage.lastItemsCount++;
|
|
|
|
parentPage.dialogsAdapter.notifyItemInserted(index);
|
|
|
|
}
|
|
|
|
if (archivedDialogs.isEmpty()) {
|
|
|
|
dialogs.remove(0);
|
|
|
|
if (index == 1) {
|
|
|
|
dialogChangeFinished = 2;
|
|
|
|
setDialogsListFrozen(true);
|
|
|
|
parentPage.dialogsAdapter.notifyItemChanged(0);
|
|
|
|
} else {
|
|
|
|
frozenDialogsList.remove(0);
|
|
|
|
parentPage.dialogsItemAnimator.prepareForRemove();
|
|
|
|
parentPage.lastItemsCount--;
|
|
|
|
parentPage.dialogsAdapter.notifyItemRemoved(0);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
} else {
|
|
|
|
parentPage.dialogsAdapter.notifyDataSetChanged();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (folderId != 0 && frozenDialogsList.isEmpty()) {
|
|
|
|
parentPage.listView.setEmptyView(null);
|
|
|
|
parentPage.progressView.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
setDialogsListFrozen(true);
|
|
|
|
if (Utilities.random.nextInt(1000) == 1) {
|
|
|
|
if (pacmanAnimation == null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
pacmanAnimation = new PacmanAnimation(parentPage.listView);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
pacmanAnimation.setFinishRunnable(finishRunnable);
|
|
|
|
pacmanAnimation.start();
|
|
|
|
} else {
|
|
|
|
finishRunnable.run();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
slidingView = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
|
|
|
|
if (viewHolder != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
parentPage.listView.hideSelector(false);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
super.onSelectedChanged(viewHolder, actionState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getAnimationDuration(RecyclerView recyclerView, int animationType, float animateDx, float animateDy) {
|
|
|
|
if (animationType == ItemTouchHelper.ANIMATION_TYPE_SWIPE_CANCEL) {
|
|
|
|
return 200;
|
|
|
|
} else if (animationType == ItemTouchHelper.ANIMATION_TYPE_DRAG) {
|
|
|
|
if (movingView != null) {
|
|
|
|
View view = movingView;
|
2020-04-30 21:07:00 +02:00
|
|
|
AndroidUtilities.runOnUIThread(() -> view.setBackgroundDrawable(null), parentPage.dialogsItemAnimator.getMoveDuration());
|
2019-05-14 14:08:05 +02:00
|
|
|
movingView = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.getAnimationDuration(recyclerView, animationType, animateDx, animateDy);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) {
|
2021-01-28 15:15:51 +01:00
|
|
|
return 0.45f;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSwipeEscapeVelocity(float defaultValue) {
|
|
|
|
return 3500;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSwipeVelocityThreshold(float defaultValue) {
|
|
|
|
return Float.MAX_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-06-25 17:29:04 +02:00
|
|
|
getConnectionsManager().updateDcSettings();
|
2020-10-04 12:14:58 +02:00
|
|
|
getMessagesController().getBlockedPeers(true);
|
2020-02-28 16:38:43 +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);
|
2020-03-30 14:00:09 +02:00
|
|
|
initialDialogsType = 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);
|
2019-12-31 14:08:08 +01:00
|
|
|
afterSignup = arguments.getBoolean("afterSignup", false);
|
2019-05-14 14:08:05 +02:00
|
|
|
folderId = arguments.getInt("folderId", 0);
|
2019-07-18 15:01:39 +02:00
|
|
|
resetDelegate = arguments.getBoolean("resetDelegate", true);
|
2019-08-22 01:53:26 +02:00
|
|
|
messagesCount = arguments.getInt("messagesCount", 0);
|
2020-01-23 07:15:40 +01:00
|
|
|
hasPoll = arguments.getInt("hasPoll", 0);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (initialDialogsType == 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
|
|
|
|
if (searchString == null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
currentConnectionState = getConnectionsManager().getConnectionState();
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
getNotificationCenter().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);
|
2020-03-30 14:00:09 +02:00
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.filterSettingsUpdated);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.dialogFiltersUpdated);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.dialogsUnreadCounterChanged);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.encryptedChatUpdated);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.contactsDidLoad);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.openedChatChanged);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.messageReceivedByAck);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.messageSendError);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.needReloadRecentDialogsSearch);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.replyMessagesDidLoad);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.reloadHints);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.didUpdateConnectionState);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.needDeleteDialog);
|
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.folderBecomeEmpty);
|
2020-07-26 10:03:38 +02:00
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.newSuggestionsAvailable);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetPasscode);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.messagesDeleted);
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().addObserver(this, NotificationCenter.didClearDatabase);
|
2020-12-23 08:48:30 +01:00
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
loadDialogs(getAccountInstance());
|
|
|
|
getMessagesController().loadPinnedDialogs(folderId, 0, null);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void loadDialogs(AccountInstance accountInstance) {
|
|
|
|
int currentAccount = accountInstance.getCurrentAccount();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!dialogsLoaded[currentAccount]) {
|
2021-02-23 12:53:38 +01:00
|
|
|
MessagesController messagesController = accountInstance.getMessagesController();
|
2020-04-24 11:21:58 +02:00
|
|
|
messagesController.loadGlobalNotificationsSettings();
|
2021-02-23 12:53:38 +01:00
|
|
|
messagesController.loadDialogs(0, 0, 100, true);
|
2020-04-24 11:21:58 +02:00
|
|
|
messagesController.loadHintDialogs();
|
2021-02-23 12:53:38 +01:00
|
|
|
messagesController.loadUserInfo(accountInstance.getUserConfig().getCurrentUser(), false, 0);
|
|
|
|
accountInstance.getContactsController().checkInviteText();
|
|
|
|
accountInstance.getMediaDataController().loadRecents(MediaDataController.TYPE_FAVE, false, true, false);
|
|
|
|
accountInstance.getMediaDataController().checkFeaturedStickers();
|
2020-04-24 11:21:58 +02:00
|
|
|
for (String emoji : messagesController.diceEmojies) {
|
2021-02-23 12:53:38 +01:00
|
|
|
accountInstance.getMediaDataController().loadStickersByEmojiOrName(emoji, true, true);
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
dialogsLoaded[currentAccount] = true;
|
2013-12-20 20:25:49 +01:00
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2015-03-19 00:09:45 +01:00
|
|
|
if (searchString == null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
getNotificationCenter().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);
|
2020-03-30 14:00:09 +02:00
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.filterSettingsUpdated);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.dialogFiltersUpdated);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.dialogsUnreadCounterChanged);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.encryptedChatUpdated);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.contactsDidLoad);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.openedChatChanged);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.notificationsSettingsUpdated);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByAck);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.messageSendError);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.needReloadRecentDialogsSearch);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.replyMessagesDidLoad);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.reloadHints);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.didUpdateConnectionState);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.needDeleteDialog);
|
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.folderBecomeEmpty);
|
2020-07-26 10:03:38 +02:00
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.newSuggestionsAvailable);
|
2020-09-30 15:48:47 +02:00
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.messagesDeleted);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetPasscode);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().removeObserver(this, NotificationCenter.didClearDatabase);
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onDestroy();
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (undoView[0] != null) {
|
|
|
|
undoView[0].hide(true, 0);
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().onAnimationFinish(animationIndex);
|
2013-10-25 17:19:00 +02:00
|
|
|
delegate = null;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected ActionBar createActionBar(Context context) {
|
|
|
|
ActionBar actionBar = new ActionBar(context) {
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
2021-02-23 12:53:38 +01:00
|
|
|
if (translationY != getTranslationY()) {
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
super.setTranslationY(translationY);
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected boolean shouldClipChild(View child) {
|
|
|
|
return super.shouldClipChild(child) || child == doneItem;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
|
|
|
if (inPreviewMode && avatarContainer != null && child != avatarContainer) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return super.drawChild(canvas, child, drawingTime);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
};
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSelector), false);
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), true);
|
|
|
|
actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultIcon), false);
|
|
|
|
actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), true);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (inPreviewMode || AndroidUtilities.isTablet() && folderId != 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
actionBar.setOccupyStatusBar(false);
|
|
|
|
}
|
|
|
|
return actionBar;
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@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;
|
2019-05-14 14:08:05 +02:00
|
|
|
pacmanAnimation = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
selectedDialogs.clear();
|
|
|
|
|
|
|
|
maximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity();
|
2015-04-09 20:00:14 +02:00
|
|
|
|
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();
|
2020-04-10 16:47:50 +02:00
|
|
|
doneItem = new ActionBarMenuItem(context, null, Theme.getColor(Theme.key_actionBarDefaultSelector), Theme.getColor(Theme.key_actionBarDefaultIcon), true);
|
|
|
|
doneItem.setText(LocaleController.getString("Done", R.string.Done).toUpperCase());
|
|
|
|
actionBar.addView(doneItem, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.RIGHT, 0, 0, 10, 0));
|
|
|
|
doneItem.setOnClickListener(v -> {
|
|
|
|
filterTabsView.setIsEditing(false);
|
|
|
|
showDoneItem(false);
|
|
|
|
});
|
|
|
|
doneItem.setAlpha(0.0f);
|
|
|
|
doneItem.setVisibility(View.GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
if (!onlySelect && searchString == null && folderId == 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyDrawable = new ProxyDrawable(context);
|
|
|
|
proxyItem = menu.addItem(2, proxyDrawable);
|
2019-05-14 14:08:05 +02:00
|
|
|
proxyItem.setContentDescription(LocaleController.getString("ProxySettings", R.string.ProxySettings));
|
2021-01-28 15:15:51 +01:00
|
|
|
|
|
|
|
passcodeDrawable = new RLottieDrawable(R.raw.passcode_lock_open, "passcode_lock_open", AndroidUtilities.dp(28), AndroidUtilities.dp(28), true, null);
|
|
|
|
passcodeDrawable2 = new RLottieDrawable(R.raw.passcode_lock_close, "passcode_lock_close", AndroidUtilities.dp(28), AndroidUtilities.dp(28), true, null);
|
|
|
|
passcodeItem = menu.addItem(1, passcodeDrawable);
|
|
|
|
updatePasscodeButton(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
updateProxyButton(false);
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
|
|
|
|
scanItem = menu.addItem(3, R.drawable.wallet_qr);
|
|
|
|
scanItem.setContentDescription(LocaleController.getString("ScanQRCode", R.string.ScanQRCode));
|
|
|
|
scanItem.setVisibility(View.GONE);
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, 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);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (proxyItem != null && proxyItemVisible) {
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyItem.setVisibility(View.GONE);
|
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
if (scanItem != null) {
|
|
|
|
scanItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[0] != null) {
|
2015-03-19 00:09:45 +01:00
|
|
|
if (searchString != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.hide();
|
2020-09-30 18:55:35 +02:00
|
|
|
if (searchViewPager != null) {
|
|
|
|
searchViewPager.searchListView.show();
|
|
|
|
}
|
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);
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-04 18:47:15 +02:00
|
|
|
setScrollY(0);
|
2021-01-28 15:15:51 +01:00
|
|
|
updatePasscodeButton(false);
|
2019-05-14 14:08:05 +02:00
|
|
|
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack));
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
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);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (proxyItem != null && proxyItemVisible) {
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
if (scanItem != null) {
|
|
|
|
scanItem.setVisibility(View.GONE);
|
|
|
|
}
|
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;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[0] != null) {
|
|
|
|
viewPages[0].listView.setEmptyView(folderId == 0 ? viewPages[0].progressView : null);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (!onlySelect) {
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setVisibility(View.VISIBLE);
|
2015-04-09 20:00:14 +02:00
|
|
|
floatingHidden = true;
|
2019-12-31 14:08:08 +01:00
|
|
|
floatingButtonTranslation = AndroidUtilities.dp(100);
|
|
|
|
floatingButtonHideProgress = 1f;
|
|
|
|
updateFloatingButtonOffset();
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
showSearch(false, true);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
updatePasscodeButton(false);
|
2019-05-14 14:08:05 +02:00
|
|
|
if (menuDrawable != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (actionBar.getBackButton().getDrawable() != menuDrawable) {
|
|
|
|
actionBar.setBackButtonDrawable(menuDrawable);
|
|
|
|
menuDrawable.setRotation(0, true);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
|
|
|
|
}
|
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();
|
2021-01-28 15:15:51 +01:00
|
|
|
if (text.length() != 0 || (searchViewPager.dialogsSearchAdapter != null && searchViewPager.dialogsSearchAdapter.hasRecentSearch()) || searchFiltersWasShowed) {
|
2015-04-09 20:00:14 +02:00
|
|
|
searchWas = true;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (!searchIsShowed) {
|
2019-12-31 14:08:08 +01:00
|
|
|
showSearch(true, true);
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2014-06-04 01:31:48 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.onTextChanged(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSearchFilterCleared(FiltersView.MediaFilterData filterData) {
|
|
|
|
if (!searchIsShowed) {
|
|
|
|
return;
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.removeSearchFilter(filterData);
|
|
|
|
searchViewPager.onTextChanged(searchItem.getSearchField().getText().toString());
|
|
|
|
|
2021-02-06 12:40:02 +01:00
|
|
|
updateFiltersView(true, null, null, true);
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canToggleSearch() {
|
|
|
|
return !actionBar.isActionModeShowed();
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
2020-03-30 14:00:09 +02:00
|
|
|
searchItem.setClearsTextOnSearchCollapse(false);
|
|
|
|
searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search));
|
|
|
|
searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
|
2015-04-09 20:00:14 +02:00
|
|
|
if (onlySelect) {
|
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (initialDialogsType == 3 && selectAlertString == null) {
|
2017-12-08 18:35:59 +01:00
|
|
|
actionBar.setTitle(LocaleController.getString("ForwardTo", R.string.ForwardTo));
|
2021-01-28 15:15:51 +01:00
|
|
|
} else if (initialDialogsType == 10) {
|
|
|
|
actionBar.setTitle(LocaleController.getString("SelectChats", R.string.SelectChats));
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
|
|
|
actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat));
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
|
2015-04-09 20:00:14 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchString != null || folderId != 0) {
|
|
|
|
actionBar.setBackButtonDrawable(backDrawable = new BackDrawable(false));
|
2015-04-09 20:00:14 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
actionBar.setBackButtonDrawable(menuDrawable = new MenuDrawable());
|
|
|
|
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
|
2014-11-19 11:32:27 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (folderId != 0) {
|
2020-06-25 17:29:04 +02:00
|
|
|
actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats));
|
2016-03-06 02:49:31 +01:00
|
|
|
} else {
|
2021-01-11 12:22:07 +01:00
|
|
|
actionBar.setTitle(LocaleController.getString("NekoX", R.string.NekoX));
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2019-12-31 20:46:59 +01:00
|
|
|
if (folderId == 0) {
|
|
|
|
actionBar.setSupportsHolidayImage(true);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-08 10:16:23 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-03-30 14:00:09 +02:00
|
|
|
actionBar.setAddToContainer(false);
|
|
|
|
actionBar.setCastShadows(false);
|
|
|
|
actionBar.setClipContent(true);
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
actionBar.setTitleActionRunnable(() -> {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType != 10) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
scrollToTop();
|
2018-07-30 04:07:02 +02:00
|
|
|
});
|
|
|
|
|
2020-06-05 02:04:52 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || initialDialogsType == 0 && folderId == 0 && !onlySelect && TextUtils.isEmpty(searchString)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
scrimPaint = new Paint() {
|
|
|
|
@Override
|
|
|
|
public void setAlpha(int a) {
|
|
|
|
super.setAlpha(a);
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
};
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
filterTabsView = new FilterTabsView(context) {
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
|
|
getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
|
maybeStartTracking = false;
|
|
|
|
return super.onInterceptTouchEvent(ev);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
2021-02-23 12:53:38 +01:00
|
|
|
if (getTranslationY() != translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
|
|
|
updateContextViewPosition();
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
super.onLayout(changed, l, t, r, b);
|
|
|
|
if (scrimView != null) {
|
|
|
|
scrimView.getLocationInWindow(scrimViewLocation);
|
|
|
|
fragmentView.invalidate();
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
};
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
filterTabsView.setVisibility(View.GONE);
|
2020-12-23 08:48:30 +01:00
|
|
|
canShowFilterTabsView = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
filterTabsView.setDelegate(new FilterTabsView.FilterTabsViewDelegate() {
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void showDeleteAlert(MessagesController.DialogFilter dialogFilter) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("FilterDelete", R.string.FilterDelete));
|
|
|
|
builder.setMessage(LocaleController.getString("FilterDeleteAlert", R.string.FilterDeleteAlert));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog2, which2) -> {
|
|
|
|
TLRPC.TL_messages_updateDialogFilter req = new TLRPC.TL_messages_updateDialogFilter();
|
|
|
|
req.id = dialogFilter.id;
|
|
|
|
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
|
|
|
}));
|
2020-12-23 08:48:30 +01:00
|
|
|
// if (getMessagesController().dialogFilters.size() > 1) {
|
|
|
|
// filterTabsView.beginCrossfade();
|
|
|
|
// }
|
2020-03-30 14:00:09 +02:00
|
|
|
getMessagesController().removeFilter(dialogFilter);
|
|
|
|
getMessagesStorage().deleteDialogFilter(dialogFilter);
|
2021-02-06 12:40:02 +01:00
|
|
|
// filterTabsView.commitCrossfade();
|
2020-03-30 14:00:09 +02:00
|
|
|
});
|
|
|
|
AlertDialog alertDialog = builder.create();
|
|
|
|
showDialog(alertDialog);
|
|
|
|
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
|
|
if (button != null) {
|
|
|
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onSamePageSelected() {
|
|
|
|
scrollToTop();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onPageReorder(int fromId, int toId) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].selectedType == fromId) {
|
|
|
|
viewPages[a].selectedType = toId;
|
|
|
|
} else if (viewPages[a].selectedType == toId) {
|
|
|
|
viewPages[a].selectedType = fromId;
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onPageSelected(int id, boolean forward) {
|
|
|
|
if (viewPages[0].selectedType == id) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 18:49:17 +02:00
|
|
|
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
|
|
|
|
if (id != Integer.MAX_VALUE && (id < 0 || id >= dialogFilters.size())) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId());
|
|
|
|
}
|
|
|
|
viewPages[1].selectedType = id;
|
|
|
|
viewPages[1].setVisibility(View.VISIBLE);
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
|
|
|
|
showScrollbars(false);
|
|
|
|
switchToCurrentSelectedMode(true);
|
|
|
|
animatingForward = forward;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public boolean canPerformActions() {
|
|
|
|
return !searching;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageScrolled(float progress) {
|
|
|
|
if (progress == 1 && viewPages[1].getVisibility() != View.VISIBLE && !searching) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (animatingForward) {
|
|
|
|
viewPages[0].setTranslationX(-progress * viewPages[0].getMeasuredWidth());
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth() - progress * viewPages[0].getMeasuredWidth());
|
|
|
|
} else {
|
|
|
|
viewPages[0].setTranslationX(progress * viewPages[0].getMeasuredWidth());
|
|
|
|
viewPages[1].setTranslationX(progress * viewPages[0].getMeasuredWidth() - viewPages[0].getMeasuredWidth());
|
|
|
|
}
|
|
|
|
if (progress == 1) {
|
|
|
|
ViewPage tempPage = viewPages[0];
|
|
|
|
viewPages[0] = viewPages[1];
|
|
|
|
viewPages[1] = tempPage;
|
|
|
|
viewPages[1].setVisibility(View.GONE);
|
|
|
|
showScrollbars(true);
|
|
|
|
updateCounters(false);
|
|
|
|
checkListLoad(viewPages[0]);
|
2020-12-23 08:48:30 +01:00
|
|
|
viewPages[0].dialogsAdapter.resume();
|
|
|
|
viewPages[1].dialogsAdapter.pause();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getTabCounter(int tabId) {
|
|
|
|
if (tabId == Integer.MAX_VALUE) {
|
|
|
|
return getMessagesStorage().getMainUnreadCount();
|
|
|
|
}
|
2020-03-30 18:49:17 +02:00
|
|
|
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
|
|
|
|
if (tabId < 0 || tabId >= dialogFilters.size()) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
return dialogFilters.get(tabId).unreadCount;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean didSelectTab(FilterTabsView.TabView tabView, boolean selected) {
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
scrimPopupWindow = null;
|
|
|
|
scrimPopupWindowItems = null;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rect rect = new Rect();
|
|
|
|
MessagesController.DialogFilter dialogFilter;
|
|
|
|
if (tabView.getId() == Integer.MAX_VALUE) {
|
|
|
|
dialogFilter = null;
|
|
|
|
} else {
|
|
|
|
dialogFilter = getMessagesController().dialogFilters.get(tabView.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionBarPopupWindow.ActionBarPopupWindowLayout popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getParentActivity());
|
|
|
|
popupLayout.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
|
|
|
private int[] pos = new int[2];
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
|
|
|
if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
|
|
|
|
View contentView = scrimPopupWindow.getContentView();
|
|
|
|
contentView.getLocationInWindow(pos);
|
|
|
|
rect.set(pos[0], pos[1], pos[0] + contentView.getMeasuredWidth(), pos[1] + contentView.getMeasuredHeight());
|
|
|
|
if (!rect.contains((int) event.getX(), (int) event.getY())) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (event.getActionMasked() == MotionEvent.ACTION_OUTSIDE) {
|
|
|
|
if (scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
popupLayout.setDispatchKeyEventListener(keyEvent -> {
|
|
|
|
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && scrimPopupWindow != null && scrimPopupWindow.isShowing()) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Rect backgroundPaddings = new Rect();
|
|
|
|
Drawable shadowDrawable = getParentActivity().getResources().getDrawable(R.drawable.popup_fixed_alert).mutate();
|
|
|
|
shadowDrawable.getPadding(backgroundPaddings);
|
|
|
|
popupLayout.setBackgroundDrawable(shadowDrawable);
|
|
|
|
popupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
|
|
|
|
LinearLayout linearLayout = new LinearLayout(getParentActivity());
|
|
|
|
ScrollView scrollView;
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
scrollView = new ScrollView(getParentActivity(), null, 0, R.style.scrollbarShapeStyle) {
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
setMeasuredDimension(linearLayout.getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
scrollView = new ScrollView(getParentActivity());
|
|
|
|
}
|
|
|
|
scrollView.setClipToPadding(false);
|
|
|
|
popupLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
|
|
|
|
|
|
|
linearLayout.setMinimumWidth(AndroidUtilities.dp(200));
|
|
|
|
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
2021-02-04 18:59:00 +01:00
|
|
|
scrimPopupWindowItems = new ActionBarMenuSubItem[4];
|
|
|
|
for (int a = 0, N = (tabView.getId() == Integer.MAX_VALUE ? 3 : 4); a < 4; a++) {
|
2020-12-23 08:48:30 +01:00
|
|
|
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), a == 0, a == N - 1);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (a == 0) {
|
2021-02-04 18:59:00 +01:00
|
|
|
if (getMessagesController().dialogFilters.size() <= 1) continue;
|
2020-03-30 14:00:09 +02:00
|
|
|
cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder);
|
|
|
|
} else if (a == 1) {
|
2021-02-04 18:59:00 +01:00
|
|
|
if (N == 3) {
|
2020-06-25 17:29:04 +02:00
|
|
|
cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.baseline_edit_24);
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
2020-06-25 17:29:04 +02:00
|
|
|
cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.baseline_edit_24);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2021-02-04 18:59:00 +01:00
|
|
|
} else if (a == 2) {
|
|
|
|
if (N == 3) continue;
|
2020-06-25 17:29:04 +02:00
|
|
|
cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.baseline_delete_24);
|
2021-02-04 18:59:00 +01:00
|
|
|
} else {
|
|
|
|
cell.setTextAndIcon(LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead), R.drawable.baseline_done_all_24);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
scrimPopupWindowItems[a] = cell;
|
|
|
|
linearLayout.addView(cell);
|
|
|
|
final int i = a;
|
|
|
|
cell.setOnClickListener(v1 -> {
|
|
|
|
if (i == 0) {
|
|
|
|
resetScroll();
|
|
|
|
filterTabsView.setIsEditing(true);
|
|
|
|
showDoneItem(true);
|
|
|
|
} else if (i == 1) {
|
2021-02-06 12:40:02 +01:00
|
|
|
if (N == 3) {
|
2020-03-30 14:00:09 +02:00
|
|
|
presentFragment(new FiltersSetupActivity());
|
|
|
|
} else {
|
|
|
|
presentFragment(new FilterCreateActivity(dialogFilter));
|
|
|
|
}
|
|
|
|
} else if (i == 2) {
|
|
|
|
showDeleteAlert(dialogFilter);
|
2021-02-04 18:59:00 +01:00
|
|
|
} else {
|
2021-02-06 12:40:02 +01:00
|
|
|
if (dialogFilter == null) {
|
2021-02-06 17:19:28 +01:00
|
|
|
int folderId = tabView.getId() == Integer.MAX_VALUE ? 0 : -1;
|
2021-02-06 12:40:02 +01:00
|
|
|
getMessagesStorage().readAllDialogs(folderId);
|
|
|
|
} else {
|
2021-02-06 17:19:28 +01:00
|
|
|
if (dialogFilter.dialogs.isEmpty()) {
|
|
|
|
getMessagesController().loadTabDialogs(dialogFilter);
|
|
|
|
}
|
2021-02-06 12:40:02 +01:00
|
|
|
for (TLRPC.Dialog dialog : dialogFilter.dialogs) {
|
|
|
|
if (dialog.unread_count == 0 && dialog.unread_mentions_count == 0)
|
|
|
|
continue;
|
|
|
|
getMessagesController().markDialogAsRead(dialog.id, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, dialog.unread_count, true, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-02-06 17:19:28 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP));
|
|
|
|
scrimPopupWindow = new ActionBarPopupWindow(popupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
|
|
|
|
@Override
|
|
|
|
public void dismiss() {
|
|
|
|
super.dismiss();
|
|
|
|
if (scrimPopupWindow != this) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
scrimPopupWindow = null;
|
|
|
|
scrimPopupWindowItems = null;
|
|
|
|
if (scrimAnimatorSet != null) {
|
|
|
|
scrimAnimatorSet.cancel();
|
|
|
|
scrimAnimatorSet = null;
|
|
|
|
}
|
|
|
|
scrimAnimatorSet = new AnimatorSet();
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0));
|
|
|
|
scrimAnimatorSet.playTogether(animators);
|
|
|
|
scrimAnimatorSet.setDuration(220);
|
|
|
|
scrimAnimatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (scrimView != null) {
|
|
|
|
scrimView.setBackground(null);
|
|
|
|
scrimView = null;
|
|
|
|
}
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
scrimAnimatorSet.start();
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
|
|
|
getParentActivity().getWindow().getDecorView().setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_AUTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
tabView.setBackground(Theme.createRoundRectDrawable(AndroidUtilities.dp(6), Theme.getColor(Theme.key_actionBarDefault)));
|
|
|
|
scrimPopupWindow.setDismissAnimationDuration(220);
|
|
|
|
scrimPopupWindow.setOutsideTouchable(true);
|
|
|
|
scrimPopupWindow.setClippingEnabled(true);
|
|
|
|
scrimPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
|
|
|
|
scrimPopupWindow.setFocusable(true);
|
|
|
|
popupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
|
|
|
|
scrimPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
|
|
|
scrimPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
|
|
|
scrimPopupWindow.getContentView().setFocusableInTouchMode(true);
|
|
|
|
tabView.getLocationInWindow(scrimViewLocation);
|
|
|
|
int popupX = scrimViewLocation[0] + backgroundPaddings.left - AndroidUtilities.dp(16);
|
|
|
|
if (popupX < AndroidUtilities.dp(6)) {
|
|
|
|
popupX = AndroidUtilities.dp(6);
|
|
|
|
} else if (popupX > fragmentView.getMeasuredWidth() - AndroidUtilities.dp(6) - popupLayout.getMeasuredWidth()) {
|
|
|
|
popupX = fragmentView.getMeasuredWidth() - AndroidUtilities.dp(6) - popupLayout.getMeasuredWidth();
|
|
|
|
}
|
|
|
|
int popupY = scrimViewLocation[1] + tabView.getMeasuredHeight() - AndroidUtilities.dp(12);
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY);
|
2020-03-30 14:00:09 +02:00
|
|
|
scrimView = tabView;
|
|
|
|
scrimViewSelected = selected;
|
|
|
|
fragmentView.invalidate();
|
|
|
|
if (scrimAnimatorSet != null) {
|
|
|
|
scrimAnimatorSet.cancel();
|
|
|
|
}
|
|
|
|
scrimAnimatorSet = new AnimatorSet();
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofInt(scrimPaint, AnimationProperties.PAINT_ALPHA, 0, 50));
|
|
|
|
scrimAnimatorSet.playTogether(animators);
|
|
|
|
scrimAnimatorSet.setDuration(150);
|
|
|
|
scrimAnimatorSet.start();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isTabMenuVisible() {
|
|
|
|
return scrimPopupWindow != null && scrimPopupWindow.isShowing();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDeletePressed(int id) {
|
|
|
|
showDeleteAlert(getMessagesController().dialogFilters.get(id));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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 = getUserConfig().getCurrentUser();
|
|
|
|
avatarDrawable.setInfo(user);
|
|
|
|
imageView.getImageReceiver().setCurrentAccount(currentAccount);
|
|
|
|
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
|
|
|
|
|
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
TLRPC.User u = AccountInstance.getInstance(a).getUserConfig().getCurrentUser();
|
|
|
|
if (u != null) {
|
|
|
|
AccountSelectCell cell = new AccountSelectCell(context);
|
|
|
|
cell.setAccount(a, true);
|
|
|
|
switchItem.addSubItem(10 + a, cell, AndroidUtilities.dp(230), AndroidUtilities.dp(48));
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
actionBar.setAllowOverlayTitle(true);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (sideMenu != null) {
|
|
|
|
sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground));
|
|
|
|
sideMenu.getAdapter().notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
createActionMode();
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
ContentView contentView = new ContentView(context);
|
|
|
|
fragmentView = contentView;
|
|
|
|
|
2020-04-08 10:16:23 +02:00
|
|
|
int pagesCount = (initialDialogsType == 3 && NekoConfig.showTabsOnForward) || (folderId == 0 && initialDialogsType == 0 && !onlySelect) ? 2 : 1;
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages = new ViewPage[pagesCount];
|
|
|
|
for (int a = 0; a < pagesCount; a++) {
|
|
|
|
final ViewPage viewPage = new ViewPage(context) {
|
|
|
|
@Override
|
|
|
|
public void setTranslationX(float translationX) {
|
|
|
|
super.setTranslationX(translationX);
|
|
|
|
if (tabsAnimationInProgress) {
|
|
|
|
if (viewPages[0] == this) {
|
|
|
|
float scrollProgress = Math.abs(viewPages[0].getTranslationX()) / (float) viewPages[0].getMeasuredWidth();
|
|
|
|
filterTabsView.selectTabWithId(viewPages[1].selectedType, scrollProgress);
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
contentView.addView(viewPage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
viewPage.dialogsType = initialDialogsType;
|
|
|
|
viewPages[a] = viewPage;
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPage.progressView = new FlickerLoadingView(context);
|
|
|
|
viewPage.progressView.setViewType(FlickerLoadingView.DIALOG_CELL_TYPE);
|
|
|
|
viewPage.progressView.setVisibility(View.GONE);
|
|
|
|
viewPage.addView(viewPage.progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView = new DialogsRecyclerView(context, viewPage);
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPage.listView.setAnimateEmptyView(true, 0);
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView.setClipToPadding(false);
|
|
|
|
viewPage.listView.setPivotY(0);
|
2020-04-30 21:07:00 +02:00
|
|
|
viewPage.dialogsItemAnimator = new DialogsItemAnimator() {
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onRemoveStarting(RecyclerView.ViewHolder item) {
|
|
|
|
super.onRemoveStarting(item);
|
|
|
|
if (viewPage.layoutManager.findFirstVisibleItemPosition() == 0) {
|
|
|
|
View v = viewPage.layoutManager.findViewByPosition(0);
|
|
|
|
if (v != null) {
|
|
|
|
v.invalidate();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
|
|
|
|
viewPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.doNotShow();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-04 12:14:50 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onRemoveFinished(RecyclerView.ViewHolder item) {
|
|
|
|
if (dialogRemoveFinished == 2) {
|
|
|
|
dialogRemoveFinished = 1;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void onAddFinished(RecyclerView.ViewHolder item) {
|
|
|
|
if (dialogInsertFinished == 2) {
|
|
|
|
dialogInsertFinished = 1;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) {
|
|
|
|
if (dialogChangeFinished == 2) {
|
|
|
|
dialogChangeFinished = 1;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected void onAllAnimationsDone() {
|
|
|
|
if (dialogRemoveFinished == 1 || dialogInsertFinished == 1 || dialogChangeFinished == 1) {
|
|
|
|
onDialogAnimationFinished();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
};
|
2020-04-30 21:07:00 +02:00
|
|
|
viewPage.listView.setItemAnimator(viewPage.dialogsItemAnimator);
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView.setVerticalScrollBarEnabled(true);
|
|
|
|
viewPage.listView.setInstantClick(true);
|
|
|
|
viewPage.layoutManager = new LinearLayoutManager(context) {
|
|
|
|
|
|
|
|
private boolean fixOffset;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void scrollToPositionWithOffset(int position, int offset) {
|
|
|
|
if (fixOffset) {
|
|
|
|
offset -= viewPage.listView.getPaddingTop();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
super.scrollToPositionWithOffset(position, offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void prepareForDrop(@NonNull View view, @NonNull View target, int x, int y) {
|
|
|
|
fixOffset = true;
|
|
|
|
super.prepareForDrop(view, target, x, y);
|
|
|
|
fixOffset = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void smoothScrollToPosition(RecyclerView recyclerView, RecyclerView.State state, int position) {
|
|
|
|
if (hasHiddenArchive() && position == 1) {
|
|
|
|
super.smoothScrollToPosition(recyclerView, state, position);
|
|
|
|
} else {
|
|
|
|
LinearSmoothScrollerCustom linearSmoothScroller = new LinearSmoothScrollerCustom(recyclerView.getContext(), LinearSmoothScrollerCustom.POSITION_MIDDLE);
|
|
|
|
linearSmoothScroller.setTargetPosition(position);
|
|
|
|
startSmoothScroll(linearSmoothScroller);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
|
2020-07-26 10:03:38 +02:00
|
|
|
if (viewPage.listView.fastScrollAnimationRunning) {
|
|
|
|
return 0;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean isDragging = viewPage.listView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING;
|
|
|
|
|
|
|
|
int measuredDy = dy;
|
|
|
|
int pTop = viewPage.listView.getPaddingTop();
|
|
|
|
if (viewPage.dialogsType == 0 && !onlySelect && folderId == 0 && dy < 0 && getMessagesController().hasHiddenArchive() && viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
|
|
|
|
viewPage.listView.setOverScrollMode(View.OVER_SCROLL_ALWAYS);
|
|
|
|
int currentPosition = viewPage.layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (currentPosition == 0) {
|
|
|
|
View view = viewPage.layoutManager.findViewByPosition(currentPosition);
|
|
|
|
if (view != null && (view.getBottom() - pTop) <= AndroidUtilities.dp(1)) {
|
|
|
|
currentPosition = 1;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!isDragging) {
|
|
|
|
View view = viewPage.layoutManager.findViewByPosition(currentPosition);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (view != null) {
|
|
|
|
int dialogHeight = AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72) + 1;
|
|
|
|
int canScrollDy = -(view.getTop() - pTop) + (currentPosition - 1) * dialogHeight;
|
|
|
|
int positiveDy = Math.abs(dy);
|
|
|
|
if (canScrollDy < positiveDy) {
|
|
|
|
measuredDy = -canScrollDy;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
} else if (currentPosition == 0) {
|
|
|
|
View v = viewPage.layoutManager.findViewByPosition(currentPosition);
|
|
|
|
float k = 1f + ((v.getTop() - pTop) / (float) v.getMeasuredHeight());
|
|
|
|
if (k > 1f) {
|
|
|
|
k = 1f;
|
|
|
|
}
|
|
|
|
viewPage.listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
|
|
|
measuredDy *= PullForegroundDrawable.startPullParallax - PullForegroundDrawable.endPullParallax * k;
|
|
|
|
if (measuredDy > -1) {
|
|
|
|
measuredDy = -1;
|
|
|
|
}
|
|
|
|
if (undoView[0].getVisibility() == View.VISIBLE) {
|
|
|
|
undoView[0].hide(true, 1);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (viewPage.dialogsType == 0 && viewPage.listView.getViewOffset() != 0 && dy > 0 && isDragging) {
|
|
|
|
float ty = (int) viewPage.listView.getViewOffset();
|
|
|
|
ty -= dy;
|
|
|
|
if (ty < 0) {
|
|
|
|
measuredDy = (int) ty;
|
|
|
|
ty = 0;
|
|
|
|
} else {
|
|
|
|
measuredDy = 0;
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView.setViewsOffset(ty);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (viewPage.dialogsType == 0 && viewPage.archivePullViewState != ARCHIVE_ITEM_STATE_PINNED && hasHiddenArchive()) {
|
|
|
|
int usedDy = super.scrollVerticallyBy(measuredDy, recycler, state);
|
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.scrollDy = usedDy;
|
|
|
|
}
|
|
|
|
int currentPosition = viewPage.layoutManager.findFirstVisibleItemPosition();
|
|
|
|
View firstView = null;
|
|
|
|
if (currentPosition == 0) {
|
|
|
|
firstView = viewPage.layoutManager.findViewByPosition(currentPosition);
|
|
|
|
}
|
|
|
|
if (currentPosition == 0 && firstView != null && (firstView.getBottom() - pTop) >= AndroidUtilities.dp(4)) {
|
|
|
|
if (startArchivePullingTime == 0) {
|
|
|
|
startArchivePullingTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
|
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.showHidden();
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
float k = 1f + ((firstView.getTop() - pTop) / (float) firstView.getMeasuredHeight());
|
|
|
|
if (k > 1f) {
|
|
|
|
k = 1f;
|
|
|
|
}
|
|
|
|
long pullingTime = System.currentTimeMillis() - startArchivePullingTime;
|
|
|
|
boolean canShowInternal = k > PullForegroundDrawable.SNAP_HEIGHT && pullingTime > PullForegroundDrawable.minPullingTime + 20;
|
|
|
|
if (canShowHiddenArchive != canShowInternal) {
|
|
|
|
canShowHiddenArchive = canShowInternal;
|
|
|
|
if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) {
|
2020-07-26 18:07:20 +02:00
|
|
|
if (!NekoConfig.disableVibration) {
|
|
|
|
viewPage.listView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.colorize(canShowInternal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && measuredDy - usedDy != 0 && dy < 0 && isDragging) {
|
|
|
|
float ty;
|
|
|
|
float tk = (viewPage.listView.getViewOffset() / PullForegroundDrawable.getMaxOverscroll());
|
|
|
|
tk = 1f - tk;
|
|
|
|
ty = (viewPage.listView.getViewOffset() - dy * PullForegroundDrawable.startPullOverScroll * tk);
|
|
|
|
viewPage.listView.setViewsOffset(ty);
|
|
|
|
}
|
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.pullProgress = k;
|
|
|
|
viewPage.pullForegroundDrawable.setListView(viewPage.listView);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
startArchivePullingTime = 0;
|
|
|
|
canShowHiddenArchive = false;
|
|
|
|
viewPage.archivePullViewState = ARCHIVE_ITEM_STATE_HIDDEN;
|
|
|
|
if (viewPage.pullForegroundDrawable != null) {
|
|
|
|
viewPage.pullForegroundDrawable.resetText();
|
|
|
|
viewPage.pullForegroundDrawable.pullProgress = 0f;
|
|
|
|
viewPage.pullForegroundDrawable.setListView(viewPage.listView);
|
|
|
|
}
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (firstView != null) {
|
|
|
|
firstView.invalidate();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
return usedDy;
|
|
|
|
}
|
|
|
|
return super.scrollVerticallyBy(measuredDy, recycler, state);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
viewPage.layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
|
|
|
viewPage.listView.setLayoutManager(viewPage.layoutManager);
|
|
|
|
viewPage.listView.setVerticalScrollbarPosition(LocaleController.isRTL ? RecyclerListView.SCROLLBAR_POSITION_LEFT : RecyclerListView.SCROLLBAR_POSITION_RIGHT);
|
|
|
|
viewPage.addView(viewPage.listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPage.listView.setOnItemClickListener((view, position) -> {
|
|
|
|
if (initialDialogsType == 10) {
|
|
|
|
onItemLongClick(view, position, 0, 0, viewPage.dialogsType, viewPage.dialogsAdapter);
|
|
|
|
return;
|
|
|
|
} else if ((initialDialogsType == 11 || initialDialogsType == 13) && position == 1) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("forImport", true);
|
|
|
|
ArrayList<Integer> result = new ArrayList<>();
|
|
|
|
result.add(getUserConfig().getClientUserId());
|
|
|
|
args.putIntegerArrayList("result", result);
|
|
|
|
args.putInt("chatType", ChatObject.CHAT_TYPE_MEGAGROUP);
|
|
|
|
String title = arguments.getString("importTitle");
|
|
|
|
if (title != null) {
|
|
|
|
args.putString("title", title);
|
|
|
|
}
|
|
|
|
GroupCreateFinalActivity activity = new GroupCreateFinalActivity(args);
|
|
|
|
activity.setDelegate(new GroupCreateFinalActivity.GroupCreateFinalActivityDelegate() {
|
|
|
|
@Override
|
|
|
|
public void didStartChatCreation() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didFinishChatCreation(GroupCreateFinalActivity fragment, int chatId) {
|
|
|
|
ArrayList<Long> arrayList = new ArrayList<>();
|
|
|
|
arrayList.add((long) -chatId);
|
|
|
|
DialogsActivityDelegate dialogsActivityDelegate = delegate;
|
|
|
|
removeSelfFromStack();
|
|
|
|
dialogsActivityDelegate.didSelectDialogs(DialogsActivity.this, arrayList, null, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didFailChatCreation() {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
presentFragment(activity);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
onItemClick(view, position, viewPage.dialogsAdapter);
|
|
|
|
});
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() {
|
|
|
|
@Override
|
|
|
|
public boolean onItemClick(View view, int position, float x, float y) {
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsView.isEditing()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return onItemLongClick(view, position, x, y, viewPage.dialogsType, viewPage.dialogsAdapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLongClickRelease() {
|
|
|
|
finishPreviewFragment();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onMove(float dx, float dy) {
|
|
|
|
movePreviewFragment(dy);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
viewPage.swipeController = new SwipeController(viewPage);
|
2021-02-23 12:53:38 +01:00
|
|
|
viewPage.recyclerItemsEnterAnimator = new RecyclerItemsEnterAnimator(viewPage.listView);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
viewPage.itemTouchhelper = new ItemTouchHelper(viewPage.swipeController);
|
|
|
|
viewPage.itemTouchhelper.attachToRecyclerView(viewPage.listView);
|
|
|
|
|
|
|
|
viewPage.listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
|
|
|
|
|
|
private boolean wasManualScroll;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
|
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
|
|
|
wasManualScroll = true;
|
|
|
|
scrollingManually = true;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
scrollingManually = false;
|
|
|
|
}
|
|
|
|
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
|
|
wasManualScroll = false;
|
|
|
|
disableActionBarScrolling = false;
|
|
|
|
if (waitingForScrollFinished) {
|
|
|
|
waitingForScrollFinished = false;
|
|
|
|
if (updatePullAfterScroll) {
|
|
|
|
viewPage.listView.updatePullState();
|
|
|
|
updatePullAfterScroll = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && viewPages[0].listView == recyclerView) {
|
|
|
|
int scrollY = (int) -actionBar.getTranslationY();
|
|
|
|
int actionBarHeight = ActionBar.getCurrentActionBarHeight();
|
|
|
|
if (scrollY != 0 && scrollY != actionBarHeight) {
|
|
|
|
if (scrollY < actionBarHeight / 2) {
|
|
|
|
recyclerView.smoothScrollBy(0, -scrollY);
|
|
|
|
} else if (viewPages[0].listView.canScrollVertically(1)) {
|
|
|
|
recyclerView.smoothScrollBy(0, actionBarHeight - scrollY);
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
|
2020-04-30 21:07:00 +02:00
|
|
|
viewPage.dialogsItemAnimator.onListScroll(-dy);
|
2020-03-30 14:00:09 +02:00
|
|
|
checkListLoad(viewPage);
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType != 10 && wasManualScroll && floatingButtonContainer.getVisibility() != View.GONE && recyclerView.getChildCount() > 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
int firstVisibleItem = viewPage.layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (firstVisibleItem != RecyclerView.NO_POSITION) {
|
|
|
|
RecyclerView.ViewHolder holder = recyclerView.findViewHolderForAdapterPosition(firstVisibleItem);
|
|
|
|
if (!hasHiddenArchive() || holder != null && holder.getAdapterPosition() != 0) {
|
|
|
|
int firstViewTop = 0;
|
|
|
|
if (holder != null) {
|
|
|
|
firstViewTop = holder.itemView.getTop();
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (changed && scrollUpdated && (goingDown || scrollingManually)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
hideFloatingButton(goingDown);
|
|
|
|
}
|
|
|
|
prevPosition = firstVisibleItem;
|
|
|
|
prevTop = firstViewTop;
|
|
|
|
scrollUpdated = true;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && recyclerView == viewPages[0].listView && !searching && !actionBar.isActionModeShowed() && !disableActionBarScrolling && filterTabsViewIsVisible) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (dy > 0 && hasHiddenArchive() && viewPages[0].dialogsType == 0) {
|
|
|
|
View child = recyclerView.getChildAt(0);
|
|
|
|
if (child != null) {
|
|
|
|
RecyclerView.ViewHolder holder = recyclerView.getChildViewHolder(child);
|
|
|
|
if (holder.getAdapterPosition() == 0) {
|
|
|
|
int visiblePartAfterScroll = child.getMeasuredHeight() + (child.getTop() - recyclerView.getPaddingTop());
|
|
|
|
if (visiblePartAfterScroll + dy > 0) {
|
|
|
|
if (visiblePartAfterScroll < 0) {
|
|
|
|
dy = -visiblePartAfterScroll;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float currentTranslation = actionBar.getTranslationY();
|
|
|
|
float newTranslation = currentTranslation - dy;
|
|
|
|
if (newTranslation < -ActionBar.getCurrentActionBarHeight()) {
|
|
|
|
newTranslation = -ActionBar.getCurrentActionBarHeight();
|
|
|
|
} else if (newTranslation > 0) {
|
|
|
|
newTranslation = 0;
|
|
|
|
}
|
|
|
|
if (newTranslation != currentTranslation) {
|
|
|
|
setScrollY(newTranslation);
|
|
|
|
}
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
});
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.archivePullViewState = SharedConfig.archiveHidden ? ARCHIVE_ITEM_STATE_HIDDEN : ARCHIVE_ITEM_STATE_PINNED;
|
|
|
|
if (viewPage.pullForegroundDrawable == null && folderId == 0) {
|
|
|
|
viewPage.pullForegroundDrawable = new PullForegroundDrawable(LocaleController.getString("AccSwipeForArchive", R.string.AccSwipeForArchive), LocaleController.getString("AccReleaseForArchive", R.string.AccReleaseForArchive)) {
|
|
|
|
@Override
|
|
|
|
protected float getViewOffset() {
|
|
|
|
return viewPage.listView.getViewOffset();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (hasHiddenArchive()) {
|
|
|
|
viewPage.pullForegroundDrawable.showHidden();
|
|
|
|
} else {
|
|
|
|
viewPage.pullForegroundDrawable.doNotShow();
|
|
|
|
}
|
|
|
|
viewPage.pullForegroundDrawable.setWillDraw(viewPage.archivePullViewState != ARCHIVE_ITEM_STATE_PINNED);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPage.dialogsAdapter = new DialogsAdapter(this, context, viewPage.dialogsType, folderId, onlySelect, selectedDialogs, currentAccount) {
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void notifyDataSetChanged() {
|
|
|
|
viewPage.lastItemsCount = getItemCount();
|
2020-08-15 02:01:55 +02:00
|
|
|
try {
|
|
|
|
super.notifyDataSetChanged();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
};
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPage.dialogsAdapter.setForceShowEmptyCell(afterSignup);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (AndroidUtilities.isTablet() && openedDialogId != 0) {
|
|
|
|
viewPage.dialogsAdapter.setOpenedDialogId(openedDialogId);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.dialogsAdapter.setArchivedPullDrawable(viewPage.pullForegroundDrawable);
|
|
|
|
viewPage.listView.setAdapter(viewPage.dialogsAdapter);
|
2018-08-27 10:33:11 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPage.listView.setEmptyView(folderId == 0 ? viewPage.progressView : null);
|
|
|
|
viewPage.scrollHelper = new RecyclerAnimationScrollHelper(viewPage.listView, viewPage.layoutManager);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (a != 0) {
|
|
|
|
viewPages[a].setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
int type = 0;
|
|
|
|
if (searchString != null) {
|
|
|
|
type = 2;
|
|
|
|
} else if (!onlySelect) {
|
|
|
|
type = 1;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager = new SearchViewPager(context, this, type, initialDialogsType, folderId, new SearchViewPager.ChatPreviewDelegate() {
|
2019-12-31 14:08:08 +01:00
|
|
|
@Override
|
2020-09-30 15:48:47 +02:00
|
|
|
public void startChatPreview(DialogCell cell) {
|
|
|
|
showChatPreview(cell);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void move(float dy) {
|
|
|
|
movePreviewFragment(dy);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void finish() {
|
|
|
|
finishPreviewFragment();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
contentView.addView(searchViewPager);
|
|
|
|
|
|
|
|
searchViewPager.dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() {
|
2019-12-31 14:08:08 +01:00
|
|
|
@Override
|
2020-10-02 13:25:02 +02:00
|
|
|
public void searchStateChanged(boolean search, boolean animated) {
|
|
|
|
if (searchViewPager.emptyView.getVisibility() == View.VISIBLE) {
|
|
|
|
animated = true;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searching && searchWas && searchViewPager.emptyView != null) {
|
|
|
|
if (search || searchViewPager.dialogsSearchAdapter.getItemCount() != 0) {
|
2020-10-02 13:25:02 +02:00
|
|
|
searchViewPager.emptyView.showProgress(true, animated);
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-10-02 13:25:02 +02:00
|
|
|
searchViewPager.emptyView.showProgress(false, animated);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2020-10-02 13:25:02 +02:00
|
|
|
if (search && searchViewPager.dialogsSearchAdapter.getItemCount() == 0) {
|
|
|
|
searchViewPager.cancelEnterAnimation();
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didPressedOnSubDialog(long did) {
|
|
|
|
if (onlySelect) {
|
|
|
|
if (!validateSlowModeDialog(did)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!selectedDialogs.isEmpty()) {
|
|
|
|
boolean checked = addOrRemoveSelectedDialog(did, null);
|
2020-01-03 16:45:22 +01:00
|
|
|
findAndUpdateCheckBox(did, checked);
|
2019-12-31 14:08:08 +01:00
|
|
|
updateSelectedCount();
|
2020-01-03 16:45:22 +01:00
|
|
|
actionBar.closeSearchField();
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
didSelectResult(did, true, false);
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
int lower_id = (int) did;
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
if (lower_id > 0) {
|
|
|
|
args.putInt("user_id", lower_id);
|
|
|
|
} else {
|
|
|
|
args.putInt("chat_id", -lower_id);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
closeSearch();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (AndroidUtilities.isTablet() && viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId = did);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
if (searchString != null) {
|
|
|
|
if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
presentFragment(new ChatActivity(args));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
|
|
|
if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
presentFragment(new ChatActivity(args));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-07-18 15:01:39 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
@Override
|
|
|
|
public void needRemoveHint(final int did) {
|
|
|
|
if (getParentActivity() == null) {
|
2019-08-22 01:53:26 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
TLRPC.User user = getMessagesController().getUser(did);
|
|
|
|
if (user == null) {
|
|
|
|
return;
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("ChatHintsDeleteAlertTitle", R.string.ChatHintsDeleteAlertTitle));
|
|
|
|
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("ChatHintsDeleteAlert", R.string.ChatHintsDeleteAlert, ContactsController.formatName(user.first_name, user.last_name))));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("StickersRemove", R.string.StickersRemove), (dialogInterface, i) -> getMediaDataController().removePeer(did));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
AlertDialog dialog = builder.create();
|
|
|
|
showDialog(dialog);
|
|
|
|
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
|
|
if (button != null) {
|
|
|
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needClearList() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("ClearSearchAlertTitle", R.string.ClearSearchAlertTitle));
|
|
|
|
builder.setMessage(LocaleController.getString("ClearSearchAlert", R.string.ClearSearchAlert));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) {
|
|
|
|
searchViewPager.dialogsSearchAdapter.clearRecentSearch();
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.dialogsSearchAdapter.clearRecentHashtags();
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
AlertDialog dialog = builder.create();
|
|
|
|
showDialog(dialog);
|
|
|
|
TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
|
|
if (button != null) {
|
|
|
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
}
|
2020-10-02 13:25:02 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void runResultsEnterAnimation() {
|
|
|
|
if (searchViewPager != null) {
|
|
|
|
searchViewPager.runResultsEnterAnimation();
|
|
|
|
}
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
});
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
searchViewPager.searchListView.setOnItemClickListener((view, position) -> {
|
|
|
|
if (initialDialogsType == 10) {
|
|
|
|
onItemLongClick(view, position, 0, 0, -1, searchViewPager.dialogsSearchAdapter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
onItemClick(view, position, searchViewPager.dialogsSearchAdapter);
|
|
|
|
});
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.searchListView.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) {
|
2020-09-30 15:48:47 +02:00
|
|
|
return onItemLongClick(view, position, x, y, -1, searchViewPager.dialogsSearchAdapter);
|
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
|
|
|
});
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setFilteredSearchViewDelegate((showMediaFilters, users, dates) -> DialogsActivity.this.updateFiltersView(showMediaFilters, users, dates, true));
|
|
|
|
searchViewPager.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
filtersView = new FiltersView(getParentActivity());
|
|
|
|
filtersView.setOnItemClickListener((view, position) -> {
|
|
|
|
filtersView.cancelClickRunnables(true);
|
|
|
|
addSearchFilter(filtersView.getFilterAt(position));
|
|
|
|
});
|
|
|
|
contentView.addView(filtersView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP));
|
|
|
|
filtersView.setVisibility(View.GONE);
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer = new FrameLayout(context);
|
2021-01-28 15:15:51 +01:00
|
|
|
floatingButtonContainer.setVisibility(onlySelect && initialDialogsType != 10 || folderId != 0 ? View.GONE : View.VISIBLE);
|
2020-12-23 08:48:30 +01:00
|
|
|
contentView.addView(floatingButtonContainer, 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, 0));
|
2019-01-23 18:03:33 +01:00
|
|
|
floatingButtonContainer.setOnClickListener(v -> {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType == 10) {
|
|
|
|
if (delegate == null || selectedDialogs.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, null, false);
|
|
|
|
} else {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("destroyAfterSelect", true);
|
|
|
|
presentFragment(new ContactsActivity(args));
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
});
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
floatingButton = new RLottieImageView(context);
|
2015-05-21 23:27:27 +02:00
|
|
|
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();
|
2020-06-25 17:29:04 +02:00
|
|
|
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.SRC_IN));
|
2017-03-31 01:58:05 +02:00
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
|
|
|
|
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
drawable = combinedDrawable;
|
|
|
|
}
|
|
|
|
floatingButton.setBackgroundDrawable(drawable);
|
2020-06-25 17:29:04 +02:00
|
|
|
floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.SRC_IN));
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType == 10) {
|
|
|
|
floatingButton.setImageResource(R.drawable.floating_check);
|
|
|
|
floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
|
|
|
|
} else {
|
|
|
|
floatingButton.setAnimation(R.raw.write_contacts_fab_icon, 52, 52);
|
|
|
|
floatingButtonContainer.setContentDescription(LocaleController.getString("NewMessageTitle", R.string.NewMessageTitle));
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-12-23 08:48:30 +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, 6, 10, 0));
|
2015-05-21 23:27:27 +02:00
|
|
|
|
2020-10-01 03:59:32 +02:00
|
|
|
searchTabsView = null;
|
2015-04-09 20:00:14 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!onlySelect && initialDialogsType == 0) {
|
|
|
|
fragmentLocationContextView = new FragmentContextView(context, this, true);
|
2020-10-30 11:26:29 +01:00
|
|
|
fragmentLocationContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
|
2020-09-30 15:48:47 +02:00
|
|
|
contentView.addView(fragmentLocationContextView);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
fragmentContextView = new FragmentContextView(context, this, false) {
|
|
|
|
@Override
|
|
|
|
protected void playbackSpeedChanged(boolean enabled) {
|
|
|
|
getUndoView().showWithAction(0, enabled ? UndoView.ACTION_PLAYBACK_SPEED_ENABLED : UndoView.ACTION_PLAYBACK_SPEED_DISABLED, null);
|
|
|
|
}
|
|
|
|
};
|
2020-10-30 11:26:29 +01:00
|
|
|
fragmentContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0));
|
2020-09-30 15:48:47 +02:00
|
|
|
contentView.addView(fragmentContextView);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
fragmentContextView.setAdditionalContextView(fragmentLocationContextView);
|
|
|
|
fragmentLocationContextView.setAdditionalContextView(fragmentContextView);
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (initialDialogsType == 3) {
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onDestroy();
|
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
commentView = new ChatActivityEnterView(getParentActivity(), contentView, null, false) {
|
|
|
|
@Override
|
|
|
|
public boolean dispatchTouchEvent(MotionEvent ev) {
|
|
|
|
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
|
|
|
}
|
|
|
|
return super.dispatchTouchEvent(ev);
|
|
|
|
}
|
|
|
|
};
|
2017-12-08 18:35:59 +01:00
|
|
|
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
|
2019-09-10 12:56:11 +02:00
|
|
|
public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (delegate == null || selectedDialogs.isEmpty()) {
|
2017-12-08 18:35:59 +01:00
|
|
|
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
|
2020-03-30 14:00:09 +02:00
|
|
|
public void didPressAttachButton() {
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-10 12:56:11 +02:00
|
|
|
public void needStartRecordVideo(int state, boolean notify, int scheduleDate) {
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needChangeVideoPreviewState(int state, float seekProgress) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needStartRecordAudio(int state) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needShowMediaBanHint() {
|
|
|
|
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) {
|
|
|
|
|
|
|
|
}
|
2020-01-23 07:15:40 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSendLongClick() {
|
|
|
|
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAudioVideoInterfaceUpdated() {
|
|
|
|
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
contentView.addView(filterTabsView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44));
|
|
|
|
}
|
2020-04-08 10:16:23 +02:00
|
|
|
if ((initialDialogsType == 3 && NekoConfig.showTabsOnForward) || !onlySelect) {
|
2020-09-30 15:48:47 +02:00
|
|
|
final FrameLayout.LayoutParams layoutParams = LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT);
|
|
|
|
if (inPreviewMode && Build.VERSION.SDK_INT >= 21) {
|
|
|
|
layoutParams.topMargin = AndroidUtilities.statusBarHeight;
|
|
|
|
}
|
|
|
|
contentView.addView(actionBar, layoutParams);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0; a < 2; a++) {
|
|
|
|
undoView[a] = new UndoView(context) {
|
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
|
|
|
if (this == undoView[0] && undoView[1].getVisibility() != VISIBLE) {
|
2020-03-30 14:00:09 +02:00
|
|
|
additionalFloatingTranslation = getMeasuredHeight() + AndroidUtilities.dp(8) - translationY;
|
|
|
|
if (additionalFloatingTranslation < 0) {
|
|
|
|
additionalFloatingTranslation = 0;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (!floatingHidden) {
|
2019-12-31 14:08:08 +01:00
|
|
|
updateFloatingButtonOffset();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
@Override
|
|
|
|
protected boolean canUndo() {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].dialogsItemAnimator.isRunning()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
contentView.addView(undoView[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.LEFT, 8, 0, 8, 8));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (folderId != 0) {
|
|
|
|
viewPages[0].listView.setGlowColor(Theme.getColor(Theme.key_actionBarDefaultArchived));
|
|
|
|
actionBar.setTitleColor(Theme.getColor(Theme.key_actionBarDefaultArchivedTitle));
|
|
|
|
actionBar.setItemsColor(Theme.getColor(Theme.key_actionBarDefaultArchivedIcon), false);
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSelector), false);
|
|
|
|
actionBar.setSearchTextColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSearch), false);
|
|
|
|
actionBar.setSearchTextColor(Theme.getColor(Theme.key_actionBarDefaultArchivedSearchPlaceholder), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!onlySelect && initialDialogsType == 0) {
|
2021-01-01 05:38:45 +01:00
|
|
|
blurredView = new View(context) {
|
|
|
|
@Override
|
|
|
|
public void setAlpha(float alpha) {
|
|
|
|
super.setAlpha(alpha);
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
|
|
|
};
|
2020-09-30 15:48:47 +02:00
|
|
|
blurredView.setVisibility(View.GONE);
|
|
|
|
contentView.addView(blurredView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
}
|
|
|
|
|
|
|
|
actionBarDefaultPaint.setColor(Theme.getColor(folderId == 0 ? Theme.key_actionBarDefault : Theme.key_actionBarDefaultArchived));
|
|
|
|
if (inPreviewMode) {
|
2020-12-24 06:36:01 +01:00
|
|
|
final TLRPC.User currentUser = getUserConfig().getCurrentUser();
|
2020-09-30 15:48:47 +02:00
|
|
|
avatarContainer = new ChatAvatarContainer(actionBar.getContext(), null, false);
|
|
|
|
avatarContainer.setTitle(UserObject.getUserName(currentUser));
|
|
|
|
avatarContainer.setSubtitle(LocaleController.formatUserStatus(currentAccount, currentUser));
|
|
|
|
avatarContainer.setUserAvatar(currentUser, true);
|
|
|
|
avatarContainer.setOccupyStatusBar(false);
|
|
|
|
avatarContainer.setLeftPadding(AndroidUtilities.dp(10));
|
|
|
|
actionBar.addView(avatarContainer, 0, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 40, 0));
|
|
|
|
floatingButton.setVisibility(View.INVISIBLE);
|
|
|
|
actionBar.setOccupyStatusBar(false);
|
|
|
|
actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
|
|
|
|
if (fragmentContextView != null) {
|
|
|
|
contentView.removeView(fragmentContextView);
|
|
|
|
}
|
|
|
|
if (fragmentLocationContextView != null) {
|
|
|
|
contentView.removeView(fragmentLocationContextView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
searchIsShowed = false;
|
2020-12-23 08:48:30 +01:00
|
|
|
updateFilterTabs(false, false);
|
|
|
|
|
|
|
|
if (searchString != null) {
|
|
|
|
showSearch(true, false);
|
|
|
|
actionBar.openSearchField(searchString, false);
|
|
|
|
} else if (initialSearchString != null) {
|
|
|
|
showSearch(true, false);
|
|
|
|
actionBar.openSearchField(initialSearchString, false);
|
|
|
|
initialSearchString = null;
|
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.setTranslationY(-AndroidUtilities.dp(44));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
showSearch(false, false);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2020-10-02 23:48:16 +02:00
|
|
|
if (folderId != 0) {
|
2020-12-23 08:48:30 +01:00
|
|
|
FiltersView.MediaFilterData filterData = new FiltersView.MediaFilterData(R.drawable.chats_archive, R.drawable.chats_archive, LocaleController.getString("ArchiveSearchFilter", R.string.ArchiveSearchFilter), null, FiltersView.FILTER_TYPE_ARCHIVE);
|
2020-10-02 23:48:16 +02:00
|
|
|
filterData.removable = false;
|
|
|
|
actionBar.setSearchFilter(filterData);
|
|
|
|
searchItem.collapseSearchFilters();
|
|
|
|
}
|
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
PrivacyUtil.postCheckAll(getParentActivity(), currentAccount);
|
2020-12-13 19:41:07 +01:00
|
|
|
UpdateUtil.postCheckFollowChannel(getParentActivity(), currentAccount);
|
2020-10-01 11:01:48 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateContextViewPosition() {
|
|
|
|
float filtersTabsHeight = 0;
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() != View.GONE) {
|
|
|
|
filtersTabsHeight = filterTabsView.getMeasuredHeight();
|
|
|
|
}
|
|
|
|
float searchTabsHeight = 0;
|
|
|
|
if (searchTabsView != null && searchTabsView.getVisibility() != View.GONE) {
|
|
|
|
searchTabsHeight = searchTabsView.getMeasuredHeight();
|
|
|
|
}
|
|
|
|
if (fragmentContextView != null) {
|
2020-10-02 23:48:16 +02:00
|
|
|
float from = 0;
|
|
|
|
if (fragmentLocationContextView != null && fragmentLocationContextView.getVisibility() == View.VISIBLE) {
|
|
|
|
from += AndroidUtilities.dp(36);
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
fragmentContextView.setTranslationY(from + fragmentContextView.getTopPadding() + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress + tabsYOffset);
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
if (fragmentLocationContextView != null) {
|
2020-10-02 23:48:16 +02:00
|
|
|
float from = 0;
|
2020-12-23 08:48:30 +01:00
|
|
|
if (fragmentContextView != null && fragmentContextView.getVisibility() == View.VISIBLE) {
|
|
|
|
from += AndroidUtilities.dp(fragmentContextView.getStyleHeight()) + fragmentContextView.getTopPadding();
|
2020-10-02 23:48:16 +02:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
fragmentLocationContextView.setTranslationY(from + fragmentLocationContextView.getTopPadding() + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress + tabsYOffset);
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateFiltersView(boolean showMediaFilters, ArrayList<TLObject> users, ArrayList<FiltersView.DateData> dates, boolean animated) {
|
|
|
|
if (!searchIsShowed || onlySelect) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boolean hasMediaFilter = false;
|
|
|
|
boolean hasUserFilter = false;
|
|
|
|
boolean hasDataFilter = false;
|
|
|
|
|
|
|
|
ArrayList<FiltersView.MediaFilterData> currentSearchFilters = searchViewPager.getCurrentSearchFilters();
|
|
|
|
for (int i = 0; i < currentSearchFilters.size(); i++) {
|
|
|
|
if (currentSearchFilters.get(i).isMedia()) {
|
|
|
|
hasMediaFilter = true;
|
|
|
|
} else if (currentSearchFilters.get(i).filterType == FiltersView.FILTER_TYPE_CHAT) {
|
|
|
|
hasUserFilter = true;
|
|
|
|
} else if (currentSearchFilters.get(i).filterType == FiltersView.FILTER_TYPE_DATE) {
|
|
|
|
hasDataFilter = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean visible = false;
|
|
|
|
boolean hasUsersOrDates = (users != null && !users.isEmpty()) || (dates != null && !dates.isEmpty());
|
|
|
|
if (!hasMediaFilter && !hasUsersOrDates && showMediaFilters) {
|
|
|
|
} else if (hasUsersOrDates) {
|
|
|
|
ArrayList<TLObject> finalUsers = (users != null && !users.isEmpty() && !hasUserFilter) ? users : null;
|
|
|
|
ArrayList<FiltersView.DateData> finalDates = (dates != null && !dates.isEmpty() && !hasDataFilter) ? dates : null;
|
|
|
|
if (finalUsers != null || finalDates != null) {
|
|
|
|
visible = true;
|
|
|
|
filtersView.setUsersAndDates(finalUsers, finalDates);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!visible) {
|
|
|
|
filtersView.setUsersAndDates(null, null);
|
|
|
|
}
|
|
|
|
if (!animated) {
|
|
|
|
filtersView.getAdapter().notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
if (searchTabsView != null) {
|
|
|
|
searchTabsView.hide(visible, true);
|
|
|
|
}
|
|
|
|
filtersView.setEnabled(visible);
|
|
|
|
filtersView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addSearchFilter(FiltersView.MediaFilterData filter) {
|
|
|
|
if (!searchIsShowed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ArrayList<FiltersView.MediaFilterData> currentSearchFilters = searchViewPager.getCurrentSearchFilters();
|
|
|
|
if (!currentSearchFilters.isEmpty()) {
|
|
|
|
for (int i = 0; i < currentSearchFilters.size(); i++) {
|
|
|
|
if (filter.isSameType(currentSearchFilters.get(i))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentSearchFilters.add(filter);
|
|
|
|
actionBar.setSearchFilter(filter);
|
|
|
|
actionBar.setSearchFieldText("");
|
|
|
|
updateFiltersView(true, null, null, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void createActionMode() {
|
|
|
|
if (actionBar.actionModeIsExist(null)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
final ActionBarMenu actionMode = actionBar.createActionMode();
|
|
|
|
actionMode.setBackground(null);
|
|
|
|
|
|
|
|
selectedDialogsCountTextView = new NumberTextView(actionMode.getContext());
|
|
|
|
selectedDialogsCountTextView.setTextSize(18);
|
|
|
|
selectedDialogsCountTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
selectedDialogsCountTextView.setTextColor(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon));
|
|
|
|
actionMode.addView(selectedDialogsCountTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 72, 0, 0, 0));
|
|
|
|
selectedDialogsCountTextView.setOnTouchListener((v, event) -> true);
|
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
pinItem = actionMode.addItemWithWidth(pin, R.drawable.deproko_baseline_pin_24, AndroidUtilities.dp(54));
|
|
|
|
muteItem = actionMode.addItemWithWidth(mute, R.drawable.baseline_volume_off_24_white, AndroidUtilities.dp(54));
|
|
|
|
archive2Item = actionMode.addItemWithWidth(archive2, R.drawable.baseline_archive_24, AndroidUtilities.dp(54));
|
|
|
|
deleteItem = actionMode.addItemWithWidth(delete, R.drawable.baseline_delete_24, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete));
|
2020-09-30 15:48:47 +02:00
|
|
|
ActionBarMenuItem otherItem = actionMode.addItemWithWidth(0, R.drawable.ic_ab_other, AndroidUtilities.dp(54), LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
|
2020-10-01 11:01:48 +02:00
|
|
|
archiveItem = otherItem.addSubItem(archive, R.drawable.baseline_archive_24, LocaleController.getString("Archive", R.string.Archive));
|
|
|
|
pin2Item = otherItem.addSubItem(pin2, R.drawable.deproko_baseline_pin_24, LocaleController.getString("DialogPin", R.string.DialogPin));
|
2021-02-04 18:59:00 +01:00
|
|
|
addToFolderItem = otherItem.addSubItem(add_to_folder, R.drawable.baseline_folder_24, LocaleController.getString("FilterAddTo", R.string.FilterAddTo));
|
|
|
|
removeFromFolderItem = otherItem.addSubItem(remove_from_folder, R.drawable.baseline_folder_open_24, LocaleController.getString("FilterRemoveFrom", R.string.FilterRemoveFrom));
|
|
|
|
readItem = otherItem.addSubItem(read, R.drawable.baseline_done_all_24, LocaleController.getString("MarkAsRead", R.string.MarkAsRead));
|
2020-10-01 11:01:48 +02:00
|
|
|
clearItem = otherItem.addSubItem(clear, R.drawable.baseline_delete_sweep_24, LocaleController.getString("ClearHistory", R.string.ClearHistory));
|
|
|
|
blockItem = otherItem.addSubItem(block, R.drawable.baseline_block_24, LocaleController.getString("BlockUser", R.string.BlockUser));
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
actionModeViews.add(pinItem);
|
|
|
|
actionModeViews.add(archive2Item);
|
|
|
|
actionModeViews.add(muteItem);
|
|
|
|
actionModeViews.add(deleteItem);
|
|
|
|
actionModeViews.add(otherItem);
|
|
|
|
|
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == SearchViewPager.forwardItemId || id == SearchViewPager.gotoItemId && searchViewPager != null) {
|
|
|
|
searchViewPager.onActionBarItemClick(id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (id == -1) {
|
|
|
|
if (filterTabsView != null && filterTabsView.isEditing()) {
|
|
|
|
filterTabsView.setIsEditing(false);
|
|
|
|
showDoneItem(false);
|
|
|
|
} else if (actionBar.isActionModeShowed()) {
|
|
|
|
if (searchViewPager != null && searchViewPager.getVisibility() == View.VISIBLE) {
|
|
|
|
searchViewPager.hideActionMode();
|
|
|
|
} else {
|
|
|
|
hideActionMode(true);
|
|
|
|
}
|
|
|
|
} else if (onlySelect || folderId != 0) {
|
|
|
|
finishFragment();
|
|
|
|
} else if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().openDrawer(false);
|
|
|
|
}
|
|
|
|
} else if (id == 1) {
|
|
|
|
SharedConfig.appLocked = !SharedConfig.appLocked;
|
|
|
|
SharedConfig.saveConfig();
|
2021-01-28 15:15:51 +01:00
|
|
|
updatePasscodeButton(true);
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (id == 2) {
|
|
|
|
presentFragment(new ProxyListActivity());
|
2020-10-01 11:01:48 +02:00
|
|
|
} else if (id == 3) {
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
|
|
if (getParentActivity().checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
getParentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA}, 22);
|
|
|
|
return;
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
CameraScanActivity.showAsSheet(DialogsActivity.this, new CameraScanActivity.CameraScanActivityDelegate() {
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
@Override
|
|
|
|
public void didFindQr(String text) {
|
2020-06-04 18:47:15 +02:00
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
ProxyUtil.showLinkAlert(getParentActivity(), text);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2020-10-01 11:01:48 +02:00
|
|
|
}
|
|
|
|
});
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DialogsActivityDelegate oldDelegate = delegate;
|
2021-02-13 04:19:54 +01:00
|
|
|
|
|
|
|
if (getParentActivity() instanceof LaunchActivity) {
|
|
|
|
|
|
|
|
LaunchActivity launchActivity = (LaunchActivity) getParentActivity();
|
|
|
|
launchActivity.switchToAccount(id - 10, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
FeedWidgetConfigActivity feedActivity = (FeedWidgetConfigActivity) getParentActivity();
|
|
|
|
feedActivity.switchToAccount(id - 10);
|
|
|
|
|
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
DialogsActivity dialogsActivity = new DialogsActivity(arguments);
|
|
|
|
dialogsActivity.setDelegate(oldDelegate);
|
2021-02-13 04:19:54 +01:00
|
|
|
|
|
|
|
if (getParentActivity() instanceof LaunchActivity) {
|
|
|
|
|
|
|
|
LaunchActivity launchActivity = (LaunchActivity) getParentActivity();
|
|
|
|
launchActivity.presentFragment(dialogsActivity, false, true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
FeedWidgetConfigActivity feedActivity = (FeedWidgetConfigActivity) getParentActivity();
|
|
|
|
feedActivity.presentFragment(dialogsActivity, false, true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (id == add_to_folder) {
|
|
|
|
FiltersListBottomSheet sheet = new FiltersListBottomSheet(DialogsActivity.this, selectedDialogs);
|
|
|
|
sheet.setDelegate(filter -> {
|
|
|
|
ArrayList<Integer> alwaysShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, true, false);
|
|
|
|
int currentCount;
|
|
|
|
if (filter != null) {
|
|
|
|
currentCount = filter.alwaysShow.size();
|
|
|
|
} else {
|
|
|
|
currentCount = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (currentCount + alwaysShow.size() > 100) {
|
|
|
|
showDialog(AlertsCreator.createSimpleAlert(getParentActivity(), LocaleController.getString("FilterAddToAlertFullTitle", R.string.FilterAddToAlertFullTitle), LocaleController.getString("FilterAddToAlertFullText", R.string.FilterAddToAlertFullText)).create());
|
|
|
|
return;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (filter != null) {
|
|
|
|
if (!alwaysShow.isEmpty()) {
|
|
|
|
for (int a = 0; a < alwaysShow.size(); a++) {
|
|
|
|
filter.neverShow.remove(alwaysShow.get(a));
|
|
|
|
}
|
|
|
|
filter.alwaysShow.addAll(alwaysShow);
|
|
|
|
FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null);
|
|
|
|
}
|
|
|
|
long did;
|
|
|
|
if (alwaysShow.size() == 1) {
|
|
|
|
did = alwaysShow.get(0);
|
|
|
|
} else {
|
|
|
|
did = 0;
|
|
|
|
}
|
|
|
|
getUndoView().showWithAction(did, UndoView.ACTION_ADDED_TO_FOLDER, alwaysShow.size(), filter, null, null);
|
|
|
|
} else {
|
|
|
|
presentFragment(new FilterCreateActivity(null, alwaysShow));
|
|
|
|
}
|
|
|
|
hideActionMode(true);
|
|
|
|
});
|
|
|
|
showDialog(sheet);
|
|
|
|
} else if (id == remove_from_folder) {
|
|
|
|
MessagesController.DialogFilter filter = getMessagesController().dialogFilters.get(viewPages[0].selectedType);
|
|
|
|
ArrayList<Integer> neverShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, false, false);
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
int currentCount;
|
|
|
|
if (filter != null) {
|
|
|
|
currentCount = filter.neverShow.size();
|
|
|
|
} else {
|
|
|
|
currentCount = 0;
|
|
|
|
}
|
|
|
|
if (currentCount + neverShow.size() > 100) {
|
|
|
|
showDialog(AlertsCreator.createSimpleAlert(getParentActivity(), LocaleController.getString("FilterAddToAlertFullTitle", R.string.FilterAddToAlertFullTitle), LocaleController.getString("FilterRemoveFromAlertFullText", R.string.FilterRemoveFromAlertFullText)).create());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!neverShow.isEmpty()) {
|
|
|
|
filter.neverShow.addAll(neverShow);
|
|
|
|
for (int a = 0; a < neverShow.size(); a++) {
|
|
|
|
Integer did = neverShow.get(a);
|
|
|
|
filter.alwaysShow.remove(did);
|
|
|
|
filter.pinnedDialogs.remove((long) did);
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, false, false, DialogsActivity.this, null);
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
long did;
|
|
|
|
if (neverShow.size() == 1) {
|
|
|
|
did = neverShow.get(0);
|
|
|
|
} else {
|
|
|
|
did = 0;
|
|
|
|
}
|
|
|
|
getUndoView().showWithAction(did, UndoView.ACTION_REMOVED_FROM_FOLDER, neverShow.size(), filter, null, null);
|
|
|
|
hideActionMode(false);
|
|
|
|
} else if (id == pin || id == read || id == delete || id == clear || id == mute || id == archive || id == block || id == archive2 || id == pin2) {
|
|
|
|
perfromSelectedDialogsAction(id, true);
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
});
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void switchToCurrentSelectedMode(boolean animated) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].listView.stopScroll();
|
|
|
|
}
|
|
|
|
int a = animated ? 1 : 0;
|
|
|
|
RecyclerView.Adapter currentAdapter = viewPages[a].listView.getAdapter();
|
|
|
|
|
|
|
|
if (viewPages[a].selectedType == Integer.MAX_VALUE) {
|
2020-04-08 10:16:23 +02:00
|
|
|
viewPages[a].dialogsType = initialDialogsType;
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[a].listView.updatePullState();
|
|
|
|
} else {
|
|
|
|
MessagesController.DialogFilter filter = getMessagesController().dialogFilters.get(viewPages[a].selectedType);
|
|
|
|
if (viewPages[a == 0 ? 1 : 0].dialogsType == 7) {
|
|
|
|
viewPages[a].dialogsType = 8;
|
|
|
|
} else {
|
|
|
|
viewPages[a].dialogsType = 7;
|
|
|
|
}
|
|
|
|
viewPages[a].listView.setScrollEnabled(true);
|
|
|
|
getMessagesController().selectDialogFilter(filter, viewPages[a].dialogsType == 8 ? 1 : 0);
|
|
|
|
}
|
|
|
|
viewPages[a].dialogsAdapter.setDialogsType(viewPages[a].dialogsType);
|
|
|
|
viewPages[a].layoutManager.scrollToPositionWithOffset(viewPages[a].dialogsType == 0 && hasHiddenArchive() ? 1 : 0, (int) actionBar.getTranslationY());
|
|
|
|
checkListLoad(viewPages[a]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean scrollBarVisible = true;
|
2020-06-25 17:29:04 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void showScrollbars(boolean show) {
|
|
|
|
if (viewPages == null || scrollBarVisible == show) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
scrollBarVisible = show;
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (show) {
|
|
|
|
viewPages[a].listView.setScrollbarFadingEnabled(false);
|
|
|
|
}
|
|
|
|
viewPages[a].listView.setVerticalScrollBarEnabled(show);
|
|
|
|
if (show) {
|
|
|
|
viewPages[a].listView.setScrollbarFadingEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void scrollToFilterTab(int index) {
|
|
|
|
if (filterTabsView == null || viewPages[0].selectedType == index) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
filterTabsView.selectTabWithId(index, 1.0f);
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(false);
|
|
|
|
viewPages[1].selectedType = viewPages[0].selectedType;
|
|
|
|
viewPages[0].selectedType = index;
|
|
|
|
switchToCurrentSelectedMode(false);
|
|
|
|
switchToCurrentSelectedMode(true);
|
|
|
|
updateCounters(false);
|
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
private void updateFilterTabs(boolean force, boolean animated) {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (filterTabsView == null || inPreviewMode || searchIsShowed) {
|
2020-03-30 14:00:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
scrimPopupWindow = null;
|
|
|
|
}
|
|
|
|
ArrayList<MessagesController.DialogFilter> filters = getMessagesController().dialogFilters;
|
|
|
|
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
|
|
|
|
if (!filters.isEmpty()) {
|
|
|
|
if (force || filterTabsView.getVisibility() != View.VISIBLE) {
|
2020-12-23 08:48:30 +01:00
|
|
|
boolean animatedUpdateItems = animated;
|
|
|
|
if (filterTabsView.getVisibility() != View.VISIBLE) {
|
|
|
|
animatedUpdateItems = false;
|
|
|
|
}
|
|
|
|
canShowFilterTabsView = true;
|
|
|
|
updateFilterTabsVisibility(animated);
|
2020-03-30 14:00:09 +02:00
|
|
|
int id = filterTabsView.getCurrentTabId();
|
|
|
|
if (id != Integer.MAX_VALUE && id >= filters.size()) {
|
|
|
|
filterTabsView.resetTabId();
|
|
|
|
}
|
|
|
|
filterTabsView.removeTabs();
|
2020-06-25 17:29:04 +02:00
|
|
|
if (!NekoConfig.hideAllTab)
|
2020-12-23 10:13:40 +01:00
|
|
|
filterTabsView.addTab(Integer.MAX_VALUE, 0, LocaleController.getString("FilterAllChats", R.string.FilterAllChats));
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0, N = filters.size(); a < N; a++) {
|
2020-04-26 08:50:44 +02:00
|
|
|
MessagesController.DialogFilter dialogFilter = filters.get(a);
|
|
|
|
switch (NekoConfig.tabsTitleType) {
|
|
|
|
case NekoConfig.TITLE_TYPE_TEXT:
|
2020-12-23 10:13:40 +01:00
|
|
|
filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.name);
|
2020-04-26 08:50:44 +02:00
|
|
|
break;
|
|
|
|
case NekoConfig.TITLE_TYPE_ICON:
|
2020-12-23 10:13:40 +01:00
|
|
|
filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon : "📂");
|
2020-04-26 08:50:44 +02:00
|
|
|
break;
|
|
|
|
case NekoConfig.TITLE_TYPE_MIX:
|
2020-12-23 10:13:40 +01:00
|
|
|
filterTabsView.addTab(a, filters.get(a).localId, dialogFilter.emoticon != null ? dialogFilter.emoticon + " " + dialogFilter.name : "📂 " + dialogFilter.name);
|
2020-04-26 08:50:44 +02:00
|
|
|
break;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
id = filterTabsView.getCurrentTabId();
|
2021-01-06 05:52:33 +01:00
|
|
|
boolean updateCurrentTab = NekoConfig.hideAllTab;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (id >= 0) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (viewPages[0].selectedType != id) {
|
|
|
|
updateCurrentTab = true;
|
|
|
|
viewPages[0].selectedType = id;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].selectedType != Integer.MAX_VALUE && viewPages[a].selectedType >= filters.size()) {
|
2020-04-17 05:27:50 +02:00
|
|
|
viewPages[a].selectedType = filters.size();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
viewPages[a].listView.setScrollingTouchSlop(RecyclerView.TOUCH_SLOP_PAGING);
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
filterTabsView.finishAddingTabs(animatedUpdateItems);
|
|
|
|
if (updateCurrentTab) {
|
|
|
|
switchToCurrentSelectedMode(false);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (filterTabsView.getVisibility() != View.GONE) {
|
2020-06-04 18:47:15 +02:00
|
|
|
filterTabsView.setIsEditing(false);
|
|
|
|
showDoneItem(false);
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
maybeStartTracking = false;
|
|
|
|
if (startedTracking) {
|
|
|
|
startedTracking = false;
|
|
|
|
viewPages[0].setTranslationX(0);
|
|
|
|
viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth());
|
|
|
|
}
|
|
|
|
if (viewPages[0].selectedType != Integer.MAX_VALUE) {
|
|
|
|
viewPages[0].selectedType = Integer.MAX_VALUE;
|
2020-04-08 10:16:23 +02:00
|
|
|
viewPages[0].dialogsAdapter.setDialogsType(initialDialogsType);
|
|
|
|
viewPages[0].dialogsType = initialDialogsType;
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].dialogsAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
viewPages[1].setVisibility(View.GONE);
|
|
|
|
viewPages[1].selectedType = Integer.MAX_VALUE;
|
2020-04-08 10:16:23 +02:00
|
|
|
viewPages[1].dialogsAdapter.setDialogsType(initialDialogsType);
|
|
|
|
viewPages[1].dialogsType = initialDialogsType;
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[1].dialogsAdapter.notifyDataSetChanged();
|
2020-12-23 08:48:30 +01:00
|
|
|
canShowFilterTabsView = false;
|
|
|
|
updateFilterTabsVisibility(animated);
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].dialogsType == 0 && viewPages[a].archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && hasHiddenArchive()) {
|
|
|
|
int p = viewPages[a].layoutManager.findFirstVisibleItemPosition();
|
|
|
|
if (p == 0 || p == 1) {
|
2021-01-28 15:15:51 +01:00
|
|
|
viewPages[a].layoutManager.scrollToPositionWithOffset(1, 0);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
viewPages[a].listView.setScrollingTouchSlop(RecyclerView.TOUCH_SLOP_DEFAULT);
|
|
|
|
viewPages[a].listView.requestLayout();
|
|
|
|
viewPages[a].requestLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (parentLayout != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateCounters(false);
|
|
|
|
}
|
|
|
|
|
2020-02-13 19:26:53 +01:00
|
|
|
@Override
|
2020-09-30 15:48:47 +02:00
|
|
|
protected void onPanTranslationUpdate(float y) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null) {
|
2020-02-13 19:26:53 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (commentView != null && commentView.isPopupShowing()) {
|
|
|
|
fragmentView.setTranslationY(y);
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].setTranslationY(0);
|
|
|
|
}
|
|
|
|
if (!onlySelect) {
|
|
|
|
actionBar.setTranslationY(0);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setTranslationY(0);
|
2020-02-13 19:26:53 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].setTranslationY(y);
|
|
|
|
}
|
|
|
|
if (!onlySelect) {
|
|
|
|
actionBar.setTranslationY(y);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setTranslationY(y);
|
2020-02-13 19:26:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
public void finishFragment() {
|
|
|
|
super.finishFragment();
|
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 18:00:42 +02:00
|
|
|
super.onResume();
|
2020-06-04 18:47:15 +02:00
|
|
|
if (!parentLayout.isInPreviewMode() && blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
|
|
|
|
blurredView.setVisibility(View.GONE);
|
|
|
|
blurredView.setBackground(null);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
2020-09-30 15:48:47 +02:00
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
if (viewPages != null && !dialogsListFrozen) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.notifyDataSetChanged();
|
|
|
|
}
|
2014-10-31 20:02:29 +01:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onResume();
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (!onlySelect && folderId == 0) {
|
|
|
|
getMediaDataController().checkStickers(MediaDataController.TYPE_EMOJI);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager != null) {
|
|
|
|
searchViewPager.onResume();
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
final boolean tosAccepted;
|
|
|
|
if (!afterSignup) {
|
2020-12-24 06:36:01 +01:00
|
|
|
tosAccepted = getUserConfig().unacceptedTermsOfService == null;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2021-02-23 12:53:38 +01:00
|
|
|
tosAccepted = true;
|
2019-12-31 14:08:08 +01:00
|
|
|
afterSignup = false;
|
|
|
|
}
|
|
|
|
if (tosAccepted && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) {
|
2015-10-29 18:10:07 +01:00
|
|
|
Activity activity = getParentActivity();
|
|
|
|
if (activity != null) {
|
|
|
|
checkPermission = false;
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean hasNotContactsPermission = activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED;
|
|
|
|
boolean hasNotStoragePermission = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED;
|
|
|
|
if (hasNotContactsPermission || hasNotStoragePermission) {
|
2020-03-30 14:00:09 +02:00
|
|
|
askingForPermissions = true;
|
2019-05-14 14:08:05 +02:00
|
|
|
if (hasNotContactsPermission && askAboutContacts && getUserConfig().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;
|
2020-06-25 17:29:04 +02:00
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
|
2018-08-27 10:33:11 +02:00
|
|
|
askForPermissons(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
showDialog(permissionDialog = builder.create());
|
2019-05-14 14:08:05 +02:00
|
|
|
} else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
2015-10-29 18:10:07 +01:00
|
|
|
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
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
showFiltersHint();
|
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].dialogsType == 0 && viewPages[a].archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && viewPages[a].layoutManager.findFirstVisibleItemPosition() == 0 && hasHiddenArchive()) {
|
|
|
|
viewPages[a].layoutManager.scrollToPositionWithOffset(1, 0);
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
if (a == 0) {
|
|
|
|
viewPages[a].dialogsAdapter.resume();
|
|
|
|
} else {
|
|
|
|
viewPages[a].dialogsAdapter.pause();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
showNextSupportedSuggestion();
|
2020-09-30 15:48:47 +02:00
|
|
|
Bulletin.addDelegate(this, new Bulletin.Delegate() {
|
|
|
|
@Override
|
|
|
|
public void onOffsetChange(float offset) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (undoView[0] != null && undoView[0].getVisibility() == View.VISIBLE) {
|
|
|
|
return;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
additionalFloatingTranslation = offset;
|
|
|
|
if (additionalFloatingTranslation < 0) {
|
|
|
|
additionalFloatingTranslation = 0;
|
|
|
|
}
|
|
|
|
if (!floatingHidden) {
|
|
|
|
updateFloatingButtonOffset();
|
|
|
|
}
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onShow(Bulletin bulletin) {
|
|
|
|
if (undoView[0] != null && undoView[0].getVisibility() == View.VISIBLE) {
|
|
|
|
undoView[0].hide(true, 2);
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
});
|
|
|
|
if (searchIsShowed) {
|
|
|
|
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
@Override
|
|
|
|
public boolean presentFragment(BaseFragment fragment) {
|
|
|
|
boolean b = super.presentFragment(fragment);
|
|
|
|
if (b) {
|
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.pause();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return b;
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
super.onPause();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.onResume();
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (undoView[0] != null) {
|
|
|
|
undoView[0].hide(true, 0);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
Bulletin.removeDelegate(this);
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.pause();
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onBackPressed() {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
return false;
|
|
|
|
} else if (filterTabsView != null && filterTabsView.isEditing()) {
|
|
|
|
filterTabsView.setIsEditing(false);
|
|
|
|
showDoneItem(false);
|
|
|
|
return false;
|
|
|
|
} else if (actionBar != null && actionBar.isActionModeShowed()) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager.getVisibility() == View.VISIBLE) {
|
|
|
|
searchViewPager.hideActionMode();
|
|
|
|
} else {
|
|
|
|
hideActionMode(true);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
return false;
|
2020-03-30 18:49:17 +02:00
|
|
|
} else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) {
|
2020-03-30 14:00:09 +02:00
|
|
|
filterTabsView.selectFirstTab();
|
|
|
|
return false;
|
2019-05-14 14:08:05 +02:00
|
|
|
} else if (commentView != null && commentView.isPopupShowing()) {
|
|
|
|
commentView.hidePopup(true);
|
|
|
|
return false;
|
2019-02-08 03:30:32 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
return super.onBackPressed();
|
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) {
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
2019-01-23 18:03:33 +01:00
|
|
|
searchObject = null;
|
|
|
|
}
|
|
|
|
closeSearchFieldOnHide = false;
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsViewIsVisible) {
|
2020-06-04 18:47:15 +02:00
|
|
|
int scrollY = (int) -actionBar.getTranslationY();
|
|
|
|
int actionBarHeight = ActionBar.getCurrentActionBarHeight();
|
|
|
|
if (scrollY != 0 && scrollY != actionBarHeight) {
|
|
|
|
if (scrollY < actionBarHeight / 2) {
|
|
|
|
setScrollY(0);
|
|
|
|
} else if (viewPages[0].listView.canScrollVertically(1)) {
|
|
|
|
setScrollY(-actionBarHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (undoView[0] != null) {
|
|
|
|
undoView[0].hide(true, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
@Override
|
|
|
|
protected void setInPreviewMode(boolean value) {
|
|
|
|
super.setInPreviewMode(value);
|
|
|
|
if (!value && avatarContainer != null) {
|
|
|
|
actionBar.setBackground(null);
|
|
|
|
((ViewGroup.MarginLayoutParams) actionBar.getLayoutParams()).topMargin = 0;
|
|
|
|
actionBar.removeView(avatarContainer);
|
|
|
|
avatarContainer = null;
|
2020-12-23 08:48:30 +01:00
|
|
|
updateFilterTabs(false, false);
|
2020-09-30 15:48:47 +02:00
|
|
|
floatingButton.setVisibility(View.VISIBLE);
|
|
|
|
final ContentView contentView = (ContentView) fragmentView;
|
|
|
|
if (fragmentContextView != null) {
|
|
|
|
contentView.addView(fragmentContextView);
|
|
|
|
}
|
|
|
|
if (fragmentLocationContextView != null) {
|
|
|
|
contentView.addView(fragmentLocationContextView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
public boolean addOrRemoveSelectedDialog(long did, View cell) {
|
|
|
|
if (selectedDialogs.contains(did)) {
|
|
|
|
selectedDialogs.remove(did);
|
|
|
|
if (cell instanceof DialogCell) {
|
|
|
|
((DialogCell) cell).setChecked(false, true);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
selectedDialogs.add(did);
|
|
|
|
if (cell instanceof DialogCell) {
|
|
|
|
((DialogCell) cell).setChecked(true, true);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public void search(String query, boolean animated) {
|
|
|
|
showSearch(true, animated);
|
|
|
|
actionBar.openSearchField(query, false);
|
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
private void showSearch(boolean show, boolean animated) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (initialDialogsType != 0 && initialDialogsType != 3) {
|
2019-12-31 14:08:08 +01:00
|
|
|
animated = false;
|
|
|
|
}
|
|
|
|
if (searchAnimator != null) {
|
|
|
|
searchAnimator.cancel();
|
|
|
|
searchAnimator = null;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (tabsAlphaAnimator != null) {
|
|
|
|
tabsAlphaAnimator.cancel();
|
|
|
|
tabsAlphaAnimator = null;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchIsShowed = show;
|
|
|
|
if (show) {
|
2021-01-28 15:15:51 +01:00
|
|
|
boolean onlyDialogsAdapter;
|
|
|
|
if (searchFiltersWasShowed) {
|
|
|
|
onlyDialogsAdapter = false;
|
|
|
|
} else {
|
|
|
|
onlyDialogsAdapter = onlyDialogsAdapter();
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.showOnlyDialogsAdapter(onlyDialogsAdapter);
|
|
|
|
whiteActionBar = !onlyDialogsAdapter;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (whiteActionBar) {
|
|
|
|
searchFiltersWasShowed = true;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
ContentView contentView = (ContentView) fragmentView;
|
|
|
|
if (searchTabsView == null && !onlyDialogsAdapter) {
|
|
|
|
searchTabsView = searchViewPager.createTabsView();
|
|
|
|
int filtersViewPosition = -1;
|
|
|
|
if (filtersView != null) {
|
|
|
|
for (int i = 0; i < contentView.getChildCount(); i++) {
|
|
|
|
if (contentView.getChildAt(i) == filtersView) {
|
|
|
|
filtersViewPosition = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filtersViewPosition > 0) {
|
|
|
|
contentView.addView(searchTabsView, filtersViewPosition, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44));
|
|
|
|
} else {
|
|
|
|
contentView.addView(searchTabsView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44));
|
|
|
|
}
|
|
|
|
} else if (searchTabsView != null && onlyDialogsAdapter) {
|
2020-10-01 03:59:32 +02:00
|
|
|
ViewParent parent = searchTabsView.getParent();
|
|
|
|
if (parent instanceof ViewGroup) {
|
|
|
|
((ViewGroup) parent).removeView(searchTabsView);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchTabsView = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
EditTextBoldCursor editText = searchItem.getSearchField();
|
|
|
|
if (whiteActionBar) {
|
|
|
|
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
editText.setHintTextColor(Theme.getColor(Theme.key_player_time));
|
|
|
|
editText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor));
|
|
|
|
} else {
|
|
|
|
editText.setCursorColor(Theme.getColor(Theme.key_actionBarDefaultSearch));
|
|
|
|
editText.setHintTextColor(Theme.getColor(Theme.key_actionBarDefaultSearchPlaceholder));
|
|
|
|
editText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSearch));
|
|
|
|
}
|
2021-02-06 12:40:02 +01:00
|
|
|
searchViewPager.setKeyboardHeight(((ContentView) fragmentView).getKeyboardHeight());
|
2020-09-30 15:48:47 +02:00
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(true);
|
|
|
|
} else {
|
|
|
|
if (filterTabsView != null) {
|
|
|
|
parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-05 00:13:31 +02:00
|
|
|
if (animated && searchViewPager.dialogsSearchAdapter.hasRecentSearch()) {
|
2020-09-30 15:48:47 +02:00
|
|
|
AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid);
|
|
|
|
} else {
|
|
|
|
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
if (!show && filterTabsView != null && canShowFilterTabsView) {
|
2020-09-30 15:48:47 +02:00
|
|
|
filterTabsView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
if (animated) {
|
|
|
|
if (show) {
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setVisibility(View.VISIBLE);
|
|
|
|
searchViewPager.reset();
|
2021-02-06 12:40:02 +01:00
|
|
|
updateFiltersView(true, null, null, false);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchTabsView != null) {
|
|
|
|
searchTabsView.hide(false, false);
|
|
|
|
searchTabsView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-10-02 23:48:16 +02:00
|
|
|
searchItem.getSearchContainer().setAlpha(0f);
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.setVisibility(View.VISIBLE);
|
|
|
|
viewPages[0].setVisibility(View.VISIBLE);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
setDialogsListFrozen(true);
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.setVerticalScrollBarEnabled(false);
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
2019-12-31 14:08:08 +01:00
|
|
|
searchAnimator = new AnimatorSet();
|
2020-03-30 14:00:09 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(viewPages[0], View.ALPHA, show ? 0.0f : 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(viewPages[0], View.SCALE_X, show ? 0.9f : 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(viewPages[0], View.SCALE_Y, show ? 0.9f : 1.0f));
|
2020-09-30 15:48:47 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(searchViewPager, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(searchViewPager, View.SCALE_X, show ? 1.0f : 1.05f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(searchViewPager, View.SCALE_Y, show ? 1.0f : 1.05f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(searchItem.getIconView(), View.ALPHA, show ? 0 : 1f));
|
2020-10-30 11:26:29 +01:00
|
|
|
if (passcodeItem != null) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(passcodeItem.getIconView(), View.ALPHA, show ? 0 : 1f));
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(searchItem.getSearchContainer(), View.ALPHA, show ? 1f : 0));
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
2020-03-30 14:00:09 +02:00
|
|
|
tabsAlphaAnimator = ObjectAnimator.ofFloat(filterTabsView.getTabsContainer(), View.ALPHA, show ? 0.0f : 1.0f).setDuration(100);
|
|
|
|
tabsAlphaAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
tabsAlphaAnimator = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
ValueAnimator valueAnimator = ValueAnimator.ofFloat(searchAnimationProgress, show ? 1f : 0);
|
|
|
|
valueAnimator.addUpdateListener(valueAnimator1 -> setSearchAnimationProgress((float) valueAnimator1.getAnimatedValue()));
|
|
|
|
|
|
|
|
animators.add(valueAnimator);
|
2020-03-30 14:00:09 +02:00
|
|
|
searchAnimator.playTogether(animators);
|
2019-12-31 14:08:08 +01:00
|
|
|
searchAnimator.setDuration(show ? 200 : 180);
|
|
|
|
searchAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT);
|
|
|
|
if (!show) {
|
|
|
|
searchAnimator.setStartDelay(20);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (tabsAlphaAnimator != null) {
|
|
|
|
tabsAlphaAnimator.setStartDelay(80);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
searchAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().onAnimationFinish(animationIndex);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (searchAnimator != animation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setDialogsListFrozen(false);
|
|
|
|
if (show) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.hide();
|
2020-09-30 15:48:47 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
searchWasFullyShowed = true;
|
|
|
|
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
|
|
|
searchItem.setVisibility(View.GONE);
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-10-02 23:48:16 +02:00
|
|
|
searchItem.collapseSearchFilters();
|
2020-09-30 15:48:47 +02:00
|
|
|
whiteActionBar = false;
|
|
|
|
searchViewPager.setVisibility(View.GONE);
|
|
|
|
if (searchTabsView != null) {
|
|
|
|
searchTabsView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
searchItem.clearSearchFilters();
|
|
|
|
searchViewPager.clear();
|
|
|
|
filtersView.setVisibility(View.GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.show();
|
2019-12-31 14:08:08 +01:00
|
|
|
if (!onlySelect) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
searchWasFullyShowed = false;
|
2020-09-30 18:55:35 +02:00
|
|
|
searchItem.getSearchContainer().setAlpha(1f);
|
2020-10-02 13:25:02 +02:00
|
|
|
}
|
2020-09-30 18:55:35 +02:00
|
|
|
|
2020-10-02 13:25:02 +02:00
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.requestLayout();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
setSearchAnimationProgress(show ? 1f : 0);
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.setVerticalScrollBarEnabled(true);
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setBackground(null);
|
2019-12-31 14:08:08 +01:00
|
|
|
searchAnimator = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().onAnimationFinish(animationIndex);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (searchAnimator == animation) {
|
|
|
|
if (show) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.hide();
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.show();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
searchAnimator = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-12-24 06:36:01 +01:00
|
|
|
animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
|
2019-12-31 14:08:08 +01:00
|
|
|
searchAnimator.start();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (tabsAlphaAnimator != null) {
|
|
|
|
tabsAlphaAnimator.start();
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
|
|
|
setDialogsListFrozen(false);
|
|
|
|
if (show) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.hide();
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.show();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].setAlpha(show ? 0.0f : 1.0f);
|
|
|
|
viewPages[0].setScaleX(show ? 0.9f : 1.0f);
|
|
|
|
viewPages[0].setScaleY(show ? 0.9f : 1.0f);
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
filtersView.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
searchViewPager.setScaleX(show ? 1.0f : 1.1f);
|
|
|
|
searchViewPager.setScaleY(show ? 1.0f : 1.1f);
|
2020-09-30 18:55:35 +02:00
|
|
|
searchItem.getSearchContainer().setAlpha(show ? 1f : 0);
|
2020-06-04 18:47:15 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
2020-03-30 14:00:09 +02:00
|
|
|
filterTabsView.setTranslationY(show ? -AndroidUtilities.dp(44) : 0);
|
|
|
|
filterTabsView.getTabsContainer().setAlpha(show ? 0.0f : 1.0f);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (filterTabsView != null) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (canShowFilterTabsView && !show) {
|
2020-09-30 15:48:47 +02:00
|
|
|
filterTabsView.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
filterTabsView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
searchViewPager.setVisibility(show ? View.VISIBLE : View.GONE);
|
|
|
|
setSearchAnimationProgress(show ? 1f : 0);
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialSearchType >= 0) {
|
|
|
|
searchViewPager.setPosition(initialSearchType);
|
|
|
|
}
|
|
|
|
if (!show) {
|
|
|
|
initialSearchType = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean onlyDialogsAdapter() {
|
|
|
|
int dialogsCount = getMessagesController().getTotalDialogsCount();
|
|
|
|
return onlySelect || !searchViewPager.dialogsSearchAdapter.hasRecentSearch() || dialogsCount <= 10;
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
private void updateFilterTabsVisibility(boolean animated) {
|
|
|
|
if (isPaused) {
|
|
|
|
animated = false;
|
|
|
|
}
|
|
|
|
if (searchIsShowed) {
|
|
|
|
if (filtersTabAnimator != null) {
|
|
|
|
filtersTabAnimator.cancel();
|
|
|
|
}
|
|
|
|
filterTabsViewIsVisible = canShowFilterTabsView;
|
|
|
|
filterTabsProgress = filterTabsViewIsVisible ? 1f : 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
boolean visible = canShowFilterTabsView;
|
|
|
|
if (filterTabsViewIsVisible != visible) {
|
|
|
|
if (filtersTabAnimator != null) {
|
|
|
|
filtersTabAnimator.cancel();
|
|
|
|
}
|
|
|
|
filterTabsViewIsVisible = visible;
|
|
|
|
if (animated) {
|
|
|
|
if (visible) {
|
|
|
|
if (filterTabsView.getVisibility() != View.VISIBLE) {
|
|
|
|
filterTabsView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
filtersTabAnimator = ValueAnimator.ofFloat(0, 1f);
|
|
|
|
filterTabsMoveFrom = AndroidUtilities.dp(44);
|
|
|
|
} else {
|
|
|
|
filtersTabAnimator = ValueAnimator.ofFloat(1f, 0f);
|
|
|
|
filterTabsMoveFrom = Math.max(0, AndroidUtilities.dp(44) + actionBar.getTranslationY());
|
|
|
|
}
|
|
|
|
float animateFromScrollY = actionBar.getTranslationY();
|
|
|
|
filtersTabAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
filtersTabAnimator = null;
|
|
|
|
scrollAdditionalOffset = AndroidUtilities.dp(44) - filterTabsMoveFrom;
|
|
|
|
if (!visible) {
|
|
|
|
filterTabsView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.requestLayout();
|
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
getNotificationCenter().onAnimationFinish(animationIndex);
|
2020-12-23 08:48:30 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
filtersTabAnimator.addUpdateListener(valueAnimator -> {
|
|
|
|
filterTabsProgress = (float) valueAnimator.getAnimatedValue();
|
|
|
|
if (!visible) {
|
|
|
|
setScrollY(animateFromScrollY * filterTabsProgress);
|
|
|
|
}
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
filtersTabAnimator.setDuration(220);
|
|
|
|
filtersTabAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2020-12-24 06:36:01 +01:00
|
|
|
animationIndex = getNotificationCenter().setAnimationInProgress(animationIndex, null);
|
2020-12-23 08:48:30 +01:00
|
|
|
filtersTabAnimator.start();
|
|
|
|
fragmentView.requestLayout();
|
|
|
|
} else {
|
|
|
|
filterTabsProgress = visible ? 1f : 0;
|
|
|
|
filterTabsView.setVisibility(visible ? View.VISIBLE : View.GONE);
|
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private void setSearchAnimationProgress(float progress) {
|
|
|
|
searchAnimationProgress = progress;
|
|
|
|
if (whiteActionBar) {
|
|
|
|
int color1 = folderId != 0 ? Theme.getColor(Theme.key_actionBarDefaultArchivedIcon) : Theme.getColor(Theme.key_actionBarDefaultIcon);
|
|
|
|
actionBar.setItemsColor(ColorUtils.blendARGB(color1, Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), searchAnimationProgress), false);
|
|
|
|
actionBar.setItemsColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2), searchAnimationProgress), true);
|
|
|
|
|
|
|
|
color1 = folderId != 0 ? Theme.getColor(Theme.key_actionBarDefaultArchivedSelector) : Theme.getColor(Theme.key_actionBarDefaultSelector);
|
|
|
|
int color2 = Theme.getColor(Theme.key_actionBarActionModeDefaultSelector);
|
|
|
|
actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(color1, color2, searchAnimationProgress), false);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (fragmentView != null) {
|
|
|
|
fragmentView.invalidate();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
updateContextViewPosition();
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
2020-01-03 16:45:22 +01:00
|
|
|
private void findAndUpdateCheckBox(long dialogId, boolean checked) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int b = 0; b < viewPages.length; b++) {
|
|
|
|
int count = viewPages[b].listView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = viewPages[b].listView.getChildAt(a);
|
|
|
|
if (child instanceof DialogCell) {
|
|
|
|
DialogCell dialogCell = (DialogCell) child;
|
|
|
|
if (dialogCell.getDialogId() == dialogId) {
|
|
|
|
dialogCell.setChecked(checked, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void checkListLoad(ViewPage viewPage) {
|
|
|
|
if (tabsAnimationInProgress || startedTracking || filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsView.isAnimatingIndicator()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int firstVisibleItem = viewPage.layoutManager.findFirstVisibleItemPosition();
|
2021-01-28 15:15:51 +01:00
|
|
|
int lastVisibleItem = viewPage.layoutManager.findLastVisibleItemPosition();
|
2020-03-30 14:00:09 +02:00
|
|
|
int visibleItemCount = Math.abs(viewPage.layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (lastVisibleItem != RecyclerView.NO_POSITION) {
|
|
|
|
RecyclerView.ViewHolder holder = viewPage.listView.findViewHolderForAdapterPosition(lastVisibleItem);
|
|
|
|
if (floatingForceVisible = holder != null && holder.getItemViewType() == 11) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
floatingForceVisible = false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean loadArchived = false;
|
|
|
|
boolean loadArchivedFromCache = false;
|
|
|
|
boolean load = false;
|
|
|
|
boolean loadFromCache = false;
|
|
|
|
if (viewPage.dialogsType == 7 || viewPage.dialogsType == 8) {
|
|
|
|
ArrayList<MessagesController.DialogFilter> dialogFilters = getMessagesController().dialogFilters;
|
|
|
|
if (viewPage.selectedType >= 0 && viewPage.selectedType < dialogFilters.size()) {
|
|
|
|
MessagesController.DialogFilter filter = getMessagesController().dialogFilters.get(viewPage.selectedType);
|
|
|
|
if ((filter.flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (visibleItemCount > 0 && lastVisibleItem >= getDialogsArray(currentAccount, viewPage.dialogsType, 1, dialogsListFrozen).size() - 10 ||
|
2020-12-24 06:36:01 +01:00
|
|
|
visibleItemCount == 0 && !getMessagesController().isDialogsEndReached(1)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
loadArchivedFromCache = !getMessagesController().isDialogsEndReached(1);
|
|
|
|
if (loadArchivedFromCache || !getMessagesController().isServerDialogsEndReached(1)) {
|
|
|
|
loadArchived = true;
|
|
|
|
}
|
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (visibleItemCount > 0 && lastVisibleItem >= getDialogsArray(currentAccount, viewPage.dialogsType, folderId, dialogsListFrozen).size() - 10 ||
|
2020-12-24 06:36:01 +01:00
|
|
|
visibleItemCount == 0 && (viewPage.dialogsType == 7 || viewPage.dialogsType == 8) && !getMessagesController().isDialogsEndReached(folderId)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
loadFromCache = !getMessagesController().isDialogsEndReached(folderId);
|
|
|
|
if (loadFromCache || !getMessagesController().isServerDialogsEndReached(folderId)) {
|
|
|
|
load = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (load || loadArchived) {
|
|
|
|
boolean loadFinal = load;
|
|
|
|
boolean loadFromCacheFinal = loadFromCache;
|
|
|
|
boolean loadArchivedFinal = loadArchived;
|
|
|
|
boolean loadArchivedFromCacheFinal = loadArchivedFromCache;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
if (loadFinal) {
|
|
|
|
getMessagesController().loadDialogs(folderId, -1, 100, loadFromCacheFinal);
|
|
|
|
}
|
|
|
|
if (loadArchivedFinal) {
|
|
|
|
getMessagesController().loadDialogs(1, -1, 100, loadArchivedFromCacheFinal);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
private void onItemClick(View view, int position, RecyclerListView.Adapter adapter) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
long dialogId = 0;
|
2019-12-31 14:08:08 +01:00
|
|
|
int message_id = 0;
|
|
|
|
boolean isGlobalSearch = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (adapter instanceof DialogsAdapter) {
|
|
|
|
DialogsAdapter dialogsAdapter = (DialogsAdapter) adapter;
|
2019-12-31 14:08:08 +01:00
|
|
|
TLObject object = dialogsAdapter.getItem(position);
|
|
|
|
if (object instanceof TLRPC.User) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = ((TLRPC.User) object).id;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else if (object instanceof TLRPC.Dialog) {
|
|
|
|
TLRPC.Dialog dialog = (TLRPC.Dialog) object;
|
|
|
|
if (dialog instanceof TLRPC.TL_dialogFolder) {
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TLRPC.TL_dialogFolder dialogFolder = (TLRPC.TL_dialogFolder) dialog;
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("folderId", dialogFolder.folder.id);
|
2020-01-01 13:10:52 +01:00
|
|
|
args.putBoolean("onlySelect", onlySelect);
|
|
|
|
DialogsActivity dialogsActivity = new DialogsActivity(args);
|
|
|
|
dialogsActivity.setDelegate(delegate);
|
|
|
|
presentFragment(dialogsActivity, onlySelect);
|
2019-12-31 14:08:08 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = dialog.id;
|
2019-12-31 14:08:08 +01:00
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
showOrUpdateActionMode(dialog, view);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlChat) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = -((TLRPC.TL_recentMeUrlChat) object).chat_id;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else if (object instanceof TLRPC.TL_recentMeUrlUser) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = ((TLRPC.TL_recentMeUrlUser) object).user_id;
|
2019-12-31 14:08:08 +01:00
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
showDialog(new JoinGroupAlert(getParentActivity(), invite, hash, DialogsActivity.this));
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (invite.chat != null) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = -invite.chat.id;
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} 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 {
|
|
|
|
return;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (adapter == searchViewPager.dialogsSearchAdapter) {
|
|
|
|
Object obj = searchViewPager.dialogsSearchAdapter.getItem(position);
|
|
|
|
isGlobalSearch = searchViewPager.dialogsSearchAdapter.isGlobalSearch(position);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (obj instanceof TLRPC.User) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = ((TLRPC.User) obj).id;
|
2019-12-31 14:08:08 +01:00
|
|
|
if (!onlySelect) {
|
2020-01-03 16:45:22 +01:00
|
|
|
searchDialogId = dialogId;
|
2019-12-31 14:08:08 +01:00
|
|
|
searchObject = (TLRPC.User) obj;
|
|
|
|
}
|
|
|
|
} else if (obj instanceof TLRPC.Chat) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = -((TLRPC.Chat) obj).id;
|
2019-12-31 14:08:08 +01:00
|
|
|
if (!onlySelect) {
|
2020-01-03 16:45:22 +01:00
|
|
|
searchDialogId = dialogId;
|
2019-12-31 14:08:08 +01:00
|
|
|
searchObject = (TLRPC.Chat) obj;
|
|
|
|
}
|
|
|
|
} else if (obj instanceof TLRPC.EncryptedChat) {
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = ((long) ((TLRPC.EncryptedChat) obj).id) << 32;
|
2019-12-31 14:08:08 +01:00
|
|
|
if (!onlySelect) {
|
2020-01-03 16:45:22 +01:00
|
|
|
searchDialogId = dialogId;
|
2019-12-31 14:08:08 +01:00
|
|
|
searchObject = (TLRPC.EncryptedChat) obj;
|
|
|
|
}
|
|
|
|
} else if (obj instanceof MessageObject) {
|
|
|
|
MessageObject messageObject = (MessageObject) obj;
|
2020-01-03 16:45:22 +01:00
|
|
|
dialogId = messageObject.getDialogId();
|
2019-12-31 14:08:08 +01:00
|
|
|
message_id = messageObject.getId();
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.dialogsSearchAdapter.addHashtagsFromMessage(searchViewPager.dialogsSearchAdapter.getLastSearchString());
|
2019-12-31 14:08:08 +01:00
|
|
|
} else if (obj instanceof String) {
|
|
|
|
String str = (String) obj;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager.dialogsSearchAdapter.isHashtagSearch()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
actionBar.openSearchField(str, false);
|
|
|
|
} else if (!str.equals("section")) {
|
|
|
|
NewContactActivity activity = new NewContactActivity();
|
2020-10-02 23:48:16 +02:00
|
|
|
activity.setInitialPhoneNumber(str, true);
|
2019-12-31 14:08:08 +01:00
|
|
|
presentFragment(activity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:45:22 +01:00
|
|
|
if (dialogId == 0) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onlySelect) {
|
2020-01-03 16:45:22 +01:00
|
|
|
if (!validateSlowModeDialog(dialogId)) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!selectedDialogs.isEmpty()) {
|
|
|
|
boolean checked = addOrRemoveSelectedDialog(dialogId, view);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (adapter == searchViewPager.dialogsSearchAdapter) {
|
2020-01-03 16:45:22 +01:00
|
|
|
actionBar.closeSearchField();
|
|
|
|
findAndUpdateCheckBox(dialogId, checked);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
updateSelectedCount();
|
|
|
|
} else {
|
2020-01-03 16:45:22 +01:00
|
|
|
didSelectResult(dialogId, true, false);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Bundle args = new Bundle();
|
2020-01-03 16:45:22 +01:00
|
|
|
int lower_part = (int) dialogId;
|
|
|
|
int high_id = (int) (dialogId >> 32);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (lower_part != 0) {
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
2021-01-28 15:15:51 +01:00
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
if (message_id != 0) {
|
|
|
|
TLRPC.Chat chat = getMessagesController().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 {
|
|
|
|
args.putInt("enc_id", high_id);
|
|
|
|
}
|
|
|
|
if (message_id != 0) {
|
|
|
|
args.putInt("message_id", message_id);
|
|
|
|
} else if (!isGlobalSearch) {
|
|
|
|
closeSearch();
|
|
|
|
} else {
|
|
|
|
if (searchObject != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
2019-12-31 14:08:08 +01:00
|
|
|
searchObject = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (openedDialogId == dialogId && adapter != searchViewPager.dialogsSearchAdapter) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId = dialogId);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager.actionModeShowing()) {
|
|
|
|
searchViewPager.hideActionMode();
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
if (searchString != null) {
|
|
|
|
if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
presentFragment(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
2021-01-28 15:15:51 +01:00
|
|
|
ChatActivity chatActivity = new ChatActivity(args);
|
|
|
|
if (adapter instanceof DialogsAdapter && lower_part > 0 && getMessagesController().dialogs_dict.get(dialogId) == null) {
|
|
|
|
chatActivity.setPreloadedSticker(((DialogsAdapter) adapter).getPreloadedSticker(), true);
|
|
|
|
}
|
|
|
|
presentFragment(chatActivity);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean onItemLongClick(View view, int position, float x, float y, int dialogsType, RecyclerListView.Adapter adapter) {
|
2019-12-31 14:08:08 +01:00
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!actionBar.isActionModeShowed() && !AndroidUtilities.isTablet() && !onlySelect && view instanceof DialogCell) {
|
|
|
|
DialogCell cell = (DialogCell) view;
|
|
|
|
if (cell.isPointInsideAvatar(x, y)) {
|
2020-09-30 15:48:47 +02:00
|
|
|
return showChatPreview(cell);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (adapter == searchViewPager.dialogsSearchAdapter) {
|
|
|
|
Object item = searchViewPager.dialogsSearchAdapter.getItem(position);
|
|
|
|
if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2020-03-30 14:00:09 +02:00
|
|
|
builder.setTitle(LocaleController.getString("ClearSearchSingleAlertTitle", R.string.ClearSearchSingleAlertTitle));
|
|
|
|
long did;
|
|
|
|
if (item instanceof TLRPC.Chat) {
|
|
|
|
TLRPC.Chat chat = (TLRPC.Chat) item;
|
|
|
|
builder.setMessage(LocaleController.formatString("ClearSearchSingleChatAlertText", R.string.ClearSearchSingleChatAlertText, chat.title));
|
|
|
|
did = -chat.id;
|
|
|
|
} else if (item instanceof TLRPC.User) {
|
|
|
|
TLRPC.User user = (TLRPC.User) item;
|
|
|
|
if (user.id == getUserConfig().clientUserId) {
|
|
|
|
builder.setMessage(LocaleController.formatString("ClearSearchSingleChatAlertText", R.string.ClearSearchSingleChatAlertText, LocaleController.getString("SavedMessages", R.string.SavedMessages)));
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
builder.setMessage(LocaleController.formatString("ClearSearchSingleUserAlertText", R.string.ClearSearchSingleUserAlertText, ContactsController.formatName(user.first_name, user.last_name)));
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
did = user.id;
|
|
|
|
} else if (item instanceof TLRPC.EncryptedChat) {
|
|
|
|
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) item;
|
|
|
|
TLRPC.User user = getMessagesController().getUser(encryptedChat.user_id);
|
|
|
|
builder.setMessage(LocaleController.formatString("ClearSearchSingleUserAlertText", R.string.ClearSearchSingleUserAlertText, ContactsController.formatName(user.first_name, user.last_name)));
|
|
|
|
did = ((long) encryptedChat.id) << 32;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearSearchRemove", R.string.ClearSearchRemove).toUpperCase(), (dialogInterface, i) -> searchViewPager.dialogsSearchAdapter.removeRecentSearch(did));
|
2019-12-31 14:08:08 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2020-03-30 14:00:09 +02:00
|
|
|
AlertDialog alertDialog = builder.create();
|
|
|
|
showDialog(alertDialog);
|
|
|
|
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
|
|
if (button != null) {
|
|
|
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
return true;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (actionBar.isSearchFieldVisible()) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
DialogsAdapter dialogsAdapter = (DialogsAdapter) adapter;
|
2019-12-31 14:08:08 +01:00
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen);
|
|
|
|
position = dialogsAdapter.fixPosition(position);
|
|
|
|
if (position < 0 || position >= dialogs.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
final TLRPC.Dialog dialog = dialogs.get(position);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (onlySelect) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType != 3 && initialDialogsType != 10) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!validateSlowModeDialog(dialog.id)) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
addOrRemoveSelectedDialog(dialog.id, view);
|
2019-12-31 14:08:08 +01:00
|
|
|
updateSelectedCount();
|
|
|
|
} else {
|
|
|
|
if (dialog instanceof TLRPC.TL_dialogFolder) {
|
2021-01-28 15:15:51 +01:00
|
|
|
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
2021-02-04 18:59:00 +01:00
|
|
|
BottomBuilder builder = new BottomBuilder(getParentActivity());
|
2020-03-30 14:00:09 +02:00
|
|
|
final boolean hasUnread = getMessagesStorage().getArchiveUnreadCount() != 0;
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
int[] icons = new int[]{
|
2021-02-04 18:59:00 +01:00
|
|
|
hasUnread ? R.drawable.baseline_done_all_24 : 0,
|
2020-06-25 17:29:04 +02:00
|
|
|
SharedConfig.archiveHidden ? R.drawable.deproko_baseline_pin_24 : R.drawable.deproko_baseline_pin_undo_24,
|
2019-12-31 14:08:08 +01:00
|
|
|
};
|
2021-02-04 18:59:00 +01:00
|
|
|
String[] items = new String[]{
|
2019-12-31 14:08:08 +01:00
|
|
|
hasUnread ? LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead) : null,
|
|
|
|
SharedConfig.archiveHidden ? LocaleController.getString("PinInTheList", R.string.PinInTheList) : LocaleController.getString("HideAboveTheList", R.string.HideAboveTheList)
|
|
|
|
};
|
2021-02-04 18:59:00 +01:00
|
|
|
builder.addItems(items, icons, (which, t, c) -> {
|
2019-12-31 14:08:08 +01:00
|
|
|
if (which == 0) {
|
|
|
|
getMessagesStorage().readAllDialogs(1);
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (which == 1 && viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].dialogsType != 0 || viewPages[a].getVisibility() != View.VISIBLE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
View child = viewPages[a].listView.getChildAt(0);
|
|
|
|
DialogCell dialogCell = null;
|
|
|
|
if (child instanceof DialogCell && ((DialogCell) child).isFolderCell()) {
|
|
|
|
dialogCell = (DialogCell) child;
|
|
|
|
}
|
|
|
|
viewPages[a].listView.toggleArchiveHidden(true, dialogCell);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-04 18:59:00 +01:00
|
|
|
return Unit.INSTANCE;
|
2019-12-31 14:08:08 +01:00
|
|
|
});
|
|
|
|
showDialog(builder.create());
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (actionBar.isActionModeShowed() && isDialogPinned(dialog)) {
|
2019-12-31 14:08:08 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
showOrUpdateActionMode(dialog, view);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private boolean showChatPreview(DialogCell cell) {
|
|
|
|
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 (lower_part > 0) {
|
|
|
|
args.putInt("user_id", lower_part);
|
|
|
|
} else if (lower_part < 0) {
|
|
|
|
if (message_id != 0) {
|
|
|
|
TLRPC.Chat chat = getMessagesController().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 (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.closeChats);
|
|
|
|
prepareBlurBitmap();
|
|
|
|
presentFragmentAsPreview(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) {
|
|
|
|
prepareBlurBitmap();
|
|
|
|
presentFragmentAsPreview(new ChatActivity(args));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
private void updateFloatingButtonOffset() {
|
|
|
|
floatingButtonContainer.setTranslationY(floatingButtonTranslation - additionalFloatingTranslation * (1f - floatingButtonHideProgress));
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private boolean hasHiddenArchive() {
|
2020-03-30 14:00:09 +02:00
|
|
|
return !onlySelect && initialDialogsType == 0 && folderId == 0 && getMessagesController().hasHiddenArchive();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
2020-04-30 21:07:00 +02:00
|
|
|
private boolean waitingForDialogsAnimationEnd(ViewPage viewPage) {
|
|
|
|
return viewPage.dialogsItemAnimator.isRunning() || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void onDialogAnimationFinished() {
|
|
|
|
dialogRemoveFinished = 0;
|
|
|
|
dialogInsertFinished = 0;
|
|
|
|
dialogChangeFinished = 0;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null && folderId != 0 && (frozenDialogsList == null || frozenDialogsList.isEmpty())) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].listView.setEmptyView(null);
|
|
|
|
viewPages[a].progressView.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
setDialogsListFrozen(false);
|
|
|
|
updateDialogIndices();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void setScrollY(float value) {
|
|
|
|
if (scrimView != null) {
|
|
|
|
scrimView.getLocationInWindow(scrimViewLocation);
|
|
|
|
}
|
|
|
|
actionBar.setTranslationY(value);
|
2020-06-04 18:47:15 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.setTranslationY(value);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
updateContextViewPosition();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].listView.setTopGlowOffset(viewPages[a].listView.getPaddingTop() + (int) value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fragmentView.invalidate();
|
|
|
|
}
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
private void prepareBlurBitmap() {
|
|
|
|
if (blurredView == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int w = (int) (fragmentView.getMeasuredWidth() / 6.0f);
|
|
|
|
int h = (int) (fragmentView.getMeasuredHeight() / 6.0f);
|
|
|
|
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
|
|
|
|
Canvas canvas = new Canvas(bitmap);
|
|
|
|
canvas.scale(1.0f / 6.0f, 1.0f / 6.0f);
|
|
|
|
fragmentView.draw(canvas);
|
|
|
|
Utilities.stackBlurBitmap(bitmap, Math.max(7, Math.max(w, h) / 180));
|
|
|
|
blurredView.setBackground(new BitmapDrawable(bitmap));
|
|
|
|
blurredView.setAlpha(0.0f);
|
|
|
|
blurredView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onTransitionAnimationProgress(boolean isOpen, float progress) {
|
|
|
|
if (blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
|
|
|
|
if (isOpen) {
|
|
|
|
blurredView.setAlpha(1.0f - progress);
|
|
|
|
} else {
|
|
|
|
blurredView.setAlpha(progress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
|
|
|
if (isOpen && blurredView != null && blurredView.getVisibility() == View.VISIBLE) {
|
|
|
|
blurredView.setVisibility(View.GONE);
|
|
|
|
blurredView.setBackground(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void resetScroll() {
|
|
|
|
if (actionBar.getTranslationY() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(this, SCROLL_Y, 0));
|
|
|
|
animatorSet.setInterpolator(new DecelerateInterpolator());
|
|
|
|
animatorSet.setDuration(180);
|
|
|
|
animatorSet.start();
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void hideActionMode(boolean animateCheck) {
|
|
|
|
actionBar.hideActionMode();
|
|
|
|
if (menuDrawable != null) {
|
|
|
|
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu));
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
selectedDialogs.clear();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (menuDrawable != null) {
|
|
|
|
menuDrawable.setRotation(0, true);
|
|
|
|
} else if (backDrawable != null) {
|
|
|
|
backDrawable.setRotation(0, true);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.animateColorsTo(Theme.key_actionBarTabLine, Theme.key_actionBarTabActiveText, Theme.key_actionBarTabUnactiveText, Theme.key_actionBarTabSelector, Theme.key_actionBarDefault);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (actionBarColorAnimator != null) {
|
|
|
|
actionBarColorAnimator.cancel();
|
|
|
|
}
|
|
|
|
actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 0);
|
|
|
|
actionBarColorAnimator.addUpdateListener(valueAnimator -> {
|
|
|
|
progressToActionMode = (float) valueAnimator.getAnimatedValue();
|
2020-09-30 18:55:35 +02:00
|
|
|
for (int i = 0; i < actionBar.getChildCount(); i++) {
|
|
|
|
if (actionBar.getChildAt(i).getVisibility() == View.VISIBLE && actionBar.getChildAt(i) != actionBar.getActionMode() && actionBar.getChildAt(i) != actionBar.getBackButton()) {
|
|
|
|
actionBar.getChildAt(i).setAlpha(1f - progressToActionMode);
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
fragmentView.invalidate();
|
|
|
|
});
|
|
|
|
actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
|
|
actionBarColorAnimator.setDuration(200);
|
|
|
|
actionBarColorAnimator.start();
|
2019-05-14 14:08:05 +02:00
|
|
|
allowMoving = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!movingDialogFilters.isEmpty()) {
|
|
|
|
for (int a = 0, N = movingDialogFilters.size(); a < N; a++) {
|
|
|
|
MessagesController.DialogFilter filter = movingDialogFilters.get(a);
|
2020-06-04 18:47:15 +02:00
|
|
|
FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
movingDialogFilters.clear();
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (movingWas) {
|
|
|
|
getMessagesController().reorderPinnedDialogs(folderId, null, 0);
|
|
|
|
movingWas = false;
|
|
|
|
}
|
|
|
|
updateCounters(true);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.onReorderStateChanged(false);
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_REORDER | MessagesController.UPDATE_MASK_CHECK | (animateCheck ? MessagesController.UPDATE_MASK_CHAT : 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getPinnedCount() {
|
|
|
|
int pinnedCount = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
ArrayList<TLRPC.Dialog> dialogs;
|
|
|
|
if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) {
|
|
|
|
dialogs = getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, dialogsListFrozen);
|
|
|
|
} else {
|
|
|
|
dialogs = getMessagesController().getDialogs(folderId);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0, N = dialogs.size(); a < N; a++) {
|
|
|
|
TLRPC.Dialog dialog = dialogs.get(a);
|
|
|
|
if (dialog instanceof TLRPC.TL_dialogFolder) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int lower_id = (int) dialog.id;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (isDialogPinned(dialog)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
pinnedCount++;
|
2020-04-30 21:07:00 +02:00
|
|
|
} else if (!getMessagesController().isPromoDialog(dialog.id, false)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return pinnedCount;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean isDialogPinned(TLRPC.Dialog dialog) {
|
|
|
|
MessagesController.DialogFilter filter;
|
|
|
|
if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) {
|
|
|
|
filter = getMessagesController().selectedDialogFilter[viewPages[0].dialogsType == 8 ? 1 : 0];
|
|
|
|
} else {
|
|
|
|
filter = null;
|
|
|
|
}
|
|
|
|
if (filter != null) {
|
|
|
|
return filter.pinnedDialogs.indexOfKey(dialog.id) >= 0;
|
|
|
|
}
|
|
|
|
return dialog.pinned;
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void perfromSelectedDialogsAction(int action, boolean alert) {
|
|
|
|
if (getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
MessagesController.DialogFilter filter;
|
|
|
|
if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) {
|
|
|
|
filter = getMessagesController().selectedDialogFilter[viewPages[0].dialogsType == 8 ? 1 : 0];
|
|
|
|
} else {
|
|
|
|
filter = null;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
int count = selectedDialogs.size();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (action == archive || action == archive2) {
|
2019-05-14 14:08:05 +02:00
|
|
|
ArrayList<Long> copy = new ArrayList<>(selectedDialogs);
|
2020-03-30 14:00:09 +02:00
|
|
|
getMessagesController().addDialogToFolder(copy, canUnarchiveCount == 0 ? 1 : 0, -1, null, 0);
|
|
|
|
if (canUnarchiveCount == 0) {
|
2019-05-14 14:08:05 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
2019-08-22 01:53:26 +02:00
|
|
|
boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden;
|
|
|
|
if (!hintShowed) {
|
2020-06-25 17:29:04 +02:00
|
|
|
preferences.edit().putBoolean("archivehint_l", true).apply();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
int undoAction;
|
|
|
|
if (hintShowed) {
|
|
|
|
undoAction = copy.size() > 1 ? UndoView.ACTION_ARCHIVE_FEW : UndoView.ACTION_ARCHIVE;
|
|
|
|
} else {
|
|
|
|
undoAction = copy.size() > 1 ? UndoView.ACTION_ARCHIVE_FEW_HINT : UndoView.ACTION_ARCHIVE_HINT;
|
|
|
|
}
|
|
|
|
getUndoView().showWithAction(0, undoAction, null, () -> getMessagesController().addDialogToFolder(copy, folderId == 0 ? 0 : 1, -1, null, 0));
|
|
|
|
} else {
|
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getMessagesController().getDialogs(folderId);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null && dialogs.isEmpty()) {
|
|
|
|
viewPages[0].listView.setEmptyView(null);
|
|
|
|
viewPages[0].progressView.setVisibility(View.INVISIBLE);
|
2019-05-14 14:08:05 +02:00
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
hideActionMode(false);
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if ((action == pin || action == pin2) && canPinCount != 0) {
|
2019-05-14 14:08:05 +02:00
|
|
|
int pinnedCount = 0;
|
|
|
|
int pinnedSecretCount = 0;
|
|
|
|
int newPinnedCount = 0;
|
|
|
|
int newPinnedSecretCount = 0;
|
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getMessagesController().getDialogs(folderId);
|
|
|
|
for (int a = 0, N = dialogs.size(); a < N; a++) {
|
|
|
|
TLRPC.Dialog dialog = dialogs.get(a);
|
|
|
|
if (dialog instanceof TLRPC.TL_dialogFolder) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int lower_id = (int) dialog.id;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (isDialogPinned(dialog)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (lower_id == 0) {
|
|
|
|
pinnedSecretCount++;
|
|
|
|
} else {
|
|
|
|
pinnedCount++;
|
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
} else if (!getMessagesController().isPromoDialog(dialog.id, false)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
int alreadyAdded = 0;
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
long selectedDialog = selectedDialogs.get(a);
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(selectedDialog);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (dialog == null || isDialogPinned(dialog)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int lower_id = (int) selectedDialog;
|
|
|
|
if (lower_id == 0) {
|
|
|
|
newPinnedSecretCount++;
|
|
|
|
} else {
|
|
|
|
newPinnedCount++;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filter != null && filter.alwaysShow.contains(lower_id)) {
|
|
|
|
alreadyAdded++;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
int maxPinnedCount;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) {
|
|
|
|
maxPinnedCount = 100 - filter.alwaysShow.size();
|
2020-03-30 15:25:47 +02:00
|
|
|
} else if (NekoConfig.unlimitedPinnedDialogs || folderId != 0 || filter != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
maxPinnedCount = getMessagesController().maxFolderPinnedDialogsCount;
|
|
|
|
} else {
|
|
|
|
maxPinnedCount = getMessagesController().maxPinnedDialogsCount;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (newPinnedSecretCount + pinnedSecretCount > maxPinnedCount || newPinnedCount + pinnedCount - alreadyAdded > maxPinnedCount) {
|
|
|
|
if (folderId != 0 || filter != null) {
|
|
|
|
AlertsCreator.showSimpleAlert(DialogsActivity.this, LocaleController.formatString("PinFolderLimitReached", R.string.PinFolderLimitReached, LocaleController.formatPluralString("Chats", maxPinnedCount)));
|
|
|
|
} else {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.formatString("PinToTopLimitReached2", R.string.PinToTopLimitReached2, LocaleController.formatPluralString("Chats", maxPinnedCount)));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("FiltersSetupPinAlert", R.string.FiltersSetupPinAlert), (dialog, which) -> presentFragment(new FiltersSetupActivity()));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
AndroidUtilities.shakeView(pinItem, 2, 0);
|
2020-07-26 18:07:20 +02:00
|
|
|
VibrateUtil.vibrate();
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if ((action == delete || action == clear) && count > 1 && alert) {
|
2020-02-13 19:26:53 +01:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
if (action == delete) {
|
|
|
|
builder.setTitle(LocaleController.formatString("DeleteFewChatsTitle", R.string.DeleteFewChatsTitle, LocaleController.formatPluralString("ChatsSelected", count)));
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureDeleteFewChats", R.string.AreYouSureDeleteFewChats));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("Delete", R.string.Delete), (dialog1, which) -> {
|
|
|
|
getMessagesController().setDialogsInTransaction(true);
|
|
|
|
perfromSelectedDialogsAction(action, false);
|
|
|
|
getMessagesController().setDialogsInTransaction(false);
|
2020-12-24 06:36:01 +01:00
|
|
|
getMessagesController().checkIfFolderEmpty(folderId);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (folderId != 0 && getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false).size() == 0) {
|
|
|
|
viewPages[0].listView.setEmptyView(null);
|
|
|
|
viewPages[0].progressView.setVisibility(View.INVISIBLE);
|
2020-02-13 19:26:53 +01:00
|
|
|
finishFragment();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-02-13 19:26:53 +01:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
if (canClearCacheCount != 0) {
|
|
|
|
builder.setTitle(LocaleController.formatString("ClearCacheFewChatsTitle", R.string.ClearCacheFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClearCache", count)));
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryCacheFewChats", R.string.AreYouSureClearHistoryCacheFewChats));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
|
|
|
|
} else {
|
|
|
|
builder.setTitle(LocaleController.formatString("ClearFewChatsTitle", R.string.ClearFewChatsTitle, LocaleController.formatPluralString("ChatsSelectedClear", count)));
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSureClearHistoryFewChats", R.string.AreYouSureClearHistoryFewChats));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearHistory", R.string.ClearHistory), (dialog1, which) -> perfromSelectedDialogsAction(action, false));
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
2020-02-13 19:26:53 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
AlertDialog alertDialog = builder.create();
|
|
|
|
showDialog(alertDialog);
|
|
|
|
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
|
|
|
if (button != null) {
|
|
|
|
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
} else if (action == block && alert) {
|
|
|
|
TLRPC.User user;
|
|
|
|
if (count == 1) {
|
|
|
|
long did = selectedDialogs.get(0);
|
|
|
|
user = getMessagesController().getUser((int) did);
|
|
|
|
} else {
|
|
|
|
user = null;
|
|
|
|
}
|
|
|
|
AlertsCreator.createBlockDialogAlert(DialogsActivity.this, count, canReportSpamCount != 0, user, (report, delete) -> {
|
|
|
|
for (int a = 0, N = selectedDialogs.size(); a < N; a++) {
|
|
|
|
long did = selectedDialogs.get(a);
|
|
|
|
int lowerId = (int) did;
|
|
|
|
if (report) {
|
|
|
|
TLRPC.User u = getMessagesController().getUser(lowerId);
|
|
|
|
getMessagesController().reportSpam(did, u, null, null, false);
|
|
|
|
}
|
|
|
|
if (delete) {
|
|
|
|
getMessagesController().deleteDialog(did, 0, true);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
getMessagesController().blockPeer(lowerId);
|
2020-02-13 19:26:53 +01:00
|
|
|
}
|
|
|
|
hideActionMode(false);
|
|
|
|
});
|
|
|
|
return;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
int minPinnedNum = Integer.MAX_VALUE;
|
|
|
|
if (filter != null && (action == pin || action == pin2) && canPinCount != 0) {
|
|
|
|
for (int c = 0, N = filter.pinnedDialogs.size(); c < N; c++) {
|
|
|
|
minPinnedNum = Math.min(minPinnedNum, filter.pinnedDialogs.valueAt(c));
|
|
|
|
}
|
|
|
|
minPinnedNum -= canPinCount;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean scrollToTop = false;
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
long selectedDialog = selectedDialogs.get(a);
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(selectedDialog);
|
|
|
|
if (dialog == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
TLRPC.Chat chat;
|
|
|
|
TLRPC.User user = null;
|
|
|
|
int lower_id = (int) selectedDialog;
|
|
|
|
int high_id = (int) (selectedDialog >> 32);
|
2020-03-30 14:00:09 +02:00
|
|
|
TLRPC.EncryptedChat encryptedChat = null;
|
2019-05-14 14:08:05 +02:00
|
|
|
if (lower_id != 0) {
|
|
|
|
if (lower_id > 0) {
|
|
|
|
user = getMessagesController().getUser(lower_id);
|
|
|
|
chat = null;
|
|
|
|
} else {
|
|
|
|
chat = getMessagesController().getChat(-lower_id);
|
|
|
|
}
|
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
encryptedChat = getMessagesController().getEncryptedChat(high_id);
|
2019-05-14 14:08:05 +02:00
|
|
|
chat = null;
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
user = getMessagesController().getUser(encryptedChat.user_id);
|
|
|
|
} else {
|
|
|
|
user = new TLRPC.TL_userEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (chat == null && user == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
boolean isBot = user != null && user.bot && !MessagesController.isSupportUser(user);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (action == pin || action == pin2) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (canPinCount != 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (isDialogPinned(dialog)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filter != null) {
|
|
|
|
filter.pinnedDialogs.put(selectedDialog, minPinnedNum);
|
|
|
|
minPinnedNum++;
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
if (!filter.alwaysShow.contains(encryptedChat.user_id)) {
|
|
|
|
filter.alwaysShow.add(encryptedChat.user_id);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!filter.alwaysShow.contains(lower_id)) {
|
|
|
|
filter.alwaysShow.add(lower_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (getMessagesController().pinDialog(selectedDialog, true, null, -1)) {
|
|
|
|
scrollToTop = true;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!isDialogPinned(dialog)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
continue;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filter != null) {
|
|
|
|
int index = filter.pinnedDialogs.get(selectedDialog, Integer.MIN_VALUE);
|
|
|
|
if (index == Integer.MIN_VALUE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
filter.pinnedDialogs.remove(selectedDialog);
|
|
|
|
} else {
|
|
|
|
if (getMessagesController().pinDialog(selectedDialog, false, null, -1)) {
|
|
|
|
scrollToTop = true;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (action == read) {
|
|
|
|
if (canReadCount != 0) {
|
|
|
|
getMessagesController().markMentionsAsRead(selectedDialog);
|
2020-09-30 15:48:47 +02:00
|
|
|
getMessagesController().markDialogAsRead(selectedDialog, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, 0, true, 0);
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
getMessagesController().markDialogAsUnread(selectedDialog, null, 0);
|
|
|
|
}
|
|
|
|
} else if (action == delete || action == clear) {
|
|
|
|
if (count == 1) {
|
2020-05-01 04:08:26 +02:00
|
|
|
if (action == delete && canDeletePsaSelected) {
|
2020-04-30 21:07:00 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("PsaHideChatAlertTitle", R.string.PsaHideChatAlertTitle));
|
|
|
|
builder.setMessage(LocaleController.getString("PsaHideChatAlertText", R.string.PsaHideChatAlertText));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("PsaHide", R.string.PsaHide), (dialog1, which) -> {
|
|
|
|
getMessagesController().hidePromoDialog();
|
|
|
|
hideActionMode(false);
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
} else {
|
2021-01-28 15:15:51 +01:00
|
|
|
AlertsCreator.createClearOrDeleteDialogAlert(DialogsActivity.this, action == clear, chat, user, lower_id == 0, action == delete, (param) -> {
|
2020-04-30 21:07:00 +02:00
|
|
|
hideActionMode(false);
|
|
|
|
if (action == clear && ChatObject.isChannel(chat) && (!chat.megagroup || !TextUtils.isEmpty(chat.username))) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 2, param);
|
|
|
|
} else {
|
|
|
|
if (action == delete && folderId != 0 && getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false).size() == 1) {
|
|
|
|
viewPages[0].progressView.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
getUndoView().showWithAction(selectedDialog, action == clear ? UndoView.ACTION_CLEAR : UndoView.ACTION_DELETE, () -> {
|
|
|
|
if (action == clear) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 1, param);
|
|
|
|
} else {
|
|
|
|
if (chat != null) {
|
|
|
|
if (ChatObject.isNotInChat(chat)) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 0, param);
|
|
|
|
} else {
|
|
|
|
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
|
2021-01-28 15:15:51 +01:00
|
|
|
getMessagesController().deleteUserFromChat((int) -selectedDialog, currentUser, null, param, false);
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
getMessagesController().deleteDialog(selectedDialog, 0, param);
|
|
|
|
if (isBot) {
|
2020-09-30 15:48:47 +02:00
|
|
|
getMessagesController().blockPeer((int) selectedDialog);
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
getMessagesController().checkIfFolderEmpty(folderId);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
if (getMessagesController().isPromoDialog(selectedDialog, true)) {
|
|
|
|
getMessagesController().hidePromoDialog();
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
if (action == clear && canClearCacheCount != 0) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 2, false);
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
if (action == clear) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 1, false);
|
|
|
|
} else {
|
|
|
|
if (chat != null) {
|
|
|
|
if (ChatObject.isNotInChat(chat)) {
|
|
|
|
getMessagesController().deleteDialog(selectedDialog, 0, false);
|
|
|
|
} else {
|
|
|
|
TLRPC.User currentUser = getMessagesController().getUser(getUserConfig().getClientUserId());
|
|
|
|
getMessagesController().deleteUserFromChat((int) -selectedDialog, currentUser, null);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-04-30 21:07:00 +02:00
|
|
|
getMessagesController().deleteDialog(selectedDialog, 0, false);
|
|
|
|
if (isBot) {
|
2020-09-30 15:48:47 +02:00
|
|
|
getMessagesController().blockPeer((int) selectedDialog);
|
2020-04-30 21:07:00 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-04-30 21:07:00 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (action == mute) {
|
|
|
|
if (count == 1 && canMuteCount == 1) {
|
2020-09-30 15:48:47 +02:00
|
|
|
showDialog(AlertsCreator.createMuteAlert(this, selectedDialog), dialog12 -> hideActionMode(true));
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
if (canUnmuteCount != 0) {
|
|
|
|
if (!getMessagesController().isDialogMuted(selectedDialog)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
getNotificationsController().setDialogNotificationsSettings(selectedDialog, NotificationsController.SETTING_MUTE_UNMUTE);
|
|
|
|
} else {
|
|
|
|
if (getMessagesController().isDialogMuted(selectedDialog)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
getNotificationsController().setDialogNotificationsSettings(selectedDialog, NotificationsController.SETTING_MUTE_FOREVER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (action == mute && !(count == 1 && canMuteCount == 1)) {
|
|
|
|
BulletinFactory.createMuteBulletin(this, canUnmuteCount == 0).show();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (action == pin || action == pin2) {
|
|
|
|
if (filter != null) {
|
2020-06-04 18:47:15 +02:00
|
|
|
FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null);
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
|
|
|
getMessagesController().reorderPinnedDialogs(folderId, null, 0);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
if (scrollToTop) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType != 10) {
|
|
|
|
hideFloatingButton(false);
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
scrollToTop();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
hideActionMode(action != pin2 && action != pin && action != delete);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
private void scrollToTop() {
|
2020-03-30 14:00:09 +02:00
|
|
|
int scrollDistance = viewPages[0].layoutManager.findFirstVisibleItemPosition() * AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72);
|
|
|
|
int position = viewPages[0].dialogsType == 0 && hasHiddenArchive() ? 1 : 0;
|
|
|
|
if (scrollDistance >= viewPages[0].listView.getMeasuredHeight() * 1.2f) {
|
|
|
|
viewPages[0].scrollHelper.setScrollDirection(RecyclerAnimationScrollHelper.SCROLL_DIRECTION_UP);
|
|
|
|
viewPages[0].scrollHelper.scrollToPosition(position, 0, false, true);
|
|
|
|
resetScroll();
|
2019-12-31 14:08:08 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].listView.smoothScrollToPosition(position);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void updateCounters(boolean hide) {
|
|
|
|
int canClearHistoryCount = 0;
|
|
|
|
int canDeleteCount = 0;
|
|
|
|
int canUnpinCount = 0;
|
|
|
|
int canArchiveCount = 0;
|
2020-04-30 21:07:00 +02:00
|
|
|
canDeletePsaSelected = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
canUnarchiveCount = 0;
|
2019-05-14 14:08:05 +02:00
|
|
|
canUnmuteCount = 0;
|
|
|
|
canMuteCount = 0;
|
|
|
|
canPinCount = 0;
|
|
|
|
canReadCount = 0;
|
|
|
|
canClearCacheCount = 0;
|
2020-02-13 19:26:53 +01:00
|
|
|
int cantBlockCount = 0;
|
|
|
|
canReportSpamCount = 0;
|
2019-05-14 14:08:05 +02:00
|
|
|
if (hide) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int count = selectedDialogs.size();
|
2020-02-13 19:26:53 +01:00
|
|
|
int selfUserId = getUserConfig().getClientUserId();
|
|
|
|
SharedPreferences preferences = getNotificationsSettings();
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(selectedDialogs.get(a));
|
|
|
|
if (dialog == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
long selectedDialog = dialog.id;
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean pinned = isDialogPinned(dialog);
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean hasUnread = dialog.unread_count != 0 || dialog.unread_mark;
|
|
|
|
if (getMessagesController().isDialogMuted(selectedDialog)) {
|
|
|
|
canUnmuteCount++;
|
|
|
|
} else {
|
|
|
|
canMuteCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasUnread) {
|
|
|
|
canReadCount++;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (folderId == 1 || dialog.folder_id == 1) {
|
2019-05-14 14:08:05 +02:00
|
|
|
canUnarchiveCount++;
|
2020-04-30 21:07:00 +02:00
|
|
|
} else if (selectedDialog != selfUserId && selectedDialog != 777000 && !getMessagesController().isPromoDialog(selectedDialog, false)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
canArchiveCount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int lower_id = (int) selectedDialog;
|
|
|
|
int high_id = (int) (selectedDialog >> 32);
|
|
|
|
|
2020-02-13 19:26:53 +01:00
|
|
|
if (lower_id <= 0 || lower_id == selfUserId) {
|
|
|
|
cantBlockCount++;
|
|
|
|
} else {
|
|
|
|
TLRPC.User user = getMessagesController().getUser(lower_id);
|
|
|
|
if (MessagesController.isSupportUser(user)) {
|
|
|
|
cantBlockCount++;
|
|
|
|
} else {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (preferences.getBoolean("dialog_bar_report" + selectedDialog, true)) {
|
2020-02-13 19:26:53 +01:00
|
|
|
canReportSpamCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
if (DialogObject.isChannel(dialog)) {
|
|
|
|
final TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
|
|
|
|
CharSequence[] items;
|
2020-04-30 21:07:00 +02:00
|
|
|
if (getMessagesController().isPromoDialog(dialog.id, true)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
canClearCacheCount++;
|
2020-04-30 21:07:00 +02:00
|
|
|
if (getMessagesController().promoDialogType == MessagesController.PROMO_TYPE_PSA) {
|
|
|
|
canDeleteCount++;
|
|
|
|
canDeletePsaSelected = true;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
if (pinned) {
|
|
|
|
canUnpinCount++;
|
|
|
|
} else {
|
|
|
|
canPinCount++;
|
|
|
|
}
|
|
|
|
if (chat != null && chat.megagroup) {
|
|
|
|
if (TextUtils.isEmpty(chat.username)) {
|
|
|
|
canClearHistoryCount++;
|
|
|
|
} else {
|
|
|
|
canClearCacheCount++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
canClearCacheCount++;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
canDeleteCount++;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
final boolean isChat = lower_id < 0 && high_id != 1;
|
|
|
|
TLRPC.User user;
|
|
|
|
TLRPC.Chat chat = isChat ? getMessagesController().getChat(-lower_id) : null;
|
|
|
|
if (lower_id == 0) {
|
|
|
|
TLRPC.EncryptedChat encryptedChat = getMessagesController().getEncryptedChat(high_id);
|
|
|
|
if (encryptedChat != null) {
|
|
|
|
user = getMessagesController().getUser(encryptedChat.user_id);
|
|
|
|
} else {
|
|
|
|
user = new TLRPC.TL_userEmpty();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
user = !isChat && lower_id > 0 && high_id != 1 ? getMessagesController().getUser(lower_id) : null;
|
|
|
|
}
|
|
|
|
final boolean isBot = user != null && user.bot && !MessagesController.isSupportUser(user);
|
|
|
|
|
|
|
|
if (pinned) {
|
|
|
|
canUnpinCount++;
|
|
|
|
} else {
|
|
|
|
canPinCount++;
|
|
|
|
}
|
|
|
|
canClearHistoryCount++;
|
|
|
|
canDeleteCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (canDeleteCount != count) {
|
|
|
|
deleteItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
deleteItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (canClearCacheCount != 0 && canClearCacheCount != count || canClearHistoryCount != 0 && canClearHistoryCount != count) {
|
|
|
|
clearItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
clearItem.setVisibility(View.VISIBLE);
|
|
|
|
if (canClearCacheCount != 0) {
|
|
|
|
clearItem.setText(LocaleController.getString("ClearHistoryCache", R.string.ClearHistoryCache));
|
|
|
|
} else {
|
|
|
|
clearItem.setText(LocaleController.getString("ClearHistory", R.string.ClearHistory));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (canUnarchiveCount != 0) {
|
2020-07-26 10:03:38 +02:00
|
|
|
final String contentDescription = LocaleController.getString("Unarchive", R.string.Unarchive);
|
2020-07-27 02:58:40 +02:00
|
|
|
archiveItem.setTextAndIcon(contentDescription, R.drawable.baseline_unarchive_24);
|
2020-06-25 17:29:04 +02:00
|
|
|
archive2Item.setIcon(R.drawable.baseline_unarchive_24);
|
2020-07-26 10:03:38 +02:00
|
|
|
archive2Item.setContentDescription(contentDescription);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
archive2Item.setVisibility(View.VISIBLE);
|
|
|
|
archiveItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
archiveItem.setVisibility(View.VISIBLE);
|
|
|
|
archive2Item.setVisibility(View.GONE);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
} else if (canArchiveCount != 0) {
|
2020-07-26 10:03:38 +02:00
|
|
|
final String contentDescription = LocaleController.getString("Archive", R.string.Archive);
|
2020-07-27 02:58:40 +02:00
|
|
|
archiveItem.setTextAndIcon(contentDescription, R.drawable.baseline_archive_24);
|
2020-06-25 17:29:04 +02:00
|
|
|
archive2Item.setIcon(R.drawable.baseline_archive_24);
|
2020-07-26 10:03:38 +02:00
|
|
|
archive2Item.setContentDescription(contentDescription);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
archive2Item.setVisibility(View.VISIBLE);
|
|
|
|
archiveItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
archiveItem.setVisibility(View.VISIBLE);
|
|
|
|
archive2Item.setVisibility(View.GONE);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
archiveItem.setVisibility(View.GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
archive2Item.setVisibility(View.GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
if (canPinCount + canUnpinCount != count) {
|
|
|
|
pinItem.setVisibility(View.GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
pin2Item.setVisibility(View.GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
pin2Item.setVisibility(View.VISIBLE);
|
|
|
|
pinItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
pinItem.setVisibility(View.VISIBLE);
|
|
|
|
pin2Item.setVisibility(View.GONE);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-02-13 19:26:53 +01:00
|
|
|
if (cantBlockCount != 0) {
|
|
|
|
blockItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
blockItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-06-04 18:47:15 +02:00
|
|
|
if (filterTabsView == null || filterTabsView.getVisibility() != View.VISIBLE || filterTabsView.getCurrentTabId() == Integer.MAX_VALUE) {
|
|
|
|
removeFromFolderItem.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
removeFromFolderItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsView.getCurrentTabId() == Integer.MAX_VALUE && !FiltersListBottomSheet.getCanAddDialogFilters(this, selectedDialogs).isEmpty()) {
|
|
|
|
addToFolderItem.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
addToFolderItem.setVisibility(View.GONE);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (canUnmuteCount != 0) {
|
2020-06-25 17:29:04 +02:00
|
|
|
muteItem.setIcon(R.drawable.baseline_bullhorn_24);
|
2019-09-10 12:56:11 +02:00
|
|
|
muteItem.setContentDescription(LocaleController.getString("ChatsUnmute", R.string.ChatsUnmute));
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-06-25 17:29:04 +02:00
|
|
|
muteItem.setIcon(R.drawable.baseline_volume_off_24_white);
|
2019-09-10 12:56:11 +02:00
|
|
|
muteItem.setContentDescription(LocaleController.getString("ChatsMute", R.string.ChatsMute));
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
if (canReadCount != 0) {
|
2021-02-04 18:59:00 +01:00
|
|
|
readItem.setTextAndIcon(LocaleController.getString("MarkAsRead", R.string.MarkAsRead), R.drawable.baseline_done_all_24);
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-06-25 17:29:04 +02:00
|
|
|
readItem.setTextAndIcon(LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread), R.drawable.baseline_unsubscribe_24);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
if (canPinCount != 0) {
|
2020-06-25 17:29:04 +02:00
|
|
|
pinItem.setIcon(R.drawable.deproko_baseline_pin_24);
|
2019-05-14 14:08:05 +02:00
|
|
|
pinItem.setContentDescription(LocaleController.getString("PinToTop", R.string.PinToTop));
|
2020-03-30 14:00:09 +02:00
|
|
|
pin2Item.setText(LocaleController.getString("DialogPin", R.string.DialogPin));
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
2020-06-25 17:29:04 +02:00
|
|
|
pinItem.setIcon(R.drawable.deproko_baseline_pin_undo_24);
|
2019-05-14 14:08:05 +02:00
|
|
|
pinItem.setContentDescription(LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop));
|
2020-03-30 14:00:09 +02:00
|
|
|
pin2Item.setText(LocaleController.getString("DialogUnpin", R.string.DialogUnpin));
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
private boolean validateSlowModeDialog(long dialogId) {
|
|
|
|
if (messagesCount <= 1 && (commentView == null || commentView.getVisibility() != View.VISIBLE || TextUtils.isEmpty(commentView.getFieldText()))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
int lowerId = (int) dialogId;
|
|
|
|
if (lowerId >= 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
TLRPC.Chat chat = getMessagesController().getChat(-lowerId);
|
|
|
|
if (chat != null && !ChatObject.hasAdminRights(chat) && chat.slowmode_enabled) {
|
|
|
|
AlertsCreator.showSimpleAlert(DialogsActivity.this, LocaleController.getString("Slowmode", R.string.Slowmode), LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void showOrUpdateActionMode(TLRPC.Dialog dialog, View cell) {
|
2020-03-30 14:00:09 +02:00
|
|
|
addOrRemoveSelectedDialog(dialog.id, cell);
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean updateAnimated = false;
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
if (selectedDialogs.isEmpty()) {
|
|
|
|
hideActionMode(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
updateAnimated = true;
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
createActionMode();
|
2021-01-30 20:47:24 +01:00
|
|
|
actionBar.setActionModeOverrideColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
2019-05-14 14:08:05 +02:00
|
|
|
actionBar.showActionMode();
|
2020-03-30 14:00:09 +02:00
|
|
|
resetScroll();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (menuDrawable != null) {
|
|
|
|
actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack));
|
|
|
|
}
|
|
|
|
if (getPinnedCount() > 1) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.onReorderStateChanged(true);
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_REORDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
for (int a = 0; a < actionModeViews.size(); a++) {
|
|
|
|
View view = actionModeViews.get(a);
|
|
|
|
view.setPivotY(ActionBar.getCurrentActionBarHeight() / 2);
|
|
|
|
AndroidUtilities.clearDrawableAnimation(view);
|
|
|
|
animators.add(ObjectAnimator.ofFloat(view, View.SCALE_Y, 0.1f, 1.0f));
|
|
|
|
}
|
|
|
|
animatorSet.playTogether(animators);
|
2019-12-31 14:08:08 +01:00
|
|
|
animatorSet.setDuration(200);
|
2019-05-14 14:08:05 +02:00
|
|
|
animatorSet.start();
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
if (actionBarColorAnimator != null) {
|
|
|
|
actionBarColorAnimator.cancel();
|
|
|
|
}
|
|
|
|
actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 1f);
|
|
|
|
actionBarColorAnimator.addUpdateListener(valueAnimator -> {
|
|
|
|
progressToActionMode = (float) valueAnimator.getAnimatedValue();
|
2020-09-30 18:55:35 +02:00
|
|
|
for (int i = 0; i < actionBar.getChildCount(); i++) {
|
|
|
|
if (actionBar.getChildAt(i).getVisibility() == View.VISIBLE && actionBar.getChildAt(i) != actionBar.getActionMode() && actionBar.getChildAt(i) != actionBar.getBackButton()) {
|
|
|
|
actionBar.getChildAt(i).setAlpha(1f - progressToActionMode);
|
|
|
|
}
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
fragmentView.invalidate();
|
|
|
|
});
|
|
|
|
actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
|
|
actionBarColorAnimator.setDuration(200);
|
|
|
|
actionBarColorAnimator.start();
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.animateColorsTo(Theme.key_profile_tabSelectedLine, Theme.key_profile_tabSelectedText, Theme.key_profile_tabText, Theme.key_profile_tabSelector, Theme.key_actionBarActionModeDefault);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (menuDrawable != null) {
|
|
|
|
menuDrawable.setRotateToBack(false);
|
|
|
|
menuDrawable.setRotation(1, true);
|
|
|
|
} else if (backDrawable != null) {
|
|
|
|
backDrawable.setRotation(1, true);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
updateCounters(false);
|
|
|
|
selectedDialogsCountTextView.setNumber(selectedDialogs.size(), updateAnimated);
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void closeSearch() {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
if (searchObject != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject);
|
2019-01-23 18:03:33 +01:00
|
|
|
searchObject = null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
closeSearchFieldOnHide = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-18 15:01:39 +02:00
|
|
|
protected RecyclerListView getListView() {
|
2020-03-30 14:00:09 +02:00
|
|
|
return viewPages[0].listView;
|
2019-07-18 15:01:39 +02:00
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
protected RecyclerListView getSearchListView() {
|
2020-09-30 15:48:47 +02:00
|
|
|
return searchViewPager.searchListView;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private UndoView getUndoView() {
|
|
|
|
if (undoView[0].getVisibility() == View.VISIBLE) {
|
|
|
|
UndoView old = undoView[0];
|
|
|
|
undoView[0] = undoView[1];
|
|
|
|
undoView[1] = old;
|
|
|
|
old.hide(true, 2);
|
|
|
|
ContentView contentView = (ContentView) fragmentView;
|
|
|
|
contentView.removeView(undoView[0]);
|
|
|
|
contentView.addView(undoView[0]);
|
|
|
|
}
|
|
|
|
return undoView[0];
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private void updateProxyButton(boolean animated) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (proxyDrawable == null || doneItem != null && doneItem.getVisibility() == View.VISIBLE) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
|
|
String proxyAddress = preferences.getString("proxy_ip", "");
|
|
|
|
boolean proxyEnabled;
|
2020-06-25 17:29:04 +02:00
|
|
|
if (!NekoConfig.useProxyItem && (!NekoConfig.hideProxyByDefault || (proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty())) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) {
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
proxyItemVisible = true;
|
2020-06-25 17:29:04 +02:00
|
|
|
proxyDrawable.setConnected(true, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
proxyItemVisible = false;
|
2018-07-30 04:07:02 +02:00
|
|
|
proxyItem.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private AnimatorSet doneItemAnimator;
|
2020-06-25 17:29:04 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void showDoneItem(boolean show) {
|
|
|
|
if (doneItem == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (doneItemAnimator != null) {
|
|
|
|
doneItemAnimator.cancel();
|
|
|
|
doneItemAnimator = null;
|
|
|
|
}
|
|
|
|
doneItemAnimator = new AnimatorSet();
|
|
|
|
doneItemAnimator.setDuration(180);
|
|
|
|
if (show) {
|
|
|
|
doneItem.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
doneItem.setSelected(false);
|
|
|
|
Drawable background = doneItem.getBackground();
|
|
|
|
if (background != null) {
|
|
|
|
background.setState(StateSet.NOTHING);
|
|
|
|
background.jumpToCurrentState();
|
|
|
|
}
|
|
|
|
if (searchItem != null) {
|
|
|
|
searchItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (proxyItem != null && proxyItemVisible) {
|
|
|
|
proxyItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (passcodeItem != null && passcodeItemVisible) {
|
|
|
|
passcodeItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ArrayList<Animator> arrayList = new ArrayList<>();
|
|
|
|
arrayList.add(ObjectAnimator.ofFloat(doneItem, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
if (proxyItemVisible) {
|
|
|
|
arrayList.add(ObjectAnimator.ofFloat(proxyItem, View.ALPHA, show ? 0.0f : 1.0f));
|
|
|
|
}
|
|
|
|
if (passcodeItemVisible) {
|
|
|
|
arrayList.add(ObjectAnimator.ofFloat(passcodeItem, View.ALPHA, show ? 0.0f : 1.0f));
|
|
|
|
}
|
|
|
|
arrayList.add(ObjectAnimator.ofFloat(searchItem, View.ALPHA, show ? 0.0f : 1.0f));
|
|
|
|
doneItemAnimator.playTogether(arrayList);
|
|
|
|
doneItemAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
doneItemAnimator = null;
|
|
|
|
if (show) {
|
|
|
|
if (searchItem != null) {
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
if (proxyItem != null && proxyItemVisible) {
|
|
|
|
proxyItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
if (passcodeItem != null && passcodeItemVisible) {
|
|
|
|
passcodeItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (doneItem != null) {
|
|
|
|
doneItem.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
doneItemAnimator.start();
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
private void updateSelectedCount() {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (commentView != null) {
|
|
|
|
if (selectedDialogs.isEmpty()) {
|
|
|
|
if (initialDialogsType == 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();
|
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, 0, commentView.getMeasuredHeight()));
|
|
|
|
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);
|
|
|
|
fragmentView.requestLayout();
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
} else {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (commentView.getTag() == null) {
|
|
|
|
commentView.setFieldText("");
|
|
|
|
commentView.setVisibility(View.VISIBLE);
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
animatorSet.playTogether(ObjectAnimator.ofFloat(commentView, View.TRANSLATION_Y, commentView.getMeasuredHeight(), 0));
|
|
|
|
animatorSet.setDuration(180);
|
|
|
|
animatorSet.setInterpolator(new DecelerateInterpolator());
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
commentView.setTag(2);
|
|
|
|
commentView.requestLayout();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
animatorSet.start();
|
|
|
|
commentView.setTag(1);
|
|
|
|
}
|
|
|
|
actionBar.setTitle(LocaleController.formatPluralString("Recipient", selectedDialogs.size()));
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
} else if (initialDialogsType == 10) {
|
|
|
|
hideFloatingButton(selectedDialogs.isEmpty());
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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<>();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (getUserConfig().syncContacts && askAboutContacts && activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (alert) {
|
2018-08-27 10:33:11 +02:00
|
|
|
AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> {
|
|
|
|
askAboutContacts = param != 0;
|
2020-06-25 17:29:04 +02:00
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).apply();
|
2018-08-27 10:33:11 +02:00
|
|
|
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()) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (askingForPermissions) {
|
|
|
|
askingForPermissions = false;
|
|
|
|
showFiltersHint();
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
String[] items = permissons.toArray(new String[0]);
|
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-05-14 14:08:05 +02:00
|
|
|
if (permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) {
|
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);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
scrimPopupWindow.dismiss();
|
|
|
|
}
|
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-12-31 14:08:08 +01:00
|
|
|
floatingButtonTranslation = floatingHidden ? AndroidUtilities.dp(100) : 0;
|
|
|
|
updateFloatingButtonOffset();
|
2019-01-23 18:03:33 +01:00
|
|
|
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) {
|
2019-05-14 14:08:05 +02:00
|
|
|
getContactsController().forceImportContacts();
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2020-06-25 17:29:04 +02:00
|
|
|
MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).apply();
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (askingForPermissions) {
|
|
|
|
askingForPermissions = false;
|
|
|
|
showFiltersHint();
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2013-10-25 17:19:00 +02:00
|
|
|
@Override
|
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) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null || dialogsListFrozen) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
|
|
|
|
MessagesController messagesController = AccountInstance.getInstance(currentAccount).getMessagesController();
|
|
|
|
ArrayList<TLRPC.Dialog> dialogs = messagesController.getDialogs(folderId);
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].getVisibility() != View.VISIBLE) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
int oldItemCount = viewPages[a].dialogsAdapter.getCurrentCount();
|
|
|
|
|
|
|
|
if (viewPages[a].dialogsType == 0 && hasHiddenArchive() && viewPages[a].listView.getChildCount() == 0) {
|
|
|
|
LinearLayoutManager layoutManager = (LinearLayoutManager) viewPages[a].listView.getLayoutManager();
|
|
|
|
layoutManager.scrollToPositionWithOffset(1, 0);
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[a].dialogsAdapter.isDataSetChanged() || args.length > 0) {
|
|
|
|
viewPages[a].dialogsAdapter.notifyDataSetChanged();
|
2021-01-28 15:15:51 +01:00
|
|
|
int newItemCount = viewPages[a].dialogsAdapter.getItemCount();
|
|
|
|
if (newItemCount > oldItemCount && initialDialogsType != 11 && initialDialogsType != 12 && initialDialogsType != 13) {
|
2021-02-23 12:53:38 +01:00
|
|
|
viewPages[a].recyclerItemsEnterAnimator.showItemsAnimated(oldItemCount);
|
2021-01-28 15:15:51 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_NEW_MESSAGE);
|
2021-01-28 15:15:51 +01:00
|
|
|
int newItemCount = viewPages[a].dialogsAdapter.getItemCount();
|
|
|
|
if (newItemCount > oldItemCount && initialDialogsType != 11 && initialDialogsType != 12 && initialDialogsType != 13) {
|
2021-02-23 12:53:38 +01:00
|
|
|
viewPages[a].recyclerItemsEnterAnimator.showItemsAnimated(oldItemCount);
|
2021-01-28 15:15:51 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2014-11-21 11:59:05 +01:00
|
|
|
try {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[a].listView.setEmptyView(folderId == 0 ? viewPages[a].progressView : null);
|
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
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
checkListLoad(viewPages[a]);
|
|
|
|
}
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
filterTabsView.checkTabsCounter();
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.dialogsUnreadCounterChanged) {
|
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) {
|
|
|
|
filterTabsView.notifyTabCounterChanged(Integer.MAX_VALUE);
|
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);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
filterTabsView.getTabsContainer().invalidateViews();
|
|
|
|
}
|
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);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && (mask & MessagesController.UPDATE_MASK_READ_DIALOG_MESSAGE) != 0) {
|
|
|
|
filterTabsView.checkTabsCounter();
|
|
|
|
}
|
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
|
|
|
|
viewPages[a].dialogsAdapter.sortOnlineContacts(true);
|
|
|
|
}
|
|
|
|
}
|
2019-07-18 15:01:39 +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) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null || dialogsListFrozen) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean updateVisibleRows = false;
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (viewPages[a].isDefaultDialogType() && getMessagesController().getDialogs(folderId).size() <= 10) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[a].dialogsAdapter.notifyDataSetChanged();
|
|
|
|
} else {
|
|
|
|
updateVisibleRows = true;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
if (updateVisibleRows) {
|
2018-07-30 04:07:02 +02:00
|
|
|
updateVisibleRows(0);
|
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
} else if (id == NotificationCenter.openedChatChanged) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].isDefaultDialogType() && AndroidUtilities.isTablet()) {
|
|
|
|
boolean close = (Boolean) args[1];
|
|
|
|
long dialog_id = (Long) args[0];
|
|
|
|
if (close) {
|
|
|
|
if (dialog_id == openedDialogId) {
|
|
|
|
openedDialogId = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
openedDialogId = dialog_id;
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId);
|
2014-09-30 00:48:11 +02:00
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG);
|
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) {
|
2021-01-28 15:15:51 +01:00
|
|
|
updatePasscodeButton(true);
|
2017-03-31 01:58:05 +02:00
|
|
|
} else if (id == NotificationCenter.needReloadRecentDialogsSearch) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) {
|
|
|
|
searchViewPager.dialogsSearchAdapter.loadRecentSearch();
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
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) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) {
|
|
|
|
searchViewPager.dialogsSearchAdapter.notifyDataSetChanged();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.didUpdateConnectionState) {
|
2019-05-14 14:08:05 +02:00
|
|
|
int state = AccountInstance.getInstance(account).getConnectionsManager().getConnectionState();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentConnectionState != state) {
|
|
|
|
currentConnectionState = state;
|
|
|
|
updateProxyButton(true);
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.needDeleteDialog) {
|
2019-07-18 15:01:39 +02:00
|
|
|
if (fragmentView == null || isPaused) {
|
2019-06-04 12:14:50 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
long dialogId = (Long) args[0];
|
|
|
|
TLRPC.User user = (TLRPC.User) args[1];
|
|
|
|
TLRPC.Chat chat = (TLRPC.Chat) args[2];
|
|
|
|
boolean revoke = (Boolean) args[3];
|
|
|
|
Runnable deleteRunnable = () -> {
|
|
|
|
if (chat != null) {
|
|
|
|
if (ChatObject.isNotInChat(chat)) {
|
|
|
|
getMessagesController().deleteDialog(dialogId, 0, revoke);
|
2019-01-23 18:03:33 +01:00
|
|
|
} else {
|
2021-01-28 15:15:51 +01:00
|
|
|
getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, revoke, revoke);
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
getMessagesController().deleteDialog(dialogId, 0, revoke);
|
2020-07-26 10:03:38 +02:00
|
|
|
if (user != null && user.bot) {
|
2020-09-30 15:48:47 +02:00
|
|
|
getMessagesController().blockPeer(user.id);
|
2020-07-26 10:03:38 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
getMessagesController().checkIfFolderEmpty(folderId);
|
2019-05-14 14:08:05 +02:00
|
|
|
};
|
|
|
|
if (undoView[0] != null) {
|
|
|
|
getUndoView().showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable);
|
|
|
|
} else {
|
|
|
|
deleteRunnable.run();
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.folderBecomeEmpty) {
|
|
|
|
int fid = (Integer) args[0];
|
|
|
|
if (folderId == fid && folderId != 0) {
|
|
|
|
finishFragment();
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (id == NotificationCenter.dialogFiltersUpdated) {
|
2020-12-23 08:48:30 +01:00
|
|
|
updateFilterTabs(true, true);
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (id == NotificationCenter.filterSettingsUpdated) {
|
|
|
|
showFiltersHint();
|
2020-07-26 10:03:38 +02:00
|
|
|
} else if (id == NotificationCenter.newSuggestionsAvailable) {
|
|
|
|
showNextSupportedSuggestion();
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (id == NotificationCenter.messagesDeleted) {
|
|
|
|
if (searchIsShowed && searchViewPager != null) {
|
|
|
|
ArrayList<Integer> markAsDeletedMessages = (ArrayList<Integer>) args[0];
|
|
|
|
int channelId = (int) args[1];
|
|
|
|
searchViewPager.messagesDeleted(channelId, markAsDeletedMessages);
|
|
|
|
}
|
2020-12-24 06:36:01 +01:00
|
|
|
} else if (id == NotificationCenter.didClearDatabase) {
|
2021-02-23 12:53:38 +01:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
viewPages[a].dialogsAdapter.didDatabaseCleared();
|
2021-01-28 15:15:51 +01:00
|
|
|
}
|
|
|
|
}
|
2021-02-23 12:53:38 +01:00
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
}
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
private String showingSuggestion;
|
2021-02-06 12:40:02 +01:00
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
private void showNextSupportedSuggestion() {
|
|
|
|
if (showingSuggestion != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (String suggestion : getMessagesController().pendingSuggestions) {
|
|
|
|
if (showSuggestion(suggestion)) {
|
|
|
|
showingSuggestion = suggestion;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onSuggestionDismiss() {
|
|
|
|
if (showingSuggestion == null) {
|
|
|
|
return;
|
|
|
|
}
|
2021-02-23 12:53:38 +01:00
|
|
|
getMessagesController().removeSuggestion(0, showingSuggestion);
|
2020-07-26 10:03:38 +02:00
|
|
|
showingSuggestion = null;
|
|
|
|
showNextSupportedSuggestion();
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean showSuggestion(String suggestion) {
|
|
|
|
if ("AUTOARCHIVE_POPULAR".equals(suggestion)) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("HideNewChatsAlertTitle", R.string.HideNewChatsAlertTitle));
|
|
|
|
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.getString("HideNewChatsAlertText", R.string.HideNewChatsAlertText)));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
builder.setPositiveButton(LocaleController.getString("GoToSettings", R.string.GoToSettings), (dialog, which) -> {
|
|
|
|
presentFragment(new PrivacySettingsActivity());
|
|
|
|
AndroidUtilities.scrollToFragmentRow(parentLayout, "newChatsRow");
|
|
|
|
});
|
|
|
|
showDialog(builder.create(), dialog -> onSuggestionDismiss());
|
|
|
|
return true;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
return false;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void showFiltersHint() {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (askingForPermissions || !getMessagesController().dialogFiltersLoaded || !getMessagesController().showFiltersTooltip || filterTabsView == null || !getMessagesController().dialogFilters.isEmpty() || isPaused || !getUserConfig().filtersLoaded || inPreviewMode) {
|
2020-03-30 14:00:09 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
|
|
|
if (preferences.getBoolean("filterhint", false)) {
|
|
|
|
return;
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2020-06-25 17:29:04 +02:00
|
|
|
preferences.edit().putBoolean("filterhint", true).apply();
|
2020-03-30 14:00:09 +02:00
|
|
|
AndroidUtilities.runOnUIThread(() -> getUndoView().showWithAction(0, UndoView.ACTION_FILTERS_AVAILABLE, null, () -> presentFragment(new FiltersSetupActivity())), 1000);
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void setDialogsListFrozen(boolean frozen) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null || dialogsListFrozen == frozen) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (frozen) {
|
2020-03-30 14:00:09 +02:00
|
|
|
frozenDialogsList = new ArrayList<>(getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false));
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
frozenDialogsList = null;
|
|
|
|
}
|
|
|
|
dialogsListFrozen = frozen;
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].dialogsAdapter.setDialogsListFrozen(frozen);
|
2019-05-14 14:08:05 +02:00
|
|
|
if (!frozen) {
|
2020-03-30 14:00:09 +02:00
|
|
|
viewPages[0].dialogsAdapter.notifyDataSetChanged();
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
@NonNull
|
|
|
|
public ArrayList<TLRPC.Dialog> getDialogsArray(int currentAccount, int dialogsType, int folderId, boolean frozen) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (frozen && frozenDialogsList != null) {
|
|
|
|
return frozenDialogsList;
|
|
|
|
}
|
|
|
|
MessagesController messagesController = AccountInstance.getInstance(currentAccount).getMessagesController();
|
2015-06-29 19:12:11 +02:00
|
|
|
if (dialogsType == 0) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.getDialogs(folderId);
|
2021-01-28 15:15:51 +01:00
|
|
|
} else if (dialogsType == 1 || dialogsType == 10 || dialogsType == 13) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsServerOnly;
|
2015-06-29 19:12:11 +02:00
|
|
|
} else if (dialogsType == 2) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsCanAddUsers;
|
2017-12-08 18:35:59 +01:00
|
|
|
} else if (dialogsType == 3) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsForward;
|
2021-01-28 15:15:51 +01:00
|
|
|
} else if (dialogsType == 4 || dialogsType == 12) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsUsersOnly;
|
2019-02-08 03:30:32 +01:00
|
|
|
} else if (dialogsType == 5) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsChannelsOnly;
|
2021-01-28 15:15:51 +01:00
|
|
|
} else if (dialogsType == 6 || dialogsType == 11) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return messagesController.dialogsGroupsOnly;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (dialogsType == 7 || dialogsType == 8) {
|
|
|
|
MessagesController.DialogFilter dialogFilter = messagesController.selectedDialogFilter[dialogsType == 7 ? 0 : 1];
|
|
|
|
if (dialogFilter == null) {
|
|
|
|
return messagesController.getDialogs(folderId);
|
|
|
|
} else {
|
|
|
|
return dialogFilter.dialogs;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
} else if (dialogsType == 9) {
|
|
|
|
return messagesController.dialogsForBlock;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
return new ArrayList<>();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
private void updatePasscodeButton(boolean animated) {
|
2015-02-26 02:32:51 +01:00
|
|
|
if (passcodeItem == null) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (isPaused) {
|
|
|
|
animated = false;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (SharedConfig.passcodeHash.length() != 0 && !searching) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (doneItem == null || doneItem.getVisibility() != View.VISIBLE) {
|
|
|
|
passcodeItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
passcodeItemVisible = true;
|
2018-07-30 04:07:02 +02:00
|
|
|
if (SharedConfig.appLocked) {
|
2019-05-14 14:08:05 +02:00
|
|
|
passcodeItem.setContentDescription(LocaleController.getString("AccDescrPasscodeUnlock", R.string.AccDescrPasscodeUnlock));
|
2021-01-28 15:15:51 +01:00
|
|
|
passcodeItem.setIcon(passcodeDrawable2);
|
|
|
|
if (animated) {
|
|
|
|
passcodeDrawable2.setCurrentFrame(0, false);
|
|
|
|
passcodeItem.getIconView().playAnimation();
|
|
|
|
} else {
|
|
|
|
passcodeDrawable2.setCurrentFrame(38, false);
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
passcodeItem.setContentDescription(LocaleController.getString("AccDescrPasscodeLock", R.string.AccDescrPasscodeLock));
|
2021-01-28 15:15:51 +01:00
|
|
|
passcodeItem.setIcon(passcodeDrawable);
|
|
|
|
if (animated) {
|
|
|
|
passcodeDrawable.setCurrentFrame(0, false);
|
|
|
|
passcodeItem.getIconView().playAnimation();
|
|
|
|
} else {
|
|
|
|
passcodeDrawable.setCurrentFrame(31, false);
|
|
|
|
}
|
2015-02-01 19:51:02 +01:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
} else {
|
|
|
|
passcodeItem.setVisibility(View.GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
passcodeItemVisible = false;
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-06 22:34:47 +01:00
|
|
|
private void hideFloatingButton(boolean hide) {
|
2021-01-28 15:15:51 +01:00
|
|
|
if (floatingHidden == hide || hide && floatingForceVisible) {
|
2014-11-06 22:34:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
floatingHidden = hide;
|
2018-07-30 04:07:02 +02:00
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
2020-06-25 17:29:04 +02:00
|
|
|
ValueAnimator valueAnimator = ValueAnimator.ofFloat(floatingButtonHideProgress, floatingHidden ? 1f : 0f);
|
2019-12-31 14:08:08 +01:00
|
|
|
valueAnimator.addUpdateListener(animation -> {
|
|
|
|
floatingButtonHideProgress = (float) animation.getAnimatedValue();
|
|
|
|
floatingButtonTranslation = AndroidUtilities.dp(100) * floatingButtonHideProgress;
|
|
|
|
updateFloatingButtonOffset();
|
|
|
|
});
|
2020-03-30 14:00:09 +02:00
|
|
|
animatorSet.playTogether(valueAnimator);
|
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
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void updateDialogIndices() {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages == null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int b = 0; b < viewPages.length; b++) {
|
|
|
|
if (viewPages[b].getVisibility() != View.VISIBLE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ArrayList<TLRPC.Dialog> dialogs = getDialogsArray(currentAccount, viewPages[b].dialogsType, folderId, false);
|
|
|
|
int count = viewPages[b].listView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = viewPages[b].listView.getChildAt(a);
|
|
|
|
if (child instanceof DialogCell) {
|
|
|
|
DialogCell dialogCell = (DialogCell) child;
|
|
|
|
TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(dialogCell.getDialogId());
|
|
|
|
if (dialog == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int index = dialogs.indexOf(dialog);
|
|
|
|
if (index < 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
dialogCell.setDialogIndex(index);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-04 19:36:55 +01:00
|
|
|
private void updateVisibleRows(int mask) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (dialogsListFrozen) {
|
2014-02-04 19:36:55 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int c = 0; c < 3; c++) {
|
|
|
|
RecyclerListView list;
|
|
|
|
if (c == 2) {
|
2020-09-30 15:48:47 +02:00
|
|
|
list = searchViewPager != null ? searchViewPager.searchListView : null;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (viewPages != null) {
|
|
|
|
list = c < viewPages.length ? viewPages[c].listView : null;
|
|
|
|
if (list != null && viewPages[c].getVisibility() != View.VISIBLE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (list == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
int count = list.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = list.getChildAt(a);
|
|
|
|
if (child instanceof DialogCell) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (list.getAdapter() != searchViewPager.dialogsSearchAdapter) {
|
2019-12-31 14:08:08 +01:00
|
|
|
DialogCell cell = (DialogCell) child;
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_REORDER) != 0) {
|
|
|
|
cell.onReorderStateChanged(actionBar.isActionModeShowed(), true);
|
|
|
|
}
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_CHECK) != 0) {
|
|
|
|
cell.setChecked(false, (mask & MessagesController.UPDATE_MASK_CHAT) != 0);
|
|
|
|
} else {
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_NEW_MESSAGE) != 0) {
|
|
|
|
cell.checkCurrentDialogIndex(dialogsListFrozen);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[c].isDefaultDialogType() && AndroidUtilities.isTablet()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
|
|
|
}
|
|
|
|
} else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages[c].isDefaultDialogType() && AndroidUtilities.isTablet()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
cell.setDialogSelected(cell.getDialogId() == openedDialogId);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cell.update(mask);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
if (selectedDialogs != null) {
|
|
|
|
cell.setChecked(selectedDialogs.contains(cell.getDialogId()), false);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
} else if (child instanceof UserCell) {
|
|
|
|
((UserCell) child).update(mask);
|
|
|
|
} else if (child instanceof ProfileSearchCell) {
|
|
|
|
((ProfileSearchCell) child).update(mask);
|
|
|
|
} 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) {
|
|
|
|
((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;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public void setInitialSearchString(String initialSearchString) {
|
|
|
|
this.initialSearchString = initialSearchString;
|
|
|
|
}
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
public boolean isMainDialogList() {
|
|
|
|
return delegate == null && searchString == null;
|
2014-09-24 04:17:27 +02:00
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
public void setInitialSearchType(int type) {
|
|
|
|
this.initialSearchType = type;
|
|
|
|
}
|
|
|
|
|
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) {
|
2020-01-23 07:15:40 +01:00
|
|
|
int lowerId = (int) dialog_id;
|
|
|
|
if (lowerId < 0) {
|
|
|
|
TLRPC.Chat chat = getMessagesController().getChat(-lowerId);
|
|
|
|
if (ChatObject.isChannel(chat) && !chat.megagroup && ((cantSendToChannels || !ChatObject.isCanWriteToChannel(-lowerId, currentAccount)) || hasPoll == 2)) {
|
2017-03-31 01:58:05 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2019-12-31 14:08:08 +01:00
|
|
|
builder.setTitle(LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle));
|
2020-01-23 07:15:40 +01:00
|
|
|
if (hasPoll == 2) {
|
|
|
|
builder.setMessage(LocaleController.getString("PublicPollCantForward", R.string.PublicPollCantForward));
|
|
|
|
} else {
|
|
|
|
builder.setMessage(LocaleController.getString("ChannelCantSendMessage", R.string.ChannelCantSendMessage));
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
return;
|
|
|
|
}
|
2020-01-23 07:15:40 +01:00
|
|
|
} else if (lowerId == 0 && hasPoll != 0) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setTitle(LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle));
|
|
|
|
builder.setMessage(LocaleController.getString("PollCantForwardSecretChat", R.string.PollCantForwardSecretChat));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
showDialog(builder.create());
|
|
|
|
return;
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (initialDialogsType == 11 || initialDialogsType == 12 || initialDialogsType == 13) {
|
2021-02-23 12:53:38 +01:00
|
|
|
if (checkingImportDialog) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int lowerId = (int) dialog_id;
|
|
|
|
TLRPC.User user;
|
|
|
|
TLRPC.Chat chat;
|
|
|
|
if (lowerId > 0) {
|
|
|
|
user = getMessagesController().getUser(lowerId);
|
|
|
|
chat = null;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (!user.mutual_contact) {
|
|
|
|
getUndoView().showWithAction(dialog_id, UndoView.ACTION_IMPORT_NOT_MUTUAL, null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
2021-02-23 12:53:38 +01:00
|
|
|
user = null;
|
|
|
|
chat = getMessagesController().getChat(-lowerId);
|
2021-01-28 15:15:51 +01:00
|
|
|
if (!ChatObject.hasAdminRights(chat) || !ChatObject.canChangeChatInfo(chat)) {
|
|
|
|
getUndoView().showWithAction(dialog_id, UndoView.ACTION_IMPORT_GROUP_NOT_ADMIN, null);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-02-23 12:53:38 +01:00
|
|
|
final AlertDialog progressDialog = new AlertDialog(getParentActivity(), 3);
|
|
|
|
TLRPC.TL_messages_checkHistoryImportPeer req = new TLRPC.TL_messages_checkHistoryImportPeer();
|
|
|
|
req.peer = getMessagesController().getInputPeer(lowerId);
|
|
|
|
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
try {
|
|
|
|
progressDialog.dismiss();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
|
|
|
checkingImportDialog = false;
|
|
|
|
if (response != null) {
|
|
|
|
TLRPC.TL_messages_checkedHistoryImportPeer res = (TLRPC.TL_messages_checkedHistoryImportPeer) response;
|
|
|
|
AlertsCreator.createImportDialogAlert(this, arguments.getString("importTitle"), res.confirm_text, user, chat, () -> {
|
|
|
|
setDialogsListFrozen(true);
|
|
|
|
ArrayList<Long> dids = new ArrayList<>();
|
|
|
|
dids.add(dialog_id);
|
|
|
|
delegate.didSelectDialogs(DialogsActivity.this, dids, null, param);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
AlertsCreator.processError(currentAccount, error, this, req);
|
|
|
|
getNotificationCenter().postNotificationName(NotificationCenter.historyImportProgressChanged, dialog_id, req, error);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
try {
|
|
|
|
progressDialog.showDelayed(300);
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
} else 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());
|
2015-05-21 23:27:27 +02:00
|
|
|
int lower_part = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
2019-12-31 14:08:08 +01:00
|
|
|
String title;
|
|
|
|
String message;
|
|
|
|
String buttonText;
|
2013-10-25 17:19:00 +02:00
|
|
|
if (lower_part != 0) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (lower_part == getUserConfig().getClientUserId()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle);
|
|
|
|
message = LocaleController.formatStringSimple(selectAlertStringGroup, LocaleController.getString("SavedMessages", R.string.SavedMessages));
|
|
|
|
buttonText = LocaleController.getString("Send", R.string.Send);
|
2019-09-10 12:56:11 +02:00
|
|
|
} else if (lower_part > 0) {
|
|
|
|
TLRPC.User user = getMessagesController().getUser(lower_part);
|
2020-01-23 07:15:40 +01:00
|
|
|
if (user == null || selectAlertString == null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle);
|
|
|
|
message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user));
|
|
|
|
buttonText = LocaleController.getString("Send", R.string.Send);
|
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
TLRPC.Chat chat = getMessagesController().getChat(-lower_part);
|
2014-02-04 19:36:55 +01:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (addToGroupAlertString != null) {
|
2019-12-31 14:08:08 +01:00
|
|
|
title = LocaleController.getString("AddToTheGroupAlertTitle", R.string.AddToTheGroupAlertTitle);
|
|
|
|
message = LocaleController.formatStringSimple(addToGroupAlertString, chat.title);
|
|
|
|
buttonText = LocaleController.getString("Add", R.string.Add);
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle);
|
|
|
|
message = LocaleController.formatStringSimple(selectAlertStringGroup, chat.title);
|
|
|
|
buttonText = LocaleController.getString("Send", R.string.Send);
|
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 {
|
2019-05-14 14:08:05 +02:00
|
|
|
TLRPC.EncryptedChat chat = getMessagesController().getEncryptedChat(high_id);
|
|
|
|
TLRPC.User user = getMessagesController().getUser(chat.user_id);
|
2014-07-27 12:53:00 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle);
|
|
|
|
message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user));
|
|
|
|
buttonText = LocaleController.getString("Send", R.string.Send);
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
builder.setTitle(title);
|
|
|
|
builder.setMessage(AndroidUtilities.replaceTags(message));
|
|
|
|
builder.setPositiveButton(buttonText, (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);
|
2019-07-18 15:01:39 +02:00
|
|
|
if (resetDelegate) {
|
|
|
|
delegate = null;
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
} else {
|
|
|
|
finishFragment();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
public RLottieImageView getFloatingButton() {
|
|
|
|
return floatingButton;
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
@Override
|
2020-04-24 11:21:58 +02:00
|
|
|
public ArrayList<ThemeDescription> getThemeDescriptions() {
|
2018-08-27 10:33:11 +02:00
|
|
|
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int b = 0; b < 3; b++) {
|
|
|
|
RecyclerListView list;
|
|
|
|
if (b == 2) {
|
2020-09-30 18:55:35 +02:00
|
|
|
if (searchViewPager == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
list = searchViewPager.searchListView;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (viewPages != null) {
|
|
|
|
list = b < viewPages.length ? viewPages[b].listView : null;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (list == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int count = list.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = list.getChildAt(a);
|
|
|
|
if (child instanceof ProfileSearchCell) {
|
|
|
|
((ProfileSearchCell) child).update(0);
|
|
|
|
} else if (child instanceof DialogCell) {
|
|
|
|
((DialogCell) child).update(0);
|
|
|
|
} else if (child instanceof UserCell) {
|
|
|
|
((UserCell) child).update(0);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2020-09-30 18:55:35 +02:00
|
|
|
if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
RecyclerListView recyclerListView = searchViewPager.dialogsSearchAdapter.getInnerListView();
|
2018-08-27 10:33:11 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-06-04 12:14:50 +02:00
|
|
|
if (sideMenu != null) {
|
|
|
|
View child = sideMenu.getChildAt(0);
|
|
|
|
if (child instanceof DrawerProfileCell) {
|
|
|
|
DrawerProfileCell profileCell = (DrawerProfileCell) child;
|
2019-07-18 15:01:39 +02:00
|
|
|
profileCell.applyBackground(true);
|
2019-12-31 14:08:08 +01:00
|
|
|
profileCell.updateColors();
|
2019-06-04 12:14:50 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (viewPages[a].pullForegroundDrawable == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
viewPages[a].pullForegroundDrawable.updateColors();
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
if (actionBar != null) {
|
|
|
|
actionBar.setPopupBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), true);
|
|
|
|
actionBar.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false, true);
|
|
|
|
actionBar.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon), true, true);
|
|
|
|
actionBar.setPopupItemsSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector), true);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (scrimPopupWindowItems != null) {
|
|
|
|
for (int a = 0; a < scrimPopupWindowItems.length; a++) {
|
|
|
|
scrimPopupWindowItems[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
|
|
|
|
scrimPopupWindowItems[a].setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (scrimPopupWindow != null) {
|
|
|
|
final View contentView = scrimPopupWindow.getContentView();
|
|
|
|
contentView.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
contentView.invalidate();
|
|
|
|
}
|
|
|
|
if (doneItem != null) {
|
|
|
|
doneItem.setIconColor(Theme.getColor(Theme.key_actionBarDefaultIcon));
|
|
|
|
}
|
2020-10-02 13:25:02 +02:00
|
|
|
if (commentView != null) {
|
|
|
|
commentView.updateColors();
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
if (filtersView != null) {
|
|
|
|
filtersView.updateColors();
|
|
|
|
}
|
2020-09-30 18:55:35 +02:00
|
|
|
if (searchViewPager != null) {
|
|
|
|
searchViewPager.updateColors();
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchTabsView != null) {
|
|
|
|
searchTabsView.updateColors();
|
|
|
|
}
|
2020-09-30 18:55:35 +02:00
|
|
|
if (searchItem != null) {
|
|
|
|
EditTextBoldCursor editText = searchItem.getSearchField();
|
|
|
|
if (whiteActionBar) {
|
|
|
|
editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
editText.setHintTextColor(Theme.getColor(Theme.key_player_time));
|
|
|
|
editText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor));
|
|
|
|
} else {
|
|
|
|
editText.setCursorColor(Theme.getColor(Theme.key_actionBarDefaultSearch));
|
|
|
|
editText.setHintTextColor(Theme.getColor(Theme.key_actionBarDefaultSearchPlaceholder));
|
|
|
|
editText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSearch));
|
|
|
|
}
|
|
|
|
searchItem.updateColor();
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
setSearchAnimationProgress(searchAnimationProgress);
|
2017-03-31 01:58:05 +02:00
|
|
|
};
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
|
|
|
|
|
|
|
if (movingView != null) {
|
|
|
|
arrayList.add(new ThemeDescription(movingView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (doneItem != null) {
|
|
|
|
arrayList.add(new ThemeDescription(doneItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarDefaultSelector));
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
if (folderId == 0) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (onlySelect) {
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
|
|
|
|
}
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, 0, null, actionBarDefaultPaint, null, null, Theme.key_actionBarDefault));
|
|
|
|
if (searchViewPager != null) {
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.searchListView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, cellDelegate, Theme.key_actionBarDefaultIcon));
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, new Drawable[]{Theme.dialogs_holidayDrawable}, null, Theme.key_actionBarDefaultTitle));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultSearch));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultSearchPlaceholder));
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
arrayList.add(new ThemeDescription(fragmentView, 0, null, actionBarDefaultPaint, null, null, Theme.key_actionBarDefaultArchived));
|
|
|
|
if (searchViewPager != null) {
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.searchListView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefaultArchived));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultArchivedIcon));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, new Drawable[]{Theme.dialogs_holidayDrawable}, null, Theme.key_actionBarDefaultArchivedTitle));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultArchivedSelector));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCH, null, null, null, null, Theme.key_actionBarDefaultArchivedSearch));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SEARCHPLACEHOLDER, null, null, null, null, Theme.key_actionBarDefaultArchivedSearchPlaceholder));
|
|
|
|
}
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
|
2020-09-30 15:48:47 +02:00
|
|
|
//arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault));
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_TOPBACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefaultTop));
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultSelector));
|
|
|
|
arrayList.add(new ThemeDescription(selectedDialogsCountTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_actionBarActionModeDefaultIcon));
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarDefaultSubmenuItem));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarDefaultSubmenuItemIcon));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_dialogButtonSelector));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (filterTabsView != null) {
|
|
|
|
if (actionBar.isActionModeShowed()) {
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView, 0, new Class[]{FilterTabsView.class}, new String[]{"selectorDrawable"}, null, null, null, Theme.key_profile_tabSelectedLine));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_profile_tabSelectedText));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_profile_tabText));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_profile_tabSelector));
|
|
|
|
} else {
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView, 0, new Class[]{FilterTabsView.class}, new String[]{"selectorDrawable"}, null, null, null, Theme.key_actionBarTabLine));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_actionBarTabActiveText));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_actionBarTabUnactiveText));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_actionBarTabSelector));
|
|
|
|
}
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), 0, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_chats_tabUnreadActiveBackground));
|
|
|
|
arrayList.add(new ThemeDescription(filterTabsView.getTabsContainer(), 0, new Class[]{FilterTabsView.TabView.class}, null, null, null, Theme.key_chats_tabUnreadUnactiveBackground));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionIcon));
|
|
|
|
arrayList.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_chats_actionBackground));
|
|
|
|
arrayList.add(new ThemeDescription(floatingButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_chats_actionPressedBackground));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
for (int a = 0; a < 3; a++) {
|
|
|
|
RecyclerListView list;
|
|
|
|
if (a == 2) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
list = searchViewPager.searchListView;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (viewPages != null) {
|
|
|
|
list = a < viewPages.length ? viewPages[a].listView : null;
|
|
|
|
} else {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (list == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, Theme.avatarDrawables, null, Theme.key_avatar_text));
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_countGrayPaint, null, null, Theme.key_chats_unreadCounterMuted));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_countTextPaint, null, null, Theme.key_chats_unreadCounterText));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_lockDrawable}, null, Theme.key_chats_secretIcon));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_groupDrawable, Theme.dialogs_broadcastDrawable, Theme.dialogs_botDrawable}, null, Theme.key_chats_nameIcon));
|
2021-01-28 15:15:51 +01:00
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_scamDrawable, Theme.dialogs_fakeDrawable}, null, Theme.key_chats_draft));
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_pinnedDrawable, Theme.dialogs_reorderDrawable}, null, Theme.key_chats_pinnedIcon));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Paint[]{Theme.dialogs_namePaint[0], Theme.dialogs_namePaint[1], Theme.dialogs_searchNamePaint}, null, null, Theme.key_chats_name));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Paint[]{Theme.dialogs_nameEncryptedPaint[0], Theme.dialogs_nameEncryptedPaint[1], Theme.dialogs_searchNameEncryptedPaint}, null, null, Theme.key_chats_secretName));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_messagePaint[1], null, null, Theme.key_chats_message_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_messagePaint[0], null, null, Theme.key_chats_message));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_messageNamePaint, null, null, Theme.key_chats_nameMessage_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, null, null, Theme.key_chats_draft));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, Theme.dialogs_messagePrintingPaint, null, null, Theme.key_chats_actionMessage));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_timePaint, null, null, Theme.key_chats_date));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_pinnedPaint, null, null, Theme.key_chats_pinnedOverlay));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_tabletSeletedPaint, null, null, Theme.key_chats_tabletSelectedOverlay));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_checkDrawable}, null, Theme.key_chats_sentCheck));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_checkReadDrawable, Theme.dialogs_halfCheckDrawable}, null, Theme.key_chats_sentReadCheck));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_clockDrawable}, null, Theme.key_chats_sentClock));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, Theme.dialogs_errorPaint, null, null, Theme.key_chats_sentError));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_errorDrawable}, null, Theme.key_chats_sentErrorIcon));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedCheckDrawable}, null, Theme.key_chats_verifiedCheck));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_verifiedDrawable}, null, Theme.key_chats_verifiedBackground));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_muteDrawable}, null, Theme.key_chats_muteIcon));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, new Drawable[]{Theme.dialogs_mentionDrawable}, null, Theme.key_chats_mentionIcon));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, null, null, Theme.key_chats_archivePinBackground));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, null, null, Theme.key_chats_archiveBackground));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, null, null, Theme.key_chats_onlineCircle));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class}, null, null, null, Theme.key_windowBackgroundWhite));
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_CHECKBOX, new Class[]{DialogCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_windowBackgroundWhite));
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_CHECKBOXCHECK, new Class[]{DialogCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_checkboxCheck));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{LoadingCell.class}, new String[]{"progressBar"}, null, null, null, Theme.key_progressCircle));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_offlinePaint, null, null, Theme.key_windowBackgroundWhiteGrayText3));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{ProfileSearchCell.class}, Theme.dialogs_onlinePaint, null, null, Theme.key_windowBackgroundWhiteBlueText3));
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
GraySectionCell.createThemeDescriptions(arrayList, list);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{HashtagSearchCell.class}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGray));
|
2021-01-28 15:15:51 +01:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
|
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{TextInfoPrivacyCell.class}, null, null, null, Theme.key_windowBackgroundGray));
|
|
|
|
arrayList.add(new ThemeDescription(list, 0, new Class[]{TextInfoPrivacyCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText4));
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueText2));
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundSaved));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundArchived));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundArchivedHidden));
|
2019-12-31 14:08:08 +01:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_nameMessage));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_draft));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_attachMessage));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_nameArchived));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_nameMessageArchived));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_nameMessageArchived_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_messageArchived));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (viewPages != null) {
|
|
|
|
for (int a = 0; a < viewPages.length; a++) {
|
|
|
|
if (folderId == 0) {
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
|
|
|
|
} else {
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefaultArchived));
|
|
|
|
}
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DialogsEmptyCell.class}, new String[]{"emptyTextView1"}, null, null, null, Theme.key_chats_nameMessage_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DialogsEmptyCell.class}, new String[]{"emptyTextView2"}, null, null, null, Theme.key_chats_message));
|
|
|
|
|
|
|
|
if (SharedConfig.archiveHidden) {
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Arrow1", Theme.key_avatar_backgroundArchivedHidden));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Arrow2", Theme.key_avatar_backgroundArchivedHidden));
|
|
|
|
} else {
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Arrow1", Theme.key_avatar_backgroundArchived));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Arrow2", Theme.key_avatar_backgroundArchived));
|
|
|
|
}
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Box2", Theme.key_avatar_text));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveAvatarDrawable}, "Box1", Theme.key_avatar_text));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_pinArchiveDrawable}, "Arrow", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_pinArchiveDrawable}, "Line", Theme.key_chats_archiveIcon));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unpinArchiveDrawable}, "Arrow", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unpinArchiveDrawable}, "Line", Theme.key_chats_archiveIcon));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveDrawable}, "Arrow", Theme.key_chats_archiveBackground));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveDrawable}, "Box2", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_archiveDrawable}, "Box1", Theme.key_chats_archiveIcon));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-04-30 21:07:00 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_hidePsaDrawable}, "Line 1", Theme.key_chats_archiveBackground));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_hidePsaDrawable}, "Line 2", Theme.key_chats_archiveBackground));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_hidePsaDrawable}, "Line 3", Theme.key_chats_archiveBackground));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_hidePsaDrawable}, "Cup Red", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_hidePsaDrawable}, "Box", Theme.key_chats_archiveIcon));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unarchiveDrawable}, "Arrow1", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unarchiveDrawable}, "Arrow2", Theme.key_chats_archivePinBackground));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unarchiveDrawable}, "Box2", Theme.key_chats_archiveIcon));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{DialogCell.class}, new RLottieDrawable[]{Theme.dialogs_unarchiveDrawable}, "Box1", Theme.key_chats_archiveIcon));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{UserCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{UserCell.class}, new String[]{"statusColor"}, null, null, cellDelegate, Theme.key_windowBackgroundWhiteGrayText));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{UserCell.class}, new String[]{"statusOnlineColor"}, null, null, cellDelegate, Theme.key_windowBackgroundWhiteBlueText));
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].listView, 0, new Class[]{TextCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
arrayList.add(new ThemeDescription(viewPages[a].progressView, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle));
|
|
|
|
|
|
|
|
ViewPager pager = viewPages[a].dialogsAdapter.getArchiveHintCellPager();
|
|
|
|
arrayList.add(new ThemeDescription(pager, 0, new Class[]{ArchiveHintInnerCell.class}, new String[]{"imageView"}, null, null, null, Theme.key_chats_nameMessage_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(pager, 0, new Class[]{ArchiveHintInnerCell.class}, new String[]{"imageView2"}, null, null, null, Theme.key_chats_unreadCounter));
|
|
|
|
arrayList.add(new ThemeDescription(pager, 0, new Class[]{ArchiveHintInnerCell.class}, new String[]{"headerTextView"}, null, null, null, Theme.key_chats_nameMessage_threeLines));
|
|
|
|
arrayList.add(new ThemeDescription(pager, 0, new Class[]{ArchiveHintInnerCell.class}, new String[]{"messageTextView"}, null, null, null, Theme.key_chats_message));
|
|
|
|
arrayList.add(new ThemeDescription(pager, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefaultArchived));
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_archivePullDownBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chats_archivePullDownBackgroundActive));
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_chats_menuBackground));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuName));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuPhone));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuPhoneCats));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuCloudBackgroundCats));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chat_serviceBackground));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuTopShadow));
|
2019-06-04 12:14:50 +02:00
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuTopShadowCats));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{DrawerProfileCell.class}, null, null, cellDelegate, Theme.key_chats_menuTopBackgroundCats));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_CELLBACKGROUNDCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{DrawerProfileCell.class}, null, null, cellDelegate, Theme.key_chats_menuTopBackground));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerActionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemIcon));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerActionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText));
|
2020-10-09 19:35:17 +02:00
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerActionCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemIcon));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerActionCheckCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerUserCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_unreadCounterText));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_unreadCounter));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{DrawerUserCell.class}, new String[]{"checkBox"}, null, null, null, Theme.key_chats_menuBackground));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerAddCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemIcon));
|
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerAddCell.class}, new String[]{"textView"}, null, null, null, Theme.key_chats_menuItemText));
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DividerCell.class}, Theme.dividerPaint, null, null, Theme.key_divider));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
if (searchViewPager != null) {
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countPaint, null, null, Theme.key_chats_unreadCounter));
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countGrayPaint, null, null, Theme.key_chats_unreadCounterMuted));
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_countTextPaint, null, null, Theme.key_chats_unreadCounterText));
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, Theme.dialogs_archiveTextPaint, null, null, Theme.key_chats_archiveText));
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, new String[]{"nameTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
arrayList.add(new ThemeDescription(searchViewPager.dialogsSearchAdapter != null ? searchViewPager.dialogsSearchAdapter.getInnerListView() : null, 0, new Class[]{HintDialogCell.class}, null, null, null, Theme.key_chats_onlineCircle));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, null, null, null, Theme.key_inappPlayerBackground));
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"playButton"}, null, null, null, Theme.key_inappPlayerPlayPause));
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_inappPlayerTitle));
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_FASTSCROLL, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_inappPlayerPerformer));
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{FragmentContextView.class}, new String[]{"closeButton"}, null, null, null, Theme.key_inappPlayerClose));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"frameLayout"}, null, null, null, Theme.key_returnToCallBackground));
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{FragmentContextView.class}, new String[]{"titleTextView"}, null, null, null, Theme.key_returnToCallText));
|
|
|
|
|
|
|
|
for (int a = 0; a < undoView.length; a++) {
|
2019-12-31 14:08:08 +01:00
|
|
|
arrayList.add(new ThemeDescription(undoView[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background));
|
2019-05-14 14:08:05 +02:00
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"undoImageView"}, null, null, null, Theme.key_undo_cancelColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"undoTextView"}, null, null, null, Theme.key_undo_cancelColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"infoTextView"}, null, null, null, Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"subinfoTextView"}, null, null, null, Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"textPaint"}, null, null, null, Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"progressPaint"}, null, null, null, Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "info1", Theme.key_undo_background));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "info2", Theme.key_undo_background));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc12", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc11", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc10", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc9", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc8", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc7", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc6", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc5", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc4", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc3", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc2", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "luc1", Theme.key_undo_infoColor));
|
|
|
|
arrayList.add(new ThemeDescription(undoView[a], 0, new Class[]{UndoView.class}, new String[]{"leftImageView"}, "Oval", Theme.key_undo_infoColor));
|
|
|
|
}
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBackgroundGray));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlack));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextLink));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLinkSelection));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue3));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextBlue4));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextRed));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextRed2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray3));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextGray4));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogIcon));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRedIcon));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogTextHint));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogInputField));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogInputFieldActivated));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareCheck));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareUnchecked));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogCheckboxSquareDisabled));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRadioBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRadioBackgroundChecked));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogProgressCircle));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogButton));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogButtonSelector));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogScrollGlow));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRoundCheckBox));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogRoundCheckBoxCheck));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBadgeBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogBadgeText));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLineProgress));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogLineProgressBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogGrayLine));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialog_inlineProgressBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialog_inlineProgress));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogSearchBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogSearchHint));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogSearchIcon));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogSearchText));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogFloatingButton));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogFloatingIcon));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_dialogShadowLine));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_sheet_scrollUp));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_sheet_other));
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBar));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarSelector));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarTitle));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarTop));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarSubtitle));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_actionBarItems));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_background));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_time));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progressBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progressCachedBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_progress));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_button));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_player_buttonActive));
|
|
|
|
|
2020-10-02 13:25:02 +02:00
|
|
|
if (commentView != null) {
|
|
|
|
arrayList.add(new ThemeDescription(commentView, 0, null, Theme.chat_composeBackgroundPaint, null, null, Theme.key_chat_messagePanelBackground));
|
|
|
|
arrayList.add(new ThemeDescription(commentView, 0, null, null, new Drawable[]{Theme.chat_composeShadowDrawable}, null, Theme.key_chat_messagePanelShadow));
|
|
|
|
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelText));
|
|
|
|
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_CURSORCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelCursor));
|
|
|
|
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_HINTTEXTCOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"messageEditText"}, null, null, null, Theme.key_chat_messagePanelHint));
|
|
|
|
arrayList.add(new ThemeDescription(commentView, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{ChatActivityEnterView.class}, new String[]{"sendButton"}, null, null, null, Theme.key_chat_messagePanelSend));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_actionBarTipBackground));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_player_time));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_chat_messagePanelCursor));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_actionBarIconBlue));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_groupcreate_spanBackground));
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen1));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayGreen2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue1));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayBlue2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen1));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGreen2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue1));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelBlue2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_topPanelGray));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientMuted2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertGradientUnmuted2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient2));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_mutedByAdminGradient3));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin));
|
|
|
|
arrayList.add(new ThemeDescription(null, 0, null, null, null, null, Theme.key_voipgroup_overlayAlertMutedByAdmin2));
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
if (filtersView != null) {
|
|
|
|
arrayList.addAll(filtersView.getThemeDescriptions());
|
|
|
|
filtersView.updateColors();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (searchViewPager != null) {
|
|
|
|
searchViewPager.getThemeDescriptors(arrayList);
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
return arrayList;
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2020-04-08 10:16:23 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSwipeBackEnabled(MotionEvent event) {
|
|
|
|
return !((initialDialogsType == 3 && NekoConfig.showTabsOnForward) && viewPages[0].selectedType != filterTabsView.getFirstTabId());
|
|
|
|
}
|
2013-10-25 17:19:00 +02:00
|
|
|
}
|