/* * This is the source code of Telegram for Android v. 5.x.x. * It is licensed under GNU GPL v. 2 or later. * You should have received a copy of the license in this archive (see LICENSE). * * Copyright Nikolai Kudashov, 2013-2018. */ package org.telegram.ui; import android.Manifest; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.StateListAnimator; import android.animation.ValueAnimator; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Outline; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Vibrator; import android.text.TextUtils; import android.util.Property; import android.util.StateSet; import android.view.Gravity; import android.view.HapticFeedbackConstants; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewOutlineProvider; import android.view.ViewParent; import android.view.ViewTreeObserver; import android.view.WindowManager; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.animation.Interpolator; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ScrollView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; 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; import org.telegram.messenger.AccountInstance; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.BuildVars; import org.telegram.messenger.ChatObject; import org.telegram.messenger.ContactsController; import org.telegram.messenger.DialogObject; import org.telegram.messenger.FileLog; import org.telegram.messenger.ImageLoader; import org.telegram.messenger.ImageLocation; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationsController; import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserObject; import org.telegram.messenger.Utilities; import org.telegram.messenger.XiaomiUtilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.ActionBar; import org.telegram.ui.ActionBar.ActionBarMenu; import org.telegram.ui.ActionBar.ActionBarMenuItem; import org.telegram.ui.ActionBar.ActionBarMenuSubItem; import org.telegram.ui.ActionBar.ActionBarPopupWindow; import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.MenuDrawable; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.Adapters.DialogsAdapter; import org.telegram.ui.Adapters.DialogsSearchAdapter; import org.telegram.ui.Adapters.FiltersView; import org.telegram.ui.Cells.AccountSelectCell; import org.telegram.ui.Cells.ArchiveHintInnerCell; import org.telegram.ui.Cells.DialogCell; import org.telegram.ui.Cells.DialogsEmptyCell; import org.telegram.ui.Cells.DividerCell; import org.telegram.ui.Cells.DrawerActionCell; import org.telegram.ui.Cells.DrawerAddCell; import org.telegram.ui.Cells.DrawerProfileCell; import org.telegram.ui.Cells.DrawerUserCell; import org.telegram.ui.Cells.GraySectionCell; import org.telegram.ui.Cells.HashtagSearchCell; import org.telegram.ui.Cells.HintDialogCell; import org.telegram.ui.Cells.LoadingCell; import org.telegram.ui.Cells.ProfileSearchCell; import org.telegram.ui.Cells.ShadowSectionCell; import org.telegram.ui.Cells.TextCell; import org.telegram.ui.Cells.UserCell; import org.telegram.ui.Components.AlertsCreator; import org.telegram.ui.Components.AnimatedArrowDrawable; import org.telegram.ui.Components.AnimationProperties; import org.telegram.ui.Components.AvatarDrawable; import org.telegram.ui.Components.BackupImageView; import org.telegram.ui.Components.Bulletin; import org.telegram.ui.Components.BulletinFactory; import org.telegram.ui.Components.ChatActivityEnterView; import org.telegram.ui.Components.ChatAvatarContainer; import org.telegram.ui.Components.CombinedDrawable; import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.DialogsItemAnimator; import org.telegram.ui.Components.EditTextBoldCursor; import org.telegram.ui.Components.FilterTabsView; import org.telegram.ui.Components.FiltersListBottomSheet; import org.telegram.ui.Components.FragmentContextView; import org.telegram.ui.Components.JoinGroupAlert; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.NumberTextView; import org.telegram.ui.Components.PacmanAnimation; import org.telegram.ui.Components.ProxyDrawable; import org.telegram.ui.Components.PullForegroundDrawable; import org.telegram.ui.Components.RLottieDrawable; import org.telegram.ui.Components.RadialProgressView; import org.telegram.ui.Components.RecyclerAnimationScrollHelper; import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.SearchViewPager; import org.telegram.ui.Components.SizeNotifierFrameLayout; import org.telegram.ui.Components.StickersAlert; import org.telegram.ui.Components.UndoView; import java.util.ArrayList; public class DialogsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate { private ViewPagerFixed.TabsView searchTabsView; 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; private RadialProgressView progressView; private int lastItemsCount; private DialogsItemAnimator dialogsItemAnimator; public ViewPage(Context context) { super(context); } public boolean isDefaultDialogType() { return dialogsType == 0 || dialogsType == 7 || dialogsType == 8; } } private ViewPage[] viewPages; private FiltersView filtersView; private ActionBarMenuItem passcodeItem; private boolean passcodeItemVisible; private ActionBarMenuItem proxyItem; private boolean proxyItemVisible; private ActionBarMenuItem searchItem; private ActionBarMenuItem doneItem; private ProxyDrawable proxyDrawable; private ImageView floatingButton; private FrameLayout floatingButtonContainer; private ChatAvatarContainer avatarContainer; private UndoView[] undoView = new UndoView[2]; private FilterTabsView filterTabsView; private boolean askingForPermissions; private SearchViewPager searchViewPager; private View blurredView; 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; private int messagesCount; private int hasPoll; private PacmanAnimation pacmanAnimation; private DialogCell slidingView; private DialogCell movingView; private boolean allowMoving; private boolean movingWas; private ArrayList movingDialogFilters = new ArrayList<>(); private boolean waitingForScrollFinished; private boolean allowSwipeDuringCurrentTouch; private boolean updatePullAfterScroll; private MenuDrawable menuDrawable; private BackDrawable backDrawable; private Paint actionBarDefaultPaint = new Paint(); private NumberTextView selectedDialogsCountTextView; private ArrayList actionModeViews = new ArrayList<>(); private ActionBarMenuItem deleteItem; private ActionBarMenuItem pinItem; private ActionBarMenuItem muteItem; private ActionBarMenuItem archive2Item; private ActionBarMenuSubItem pin2Item; private ActionBarMenuSubItem addToFolderItem; private ActionBarMenuSubItem removeFromFolderItem; private ActionBarMenuSubItem archiveItem; private ActionBarMenuSubItem clearItem; private ActionBarMenuSubItem readItem; private ActionBarMenuSubItem blockItem; private float additionalFloatingTranslation; private float floatingButtonTranslation; private float floatingButtonHideProgress; private AnimatorSet searchAnimator; private Animator tabsAlphaAnimator; private float searchAnimationProgress; private AnimatedArrowDrawable arrowDrawable; private RecyclerView sideMenu; private ChatActivityEnterView commentView; private ActionBarMenuItem switchItem; private FragmentContextView fragmentLocationContextView; private FragmentContextView fragmentContextView; private static ArrayList frozenDialogsList; private boolean dialogsListFrozen; private int dialogRemoveFinished; private int dialogInsertFinished; private int dialogChangeFinished; private AlertDialog permissionDialog; private boolean askAboutContacts = true; private boolean closeSearchFieldOnHide; private long searchDialogId; private TLObject searchObject; private int prevPosition; private int prevTop; private boolean scrollUpdated; private boolean floatingHidden; private final AccelerateDecelerateInterpolator floatingInterpolator = new AccelerateDecelerateInterpolator(); private boolean checkPermission = true; private int currentConnectionState; private boolean disableActionBarScrolling; private String selectAlertString; private String selectAlertStringGroup; private String addToGroupAlertString; private boolean resetDelegate = true; public static boolean[] dialogsLoaded = new boolean[UserConfig.MAX_ACCOUNT_COUNT]; private boolean searching; private boolean searchWas; private boolean onlySelect; private String searchString; private String initialSearchString; private long openedDialogId; private boolean cantSendToChannels; private boolean allowSwitchAccount; private boolean checkCanWrite; private boolean afterSignup; private DialogsActivityDelegate delegate; private ArrayList selectedDialogs = new ArrayList<>(); private int canReadCount; private int canPinCount; private int canMuteCount; private int canUnmuteCount; private int canClearCacheCount; private int canReportSpamCount; private int canUnarchiveCount; private boolean canDeletePsaSelected; private int topPadding; private int lastMeasuredTopPadding; 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; private final static int block = 106; private final static int archive2 = 107; private final static int pin2 = 108; private final static int add_to_folder = 109; private final static int remove_from_folder = 110; 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; private boolean scrollingManually; private boolean canShowHiddenArchive; 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; }; private int animationIndex = -1; private boolean searchIsShowed; private boolean searchWasFullyShowed; private boolean whiteActionBar; private float progressToActionMode; ValueAnimator actionBarColorAnimator; public final Property SCROLL_Y = new AnimationProperties.FloatProperty("animationValue") { @Override public void setValue(DialogsActivity object, float value) { object.setScrollY(value); } @Override public Float get(DialogsActivity object) { return actionBar.getTranslationY(); } }; private class ContentView extends SizeNotifierFrameLayout { private Paint actionBarSearchPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint windowBackgroundPaint = new Paint(); private int inputFieldHeight; public ContentView(Context context) { super(context); } 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; updateContextViewPosition(); if (whiteActionBar && searchViewPager != null) { searchViewPager.setTranslationY(topPadding - lastMeasuredTopPadding); } else { requestLayout(); } } 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; } public int getActionBarFullHeight() { float h = actionBar.getHeight(); float filtersTabsHeight = 0; if (filterTabsView != null && filterTabsView.getVisibility() != GONE) { filtersTabsHeight = filterTabsView.getMeasuredHeight(); } float searchTabsHeight = 0; if (searchTabsView != null && searchTabsView.getVisibility() != View.GONE) { searchTabsHeight = searchTabsView.getMeasuredHeight(); } h += filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress; return (int) h; } @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { boolean result; if (child == viewPages[0] || (viewPages.length > 1 && child == viewPages[1]) || child == fragmentContextView || child == fragmentLocationContextView) { 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); } if (child == actionBar && parentLayout != null) { 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); } } } return result; } @Override protected void dispatchDraw(Canvas canvas) { int actionBarHeight = getActionBarFullHeight(); int top; if (inPreviewMode) { top = AndroidUtilities.statusBarHeight; } else { top = inPreviewMode ? 0 : (int) (-getY() + actionBar.getY()); } 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); } } super.dispatchDraw(canvas); 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); } 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(); } } @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(); if (doneItem != null) { LayoutParams layoutParams = (LayoutParams) doneItem.getLayoutParams(); layoutParams.topMargin = actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0; layoutParams.height = ActionBar.getCurrentActionBarHeight(); } measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0); int keyboardSize = measureKeyboardHeight(); 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; } if (SharedConfig.smoothKeyboard && commentView.isPopupShowing()) { fragmentView.setTranslationY(0); for (int a = 0; a < viewPages.length; a++) { if (viewPages[a] != null) { viewPages[a].setTranslationY(0); } } if (!onlySelect) { actionBar.setTranslationY(0); } searchViewPager.setTranslationY(0); } } for (int i = 0; i < childCount; i++) { View child = getChildAt(i); if (child == null || child.getVisibility() == GONE || child == commentView || child == actionBar) { continue; } if (child 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 { h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect ? 0 : actionBar.getMeasuredHeight()) - topPadding; } child.measure(contentWidthSpec, View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h), View.MeasureSpec.EXACTLY)); child.setPivotX(child.getMeasuredWidth() / 2); } else if (child == searchViewPager) { searchViewPager.setTranslationY(0); int contentWidthSpec = View.MeasureSpec.makeMeasureSpec(widthSize, View.MeasureSpec.EXACTLY); int h = View.MeasureSpec.getSize(heightMeasureSpec) + keyboardSize; int contentHeightSpec = View.MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), h - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect ? 0 : actionBar.getMeasuredHeight()) - topPadding) - (searchTabsView == null ? 0 : AndroidUtilities.dp(44)), View.MeasureSpec.EXACTLY); child.measure(contentWidthSpec, contentHeightSpec); child.setPivotX(child.getMeasuredWidth() / 2); } 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; int keyboardSize = measureKeyboardHeight(); if (tag != null && tag.equals(2)) { paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow ? commentView.getEmojiPadding() : 0; } else { paddingBottom = 0; } setBottomClip(paddingBottom); lastMeasuredTopPadding = topPadding; 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(); } } else if (child == filterTabsView || child == searchTabsView || child == filtersView) { childTop = actionBar.getMeasuredHeight(); } else if (child == searchViewPager) { childTop = (onlySelect ? 0 : actionBar.getMeasuredHeight()) + topPadding + (searchTabsView == null ? 0 : AndroidUtilities.dp(44)); } else if (child instanceof ViewPage) { if (!onlySelect) { if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { childTop = AndroidUtilities.dp(44); } else { childTop = actionBar.getMeasuredHeight(); } } childTop += topPadding; } else if (child instanceof FragmentContextView) { childTop += actionBar.getMeasuredHeight(); } child.layout(childLeft, childTop, childLeft + width, childTop + height); } searchViewPager.setKeyboardHeight(keyboardSize); notifyHeightChanged(); updateContextViewPosition(); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { int action = ev.getActionMasked(); if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { if (actionBar.isActionModeShowed()) { allowMoving = true; } } 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) { if (filterTabsView != null && !filterTabsView.isEditing() && !searching && !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); } } 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); } 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); } if (parentLayout != null) { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed); } 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 { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed); maybeStartTracking = false; actionBar.setEnabled(true); filterTabsView.setEnabled(true); } if (velocityTracker != null) { velocityTracker.recycle(); velocityTracker = null; } } return startedTracking; } return false; } @Override public boolean hasOverlappingRendering() { return false; } } public static float viewOffset = 0.0f; public class DialogsRecyclerView extends RecyclerListView { private boolean firstLayout = true; private boolean ignoreLayout; private ViewPage parentPage; private int appliedPaddingTop; public DialogsRecyclerView(Context context, ViewPage page) { super(context); parentPage = page; } 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) { View v = getLayoutManager().findViewByPosition(selectorPosition); 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) { 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(); } } super.onDraw(canvas); } @Override protected void dispatchDraw(Canvas canvas) { 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() { RecyclerView.Adapter adapter = getAdapter(); if (parentPage.lastItemsCount != adapter.getItemCount()) { ignoreLayout = true; adapter.notifyDataSetChanged(); ignoreLayout = false; } } @Override protected void onMeasure(int widthSpec, int heightSpec) { int t = 0; if (!onlySelect) { ignoreLayout = true; if (filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { t = ActionBar.getCurrentActionBarHeight() + (actionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0); } else { t = inPreviewMode && Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0; } setTopGlowOffset(t); setPadding(0, t, 0, 0); if (appliedPaddingTop != t) { 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(); parentPage.layoutManager.scrollToPositionWithOffset(pos, top - appliedPaddingTop); } } } ignoreLayout = false; } if (firstLayout && getMessagesController().dialogsLoaded) { if (parentPage.dialogsType == 0 && hasHiddenArchive()) { ignoreLayout = true; LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); layoutManager.scrollToPositionWithOffset(1, (int) actionBar.getTranslationY()); ignoreLayout = false; } firstLayout = false; } checkIfAdapterValid(); super.onMeasure(widthSpec, heightSpec); if (!onlySelect) { if (appliedPaddingTop != t && viewPages != null && viewPages.length > 1) { viewPages[1].setTranslationX(viewPages[0].getMeasuredWidth()); } } } @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); appliedPaddingTop = getPaddingTop(); if ((dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) && !parentPage.dialogsItemAnimator.isRunning()) { 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) { disableActionBarScrolling = true; smoothScrollBy(0, (dialogCell.getMeasuredHeight() + (dialogCell.getTop() - getPaddingTop())), CubicBezierInterpolator.EASE_OUT); 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() { 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); } } @Override public boolean onTouchEvent(MotionEvent e) { if (fastScrollAnimationRunning || waitingForScrollFinished || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) { return false; } int action = e.getAction(); if (action == MotionEvent.ACTION_DOWN) { setOverScrollMode(View.OVER_SCROLL_ALWAYS); } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { if (!parentPage.itemTouchhelper.isIdle() && parentPage.swipeController.swipingFolder) { parentPage.swipeController.swipeFolderBack = true; if (parentPage.itemTouchhelper.checkHorizontalSwipe(null, ItemTouchHelper.LEFT) != 0) { toggleArchiveHidden(false, null); } } } boolean result = super.onTouchEvent(e); if (parentPage.dialogsType == 0 && (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) && parentPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN && hasHiddenArchive()) { LinearLayoutManager layoutManager = (LinearLayoutManager) getLayoutManager(); int currentPosition = layoutManager.findFirstVisibleItemPosition(); if (currentPosition == 0) { int pTop = getPaddingTop(); View view = layoutManager.findViewByPosition(currentPosition); int height = (int) (AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72) * PullForegroundDrawable.SNAP_HEIGHT); int diff = (view.getTop() - pTop) + view.getMeasuredHeight(); if (view != null) { long pullingTime = System.currentTimeMillis() - startArchivePullingTime; if (diff < height || pullingTime < PullForegroundDrawable.minPullingTime) { disableActionBarScrolling = true; smoothScrollBy(0, diff, CubicBezierInterpolator.EASE_OUT_QUINT); parentPage.archivePullViewState = ARCHIVE_ITEM_STATE_HIDDEN; } else { if (parentPage.archivePullViewState != ARCHIVE_ITEM_STATE_SHOWED) { if (getViewOffset() == 0) { disableActionBarScrolling = true; smoothScrollBy(0, (view.getTop() - pTop), CubicBezierInterpolator.EASE_OUT_QUINT); } if (!canShowHiddenArchive) { canShowHiddenArchive = true; performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); if (parentPage.pullForegroundDrawable != null) { parentPage.pullForegroundDrawable.colorize(true); } } ((DialogCell) view).startOutAnimation(); parentPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED; } } if (getViewOffset() != 0) { ValueAnimator valueAnimator = ValueAnimator.ofFloat(getViewOffset(), 0f); valueAnimator.addUpdateListener(animation -> setViewsOffset((float) animation.getAnimatedValue())); valueAnimator.setDuration(Math.max(100, (long) (350f - 120f * (getViewOffset() / PullForegroundDrawable.getMaxOverscroll())))); valueAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); setScrollEnabled(false); valueAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setScrollEnabled(true); } }); valueAnimator.start(); } } } } return result; } @Override public boolean onInterceptTouchEvent(MotionEvent e) { if (fastScrollAnimationRunning || waitingForScrollFinished || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0) { return false; } if (e.getAction() == MotionEvent.ACTION_DOWN) { allowSwipeDuringCurrentTouch = !actionBar.isActionModeShowed(); checkIfAdapterValid(); } return super.onInterceptTouchEvent(e); } } private class SwipeController extends ItemTouchHelper.Callback { private RectF buttonInstance; private RecyclerView.ViewHolder currentItemViewHolder; private boolean swipingFolder; private boolean swipeFolderBack; private ViewPage parentPage; public SwipeController(ViewPage page) { parentPage = page; } @Override public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { if (waitingForDialogsAnimationEnd(parentPage) || parentLayout != null && parentLayout.isInPreviewMode()) { return 0; } if (swipingFolder && swipeFolderBack) { swipingFolder = false; return 0; } if (!onlySelect && parentPage.isDefaultDialogType() && slidingView == null && viewHolder.itemView instanceof DialogCell) { DialogCell dialogCell = (DialogCell) viewHolder.itemView; long dialogId = dialogCell.getDialogId(); if (actionBar.isActionModeShowed()) { TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(dialogId); if (!allowMoving || dialog == null || !isDialogPinned(dialog) || DialogObject.isFolderDialogId(dialogId)) { return 0; } movingView = (DialogCell) viewHolder.itemView; movingView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); return makeMovementFlags(ItemTouchHelper.UP | ItemTouchHelper.DOWN, 0); } else { if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE || !allowSwipeDuringCurrentTouch || dialogId == getUserConfig().clientUserId || dialogId == 777000 || getMessagesController().isPromoDialog(dialogId, false) && getMessagesController().promoDialogType != MessagesController.PROMO_TYPE_PSA) { 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); if (dialog == null || !isDialogPinned(dialog) || DialogObject.isFolderDialogId(dialogId)) { return false; } int fromIndex = source.getAdapterPosition(); int toIndex = target.getAdapterPosition(); parentPage.dialogsAdapter.notifyItemMoved(fromIndex, toIndex); updateDialogIndices(); 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; } 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)) { parentPage.listView.toggleArchiveHidden(false, dialogCell); return; } slidingView = dialogCell; int position = viewHolder.getAdapterPosition(); int dialogIndex = parentPage.dialogsAdapter.fixPosition(position); int count = parentPage.dialogsAdapter.getItemCount(); Runnable finishRunnable = () -> { if (frozenDialogsList == null) { return; } TLRPC.Dialog dialog = frozenDialogsList.remove(dialogIndex); int pinnedNum = dialog.pinnedNum; slidingView = null; parentPage.listView.invalidate(); int lastItemPosition = parentPage.layoutManager.findLastVisibleItemPosition(); if (lastItemPosition == count - 1) { parentPage.layoutManager.findViewByPosition(lastItemPosition).requestLayout(); } if (getMessagesController().isPromoDialog(dialog.id, false)) { getMessagesController().hidePromoDialog(); parentPage.dialogsItemAnimator.prepareForRemove(); parentPage.lastItemsCount--; parentPage.dialogsAdapter.notifyItemRemoved(position); dialogRemoveFinished = 2; } 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; } if (folderId == 0) { if (added == 2) { parentPage.dialogsItemAnimator.prepareForRemove(); if (position == 0) { dialogChangeFinished = 2; setDialogsListFrozen(true); parentPage.dialogsAdapter.notifyItemChanged(0); } else { parentPage.lastItemsCount++; parentPage.dialogsAdapter.notifyItemInserted(0); if (!SharedConfig.archiveHidden && parentPage.layoutManager.findFirstVisibleItemPosition() == 0) { disableActionBarScrolling = true; parentPage.listView.smoothScrollBy(0, -AndroidUtilities.dp(SharedConfig.useThreeLinesLayout ? 78 : 72)); } } ArrayList 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) { preferences.edit().putBoolean("archivehint_l", true).commit(); } 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 dialogs = getMessagesController().getDialogs(0); int index = dialogs.indexOf(dialog); if (index >= 0) { ArrayList archivedDialogs = getMessagesController().getDialogs(1); if (!archivedDialogs.isEmpty() || index != 1) { dialogInsertFinished = 2; setDialogsListFrozen(true); 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); } } } else { parentPage.dialogsAdapter.notifyDataSetChanged(); } }); } if (folderId != 0 && frozenDialogsList.isEmpty()) { parentPage.listView.setEmptyView(null); parentPage.progressView.setVisibility(View.INVISIBLE); } } }; setDialogsListFrozen(true); if (Utilities.random.nextInt(1000) == 1) { if (pacmanAnimation == null) { pacmanAnimation = new PacmanAnimation(parentPage.listView); } pacmanAnimation.setFinishRunnable(finishRunnable); pacmanAnimation.start(); } else { finishRunnable.run(); } } else { slidingView = null; } } @Override public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) { if (viewHolder != null) { parentPage.listView.hideSelector(false); } 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; AndroidUtilities.runOnUIThread(() -> view.setBackgroundDrawable(null), parentPage.dialogsItemAnimator.getMoveDuration()); movingView = null; } } return super.getAnimationDuration(recyclerView, animationType, animateDx, animateDy); } @Override public float getSwipeThreshold(RecyclerView.ViewHolder viewHolder) { return 0.3f; } @Override public float getSwipeEscapeVelocity(float defaultValue) { return 3500; } @Override public float getSwipeVelocityThreshold(float defaultValue) { return Float.MAX_VALUE; } } public interface DialogsActivityDelegate { void didSelectDialogs(DialogsActivity fragment, ArrayList dids, CharSequence message, boolean param); } public DialogsActivity(Bundle args) { super(args); } @Override public boolean onFragmentCreate() { super.onFragmentCreate(); if (getArguments() != null) { onlySelect = arguments.getBoolean("onlySelect", false); cantSendToChannels = arguments.getBoolean("cantSendToChannels", false); initialDialogsType = arguments.getInt("dialogsType", 0); selectAlertString = arguments.getString("selectAlertString"); selectAlertStringGroup = arguments.getString("selectAlertStringGroup"); addToGroupAlertString = arguments.getString("addToGroupAlertString"); allowSwitchAccount = arguments.getBoolean("allowSwitchAccount"); checkCanWrite = arguments.getBoolean("checkCanWrite", true); afterSignup = arguments.getBoolean("afterSignup", false); folderId = arguments.getInt("folderId", 0); resetDelegate = arguments.getBoolean("resetDelegate", true); messagesCount = arguments.getInt("messagesCount", 0); hasPoll = arguments.getInt("hasPoll", 0); } if (initialDialogsType == 0) { askAboutContacts = MessagesController.getGlobalNotificationsSettings().getBoolean("askAboutContacts", true); SharedConfig.loadProxyList(); } if (searchString == null) { currentConnectionState = getConnectionsManager().getConnectionState(); getNotificationCenter().addObserver(this, NotificationCenter.dialogsNeedReload); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad); if (!onlySelect) { NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.closeSearchByActiveAction); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged); getNotificationCenter().addObserver(this, NotificationCenter.filterSettingsUpdated); getNotificationCenter().addObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().addObserver(this, NotificationCenter.dialogsUnreadCounterChanged); } 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); getNotificationCenter().addObserver(this, NotificationCenter.newSuggestionsAvailable); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetPasscode); } getNotificationCenter().addObserver(this, NotificationCenter.messagesDeleted); if (!dialogsLoaded[currentAccount]) { MessagesController messagesController = getMessagesController(); messagesController.loadGlobalNotificationsSettings(); messagesController.loadDialogs(folderId, 0, 100, true); messagesController.loadHintDialogs(); messagesController.loadUserInfo(UserConfig.getInstance(currentAccount).getCurrentUser(), false, classGuid); getContactsController().checkInviteText(); getMediaDataController().loadRecents(MediaDataController.TYPE_FAVE, false, true, false); getMediaDataController().checkFeaturedStickers(); for (String emoji : messagesController.diceEmojies) { getMediaDataController().loadStickersByEmojiOrName(emoji, true, true); } dialogsLoaded[currentAccount] = true; } getMessagesController().loadPinnedDialogs(folderId, 0, null); return true; } @Override public void onFragmentDestroy() { super.onFragmentDestroy(); if (searchString == null) { getNotificationCenter().removeObserver(this, NotificationCenter.dialogsNeedReload); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad); if (!onlySelect) { NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.closeSearchByActiveAction); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.proxySettingsChanged); getNotificationCenter().removeObserver(this, NotificationCenter.filterSettingsUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.dialogFiltersUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.dialogsUnreadCounterChanged); } 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); getNotificationCenter().removeObserver(this, NotificationCenter.newSuggestionsAvailable); getNotificationCenter().removeObserver(this, NotificationCenter.messagesDeleted); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetPasscode); } if (commentView != null) { commentView.onDestroy(); } if (undoView[0] != null) { undoView[0].hide(true, 0); } delegate = null; } @Override protected ActionBar createActionBar(Context context) { ActionBar actionBar = new ActionBar(context) { @Override protected boolean shouldClipChild(View child) { return super.shouldClipChild(child) || child == doneItem; } @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { if (inPreviewMode && avatarContainer != null && child != avatarContainer) { return false; } return super.drawChild(canvas, child, drawingTime); } }; 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); if (inPreviewMode || AndroidUtilities.isTablet() && folderId != 0) { actionBar.setOccupyStatusBar(false); } return actionBar; } @Override public View createView(final Context context) { searching = false; searchWas = false; pacmanAnimation = null; selectedDialogs.clear(); maximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity(); AndroidUtilities.runOnUIThread(() -> Theme.createChatResources(context, false)); ActionBarMenu menu = actionBar.createMenu(); if (!onlySelect && searchString == null && folderId == 0) { 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); proxyDrawable = new ProxyDrawable(context); proxyItem = menu.addItem(2, proxyDrawable); proxyItem.setContentDescription(LocaleController.getString("ProxySettings", R.string.ProxySettings)); passcodeItem = menu.addItem(1, R.drawable.lock_close); updatePasscodeButton(); updateProxyButton(false); } searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { @Override public void onSearchExpand() { searching = true; if (switchItem != null) { switchItem.setVisibility(View.GONE); } if (proxyItem != null && proxyItemVisible) { proxyItem.setVisibility(View.GONE); } if (viewPages[0] != null) { if (searchString != null) { viewPages[0].listView.hide(); if (searchViewPager != null) { searchViewPager.searchListView.show(); } } if (!onlySelect) { floatingButtonContainer.setVisibility(View.GONE); } } setScrollY(0); updatePasscodeButton(); actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack)); } @Override public boolean canCollapseSearch() { if (switchItem != null) { switchItem.setVisibility(View.VISIBLE); } if (proxyItem != null && proxyItemVisible) { proxyItem.setVisibility(View.VISIBLE); } if (searchString != null) { finishFragment(); return false; } return true; } @Override public void onSearchCollapse() { searching = false; searchWas = false; if (viewPages[0] != null) { viewPages[0].listView.setEmptyView(folderId == 0 ? viewPages[0].progressView : null); if (!onlySelect) { floatingButtonContainer.setVisibility(View.VISIBLE); floatingHidden = true; floatingButtonTranslation = AndroidUtilities.dp(100); floatingButtonHideProgress = 1f; updateFloatingButtonOffset(); } showSearch(false, true); } updatePasscodeButton(); if (menuDrawable != null) { if (actionBar.getBackButton().getDrawable() != menuDrawable) { actionBar.setBackButtonDrawable(menuDrawable); menuDrawable.setRotation(0, true); } actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu)); } } @Override public void onTextChanged(EditText editText) { String text = editText.getText().toString(); if (text.length() != 0 || searchViewPager.dialogsSearchAdapter != null && searchViewPager.dialogsSearchAdapter.hasRecentRearch()) { searchWas = true; if (viewPages[0].listView.getVisibility() == View.VISIBLE) { showSearch(true, true); } } searchViewPager.onTextChanged(text); } @Override public void onSearchFilterCleared(FiltersView.MediaFilterData filterData) { if (!searchIsShowed) { return; } searchViewPager.removeSearchFilter(filterData); searchViewPager.onTextChanged(searchItem.getSearchField().getText().toString()); updateFiltersView(true, null, null,true); } @Override public boolean canToggleSearch() { return !actionBar.isActionModeShowed(); } }); searchItem.setClearsTextOnSearchCollapse(false); searchItem.setSearchFieldHint(LocaleController.getString("Search", R.string.Search)); searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search)); if (onlySelect) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); if (initialDialogsType == 3 && selectAlertString == null) { actionBar.setTitle(LocaleController.getString("ForwardTo", R.string.ForwardTo)); } else { actionBar.setTitle(LocaleController.getString("SelectChat", R.string.SelectChat)); } actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault)); } else { if (searchString != null || folderId != 0) { actionBar.setBackButtonDrawable(backDrawable = new BackDrawable(false)); } else { actionBar.setBackButtonDrawable(menuDrawable = new MenuDrawable()); actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu)); } if (folderId != 0) { actionBar.setTitle(LocaleController.getString("ArchivedChats", R.string.ArchivedChats)); } else { if (BuildVars.DEBUG_VERSION) { actionBar.setTitle("Telegram Beta"); } else { actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName)); } } if (folderId == 0) { actionBar.setSupportsHolidayImage(true); } } if (!onlySelect) { actionBar.setAddToContainer(false); actionBar.setCastShadows(false); actionBar.setClipContent(true); } actionBar.setTitleActionRunnable(() -> { hideFloatingButton(false); scrollToTop(); }); if (initialDialogsType == 0 && folderId == 0 && !onlySelect && TextUtils.isEmpty(searchString)) { scrimPaint = new Paint() { @Override public void setAlpha(int a) { super.setAlpha(a); if (fragmentView != null) { fragmentView.invalidate(); } } }; filterTabsView = new FilterTabsView(context) { @Override public boolean onInterceptTouchEvent(MotionEvent ev) { getParent().requestDisallowInterceptTouchEvent(true); maybeStartTracking = false; return super.onInterceptTouchEvent(ev); } @Override public void setTranslationY(float translationY) { super.setTranslationY(translationY); updateContextViewPosition(); if (fragmentView != null) { fragmentView.invalidate(); } } @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(); } } }; filterTabsView.setVisibility(View.GONE); filterTabsView.setTag(null); filterTabsView.setDelegate(new FilterTabsView.FilterTabsViewDelegate() { 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(() -> { })); if (getMessagesController().dialogFilters.size() > 1) { filterTabsView.beginCrossfade(); } getMessagesController().removeFilter(dialogFilter); getMessagesStorage().deleteDialogFilter(dialogFilter); filterTabsView.commitCrossfade(); }); AlertDialog alertDialog = builder.create(); showDialog(alertDialog); TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); if (button != null) { button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2)); } } @Override public void onSamePageSelected() { scrollToTop(); } @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; } } } @Override public void onPageSelected(int id, boolean forward) { if (viewPages[0].selectedType == id) { return; } ArrayList dialogFilters = getMessagesController().dialogFilters; if (id != Integer.MAX_VALUE && (id < 0 || id >= dialogFilters.size())) { return; } 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; } @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]); } } @Override public int getTabCounter(int tabId) { if (tabId == Integer.MAX_VALUE) { return getMessagesStorage().getMainUnreadCount(); } ArrayList dialogFilters = getMessagesController().dialogFilters; if (tabId < 0 || tabId >= dialogFilters.size()) { return 0; } return getMessagesController().dialogFilters.get(tabId).unreadCount; } @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); scrimPopupWindowItems = new ActionBarMenuSubItem[3]; for (int a = 0, N = (tabView.getId() == Integer.MAX_VALUE ? 2 : 3); a < N; a++) { ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity()); if (a == 0) { if (getMessagesController().dialogFilters.size() <= 1) { continue; } cell.setTextAndIcon(LocaleController.getString("FilterReorder", R.string.FilterReorder), R.drawable.tabs_reorder); } else if (a == 1) { if (N == 2) { cell.setTextAndIcon(LocaleController.getString("FilterEditAll", R.string.FilterEditAll), R.drawable.msg_edit); } else { cell.setTextAndIcon(LocaleController.getString("FilterEdit", R.string.FilterEdit), R.drawable.msg_edit); } } else { cell.setTextAndIcon(LocaleController.getString("FilterDeleteItem", R.string.FilterDeleteItem), R.drawable.msg_delete); } 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) { if (N == 2) { presentFragment(new FiltersSetupActivity()); } else { presentFragment(new FilterCreateActivity(dialogFilter)); } } else if (i == 2) { showDeleteAlert(dialogFilter); } if (scrimPopupWindow != null) { scrimPopupWindow.dismiss(); } }); } 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 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); scrimPopupWindow.showAtLocation(fragmentView, Gravity.LEFT | Gravity.TOP, popupX, popupY); scrimView = tabView; scrimViewSelected = selected; fragmentView.invalidate(); if (scrimAnimatorSet != null) { scrimAnimatorSet.cancel(); } scrimAnimatorSet = new AnimatorSet(); ArrayList 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)); } } } actionBar.setAllowOverlayTitle(true); if (sideMenu != null) { sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground)); sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground)); sideMenu.getAdapter().notifyDataSetChanged(); } createActionMode(); ContentView contentView = new ContentView(context); fragmentView = contentView; int pagesCount = folderId == 0 && initialDialogsType == 0 && !onlySelect ? 2 : 1; 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); } } } }; contentView.addView(viewPage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); viewPage.dialogsType = initialDialogsType; viewPages[a] = viewPage; viewPage.listView = new DialogsRecyclerView(context, viewPage); viewPage.listView.setClipToPadding(false); viewPage.listView.setPivotY(0); viewPage.dialogsItemAnimator = new DialogsItemAnimator() { @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(); } if (viewPage.archivePullViewState == ARCHIVE_ITEM_STATE_HIDDEN) { viewPage.archivePullViewState = ARCHIVE_ITEM_STATE_SHOWED; } if (viewPage.pullForegroundDrawable != null) { viewPage.pullForegroundDrawable.doNotShow(); } } } @Override public void onRemoveFinished(RecyclerView.ViewHolder item) { if (dialogRemoveFinished == 2) { dialogRemoveFinished = 1; } } @Override public void onAddFinished(RecyclerView.ViewHolder item) { if (dialogInsertFinished == 2) { dialogInsertFinished = 1; } } @Override public void onChangeFinished(RecyclerView.ViewHolder item, boolean oldItem) { if (dialogChangeFinished == 2) { dialogChangeFinished = 1; } } @Override protected void onAllAnimationsDone() { if (dialogRemoveFinished == 1 || dialogInsertFinished == 1 || dialogChangeFinished == 1) { onDialogAnimationFinished(); } } }; viewPage.listView.setItemAnimator(viewPage.dialogsItemAnimator); 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(); } 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) { if (viewPage.listView.fastScrollAnimationRunning) { return 0; } 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; } } if (!isDragging) { View view = viewPage.layoutManager.findViewByPosition(currentPosition); 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; } } } 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); } } } 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; } 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(); } } 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) { viewPage.listView.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); 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); } } if (firstView != null) { firstView.invalidate(); } 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)); viewPage.listView.setOnItemClickListener((view, position) -> onItemClick(view, position, viewPage.dialogsAdapter)); 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); 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; } else { 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); } } } } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { viewPage.dialogsItemAnimator.onListScroll(-dy); checkListLoad(viewPage); if (wasManualScroll && floatingButtonContainer.getVisibility() != View.GONE && recyclerView.getChildCount() > 0) { 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; } if (changed && scrollUpdated && (goingDown || !goingDown && scrollingManually)) { hideFloatingButton(goingDown); } prevPosition = firstVisibleItem; prevTop = firstViewTop; scrollUpdated = true; } } } if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && recyclerView == viewPages[0].listView && !searching && !actionBar.isActionModeShowed() && !disableActionBarScrolling) { 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); } } } }); viewPage.progressView = new RadialProgressView(context); viewPage.progressView.setPivotY(0); viewPage.progressView.setVisibility(View.GONE); viewPage.addView(viewPage.progressView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER)); 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); } viewPage.dialogsAdapter = new DialogsAdapter(context, viewPage.dialogsType, folderId, onlySelect, selectedDialogs, currentAccount) { @Override public void notifyDataSetChanged() { viewPage.lastItemsCount = getItemCount(); try { super.notifyDataSetChanged(); } catch (Exception e) { FileLog.e(e); } } }; if (AndroidUtilities.isTablet() && openedDialogId != 0) { viewPage.dialogsAdapter.setOpenedDialogId(openedDialogId); } viewPage.dialogsAdapter.setArchivedPullDrawable(viewPage.pullForegroundDrawable); viewPage.listView.setAdapter(viewPage.dialogsAdapter); viewPage.listView.setEmptyView(folderId == 0 ? viewPage.progressView : null); viewPage.scrollHelper = new RecyclerAnimationScrollHelper(viewPage.listView, viewPage.layoutManager); if (a != 0) { viewPages[a].setVisibility(View.GONE); } } int type = 0; if (searchString != null) { type = 2; } else if (!onlySelect) { type = 1; } searchViewPager = new SearchViewPager(context, this, type, initialDialogsType, folderId, new SearchViewPager.ChatPreviewDelegate() { @Override public void startChatPreview(DialogCell cell) { showChatPreview(cell); } @Override public void move(float dy) { movePreviewFragment(dy); } @Override public void finish() { finishPreviewFragment(); } }); contentView.addView(searchViewPager); searchViewPager.dialogsSearchAdapter.setDelegate(new DialogsSearchAdapter.DialogsSearchAdapterDelegate() { @Override public void searchStateChanged(boolean search) { if (searching && searchWas && searchViewPager.emptyView != null) { if (search || searchViewPager.dialogsSearchAdapter.getItemCount() != 0) { searchViewPager.emptyView.showProgress(true); } else { searchViewPager.emptyView.showProgress(false); } } } @Override public void didPressedOnSubDialog(long did) { if (onlySelect) { if (!validateSlowModeDialog(did)) { return; } if (!selectedDialogs.isEmpty()) { boolean checked = addOrRemoveSelectedDialog(did, null); findAndUpdateCheckBox(did, checked); updateSelectedCount(); actionBar.closeSearchField(); } else { didSelectResult(did, true, false); } } else { 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); } closeSearch(); if (AndroidUtilities.isTablet() && viewPages != null) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId = did); } updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } if (searchString != null) { if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) { getNotificationCenter().postNotificationName(NotificationCenter.closeChats); presentFragment(new ChatActivity(args)); } } else { if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) { presentFragment(new ChatActivity(args)); } } } } @Override public void needRemoveHint(final int did) { if (getParentActivity() == null) { return; } TLRPC.User user = getMessagesController().getUser(did); if (user == null) { return; } 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)); } } @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) -> { if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) { searchViewPager.dialogsSearchAdapter.clearRecentSearch(); } else { searchViewPager.dialogsSearchAdapter.clearRecentHashtags(); } }); 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)); } } }); searchViewPager.searchListView.setOnItemClickListener((view, position) -> onItemClick(view, position, searchViewPager.dialogsSearchAdapter)); searchViewPager.searchListView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListenerExtended() { @Override public boolean onItemClick(View view, int position, float x, float y) { return onItemLongClick(view, position, x, y, -1, searchViewPager.dialogsSearchAdapter); } @Override public void onLongClickRelease() { finishPreviewFragment(); } @Override public void onMove(float dx, float dy) { movePreviewFragment(dy); } }); 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); floatingButtonContainer = new FrameLayout(context); floatingButtonContainer.setVisibility(onlySelect || folderId != 0 ? View.GONE : View.VISIBLE); contentView.addView(floatingButtonContainer, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 20, (Build.VERSION.SDK_INT >= 21 ? 56 : 60) + 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 4 : 0, 0, LocaleController.isRTL ? 0 : 4, 0)); floatingButtonContainer.setOnClickListener(v -> { Bundle args = new Bundle(); args.putBoolean("destroyAfterSelect", true); presentFragment(new ContactsActivity(args)); }); floatingButton = new ImageView(context); floatingButton.setScaleType(ImageView.ScaleType.CENTER); Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground)); if (Build.VERSION.SDK_INT < 21) { Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate(); shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY)); CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0); combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56)); drawable = combinedDrawable; } floatingButton.setBackgroundDrawable(drawable); floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY)); floatingButton.setImageResource(R.drawable.floating_pencil); if (Build.VERSION.SDK_INT >= 21) { StateListAnimator animator = new StateListAnimator(); 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)); 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)); } }); } floatingButtonContainer.setContentDescription(LocaleController.getString("NewMessageTitle", R.string.NewMessageTitle)); floatingButtonContainer.addView(floatingButton, LayoutHelper.createFrame((Build.VERSION.SDK_INT >= 21 ? 56 : 60), (Build.VERSION.SDK_INT >= 21 ? 56 : 60), Gravity.LEFT | Gravity.TOP, 10, 0, 10, 0)); searchTabsView = null; 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); } if (!onlySelect && initialDialogsType == 0) { fragmentLocationContextView = new FragmentContextView(context, this, true); fragmentLocationContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); contentView.addView(fragmentLocationContextView); fragmentContextView = new FragmentContextView(context, this, false); fragmentContextView.setLayoutParams(LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 39, Gravity.TOP | Gravity.LEFT, 0, -36, 0, 0)); contentView.addView(fragmentContextView); fragmentContextView.setAdditionalContextView(fragmentLocationContextView); fragmentLocationContextView.setAdditionalContextView(fragmentContextView); } else if (initialDialogsType == 3) { if (commentView != null) { commentView.onDestroy(); } commentView = new ChatActivityEnterView(getParentActivity(), contentView, null, false); commentView.setAllowStickersAndGifs(false, false); commentView.setForceShowSendButton(true, false); commentView.setVisibility(View.GONE); contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { @Override public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) { if (delegate == null) { return; } if (selectedDialogs.isEmpty()) { return; } delegate.didSelectDialogs(DialogsActivity.this, selectedDialogs, message, false); } @Override public void onSwitchRecordMode(boolean video) { } @Override public void onTextSelectionChanged(int start, int end) { } @Override public void onStickersExpandedChange() { } @Override public void onPreAudioVideoRecord() { } @Override public void onTextChanged(final CharSequence text, boolean bigChange) { } @Override public void onTextSpansChanged(CharSequence text) { } @Override public void needSendTyping() { } @Override public void onAttachButtonHidden() { } @Override public void onAttachButtonShow() { } @Override public void onMessageEditEnd(boolean loading) { } @Override public void onWindowSizeChanged(int size) { } @Override public void onStickersTab(boolean opened) { } @Override public void didPressAttachButton() { } @Override public void needStartRecordVideo(int state, boolean notify, int scheduleDate) { } @Override public void needChangeVideoPreviewState(int state, float seekProgress) { } @Override public void needStartRecordAudio(int state) { } @Override public void needShowMediaBanHint() { } @Override public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) { } @Override public void onSendLongClick() { } @Override public void onAudioVideoInterfaceUpdated() { } }); } if (filterTabsView != null) { contentView.addView(filterTabsView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 44)); } if (!onlySelect) { 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); } 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) { additionalFloatingTranslation = getMeasuredHeight() + AndroidUtilities.dp(8) - translationY; if (additionalFloatingTranslation < 0) { additionalFloatingTranslation = 0; } if (!floatingHidden) { updateFloatingButtonOffset(); } } } @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) { blurredView = new View(context); 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) { final TLRPC.User currentUser = UserConfig.getInstance(currentAccount).getCurrentUser(); 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); } } updateFilterTabs(false); 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) { fragmentContextView.setTranslationY(topPadding + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress); } if (fragmentLocationContextView != null) { fragmentLocationContextView.setTranslationY(topPadding + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress); } } private void updateFiltersView(boolean showMediaFilters, ArrayList users, ArrayList dates, boolean animated) { if (!searchIsShowed || onlySelect) { return; } boolean hasMediaFilter = false; boolean hasUserFilter = false; boolean hasDataFilter = false; ArrayList 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 finalUsers = (users != null && !users.isEmpty() && !hasUserFilter) ? users : null; ArrayList 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 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); pinItem = actionMode.addItemWithWidth(pin, R.drawable.msg_pin, AndroidUtilities.dp(54)); muteItem = actionMode.addItemWithWidth(mute, R.drawable.msg_mute, AndroidUtilities.dp(54)); archive2Item = actionMode.addItemWithWidth(archive2, R.drawable.msg_archive, AndroidUtilities.dp(54)); deleteItem = actionMode.addItemWithWidth(delete, R.drawable.msg_delete, AndroidUtilities.dp(54), LocaleController.getString("Delete", R.string.Delete)); ActionBarMenuItem otherItem = actionMode.addItemWithWidth(0, R.drawable.ic_ab_other, AndroidUtilities.dp(54), LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions)); archiveItem = otherItem.addSubItem(archive, R.drawable.msg_archive, LocaleController.getString("Archive", R.string.Archive)); pin2Item = otherItem.addSubItem(pin2, R.drawable.msg_pin, LocaleController.getString("DialogPin", R.string.DialogPin)); addToFolderItem = otherItem.addSubItem(add_to_folder, R.drawable.msg_addfolder, LocaleController.getString("FilterAddTo", R.string.FilterAddTo)); removeFromFolderItem = otherItem.addSubItem(remove_from_folder, R.drawable.msg_removefolder, LocaleController.getString("FilterRemoveFrom", R.string.FilterRemoveFrom)); readItem = otherItem.addSubItem(read, R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead)); clearItem = otherItem.addSubItem(clear, R.drawable.msg_clear, LocaleController.getString("ClearHistory", R.string.ClearHistory)); blockItem = otherItem.addSubItem(block, R.drawable.msg_block, LocaleController.getString("BlockUser", R.string.BlockUser)); 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(); updatePasscodeButton(); } else if (id == 2) { presentFragment(new ProxyListActivity()); } else if (id >= 10 && id < 10 + UserConfig.MAX_ACCOUNT_COUNT) { if (getParentActivity() == null) { return; } DialogsActivityDelegate oldDelegate = delegate; LaunchActivity launchActivity = (LaunchActivity) getParentActivity(); launchActivity.switchToAccount(id - 10, true); DialogsActivity dialogsActivity = new DialogsActivity(arguments); dialogsActivity.setDelegate(oldDelegate); launchActivity.presentFragment(dialogsActivity, false, true); } else if (id == add_to_folder) { FiltersListBottomSheet sheet = new FiltersListBottomSheet(DialogsActivity.this, selectedDialogs); sheet.setDelegate(filter -> { ArrayList alwaysShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, true, false); int currentCount; if (filter != null) { currentCount = filter.alwaysShow.size(); } else { currentCount = 0; } if (currentCount + alwaysShow.size() > 100) { showDialog(AlertsCreator.createSimpleAlert(getParentActivity(), LocaleController.getString("FilterAddToAlertFullTitle", R.string.FilterAddToAlertFullTitle), LocaleController.getString("FilterAddToAlertFullText", R.string.FilterAddToAlertFullText)).create()); return; } 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 neverShow = FiltersListBottomSheet.getDialogsCount(DialogsActivity.this, filter, selectedDialogs, false, false); 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); } FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, false, false, DialogsActivity.this, null); } 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); } } }); } 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) { viewPages[a].dialogsType = 0; 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; 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); } private void updateFilterTabs(boolean force) { if (filterTabsView == null || inPreviewMode) { return; } if (scrimPopupWindow != null) { scrimPopupWindow.dismiss(); scrimPopupWindow = null; } ArrayList filters = getMessagesController().dialogFilters; SharedPreferences preferences = MessagesController.getMainSettings(currentAccount); if (!filters.isEmpty()) { if (force || filterTabsView.getVisibility() != View.VISIBLE) { filterTabsView.setVisibility(View.VISIBLE); filterTabsView.setTag(1); int id = filterTabsView.getCurrentTabId(); if (id != Integer.MAX_VALUE && id >= filters.size()) { filterTabsView.resetTabId(); } filterTabsView.removeTabs(); filterTabsView.addTab(Integer.MAX_VALUE, LocaleController.getString("FilterAllChats", R.string.FilterAllChats)); for (int a = 0, N = filters.size(); a < N; a++) { filterTabsView.addTab(a, filters.get(a).name); } id = filterTabsView.getCurrentTabId(); if (id >= 0) { viewPages[0].selectedType = id; } for (int a = 0; a < viewPages.length; a++) { if (viewPages[a].selectedType != Integer.MAX_VALUE && viewPages[a].selectedType >= filters.size()) { viewPages[a].selectedType = filters.size() - 1; } viewPages[a].listView.setScrollingTouchSlop(RecyclerView.TOUCH_SLOP_PAGING); } filterTabsView.finishAddingTabs(); switchToCurrentSelectedMode(false); if (parentLayout != null) { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(id == filterTabsView.getFirstTabId()); } } } else { if (filterTabsView.getVisibility() != View.GONE) { filterTabsView.setIsEditing(false); showDoneItem(false); 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; viewPages[0].dialogsAdapter.setDialogsType(0); viewPages[0].dialogsType = 0; viewPages[0].dialogsAdapter.notifyDataSetChanged(); } viewPages[1].setVisibility(View.GONE); viewPages[1].selectedType = Integer.MAX_VALUE; viewPages[1].dialogsAdapter.setDialogsType(0); viewPages[1].dialogsType = 0; viewPages[1].dialogsAdapter.notifyDataSetChanged(); filterTabsView.setVisibility(View.GONE); filterTabsView.setTag(null); 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) { viewPages[a].layoutManager.scrollToPositionWithOffset(p, 0); } } viewPages[a].listView.setScrollingTouchSlop(RecyclerView.TOUCH_SLOP_DEFAULT); viewPages[a].listView.requestLayout(); viewPages[a].requestLayout(); } } if (parentLayout != null) { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(true); } } updateCounters(false); } @Override protected void onPanTranslationUpdate(float y) { if (viewPages == null) { return; } if (commentView != null && commentView.isPopupShowing()) { fragmentView.setTranslationY(y); for (int a = 0; a < viewPages.length; a++) { viewPages[a].setTranslationY(0); } if (!onlySelect) { actionBar.setTranslationY(0); } searchViewPager.setTranslationY(0); } else { for (int a = 0; a < viewPages.length; a++) { viewPages[a].setTranslationY(y); } if (!onlySelect) { actionBar.setTranslationY(y); } searchViewPager.setTranslationY(y); } } @Override public void finishFragment() { super.finishFragment(); if (scrimPopupWindow != null) { scrimPopupWindow.dismiss(); } } @Override public void onResume() { super.onResume(); if (!parentLayout.isInPreviewMode() && blurredView != null && blurredView.getVisibility() == View.VISIBLE) { blurredView.setVisibility(View.GONE); blurredView.setBackground(null); } if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId() || searchIsShowed); } if (viewPages != null && !dialogsListFrozen) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].dialogsAdapter.notifyDataSetChanged(); } } if (commentView != null) { commentView.onResume(); } if (!onlySelect && folderId == 0) { getMediaDataController().checkStickers(MediaDataController.TYPE_EMOJI); } if (searchViewPager != null) { searchViewPager.onResume(); } final boolean tosAccepted; if (!afterSignup) { tosAccepted = UserConfig.getInstance(UserConfig.selectedAccount).unacceptedTermsOfService == null; } else { tosAccepted = false; afterSignup = false; } if (tosAccepted && checkPermission && !onlySelect && Build.VERSION.SDK_INT >= 23) { Activity activity = getParentActivity(); if (activity != null) { checkPermission = false; 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) { askingForPermissions = true; if (hasNotContactsPermission && askAboutContacts && getUserConfig().syncContacts && activity.shouldShowRequestPermissionRationale(Manifest.permission.READ_CONTACTS)) { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { askAboutContacts = param != 0; MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit(); askForPermissons(false); }); showDialog(permissionDialog = builder.create()); } else if (hasNotStoragePermission && activity.shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.getString("PermissionStorage", R.string.PermissionStorage)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); showDialog(permissionDialog = builder.create()); } else { askForPermissons(true); } } } } 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()); } 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); } } } showNextSupportedSuggestion(); Bulletin.addDelegate(this, new Bulletin.Delegate() { @Override public void onOffsetChange(float offset) { additionalFloatingTranslation = offset; if (additionalFloatingTranslation < 0) { additionalFloatingTranslation = 0; } if (!floatingHidden) { updateFloatingButtonOffset(); } } }); if (searchIsShowed) { AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid); } } @Override public void onPause() { super.onPause(); if (scrimPopupWindow != null) { scrimPopupWindow.dismiss(); } if (commentView != null) { commentView.onResume(); } if (undoView[0] != null) { undoView[0].hide(true, 0); } Bulletin.removeDelegate(this); } @Override public boolean onBackPressed() { 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()) { if (searchViewPager.getVisibility() == View.VISIBLE) { searchViewPager.hideActionMode(); } else { hideActionMode(true); } return false; } else if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && !tabsAnimationInProgress && !filterTabsView.isAnimatingIndicator() && filterTabsView.getCurrentTabId() != Integer.MAX_VALUE && !startedTracking) { filterTabsView.selectFirstTab(); return false; } else if (commentView != null && commentView.isPopupShowing()) { commentView.hidePopup(true); return false; } return super.onBackPressed(); } @Override protected void onBecomeFullyHidden() { if (closeSearchFieldOnHide) { if (actionBar != null) { actionBar.closeSearchField(); } if (searchObject != null) { searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject); searchObject = null; } closeSearchFieldOnHide = false; } if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { 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); } } } if (undoView[0] != null) { undoView[0].hide(true, 0); } } @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; updateFilterTabs(false); floatingButton.setVisibility(View.VISIBLE); final ContentView contentView = (ContentView) fragmentView; if (fragmentContextView != null) { contentView.addView(fragmentContextView); } if (fragmentLocationContextView != null) { contentView.addView(fragmentLocationContextView); } } } 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; } } public void search(String query, boolean animated) { showSearch(true, animated); actionBar.openSearchField(query, false); } private void showSearch(boolean show, boolean animated) { if (initialDialogsType != 0) { animated = false; } if (searchAnimator != null) { searchAnimator.cancel(); searchAnimator = null; } if (tabsAlphaAnimator != null) { tabsAlphaAnimator.cancel(); tabsAlphaAnimator = null; } searchIsShowed = show; if (show) { int dialogsCount = getMessagesController().getTotalDialogsCount(); boolean onlyDialogsAdapter = onlySelect || !searchViewPager.dialogsSearchAdapter.hasRecentRearch() || dialogsCount <= 10; searchViewPager.showOnlyDialogsAdapter(onlyDialogsAdapter); whiteActionBar = !onlyDialogsAdapter; 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) { ViewParent parent = searchTabsView.getParent(); if (parent instanceof ViewGroup) { ((ViewGroup) parent).removeView(searchTabsView); } 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)); } searchViewPager.setKeyboardHeight(((ContentView)fragmentView).getKeyboardHeight()); parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(true); } else { if (filterTabsView != null) { parentLayout.getDrawerLayoutContainer().setAllowOpenDrawerBySwipe(viewPages[0].selectedType == filterTabsView.getFirstTabId()); } } if (animated && searchViewPager.dialogsSearchAdapter.hasRecentRearch()) { AndroidUtilities.setAdjustResizeToNothing(getParentActivity(), classGuid); } else { AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid); } if (!show && filterTabsView != null && filterTabsView.getTag() != null) { filterTabsView.setVisibility(View.VISIBLE); } if (animated) { if (show) { searchViewPager.setVisibility(View.VISIBLE); searchViewPager.reset(); updateFiltersView(true, null, null,false); if (searchTabsView != null) { searchTabsView.hide(false, false); searchTabsView.setVisibility(View.VISIBLE); } } else { viewPages[0].listView.setVisibility(View.VISIBLE); viewPages[0].setVisibility(View.VISIBLE); } setDialogsListFrozen(true); viewPages[0].listView.setVerticalScrollBarEnabled(false); searchViewPager.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); searchAnimator = new AnimatorSet(); ArrayList 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)); 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)); animators.add(ObjectAnimator.ofFloat(searchItem.getSearchContainer(), View.ALPHA, show ? 1f : 0)); if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { 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; } }); } ValueAnimator valueAnimator = ValueAnimator.ofFloat(searchAnimationProgress, show ? 1f : 0); valueAnimator.addUpdateListener(valueAnimator1 -> setSearchAnimationProgress((float) valueAnimator1.getAnimatedValue())); animators.add(valueAnimator); searchAnimator.playTogether(animators); searchAnimator.setDuration(show ? 200 : 180); searchAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT); if (!show) { searchAnimator.setStartDelay(20); if (tabsAlphaAnimator != null) { tabsAlphaAnimator.setStartDelay(80); } } searchAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex); if (searchAnimator != animation) { return; } setDialogsListFrozen(false); if (show) { viewPages[0].listView.hide(); if (filterTabsView != null) { filterTabsView.setVisibility(View.GONE); } searchWasFullyShowed = true; AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid); fragmentView.requestLayout(); searchItem.setVisibility(View.GONE); } else { whiteActionBar = false; searchViewPager.setVisibility(View.GONE); if (searchTabsView != null) { searchTabsView.setVisibility(View.GONE); } searchItem.clearSearchFilters(); searchViewPager.clear(); filtersView.setVisibility(View.GONE); viewPages[0].listView.show(); if (!onlySelect) { hideFloatingButton(false); } searchWasFullyShowed = false; fragmentView.requestLayout(); searchItem.getSearchContainer().setAlpha(1f); } viewPages[0].listView.setVerticalScrollBarEnabled(true); searchViewPager.setBackground(null); searchAnimator = null; } @Override public void onAnimationCancel(Animator animation) { NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex); if (searchAnimator == animation) { if (show) { viewPages[0].listView.hide(); } else { viewPages[0].listView.show(); } searchAnimator = null; } } }); animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null); searchAnimator.start(); if (tabsAlphaAnimator != null) { tabsAlphaAnimator.start(); } } else { setDialogsListFrozen(false); if (show) { viewPages[0].listView.hide(); } else { viewPages[0].listView.show(); } viewPages[0].setAlpha(show ? 0.0f : 1.0f); viewPages[0].setScaleX(show ? 0.9f : 1.0f); viewPages[0].setScaleY(show ? 0.9f : 1.0f); 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); searchItem.getSearchContainer().setAlpha(show ? 1f : 0); if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { filterTabsView.setTranslationY(show ? -AndroidUtilities.dp(44) : 0); filterTabsView.getTabsContainer().setAlpha(show ? 0.0f : 1.0f); } if (filterTabsView != null) { if (filterTabsView.getTag() != null && !show) { filterTabsView.setVisibility(View.VISIBLE); } else { filterTabsView.setVisibility(View.GONE); } } searchViewPager.setVisibility(show ? View.VISIBLE : View.GONE); setSearchAnimationProgress(show ? 1f : 0); fragmentView.invalidate(); } } 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); } if (fragmentView != null) { fragmentView.invalidate(); } updateContextViewPosition(); } private void findAndUpdateCheckBox(long dialogId, boolean checked) { 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; } } } } } private void checkListLoad(ViewPage viewPage) { if (tabsAnimationInProgress || startedTracking || filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE && filterTabsView.isAnimatingIndicator()) { return; } int firstVisibleItem = viewPage.layoutManager.findFirstVisibleItemPosition(); int visibleItemCount = Math.abs(viewPage.layoutManager.findLastVisibleItemPosition() - firstVisibleItem) + 1; boolean loadArchived = false; boolean loadArchivedFromCache = false; boolean load = false; boolean loadFromCache = false; if (viewPage.dialogsType == 7 || viewPage.dialogsType == 8) { ArrayList 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) { if (visibleItemCount > 0 && viewPage.layoutManager.findLastVisibleItemPosition() >= getDialogsArray(currentAccount, viewPage.dialogsType, 1, dialogsListFrozen).size() - 10 || visibleItemCount == 0 && !MessagesController.getInstance(currentAccount).isDialogsEndReached(1)) { loadArchivedFromCache = !getMessagesController().isDialogsEndReached(1); if (loadArchivedFromCache || !getMessagesController().isServerDialogsEndReached(1)) { loadArchived = true; } } } } } if (visibleItemCount > 0 && viewPage.layoutManager.findLastVisibleItemPosition() >= getDialogsArray(currentAccount, viewPage.dialogsType, folderId, dialogsListFrozen).size() - 10 || visibleItemCount == 0 && (viewPage.dialogsType == 7 || viewPage.dialogsType == 8) && !MessagesController.getInstance(currentAccount).isDialogsEndReached(folderId)) { 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); } }); } } private void onItemClick(View view, int position, RecyclerListView.Adapter adapter) { if (getParentActivity() == null) { return; } long dialogId = 0; int message_id = 0; boolean isGlobalSearch = false; if (adapter instanceof DialogsAdapter) { DialogsAdapter dialogsAdapter = (DialogsAdapter) adapter; TLObject object = dialogsAdapter.getItem(position); if (object instanceof TLRPC.User) { dialogId = ((TLRPC.User) object).id; } 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); presentFragment(new DialogsActivity(args)); return; } dialogId = dialog.id; if (actionBar.isActionModeShowed()) { showOrUpdateActionMode(dialog, view); return; } } else if (object instanceof TLRPC.TL_recentMeUrlChat) { dialogId = -((TLRPC.TL_recentMeUrlChat) object).chat_id; } else if (object instanceof TLRPC.TL_recentMeUrlUser) { dialogId = ((TLRPC.TL_recentMeUrlUser) object).user_id; } else if (object instanceof TLRPC.TL_recentMeUrlChatInvite) { TLRPC.TL_recentMeUrlChatInvite chatInvite = (TLRPC.TL_recentMeUrlChatInvite) object; TLRPC.ChatInvite invite = chatInvite.chat_invite; if (invite.chat == null && (!invite.channel || invite.megagroup) || invite.chat != null && (!ChatObject.isChannel(invite.chat) || invite.chat.megagroup)) { String hash = chatInvite.url; int index = hash.indexOf('/'); if (index > 0) { hash = hash.substring(index + 1); } showDialog(new JoinGroupAlert(getParentActivity(), invite, hash, DialogsActivity.this)); return; } else { if (invite.chat != null) { dialogId = -invite.chat.id; } 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; } } else if (adapter == searchViewPager.dialogsSearchAdapter) { Object obj = searchViewPager.dialogsSearchAdapter.getItem(position); isGlobalSearch = searchViewPager.dialogsSearchAdapter.isGlobalSearch(position); if (obj instanceof TLRPC.User) { dialogId = ((TLRPC.User) obj).id; if (!onlySelect) { searchDialogId = dialogId; searchObject = (TLRPC.User) obj; } } else if (obj instanceof TLRPC.Chat) { dialogId = -((TLRPC.Chat) obj).id; if (!onlySelect) { searchDialogId = dialogId; searchObject = (TLRPC.Chat) obj; } } else if (obj instanceof TLRPC.EncryptedChat) { dialogId = ((long) ((TLRPC.EncryptedChat) obj).id) << 32; if (!onlySelect) { searchDialogId = dialogId; searchObject = (TLRPC.EncryptedChat) obj; } } else if (obj instanceof MessageObject) { MessageObject messageObject = (MessageObject) obj; dialogId = messageObject.getDialogId(); message_id = messageObject.getId(); searchViewPager.dialogsSearchAdapter.addHashtagsFromMessage(searchViewPager.dialogsSearchAdapter.getLastSearchString()); } else if (obj instanceof String) { String str = (String) obj; if (searchViewPager.dialogsSearchAdapter.isHashtagSearch()) { actionBar.openSearchField(str, false); } else if (!str.equals("section")) { NewContactActivity activity = new NewContactActivity(); activity.setInitialPhoneNumber(str); presentFragment(activity); } } } if (dialogId == 0) { return; } if (onlySelect) { if (!validateSlowModeDialog(dialogId)) { return; } if (!selectedDialogs.isEmpty()) { boolean checked = addOrRemoveSelectedDialog(dialogId, view); if (adapter == searchViewPager.dialogsSearchAdapter) { actionBar.closeSearchField(); findAndUpdateCheckBox(dialogId, checked); } updateSelectedCount(); } else { didSelectResult(dialogId, true, false); } } else { Bundle args = new Bundle(); int lower_part = (int) dialogId; int high_id = (int) (dialogId >> 32); 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 { args.putInt("enc_id", high_id); } if (message_id != 0) { args.putInt("message_id", message_id); } else if (!isGlobalSearch) { closeSearch(); } else { if (searchObject != null) { searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject); searchObject = null; } } if (AndroidUtilities.isTablet()) { if (openedDialogId == dialogId && adapter != searchViewPager.dialogsSearchAdapter) { return; } if (viewPages != null) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId = dialogId); } } updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } if (searchViewPager.actionModeShowing()) { searchViewPager.hideActionMode(); } if (searchString != null) { if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) { getNotificationCenter().postNotificationName(NotificationCenter.closeChats); presentFragment(new ChatActivity(args)); } } else { if (getMessagesController().checkCanOpenChat(args, DialogsActivity.this)) { presentFragment(new ChatActivity(args)); } } } } private boolean onItemLongClick(View view, int position, float x, float y, int dialogsType, RecyclerListView.Adapter adapter) { if (getParentActivity() == null) { return false; } if (!actionBar.isActionModeShowed() && !AndroidUtilities.isTablet() && !onlySelect && view instanceof DialogCell) { DialogCell cell = (DialogCell) view; if (cell.isPointInsideAvatar(x, y)) { return showChatPreview(cell); } } if (adapter == searchViewPager.dialogsSearchAdapter) { Object item = searchViewPager.dialogsSearchAdapter.getItem(position); if (searchViewPager.dialogsSearchAdapter.isRecentSearchDisplayed()) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); 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))); } else { builder.setMessage(LocaleController.formatString("ClearSearchSingleUserAlertText", R.string.ClearSearchSingleUserAlertText, ContactsController.formatName(user.first_name, user.last_name))); } 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; } builder.setPositiveButton(LocaleController.getString("ClearSearchRemove", R.string.ClearSearchRemove).toUpperCase(), (dialogInterface, i) -> searchViewPager.dialogsSearchAdapter.removeRecentSearch(did)); 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 true; } return false; } if (actionBar.isSearchFieldVisible()) { return false; } DialogsAdapter dialogsAdapter = (DialogsAdapter) adapter; ArrayList dialogs = getDialogsArray(currentAccount, dialogsType, folderId, dialogsListFrozen); position = dialogsAdapter.fixPosition(position); if (position < 0 || position >= dialogs.size()) { return false; } final TLRPC.Dialog dialog = dialogs.get(position); if (onlySelect) { if (initialDialogsType != 3) { return false; } if (!validateSlowModeDialog(dialog.id)) { return false; } addOrRemoveSelectedDialog(dialog.id, view); updateSelectedCount(); } else { if (dialog instanceof TLRPC.TL_dialogFolder) { BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); final boolean hasUnread = getMessagesStorage().getArchiveUnreadCount() != 0; int[] icons = new int[]{ hasUnread ? R.drawable.menu_read : 0, SharedConfig.archiveHidden ? R.drawable.chats_pin : R.drawable.chats_unpin, }; CharSequence[] items = new CharSequence[]{ hasUnread ? LocaleController.getString("MarkAllAsRead", R.string.MarkAllAsRead) : null, SharedConfig.archiveHidden ? LocaleController.getString("PinInTheList", R.string.PinInTheList) : LocaleController.getString("HideAboveTheList", R.string.HideAboveTheList) }; builder.setItems(items, icons, (d, which) -> { if (which == 0) { getMessagesStorage().readAllDialogs(1); } 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); } } }); showDialog(builder.create()); return false; } if (actionBar.isActionModeShowed() && isDialogPinned(dialog)) { return false; } showOrUpdateActionMode(dialog, view); } return true; } 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; } private void updateFloatingButtonOffset() { floatingButtonContainer.setTranslationY(floatingButtonTranslation - additionalFloatingTranslation * (1f - floatingButtonHideProgress)); } private boolean hasHiddenArchive() { return !onlySelect && initialDialogsType == 0 && folderId == 0 && getMessagesController().hasHiddenArchive(); } private boolean waitingForDialogsAnimationEnd(ViewPage viewPage) { return viewPage.dialogsItemAnimator.isRunning() || dialogRemoveFinished != 0 || dialogInsertFinished != 0 || dialogChangeFinished != 0; } private void onDialogAnimationFinished() { dialogRemoveFinished = 0; dialogInsertFinished = 0; dialogChangeFinished = 0; AndroidUtilities.runOnUIThread(() -> { 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); } finishFragment(); } setDialogsListFrozen(false); updateDialogIndices(); }); } private void setScrollY(float value) { if (scrimView != null) { scrimView.getLocationInWindow(scrimViewLocation); } actionBar.setTranslationY(value); if (filterTabsView != null) { filterTabsView.setTranslationY(value); } updateContextViewPosition(); if (viewPages != null) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].listView.setTopGlowOffset(viewPages[a].listView.getPaddingTop() + (int) value); } } fragmentView.invalidate(); } 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); } } 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(); } private void hideActionMode(boolean animateCheck) { actionBar.hideActionMode(); if (menuDrawable != null) { actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrOpenMenu", R.string.AccDescrOpenMenu)); } selectedDialogs.clear(); if (menuDrawable != null) { menuDrawable.setRotation(0, true); } else if (backDrawable != null) { backDrawable.setRotation(0, true); } if (filterTabsView != null) { filterTabsView.animateColorsTo(Theme.key_actionBarTabLine, Theme.key_actionBarTabActiveText, Theme.key_actionBarTabUnactiveText, Theme.key_actionBarTabSelector, Theme.key_actionBarDefault); } if (actionBarColorAnimator != null) { actionBarColorAnimator.cancel(); } actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 0); actionBarColorAnimator.addUpdateListener(valueAnimator -> { progressToActionMode = (float) valueAnimator.getAnimatedValue(); 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); } } fragmentView.invalidate(); }); actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); actionBarColorAnimator.setDuration(200); actionBarColorAnimator.start(); allowMoving = false; if (!movingDialogFilters.isEmpty()) { for (int a = 0, N = movingDialogFilters.size(); a < N; a++) { MessagesController.DialogFilter filter = movingDialogFilters.get(a); FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null); } movingDialogFilters.clear(); } if (movingWas) { getMessagesController().reorderPinnedDialogs(folderId, null, 0); movingWas = false; } updateCounters(true); if (viewPages != null) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].dialogsAdapter.onReorderStateChanged(false); } } updateVisibleRows(MessagesController.UPDATE_MASK_REORDER | MessagesController.UPDATE_MASK_CHECK | (animateCheck ? MessagesController.UPDATE_MASK_CHAT : 0)); } private int getPinnedCount() { int pinnedCount = 0; ArrayList dialogs; if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) { dialogs = getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, dialogsListFrozen); } else { 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; if (isDialogPinned(dialog)) { pinnedCount++; } else if (!getMessagesController().isPromoDialog(dialog.id, false)) { break; } } return pinnedCount; } 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; } private void perfromSelectedDialogsAction(int action, boolean alert) { if (getParentActivity() == null) { return; } MessagesController.DialogFilter filter; if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) { filter = getMessagesController().selectedDialogFilter[viewPages[0].dialogsType == 8 ? 1 : 0]; } else { filter = null; } int count = selectedDialogs.size(); if (action == archive || action == archive2) { ArrayList copy = new ArrayList<>(selectedDialogs); getMessagesController().addDialogToFolder(copy, canUnarchiveCount == 0 ? 1 : 0, -1, null, 0); if (canUnarchiveCount == 0) { SharedPreferences preferences = MessagesController.getGlobalMainSettings(); boolean hintShowed = preferences.getBoolean("archivehint_l", false) || SharedConfig.archiveHidden; if (!hintShowed) { preferences.edit().putBoolean("archivehint_l", true).commit(); } 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 dialogs = getMessagesController().getDialogs(folderId); if (viewPages != null && dialogs.isEmpty()) { viewPages[0].listView.setEmptyView(null); viewPages[0].progressView.setVisibility(View.INVISIBLE); finishFragment(); } } hideActionMode(false); return; } else if ((action == pin || action == pin2) && canPinCount != 0) { int pinnedCount = 0; int pinnedSecretCount = 0; int newPinnedCount = 0; int newPinnedSecretCount = 0; ArrayList 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; if (isDialogPinned(dialog)) { if (lower_id == 0) { pinnedSecretCount++; } else { pinnedCount++; } } else if (!getMessagesController().isPromoDialog(dialog.id, false)) { break; } } int alreadyAdded = 0; for (int a = 0; a < count; a++) { long selectedDialog = selectedDialogs.get(a); TLRPC.Dialog dialog = getMessagesController().dialogs_dict.get(selectedDialog); if (dialog == null || isDialogPinned(dialog)) { continue; } int lower_id = (int) selectedDialog; if (lower_id == 0) { newPinnedSecretCount++; } else { newPinnedCount++; } if (filter != null && filter.alwaysShow.contains(lower_id)) { alreadyAdded++; } } int maxPinnedCount; if (viewPages[0].dialogsType == 7 || viewPages[0].dialogsType == 8) { maxPinnedCount = 100 - filter.alwaysShow.size(); } else if (folderId != 0 || filter != null) { maxPinnedCount = getMessagesController().maxFolderPinnedDialogsCount; } else { maxPinnedCount = getMessagesController().maxPinnedDialogsCount; } 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()); } AndroidUtilities.shakeView(pinItem, 2, 0); Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE); if (v != null) { v.vibrate(200); } return; } } else if ((action == delete || action == clear) && count > 1 && alert) { 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); MessagesController.getInstance(currentAccount).checkIfFolderEmpty(folderId); if (folderId != 0 && getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false).size() == 0) { viewPages[0].listView.setEmptyView(null); viewPages[0].progressView.setVisibility(View.INVISIBLE); finishFragment(); } }); } 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)); } } 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); } getMessagesController().blockPeer(lowerId); } hideActionMode(false); }); return; } 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; } 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); TLRPC.EncryptedChat encryptedChat = null; if (lower_id != 0) { if (lower_id > 0) { user = getMessagesController().getUser(lower_id); chat = null; } else { chat = getMessagesController().getChat(-lower_id); } } else { encryptedChat = getMessagesController().getEncryptedChat(high_id); 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); if (action == pin || action == pin2) { if (canPinCount != 0) { if (isDialogPinned(dialog)) { continue; } 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; } } } else { if (!isDialogPinned(dialog)) { continue; } 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; } } } } else if (action == read) { if (canReadCount != 0) { getMessagesController().markMentionsAsRead(selectedDialog); getMessagesController().markDialogAsRead(selectedDialog, dialog.top_message, dialog.top_message, dialog.last_message_date, false, 0, 0, true, 0); } else { getMessagesController().markDialogAsUnread(selectedDialog, null, 0); } } else if (action == delete || action == clear) { if (count == 1) { if (action == delete && canDeletePsaSelected) { 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 { AlertsCreator.createClearOrDeleteDialogAlert(DialogsActivity.this, action == clear, chat, user, lower_id == 0, (param) -> { 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()); getMessagesController().deleteUserFromChat((int) -selectedDialog, currentUser, null); } } else { getMessagesController().deleteDialog(selectedDialog, 0, param); if (isBot) { getMessagesController().blockPeer((int) selectedDialog); } } if (AndroidUtilities.isTablet()) { getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog); } MessagesController.getInstance(currentAccount).checkIfFolderEmpty(folderId); } }); } }); } return; } else { if (getMessagesController().isPromoDialog(selectedDialog, true)) { getMessagesController().hidePromoDialog(); } else { if (action == clear && canClearCacheCount != 0) { getMessagesController().deleteDialog(selectedDialog, 2, false); } else { 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); } } else { getMessagesController().deleteDialog(selectedDialog, 0, false); if (isBot) { getMessagesController().blockPeer((int) selectedDialog); } } if (AndroidUtilities.isTablet()) { getNotificationCenter().postNotificationName(NotificationCenter.closeChats, selectedDialog); } } } } } } else if (action == mute) { if (count == 1 && canMuteCount == 1) { showDialog(AlertsCreator.createMuteAlert(this, selectedDialog), dialog12 -> hideActionMode(true)); 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); } } } } if (action == mute && !(count == 1 && canMuteCount == 1)) { BulletinFactory.createMuteBulletin(this, canUnmuteCount == 0).show(); } if (action == pin || action == pin2) { if (filter != null) { FilterCreateActivity.saveFilterToServer(filter, filter.flags, filter.name, filter.alwaysShow, filter.neverShow, filter.pinnedDialogs, false, false, true, true, false, DialogsActivity.this, null); } else { getMessagesController().reorderPinnedDialogs(folderId, null, 0); } } if (scrollToTop) { hideFloatingButton(false); scrollToTop(); } hideActionMode(action != pin2 && action != pin && action != delete); } private void scrollToTop() { 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(); } else { viewPages[0].listView.smoothScrollToPosition(position); } } private void updateCounters(boolean hide) { int canClearHistoryCount = 0; int canDeleteCount = 0; int canUnpinCount = 0; int canArchiveCount = 0; canDeletePsaSelected = false; canUnarchiveCount = 0; canUnmuteCount = 0; canMuteCount = 0; canPinCount = 0; canReadCount = 0; canClearCacheCount = 0; int cantBlockCount = 0; canReportSpamCount = 0; if (hide) { return; } int count = selectedDialogs.size(); int selfUserId = getUserConfig().getClientUserId(); SharedPreferences preferences = getNotificationsSettings(); 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; boolean pinned = isDialogPinned(dialog); boolean hasUnread = dialog.unread_count != 0 || dialog.unread_mark; if (getMessagesController().isDialogMuted(selectedDialog)) { canUnmuteCount++; } else { canMuteCount++; } if (hasUnread) { canReadCount++; } if (folderId == 1 || dialog.folder_id == 1) { canUnarchiveCount++; } else if (selectedDialog != selfUserId && selectedDialog != 777000 && !getMessagesController().isPromoDialog(selectedDialog, false)) { canArchiveCount++; } int lower_id = (int) selectedDialog; int high_id = (int) (selectedDialog >> 32); if (lower_id <= 0 || lower_id == selfUserId) { cantBlockCount++; } else { TLRPC.User user = getMessagesController().getUser(lower_id); if (MessagesController.isSupportUser(user)) { cantBlockCount++; } else { if (lower_id == 0 || preferences.getBoolean("dialog_bar_report" + selectedDialog, true)) { canReportSpamCount++; } } } if (DialogObject.isChannel(dialog)) { final TLRPC.Chat chat = getMessagesController().getChat(-lower_id); CharSequence[] items; if (getMessagesController().isPromoDialog(dialog.id, true)) { canClearCacheCount++; if (getMessagesController().promoDialogType == MessagesController.PROMO_TYPE_PSA) { canDeleteCount++; canDeletePsaSelected = true; } } else { if (pinned) { canUnpinCount++; } else { canPinCount++; } if (chat != null && chat.megagroup) { if (TextUtils.isEmpty(chat.username)) { canClearHistoryCount++; } else { canClearCacheCount++; } } else { canClearCacheCount++; } canDeleteCount++; } } 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) { final String contentDescription = LocaleController.getString("Unarchive", R.string.Unarchive); archiveItem.setTextAndIcon(contentDescription, R.drawable.msg_unarchive); archive2Item.setIcon(R.drawable.msg_unarchive); archive2Item.setContentDescription(contentDescription); if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { archive2Item.setVisibility(View.VISIBLE); archiveItem.setVisibility(View.GONE); } else { archiveItem.setVisibility(View.VISIBLE); archive2Item.setVisibility(View.GONE); } } else if (canArchiveCount != 0) { final String contentDescription = LocaleController.getString("Archive", R.string.Archive); archiveItem.setTextAndIcon(contentDescription, R.drawable.msg_archive); archive2Item.setIcon(R.drawable.msg_archive); archive2Item.setContentDescription(contentDescription); if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { archive2Item.setVisibility(View.VISIBLE); archiveItem.setVisibility(View.GONE); } else { archiveItem.setVisibility(View.VISIBLE); archive2Item.setVisibility(View.GONE); } } else { archiveItem.setVisibility(View.GONE); archive2Item.setVisibility(View.GONE); } if (canPinCount + canUnpinCount != count) { pinItem.setVisibility(View.GONE); pin2Item.setVisibility(View.GONE); } else { if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { pin2Item.setVisibility(View.VISIBLE); pinItem.setVisibility(View.GONE); } else { pinItem.setVisibility(View.VISIBLE); pin2Item.setVisibility(View.GONE); } } if (cantBlockCount != 0) { blockItem.setVisibility(View.GONE); } else { blockItem.setVisibility(View.VISIBLE); } 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); } if (canUnmuteCount != 0) { muteItem.setIcon(R.drawable.msg_unmute); muteItem.setContentDescription(LocaleController.getString("ChatsUnmute", R.string.ChatsUnmute)); } else { muteItem.setIcon(R.drawable.msg_mute); muteItem.setContentDescription(LocaleController.getString("ChatsMute", R.string.ChatsMute)); } if (canReadCount != 0) { readItem.setTextAndIcon(LocaleController.getString("MarkAsRead", R.string.MarkAsRead), R.drawable.msg_markread); } else { readItem.setTextAndIcon(LocaleController.getString("MarkAsUnread", R.string.MarkAsUnread), R.drawable.msg_markunread); } if (canPinCount != 0) { pinItem.setIcon(R.drawable.msg_pin); pinItem.setContentDescription(LocaleController.getString("PinToTop", R.string.PinToTop)); pin2Item.setText(LocaleController.getString("DialogPin", R.string.DialogPin)); } else { pinItem.setIcon(R.drawable.msg_unpin); pinItem.setContentDescription(LocaleController.getString("UnpinFromTop", R.string.UnpinFromTop)); pin2Item.setText(LocaleController.getString("DialogUnpin", R.string.DialogUnpin)); } } 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; } private void showOrUpdateActionMode(TLRPC.Dialog dialog, View cell) { addOrRemoveSelectedDialog(dialog.id, cell); boolean updateAnimated = false; if (actionBar.isActionModeShowed()) { if (selectedDialogs.isEmpty()) { hideActionMode(true); return; } updateAnimated = true; } else { createActionMode(); actionBar.showActionMode(); resetScroll(); if (menuDrawable != null) { actionBar.setBackButtonContentDescription(LocaleController.getString("AccDescrGoBack", R.string.AccDescrGoBack)); } if (getPinnedCount() > 1) { if (viewPages != null) { for (int a = 0; a < viewPages.length; a++) { viewPages[a].dialogsAdapter.onReorderStateChanged(true); } } updateVisibleRows(MessagesController.UPDATE_MASK_REORDER); } AnimatorSet animatorSet = new AnimatorSet(); ArrayList 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); animatorSet.setDuration(200); animatorSet.start(); if (actionBarColorAnimator != null) { actionBarColorAnimator.cancel(); } actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 1f); actionBarColorAnimator.addUpdateListener(valueAnimator -> { progressToActionMode = (float) valueAnimator.getAnimatedValue(); 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); } } fragmentView.invalidate(); }); actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); actionBarColorAnimator.setDuration(200); actionBarColorAnimator.start(); if (filterTabsView != null) { filterTabsView.animateColorsTo(Theme.key_profile_tabSelectedLine, Theme.key_profile_tabSelectedText, Theme.key_profile_tabText, Theme.key_profile_tabSelector, Theme.key_actionBarActionModeDefault); } if (menuDrawable != null) { menuDrawable.setRotateToBack(false); menuDrawable.setRotation(1, true); } else if (backDrawable != null) { backDrawable.setRotation(1, true); } } updateCounters(false); selectedDialogsCountTextView.setNumber(selectedDialogs.size(), updateAnimated); } private void closeSearch() { if (AndroidUtilities.isTablet()) { if (actionBar != null) { actionBar.closeSearchField(); } if (searchObject != null) { searchViewPager.dialogsSearchAdapter.putRecentSearch(searchDialogId, searchObject); searchObject = null; } } else { closeSearchFieldOnHide = true; } } protected RecyclerListView getListView() { return viewPages[0].listView; } protected RecyclerListView getSearchListView() { return searchViewPager.searchListView; } 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]; } private void updateProxyButton(boolean animated) { if (proxyDrawable == null || doneItem != null && doneItem.getVisibility() == View.VISIBLE) { return; } SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); String proxyAddress = preferences.getString("proxy_ip", ""); boolean proxyEnabled; if ((proxyEnabled = preferences.getBoolean("proxy_enabled", false) && !TextUtils.isEmpty(proxyAddress)) || getMessagesController().blockedCountry && !SharedConfig.proxyList.isEmpty()) { if (!actionBar.isSearchFieldVisible() && (doneItem == null || doneItem.getVisibility() != View.VISIBLE)) { proxyItem.setVisibility(View.VISIBLE); } proxyItemVisible = true; proxyDrawable.setConnected(proxyEnabled, currentConnectionState == ConnectionsManager.ConnectionStateConnected || currentConnectionState == ConnectionsManager.ConnectionStateUpdating, animated); } else { proxyItemVisible = false; proxyItem.setVisibility(View.GONE); } } private AnimatorSet doneItemAnimator; 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 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(); } private void updateSelectedCount() { if (commentView == null) { return; } 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(); } } else { 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())); } } @TargetApi(Build.VERSION_CODES.M) private void askForPermissons(boolean alert) { Activity activity = getParentActivity(); if (activity == null) { return; } ArrayList permissons = new ArrayList<>(); if (getUserConfig().syncContacts && askAboutContacts && activity.checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { if (alert) { AlertDialog.Builder builder = AlertsCreator.createContactsPermissionDialog(activity, param -> { askAboutContacts = param != 0; MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts).commit(); askForPermissons(false); }); showDialog(permissionDialog = builder.create()); return; } 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); } if (permissons.isEmpty()) { if (askingForPermissions) { askingForPermissions = false; showFiltersHint(); } return; } String[] items = permissons.toArray(new String[0]); try { activity.requestPermissions(items, 1); } catch (Exception ignore) { } } @Override protected void onDialogDismiss(Dialog dialog) { super.onDialogDismiss(dialog); if (permissionDialog != null && dialog == permissionDialog && getParentActivity() != null) { askForPermissons(false); } } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (scrimPopupWindow != null) { scrimPopupWindow.dismiss(); } if (!onlySelect && floatingButtonContainer != null) { floatingButtonContainer.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { floatingButtonTranslation = floatingHidden ? AndroidUtilities.dp(100) : 0; updateFloatingButtonOffset(); floatingButtonContainer.setClickable(!floatingHidden); if (floatingButtonContainer != null) { floatingButtonContainer.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); } } @Override public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == 1) { for (int a = 0; a < permissions.length; a++) { if (grantResults.length <= a) { continue; } switch (permissions[a]) { case Manifest.permission.READ_CONTACTS: if (grantResults[a] == PackageManager.PERMISSION_GRANTED) { getContactsController().forceImportContacts(); } else { MessagesController.getGlobalNotificationsSettings().edit().putBoolean("askAboutContacts", askAboutContacts = false).commit(); } break; case Manifest.permission.WRITE_EXTERNAL_STORAGE: if (grantResults[a] == PackageManager.PERMISSION_GRANTED) { ImageLoader.getInstance().checkMediaPaths(); } break; } } if (askingForPermissions) { askingForPermissions = false; showFiltersHint(); } } } @SuppressWarnings("unchecked") @Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.dialogsNeedReload) { if (viewPages == null || dialogsListFrozen) { return; } for (int a = 0; a < viewPages.length; a++) { if (viewPages[a].getVisibility() != View.VISIBLE) { continue; } if (viewPages[a].dialogsAdapter.isDataSetChanged() || args.length > 0) { viewPages[a].dialogsAdapter.notifyDataSetChanged(); } else { updateVisibleRows(MessagesController.UPDATE_MASK_NEW_MESSAGE); } try { viewPages[a].listView.setEmptyView(folderId == 0 ? viewPages[a].progressView : null); } catch (Exception e) { FileLog.e(e); } 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); } } else if (id == NotificationCenter.emojiDidLoad) { updateVisibleRows(0); if (filterTabsView != null) { filterTabsView.getTabsContainer().invalidateViews(); } } else if (id == NotificationCenter.closeSearchByActiveAction) { if (actionBar != null) { actionBar.closeSearchField(); } } else if (id == NotificationCenter.proxySettingsChanged) { updateProxyButton(false); } else if (id == NotificationCenter.updateInterfaces) { Integer mask = (Integer) args[0]; updateVisibleRows(mask); 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); } } } } else if (id == NotificationCenter.appDidLogout) { dialogsLoaded[currentAccount] = false; } else if (id == NotificationCenter.encryptedChatUpdated) { updateVisibleRows(0); } else if (id == NotificationCenter.contactsDidLoad) { if (viewPages == null || dialogsListFrozen) { return; } boolean updateVisibleRows = false; for (int a = 0; a < viewPages.length; a++) { if (viewPages[a].isDefaultDialogType() && getMessagesController().getDialogs(folderId).isEmpty()) { viewPages[a].dialogsAdapter.notifyDataSetChanged(); } else { updateVisibleRows = true; } } if (updateVisibleRows) { updateVisibleRows(0); } } else if (id == NotificationCenter.openedChatChanged) { 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; } viewPages[a].dialogsAdapter.setOpenedDialogId(openedDialogId); } } updateVisibleRows(MessagesController.UPDATE_MASK_SELECT_DIALOG); } else if (id == NotificationCenter.notificationsSettingsUpdated) { updateVisibleRows(0); } else if (id == NotificationCenter.messageReceivedByAck || id == NotificationCenter.messageReceivedByServer || id == NotificationCenter.messageSendError) { updateVisibleRows(MessagesController.UPDATE_MASK_SEND_STATE); } else if (id == NotificationCenter.didSetPasscode) { updatePasscodeButton(); } else if (id == NotificationCenter.needReloadRecentDialogsSearch) { if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) { searchViewPager.dialogsSearchAdapter.loadRecentSearch(); } } else if (id == NotificationCenter.replyMessagesDidLoad) { updateVisibleRows(MessagesController.UPDATE_MASK_MESSAGE_TEXT); } else if (id == NotificationCenter.reloadHints) { if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) { searchViewPager.dialogsSearchAdapter.notifyDataSetChanged(); } } else if (id == NotificationCenter.didUpdateConnectionState) { int state = AccountInstance.getInstance(account).getConnectionsManager().getConnectionState(); if (currentConnectionState != state) { currentConnectionState = state; updateProxyButton(true); } } else if (id == NotificationCenter.needDeleteDialog) { if (fragmentView == null || isPaused) { return; } 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); } else { getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke); } } else { getMessagesController().deleteDialog(dialogId, 0, revoke); if (user != null && user.bot) { getMessagesController().blockPeer(user.id); } } MessagesController.getInstance(currentAccount).checkIfFolderEmpty(folderId); }; 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(); } } else if (id == NotificationCenter.dialogFiltersUpdated) { updateFilterTabs(true); } else if (id == NotificationCenter.filterSettingsUpdated) { showFiltersHint(); } else if (id == NotificationCenter.newSuggestionsAvailable) { showNextSupportedSuggestion(); } else if (id == NotificationCenter.messagesDeleted) { if (searchIsShowed && searchViewPager != null) { ArrayList markAsDeletedMessages = (ArrayList) args[0]; int channelId = (int) args[1]; searchViewPager.messagesDeleted(channelId, markAsDeletedMessages); } } } private String showingSuggestion; 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; } getMessagesController().removeSuggestion(showingSuggestion); 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; } return false; } private void showFiltersHint() { if (askingForPermissions || !getMessagesController().dialogFiltersLoaded || !getMessagesController().showFiltersTooltip || filterTabsView == null || filterTabsView.getVisibility() == View.VISIBLE || isPaused || !getUserConfig().filtersLoaded || inPreviewMode) { return; } SharedPreferences preferences = MessagesController.getGlobalMainSettings(); if (preferences.getBoolean("filterhint", false)) { return; } preferences.edit().putBoolean("filterhint", true).commit(); AndroidUtilities.runOnUIThread(() -> getUndoView().showWithAction(0, UndoView.ACTION_FILTERS_AVAILABLE, null, () -> presentFragment(new FiltersSetupActivity())), 1000); } private void setDialogsListFrozen(boolean frozen) { if (viewPages == null || dialogsListFrozen == frozen) { return; } if (frozen) { frozenDialogsList = new ArrayList<>(getDialogsArray(currentAccount, viewPages[0].dialogsType, folderId, false)); } else { frozenDialogsList = null; } dialogsListFrozen = frozen; viewPages[0].dialogsAdapter.setDialogsListFrozen(frozen); if (!frozen) { viewPages[0].dialogsAdapter.notifyDataSetChanged(); } } public static ArrayList getDialogsArray(int currentAccount, int dialogsType, int folderId, boolean frozen) { if (frozen && frozenDialogsList != null) { return frozenDialogsList; } MessagesController messagesController = AccountInstance.getInstance(currentAccount).getMessagesController(); if (dialogsType == 0) { return messagesController.getDialogs(folderId); } else if (dialogsType == 1) { return messagesController.dialogsServerOnly; } else if (dialogsType == 2) { return messagesController.dialogsCanAddUsers; } else if (dialogsType == 3) { return messagesController.dialogsForward; } else if (dialogsType == 4) { return messagesController.dialogsUsersOnly; } else if (dialogsType == 5) { return messagesController.dialogsChannelsOnly; } else if (dialogsType == 6) { return messagesController.dialogsGroupsOnly; } 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; } } else if (dialogsType == 9) { return messagesController.dialogsForBlock; } return null; } public void setSideMenu(RecyclerView recyclerView) { sideMenu = recyclerView; sideMenu.setBackgroundColor(Theme.getColor(Theme.key_chats_menuBackground)); sideMenu.setGlowColor(Theme.getColor(Theme.key_chats_menuBackground)); } private void updatePasscodeButton() { if (passcodeItem == null) { return; } if (SharedConfig.passcodeHash.length() != 0 && !searching) { if (doneItem == null || doneItem.getVisibility() != View.VISIBLE) { passcodeItem.setVisibility(View.VISIBLE); } passcodeItemVisible = true; if (SharedConfig.appLocked) { passcodeItem.setIcon(R.drawable.lock_close); passcodeItem.setContentDescription(LocaleController.getString("AccDescrPasscodeUnlock", R.string.AccDescrPasscodeUnlock)); } else { passcodeItem.setIcon(R.drawable.lock_open); passcodeItem.setContentDescription(LocaleController.getString("AccDescrPasscodeLock", R.string.AccDescrPasscodeLock)); } } else { passcodeItem.setVisibility(View.GONE); passcodeItemVisible = false; } } private void hideFloatingButton(boolean hide) { if (floatingHidden == hide) { return; } floatingHidden = hide; AnimatorSet animatorSet = new AnimatorSet(); ValueAnimator valueAnimator = ValueAnimator.ofFloat(floatingButtonHideProgress,floatingHidden ? 1f : 0f); valueAnimator.addUpdateListener(animation -> { floatingButtonHideProgress = (float) animation.getAnimatedValue(); floatingButtonTranslation = AndroidUtilities.dp(100) * floatingButtonHideProgress; updateFloatingButtonOffset(); }); animatorSet.playTogether(valueAnimator); animatorSet.setDuration(300); animatorSet.setInterpolator(floatingInterpolator); floatingButtonContainer.setClickable(!hide); animatorSet.start(); } private void updateDialogIndices() { if (viewPages == null) { return; } for (int b = 0; b < viewPages.length; b++) { if (viewPages[b].getVisibility() != View.VISIBLE) { continue; } ArrayList 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); } } } } private void updateVisibleRows(int mask) { if (dialogsListFrozen) { return; } for (int c = 0; c < 3; c++) { RecyclerListView list; if (c == 2) { list = searchViewPager != null ? searchViewPager.searchListView : null; } 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; } int count = list.getChildCount(); for (int a = 0; a < count; a++) { View child = list.getChildAt(a); if (child instanceof DialogCell) { if (list.getAdapter() != searchViewPager.dialogsSearchAdapter) { 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); if (viewPages[c].isDefaultDialogType() && AndroidUtilities.isTablet()) { cell.setDialogSelected(cell.getDialogId() == openedDialogId); } } else if ((mask & MessagesController.UPDATE_MASK_SELECT_DIALOG) != 0) { if (viewPages[c].isDefaultDialogType() && AndroidUtilities.isTablet()) { cell.setDialogSelected(cell.getDialogId() == openedDialogId); } } else { cell.update(mask); } if (selectedDialogs != null) { cell.setChecked(selectedDialogs.contains(cell.getDialogId()), false); } } } } 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); } } } } } } public void setDelegate(DialogsActivityDelegate dialogsActivityDelegate) { delegate = dialogsActivityDelegate; } public void setSearchString(String string) { searchString = string; } public void setInitialSearchString(String initialSearchString) { this.initialSearchString = initialSearchString; } public boolean isMainDialogList() { return delegate == null && searchString == null; } private void didSelectResult(final long dialog_id, boolean useAlert, final boolean param) { if (addToGroupAlertString == null && checkCanWrite) { 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)) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle)); if (hasPoll == 2) { builder.setMessage(LocaleController.getString("PublicPollCantForward", R.string.PublicPollCantForward)); } else { builder.setMessage(LocaleController.getString("ChannelCantSendMessage", R.string.ChannelCantSendMessage)); } builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null); showDialog(builder.create()); return; } } 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; } } if (useAlert && (selectAlertString != null && selectAlertStringGroup != null || addToGroupAlertString != null)) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); int lower_part = (int) dialog_id; int high_id = (int) (dialog_id >> 32); String title; String message; String buttonText; if (lower_part != 0) { if (lower_part == getUserConfig().getClientUserId()) { title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle); message = LocaleController.formatStringSimple(selectAlertStringGroup, LocaleController.getString("SavedMessages", R.string.SavedMessages)); buttonText = LocaleController.getString("Send", R.string.Send); } else if (lower_part > 0) { TLRPC.User user = getMessagesController().getUser(lower_part); if (user == null || selectAlertString == null) { return; } title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle); message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)); buttonText = LocaleController.getString("Send", R.string.Send); } else { TLRPC.Chat chat = getMessagesController().getChat(-lower_part); if (chat == null) { return; } if (addToGroupAlertString != null) { title = LocaleController.getString("AddToTheGroupAlertTitle", R.string.AddToTheGroupAlertTitle); message = LocaleController.formatStringSimple(addToGroupAlertString, chat.title); buttonText = LocaleController.getString("Add", R.string.Add); } else { title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle); message = LocaleController.formatStringSimple(selectAlertStringGroup, chat.title); buttonText = LocaleController.getString("Send", R.string.Send); } } } else { TLRPC.EncryptedChat chat = getMessagesController().getEncryptedChat(high_id); TLRPC.User user = getMessagesController().getUser(chat.user_id); if (user == null) { return; } title = LocaleController.getString("SendMessageTitle", R.string.SendMessageTitle); message = LocaleController.formatStringSimple(selectAlertString, UserObject.getUserName(user)); buttonText = LocaleController.getString("Send", R.string.Send); } builder.setTitle(title); builder.setMessage(AndroidUtilities.replaceTags(message)); builder.setPositiveButton(buttonText, (dialogInterface, i) -> didSelectResult(dialog_id, false, false)); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } else { if (delegate != null) { ArrayList dids = new ArrayList<>(); dids.add(dialog_id); delegate.didSelectDialogs(DialogsActivity.this, dids, null, param); if (resetDelegate) { delegate = null; } } else { finishFragment(); } } } @Override public ArrayList getThemeDescriptions() { ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> { for (int b = 0; b < 3; b++) { RecyclerListView list; if (b == 2) { if (searchViewPager == null) { continue; } list = searchViewPager.searchListView; } 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); } } } if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) { RecyclerListView recyclerListView = searchViewPager.dialogsSearchAdapter.getInnerListView(); if (recyclerListView != null) { int count = recyclerListView.getChildCount(); for (int a = 0; a < count; a++) { View child = recyclerListView.getChildAt(a); if (child instanceof HintDialogCell) { ((HintDialogCell) child).update(); } } } } if (sideMenu != null) { View child = sideMenu.getChildAt(0); if (child instanceof DrawerProfileCell) { DrawerProfileCell profileCell = (DrawerProfileCell) child; profileCell.applyBackground(true); profileCell.updateColors(); } } if (viewPages != null) { for (int a = 0; a < viewPages.length; a++) { if (viewPages[a].pullForegroundDrawable == null) { continue; } viewPages[a].pullForegroundDrawable.updateColors(); } } 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); } 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)); } if (filtersView != null) { filtersView.updateColors(); } if (searchViewPager != null) { searchViewPager.updateColors(); } if (searchTabsView != null) { searchTabsView.updateColors(); } 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(); } setSearchAnimationProgress(searchAnimationProgress); }; ArrayList 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)); } if (doneItem != null) { arrayList.add(new ThemeDescription(doneItem, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_actionBarDefaultSelector)); } if (folderId == 0) { 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)); } arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, cellDelegate, Theme.key_actionBarDefaultIcon)); 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 { 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)); } 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)); //arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_AM_BACKGROUND, null, null, null, null, Theme.key_actionBarActionModeDefault)); 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)); 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)); 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)); } 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)); for (int a = 0; a < 3; a++) { RecyclerListView list; if (a == 2) { if (searchViewPager == null) { continue; } list = searchViewPager.searchListView; } else if (viewPages != null) { list = a < viewPages.length ? viewPages[a].listView : null; } else { continue; } if (list == null) { continue; } 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)); arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, Theme.avatarDrawables, null, Theme.key_avatar_text)); 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)); arrayList.add(new ThemeDescription(list, 0, new Class[]{DialogCell.class, ProfileSearchCell.class}, null, new Drawable[]{Theme.dialogs_scamDrawable}, null, Theme.key_chats_draft)); 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)); GraySectionCell.createThemeDescriptions(arrayList, list); 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)); arrayList.add(new ThemeDescription(list, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{TextCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueText2)); } 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); 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)); } } 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)); 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)); arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DrawerProfileCell.class}, null, null, null, Theme.key_chats_menuTopShadowCats)); arrayList.add(new ThemeDescription(sideMenu, ThemeDescription.FLAG_IMAGECOLOR, new Class[]{DrawerProfileCell.class}, new String[]{"darkThemeView"}, null, null, null, Theme.key_chats_menuName)); 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)); 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)); 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)); arrayList.add(new ThemeDescription(sideMenu, 0, new Class[]{DividerCell.class}, Theme.dividerPaint, null, null, Theme.key_divider)); 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)); } 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++) { arrayList.add(new ThemeDescription(undoView[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_undo_background)); 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)); 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)); if (filtersView != null) { arrayList.addAll(filtersView.getThemeDescriptions()); filtersView.updateColors(); } if (searchViewPager != null) { searchViewPager.getThemeDescriptors(arrayList); } return arrayList; } }