2016-05-25 23:49:47 +02:00
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
* This is the source code of Telegram for Android v. 5.x.x.
|
2016-05-25 23:49:47 +02:00
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
*
|
2019-01-23 18:03:33 +01:00
|
|
|
* Copyright Nikolai Kudashov, 2013-2018.
|
2016-05-25 23:49:47 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui.Components;
|
|
|
|
|
|
|
|
import android.Manifest;
|
|
|
|
import android.animation.Animator;
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
import android.animation.ObjectAnimator;
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.content.Context;
|
2018-07-30 04:07:02 +02:00
|
|
|
import android.content.Intent;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.content.pm.PackageManager;
|
2016-10-11 13:57:01 +02:00
|
|
|
import android.graphics.Canvas;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.Outline;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.graphics.Paint;
|
2016-10-11 13:57:01 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.graphics.Rect;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.graphics.RectF;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.os.Build;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.text.InputFilter;
|
|
|
|
import android.text.TextPaint;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.text.TextUtils;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.util.Property;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.view.Gravity;
|
|
|
|
import android.view.HapticFeedbackConstants;
|
2016-10-11 13:57:01 +02:00
|
|
|
import android.view.KeyEvent;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.view.ViewOutlineProvider;
|
|
|
|
import android.view.WindowManager;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.view.animation.DecelerateInterpolator;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.view.animation.OvershootInterpolator;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2017-07-08 18:32:04 +02:00
|
|
|
import org.telegram.messenger.ChatObject;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.ContactsController;
|
|
|
|
import org.telegram.messenger.FileLog;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.ImageLocation;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.MediaController;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.MediaDataController;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.messenger.MessageObject;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.MessagesController;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.R;
|
2020-04-24 11:21:58 +02:00
|
|
|
import org.telegram.messenger.SendMessagesHelper;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.UserConfig;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.UserObject;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.tgnet.TLRPC;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.ui.ActionBar.BottomSheet;
|
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2020-04-24 11:21:58 +02:00
|
|
|
import org.telegram.ui.ActionBar.ThemeDescription;
|
2016-05-25 23:49:47 +02:00
|
|
|
import org.telegram.ui.ChatActivity;
|
2020-04-24 11:21:58 +02:00
|
|
|
import org.telegram.ui.PassportActivity;
|
|
|
|
import org.telegram.ui.PhotoPickerActivity;
|
|
|
|
import org.telegram.ui.PhotoPickerSearchActivity;
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
import androidx.annotation.Keep;
|
2020-04-24 11:21:58 +02:00
|
|
|
import androidx.core.graphics.ColorUtils;
|
|
|
|
import androidx.dynamicanimation.animation.DynamicAnimation;
|
|
|
|
import androidx.dynamicanimation.animation.SpringAnimation;
|
2019-08-22 01:53:26 +02:00
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
public class ChatAttachAlert extends BottomSheet implements NotificationCenter.NotificationCenterDelegate, BottomSheet.BottomSheetDelegateInterface {
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
public interface ChatAttachViewDelegate {
|
2019-09-10 12:56:11 +02:00
|
|
|
void didPressedButton(int button, boolean arg, boolean notify, int scheduleDate);
|
2016-05-25 23:49:47 +02:00
|
|
|
View getRevealView();
|
|
|
|
void didSelectBot(TLRPC.User user);
|
2017-03-31 01:58:05 +02:00
|
|
|
void onCameraOpened();
|
2019-08-22 01:53:26 +02:00
|
|
|
void needEnterComment();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public float translationProgress;
|
|
|
|
public final Property<AttachAlertLayout, Float> ATTACH_ALERT_LAYOUT_TRANSLATION = new AnimationProperties.FloatProperty<AttachAlertLayout>("translation") {
|
|
|
|
@Override
|
|
|
|
public void setValue(AttachAlertLayout object, float value) {
|
|
|
|
if (value > 0.7f) {
|
|
|
|
float alpha = 1.0f - (1.0f - value) / 0.3f;
|
|
|
|
if (nextAttachLayout == locationLayout) {
|
|
|
|
currentAttachLayout.setAlpha(1.0f - alpha);
|
|
|
|
nextAttachLayout.setAlpha(1.0f);
|
|
|
|
} else {
|
|
|
|
nextAttachLayout.setAlpha(alpha);
|
|
|
|
nextAttachLayout.onHideShowProgress(alpha);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (nextAttachLayout == locationLayout) {
|
|
|
|
nextAttachLayout.setAlpha(0.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nextAttachLayout == pollLayout || currentAttachLayout == pollLayout) {
|
|
|
|
updateSelectedPosition(nextAttachLayout == pollLayout ? 1 : 0);
|
|
|
|
}
|
|
|
|
nextAttachLayout.setTranslationY(AndroidUtilities.dp(78) * value);
|
|
|
|
currentAttachLayout.onHideShowProgress(1.0f - Math.min(1.0f, value / 0.7f));
|
|
|
|
currentAttachLayout.onContainerTranslationUpdated();
|
|
|
|
containerView.invalidate();
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public Float get(AttachAlertLayout object) {
|
|
|
|
return translationProgress;
|
|
|
|
}
|
|
|
|
};
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public static class AttachAlertLayout extends FrameLayout {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
protected ChatAttachAlert parentAlert;
|
2020-02-13 19:26:53 +01:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public AttachAlertLayout(ChatAttachAlert alert, Context context) {
|
|
|
|
super(context);
|
|
|
|
parentAlert = alert;
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onSheetKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onDismiss() {
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onCustomMeasure(View view, int width, int height) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onCustomLayout(View view, int left, int top, int right, int bottom) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onContainerViewTouchEvent(MotionEvent event) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onPreMeasure(int availableWidth, int availableHeight) {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onMenuItemClick(int id) {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onButtonsTranslationYUpdated() {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean canScheduleMessages() {
|
|
|
|
return true;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void checkColors() {
|
2017-07-08 18:32:04 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
ArrayList<ThemeDescription> getThemeDescriptions() {
|
|
|
|
return null;
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onPause() {
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onResume() {
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean canDismissWithTouchOutside() {
|
|
|
|
return true;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onDismissWithButtonClick(int item) {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onContainerTranslationUpdated() {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onHideShowProgress(float progress) {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onOpenAnimationEnd() {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onInit(boolean mediaEnabled) {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
int getSelectedItemsCount() {
|
|
|
|
return 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onSelectedItemsCountChanged(int count) {
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void applyCaption(String text) {
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onDestroy() {
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onHide() {
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void onHidden() {
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
int getCurrentItemTop() {
|
|
|
|
return 0;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
int getFirstOffset() {
|
|
|
|
return 0;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
int getButtonsHideOffset() {
|
|
|
|
return AndroidUtilities.dp(needsActionBar() != 0 ? 12 : 17);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
|
|
|
|
int getListTopPadding() {
|
|
|
|
return 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
|
|
|
|
int needsActionBar() {
|
|
|
|
return 0;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
void sendSelectedItems(boolean notify, int scheduleDate) {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
|
|
|
|
void onShow() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void onShown() {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
|
|
|
|
void scrollToTop() {
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean onBackPressed() {
|
|
|
|
return false;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
protected BaseFragment baseFragment;
|
|
|
|
private ActionBarPopupWindow sendPopupWindow;
|
|
|
|
private ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout;
|
|
|
|
private ActionBarMenuSubItem[] itemCells;
|
|
|
|
|
|
|
|
private View shadow;
|
|
|
|
|
|
|
|
private int currentPanTranslationY;
|
|
|
|
|
|
|
|
private ChatAttachAlertPhotoLayout photoLayout;
|
|
|
|
private ChatAttachAlertContactsLayout contactsLayout;
|
|
|
|
private ChatAttachAlertAudioLayout audioLayout;
|
|
|
|
private ChatAttachAlertPollLayout pollLayout;
|
|
|
|
private ChatAttachAlertLocationLayout locationLayout;
|
|
|
|
private ChatAttachAlertDocumentLayout documentLayout;
|
|
|
|
private AttachAlertLayout[] layouts = new AttachAlertLayout[6];
|
|
|
|
private AttachAlertLayout currentAttachLayout;
|
|
|
|
private AttachAlertLayout nextAttachLayout;
|
|
|
|
|
|
|
|
private FrameLayout frameLayout2;
|
|
|
|
protected EditTextEmoji commentTextView;
|
|
|
|
private FrameLayout writeButtonContainer;
|
|
|
|
private ImageView writeButton;
|
|
|
|
private Drawable writeButtonDrawable;
|
|
|
|
private View selectedCountView;
|
|
|
|
private TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
private RectF rect = new RectF();
|
|
|
|
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
private AnimatorSet commentsAnimator;
|
|
|
|
|
|
|
|
private int selectedId;
|
|
|
|
|
|
|
|
protected float cornerRadius = 1.0f;
|
|
|
|
|
|
|
|
protected ActionBar actionBar;
|
|
|
|
private View actionBarShadow;
|
|
|
|
private AnimatorSet actionBarAnimation;
|
|
|
|
private AnimatorSet menuAnimator;
|
|
|
|
protected ActionBarMenuItem selectedMenuItem;
|
|
|
|
protected ActionBarMenuItem searchItem;
|
|
|
|
protected ActionBarMenuItem doneItem;
|
|
|
|
protected TextView selectedTextView;
|
|
|
|
private boolean menuShowed;
|
|
|
|
protected SizeNotifierFrameLayout sizeNotifierFrameLayout;
|
|
|
|
|
|
|
|
private Object viewChangeAnimator;
|
|
|
|
|
|
|
|
private boolean enterCommentEventSent;
|
|
|
|
|
|
|
|
protected RecyclerListView buttonsRecyclerView;
|
|
|
|
private LinearLayoutManager buttonsLayoutManager;
|
|
|
|
private ButtonsAdapter buttonsAdapter;
|
|
|
|
|
|
|
|
protected MessageObject editingMessageObject;
|
|
|
|
|
|
|
|
private boolean buttonPressed;
|
|
|
|
|
|
|
|
protected int currentAccount = UserConfig.selectedAccount;
|
|
|
|
|
|
|
|
private boolean mediaEnabled = true;
|
|
|
|
private boolean pollsEnabled = true;
|
|
|
|
|
|
|
|
protected int maxSelectedPhotos = -1;
|
|
|
|
protected boolean allowOrder = true;
|
|
|
|
protected boolean openWithFrontFaceCamera;
|
|
|
|
|
|
|
|
private int attachItemSize = AndroidUtilities.dp(85);
|
|
|
|
|
|
|
|
private DecelerateInterpolator decelerateInterpolator = new DecelerateInterpolator();
|
|
|
|
|
|
|
|
protected ChatAttachViewDelegate delegate;
|
|
|
|
|
|
|
|
protected int[] scrollOffsetY = new int[2];
|
|
|
|
|
|
|
|
protected boolean paused;
|
|
|
|
|
|
|
|
private Paint attachButtonPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
private class AttachButton extends FrameLayout {
|
|
|
|
|
|
|
|
private TextView textView;
|
2020-04-24 11:21:58 +02:00
|
|
|
private RLottieImageView imageView;
|
|
|
|
private boolean checked;
|
|
|
|
private String backgroundKey;
|
|
|
|
private String textKey;
|
|
|
|
private float checkedState;
|
|
|
|
private Animator checkAnimator;
|
|
|
|
private int currentId;
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
public AttachButton(Context context) {
|
|
|
|
super(context);
|
2020-04-24 11:21:58 +02:00
|
|
|
setWillNotDraw(false);
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
imageView = new RLottieImageView(context) {
|
|
|
|
@Override
|
|
|
|
public void setScaleX(float scaleX) {
|
|
|
|
super.setScaleX(scaleX);
|
|
|
|
AttachButton.this.invalidate();
|
|
|
|
}
|
|
|
|
};
|
2016-05-25 23:49:47 +02:00
|
|
|
imageView.setScaleType(ImageView.ScaleType.CENTER);
|
2020-04-24 11:21:58 +02:00
|
|
|
addView(imageView, LayoutHelper.createFrame(32, 32, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, 18, 0, 0));
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
textView = new TextView(context);
|
2019-01-23 18:03:33 +01:00
|
|
|
textView.setMaxLines(2);
|
2016-05-25 23:49:47 +02:00
|
|
|
textView.setGravity(Gravity.CENTER_HORIZONTAL);
|
|
|
|
textView.setEllipsize(TextUtils.TruncateAt.END);
|
2017-03-31 01:58:05 +02:00
|
|
|
textView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
|
2016-05-25 23:49:47 +02:00
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
2019-01-23 18:03:33 +01:00
|
|
|
textView.setLineSpacing(-AndroidUtilities.dp(2), 1.0f);
|
2020-04-24 11:21:58 +02:00
|
|
|
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 62, 0, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void updateCheckedState(boolean animate) {
|
|
|
|
if (checked == (currentId == selectedId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
checked = currentId == selectedId;
|
|
|
|
if (checkAnimator != null) {
|
|
|
|
checkAnimator.cancel();
|
|
|
|
}
|
|
|
|
if (animate) {
|
|
|
|
if (checked) {
|
|
|
|
imageView.setProgress(0.0f);
|
|
|
|
imageView.playAnimation();
|
|
|
|
}
|
|
|
|
checkAnimator = ObjectAnimator.ofFloat(this, "checkedState", checked ? 1f : 0f);
|
|
|
|
checkAnimator.setDuration(200);
|
|
|
|
checkAnimator.start();
|
|
|
|
} else {
|
|
|
|
imageView.stopAnimation();
|
|
|
|
imageView.setProgress(0.0f);
|
|
|
|
setCheckedState(checked ? 1f : 0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public void setCheckedState(float state) {
|
|
|
|
checkedState = state;
|
|
|
|
imageView.setScaleX(1.0f - 0.06f * state);
|
|
|
|
imageView.setScaleY(1.0f - 0.06f * state);
|
|
|
|
textView.setTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_dialogTextGray2), Theme.getColor(textKey), checkedState));
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public float getCheckedState() {
|
|
|
|
return checkedState;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onAttachedToWindow() {
|
|
|
|
super.onAttachedToWindow();
|
|
|
|
updateCheckedState(false);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2020-04-24 11:21:58 +02:00
|
|
|
super.onMeasure(MeasureSpec.makeMeasureSpec(attachItemSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(84), MeasureSpec.EXACTLY));
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public void setTextAndIcon(int id, CharSequence text, RLottieDrawable drawable, String background, String textColor) {
|
|
|
|
currentId = id;
|
2016-05-25 23:49:47 +02:00
|
|
|
textView.setText(text);
|
2020-04-24 11:21:58 +02:00
|
|
|
imageView.setAnimation(drawable);
|
|
|
|
backgroundKey = background;
|
|
|
|
textKey = textColor;
|
|
|
|
textView.setTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_dialogTextGray2), Theme.getColor(textKey), checkedState));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
float scale = imageView.getScaleX() + 0.06f * checkedState;
|
|
|
|
float radius = AndroidUtilities.dp(23) * scale;
|
|
|
|
|
|
|
|
float cx = imageView.getLeft() + imageView.getMeasuredWidth() / 2;
|
|
|
|
float cy = imageView.getTop() + imageView.getMeasuredWidth() / 2;
|
|
|
|
|
|
|
|
attachButtonPaint.setColor(Theme.getColor(backgroundKey));
|
|
|
|
attachButtonPaint.setStyle(Paint.Style.STROKE);
|
|
|
|
attachButtonPaint.setStrokeWidth(AndroidUtilities.dp(3) * scale);
|
|
|
|
attachButtonPaint.setAlpha(Math.round(255f * checkedState));
|
|
|
|
canvas.drawCircle(cx, cy, radius - 0.5f * attachButtonPaint.getStrokeWidth(), attachButtonPaint);
|
|
|
|
|
|
|
|
attachButtonPaint.setAlpha(255);
|
|
|
|
attachButtonPaint.setStyle(Paint.Style.FILL);
|
|
|
|
canvas.drawCircle(cx, cy, radius - AndroidUtilities.dp(5) * checkedState, attachButtonPaint);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasOverlappingRendering() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class AttachBotButton extends FrameLayout {
|
|
|
|
|
|
|
|
private BackupImageView imageView;
|
|
|
|
private TextView nameTextView;
|
|
|
|
private AvatarDrawable avatarDrawable = new AvatarDrawable();
|
|
|
|
|
|
|
|
private TLRPC.User currentUser;
|
|
|
|
|
|
|
|
public AttachBotButton(Context context) {
|
|
|
|
super(context);
|
|
|
|
|
|
|
|
imageView = new BackupImageView(context);
|
2019-08-22 01:53:26 +02:00
|
|
|
imageView.setRoundRadius(AndroidUtilities.dp(25));
|
2020-04-24 11:21:58 +02:00
|
|
|
addView(imageView, LayoutHelper.createFrame(46, 46, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 9, 0, 0));
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
View selector = new View(context);
|
2020-04-24 11:21:58 +02:00
|
|
|
selector.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 1, AndroidUtilities.dp(23)));
|
|
|
|
addView(selector, LayoutHelper.createFrame(46, 46, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 9, 0, 0));
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
nameTextView = new TextView(context);
|
|
|
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
|
|
|
|
nameTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
|
2019-08-22 01:53:26 +02:00
|
|
|
nameTextView.setLines(1);
|
|
|
|
nameTextView.setSingleLine(true);
|
2016-05-25 23:49:47 +02:00
|
|
|
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
2020-04-24 11:21:58 +02:00
|
|
|
addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 6, 60, 6, 0));
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2019-08-22 01:53:26 +02:00
|
|
|
super.onMeasure(MeasureSpec.makeMeasureSpec(attachItemSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.EXACTLY));
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setUser(TLRPC.User user) {
|
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
|
2016-05-25 23:49:47 +02:00
|
|
|
currentUser = user;
|
|
|
|
nameTextView.setText(ContactsController.formatName(user.first_name, user.last_name));
|
|
|
|
avatarDrawable.setInfo(user);
|
2019-05-14 14:08:05 +02:00
|
|
|
imageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
|
2016-05-25 23:49:47 +02:00
|
|
|
requestLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
private ArrayList<android.graphics.Rect> exclusionRects = new ArrayList<>();
|
|
|
|
private android.graphics.Rect exclustionRect = new Rect();
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public ChatAttachAlert(Context context, final BaseFragment parentFragment) {
|
2019-12-31 14:08:08 +01:00
|
|
|
super(context, false);
|
2020-04-24 11:21:58 +02:00
|
|
|
drawNavigationBar = true;
|
2019-08-22 01:53:26 +02:00
|
|
|
openInterpolator = new OvershootInterpolator(0.7f);
|
2016-10-11 13:57:01 +02:00
|
|
|
baseFragment = parentFragment;
|
2016-05-25 23:49:47 +02:00
|
|
|
setDelegate(this);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.reloadInlineHints);
|
2020-04-24 11:21:58 +02:00
|
|
|
exclusionRects.add(exclustionRect);
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2020-02-13 19:26:53 +01:00
|
|
|
sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context, false) {
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
private int lastNotifyWidth;
|
|
|
|
private RectF rect = new RectF();
|
|
|
|
private boolean ignoreLayout;
|
|
|
|
private float initialTranslationY;
|
2016-05-25 23:49:47 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.onContainerViewTouchEvent(ev)) {
|
2016-10-11 13:57:01 +02:00
|
|
|
return true;
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
|
|
|
if (ev.getAction() == MotionEvent.ACTION_DOWN && scrollOffsetY[0] != 0 && ev.getY() < scrollOffsetY[0] && actionBar.getAlpha() == 0.0f) {
|
2016-05-25 23:49:47 +02:00
|
|
|
dismiss();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onInterceptTouchEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-11 13:57:01 +02:00
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.onContainerViewTouchEvent(event)) {
|
2016-10-11 13:57:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return !isDismissed() && super.onTouchEvent(event);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2019-08-22 01:53:26 +02:00
|
|
|
int totalHeight = MeasureSpec.getSize(heightMeasureSpec);
|
2016-05-25 23:49:47 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
2019-08-22 01:53:26 +02:00
|
|
|
ignoreLayout = true;
|
|
|
|
setPadding(backgroundPaddingLeft, AndroidUtilities.statusBarHeight, backgroundPaddingLeft, 0);
|
|
|
|
ignoreLayout = false;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
int availableHeight = totalHeight - getPaddingTop();
|
2020-02-13 19:26:53 +01:00
|
|
|
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
|
2019-08-22 01:53:26 +02:00
|
|
|
if (!AndroidUtilities.isInMultiwindow && keyboardSize <= AndroidUtilities.dp(20)) {
|
|
|
|
availableHeight -= commentTextView.getEmojiPadding();
|
|
|
|
}
|
|
|
|
int availableWidth = MeasureSpec.getSize(widthMeasureSpec) - backgroundPaddingLeft * 2;
|
2020-04-24 11:21:58 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
selectedMenuItem.setAdditionalYOffset(-AndroidUtilities.dp(3));
|
|
|
|
} else if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
|
|
|
|
selectedMenuItem.setAdditionalYOffset(0);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedMenuItem.setAdditionalYOffset(-AndroidUtilities.dp(3));
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
LayoutParams layoutParams = (LayoutParams) actionBarShadow.getLayoutParams();
|
2019-08-22 01:53:26 +02:00
|
|
|
layoutParams.topMargin = ActionBar.getCurrentActionBarHeight();
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
layoutParams = (LayoutParams) doneItem.getLayoutParams();
|
|
|
|
layoutParams.height = ActionBar.getCurrentActionBarHeight();
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
ignoreLayout = true;
|
2020-04-24 11:21:58 +02:00
|
|
|
int newSize = (int) (availableWidth / Math.min(4.5f, buttonsAdapter.getItemCount()));
|
2019-08-22 01:53:26 +02:00
|
|
|
if (attachItemSize != newSize) {
|
|
|
|
attachItemSize = newSize;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> buttonsAdapter.notifyDataSetChanged());
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onPreMeasure(availableWidth, availableHeight);
|
|
|
|
if (nextAttachLayout != null) {
|
|
|
|
nextAttachLayout.onPreMeasure(availableWidth, availableHeight);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
ignoreLayout = false;
|
|
|
|
onMeasureInternal(widthMeasureSpec, MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
|
|
|
|
private void onMeasureInternal(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
|
|
|
|
setMeasuredDimension(widthSize, heightSize);
|
|
|
|
widthSize -= backgroundPaddingLeft * 2;
|
|
|
|
|
2020-02-13 19:26:53 +01:00
|
|
|
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
|
2019-08-22 01:53:26 +02:00
|
|
|
if (keyboardSize <= AndroidUtilities.dp(20)) {
|
|
|
|
if (!AndroidUtilities.isInMultiwindow) {
|
|
|
|
heightSize -= commentTextView.getEmojiPadding();
|
|
|
|
heightMeasureSpec = MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY);
|
|
|
|
}
|
|
|
|
} else {
|
2016-06-24 12:27:15 +02:00
|
|
|
ignoreLayout = true;
|
2019-08-22 01:53:26 +02:00
|
|
|
commentTextView.hideEmojiView();
|
2016-06-24 12:27:15 +02:00
|
|
|
ignoreLayout = false;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
int childCount = getChildCount();
|
|
|
|
for (int i = 0; i < childCount; i++) {
|
|
|
|
View child = getChildAt(i);
|
|
|
|
if (child == null || child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (commentTextView != null && commentTextView.isPopupView(child)) {
|
|
|
|
if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
|
|
|
|
} else {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
|
|
|
}
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-08-22 01:53:26 +02:00
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
if (lastNotifyWidth != r - l) {
|
|
|
|
lastNotifyWidth = r - l;
|
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final int count = getChildCount();
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
|
|
exclustionRect.set(l, t, r, b);
|
|
|
|
setSystemGestureExclusionRects(exclusionRects);
|
|
|
|
}
|
|
|
|
|
2020-02-13 19:26:53 +01:00
|
|
|
int keyboardSize = useSmoothKeyboard ? 0 : getKeyboardHeight();
|
|
|
|
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? commentTextView.getEmojiPadding() : 0;
|
2019-08-22 01:53:26 +02:00
|
|
|
setBottomClip(paddingBottom);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
final View child = getChildAt(i);
|
|
|
|
if (child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
|
|
|
|
|
|
|
final int width = child.getMeasuredWidth();
|
|
|
|
final int height = child.getMeasuredHeight();
|
|
|
|
|
|
|
|
int childLeft;
|
|
|
|
int childTop;
|
|
|
|
|
|
|
|
int gravity = lp.gravity;
|
|
|
|
if (gravity == -1) {
|
|
|
|
gravity = Gravity.TOP | Gravity.LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
|
|
|
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
|
|
|
|
|
|
|
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
|
|
|
case Gravity.CENTER_HORIZONTAL:
|
|
|
|
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.RIGHT:
|
|
|
|
childLeft = (r - l) - width - lp.rightMargin - getPaddingRight() - backgroundPaddingLeft;
|
|
|
|
break;
|
|
|
|
case Gravity.LEFT:
|
|
|
|
default:
|
|
|
|
childLeft = lp.leftMargin + getPaddingLeft();
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
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;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
if (commentTextView != null && commentTextView.isPopupView(child)) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
childTop = getMeasuredHeight() - child.getMeasuredHeight();
|
|
|
|
} else {
|
2020-02-13 19:26:53 +01:00
|
|
|
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
notifyHeightChanged();
|
2020-04-24 11:21:58 +02:00
|
|
|
updateLayout(currentAttachLayout, false);
|
|
|
|
updateLayout(nextAttachLayout, false);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestLayout() {
|
|
|
|
if (ignoreLayout) {
|
|
|
|
return;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
super.requestLayout();
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
@Override
|
2020-04-24 11:21:58 +02:00
|
|
|
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
|
|
|
if (child instanceof AttachAlertLayout && child.getAlpha() > 0.0f) {
|
|
|
|
int viewAlpha = (int) (255 * child.getAlpha());
|
|
|
|
AttachAlertLayout layout = (AttachAlertLayout) child;
|
|
|
|
int actionBarType = layout.needsActionBar();
|
|
|
|
|
|
|
|
int offset = AndroidUtilities.dp(13) + (selectedTextView != null ? AndroidUtilities.dp(selectedTextView.getAlpha() * 26) : 0);
|
|
|
|
int top = scrollOffsetY[layout == currentAttachLayout ? 0 : 1] - backgroundPaddingTop - offset;
|
|
|
|
if (currentSheetAnimationType == 1 || viewChangeAnimator != null) {
|
|
|
|
top += child.getTranslationY();
|
|
|
|
}
|
|
|
|
int y = top + AndroidUtilities.dp(20);
|
|
|
|
|
|
|
|
int height = getMeasuredHeight() + AndroidUtilities.dp(45) + backgroundPaddingTop;
|
|
|
|
float rad = 1.0f;
|
|
|
|
|
|
|
|
int h = (actionBarType != 0 ? ActionBar.getCurrentActionBarHeight() : backgroundPaddingTop);
|
|
|
|
if (actionBarType == 2) {
|
|
|
|
if (top < h) {
|
|
|
|
rad = Math.max(0, 1.0f - (h - top) / (float) backgroundPaddingTop);
|
|
|
|
}
|
|
|
|
} else if (top + backgroundPaddingTop < h) {
|
|
|
|
float toMove = offset;
|
|
|
|
if (layout == locationLayout) {
|
|
|
|
toMove += AndroidUtilities.dp(11);
|
|
|
|
} else if (layout == pollLayout) {
|
|
|
|
toMove -= AndroidUtilities.dp(3);
|
|
|
|
} else {
|
|
|
|
toMove += AndroidUtilities.dp(4);
|
|
|
|
}
|
|
|
|
float moveProgress = Math.min(1.0f, (h - top - backgroundPaddingTop) / toMove);
|
|
|
|
float availableToMove = h - toMove;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
int diff = (int) (availableToMove * moveProgress);
|
|
|
|
top -= diff;
|
|
|
|
y -= diff;
|
|
|
|
height += diff;
|
|
|
|
rad = 1.0f - moveProgress;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
top += AndroidUtilities.statusBarHeight;
|
|
|
|
y += AndroidUtilities.statusBarHeight;
|
|
|
|
height -= AndroidUtilities.statusBarHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
shadowDrawable.setAlpha(viewAlpha);
|
|
|
|
shadowDrawable.setBounds(0, top, getMeasuredWidth(), height);
|
|
|
|
shadowDrawable.draw(canvas);
|
|
|
|
if (actionBarType == 2) {
|
|
|
|
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
|
|
|
|
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(rect.left, rect.top, rect.right, rect.top + rect.height() / 2);
|
|
|
|
canvas.drawRoundRect(rect, AndroidUtilities.dp(12) * rad, AndroidUtilities.dp(12) * rad, Theme.dialogs_onlineCirclePaint);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean result = super.drawChild(canvas, child, drawingTime);
|
|
|
|
|
|
|
|
if (rad != 1.0f && actionBarType != 2) {
|
|
|
|
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
|
|
|
|
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(rect.left, rect.top, rect.right, rect.top + rect.height() / 2);
|
|
|
|
canvas.drawRoundRect(rect, AndroidUtilities.dp(12) * rad, AndroidUtilities.dp(12) * rad, Theme.dialogs_onlineCirclePaint);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((selectedTextView == null || selectedTextView.getAlpha() != 1.0f) && rad != 0) {
|
|
|
|
int w = AndroidUtilities.dp(36);
|
|
|
|
rect.set((getMeasuredWidth() - w) / 2, y, (getMeasuredWidth() + w) / 2, y + AndroidUtilities.dp(4));
|
|
|
|
int color;
|
|
|
|
float alphaProgress;
|
|
|
|
if (actionBarType == 2) {
|
|
|
|
color = 0x20000000;
|
|
|
|
alphaProgress = rad;
|
|
|
|
} else {
|
|
|
|
color = Theme.getColor(Theme.key_sheet_scrollUp);
|
|
|
|
alphaProgress = selectedTextView == null ? 1.0f : 1.0f - selectedTextView.getAlpha();
|
|
|
|
}
|
|
|
|
int alpha = Color.alpha(color);
|
|
|
|
Theme.dialogs_onlineCirclePaint.setColor(color);
|
|
|
|
Theme.dialogs_onlineCirclePaint.setAlpha((int) (alpha * alphaProgress * rad * child.getAlpha()));
|
|
|
|
canvas.drawRoundRect(rect, AndroidUtilities.dp(2), AndroidUtilities.dp(2), Theme.dialogs_onlineCirclePaint);
|
|
|
|
}
|
|
|
|
return result;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
return super.drawChild(canvas, child, drawingTime);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2019-08-22 01:53:26 +02:00
|
|
|
int color1 = Theme.getColor(Theme.key_dialogBackground);
|
|
|
|
int finalColor = Color.argb((int) (255 * actionBar.getAlpha()), (int) (Color.red(color1) * 0.8f), (int) (Color.green(color1) * 0.8f), (int) (Color.blue(color1) * 0.8f));
|
|
|
|
Theme.dialogs_onlineCirclePaint.setColor(finalColor);
|
|
|
|
canvas.drawRect(backgroundPaddingLeft, 0, getMeasuredWidth() - backgroundPaddingLeft, AndroidUtilities.statusBarHeight, Theme.dialogs_onlineCirclePaint);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
if (currentSheetAnimationType == 0) {
|
|
|
|
initialTranslationY = translationY;
|
|
|
|
}
|
|
|
|
if (currentSheetAnimationType == 1) {
|
|
|
|
if (translationY < 0) {
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.setTranslationY(translationY);
|
2019-08-22 01:53:26 +02:00
|
|
|
translationY = 0;
|
|
|
|
buttonsRecyclerView.setTranslationY(0);
|
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.setTranslationY(0);
|
2019-08-22 01:53:26 +02:00
|
|
|
buttonsRecyclerView.setTranslationY(-translationY + buttonsRecyclerView.getMeasuredHeight() * (translationY / initialTranslationY));
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
containerView.invalidate();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
super.setTranslationY(translationY);
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentSheetAnimationType != 1) {
|
|
|
|
currentAttachLayout.onContainerTranslationUpdated();
|
2020-02-13 19:26:53 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
};
|
|
|
|
containerView = sizeNotifierFrameLayout;
|
|
|
|
containerView.setWillNotDraw(false);
|
|
|
|
containerView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, 0);
|
|
|
|
|
|
|
|
actionBar = new ActionBar(context) {
|
2016-05-25 23:49:47 +02:00
|
|
|
@Override
|
2019-08-22 01:53:26 +02:00
|
|
|
public void setAlpha(float alpha) {
|
|
|
|
super.setAlpha(alpha);
|
|
|
|
containerView.invalidate();
|
|
|
|
if (frameLayout2 != null && buttonsRecyclerView != null) {
|
|
|
|
if (frameLayout2.getTag() == null) {
|
|
|
|
buttonsRecyclerView.setAlpha(1.0f - alpha);
|
|
|
|
shadow.setAlpha(1.0f - alpha);
|
|
|
|
buttonsRecyclerView.setTranslationY(AndroidUtilities.dp(44) * alpha);
|
|
|
|
frameLayout2.setTranslationY(AndroidUtilities.dp(48) * alpha);
|
2020-04-24 11:21:58 +02:00
|
|
|
shadow.setTranslationY(AndroidUtilities.dp(84) * alpha);
|
2016-05-25 23:49:47 +02:00
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
float value = alpha == 0.0f ? 1.0f : 0.0f;
|
|
|
|
if (buttonsRecyclerView.getAlpha() != value) {
|
|
|
|
buttonsRecyclerView.setAlpha(value);
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
|
|
|
actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
|
|
|
|
actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
actionBar.setOccupyStatusBar(false);
|
|
|
|
actionBar.setAlpha(0.0f);
|
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.onBackPressed()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
dismiss();
|
2016-06-24 12:27:15 +02:00
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onMenuItemClick(id);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
});
|
2016-10-11 13:57:01 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
selectedMenuItem = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_dialogTextBlack));
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedMenuItem.setLongClickEnabled(false);
|
|
|
|
selectedMenuItem.setIcon(R.drawable.ic_ab_other);
|
|
|
|
selectedMenuItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
|
|
|
|
selectedMenuItem.setVisibility(View.INVISIBLE);
|
|
|
|
selectedMenuItem.setAlpha(0.0f);
|
|
|
|
selectedMenuItem.setSubMenuOpenSide(2);
|
|
|
|
selectedMenuItem.setDelegate(id -> actionBar.getActionBarMenuOnItemClick().onItemClick(id));
|
|
|
|
selectedMenuItem.setAdditionalYOffset(AndroidUtilities.dp(72));
|
|
|
|
selectedMenuItem.setTranslationX(AndroidUtilities.dp(6));
|
|
|
|
selectedMenuItem.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 6));
|
|
|
|
selectedMenuItem.setOnClickListener(v -> selectedMenuItem.toggleSubMenu());
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
doneItem = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader), true);
|
|
|
|
doneItem.setLongClickEnabled(false);
|
|
|
|
doneItem.setText(LocaleController.getString("Create", R.string.Create).toUpperCase());
|
|
|
|
doneItem.setVisibility(View.INVISIBLE);
|
|
|
|
doneItem.setAlpha(0.0f);
|
|
|
|
doneItem.setTranslationX(-AndroidUtilities.dp(12));
|
|
|
|
doneItem.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 3));
|
|
|
|
doneItem.setOnClickListener(v -> currentAttachLayout.onMenuItemClick(40));
|
|
|
|
|
|
|
|
searchItem = new ActionBarMenuItem(context, null, 0, Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
searchItem.setLongClickEnabled(false);
|
|
|
|
searchItem.setIcon(R.drawable.ic_ab_search);
|
|
|
|
searchItem.setContentDescription(LocaleController.getString("Search", R.string.Search));
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
|
|
|
searchItem.setAlpha(0.0f);
|
|
|
|
searchItem.setTranslationX(-AndroidUtilities.dp(42));
|
|
|
|
searchItem.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_dialogButtonSelector), 6));
|
|
|
|
searchItem.setOnClickListener(v -> {
|
|
|
|
final HashMap<Object, Object> photos = new HashMap<>();
|
|
|
|
final ArrayList<Object> order = new ArrayList<>();
|
|
|
|
PhotoPickerSearchActivity fragment = new PhotoPickerSearchActivity(photos, order, 0, true, (ChatActivity) baseFragment);
|
|
|
|
fragment.setDelegate(new PhotoPickerActivity.PhotoPickerActivityDelegate() {
|
|
|
|
|
|
|
|
private boolean sendPressed;
|
2016-06-24 12:27:15 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public void selectedPhotosChanged() {
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public void actionButtonPressed(boolean canceled, boolean notify, int scheduleDate) {
|
|
|
|
if (canceled) {
|
|
|
|
return;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (photos.isEmpty() || sendPressed) {
|
|
|
|
return;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
sendPressed = true;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
ArrayList<SendMessagesHelper.SendingMediaInfo> media = new ArrayList<>();
|
|
|
|
for (int a = 0; a < order.size(); a++) {
|
|
|
|
Object object = photos.get(order.get(a));
|
|
|
|
SendMessagesHelper.SendingMediaInfo info = new SendMessagesHelper.SendingMediaInfo();
|
|
|
|
media.add(info);
|
|
|
|
MediaController.SearchImage searchImage = (MediaController.SearchImage) object;
|
|
|
|
if (searchImage.imagePath != null) {
|
|
|
|
info.path = searchImage.imagePath;
|
|
|
|
} else {
|
|
|
|
info.searchImage = searchImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
info.caption = searchImage.caption != null ? searchImage.caption.toString() : null;
|
|
|
|
info.entities = searchImage.entities;
|
|
|
|
info.masks = !searchImage.stickers.isEmpty() ? new ArrayList<>(searchImage.stickers) : null;
|
|
|
|
info.ttl = searchImage.ttl;
|
|
|
|
if (searchImage.inlineResult != null && searchImage.type == 1) {
|
|
|
|
info.inlineResult = searchImage.inlineResult;
|
|
|
|
info.params = searchImage.params;
|
|
|
|
}
|
|
|
|
|
|
|
|
searchImage.date = (int) (System.currentTimeMillis() / 1000);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
((ChatActivity) baseFragment).didSelectSearchPhotos(media, notify, scheduleDate);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public void onCaptionChanged(CharSequence text) {
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
});
|
|
|
|
fragment.setMaxSelectedPhotos(maxSelectedPhotos, allowOrder);
|
|
|
|
parentFragment.presentFragment(fragment);
|
|
|
|
dismiss();
|
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
selectedTextView = new TextView(context) {
|
2019-09-10 12:56:11 +02:00
|
|
|
@Override
|
2020-04-24 11:21:58 +02:00
|
|
|
public void setAlpha(float alpha) {
|
|
|
|
super.setAlpha(alpha);
|
|
|
|
updateSelectedPosition(0);
|
|
|
|
containerView.invalidate();
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
};
|
|
|
|
selectedTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
selectedTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
selectedTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
selectedTextView.setGravity(Gravity.LEFT | Gravity.TOP);
|
|
|
|
selectedTextView.setVisibility(View.INVISIBLE);
|
|
|
|
selectedTextView.setAlpha(0.0f);
|
2019-09-10 12:56:11 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
layouts[0] = photoLayout = new ChatAttachAlertPhotoLayout(this, context);
|
|
|
|
currentAttachLayout = photoLayout;
|
|
|
|
selectedId = 1;
|
|
|
|
containerView.addView(photoLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2019-09-10 12:56:11 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
containerView.addView(selectedTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 23, 0, 48, 0));
|
|
|
|
containerView.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
|
|
|
|
containerView.addView(selectedMenuItem, LayoutHelper.createFrame(48, 48, Gravity.TOP | Gravity.RIGHT));
|
|
|
|
containerView.addView(searchItem, LayoutHelper.createFrame(48, 48, Gravity.TOP | Gravity.RIGHT));
|
|
|
|
containerView.addView(doneItem, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 48, Gravity.TOP | Gravity.RIGHT));
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
actionBarShadow = new View(context);
|
|
|
|
actionBarShadow.setAlpha(0.0f);
|
|
|
|
actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));
|
|
|
|
containerView.addView(actionBarShadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 1));
|
|
|
|
|
|
|
|
shadow = new View(context);
|
2020-04-24 11:21:58 +02:00
|
|
|
shadow.setBackgroundResource(R.drawable.attach_shadow);
|
|
|
|
shadow.getBackground().setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
|
|
|
|
containerView.addView(shadow, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 2, Gravity.BOTTOM | Gravity.LEFT, 0, 0, 0, 84));
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
buttonsRecyclerView = new RecyclerListView(context) {
|
2016-05-25 23:49:47 +02:00
|
|
|
@Override
|
2019-08-22 01:53:26 +02:00
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onButtonsTranslationYUpdated();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
};
|
2019-08-22 01:53:26 +02:00
|
|
|
buttonsRecyclerView.setAdapter(buttonsAdapter = new ButtonsAdapter(context));
|
|
|
|
buttonsRecyclerView.setLayoutManager(buttonsLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
|
|
|
|
buttonsRecyclerView.setVerticalScrollBarEnabled(false);
|
|
|
|
buttonsRecyclerView.setHorizontalScrollBarEnabled(false);
|
|
|
|
buttonsRecyclerView.setItemAnimator(null);
|
|
|
|
buttonsRecyclerView.setLayoutAnimation(null);
|
|
|
|
buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
|
|
|
|
buttonsRecyclerView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
2020-04-24 11:21:58 +02:00
|
|
|
containerView.addView(buttonsRecyclerView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 84, Gravity.BOTTOM | Gravity.LEFT));
|
2019-08-22 01:53:26 +02:00
|
|
|
buttonsRecyclerView.setOnItemClickListener((view, position) -> {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (baseFragment.getParentActivity() == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (view instanceof AttachButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
int num = (Integer) view.getTag();
|
|
|
|
if (num == 1) {
|
|
|
|
showLayout(photoLayout);
|
|
|
|
} else if (num == 3) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
openAudioLayout();
|
|
|
|
} else if (num == 4) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
openDocumentsLayout();
|
|
|
|
} else if (num == 5) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
|
|
if (baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, 5);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
openContactsLayout();
|
|
|
|
} else if (num == 6) {
|
|
|
|
if (!AndroidUtilities.isGoogleMapsInstalled(parentFragment)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (locationLayout == null) {
|
|
|
|
layouts[5] = locationLayout = new ChatAttachAlertLocationLayout(this, getContext());
|
|
|
|
locationLayout.setDelegate((location, live, notify, scheduleDate) -> ((ChatActivity) baseFragment).didSelectLocation(location, live, notify, scheduleDate));
|
|
|
|
}
|
|
|
|
showLayout(locationLayout);
|
|
|
|
} else if (num == 9) {
|
|
|
|
if (pollLayout == null) {
|
|
|
|
layouts[1] = pollLayout = new ChatAttachAlertPollLayout(this, getContext());
|
|
|
|
pollLayout.setDelegate((poll, params, notify, scheduleDate) -> ((ChatActivity) baseFragment).sendPoll(poll, params, notify, scheduleDate));
|
|
|
|
}
|
|
|
|
showLayout(pollLayout);
|
|
|
|
} else {
|
|
|
|
delegate.didPressedButton((Integer) view.getTag(), true, true, 0);
|
|
|
|
}
|
|
|
|
int left = view.getLeft();
|
|
|
|
int right = view.getRight();
|
|
|
|
int extra = AndroidUtilities.dp(10);
|
|
|
|
if (left - extra < 0) {
|
|
|
|
buttonsRecyclerView.smoothScrollBy(left - extra, 0);
|
|
|
|
} else if (right + extra > buttonsRecyclerView.getMeasuredWidth()) {
|
|
|
|
buttonsRecyclerView.smoothScrollBy(right + extra - buttonsRecyclerView.getMeasuredWidth(), 0);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (view instanceof AttachBotButton) {
|
|
|
|
AttachBotButton button = (AttachBotButton) view;
|
|
|
|
delegate.didSelectBot(button.currentUser);
|
|
|
|
dismiss();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
buttonsRecyclerView.setOnItemLongClickListener((view, position) -> {
|
|
|
|
if (view instanceof AttachBotButton) {
|
|
|
|
AttachBotButton button = (AttachBotButton) view;
|
|
|
|
if (baseFragment == null || button.currentUser == null) {
|
|
|
|
return false;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.formatString("ChatHintsDelete", R.string.ChatHintsDelete, ContactsController.formatName(button.currentUser.first_name, button.currentUser.last_name)));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> MediaDataController.getInstance(currentAccount).removeInline(button.currentUser.id));
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
builder.show();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
frameLayout2 = new FrameLayout(context);
|
|
|
|
frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
frameLayout2.setVisibility(View.INVISIBLE);
|
|
|
|
frameLayout2.setAlpha(0.0f);
|
|
|
|
containerView.addView(frameLayout2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.BOTTOM));
|
|
|
|
frameLayout2.setOnTouchListener((v, event) -> true);
|
|
|
|
|
|
|
|
commentTextView = new EditTextEmoji(context, sizeNotifierFrameLayout, null, EditTextEmoji.STYLE_DIALOG) {
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
|
|
if (!enterCommentEventSent) {
|
2020-04-24 11:21:58 +02:00
|
|
|
makeFocusable(commentTextView.getEditText());
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
return super.onInterceptTouchEvent(ev);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
InputFilter[] inputFilters = new InputFilter[1];
|
|
|
|
inputFilters[0] = new InputFilter.LengthFilter(MessagesController.getInstance(UserConfig.selectedAccount).maxCaptionLength);
|
|
|
|
commentTextView.setFilters(inputFilters);
|
|
|
|
commentTextView.setHint(LocaleController.getString("AddCaption", R.string.AddCaption));
|
|
|
|
commentTextView.onResume();
|
|
|
|
EditTextBoldCursor editText = commentTextView.getEditText();
|
|
|
|
editText.setMaxLines(1);
|
|
|
|
editText.setSingleLine(true);
|
|
|
|
frameLayout2.addView(commentTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 84, 0));
|
|
|
|
|
|
|
|
writeButtonContainer = new FrameLayout(context);
|
|
|
|
writeButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
writeButtonContainer.setScaleX(0.2f);
|
|
|
|
writeButtonContainer.setScaleY(0.2f);
|
|
|
|
writeButtonContainer.setAlpha(0.0f);
|
|
|
|
writeButtonContainer.setContentDescription(LocaleController.getString("Send", R.string.Send));
|
|
|
|
containerView.addView(writeButtonContainer, LayoutHelper.createFrame(60, 60, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, 6, 10));
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
writeButton = new ImageView(context);
|
|
|
|
writeButtonDrawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_dialogFloatingButton), Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton));
|
|
|
|
if (Build.VERSION.SDK_INT < 21) {
|
|
|
|
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow_profile).mutate();
|
|
|
|
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
|
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, writeButtonDrawable, 0, 0);
|
|
|
|
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
writeButtonDrawable = combinedDrawable;
|
|
|
|
}
|
|
|
|
writeButton.setBackgroundDrawable(writeButtonDrawable);
|
|
|
|
writeButton.setImageResource(R.drawable.attach_send);
|
|
|
|
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
|
|
|
|
writeButton.setScaleType(ImageView.ScaleType.CENTER);
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
writeButton.setOutlineProvider(new ViewOutlineProvider() {
|
|
|
|
@SuppressLint("NewApi")
|
|
|
|
@Override
|
|
|
|
public void getOutline(View view, Outline outline) {
|
|
|
|
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
writeButtonContainer.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.LEFT | Gravity.TOP, Build.VERSION.SDK_INT >= 21 ? 2 : 0, 0, 0, 0));
|
|
|
|
writeButton.setOnClickListener(v -> {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (editingMessageObject == null && parentFragment instanceof ChatActivity && ((ChatActivity) parentFragment).isInScheduleMode()) {
|
2020-04-24 11:21:58 +02:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(getContext(), ((ChatActivity) parentFragment).getDialogId(), (notify, scheduleDate) -> {
|
|
|
|
if (currentAttachLayout == photoLayout) {
|
|
|
|
sendPressed(notify, scheduleDate);
|
|
|
|
} else {
|
|
|
|
currentAttachLayout.sendSelectedItems(notify, scheduleDate);
|
|
|
|
dismiss();
|
|
|
|
}
|
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout == photoLayout) {
|
|
|
|
sendPressed(true, 0);
|
|
|
|
} else {
|
|
|
|
currentAttachLayout.sendSelectedItems(true, 0);
|
|
|
|
dismiss();
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
});
|
2019-12-31 14:08:08 +01:00
|
|
|
writeButton.setOnLongClickListener(view -> {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (!(baseFragment instanceof ChatActivity) || editingMessageObject != null) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ChatActivity chatActivity = (ChatActivity) baseFragment;
|
|
|
|
TLRPC.Chat chat = chatActivity.getCurrentChat();
|
|
|
|
TLRPC.User user = chatActivity.getCurrentUser();
|
2019-09-10 12:56:11 +02:00
|
|
|
if (chatActivity.getCurrentEncryptedChat() != null || chatActivity.isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
sendPopupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext());
|
|
|
|
sendPopupLayout.setAnimationEnabled(false);
|
|
|
|
sendPopupLayout.setOnTouchListener(new View.OnTouchListener() {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
private android.graphics.Rect popupRect = new android.graphics.Rect();
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
@Override
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
v.getHitRect(popupRect);
|
|
|
|
if (!popupRect.contains((int) event.getX(), (int) event.getY())) {
|
|
|
|
sendPopupWindow.dismiss();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sendPopupLayout.setDispatchKeyEventListener(keyEvent -> {
|
|
|
|
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sendPopupLayout.setShowedFromBotton(false);
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
itemCells = new ActionBarMenuSubItem[2];
|
|
|
|
int i = 0;
|
|
|
|
for (int a = 0; a < 2; a++) {
|
|
|
|
if (a == 0) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (!currentAttachLayout.canScheduleMessages()) {
|
2019-09-10 12:56:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else if (a == 1 && UserObject.isUserSelf(user)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int num = a;
|
|
|
|
itemCells[a] = new ActionBarMenuSubItem(getContext());
|
|
|
|
if (num == 0) {
|
|
|
|
if (UserObject.isUserSelf(user)) {
|
|
|
|
itemCells[a].setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.msg_schedule);
|
|
|
|
} else {
|
|
|
|
itemCells[a].setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.msg_schedule);
|
|
|
|
}
|
|
|
|
} else if (num == 1) {
|
|
|
|
itemCells[a].setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
|
|
|
|
}
|
|
|
|
itemCells[a].setMinimumWidth(AndroidUtilities.dp(196));
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
sendPopupLayout.addView(itemCells[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 48 * i, 0, 0));
|
|
|
|
itemCells[a].setOnClickListener(v -> {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupWindow.dismiss();
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (num == 0) {
|
2020-04-24 11:21:58 +02:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(getContext(), chatActivity.getDialogId(), (notify, scheduleDate) -> {
|
|
|
|
if (currentAttachLayout == photoLayout) {
|
|
|
|
sendPressed(notify, scheduleDate);
|
|
|
|
} else {
|
|
|
|
currentAttachLayout.sendSelectedItems(notify, scheduleDate);
|
|
|
|
dismiss();
|
|
|
|
}
|
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
} else if (num == 1) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout == photoLayout) {
|
|
|
|
sendPressed(false, 0);
|
|
|
|
} else {
|
|
|
|
currentAttachLayout.sendSelectedItems(false, 0);
|
|
|
|
dismiss();
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
i++;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
sendPopupWindow = new ActionBarPopupWindow(sendPopupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT);
|
|
|
|
sendPopupWindow.setAnimationEnabled(false);
|
|
|
|
sendPopupWindow.setAnimationStyle(R.style.PopupContextAnimation2);
|
|
|
|
sendPopupWindow.setOutsideTouchable(true);
|
|
|
|
sendPopupWindow.setClippingEnabled(true);
|
|
|
|
sendPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
|
|
|
|
sendPopupWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
|
|
|
|
sendPopupWindow.getContentView().setFocusableInTouchMode(true);
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
sendPopupLayout.measure(View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), View.MeasureSpec.AT_MOST));
|
|
|
|
sendPopupWindow.setFocusable(true);
|
|
|
|
int[] location = new int[2];
|
|
|
|
view.getLocationInWindow(location);
|
|
|
|
sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2));
|
|
|
|
sendPopupWindow.dimBehind();
|
|
|
|
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
textPaint.setTextSize(AndroidUtilities.dp(12));
|
|
|
|
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedCountView = new View(context) {
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2020-04-24 11:21:58 +02:00
|
|
|
String text = String.format("%d", Math.max(1, currentAttachLayout.getSelectedItemsCount()));
|
2019-08-22 01:53:26 +02:00
|
|
|
int textSize = (int) Math.ceil(textPaint.measureText(text));
|
|
|
|
int size = Math.max(AndroidUtilities.dp(16) + textSize, AndroidUtilities.dp(24));
|
|
|
|
int cx = getMeasuredWidth() / 2;
|
|
|
|
int cy = getMeasuredHeight() / 2;
|
|
|
|
|
|
|
|
textPaint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBoxCheck));
|
|
|
|
paint.setColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
rect.set(cx - size / 2, 0, cx + size / 2, getMeasuredHeight());
|
|
|
|
canvas.drawRoundRect(rect, AndroidUtilities.dp(12), AndroidUtilities.dp(12), paint);
|
|
|
|
|
|
|
|
paint.setColor(Theme.getColor(Theme.key_dialogRoundCheckBox));
|
|
|
|
rect.set(cx - size / 2 + AndroidUtilities.dp(2), AndroidUtilities.dp(2), cx + size / 2 - AndroidUtilities.dp(2), getMeasuredHeight() - AndroidUtilities.dp(2));
|
|
|
|
canvas.drawRoundRect(rect, AndroidUtilities.dp(10), AndroidUtilities.dp(10), paint);
|
|
|
|
|
|
|
|
canvas.drawText(text, cx - textSize / 2, AndroidUtilities.dp(16.2f), textPaint);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
selectedCountView.setAlpha(0.0f);
|
|
|
|
selectedCountView.setScaleX(0.2f);
|
|
|
|
selectedCountView.setScaleY(0.2f);
|
|
|
|
containerView.addView(selectedCountView, LayoutHelper.createFrame(42, 24, Gravity.RIGHT | Gravity.BOTTOM, 0, 0, -8, 9));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void show() {
|
|
|
|
super.show();
|
|
|
|
buttonPressed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEditingMessageObject(MessageObject messageObject) {
|
|
|
|
if (editingMessageObject == messageObject) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
editingMessageObject = messageObject;
|
|
|
|
if (editingMessageObject != null) {
|
|
|
|
maxSelectedPhotos = 1;
|
2019-08-22 01:53:26 +02:00
|
|
|
allowOrder = false;
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
|
|
|
maxSelectedPhotos = -1;
|
2019-08-22 01:53:26 +02:00
|
|
|
allowOrder = true;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
buttonsAdapter.notifyDataSetChanged();
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public MessageObject getEditingMessageObject() {
|
|
|
|
return editingMessageObject;
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
protected void applyCaption() {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (commentTextView.length() <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.applyCaption(commentTextView.getText().toString());
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
private void sendPressed(boolean notify, int scheduleDate) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (buttonPressed) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
if (baseFragment instanceof ChatActivity) {
|
2019-08-22 01:53:26 +02:00
|
|
|
ChatActivity chatActivity = (ChatActivity) baseFragment;
|
|
|
|
TLRPC.Chat chat = chatActivity.getCurrentChat();
|
|
|
|
TLRPC.User user = chatActivity.getCurrentUser();
|
|
|
|
if (user != null || ChatObject.isChannel(chat) && chat.megagroup || !ChatObject.isChannel(chat)) {
|
2019-09-10 12:56:11 +02:00
|
|
|
MessagesController.getNotificationsSettings(currentAccount).edit().putBoolean("silent_" + chatActivity.getDialogId(), !notify).commit();
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
applyCaption();
|
|
|
|
buttonPressed = true;
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.didPressedButton(7, true, notify, scheduleDate);
|
2019-01-23 18:03:33 +01:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
private void showLayout(AttachAlertLayout layout) {
|
|
|
|
if (viewChangeAnimator != null || commentsAnimator != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout == layout) {
|
|
|
|
currentAttachLayout.scrollToTop();
|
|
|
|
return;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (layout == photoLayout) {
|
|
|
|
selectedId = 1;
|
|
|
|
} else if (layout == audioLayout) {
|
|
|
|
selectedId = 3;
|
|
|
|
} else if (layout == documentLayout) {
|
|
|
|
selectedId = 4;
|
|
|
|
} else if (layout == contactsLayout) {
|
|
|
|
selectedId = 5;
|
|
|
|
} else if (layout == locationLayout) {
|
|
|
|
selectedId = 6;
|
|
|
|
} else if (layout == pollLayout) {
|
|
|
|
selectedId = 9;
|
|
|
|
}
|
|
|
|
int count = buttonsRecyclerView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View child = buttonsRecyclerView.getChildAt(a);
|
|
|
|
if (child instanceof AttachButton) {
|
|
|
|
AttachButton attachButton = (AttachButton) child;
|
|
|
|
attachButton.updateCheckedState(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int t = currentAttachLayout.getFirstOffset() - AndroidUtilities.dp(11) - scrollOffsetY[0];
|
|
|
|
nextAttachLayout = layout;
|
|
|
|
if (Build.VERSION.SDK_INT >= 20) {
|
|
|
|
container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
|
|
}
|
|
|
|
actionBar.setVisibility(nextAttachLayout.needsActionBar() != 0 ? View.VISIBLE : View.INVISIBLE);
|
|
|
|
actionBarShadow.setVisibility(actionBar.getVisibility());
|
|
|
|
if (actionBar.isSearchFieldVisible()) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
currentAttachLayout.onHide();
|
|
|
|
nextAttachLayout.onShow();
|
|
|
|
nextAttachLayout.setVisibility(View.VISIBLE);
|
|
|
|
nextAttachLayout.setAlpha(0.0f);
|
|
|
|
|
|
|
|
if (layout.getParent() != null) {
|
|
|
|
containerView.removeView(nextAttachLayout);
|
|
|
|
}
|
|
|
|
int index = containerView.indexOfChild(currentAttachLayout);
|
|
|
|
containerView.addView(nextAttachLayout, nextAttachLayout == locationLayout ? index : index + 1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
nextAttachLayout.setTranslationY(AndroidUtilities.dp(78));
|
|
|
|
AnimatorSet animator = new AnimatorSet();
|
|
|
|
animator.playTogether(ObjectAnimator.ofFloat(currentAttachLayout, View.TRANSLATION_Y, AndroidUtilities.dp(78) + t),
|
|
|
|
ObjectAnimator.ofFloat(currentAttachLayout, ATTACH_ALERT_LAYOUT_TRANSLATION, 0.0f, 1.0f));
|
|
|
|
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
|
|
animator.setDuration(180);
|
|
|
|
animator.setStartDelay(20);
|
|
|
|
animator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
currentAttachLayout.setAlpha(0.0f);
|
|
|
|
SpringAnimation springAnimation = new SpringAnimation(nextAttachLayout, DynamicAnimation.TRANSLATION_Y, 0);
|
|
|
|
springAnimation.getSpring().setDampingRatio(0.7f);
|
|
|
|
springAnimation.getSpring().setStiffness(400.0f);
|
|
|
|
springAnimation.addUpdateListener((animation12, value, velocity) -> {
|
|
|
|
if (nextAttachLayout == pollLayout) {
|
|
|
|
updateSelectedPosition(1);
|
|
|
|
}
|
|
|
|
nextAttachLayout.onContainerTranslationUpdated();
|
|
|
|
containerView.invalidate();
|
|
|
|
});
|
|
|
|
springAnimation.addEndListener((animation1, canceled, value, velocity) -> {
|
|
|
|
if (Build.VERSION.SDK_INT >= 20) {
|
|
|
|
container.setLayerType(View.LAYER_TYPE_NONE, null);
|
|
|
|
}
|
|
|
|
viewChangeAnimator = null;
|
|
|
|
containerView.removeView(currentAttachLayout);
|
|
|
|
currentAttachLayout.setVisibility(View.GONE);
|
|
|
|
currentAttachLayout.onHidden();
|
|
|
|
nextAttachLayout.onShown();
|
|
|
|
currentAttachLayout = nextAttachLayout;
|
|
|
|
nextAttachLayout = null;
|
|
|
|
scrollOffsetY[0] = scrollOffsetY[1];
|
|
|
|
});
|
|
|
|
viewChangeAnimator = springAnimation;
|
|
|
|
springAnimation.start();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
});
|
|
|
|
viewChangeAnimator = animator;
|
|
|
|
animator.start();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
if (requestCode == 5 && grantResults != null && grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
openContactsLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void openContactsLayout() {
|
|
|
|
if (contactsLayout == null) {
|
|
|
|
layouts[2] = contactsLayout = new ChatAttachAlertContactsLayout(this, getContext());
|
|
|
|
contactsLayout.setDelegate((user, notify, scheduleDate) -> ((ChatActivity) baseFragment).sendContact(user, notify, scheduleDate));
|
|
|
|
}
|
|
|
|
showLayout(contactsLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void openAudioLayout() {
|
|
|
|
if (audioLayout == null) {
|
|
|
|
layouts[3] = audioLayout = new ChatAttachAlertAudioLayout(this, getContext());
|
|
|
|
audioLayout.setDelegate((audios, caption, notify, scheduleDate) -> ((ChatActivity) baseFragment).sendAudio(audios, caption, notify, scheduleDate));
|
|
|
|
}
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
ChatActivity chatActivity = (ChatActivity) baseFragment;
|
|
|
|
TLRPC.Chat currentChat = chatActivity.getCurrentChat();
|
|
|
|
audioLayout.setMaxSelectedFiles(currentChat != null && !ChatObject.hasAdminRights(currentChat) && currentChat.slowmode_enabled || editingMessageObject != null ? 1 : -1);
|
|
|
|
}
|
|
|
|
showLayout(audioLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void openDocumentsLayout() {
|
|
|
|
if (documentLayout == null) {
|
|
|
|
layouts[4] = documentLayout = new ChatAttachAlertDocumentLayout(this, getContext(), false);
|
|
|
|
documentLayout.setDelegate(new ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate() {
|
|
|
|
@Override
|
|
|
|
public void didSelectFiles(ArrayList<String> files, String caption, boolean notify, int scheduleDate) {
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
((ChatActivity) baseFragment).didSelectFiles(files, caption, notify, scheduleDate);
|
|
|
|
} else if (baseFragment instanceof PassportActivity) {
|
|
|
|
((PassportActivity) baseFragment).didSelectFiles(files, caption, notify, scheduleDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos, boolean notify, int scheduleDate) {
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
((ChatActivity) baseFragment).didSelectPhotos(photos, notify, scheduleDate);
|
|
|
|
} else if (baseFragment instanceof PassportActivity) {
|
|
|
|
((PassportActivity) baseFragment).didSelectPhotos(photos, notify, scheduleDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startDocumentSelectActivity() {
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
((ChatActivity) baseFragment).startDocumentSelectActivity();
|
|
|
|
} else if (baseFragment instanceof PassportActivity) {
|
|
|
|
((PassportActivity) baseFragment).startDocumentSelectActivity();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startMusicSelectActivity() {
|
|
|
|
openAudioLayout();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
ChatActivity chatActivity = (ChatActivity) baseFragment;
|
|
|
|
TLRPC.Chat currentChat = chatActivity.getCurrentChat();
|
|
|
|
documentLayout.setMaxSelectedFiles(currentChat != null && !ChatObject.hasAdminRights(currentChat) && currentChat.slowmode_enabled || editingMessageObject != null ? 1 : -1);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
documentLayout.setMaxSelectedFiles(maxSelectedPhotos);
|
|
|
|
documentLayout.setCanSelectOnlyImageFiles(true);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
showLayout(documentLayout);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private boolean showCommentTextView(boolean show, boolean animated) {
|
|
|
|
if (show == (frameLayout2.getTag() != null)) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (commentsAnimator != null) {
|
|
|
|
commentsAnimator.cancel();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
frameLayout2.setTag(show ? 1 : null);
|
|
|
|
if (commentTextView.getEditText().isFocused()) {
|
|
|
|
AndroidUtilities.hideKeyboard(commentTextView.getEditText());
|
|
|
|
}
|
|
|
|
commentTextView.hidePopup(true);
|
|
|
|
if (show) {
|
|
|
|
frameLayout2.setVisibility(View.VISIBLE);
|
|
|
|
writeButtonContainer.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (animated) {
|
2020-04-24 11:21:58 +02:00
|
|
|
commentsAnimator = new AnimatorSet();
|
2019-08-22 01:53:26 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(frameLayout2, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_X, show ? 1.0f : 0.2f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(writeButtonContainer, View.SCALE_Y, show ? 1.0f : 0.2f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(writeButtonContainer, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedCountView, View.SCALE_X, show ? 1.0f : 0.2f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedCountView, View.SCALE_Y, show ? 1.0f : 0.2f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedCountView, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
if (actionBar.getTag() != null) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(frameLayout2, View.TRANSLATION_Y, show ? 0.0f : AndroidUtilities.dp(48)));
|
2020-04-24 11:21:58 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(shadow, View.TRANSLATION_Y, show ? AndroidUtilities.dp(36) : AndroidUtilities.dp(48 + 36)));
|
2019-08-22 01:53:26 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(shadow, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(buttonsRecyclerView, View.TRANSLATION_Y, show ? AndroidUtilities.dp(36) : 0));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(shadow, View.TRANSLATION_Y, show ? AndroidUtilities.dp(36) : 0));
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
commentsAnimator.playTogether(animators);
|
|
|
|
commentsAnimator.setInterpolator(new DecelerateInterpolator());
|
|
|
|
commentsAnimator.setDuration(180);
|
|
|
|
commentsAnimator.addListener(new AnimatorListenerAdapter() {
|
2019-08-22 01:53:26 +02:00
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (animation.equals(commentsAnimator)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (!show) {
|
|
|
|
frameLayout2.setVisibility(View.INVISIBLE);
|
|
|
|
writeButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
commentsAnimator = null;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (animation.equals(commentsAnimator)) {
|
|
|
|
commentsAnimator = null;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-04-24 11:21:58 +02:00
|
|
|
commentsAnimator.start();
|
2019-08-22 01:53:26 +02:00
|
|
|
} else {
|
|
|
|
frameLayout2.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
writeButtonContainer.setScaleX(show ? 1.0f : 0.2f);
|
|
|
|
writeButtonContainer.setScaleY(show ? 1.0f : 0.2f);
|
|
|
|
writeButtonContainer.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
selectedCountView.setScaleX(show ? 1.0f : 0.2f);
|
|
|
|
selectedCountView.setScaleY(show ? 1.0f : 0.2f);
|
|
|
|
selectedCountView.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
if (actionBar.getTag() != null) {
|
|
|
|
frameLayout2.setTranslationY(show ? 0.0f : AndroidUtilities.dp(48));
|
2020-04-24 11:21:58 +02:00
|
|
|
shadow.setTranslationY(show ? AndroidUtilities.dp(36) : AndroidUtilities.dp(48 + 36));
|
2019-08-22 01:53:26 +02:00
|
|
|
shadow.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
} else {
|
2020-04-24 11:21:58 +02:00
|
|
|
buttonsRecyclerView.setTranslationY(show ? AndroidUtilities.dp(36) : 0);
|
|
|
|
shadow.setTranslationY(show ? AndroidUtilities.dp(36) : 0);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
if (!show) {
|
|
|
|
frameLayout2.setVisibility(View.INVISIBLE);
|
|
|
|
writeButtonContainer.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final Property<ChatAttachAlert, Float> ATTACH_ALERT_PROGRESS = new AnimationProperties.FloatProperty<ChatAttachAlert>("openProgress") {
|
|
|
|
|
|
|
|
private float openProgress;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setValue(ChatAttachAlert object, float value) {
|
|
|
|
for (int a = 0, N = buttonsRecyclerView.getChildCount(); a < N; a++) {
|
|
|
|
float startTime = 32.0f * (3 - a);
|
|
|
|
View child = buttonsRecyclerView.getChildAt(a);
|
|
|
|
float scale;
|
|
|
|
if (value > startTime) {
|
|
|
|
float elapsedTime = value - startTime;
|
|
|
|
if (elapsedTime <= 200.0f) {
|
|
|
|
scale = 1.1f * CubicBezierInterpolator.EASE_OUT.getInterpolation(elapsedTime / 200.0f);
|
|
|
|
child.setAlpha(CubicBezierInterpolator.EASE_BOTH.getInterpolation(elapsedTime / 200.0f));
|
|
|
|
} else {
|
|
|
|
child.setAlpha(1.0f);
|
|
|
|
elapsedTime -= 200.0f;
|
|
|
|
if (elapsedTime <= 100.0f) {
|
|
|
|
scale = 1.1f - 0.1f * CubicBezierInterpolator.EASE_IN.getInterpolation(elapsedTime / 100.0f);
|
|
|
|
} else {
|
|
|
|
scale = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
scale = 0;
|
|
|
|
}
|
|
|
|
if (child instanceof AttachButton) {
|
|
|
|
AttachButton attachButton = (AttachButton) child;
|
|
|
|
attachButton.textView.setScaleX(scale);
|
|
|
|
attachButton.textView.setScaleY(scale);
|
|
|
|
attachButton.imageView.setScaleX(scale);
|
|
|
|
attachButton.imageView.setScaleY(scale);
|
|
|
|
} else if (child instanceof AttachBotButton) {
|
|
|
|
AttachBotButton attachButton = (AttachBotButton) child;
|
|
|
|
attachButton.nameTextView.setScaleX(scale);
|
|
|
|
attachButton.nameTextView.setScaleY(scale);
|
|
|
|
attachButton.imageView.setScaleX(scale);
|
|
|
|
attachButton.imageView.setScaleY(scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Float get(ChatAttachAlert object) {
|
|
|
|
return openProgress;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onCustomOpenAnimation() {
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
animatorSet.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(this, ATTACH_ALERT_PROGRESS, 0.0f, 400.0f));
|
|
|
|
animatorSet.setDuration(400);
|
|
|
|
animatorSet.setStartDelay(20);
|
|
|
|
animatorSet.start();
|
|
|
|
return false;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
protected boolean onContainerTouchEvent(MotionEvent event) {
|
|
|
|
return currentAttachLayout.onContainerViewTouchEvent(event);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
protected void makeFocusable(EditTextBoldCursor editText) {
|
|
|
|
if (!enterCommentEventSent) {
|
|
|
|
delegate.needEnterComment();
|
|
|
|
setFocusable(true);
|
|
|
|
enterCommentEventSent = true;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> AndroidUtilities.showKeyboard(editText));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
private void applyAttachButtonColors(View view) {
|
|
|
|
if (view instanceof AttachButton) {
|
|
|
|
AttachButton button = (AttachButton) view;
|
2020-04-24 11:21:58 +02:00
|
|
|
button.textView.setTextColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_dialogTextGray2), Theme.getColor(button.textKey), button.checkedState));
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (view instanceof AttachBotButton) {
|
|
|
|
AttachBotButton button = (AttachBotButton) view;
|
|
|
|
button.nameTextView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public ArrayList<ThemeDescription> getThemeDescriptions() {
|
|
|
|
ArrayList<ThemeDescription> descriptions = new ArrayList<>();
|
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null) {
|
|
|
|
ArrayList<ThemeDescription> arrayList = layouts[a].getThemeDescriptions();
|
|
|
|
if (arrayList != null) {
|
|
|
|
descriptions.addAll(arrayList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
descriptions.add(new ThemeDescription(container, 0, null, null, null, null, Theme.key_dialogBackgroundGray));
|
|
|
|
return descriptions;
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
public void checkColors() {
|
|
|
|
if (buttonsRecyclerView == null) {
|
|
|
|
return;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
int count = buttonsRecyclerView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
applyAttachButtonColors(buttonsRecyclerView.getChildAt(a));
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
doneItem.getTextView().setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedMenuItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
Theme.setDrawableColor(selectedMenuItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));
|
|
|
|
selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false);
|
|
|
|
selectedMenuItem.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), true);
|
|
|
|
selectedMenuItem.redrawPopup(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
searchItem.setIconColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
Theme.setDrawableColor(searchItem.getBackground(), Theme.getColor(Theme.key_dialogButtonSelector));
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
commentTextView.updateColors();
|
|
|
|
|
|
|
|
if (sendPopupLayout != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
for (int a = 0; a < itemCells.length; a++) {
|
2019-12-31 14:08:08 +01:00
|
|
|
if (itemCells[a] != null) {
|
|
|
|
itemCells[a].setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
|
|
|
|
itemCells[a].setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupLayout.invalidate();
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Theme.key_dialogFloatingButton), false);
|
2019-12-31 14:08:08 +01:00
|
|
|
Theme.setSelectorDrawableColor(writeButtonDrawable, Theme.getColor(Build.VERSION.SDK_INT >= 21 ? Theme.key_dialogFloatingButtonPressed : Theme.key_dialogFloatingButton), true);
|
2019-08-22 01:53:26 +02:00
|
|
|
writeButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogFloatingIcon), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
|
|
|
actionBarShadow.setBackgroundColor(Theme.getColor(Theme.key_dialogShadowLine));
|
|
|
|
|
|
|
|
buttonsRecyclerView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
|
|
|
|
buttonsRecyclerView.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
|
|
|
|
frameLayout2.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
|
|
|
|
selectedCountView.invalidate();
|
|
|
|
|
|
|
|
actionBar.setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
|
|
|
|
actionBar.setItemsColor(Theme.getColor(Theme.key_dialogTextBlack), false);
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_dialogButtonSelector), false);
|
|
|
|
actionBar.setTitleColor(Theme.getColor(Theme.key_dialogTextBlack));
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
Theme.setDrawableColor(shadowDrawable, Theme.getColor(Theme.key_dialogBackground));
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
containerView.invalidate();
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null) {
|
|
|
|
layouts[a].checkColors();
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onCustomMeasure(View view, int width, int height) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (photoLayout.onCustomMeasure(view, width, height)) {
|
2018-07-30 04:07:02 +02:00
|
|
|
return true;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onCustomLayout(View view, int left, int top, int right, int bottom) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (photoLayout.onCustomLayout(view, left, top, right, bottom)) {
|
2016-10-11 13:57:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
public void onPause() {
|
2020-04-24 11:21:58 +02:00
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null) {
|
|
|
|
layouts[a].onPause();
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
paused = true;
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
paused = false;
|
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null) {
|
|
|
|
layouts[a].onResume();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public void onActivityResultFragment(int requestCode, Intent data, String currentPicturePath) {
|
|
|
|
photoLayout.onActivityResultFragment(requestCode, data, currentPicturePath);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public void didReceivedNotification(int id, int account, Object... args) {
|
|
|
|
if (id == NotificationCenter.reloadInlineHints) {
|
|
|
|
if (buttonsAdapter != null) {
|
|
|
|
buttonsAdapter.notifyDataSetChanged();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
private void updateSelectedPosition(int idx) {
|
2019-08-22 01:53:26 +02:00
|
|
|
float moveProgress;
|
2020-04-24 11:21:58 +02:00
|
|
|
AttachAlertLayout layout = idx == 0 ? currentAttachLayout : nextAttachLayout;
|
|
|
|
int t = scrollOffsetY[idx] - backgroundPaddingTop;
|
|
|
|
float toMove;
|
|
|
|
if (layout == pollLayout) {
|
|
|
|
t -= AndroidUtilities.dp(13);
|
|
|
|
toMove = AndroidUtilities.dp(11);
|
|
|
|
} else {
|
|
|
|
t -= AndroidUtilities.dp(39);
|
|
|
|
toMove = AndroidUtilities.dp(43);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (t + backgroundPaddingTop < ActionBar.getCurrentActionBarHeight()) {
|
|
|
|
moveProgress = Math.min(1.0f, (ActionBar.getCurrentActionBarHeight() - t - backgroundPaddingTop) / toMove);
|
|
|
|
cornerRadius = 1.0f - moveProgress;
|
|
|
|
} else {
|
|
|
|
moveProgress = 0.0f;
|
|
|
|
cornerRadius = 1.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
int finalMove;
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
finalMove = 16;
|
|
|
|
} else if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
|
|
|
|
finalMove = 6;
|
|
|
|
} else {
|
|
|
|
finalMove = 12;
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
float offset = actionBar.getAlpha() != 0 ? 0.0f : AndroidUtilities.dp(26 * (1.0f - selectedTextView.getAlpha()));
|
|
|
|
if (menuShowed) {
|
|
|
|
selectedMenuItem.setTranslationY(scrollOffsetY[idx] - AndroidUtilities.dp(37 + finalMove * moveProgress) + offset);
|
|
|
|
} else {
|
|
|
|
selectedMenuItem.setTranslationY(ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(4) - AndroidUtilities.dp(37 + finalMove));
|
|
|
|
}
|
|
|
|
searchItem.setTranslationY(ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(4) - AndroidUtilities.dp(37 + finalMove));
|
|
|
|
selectedTextView.setTranslationY(scrollOffsetY[idx] - AndroidUtilities.dp(25 + finalMove * moveProgress) + offset);
|
|
|
|
if (pollLayout != null && layout == pollLayout) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
finalMove = 63;
|
|
|
|
} else if (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y) {
|
|
|
|
finalMove = 53;
|
|
|
|
} else {
|
|
|
|
finalMove = 59;
|
|
|
|
}
|
|
|
|
doneItem.setTranslationY(Math.max(0, pollLayout.getTranslationY() + scrollOffsetY[idx] - AndroidUtilities.dp(7 + finalMove * moveProgress)));
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
@SuppressLint("NewApi")
|
2020-04-24 11:21:58 +02:00
|
|
|
protected void updateLayout(AttachAlertLayout layout, boolean animated) {
|
|
|
|
if (layout == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int newOffset = layout.getCurrentItemTop();
|
|
|
|
FileLog.d(layout + " offset = " + newOffset);
|
|
|
|
if (newOffset == Integer.MAX_VALUE) {
|
2016-05-25 23:49:47 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean show = layout == currentAttachLayout && newOffset <= layout.getButtonsHideOffset();
|
|
|
|
if (keyboardVisible && animated) {
|
|
|
|
animated = false;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (show && actionBar.getTag() == null || !show && actionBar.getTag() != null) {
|
|
|
|
actionBar.setTag(show ? 1 : null);
|
|
|
|
if (actionBarAnimation != null) {
|
|
|
|
actionBarAnimation.cancel();
|
|
|
|
actionBarAnimation = null;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean needsSearchItem = currentAttachLayout == photoLayout && !menuShowed && baseFragment instanceof ChatActivity && ((ChatActivity) baseFragment).allowSendGifs();
|
|
|
|
if (show) {
|
|
|
|
if (needsSearchItem) {
|
|
|
|
searchItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
if (!menuShowed && currentAttachLayout == photoLayout) {
|
|
|
|
selectedMenuItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
buttonsRecyclerView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (animated) {
|
|
|
|
actionBarAnimation = new AnimatorSet();
|
|
|
|
actionBarAnimation.setDuration(180);
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(actionBar, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(actionBarShadow, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
if (needsSearchItem) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(searchItem, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
}
|
|
|
|
if (!menuShowed && currentAttachLayout == photoLayout) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedMenuItem, View.ALPHA, show ? 1.0f : 0.0f));
|
|
|
|
}
|
|
|
|
actionBarAnimation.playTogether(animators);
|
|
|
|
actionBarAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (actionBarAnimation != null) {
|
|
|
|
if (show) {
|
|
|
|
buttonsRecyclerView.setVisibility(View.INVISIBLE);
|
|
|
|
} else {
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
|
|
|
if (!menuShowed) {
|
|
|
|
selectedMenuItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
|
|
|
actionBarAnimation = null;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
actionBarAnimation.start();
|
|
|
|
} else {
|
|
|
|
if (show) {
|
|
|
|
buttonsRecyclerView.setVisibility(View.INVISIBLE);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
actionBar.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
actionBarShadow.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
if (needsSearchItem) {
|
|
|
|
searchItem.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
}
|
|
|
|
if (!menuShowed && currentAttachLayout == photoLayout) {
|
|
|
|
selectedMenuItem.setAlpha(show ? 1.0f : 0.0f);
|
|
|
|
}
|
|
|
|
if (!show) {
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
|
|
|
if (!menuShowed) {
|
|
|
|
selectedMenuItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) layout.getLayoutParams();
|
2019-08-22 01:53:26 +02:00
|
|
|
newOffset += layoutParams.topMargin - AndroidUtilities.dp(11);
|
2020-04-24 11:21:58 +02:00
|
|
|
int idx = currentAttachLayout == layout ? 0 : 1;
|
|
|
|
if (scrollOffsetY[idx] != newOffset) {
|
|
|
|
scrollOffsetY[idx] = newOffset;
|
|
|
|
updateSelectedPosition(idx);
|
2019-08-22 01:53:26 +02:00
|
|
|
containerView.invalidate();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean canDismissWithSwipe() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public void updateCountButton(int animated) {
|
|
|
|
if (viewChangeAnimator != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int count = currentAttachLayout.getSelectedItemsCount();
|
2019-08-22 01:53:26 +02:00
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
if (count == 0) {
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedCountView.setPivotX(0);
|
|
|
|
selectedCountView.setPivotY(0);
|
|
|
|
showCommentTextView(false, animated != 0);
|
2016-05-25 23:49:47 +02:00
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedCountView.invalidate();
|
2019-09-10 12:56:11 +02:00
|
|
|
if (!showCommentTextView(true, animated != 0) && animated != 0) {
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedCountView.setPivotX(AndroidUtilities.dp(21));
|
|
|
|
selectedCountView.setPivotY(AndroidUtilities.dp(12));
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
animatorSet.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_X, animated == 1 ? 1.1f : 0.9f, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(selectedCountView, View.SCALE_Y, animated == 1 ? 1.1f : 0.9f, 1.0f));
|
|
|
|
animatorSet.setInterpolator(new OvershootInterpolator());
|
|
|
|
animatorSet.setDuration(180);
|
|
|
|
animatorSet.start();
|
|
|
|
} else {
|
|
|
|
selectedCountView.setPivotX(0);
|
|
|
|
selectedCountView.setPivotY(0);
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onSelectedItemsCountChanged(count);
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout == photoLayout && (baseFragment instanceof ChatActivity) && (count == 0 && menuShowed || count != 0 && !menuShowed)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
menuShowed = count != 0;
|
|
|
|
if (menuAnimator != null) {
|
|
|
|
menuAnimator.cancel();
|
|
|
|
menuAnimator = null;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
boolean needsSearchItem = actionBar.getTag() != null && baseFragment instanceof ChatActivity && ((ChatActivity) baseFragment).allowSendGifs();
|
2019-08-22 01:53:26 +02:00
|
|
|
if (menuShowed) {
|
|
|
|
selectedMenuItem.setVisibility(View.VISIBLE);
|
|
|
|
selectedTextView.setVisibility(View.VISIBLE);
|
2020-04-24 11:21:58 +02:00
|
|
|
} else {
|
|
|
|
if (actionBar.getTag() != null) {
|
|
|
|
searchItem.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
if (animated == 0) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (actionBar.getTag() == null) {
|
|
|
|
selectedMenuItem.setAlpha(menuShowed ? 1.0f : 0.0f);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedTextView.setAlpha(menuShowed ? 1.0f : 0.0f);
|
2020-04-24 11:21:58 +02:00
|
|
|
if (needsSearchItem) {
|
|
|
|
searchItem.setAlpha(menuShowed ? 0.0f : 1.0f);
|
|
|
|
}
|
|
|
|
if (menuShowed) {
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
} else {
|
|
|
|
menuAnimator = new AnimatorSet();
|
2020-04-24 11:21:58 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
if (actionBar.getTag() == null) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedMenuItem, View.ALPHA, menuShowed ? 1.0f : 0.0f));
|
|
|
|
}
|
|
|
|
animators.add(ObjectAnimator.ofFloat(selectedTextView, View.ALPHA, menuShowed ? 1.0f : 0.0f));
|
|
|
|
if (needsSearchItem) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(searchItem, View.ALPHA, menuShowed ? 0.0f : 1.0f));
|
|
|
|
}
|
|
|
|
menuAnimator.playTogether(animators);
|
2019-08-22 01:53:26 +02:00
|
|
|
menuAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
menuAnimator = null;
|
|
|
|
if (!menuShowed) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (actionBar.getTag() == null) {
|
|
|
|
selectedMenuItem.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
selectedTextView.setVisibility(View.INVISIBLE);
|
2020-04-24 11:21:58 +02:00
|
|
|
} else {
|
|
|
|
searchItem.setVisibility(View.INVISIBLE);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
menuAnimator.setDuration(180);
|
|
|
|
menuAnimator.start();
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDelegate(ChatAttachViewDelegate chatAttachViewDelegate) {
|
|
|
|
delegate = chatAttachViewDelegate;
|
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
public void init() {
|
2020-01-05 12:50:11 +01:00
|
|
|
if (baseFragment == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (baseFragment instanceof ChatActivity) {
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.Chat chat = ((ChatActivity) baseFragment).getCurrentChat();
|
2020-01-23 07:15:40 +01:00
|
|
|
TLRPC.User user = ((ChatActivity) baseFragment).getCurrentUser();
|
2019-08-22 01:53:26 +02:00
|
|
|
if (chat != null) {
|
|
|
|
mediaEnabled = ChatObject.canSendMedia(chat);
|
|
|
|
pollsEnabled = ChatObject.canSendPolls(chat);
|
|
|
|
} else {
|
2020-01-23 07:15:40 +01:00
|
|
|
pollsEnabled = user != null && user.bot;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
commentTextView.setVisibility(View.INVISIBLE);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
photoLayout.onInit(mediaEnabled);
|
2019-08-22 01:53:26 +02:00
|
|
|
commentTextView.hidePopup(true);
|
|
|
|
enterCommentEventSent = false;
|
|
|
|
setFocusable(false);
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout != photoLayout) {
|
|
|
|
if (actionBar.isSearchFieldVisible()) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
containerView.removeView(currentAttachLayout);
|
|
|
|
currentAttachLayout.onHide();
|
|
|
|
currentAttachLayout.setVisibility(View.GONE);
|
|
|
|
currentAttachLayout.onHidden();
|
|
|
|
currentAttachLayout = photoLayout;
|
2020-04-30 21:07:00 +02:00
|
|
|
setAllowNestedScroll(true);
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.getParent() == null) {
|
|
|
|
containerView.addView(currentAttachLayout, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
}
|
|
|
|
selectedId = 1;
|
|
|
|
photoLayout.setAlpha(1.0f);
|
|
|
|
photoLayout.setVisibility(View.VISIBLE);
|
|
|
|
photoLayout.onShow();
|
|
|
|
photoLayout.onShown();
|
|
|
|
actionBar.setVisibility(View.VISIBLE);
|
|
|
|
actionBarShadow.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
updateCountButton(0);
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
buttonsAdapter.notifyDataSetChanged();
|
|
|
|
commentTextView.setText("");
|
|
|
|
buttonsLayoutManager.scrollToPositionWithOffset(0, 1000000);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onDestroy() {
|
2020-04-24 11:21:58 +02:00
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null) {
|
|
|
|
layouts[a].onDestroy();
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.reloadInlineHints);
|
2016-05-25 23:49:47 +02:00
|
|
|
baseFragment = null;
|
2019-08-22 01:53:26 +02:00
|
|
|
if (commentTextView != null) {
|
|
|
|
commentTextView.onDestroy();
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onOpenAnimationEnd() {
|
2019-08-22 01:53:26 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).setAnimationInProgress(false);
|
|
|
|
MediaController.AlbumEntry albumEntry;
|
|
|
|
if (baseFragment instanceof ChatActivity) {
|
|
|
|
albumEntry = MediaController.allMediaAlbumEntry;
|
|
|
|
} else {
|
|
|
|
albumEntry = MediaController.allPhotosAlbumEntry;
|
|
|
|
}
|
|
|
|
if (Build.VERSION.SDK_INT <= 19 && albumEntry == null) {
|
|
|
|
MediaController.loadGalleryPhotosAlbums(0);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onOpenAnimationEnd();
|
2019-08-22 01:53:26 +02:00
|
|
|
AndroidUtilities.makeAccessibilityAnnouncement(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onOpenAnimationStart() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
@Override
|
|
|
|
public boolean canDismiss() {
|
|
|
|
return true;
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
@Override
|
|
|
|
public void setAllowDrawContent(boolean value) {
|
|
|
|
super.setAllowDrawContent(value);
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onContainerTranslationUpdated();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
public void setMaxSelectedPhotos(int value, boolean order) {
|
|
|
|
if (editingMessageObject != null) {
|
|
|
|
return;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
maxSelectedPhotos = value;
|
2019-08-22 01:53:26 +02:00
|
|
|
allowOrder = order;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public void setOpenWithFrontFaceCamera(boolean value) {
|
|
|
|
openWithFrontFaceCamera = value;
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
public ChatAttachAlertPhotoLayout getPhotoLayout() {
|
|
|
|
return photoLayout;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private class ButtonsAdapter extends RecyclerListView.SelectionAdapter {
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
private int galleryButton;
|
|
|
|
private int documentButton;
|
|
|
|
private int musicButton;
|
|
|
|
private int pollButton;
|
|
|
|
private int contactButton;
|
|
|
|
private int locationButton;
|
|
|
|
private int buttonsCount;
|
|
|
|
|
|
|
|
public ButtonsAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
|
|
|
View view;
|
|
|
|
switch (viewType) {
|
|
|
|
case 0:
|
|
|
|
view = new AttachButton(mContext);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
default:
|
|
|
|
view = new AttachBotButton(mContext);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return new RecyclerListView.Holder(view);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
|
|
|
switch (holder.getItemViewType()) {
|
|
|
|
case 0:
|
|
|
|
AttachButton attachButton = (AttachButton) holder.itemView;
|
|
|
|
if (position == galleryButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(1, LocaleController.getString("ChatGallery", R.string.ChatGallery), Theme.chat_attachButtonDrawables[0], Theme.key_chat_attachGalleryBackground, Theme.key_chat_attachGalleryText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(1);
|
|
|
|
} else if (position == documentButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(4, LocaleController.getString("ChatDocument", R.string.ChatDocument), Theme.chat_attachButtonDrawables[2], Theme.key_chat_attachFileBackground, Theme.key_chat_attachFileText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(4);
|
|
|
|
} else if (position == locationButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(6, LocaleController.getString("ChatLocation", R.string.ChatLocation), Theme.chat_attachButtonDrawables[4], Theme.key_chat_attachLocationBackground, Theme.key_chat_attachLocationText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(6);
|
|
|
|
} else if (position == musicButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(3, LocaleController.getString("AttachMusic", R.string.AttachMusic), Theme.chat_attachButtonDrawables[1], Theme.key_chat_attachAudioBackground, Theme.key_chat_attachAudioText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(3);
|
|
|
|
} else if (position == pollButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(9, LocaleController.getString("Poll", R.string.Poll), Theme.chat_attachButtonDrawables[5], Theme.key_chat_attachPollBackground, Theme.key_chat_attachPollText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(9);
|
|
|
|
} else if (position == contactButton) {
|
2020-04-24 11:21:58 +02:00
|
|
|
attachButton.setTextAndIcon(5, LocaleController.getString("AttachContact", R.string.AttachContact), Theme.chat_attachButtonDrawables[3], Theme.key_chat_attachContactBackground, Theme.key_chat_attachContactText);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachButton.setTag(5);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
position -= buttonsCount;
|
|
|
|
AttachBotButton child = (AttachBotButton) holder.itemView;
|
|
|
|
child.setTag(position);
|
|
|
|
child.setUser(MessagesController.getInstance(currentAccount).getUser(MediaDataController.getInstance(currentAccount).inlineBots.get(position).peer.user_id));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
|
|
|
|
applyAttachButtonColors(holder.itemView);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(RecyclerView.ViewHolder holder) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemCount() {
|
|
|
|
int count = buttonsCount;
|
|
|
|
if (editingMessageObject == null && baseFragment instanceof ChatActivity) {
|
|
|
|
count += MediaDataController.getInstance(currentAccount).inlineBots.size();
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void notifyDataSetChanged() {
|
|
|
|
buttonsCount = 0;
|
|
|
|
galleryButton = -1;
|
|
|
|
documentButton = -1;
|
|
|
|
musicButton = -1;
|
|
|
|
pollButton = -1;
|
|
|
|
contactButton = -1;
|
|
|
|
locationButton = -1;
|
|
|
|
if (!(baseFragment instanceof ChatActivity)) {
|
|
|
|
galleryButton = buttonsCount++;
|
|
|
|
documentButton = buttonsCount++;
|
|
|
|
} else if (editingMessageObject != null) {
|
|
|
|
galleryButton = buttonsCount++;
|
|
|
|
documentButton = buttonsCount++;
|
|
|
|
musicButton = buttonsCount++;
|
|
|
|
} else {
|
|
|
|
if (mediaEnabled) {
|
|
|
|
galleryButton = buttonsCount++;
|
|
|
|
documentButton = buttonsCount++;
|
|
|
|
}
|
|
|
|
locationButton = buttonsCount++;
|
|
|
|
if (pollsEnabled) {
|
|
|
|
pollButton = buttonsCount++;
|
|
|
|
} else {
|
|
|
|
contactButton = buttonsCount++;
|
|
|
|
}
|
|
|
|
if (mediaEnabled) {
|
|
|
|
musicButton = buttonsCount++;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
TLRPC.User user = baseFragment instanceof ChatActivity ? ((ChatActivity) baseFragment).getCurrentUser() : null;
|
|
|
|
if (user != null && user.bot) {
|
|
|
|
contactButton = buttonsCount++;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
super.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getButtonsCount() {
|
|
|
|
return buttonsCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int position) {
|
|
|
|
if (position < buttonsCount) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
@Override
|
|
|
|
public void dismissInternal() {
|
|
|
|
if (containerView != null) {
|
|
|
|
containerView.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
if (actionBar.isSearchFieldVisible()) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
}
|
|
|
|
contactsLayout = null;
|
|
|
|
audioLayout = null;
|
|
|
|
pollLayout = null;
|
|
|
|
locationLayout = null;
|
|
|
|
documentLayout = null;
|
|
|
|
for (int a = 1; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] == null) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
layouts[a].onDestroy();
|
|
|
|
containerView.removeView(layouts[a]);
|
|
|
|
layouts[a] = null;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
super.dismissInternal();
|
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
@Override
|
2019-08-22 01:53:26 +02:00
|
|
|
public void onBackPressed() {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (actionBar.isSearchFieldVisible()) {
|
|
|
|
actionBar.closeSearchField();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (currentAttachLayout.onBackPressed()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (commentTextView != null && commentTextView.isPopupShowing()) {
|
|
|
|
commentTextView.hidePopup(true);
|
|
|
|
return;
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
super.onBackPressed();
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dismissWithButtonClick(int item) {
|
|
|
|
super.dismissWithButtonClick(item);
|
2020-04-24 11:21:58 +02:00
|
|
|
currentAttachLayout.onDismissWithButtonClick(item);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean canDismissWithTouchOutside() {
|
2020-04-24 11:21:58 +02:00
|
|
|
return currentAttachLayout.canDismissWithTouchOutside();
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void dismiss() {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.onDismiss()) {
|
2016-10-11 13:57:01 +02:00
|
|
|
return;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
for (int a = 0; a < layouts.length; a++) {
|
|
|
|
if (layouts[a] != null && currentAttachLayout != layouts[a]) {
|
|
|
|
layouts[a].onDismiss();
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (commentTextView != null) {
|
|
|
|
AndroidUtilities.hideKeyboard(commentTextView.getEditText());
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
super.dismiss();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (currentAttachLayout.onSheetKeyDown(keyCode, event)) {
|
2016-10-11 13:57:01 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|