2014-07-03 00:39:05 +02:00
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
* This is the source code of Telegram for Android v. 5.x.x.
|
2014-07-03 00:39:05 +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.
|
2014-07-03 00:39:05 +02:00
|
|
|
*/
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
package org.telegram.ui.Components;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.Manifest;
|
2016-06-24 12:27:15 +02:00
|
|
|
import android.animation.Animator;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.animation.AnimatorListenerAdapter;
|
2016-06-24 12:27:15 +02:00
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
import android.animation.ObjectAnimator;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.animation.ValueAnimator;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.annotation.SuppressLint;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.app.Activity;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.content.ClipDescription;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.content.SharedPreferences;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.graphics.Bitmap;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.graphics.Canvas;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.graphics.Color;
|
2017-07-23 14:56:38 +02:00
|
|
|
import android.graphics.ColorFilter;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.graphics.Matrix;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.graphics.Paint;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.graphics.Path;
|
2018-07-30 04:07:02 +02:00
|
|
|
import android.graphics.PixelFormat;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
2020-02-13 19:26:53 +01:00
|
|
|
import android.graphics.Rect;
|
2017-07-08 18:32:04 +02:00
|
|
|
import android.graphics.RectF;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.graphics.drawable.Drawable;
|
2015-01-02 23:15:07 +01:00
|
|
|
import android.media.AudioManager;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.os.Build;
|
2016-04-22 15:49:00 +02:00
|
|
|
import android.os.Bundle;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.os.PowerManager;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.os.SystemClock;
|
2020-12-23 08:48:30 +01:00
|
|
|
import android.os.Vibrator;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.text.Editable;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.text.Layout;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.text.Spannable;
|
2016-03-06 02:49:31 +01:00
|
|
|
import android.text.SpannableStringBuilder;
|
2016-05-25 23:49:47 +02:00
|
|
|
import android.text.Spanned;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.text.StaticLayout;
|
|
|
|
import android.text.TextPaint;
|
2020-10-30 11:26:29 +01:00
|
|
|
import android.text.TextUtils;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.text.TextWatcher;
|
|
|
|
import android.text.style.ImageSpan;
|
2017-07-23 14:56:38 +02:00
|
|
|
import android.util.Property;
|
2015-02-26 02:32:51 +01:00
|
|
|
import android.util.TypedValue;
|
2019-12-31 14:08:08 +01:00
|
|
|
import android.view.ActionMode;
|
2014-11-06 22:34:47 +01:00
|
|
|
import android.view.Gravity;
|
2019-01-23 18:03:33 +01:00
|
|
|
import android.view.HapticFeedbackConstants;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.view.KeyEvent;
|
2019-12-31 14:08:08 +01:00
|
|
|
import android.view.Menu;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.View;
|
2020-03-30 14:00:09 +02:00
|
|
|
import android.view.ViewConfiguration;
|
|
|
|
import android.view.ViewGroup;
|
2019-08-22 01:53:26 +02:00
|
|
|
import android.view.WindowManager;
|
2019-05-14 14:08:05 +02:00
|
|
|
import android.view.accessibility.AccessibilityEvent;
|
|
|
|
import android.view.accessibility.AccessibilityManager;
|
|
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.view.animation.DecelerateInterpolator;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.view.inputmethod.EditorInfo;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.view.inputmethod.InputConnection;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.widget.FrameLayout;
|
|
|
|
import android.widget.ImageView;
|
2015-02-26 02:32:51 +01:00
|
|
|
import android.widget.LinearLayout;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.widget.TextView;
|
2016-03-06 02:49:31 +01:00
|
|
|
import android.widget.Toast;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
import androidx.annotation.Keep;
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.core.content.ContextCompat;
|
|
|
|
import androidx.core.graphics.ColorUtils;
|
|
|
|
import androidx.core.os.BuildCompat;
|
|
|
|
import androidx.core.view.ViewCompat;
|
|
|
|
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
|
|
|
|
import androidx.core.view.inputmethod.EditorInfoCompat;
|
|
|
|
import androidx.core.view.inputmethod.InputConnectionCompat;
|
|
|
|
import androidx.core.view.inputmethod.InputContentInfoCompat;
|
|
|
|
import androidx.customview.widget.ExploreByTouchHelper;
|
|
|
|
|
2019-07-18 15:01:39 +02:00
|
|
|
import org.telegram.messenger.AccountInstance;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.ChatObject;
|
|
|
|
import org.telegram.messenger.Emoji;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.FileLog;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.MediaController;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.MediaDataController;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.MessageObject;
|
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.NotificationsController;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.messenger.R;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.SendMessagesHelper;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.SharedConfig;
|
2020-03-30 14:00:09 +02:00
|
|
|
import org.telegram.messenger.UserConfig;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.messenger.UserObject;
|
2017-07-08 18:32:04 +02:00
|
|
|
import org.telegram.messenger.VideoEditedInfo;
|
|
|
|
import org.telegram.messenger.camera.CameraController;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.tgnet.ConnectionsManager;
|
|
|
|
import org.telegram.tgnet.TLRPC;
|
2015-07-22 20:56:37 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuSubItem;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarPopupWindow;
|
2020-09-30 15:48:47 +02:00
|
|
|
import org.telegram.ui.ActionBar.AdjustPanLayoutHelper;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2019-08-22 01:53:26 +02:00
|
|
|
import org.telegram.ui.ActionBar.SimpleTextView;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
|
|
|
import org.telegram.ui.ChatActivity;
|
|
|
|
import org.telegram.ui.DialogsActivity;
|
2017-12-08 18:35:59 +01:00
|
|
|
import org.telegram.ui.GroupStickersActivity;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.ui.LaunchActivity;
|
2015-12-09 19:27:52 +01:00
|
|
|
import org.telegram.ui.StickersActivity;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
import java.io.File;
|
2016-04-22 15:49:00 +02:00
|
|
|
import java.util.ArrayList;
|
2019-05-14 14:08:05 +02:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
2015-06-29 19:12:11 +02:00
|
|
|
import java.util.Locale;
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
public class ChatActivityEnterView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate, SizeNotifierFrameLayout.SizeNotifierFrameLayoutDelegate, StickersAlert.StickersAlertDelegate {
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
public interface ChatActivityEnterViewDelegate {
|
2019-09-10 12:56:11 +02:00
|
|
|
void onMessageSend(CharSequence message, boolean notify, int scheduleDate);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
void needSendTyping();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
void onTextChanged(CharSequence text, boolean bigChange);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void onTextSelectionChanged(int start, int end);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void onTextSpansChanged(CharSequence text);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
void onAttachButtonHidden();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
void onAttachButtonShow();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
void onWindowSizeChanged(int size);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
void onStickersTab(boolean opened);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
void onMessageEditEnd(boolean loading);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
void didPressAttachButton();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
void needStartRecordVideo(int state, boolean notify, int scheduleDate);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
void needChangeVideoPreviewState(int state, float seekProgress);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
void onSwitchRecordMode(boolean video);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
void onPreAudioVideoRecord();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
void needStartRecordAudio(int state);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
void needShowMediaBanHint();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
void onStickersExpandedChange();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
void onUpdateSlowModeButton(View button, boolean show, CharSequence time);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
default void scrollToSendingMessage() {
|
|
|
|
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
default void openScheduledMessages() {
|
|
|
|
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
default boolean hasScheduledMessages() {
|
|
|
|
return true;
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-01-23 07:15:40 +01:00
|
|
|
void onSendLongClick();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
void onAudioVideoInterfaceUpdated();
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
default void bottomPanelTranslationYChanged(float translation) {
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
default void prepareMessageSending() {
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-10-30 11:26:29 +01:00
|
|
|
|
|
|
|
default void onTrendingStickersShowed(boolean show) {
|
|
|
|
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private final static int RECORD_STATE_ENTER = 0;
|
|
|
|
private final static int RECORD_STATE_SENDING = 1;
|
|
|
|
private final static int RECORD_STATE_CANCEL = 2;
|
|
|
|
private final static int RECORD_STATE_PREPARING = 3;
|
|
|
|
private final static int RECORD_STATE_CANCEL_BY_TIME = 4;
|
|
|
|
private final static int RECORD_STATE_CANCEL_BY_GESTURE = 5;
|
|
|
|
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private int currentAccount = UserConfig.selectedAccount;
|
2019-07-18 15:01:39 +02:00
|
|
|
private AccountInstance accountInstance = AccountInstance.getInstance(UserConfig.selectedAccount);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
private SeekBarWaveform seekBarWaveform;
|
2020-07-26 10:03:38 +02:00
|
|
|
private boolean isInitLineCount;
|
|
|
|
private int lineCount = 1;
|
2020-09-30 15:48:47 +02:00
|
|
|
private AdjustPanLayoutHelper adjustPanLayoutHelper;
|
|
|
|
private Runnable showTopViewRunnable;
|
|
|
|
private Runnable setTextFieldRunnable;
|
2020-10-30 13:41:45 +01:00
|
|
|
public boolean preventInput;
|
2020-12-23 08:48:30 +01:00
|
|
|
private NumberTextView captionLimitView;
|
|
|
|
private int currentLimit = -1;
|
|
|
|
private int codePointCount;
|
2021-01-28 15:15:51 +01:00
|
|
|
CrossOutDrawable notifySilentDrawable;
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
private Runnable moveToSendStateRunnable;
|
|
|
|
boolean messageTransitionIsRunning;
|
2016-03-06 02:49:31 +01:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private class SeekBarWaveformView extends View {
|
2016-03-06 02:49:31 +01:00
|
|
|
|
|
|
|
public SeekBarWaveformView(Context context) {
|
|
|
|
super(context);
|
|
|
|
seekBarWaveform = new SeekBarWaveform(context);
|
2018-08-27 10:33:11 +02:00
|
|
|
seekBarWaveform.setDelegate(progress -> {
|
|
|
|
if (audioToSendMessageObject != null) {
|
|
|
|
audioToSendMessageObject.audioProgress = progress;
|
|
|
|
MediaController.getInstance().seekToProgress(audioToSendMessageObject, progress);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setWaveform(byte[] waveform) {
|
|
|
|
seekBarWaveform.setWaveform(waveform);
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProgress(float progress) {
|
|
|
|
seekBarWaveform.setProgress(progress);
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isDragging() {
|
|
|
|
return seekBarWaveform.isDragging();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
boolean result = seekBarWaveform.onTouch(event.getAction(), event.getX(), event.getY());
|
|
|
|
if (result) {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
requestDisallowInterceptTouchEvent(true);
|
|
|
|
}
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
return result || super.onTouchEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
2016-04-22 15:49:00 +02:00
|
|
|
seekBarWaveform.setSize(right - left, bottom - top);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
super.onDraw(canvas);
|
2017-03-31 01:58:05 +02:00
|
|
|
seekBarWaveform.setColors(Theme.getColor(Theme.key_chat_recordedVoiceProgress), Theme.getColor(Theme.key_chat_recordedVoiceProgressInner), Theme.getColor(Theme.key_chat_recordedVoiceProgress));
|
2021-03-19 11:25:58 +01:00
|
|
|
seekBarWaveform.draw(canvas, this);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
@SuppressWarnings("FieldCanBeLocal")
|
|
|
|
private View.AccessibilityDelegate mediaMessageButtonsDelegate = new View.AccessibilityDelegate() {
|
|
|
|
@Override
|
|
|
|
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
|
|
|
|
super.onInitializeAccessibilityNodeInfo(host, info);
|
|
|
|
info.setClassName("android.widget.ImageButton");
|
|
|
|
info.setClickable(true);
|
|
|
|
info.setLongClickable(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
protected EditTextCaption messageEditText;
|
2019-08-22 01:53:26 +02:00
|
|
|
private SimpleTextView slowModeButton;
|
|
|
|
private int slowModeTimer;
|
|
|
|
private Runnable updateSlowModeRunnable;
|
|
|
|
private View sendButton;
|
|
|
|
private Drawable sendButtonDrawable;
|
|
|
|
private Drawable inactinveSendButtonDrawable;
|
|
|
|
private Drawable sendButtonInverseDrawable;
|
|
|
|
private ActionBarPopupWindow sendPopupWindow;
|
|
|
|
private ActionBarPopupWindow.ActionBarPopupWindowLayout sendPopupLayout;
|
2016-04-22 15:49:00 +02:00
|
|
|
private ImageView cancelBotButton;
|
2019-05-14 14:08:05 +02:00
|
|
|
private ImageView[] emojiButton = new ImageView[2];
|
2019-12-31 14:08:08 +01:00
|
|
|
@SuppressWarnings("FieldCanBeLocal")
|
|
|
|
private ImageView emojiButton1;
|
|
|
|
@SuppressWarnings("FieldCanBeLocal")
|
|
|
|
private ImageView emojiButton2;
|
2017-07-23 14:56:38 +02:00
|
|
|
private ImageView expandStickersButton;
|
2014-07-03 00:39:05 +02:00
|
|
|
private EmojiView emojiView;
|
2020-03-30 14:00:09 +02:00
|
|
|
private AnimatorSet panelAnimation;
|
2019-05-14 14:08:05 +02:00
|
|
|
private boolean emojiViewVisible;
|
2020-01-03 16:45:22 +01:00
|
|
|
private boolean botKeyboardViewVisible;
|
2020-03-30 14:00:09 +02:00
|
|
|
private TimerView recordTimerView;
|
2017-03-31 01:58:05 +02:00
|
|
|
private FrameLayout audioVideoButtonContainer;
|
|
|
|
private AnimatorSet audioVideoButtonAnimation;
|
2019-05-14 14:08:05 +02:00
|
|
|
private AnimatorSet emojiButtonAnimation;
|
2015-02-26 02:32:51 +01:00
|
|
|
private ImageView audioSendButton;
|
2017-03-31 01:58:05 +02:00
|
|
|
private ImageView videoSendButton;
|
2015-02-26 02:32:51 +01:00
|
|
|
private FrameLayout recordPanel;
|
2016-03-06 02:49:31 +01:00
|
|
|
private FrameLayout recordedAudioPanel;
|
2017-07-08 18:32:04 +02:00
|
|
|
private VideoTimelineView videoTimelineView;
|
2019-05-14 14:08:05 +02:00
|
|
|
@SuppressWarnings("FieldCanBeLocal")
|
2020-03-30 14:00:09 +02:00
|
|
|
private RLottieImageView recordDeleteImageView;
|
2016-03-06 02:49:31 +01:00
|
|
|
private SeekBarWaveformView recordedAudioSeekBar;
|
2017-03-31 01:58:05 +02:00
|
|
|
private View recordedAudioBackground;
|
2016-03-06 02:49:31 +01:00
|
|
|
private ImageView recordedAudioPlayButton;
|
|
|
|
private TextView recordedAudioTimeTextView;
|
2020-03-30 14:00:09 +02:00
|
|
|
private SlideTextView slideText;
|
2019-05-14 14:08:05 +02:00
|
|
|
@SuppressWarnings("FieldCanBeLocal")
|
2017-03-31 01:58:05 +02:00
|
|
|
private LinearLayout recordTimeContainer;
|
2015-10-29 18:10:07 +01:00
|
|
|
private RecordDot recordDot;
|
2015-06-29 19:12:11 +02:00
|
|
|
private SizeNotifierFrameLayout sizeNotifierLayout;
|
2019-05-14 14:08:05 +02:00
|
|
|
private int originalViewHeight;
|
2017-03-31 01:58:05 +02:00
|
|
|
private LinearLayout attachLayout;
|
|
|
|
private ImageView attachButton;
|
2015-06-29 19:12:11 +02:00
|
|
|
private ImageView botButton;
|
2015-03-19 00:09:45 +01:00
|
|
|
private LinearLayout textFieldContainer;
|
2016-03-06 02:49:31 +01:00
|
|
|
private FrameLayout sendButtonContainer;
|
2017-03-31 01:58:05 +02:00
|
|
|
private FrameLayout doneButtonContainer;
|
|
|
|
private ImageView doneButtonImage;
|
|
|
|
private AnimatorSet doneButtonAnimation;
|
|
|
|
private ContextProgressView doneButtonProgress;
|
2020-06-04 18:47:15 +02:00
|
|
|
protected View topView;
|
|
|
|
protected View topLineView;
|
2015-06-29 19:12:11 +02:00
|
|
|
private BotKeyboardView botKeyboardView;
|
2016-03-06 02:49:31 +01:00
|
|
|
private ImageView notifyButton;
|
2019-09-10 12:56:11 +02:00
|
|
|
private ImageView scheduledButton;
|
|
|
|
private boolean scheduleButtonHidden;
|
|
|
|
private AnimatorSet scheduledButtonAnimation;
|
2015-10-29 18:10:07 +01:00
|
|
|
private RecordCircle recordCircle;
|
2016-04-22 15:49:00 +02:00
|
|
|
private CloseProgressDrawable2 progressDrawable;
|
2017-03-31 01:58:05 +02:00
|
|
|
private Paint dotPaint;
|
2020-03-30 14:00:09 +02:00
|
|
|
private MediaActionDrawable playPauseDrawable;
|
2019-05-14 14:08:05 +02:00
|
|
|
private int searchingType;
|
2019-07-18 15:01:39 +02:00
|
|
|
private Runnable focusRunnable;
|
2020-06-04 18:47:15 +02:00
|
|
|
protected float topViewEnterProgress;
|
|
|
|
protected int animatedTop;
|
2020-12-23 08:48:30 +01:00
|
|
|
public ValueAnimator currentTopViewAnimation;
|
2020-09-30 15:48:47 +02:00
|
|
|
private ReplaceableIconDrawable botButtonDrawablel;
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
private boolean isPaste;
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean destroyed;
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
private MessageObject editingMessageObject;
|
|
|
|
private boolean editingCaption;
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
private TLRPC.ChatFull info;
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
private boolean hasRecordVideo;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private int currentPopupContentType = -1;
|
2019-05-14 14:08:05 +02:00
|
|
|
private int currentEmojiIcon = -1;
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
private boolean silent;
|
|
|
|
private boolean canWriteToChannel;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean smoothKeyboard;
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
private boolean isPaused = true;
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean recordIsCanceled;
|
2015-06-29 19:12:11 +02:00
|
|
|
private boolean showKeyboardOnResume;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private MessageObject botButtonsMessageObject;
|
|
|
|
private TLRPC.TL_replyKeyboardMarkup botReplyMarkup;
|
|
|
|
private int botCount;
|
|
|
|
private boolean hasBotCommands;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private PowerManager.WakeLock wakeLock;
|
2016-06-24 12:27:15 +02:00
|
|
|
private AnimatorSet runningAnimation;
|
|
|
|
private AnimatorSet runningAnimation2;
|
|
|
|
private AnimatorSet runningAnimationAudio;
|
2020-03-30 14:00:09 +02:00
|
|
|
private AnimatorSet recordPannelAnimation;
|
2014-11-14 16:40:15 +01:00
|
|
|
private int runningAnimationType;
|
2017-03-31 01:58:05 +02:00
|
|
|
private int recordInterfaceState;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2014-11-14 16:40:15 +01:00
|
|
|
private int keyboardHeight;
|
|
|
|
private int keyboardHeightLand;
|
2014-07-03 00:39:05 +02:00
|
|
|
private boolean keyboardVisible;
|
2015-06-29 19:12:11 +02:00
|
|
|
private int emojiPadding;
|
2014-11-14 16:40:15 +01:00
|
|
|
private boolean sendByEnter;
|
|
|
|
private long lastTypingTimeSend;
|
2014-07-03 00:39:05 +02:00
|
|
|
private float startedDraggingX = -1;
|
|
|
|
private float distCanMove = AndroidUtilities.dp(80);
|
2017-03-31 01:58:05 +02:00
|
|
|
private boolean recordingAudioVideo;
|
2019-09-10 12:56:11 +02:00
|
|
|
private int recordingGuid;
|
2015-03-19 00:09:45 +01:00
|
|
|
private boolean forceShowSendButton;
|
2015-05-03 13:48:36 +02:00
|
|
|
private boolean allowStickers;
|
2016-01-11 18:19:48 +01:00
|
|
|
private boolean allowGifs;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private int lastSizeChangeValue1;
|
|
|
|
private boolean lastSizeChangeValue2;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
private Activity parentActivity;
|
2016-04-22 15:49:00 +02:00
|
|
|
private ChatActivity parentFragment;
|
2014-07-03 00:39:05 +02:00
|
|
|
private long dialog_id;
|
2014-11-14 16:40:15 +01:00
|
|
|
private boolean ignoreTextChange;
|
2015-07-22 20:56:37 +02:00
|
|
|
private int innerTextChange;
|
2015-03-19 00:09:45 +01:00
|
|
|
private MessageObject replyingMessageObject;
|
2015-06-29 19:12:11 +02:00
|
|
|
private MessageObject botMessageObject;
|
2015-04-09 20:00:14 +02:00
|
|
|
private TLRPC.WebPage messageWebPage;
|
2015-05-03 13:48:36 +02:00
|
|
|
private boolean messageWebPageSearch = true;
|
2014-07-03 00:39:05 +02:00
|
|
|
private ChatActivityEnterViewDelegate delegate;
|
2020-06-04 18:47:15 +02:00
|
|
|
private TrendingStickersAlert trendingStickersAlert;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
private TLRPC.TL_document audioToSend;
|
|
|
|
private String audioToSendPath;
|
|
|
|
private MessageObject audioToSendMessageObject;
|
2017-07-08 18:32:04 +02:00
|
|
|
private VideoEditedInfo videoToSendMessageObject;
|
2016-03-06 02:49:31 +01:00
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
protected boolean topViewShowed;
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
private boolean needShowTopView;
|
|
|
|
private boolean allowShowTopView;
|
2020-06-04 18:47:15 +02:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
private MessageObject pendingMessageObject;
|
|
|
|
private TLRPC.KeyboardButton pendingLocationButton;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean configAnimationsEnabled;
|
2020-06-04 18:47:15 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private boolean waitingForKeyboardOpen;
|
2020-09-30 15:48:47 +02:00
|
|
|
private boolean waitingForKeyboardOpenAfterAnimation;
|
2020-03-30 14:00:09 +02:00
|
|
|
private boolean wasSendTyping;
|
2020-07-26 10:03:38 +02:00
|
|
|
protected boolean shouldAnimateEditTextWithBounds;
|
2020-09-30 15:48:47 +02:00
|
|
|
private int animatingContentType = -1;
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
private boolean clearBotButtonsOnKeyboardOpen;
|
|
|
|
private boolean expandStickersWithKeyboard;
|
|
|
|
private float doneButtonEnabledProgress = 1f;
|
|
|
|
private final Drawable doneCheckDrawable;
|
|
|
|
boolean doneButtonEnabled = true;
|
|
|
|
private ValueAnimator doneButtonColorAnimator;
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private Runnable openKeyboardRunnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!destroyed && messageEditText != null && waitingForKeyboardOpen && !keyboardVisible && !AndroidUtilities.usingHardwareInput && !AndroidUtilities.isInMultiwindow) {
|
2015-06-29 19:12:11 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
AndroidUtilities.showKeyboard(messageEditText);
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
|
|
|
|
AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-07-23 14:56:38 +02:00
|
|
|
private Runnable updateExpandabilityRunnable = new Runnable() {
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2017-07-23 14:56:38 +02:00
|
|
|
private int lastKnownPage = -1;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (emojiView != null) {
|
|
|
|
int curPage = emojiView.getCurrentPage();
|
|
|
|
if (curPage != lastKnownPage) {
|
|
|
|
lastKnownPage = curPage;
|
|
|
|
boolean prevOpen = stickersTabOpen;
|
|
|
|
stickersTabOpen = curPage == 1 || curPage == 2;
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean prevOpen2 = emojiTabOpen;
|
|
|
|
emojiTabOpen = curPage == 0;
|
|
|
|
if (stickersExpanded) {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (searchingType != 0) {
|
2019-05-14 14:08:05 +02:00
|
|
|
searchingType = curPage == 0 ? 2 : 1;
|
|
|
|
checkStickresExpandHeight();
|
2020-10-30 11:26:29 +01:00
|
|
|
} else if (!stickersTabOpen) {
|
|
|
|
setStickersExpanded(false, true, false);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
if (prevOpen != stickersTabOpen || prevOpen2 != emojiTabOpen) {
|
|
|
|
checkSendButton(true);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
private Property<View, Integer> roundedTranslationYProperty = new Property<View, Integer>(Integer.class, "translationY") {
|
2017-07-23 14:56:38 +02:00
|
|
|
@Override
|
2017-12-08 18:35:59 +01:00
|
|
|
public Integer get(View object) {
|
2017-07-23 14:56:38 +02:00
|
|
|
return Math.round(object.getTranslationY());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-12-08 18:35:59 +01:00
|
|
|
public void set(View object, Integer value) {
|
2017-07-23 14:56:38 +02:00
|
|
|
object.setTranslationY(value);
|
|
|
|
}
|
|
|
|
};
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private Property<RecordCircle, Float> recordCircleScale = new Property<RecordCircle, Float>(Float.class, "scale") {
|
|
|
|
@Override
|
|
|
|
public Float get(RecordCircle object) {
|
|
|
|
return object.getScale();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void set(RecordCircle object, Float value) {
|
|
|
|
object.setScale(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private Paint redDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
|
2017-07-23 14:56:38 +02:00
|
|
|
private boolean stickersTabOpen;
|
2019-05-14 14:08:05 +02:00
|
|
|
private boolean emojiTabOpen;
|
2017-07-23 14:56:38 +02:00
|
|
|
private boolean gifsTabOpen;
|
|
|
|
private boolean stickersExpanded;
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean closeAnimationInProgress;
|
2017-07-23 14:56:38 +02:00
|
|
|
private Animator stickersExpansionAnim;
|
2019-01-23 18:03:33 +01:00
|
|
|
private Animator currentResizeAnimation;
|
2017-07-23 14:56:38 +02:00
|
|
|
private float stickersExpansionProgress;
|
|
|
|
private int stickersExpandedHeight;
|
|
|
|
private boolean stickersDragging;
|
|
|
|
private AnimatedArrowDrawable stickersArrow;
|
2020-09-30 15:48:47 +02:00
|
|
|
private boolean removeEmojiViewAfterAnimation;
|
2017-07-23 14:56:38 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private Runnable onFinishInitCameraRunnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.needStartRecordVideo(0, true, 0);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private boolean recordAudioVideoRunnableStarted;
|
2017-07-08 18:32:04 +02:00
|
|
|
private boolean calledRecordRunnable;
|
2017-03-31 01:58:05 +02:00
|
|
|
private Runnable recordAudioVideoRunnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
if (delegate == null || parentActivity == null) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
delegate.onPreAudioVideoRecord();
|
|
|
|
calledRecordRunnable = true;
|
2017-03-31 01:58:05 +02:00
|
|
|
recordAudioVideoRunnableStarted = false;
|
2017-07-08 18:32:04 +02:00
|
|
|
slideText.setAlpha(1.0f);
|
|
|
|
slideText.setTranslationY(0);
|
2017-03-31 01:58:05 +02:00
|
|
|
if (videoSendButton != null && videoSendButton.getTag() != null) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
|
|
boolean hasAudio = parentActivity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED;
|
|
|
|
boolean hasVideo = parentActivity.checkSelfPermission(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
|
|
|
|
if (!hasAudio || !hasVideo) {
|
|
|
|
String[] permissions = new String[!hasAudio && !hasVideo ? 2 : 1];
|
|
|
|
if (!hasAudio && !hasVideo) {
|
|
|
|
permissions[0] = Manifest.permission.RECORD_AUDIO;
|
|
|
|
permissions[1] = Manifest.permission.CAMERA;
|
|
|
|
} else if (!hasAudio) {
|
|
|
|
permissions[0] = Manifest.permission.RECORD_AUDIO;
|
|
|
|
} else {
|
|
|
|
permissions[0] = Manifest.permission.CAMERA;
|
|
|
|
}
|
|
|
|
parentActivity.requestPermissions(permissions, 3);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!CameraController.getInstance().isCameraInitied()) {
|
|
|
|
CameraController.getInstance().initCamera(onFinishInitCameraRunnable);
|
|
|
|
} else {
|
|
|
|
onFinishInitCameraRunnable.run();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!recordingAudioVideo) {
|
|
|
|
recordingAudioVideo = true;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_ENTER);
|
|
|
|
recordCircle.showWaves(false, false);
|
|
|
|
recordTimerView.reset();
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
} else {
|
|
|
|
if (parentFragment != null) {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
parentActivity.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, 3);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
delegate.needStartRecordAudio(1);
|
2017-03-31 01:58:05 +02:00
|
|
|
startedDraggingX = -1;
|
2020-09-30 15:48:47 +02:00
|
|
|
MediaController.getInstance().startRecording(currentAccount, dialog_id, replyingMessageObject, getThreadMessage(), recordingGuid);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordingAudioVideo = true;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_ENTER);
|
|
|
|
recordTimerView.start();
|
|
|
|
recordDot.enterAnimation = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.getParent().requestDisallowInterceptTouchEvent(true);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordCircle.showWaves(true, false);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private int notificationsIndex;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private class RecordDot extends View {
|
|
|
|
|
|
|
|
private float alpha;
|
|
|
|
private long lastUpdateTime;
|
|
|
|
private boolean isIncr;
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean attachedToWindow;
|
|
|
|
boolean playing;
|
|
|
|
RLottieDrawable drawable;
|
|
|
|
private boolean enterAnimation;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onAttachedToWindow() {
|
|
|
|
super.onAttachedToWindow();
|
|
|
|
attachedToWindow = true;
|
|
|
|
if (playing) {
|
|
|
|
drawable.start();
|
|
|
|
}
|
|
|
|
drawable.addParentView(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDetachedFromWindow() {
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
attachedToWindow = false;
|
|
|
|
drawable.stop();
|
|
|
|
drawable.removeParentView(this);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
|
|
|
|
public RecordDot(Context context) {
|
|
|
|
super(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
int resId = R.raw.chat_audio_record_delete;
|
|
|
|
drawable = new RLottieDrawable(resId, "" + resId, AndroidUtilities.dp(28), AndroidUtilities.dp(28), false, null);
|
|
|
|
drawable.setCurrentParentView(this);
|
|
|
|
drawable.setInvalidateOnProgressSet(true);
|
|
|
|
updateColors();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateColors() {
|
|
|
|
int dotColor = Theme.getColor(Theme.key_chat_recordedVoiceDot);
|
|
|
|
int background = Theme.getColor(Theme.key_chat_messagePanelBackground);
|
|
|
|
redDotPaint.setColor(dotColor);
|
|
|
|
drawable.beginApplyLayerColors();
|
|
|
|
drawable.setLayerColor("Cup Red.**", dotColor);
|
|
|
|
drawable.setLayerColor("Box.**", dotColor);
|
|
|
|
drawable.setLayerColor("Line 1.**", background);
|
|
|
|
drawable.setLayerColor("Line 2.**", background);
|
|
|
|
drawable.setLayerColor("Line 3.**", background);
|
|
|
|
drawable.commitApplyLayerColors();
|
2020-04-24 11:21:58 +02:00
|
|
|
if (playPauseDrawable != null) {
|
|
|
|
playPauseDrawable.setColor(Theme.getColor(Theme.key_chat_recordedVoicePlayPause));
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void resetAlpha() {
|
|
|
|
alpha = 1.0f;
|
|
|
|
lastUpdateTime = System.currentTimeMillis();
|
|
|
|
isIncr = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
playing = false;
|
|
|
|
drawable.stop();
|
2015-10-29 18:10:07 +01:00
|
|
|
invalidate();
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
drawable.setBounds(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (playing) {
|
|
|
|
drawable.setAlpha((int) (255 * alpha));
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
redDotPaint.setAlpha((int) (255 * alpha));
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
long dt = (System.currentTimeMillis() - lastUpdateTime);
|
2020-03-30 14:00:09 +02:00
|
|
|
if (enterAnimation) {
|
|
|
|
alpha = 1;
|
2015-10-29 18:10:07 +01:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (!isIncr && !playing) {
|
|
|
|
alpha -= dt / 600.0f;
|
|
|
|
if (alpha <= 0) {
|
|
|
|
alpha = 0;
|
|
|
|
isIncr = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
alpha += dt / 600.0f;
|
|
|
|
if (alpha >= 1) {
|
|
|
|
alpha = 1;
|
|
|
|
isIncr = false;
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
lastUpdateTime = System.currentTimeMillis();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (playing) {
|
|
|
|
drawable.draw(canvas);
|
|
|
|
}
|
|
|
|
if (!playing || !drawable.hasBitmap()) {
|
|
|
|
canvas.drawCircle(this.getMeasuredWidth() >> 1, this.getMeasuredHeight() >> 1, AndroidUtilities.dp(5), redDotPaint);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
invalidate();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
public void playDeleteAnimation() {
|
|
|
|
playing = true;
|
|
|
|
drawable.setProgress(0);
|
|
|
|
if (attachedToWindow) {
|
|
|
|
drawable.start();
|
|
|
|
}
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
2020-03-30 14:00:09 +02:00
|
|
|
private Drawable micOutline;
|
|
|
|
private Drawable cameraOutline;
|
2017-03-31 01:58:05 +02:00
|
|
|
private Drawable micDrawable;
|
|
|
|
private Drawable cameraDrawable;
|
2017-07-08 18:32:04 +02:00
|
|
|
private Drawable sendDrawable;
|
2020-03-30 14:00:09 +02:00
|
|
|
private RectF pauseRect = new RectF();
|
|
|
|
private android.graphics.Rect sendRect = new Rect();
|
|
|
|
private android.graphics.Rect rect = new Rect();
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
private Drawable lockShadowDrawable;
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
public class RecordCircle extends View {
|
2017-07-08 18:32:04 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private float scale;
|
|
|
|
private float amplitude;
|
|
|
|
private float animateToAmplitude;
|
|
|
|
private float animateAmplitudeDiff;
|
|
|
|
private long lastUpdateTime;
|
2017-07-08 18:32:04 +02:00
|
|
|
private float lockAnimatedTranslation;
|
2020-03-30 14:00:09 +02:00
|
|
|
private float snapAnimationProgress;
|
2017-07-08 18:32:04 +02:00
|
|
|
private float startTranslation;
|
|
|
|
private boolean sendButtonVisible;
|
|
|
|
private boolean pressed;
|
2020-03-30 14:00:09 +02:00
|
|
|
private float transformToSeekbar;
|
|
|
|
private float exitTransition;
|
|
|
|
private float progressToSeekbarStep3;
|
|
|
|
private float progressToSendButton;
|
|
|
|
|
|
|
|
public float iconScale;
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
BlobDrawable tinyWaveDrawable = new BlobDrawable(11);
|
|
|
|
BlobDrawable bigWaveDrawable = new BlobDrawable(12);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
private Drawable tooltipBackground;
|
|
|
|
private Drawable tooltipBackgroundArrow;
|
|
|
|
private String tooltipMessage;
|
|
|
|
private StaticLayout tooltipLayout;
|
|
|
|
private float tooltipWidth;
|
|
|
|
private TextPaint tooltipPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
private float tooltipAlpha;
|
|
|
|
private boolean showTooltip;
|
|
|
|
private long showTooltipStartTime;
|
|
|
|
|
|
|
|
private float circleRadius = AndroidUtilities.dpf2(41);
|
|
|
|
private float circleRadiusAmplitude = AndroidUtilities.dp(30);
|
|
|
|
|
|
|
|
Paint lockBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
Paint lockPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
Paint lockOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
RectF rectF = new RectF();
|
|
|
|
Path path = new Path();
|
|
|
|
|
|
|
|
float idleProgress;
|
|
|
|
boolean incIdle;
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private VirtualViewHelper virtualViewHelper;
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private int paintAlpha;
|
|
|
|
private float touchSlop;
|
|
|
|
private float slideToCancelProgress;
|
|
|
|
private float slideToCancelLockProgress;
|
|
|
|
private int slideDelta;
|
|
|
|
private boolean canceledByGesture;
|
|
|
|
|
|
|
|
private float lastMovingX;
|
|
|
|
private float lastMovingY;
|
|
|
|
|
|
|
|
private float wavesEnterAnimation = 0f;
|
|
|
|
private boolean showWaves = true;
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
private Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
public float drawingCx, drawingCy, drawingCircleRadius;
|
|
|
|
|
|
|
|
public boolean voiceEnterTransitionInProgress;
|
|
|
|
public boolean skipDraw;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
public RecordCircle(Context context) {
|
|
|
|
super(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
micDrawable = getResources().getDrawable(R.drawable.input_mic_pressed).mutate();
|
2017-03-31 01:58:05 +02:00
|
|
|
micDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoicePressed), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
cameraDrawable = getResources().getDrawable(R.drawable.input_video_pressed).mutate();
|
2017-03-31 01:58:05 +02:00
|
|
|
cameraDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoicePressed), PorterDuff.Mode.MULTIPLY));
|
2017-07-08 18:32:04 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
sendDrawable = getResources().getDrawable(R.drawable.attach_send).mutate();
|
2017-07-08 18:32:04 +02:00
|
|
|
sendDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoicePressed), PorterDuff.Mode.MULTIPLY));
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
micOutline = getResources().getDrawable(R.drawable.input_mic).mutate();
|
|
|
|
micOutline.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
|
|
|
cameraOutline = getResources().getDrawable(R.drawable.input_video).mutate();
|
|
|
|
cameraOutline.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
virtualViewHelper = new VirtualViewHelper(this);
|
|
|
|
ViewCompat.setAccessibilityDelegate(this, virtualViewHelper);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
tinyWaveDrawable.minRadius = AndroidUtilities.dp(47);
|
|
|
|
tinyWaveDrawable.maxRadius = AndroidUtilities.dp(55);
|
|
|
|
tinyWaveDrawable.generateBlob();
|
|
|
|
|
|
|
|
bigWaveDrawable.minRadius = AndroidUtilities.dp(47);
|
|
|
|
bigWaveDrawable.maxRadius = AndroidUtilities.dp(55);
|
|
|
|
bigWaveDrawable.generateBlob();
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
lockOutlinePaint.setStyle(Paint.Style.STROKE);
|
|
|
|
lockOutlinePaint.setStrokeCap(Paint.Cap.ROUND);
|
|
|
|
lockOutlinePaint.setStrokeWidth(AndroidUtilities.dpf2(1.7f));
|
|
|
|
|
|
|
|
lockShadowDrawable = getResources().getDrawable(R.drawable.lock_round_shadow);
|
|
|
|
lockShadowDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoiceLockShadow), PorterDuff.Mode.MULTIPLY));
|
|
|
|
tooltipBackground = Theme.createRoundRectDrawable(AndroidUtilities.dp(5), Theme.getColor(Theme.key_chat_gifSaveHintBackground));
|
|
|
|
|
|
|
|
tooltipPaint.setTextSize(AndroidUtilities.dp(14));
|
|
|
|
tooltipBackgroundArrow = ContextCompat.getDrawable(context, R.drawable.tooltip_arrow);
|
|
|
|
tooltipMessage = LocaleController.getString("SlideUpToLock", R.string.SlideUpToLock);
|
|
|
|
iconScale = 1f;
|
|
|
|
|
|
|
|
final ViewConfiguration vc = ViewConfiguration.get(context);
|
|
|
|
touchSlop = vc.getScaledTouchSlop();
|
|
|
|
touchSlop *= touchSlop;
|
|
|
|
|
|
|
|
updateColors();
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setAmplitude(double value) {
|
2021-03-19 11:25:58 +01:00
|
|
|
bigWaveDrawable.setValue((float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE), true);
|
|
|
|
tinyWaveDrawable.setValue((float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE), false);
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
animateToAmplitude = (float) (Math.min(WaveDrawable.MAX_AMPLITUDE, value) / WaveDrawable.MAX_AMPLITUDE);
|
|
|
|
animateAmplitudeDiff = (animateToAmplitude - amplitude) / (100 + 500.0f * WaveDrawable.animationSpeedCircle);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getScale() {
|
|
|
|
return scale;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Keep
|
2015-10-29 18:10:07 +01:00
|
|
|
public void setScale(float value) {
|
|
|
|
scale = value;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Keep
|
2017-07-08 18:32:04 +02:00
|
|
|
public void setLockAnimatedTranslation(float value) {
|
|
|
|
lockAnimatedTranslation = value;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@Keep
|
|
|
|
public void setSnapAnimationProgress(float snapAnimationProgress) {
|
|
|
|
this.snapAnimationProgress = snapAnimationProgress;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
2017-07-08 18:32:04 +02:00
|
|
|
public float getLockAnimatedTranslation() {
|
|
|
|
return lockAnimatedTranslation;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isSendButtonVisible() {
|
|
|
|
return sendButtonVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSendButtonInvisible() {
|
|
|
|
sendButtonVisible = false;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int setLockTranslation(float value) {
|
|
|
|
if (value == 10000) {
|
|
|
|
sendButtonVisible = false;
|
|
|
|
lockAnimatedTranslation = -1;
|
|
|
|
startTranslation = -1;
|
|
|
|
invalidate();
|
2020-03-30 14:00:09 +02:00
|
|
|
snapAnimationProgress = 0;
|
|
|
|
transformToSeekbar = 0;
|
|
|
|
exitTransition = 0;
|
|
|
|
iconScale = 1f;
|
|
|
|
scale = 0f;
|
|
|
|
tooltipAlpha = 0f;
|
|
|
|
showTooltip = false;
|
|
|
|
progressToSendButton = 0f;
|
|
|
|
slideToCancelProgress = 1f;
|
|
|
|
slideToCancelLockProgress = 1f;
|
|
|
|
canceledByGesture = false;
|
2017-07-08 18:32:04 +02:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
if (sendButtonVisible) {
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if (lockAnimatedTranslation == -1) {
|
|
|
|
startTranslation = value;
|
|
|
|
}
|
|
|
|
lockAnimatedTranslation = value;
|
|
|
|
invalidate();
|
2020-03-30 14:00:09 +02:00
|
|
|
if (canceledByGesture || slideToCancelProgress < 0.7f) {
|
|
|
|
return 1;
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if (startTranslation - lockAnimatedTranslation >= AndroidUtilities.dp(57)) {
|
|
|
|
sendButtonVisible = true;
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
if (sendButtonVisible) {
|
|
|
|
int x = (int) event.getX();
|
|
|
|
int y = (int) event.getY();
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
2020-03-30 14:00:09 +02:00
|
|
|
return pressed = pauseRect.contains(x, y);
|
2017-07-08 18:32:04 +02:00
|
|
|
} else if (pressed) {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_UP) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (pauseRect.contains(x, y)) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (videoSendButton != null && videoSendButton.getTag() != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.needStartRecordVideo(3, true, 0);
|
2017-07-08 18:32:04 +02:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
MediaController.getInstance().stopRecording(2, true, 0);
|
2017-07-08 18:32:04 +02:00
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
slideText.setEnabled(false);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@SuppressLint("DrawAllocation")
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
int h = AndroidUtilities.dp(194);
|
|
|
|
tooltipLayout = new StaticLayout(tooltipMessage, tooltipPaint, AndroidUtilities.dp(220), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, true);
|
|
|
|
int n = tooltipLayout.getLineCount();
|
|
|
|
tooltipWidth = 0;
|
2020-07-26 10:03:38 +02:00
|
|
|
for (int i = 0; i < n; i++) {
|
2020-03-30 14:00:09 +02:00
|
|
|
float w = tooltipLayout.getLineWidth(i);
|
|
|
|
if (w > tooltipWidth) {
|
|
|
|
tooltipWidth = w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (tooltipLayout.getLineCount() > 1) {
|
|
|
|
h += tooltipLayout.getHeight() - tooltipLayout.getLineBottom(0);
|
|
|
|
}
|
|
|
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(h, MeasureSpec.EXACTLY));
|
|
|
|
|
|
|
|
float distance = getMeasuredWidth() * 0.35f;
|
|
|
|
if (distance > AndroidUtilities.dp(140)) {
|
|
|
|
distance = AndroidUtilities.dp(140);
|
|
|
|
}
|
|
|
|
slideDelta = (int) (-distance * (1f - slideToCancelProgress));
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2021-03-19 11:25:58 +01:00
|
|
|
if (skipDraw) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
float multilinTooltipOffset = 0;
|
2020-03-30 18:49:17 +02:00
|
|
|
if (tooltipLayout != null && tooltipLayout.getLineCount() > 1) {
|
2020-03-30 14:00:09 +02:00
|
|
|
multilinTooltipOffset = tooltipLayout.getHeight() - tooltipLayout.getLineBottom(0);
|
|
|
|
}
|
|
|
|
int cx = getMeasuredWidth() - AndroidUtilities.dp2(26);
|
|
|
|
int cy = (int) (AndroidUtilities.dp(170) + multilinTooltipOffset);
|
2017-07-08 18:32:04 +02:00
|
|
|
float yAdd = 0;
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
drawingCx = cx + slideDelta;
|
|
|
|
drawingCy = cy;
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
if (lockAnimatedTranslation != 10000) {
|
|
|
|
yAdd = Math.max(0, (int) (startTranslation - lockAnimatedTranslation));
|
|
|
|
if (yAdd > AndroidUtilities.dp(57)) {
|
|
|
|
yAdd = AndroidUtilities.dp(57);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
float sc;
|
2020-03-30 14:00:09 +02:00
|
|
|
float circleAlpha = 1f;
|
2015-10-29 18:10:07 +01:00
|
|
|
if (scale <= 0.5f) {
|
2020-03-30 14:00:09 +02:00
|
|
|
sc = scale / 0.5f;
|
2015-10-29 18:10:07 +01:00
|
|
|
} else if (scale <= 0.75f) {
|
|
|
|
sc = 1.0f - (scale - 0.5f) / 0.25f * 0.1f;
|
|
|
|
} else {
|
|
|
|
sc = 0.9f + (scale - 0.75f) / 0.25f * 0.1f;
|
|
|
|
}
|
|
|
|
long dt = System.currentTimeMillis() - lastUpdateTime;
|
|
|
|
if (animateToAmplitude != amplitude) {
|
|
|
|
amplitude += animateAmplitudeDiff * dt;
|
|
|
|
if (animateAmplitudeDiff > 0) {
|
|
|
|
if (amplitude > animateToAmplitude) {
|
|
|
|
amplitude = animateToAmplitude;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (amplitude < animateToAmplitude) {
|
|
|
|
amplitude = animateToAmplitude;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
invalidate();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
float slideToCancelScale;
|
|
|
|
if (canceledByGesture) {
|
|
|
|
slideToCancelScale = 0.7f * CubicBezierInterpolator.EASE_OUT.getInterpolation(1f - slideToCancelProgress);
|
|
|
|
} else {
|
|
|
|
slideToCancelScale = (0.7f + slideToCancelProgress * 0.3f);
|
|
|
|
}
|
|
|
|
float radius = (circleRadius + circleRadiusAmplitude * amplitude) * sc * slideToCancelScale;
|
|
|
|
|
|
|
|
progressToSeekbarStep3 = 0f;
|
|
|
|
float progressToSeekbarStep1 = 0f;
|
|
|
|
float progressToSeekbarStep2 = 0;
|
|
|
|
float exitProgress2 = 0f;
|
|
|
|
|
|
|
|
if (transformToSeekbar != 0) {
|
|
|
|
float step1Time = 0.38f;
|
|
|
|
float step2Time = 0.25f;
|
|
|
|
float step3Time = 1f - step1Time - step2Time;
|
|
|
|
|
|
|
|
progressToSeekbarStep1 = transformToSeekbar > step1Time ? 1f : transformToSeekbar / step1Time;
|
|
|
|
progressToSeekbarStep2 = transformToSeekbar > step1Time + step2Time ? 1f : Math.max(0, (transformToSeekbar - step1Time) / step2Time);
|
|
|
|
progressToSeekbarStep3 = Math.max(0, (transformToSeekbar - step1Time - step2Time) / step3Time);
|
|
|
|
|
|
|
|
progressToSeekbarStep1 = CubicBezierInterpolator.EASE_BOTH.getInterpolation(progressToSeekbarStep1);
|
|
|
|
progressToSeekbarStep2 = CubicBezierInterpolator.EASE_BOTH.getInterpolation(progressToSeekbarStep2);
|
|
|
|
progressToSeekbarStep3 = CubicBezierInterpolator.EASE_BOTH.getInterpolation(progressToSeekbarStep3);
|
|
|
|
|
|
|
|
radius = radius + AndroidUtilities.dp(16) * progressToSeekbarStep1;
|
|
|
|
|
|
|
|
float toRadius = recordedAudioBackground.getMeasuredHeight() / 2f;
|
|
|
|
radius = toRadius + (radius - toRadius) * (1f - progressToSeekbarStep2);
|
|
|
|
} else if (exitTransition != 0) {
|
|
|
|
float step1Time = 0.6f;
|
|
|
|
float step2Time = 0.4f;
|
|
|
|
|
|
|
|
progressToSeekbarStep1 = exitTransition > step1Time ? 1f : exitTransition / step1Time;
|
2021-03-19 11:25:58 +01:00
|
|
|
exitProgress2 = messageTransitionIsRunning ? exitTransition : Math.max(0, (exitTransition - step1Time) / step2Time);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
progressToSeekbarStep1 = CubicBezierInterpolator.EASE_BOTH.getInterpolation(progressToSeekbarStep1);
|
|
|
|
exitProgress2 = CubicBezierInterpolator.EASE_BOTH.getInterpolation(exitProgress2);
|
|
|
|
|
|
|
|
radius = radius + AndroidUtilities.dp(16) * progressToSeekbarStep1;
|
|
|
|
radius *= (1f - exitProgress2);
|
|
|
|
|
|
|
|
if (configAnimationsEnabled && exitTransition > 0.6f) {
|
|
|
|
circleAlpha = Math.max(0, 1f - (exitTransition - 0.6f) / 0.4f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canceledByGesture && slideToCancelProgress > 0.7f) {
|
|
|
|
circleAlpha *= (1f - (slideToCancelProgress - 0.7f) / 0.3f);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (progressToSeekbarStep3 > 0) {
|
|
|
|
paint.setColor(ColorUtils.blendARGB(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground), Theme.getColor(Theme.key_chat_recordedVoiceBackground), progressToSeekbarStep3));
|
|
|
|
} else {
|
|
|
|
paint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
Drawable drawable;
|
2020-03-30 14:00:09 +02:00
|
|
|
Drawable replaceDrawable = null;
|
2017-07-08 18:32:04 +02:00
|
|
|
if (isSendButtonVisible()) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (progressToSendButton != 1f) {
|
|
|
|
progressToSendButton += dt / 150f;
|
|
|
|
if (progressToSendButton > 1f) {
|
|
|
|
progressToSendButton = 1f;
|
|
|
|
}
|
|
|
|
replaceDrawable = videoSendButton != null && videoSendButton.getTag() != null ? cameraDrawable : micDrawable;
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
drawable = sendDrawable;
|
|
|
|
} else {
|
|
|
|
drawable = videoSendButton != null && videoSendButton.getTag() != null ? cameraDrawable : micDrawable;
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
sendRect.set(cx - drawable.getIntrinsicWidth() / 2, cy - drawable.getIntrinsicHeight() / 2, cx + drawable.getIntrinsicWidth() / 2, cy + drawable.getIntrinsicHeight() / 2);
|
|
|
|
drawable.setBounds(sendRect);
|
|
|
|
if (replaceDrawable != null) {
|
|
|
|
replaceDrawable.setBounds(cx - replaceDrawable.getIntrinsicWidth() / 2, cy - replaceDrawable.getIntrinsicHeight() / 2, cx + replaceDrawable.getIntrinsicWidth() / 2, cy + replaceDrawable.getIntrinsicHeight() / 2);
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
|
|
|
|
float moveProgress = 1.0f - yAdd / AndroidUtilities.dp(57);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
float lockSize;
|
|
|
|
float lockY;
|
|
|
|
float lockTopY;
|
|
|
|
float lockMiddleY;
|
|
|
|
|
|
|
|
float lockRotation;
|
|
|
|
float transformToPauseProgress = 0;
|
|
|
|
|
|
|
|
if (incIdle) {
|
|
|
|
idleProgress += 0.01f;
|
|
|
|
if (idleProgress > 1f) {
|
|
|
|
incIdle = false;
|
|
|
|
idleProgress = 1f;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
idleProgress -= 0.01f;
|
|
|
|
if (idleProgress < 0) {
|
|
|
|
incIdle = true;
|
|
|
|
idleProgress = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (configAnimationsEnabled) {
|
2021-03-19 11:25:58 +01:00
|
|
|
tinyWaveDrawable.minRadius = AndroidUtilities.dp(47);
|
|
|
|
tinyWaveDrawable.maxRadius = AndroidUtilities.dp(47) + AndroidUtilities.dp(15) * BlobDrawable.FORM_SMALL_MAX;
|
|
|
|
|
|
|
|
bigWaveDrawable.minRadius = AndroidUtilities.dp(50);
|
|
|
|
bigWaveDrawable.maxRadius = AndroidUtilities.dp(50) + AndroidUtilities.dp(12) * BlobDrawable.FORM_BIG_MAX;
|
|
|
|
|
|
|
|
bigWaveDrawable.updateAmplitude(dt);
|
|
|
|
bigWaveDrawable.update(bigWaveDrawable.amplitude, 1.01f);
|
|
|
|
tinyWaveDrawable.updateAmplitude(dt);
|
|
|
|
tinyWaveDrawable.update(tinyWaveDrawable.amplitude, 1.02f);
|
|
|
|
|
|
|
|
// bigWaveDrawable.tick(radius);
|
|
|
|
// tinyWaveDrawable.tick(radius);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
lastUpdateTime = System.currentTimeMillis();
|
|
|
|
float slideToCancelProgress1 = slideToCancelProgress > 0.7f ? 1f : slideToCancelProgress / 0.7f;
|
2021-03-19 11:25:58 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (configAnimationsEnabled && progressToSeekbarStep2 != 1 && exitProgress2 < 0.4f && slideToCancelProgress1 > 0 && !canceledByGesture) {
|
|
|
|
if (showWaves && wavesEnterAnimation != 1f) {
|
|
|
|
wavesEnterAnimation += 0.04f;
|
|
|
|
if (wavesEnterAnimation > 1f) {
|
|
|
|
wavesEnterAnimation = 1f;
|
|
|
|
}
|
|
|
|
}
|
2021-03-19 11:25:58 +01:00
|
|
|
if (!voiceEnterTransitionInProgress) {
|
|
|
|
float enter = CubicBezierInterpolator.EASE_OUT.getInterpolation(wavesEnterAnimation);
|
|
|
|
canvas.save();
|
|
|
|
float s = scale * (1f - progressToSeekbarStep1) * slideToCancelProgress1 * enter * (BlobDrawable.SCALE_BIG_MIN + 1.4f * bigWaveDrawable.amplitude);
|
|
|
|
canvas.scale(s, s, cx + slideDelta, cy);
|
|
|
|
bigWaveDrawable.draw(cx + slideDelta, cy, canvas, bigWaveDrawable.paint);
|
|
|
|
canvas.restore();
|
|
|
|
s = scale * (1f - progressToSeekbarStep1) * slideToCancelProgress1 * enter * (BlobDrawable.SCALE_SMALL_MIN + 1.4f * tinyWaveDrawable.amplitude);
|
|
|
|
canvas.save();
|
|
|
|
canvas.scale(s, s, cx + slideDelta, cy);
|
|
|
|
tinyWaveDrawable.draw(cx + slideDelta, cy, canvas, tinyWaveDrawable.paint);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
if (!voiceEnterTransitionInProgress) {
|
|
|
|
paint.setAlpha((int) (paintAlpha * circleAlpha));
|
|
|
|
if (this.scale == 1f) {
|
|
|
|
if (transformToSeekbar != 0) {
|
|
|
|
if (progressToSeekbarStep3 > 0) {
|
|
|
|
float circleB = cy + radius;
|
|
|
|
float circleT = cy - radius;
|
|
|
|
float circleR = cx + slideDelta + radius;
|
|
|
|
float circleL = cx + slideDelta - radius;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
int topOffset = 0;
|
|
|
|
int leftOffset = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
View transformToView = recordedAudioBackground;
|
|
|
|
View v = (View) transformToView.getParent();
|
|
|
|
while (v != getParent()) {
|
|
|
|
topOffset += v.getTop();
|
|
|
|
leftOffset += v.getLeft();
|
|
|
|
v = (View) v.getParent();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
int seekbarT = transformToView.getTop() + topOffset - getTop();
|
|
|
|
int seekbarB = transformToView.getBottom() + topOffset - getTop();
|
|
|
|
int seekbarR = transformToView.getRight() + leftOffset - getLeft();
|
|
|
|
int seekbarL = transformToView.getLeft() + leftOffset - getLeft();
|
|
|
|
float toRadius = isInVideoMode() ? 0 : transformToView.getMeasuredHeight() / 2f;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
float top = seekbarT + (circleT - seekbarT) * (1f - progressToSeekbarStep3);
|
|
|
|
float bottom = seekbarB + (circleB - seekbarB) * (1f - progressToSeekbarStep3);
|
|
|
|
float left = seekbarL + (circleL - seekbarL) * (1f - progressToSeekbarStep3);
|
|
|
|
float right = seekbarR + (circleR - seekbarR) * (1f - progressToSeekbarStep3);
|
|
|
|
float transformRadius = toRadius + (radius - toRadius) * (1f - progressToSeekbarStep3);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
rectF.set(left, top, right, bottom);
|
|
|
|
canvas.drawRoundRect(rectF, transformRadius, transformRadius, paint);
|
|
|
|
} else {
|
|
|
|
canvas.drawCircle(cx + slideDelta, cy, radius, paint);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
|
|
|
canvas.drawCircle(cx + slideDelta, cy, radius, paint);
|
|
|
|
}
|
2021-03-19 11:25:58 +01:00
|
|
|
canvas.save();
|
|
|
|
float a = (1f - exitProgress2);
|
|
|
|
canvas.translate(slideDelta, 0);
|
|
|
|
drawIconInternal(canvas, drawable, replaceDrawable, progressToSendButton, (int) ((1f - progressToSeekbarStep2) * a * 255));
|
|
|
|
canvas.restore();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
if (isSendButtonVisible()) {
|
2020-03-30 14:00:09 +02:00
|
|
|
lockSize = AndroidUtilities.dp(36);
|
|
|
|
lockY = AndroidUtilities.dp(60) + multilinTooltipOffset + AndroidUtilities.dpf2(30) * (1.0f - sc) - yAdd + AndroidUtilities.dpf2(14f) * moveProgress;
|
|
|
|
|
|
|
|
lockMiddleY = lockY + lockSize / 2f - AndroidUtilities.dpf2(8) + AndroidUtilities.dpf2(2);
|
|
|
|
lockTopY = lockY + lockSize / 2f - AndroidUtilities.dpf2(16) + AndroidUtilities.dpf2(2);
|
|
|
|
float snapRotateBackProgress = moveProgress > 0.4f ? 1f : moveProgress / 0.4f;
|
|
|
|
|
|
|
|
lockRotation = 9 * (1f - moveProgress) * (1f - snapAnimationProgress) - 15 * snapAnimationProgress * (1f - snapRotateBackProgress);
|
|
|
|
|
|
|
|
transformToPauseProgress = moveProgress;
|
|
|
|
} else {
|
|
|
|
lockSize = AndroidUtilities.dp(36) + (int) (AndroidUtilities.dp(14) * moveProgress);
|
|
|
|
lockY = AndroidUtilities.dp(60) + multilinTooltipOffset + (int) (AndroidUtilities.dp(30) * (1.0f - sc)) - (int) yAdd + (moveProgress) * idleProgress * -AndroidUtilities.dp(8);
|
|
|
|
lockMiddleY = lockY + lockSize / 2f - AndroidUtilities.dpf2(8) + AndroidUtilities.dpf2(2) + AndroidUtilities.dpf2(2) * moveProgress;
|
|
|
|
lockTopY = lockY + lockSize / 2f - AndroidUtilities.dpf2(16) + AndroidUtilities.dpf2(2) + AndroidUtilities.dpf2(2) * moveProgress;
|
|
|
|
lockRotation = 9 * (1f - moveProgress);
|
|
|
|
snapAnimationProgress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((showTooltip && System.currentTimeMillis() - showTooltipStartTime > 200) || tooltipAlpha != 0f) {
|
|
|
|
if (moveProgress < 0.8f || isSendButtonVisible() || exitTransition != 0 || transformToSeekbar != 0) {
|
|
|
|
showTooltip = false;
|
|
|
|
}
|
|
|
|
if (showTooltip) {
|
|
|
|
if (tooltipAlpha != 1f) {
|
|
|
|
tooltipAlpha += dt / 150f;
|
|
|
|
if (tooltipAlpha >= 1f) {
|
|
|
|
tooltipAlpha = 1f;
|
|
|
|
SharedConfig.increaseLockRecordAudioVideoHintShowed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
tooltipAlpha -= dt / 150f;
|
|
|
|
if (tooltipAlpha < 0) {
|
|
|
|
tooltipAlpha = 0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 18:49:17 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
int alphaInt = (int) (tooltipAlpha * 255);
|
|
|
|
|
|
|
|
tooltipBackground.setAlpha(alphaInt);
|
|
|
|
tooltipBackgroundArrow.setAlpha(alphaInt);
|
|
|
|
tooltipPaint.setAlpha(alphaInt);
|
|
|
|
|
2020-03-30 18:49:17 +02:00
|
|
|
if (tooltipLayout != null) {
|
|
|
|
canvas.save();
|
|
|
|
rectF.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
canvas.translate(getMeasuredWidth() - tooltipWidth - AndroidUtilities.dp(44), AndroidUtilities.dpf2(16));
|
|
|
|
tooltipBackground.setBounds(
|
|
|
|
-AndroidUtilities.dp(8), -AndroidUtilities.dp(2),
|
|
|
|
(int) (tooltipWidth + AndroidUtilities.dp(36)), (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(4))
|
|
|
|
);
|
|
|
|
tooltipBackground.draw(canvas);
|
|
|
|
tooltipLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(cx, AndroidUtilities.dpf2(17) + tooltipLayout.getHeight() / 2f - idleProgress * AndroidUtilities.dpf2(3f));
|
|
|
|
path.reset();
|
|
|
|
path.setLastPoint(-AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
|
|
|
path.lineTo(0, 0);
|
|
|
|
path.lineTo(AndroidUtilities.dpf2(5), AndroidUtilities.dpf2(4));
|
|
|
|
|
|
|
|
p.setColor(Color.WHITE);
|
|
|
|
p.setAlpha(alphaInt);
|
|
|
|
p.setStyle(Paint.Style.STROKE);
|
|
|
|
p.setStrokeCap(Paint.Cap.ROUND);
|
|
|
|
p.setStrokeJoin(Paint.Join.ROUND);
|
|
|
|
p.setStrokeWidth(AndroidUtilities.dpf2(1.5f));
|
|
|
|
canvas.drawPath(path, p);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
tooltipBackgroundArrow.setBounds(
|
|
|
|
cx - tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)),
|
|
|
|
cx + tooltipBackgroundArrow.getIntrinsicWidth() / 2, (int) (tooltipLayout.getHeight() + AndroidUtilities.dpf2(20)) + tooltipBackgroundArrow.getIntrinsicHeight()
|
|
|
|
);
|
|
|
|
tooltipBackgroundArrow.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(0, 0, getMeasuredWidth(), getMeasuredHeight() - textFieldContainer.getMeasuredHeight());
|
|
|
|
float translation = 0;
|
|
|
|
if (1f - scale != 0) {
|
|
|
|
translation = 1f - scale;
|
|
|
|
} else if (progressToSeekbarStep2 != 0) {
|
|
|
|
translation = progressToSeekbarStep2;
|
|
|
|
} else if (exitProgress2 != 0) {
|
|
|
|
translation = exitProgress2;
|
|
|
|
}
|
|
|
|
if (slideToCancelProgress < 0.7f || canceledByGesture) {
|
|
|
|
showTooltip = false;
|
|
|
|
if (slideToCancelLockProgress != 0) {
|
|
|
|
slideToCancelLockProgress -= 0.12f;
|
|
|
|
if (slideToCancelLockProgress < 0) {
|
|
|
|
slideToCancelLockProgress = 0;
|
|
|
|
}
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (slideToCancelLockProgress != 1f) {
|
|
|
|
slideToCancelLockProgress += 0.12f;
|
|
|
|
if (slideToCancelLockProgress > 1f) {
|
|
|
|
slideToCancelLockProgress = 1f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float maxTranslationDy = AndroidUtilities.dpf2(72);
|
|
|
|
float dy = maxTranslationDy * translation - AndroidUtilities.dpf2(20) * (progressToSeekbarStep1) * (1f - translation) + maxTranslationDy * (1f - slideToCancelLockProgress);
|
|
|
|
if (dy > maxTranslationDy) {
|
|
|
|
dy = maxTranslationDy;
|
|
|
|
}
|
|
|
|
canvas.translate(0, dy);
|
|
|
|
float s = scale * (1f - progressToSeekbarStep2) * (1f - exitProgress2) * slideToCancelLockProgress;
|
|
|
|
canvas.scale(s, s, cx, lockMiddleY);
|
|
|
|
|
|
|
|
rectF.set(cx - AndroidUtilities.dpf2(18), lockY, cx + AndroidUtilities.dpf2(18), lockY + lockSize);
|
|
|
|
lockShadowDrawable.setBounds(
|
|
|
|
(int) (rectF.left - AndroidUtilities.dpf2(3)), (int) (rectF.top - AndroidUtilities.dpf2(3)),
|
|
|
|
(int) (rectF.right + AndroidUtilities.dpf2(3)), (int) (rectF.bottom + AndroidUtilities.dpf2(3))
|
|
|
|
);
|
2017-07-08 18:32:04 +02:00
|
|
|
lockShadowDrawable.draw(canvas);
|
2020-03-30 14:00:09 +02:00
|
|
|
canvas.drawRoundRect(rectF, AndroidUtilities.dpf2(18), AndroidUtilities.dpf2(18), lockBackgroundPaint);
|
|
|
|
pauseRect.set(rectF);
|
|
|
|
|
|
|
|
rectF.set(
|
|
|
|
cx - AndroidUtilities.dpf2(6) - AndroidUtilities.dpf2(2) * (1f - transformToPauseProgress),
|
|
|
|
lockMiddleY - AndroidUtilities.dpf2(2) * (1f - transformToPauseProgress),
|
|
|
|
cx + AndroidUtilities.dp(6) + AndroidUtilities.dpf2(2) * (1f - transformToPauseProgress),
|
|
|
|
lockMiddleY + AndroidUtilities.dp(12) + AndroidUtilities.dpf2(2) * (1f - transformToPauseProgress)
|
|
|
|
);
|
|
|
|
float lockBottom = rectF.bottom;
|
|
|
|
float locCx = rectF.centerX();
|
|
|
|
float locCy = rectF.centerY();
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(0, AndroidUtilities.dpf2(2) * (1f - moveProgress));
|
|
|
|
canvas.rotate(lockRotation, locCx, locCy);
|
|
|
|
canvas.drawRoundRect(rectF, AndroidUtilities.dpf2(3), AndroidUtilities.dpf2(3), lockPaint);
|
|
|
|
|
|
|
|
if (transformToPauseProgress != 1) {
|
|
|
|
canvas.drawCircle(locCx, locCy, AndroidUtilities.dpf2(2) * (1f - transformToPauseProgress), lockBackgroundPaint);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transformToPauseProgress != 1f) {
|
|
|
|
rectF.set(0, 0, AndroidUtilities.dpf2(8), AndroidUtilities.dpf2(8));
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(0, 0, getMeasuredWidth(), dy + lockBottom + AndroidUtilities.dpf2(2) * (1f - moveProgress));
|
|
|
|
canvas.translate(cx - AndroidUtilities.dpf2(4), lockTopY - AndroidUtilities.dpf2(1.5f) * (1f - idleProgress) * (moveProgress) - AndroidUtilities.dpf2(2) * (1f - moveProgress) + AndroidUtilities.dpf2(12) * transformToPauseProgress + AndroidUtilities.dpf2(2) * snapAnimationProgress);
|
|
|
|
if (lockRotation > 0) {
|
|
|
|
canvas.rotate(lockRotation, AndroidUtilities.dp(8), AndroidUtilities.dp(8));
|
|
|
|
}
|
|
|
|
canvas.drawLine(AndroidUtilities.dpf2(8), AndroidUtilities.dpf2(4), AndroidUtilities.dpf2(8), AndroidUtilities.dpf2(6) + AndroidUtilities.dpf2(4) * (1f - transformToPauseProgress), lockOutlinePaint);
|
|
|
|
canvas.drawArc(rectF, 0, -180, false, lockOutlinePaint);
|
|
|
|
canvas.drawLine(
|
|
|
|
0, AndroidUtilities.dpf2(4),
|
|
|
|
0, AndroidUtilities.dpf2(4) + AndroidUtilities.dpf2(4) * idleProgress * (moveProgress) * (isSendButtonVisible() ? 0 : 1) + AndroidUtilities.dpf2(4) * snapAnimationProgress * (1f - moveProgress),
|
|
|
|
lockOutlinePaint
|
|
|
|
);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
canvas.restore();
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
if (scale != 1f) {
|
|
|
|
canvas.drawCircle(cx + slideDelta, cy, radius, paint);
|
|
|
|
float a = (canceledByGesture ? (1f - slideToCancelProgress) : 1);
|
2021-03-19 11:25:58 +01:00
|
|
|
canvas.save();
|
|
|
|
canvas.translate(slideDelta, 0);
|
|
|
|
drawIconInternal(canvas, drawable, replaceDrawable, progressToSendButton, (int) (255 * a));
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
drawingCircleRadius = radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void drawIcon(Canvas canvas, int cx, int cy, float alpha) {
|
|
|
|
Drawable drawable;
|
|
|
|
Drawable replaceDrawable = null;
|
|
|
|
if (isSendButtonVisible()) {
|
|
|
|
if (progressToSendButton != 1f) {
|
|
|
|
replaceDrawable = videoSendButton != null && videoSendButton.getTag() != null ? cameraDrawable : micDrawable;
|
|
|
|
}
|
|
|
|
drawable = sendDrawable;
|
|
|
|
} else {
|
|
|
|
drawable = videoSendButton != null && videoSendButton.getTag() != null ? cameraDrawable : micDrawable;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2021-03-19 11:25:58 +01:00
|
|
|
sendRect.set(cx - drawable.getIntrinsicWidth() / 2, cy - drawable.getIntrinsicHeight() / 2, cx + drawable.getIntrinsicWidth() / 2, cy + drawable.getIntrinsicHeight() / 2);
|
|
|
|
drawable.setBounds(sendRect);
|
|
|
|
if (replaceDrawable != null) {
|
|
|
|
replaceDrawable.setBounds(cx - replaceDrawable.getIntrinsicWidth() / 2, cy - replaceDrawable.getIntrinsicHeight() / 2, cx + replaceDrawable.getIntrinsicWidth() / 2, cy + replaceDrawable.getIntrinsicHeight() / 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
drawIconInternal(canvas, drawable, replaceDrawable, progressToSendButton, (int) (255 * alpha));
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
private void drawIconInternal(Canvas canvas, Drawable drawable, Drawable replaceDrawable, float progressToSendButton, int alpha) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (progressToSendButton == 0 || progressToSendButton == 1 || replaceDrawable == null) {
|
|
|
|
if (canceledByGesture && slideToCancelProgress == 1f) {
|
|
|
|
View v = isInVideoMode() ? videoSendButton : audioSendButton;
|
|
|
|
v.setAlpha(1f);
|
|
|
|
setVisibility(View.GONE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (canceledByGesture && slideToCancelProgress < 1f) {
|
|
|
|
Drawable outlineDrawable = isInVideoMode() ? cameraOutline : micOutline;
|
|
|
|
outlineDrawable.setBounds(drawable.getBounds());
|
|
|
|
int a = (int) (slideToCancelProgress < 0.93f ? 0f : (slideToCancelProgress - 0.93f) / 0.07f * 255);
|
|
|
|
outlineDrawable.setAlpha(a);
|
|
|
|
outlineDrawable.draw(canvas);
|
|
|
|
outlineDrawable.setAlpha(255);
|
|
|
|
|
|
|
|
drawable.setAlpha(255 - a);
|
|
|
|
drawable.draw(canvas);
|
|
|
|
} else if (!canceledByGesture) {
|
|
|
|
drawable.setAlpha(alpha);
|
|
|
|
drawable.draw(canvas);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
canvas.save();
|
|
|
|
canvas.scale(progressToSendButton, progressToSendButton, drawable.getBounds().centerX(), drawable.getBounds().centerY());
|
|
|
|
drawable.setAlpha((int) (alpha * progressToSendButton));
|
|
|
|
drawable.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.scale(1f - progressToSendButton, 1f - progressToSendButton, drawable.getBounds().centerX(), drawable.getBounds().centerY());
|
|
|
|
replaceDrawable.setAlpha((int) (alpha * (1f - progressToSendButton)));
|
|
|
|
replaceDrawable.draw(canvas);
|
|
|
|
canvas.restore();
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean dispatchHoverEvent(MotionEvent event) {
|
|
|
|
return super.dispatchHoverEvent(event) || virtualViewHelper.dispatchHoverEvent(event);
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
public void setTransformToSeekbar(float value) {
|
|
|
|
transformToSeekbar = value;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getTransformToSeekbarProgressStep3() {
|
|
|
|
return progressToSeekbarStep3;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public float getExitTransition() {
|
|
|
|
return exitTransition;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public void setExitTransition(float exitTransition) {
|
|
|
|
this.exitTransition = exitTransition;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateColors() {
|
|
|
|
paint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground));
|
2021-03-19 11:25:58 +01:00
|
|
|
tinyWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground), (int) (255 * WaveDrawable.CIRCLE_ALPHA_2)));
|
|
|
|
bigWaveDrawable.paint.setColor(ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_messagePanelVoiceBackground), (int) (255 * WaveDrawable.CIRCLE_ALPHA_1)));
|
2020-03-30 14:00:09 +02:00
|
|
|
tooltipPaint.setColor(Theme.getColor(Theme.key_chat_gifSaveHintText));
|
|
|
|
tooltipBackground = Theme.createRoundRectDrawable(AndroidUtilities.dp(5), Theme.getColor(Theme.key_chat_gifSaveHintBackground));
|
|
|
|
tooltipBackgroundArrow.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_gifSaveHintBackground), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
|
|
|
lockBackgroundPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceLockBackground));
|
|
|
|
lockPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceLock));
|
|
|
|
lockOutlinePaint.setColor(Theme.getColor(Theme.key_chat_messagePanelVoiceLock));
|
|
|
|
|
|
|
|
paintAlpha = paint.getAlpha();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showTooltipIfNeed() {
|
|
|
|
if (SharedConfig.lockRecordAudioVideoHint < 3) {
|
|
|
|
showTooltip = true;
|
|
|
|
showTooltipStartTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public float getSlideToCancelProgress() {
|
|
|
|
return slideToCancelProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public void setSlideToCancelProgress(float slideToCancelProgress) {
|
|
|
|
this.slideToCancelProgress = slideToCancelProgress;
|
|
|
|
float distance = getMeasuredWidth() * 0.35f;
|
|
|
|
if (distance > AndroidUtilities.dp(140)) {
|
|
|
|
distance = AndroidUtilities.dp(140);
|
|
|
|
}
|
|
|
|
slideDelta = (int) (-distance * (1f - slideToCancelProgress));
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void canceledByGesture() {
|
|
|
|
canceledByGesture = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMovingCords(float x, float y) {
|
|
|
|
float delta = (x - lastMovingX) * (x - lastMovingX) + (y - lastMovingY) * (y - lastMovingY);
|
|
|
|
lastMovingY = y;
|
|
|
|
lastMovingX = x;
|
|
|
|
if (showTooltip && tooltipAlpha == 0f && delta > touchSlop) {
|
|
|
|
showTooltipStartTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showWaves(boolean b, boolean animated) {
|
|
|
|
if (!animated) {
|
2020-07-26 10:03:38 +02:00
|
|
|
wavesEnterAnimation = b ? 1f : 0.5f;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
showWaves = b;
|
|
|
|
}
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
public void drawWaves(Canvas canvas, float cx, float cy, float additionalScale) {
|
|
|
|
float enter = CubicBezierInterpolator.EASE_OUT.getInterpolation(wavesEnterAnimation);
|
|
|
|
float slideToCancelProgress1 = slideToCancelProgress > 0.7f ? 1f : slideToCancelProgress / 0.7f;
|
|
|
|
canvas.save();
|
|
|
|
float s = scale * slideToCancelProgress1 * enter * (BlobDrawable.SCALE_BIG_MIN + 1.4f * bigWaveDrawable.amplitude) * additionalScale;
|
|
|
|
canvas.scale(s, s, cx, cy);
|
|
|
|
bigWaveDrawable.draw(cx, cy, canvas, bigWaveDrawable.paint);
|
|
|
|
canvas.restore();
|
|
|
|
s = scale * slideToCancelProgress1 * enter * (BlobDrawable.SCALE_SMALL_MIN + 1.4f * tinyWaveDrawable.amplitude) * additionalScale;
|
|
|
|
canvas.save();
|
|
|
|
canvas.scale(s, s, cx, cy);
|
|
|
|
tinyWaveDrawable.draw(cx, cy, canvas, tinyWaveDrawable.paint);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private class VirtualViewHelper extends ExploreByTouchHelper {
|
|
|
|
|
|
|
|
public VirtualViewHelper(@NonNull View host) {
|
|
|
|
super(host);
|
|
|
|
}
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
@Override
|
|
|
|
protected int getVirtualViewAt(float x, float y) {
|
|
|
|
if (isSendButtonVisible()) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (sendRect.contains((int) x, (int) y)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return 1;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (pauseRect.contains(x, y)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return HOST_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void getVisibleVirtualViews(List<Integer> list) {
|
2019-12-31 14:08:08 +01:00
|
|
|
if (isSendButtonVisible()) {
|
2019-05-14 14:08:05 +02:00
|
|
|
list.add(1);
|
|
|
|
list.add(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPopulateNodeForVirtualView(int id, @NonNull AccessibilityNodeInfoCompat info) {
|
|
|
|
if (id == 1) {
|
2020-03-30 14:00:09 +02:00
|
|
|
info.setBoundsInParent(sendRect);
|
2019-05-14 14:08:05 +02:00
|
|
|
info.setText(LocaleController.getString("Send", R.string.Send));
|
2019-12-31 14:08:08 +01:00
|
|
|
} else if (id == 2) {
|
2020-03-30 14:00:09 +02:00
|
|
|
rect.set((int) pauseRect.left, (int) pauseRect.top, (int) pauseRect.right, (int) pauseRect.bottom);
|
|
|
|
info.setBoundsInParent(rect);
|
2019-05-14 14:08:05 +02:00
|
|
|
info.setText(LocaleController.getString("Stop", R.string.Stop));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean onPerformActionForVirtualView(int id, int action, @Nullable Bundle args) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
public ChatActivityEnterView(Activity context, SizeNotifierFrameLayout parent, ChatActivity fragment, final boolean isChat) {
|
|
|
|
super(context);
|
|
|
|
|
2020-10-15 02:39:36 +02:00
|
|
|
smoothKeyboard = isChat && SharedConfig.smoothKeyboard && !AndroidUtilities.isInMultiwindow && (fragment == null || !fragment.isInBubbleMode());
|
2020-03-30 14:00:09 +02:00
|
|
|
dotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
dotPaint.setColor(Theme.getColor(Theme.key_chat_emojiPanelNewTrending));
|
|
|
|
setFocusable(true);
|
|
|
|
setFocusableInTouchMode(true);
|
|
|
|
setWillNotDraw(false);
|
2020-07-26 10:03:38 +02:00
|
|
|
setClipChildren(false);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStarted);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStartError);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStopped);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordProgressChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.closeChats);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.audioDidSent);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.audioRouteChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidReset);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.featuredStickersDidLoad);
|
2019-08-22 01:53:26 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.sendingMessagesChanged);
|
2020-03-30 14:00:09 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.audioRecordTooShort);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
parentActivity = context;
|
2015-02-27 20:57:58 +01:00
|
|
|
parentFragment = fragment;
|
2019-09-10 12:56:11 +02:00
|
|
|
if (fragment != null) {
|
|
|
|
recordingGuid = parentFragment.getClassGuid();
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
sizeNotifierLayout = parent;
|
2015-06-29 19:12:11 +02:00
|
|
|
sizeNotifierLayout.setDelegate(this);
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
2014-07-03 00:39:05 +02:00
|
|
|
sendByEnter = preferences.getBoolean("send_by_enter", false);
|
2020-03-30 14:00:09 +02:00
|
|
|
configAnimationsEnabled = preferences.getBoolean("view_animations", true);
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
textFieldContainer = new LinearLayout(context);
|
|
|
|
textFieldContainer.setOrientation(LinearLayout.HORIZONTAL);
|
2019-08-22 01:53:26 +02:00
|
|
|
textFieldContainer.setClipChildren(false);
|
|
|
|
textFieldContainer.setClipToPadding(false);
|
2020-03-30 14:00:09 +02:00
|
|
|
textFieldContainer.setPadding(0, AndroidUtilities.dp(1), 0, 0);
|
|
|
|
addView(textFieldContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM, 0, 1, 0, 0));
|
2015-03-19 00:09:45 +01:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
FrameLayout frameLayout = new FrameLayout(context) {
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
int x = getMeasuredWidth() - AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48) - AndroidUtilities.dp(48);
|
|
|
|
scheduledButton.layout(x, scheduledButton.getTop(), x + scheduledButton.getMeasuredWidth(), scheduledButton.getBottom());
|
|
|
|
}
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
|
|
|
if (child == messageEditText) {
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(0, -getTop() - textFieldContainer.getTop() - ChatActivityEnterView.this.getTop(), getMeasuredWidth(), getMeasuredHeight() - AndroidUtilities.dp(6));
|
|
|
|
boolean rez = super.drawChild(canvas, child, drawingTime);
|
|
|
|
canvas.restore();
|
|
|
|
return rez;
|
|
|
|
}
|
|
|
|
return super.drawChild(canvas, child, drawingTime);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
};
|
2020-03-30 14:00:09 +02:00
|
|
|
frameLayout.setClipChildren(false);
|
2019-05-14 14:08:05 +02:00
|
|
|
textFieldContainer.addView(frameLayout, LayoutHelper.createLinear(0, LayoutHelper.WRAP_CONTENT, 1.0f, Gravity.BOTTOM));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0; a < 2; a++) {
|
|
|
|
emojiButton[a] = new ImageView(context) {
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
super.onDraw(canvas);
|
2019-07-18 15:01:39 +02:00
|
|
|
if (getTag() != null && attachLayout != null && !emojiViewVisible && !MediaDataController.getInstance(currentAccount).getUnreadStickerSets().isEmpty() && dotPaint != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
int x = getWidth() / 2 + AndroidUtilities.dp(4 + 5);
|
|
|
|
int y = getHeight() / 2 - AndroidUtilities.dp(13 - 5);
|
|
|
|
canvas.drawCircle(x, y, AndroidUtilities.dp(5), dotPaint);
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
};
|
|
|
|
emojiButton[a].setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
|
|
|
emojiButton[a].setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
emojiButton[a].setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
frameLayout.addView(emojiButton[a], LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.LEFT, 3, 0, 0, 0));
|
|
|
|
emojiButton[a].setOnClickListener(view -> {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (adjustPanLayoutHelper != null && adjustPanLayoutHelper.animationInProgress()) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (!isPopupShowing() || currentPopupContentType != 0) {
|
|
|
|
showPopup(1, 0);
|
|
|
|
emojiView.onOpen(messageEditText.length() > 0);
|
|
|
|
} else {
|
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2020-10-02 23:48:16 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.closeSearch(false);
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (stickersExpanded) {
|
|
|
|
setStickersExpanded(false, true, false);
|
|
|
|
waitingForKeyboardOpenAfterAnimation = true;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
waitingForKeyboardOpenAfterAnimation = false;
|
|
|
|
openKeyboardInternal();
|
|
|
|
}, 200);
|
|
|
|
} else {
|
|
|
|
openKeyboardInternal();
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
});
|
|
|
|
emojiButton[a].setContentDescription(LocaleController.getString("AccDescrEmojiButton", R.string.AccDescrEmojiButton));
|
|
|
|
if (a == 1) {
|
|
|
|
emojiButton[a].setVisibility(INVISIBLE);
|
|
|
|
emojiButton[a].setAlpha(0.0f);
|
|
|
|
emojiButton[a].setScaleX(0.1f);
|
|
|
|
emojiButton[a].setScaleY(0.1f);
|
2019-12-31 14:08:08 +01:00
|
|
|
emojiButton2 = emojiButton[a];
|
|
|
|
} else {
|
|
|
|
emojiButton1 = emojiButton[a];
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
|
|
|
setEmojiButtonImage(false, false);
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
captionLimitView = new NumberTextView(context);
|
|
|
|
captionLimitView.setVisibility(View.GONE);
|
|
|
|
captionLimitView.setTextSize(15);
|
|
|
|
captionLimitView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
|
|
|
captionLimitView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
captionLimitView.setCenterAlign(true);
|
|
|
|
addView(captionLimitView, LayoutHelper.createFrame(48, 20, Gravity.BOTTOM | Gravity.RIGHT, 3, 0, 0, 48));
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
messageEditText = new EditTextCaption(context) {
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
private void send(InputContentInfoCompat inputContentInfo, boolean notify, int scheduleDate) {
|
|
|
|
ClipDescription description = inputContentInfo.getDescription();
|
|
|
|
if (description.hasMimeType("image/gif")) {
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.prepareSendingDocument(accountInstance, null, null, inputContentInfo.getContentUri(), null, "image/gif", dialog_id, replyingMessageObject, getThreadMessage(), inputContentInfo, null, notify, 0);
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.prepareSendingPhoto(accountInstance, null, inputContentInfo.getContentUri(), dialog_id, replyingMessageObject, getThreadMessage(), null, null, null, inputContentInfo, 0, null, notify, 0);
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onMessageSend(null, true, scheduleDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
@Override
|
|
|
|
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
|
|
|
final InputConnection ic = super.onCreateInputConnection(editorInfo);
|
2019-07-18 15:01:39 +02:00
|
|
|
try {
|
2020-06-04 18:47:15 +02:00
|
|
|
EditorInfoCompat.setContentMimeTypes(editorInfo, new String[]{"image/gif", "image/*", "image/jpg", "image/png", "image/webp"});
|
2019-07-18 15:01:39 +02:00
|
|
|
|
|
|
|
final InputConnectionCompat.OnCommitContentListener callback = (inputContentInfo, flags, opts) -> {
|
|
|
|
if (BuildCompat.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
|
|
|
|
try {
|
|
|
|
inputContentInfo.requestPermission();
|
|
|
|
} catch (Exception e) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
if (isInScheduleMode()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> send(inputContentInfo, notify, scheduleDate));
|
2019-07-18 15:01:39 +02:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
send(inputContentInfo, true, 0);
|
2019-07-18 15:01:39 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
return InputConnectionCompat.createWrapper(ic, editorInfo, callback);
|
|
|
|
} catch (Throwable e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
|
|
|
return ic;
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (stickersDragging || stickersExpansionAnim != null) {
|
|
|
|
return false;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (isPopupShowing() && event.getAction() == MotionEvent.ACTION_DOWN) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
emojiView.closeSearch(false);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
showPopup(AndroidUtilities.usingHardwareInput ? 0 : 2, 0);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (stickersExpanded) {
|
|
|
|
setStickersExpanded(false, true, false);
|
|
|
|
waitingForKeyboardOpenAfterAnimation = true;
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
waitingForKeyboardOpenAfterAnimation = false;
|
|
|
|
openKeyboardInternal();
|
|
|
|
}, 200);
|
|
|
|
} else {
|
|
|
|
openKeyboardInternal();
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
try {
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
2020-10-30 13:41:45 +01:00
|
|
|
@Override
|
|
|
|
public boolean dispatchKeyEvent(KeyEvent event) {
|
|
|
|
if (preventInput) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return super.dispatchKeyEvent(event);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
|
|
|
protected void onSelectionChanged(int selStart, int selEnd) {
|
|
|
|
super.onSelectionChanged(selStart, selEnd);
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onTextSelectionChanged(selStart, selEnd);
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void extendActionMode(ActionMode actionMode, Menu menu) {
|
|
|
|
if (parentFragment != null) {
|
|
|
|
parentFragment.extendActionMode(menu);
|
|
|
|
}
|
|
|
|
}
|
2020-02-13 19:26:53 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean requestRectangleOnScreen(Rect rectangle) {
|
|
|
|
rectangle.bottom += AndroidUtilities.dp(1000);
|
|
|
|
return super.requestRectangleOnScreen(rectangle);
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
isInitLineCount = getMeasuredWidth() == 0 && getMeasuredHeight() == 0;
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
if (isInitLineCount) {
|
|
|
|
lineCount = getLineCount();
|
|
|
|
}
|
|
|
|
isInitLineCount = false;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTextContextMenuItem(int id) {
|
|
|
|
if (id == android.R.id.paste) {
|
|
|
|
isPaste = true;
|
|
|
|
}
|
|
|
|
return super.onTextContextMenuItem(id);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
};
|
2018-08-27 10:33:11 +02:00
|
|
|
messageEditText.setDelegate(() -> {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onTextSpansChanged(messageEditText.getText());
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
});
|
2019-12-31 14:08:08 +01:00
|
|
|
messageEditText.setWindowView(parentActivity.getWindow().getDecorView());
|
2019-07-18 15:01:39 +02:00
|
|
|
TLRPC.EncryptedChat encryptedChat = parentFragment != null ? parentFragment.getCurrentEncryptedChat() : null;
|
2019-12-31 14:08:08 +01:00
|
|
|
messageEditText.setAllowTextEntitiesIntersection(supportsSendingNewEntities());
|
2021-01-28 15:15:51 +01:00
|
|
|
updateFieldHint(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
int flags = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
|
2019-07-18 15:01:39 +02:00
|
|
|
if (encryptedChat != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
flags |= 0x01000000; //EditorInfo.IME_FLAG_NO_PERSONALIZED_LEARNING;
|
|
|
|
}
|
|
|
|
messageEditText.setImeOptions(flags);
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setInputType(messageEditText.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES | EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
|
|
|
|
messageEditText.setSingleLine(false);
|
2019-01-23 18:03:33 +01:00
|
|
|
messageEditText.setMaxLines(6);
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
messageEditText.setGravity(Gravity.BOTTOM);
|
|
|
|
messageEditText.setPadding(0, AndroidUtilities.dp(11), 0, AndroidUtilities.dp(12));
|
|
|
|
messageEditText.setBackgroundDrawable(null);
|
2017-03-31 01:58:05 +02:00
|
|
|
messageEditText.setTextColor(Theme.getColor(Theme.key_chat_messagePanelText));
|
|
|
|
messageEditText.setHintColor(Theme.getColor(Theme.key_chat_messagePanelHint));
|
|
|
|
messageEditText.setHintTextColor(Theme.getColor(Theme.key_chat_messagePanelHint));
|
2019-09-10 12:56:11 +02:00
|
|
|
messageEditText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor));
|
2015-06-29 19:12:11 +02:00
|
|
|
frameLayout.addView(messageEditText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 52, 0, isChat ? 50 : 2, 0));
|
2016-04-22 15:49:00 +02:00
|
|
|
messageEditText.setOnKeyListener(new OnKeyListener() {
|
2015-09-02 00:14:21 +02:00
|
|
|
|
|
|
|
boolean ctrlPressed = false;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (i == KeyEvent.KEYCODE_BACK && !keyboardVisible && isPopupShowing()) {
|
2014-07-03 00:39:05 +02:00
|
|
|
if (keyEvent.getAction() == 1) {
|
2015-09-02 00:14:21 +02:00
|
|
|
if (currentPopupContentType == 1 && botButtonsMessageObject != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
|
2015-09-02 00:14:21 +02:00
|
|
|
preferences.edit().putInt("hidekeyboard_" + dialog_id, botButtonsMessageObject.getId()).commit();
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2020-10-05 00:13:31 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.closeSearch(true);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (stickersExpanded) {
|
|
|
|
setStickersExpanded(false, true, false);
|
|
|
|
} else {
|
|
|
|
if (stickersExpansionAnim == null) {
|
|
|
|
showPopup(0, 0);
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
return true;
|
2016-10-11 13:57:01 +02:00
|
|
|
} else if (i == KeyEvent.KEYCODE_ENTER && (ctrlPressed || sendByEnter) && keyEvent.getAction() == KeyEvent.ACTION_DOWN && editingMessageObject == null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
sendMessage();
|
2014-07-03 00:39:05 +02:00
|
|
|
return true;
|
2015-09-02 00:14:21 +02:00
|
|
|
} else if (i == KeyEvent.KEYCODE_CTRL_LEFT || i == KeyEvent.KEYCODE_CTRL_RIGHT) {
|
|
|
|
ctrlPressed = keyEvent.getAction() == KeyEvent.ACTION_DOWN;
|
|
|
|
return true;
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
2015-09-02 00:14:21 +02:00
|
|
|
|
|
|
|
boolean ctrlPressed = false;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
|
|
|
if (i == EditorInfo.IME_ACTION_SEND) {
|
2019-09-10 12:56:11 +02:00
|
|
|
sendMessage();
|
2014-07-03 00:39:05 +02:00
|
|
|
return true;
|
2015-09-02 00:14:21 +02:00
|
|
|
} else if (keyEvent != null && i == EditorInfo.IME_NULL) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if ((ctrlPressed || sendByEnter) && keyEvent.getAction() == KeyEvent.ACTION_DOWN && editingMessageObject == null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
sendMessage();
|
2014-07-03 00:39:05 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.addTextChangedListener(new TextWatcher() {
|
2020-07-26 10:03:38 +02:00
|
|
|
|
|
|
|
private boolean processChange;
|
|
|
|
private boolean nextChangeIsSend;
|
2015-07-22 20:56:37 +02:00
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
@Override
|
|
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
|
|
|
|
@Override
|
2015-04-09 20:00:14 +02:00
|
|
|
public void onTextChanged(CharSequence charSequence, int start, int before, int count) {
|
2020-07-26 10:03:38 +02:00
|
|
|
if (lineCount != messageEditText.getLineCount()) {
|
|
|
|
if (!isInitLineCount && messageEditText.getMeasuredWidth() > 0) {
|
|
|
|
onLineCountChanged(lineCount, messageEditText.getLineCount());
|
|
|
|
}
|
|
|
|
lineCount = messageEditText.getLineCount();
|
|
|
|
}
|
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
if (innerTextChange == 1) {
|
|
|
|
return;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
if (sendByEnter && !isPaste && editingMessageObject == null && count > before && charSequence.length() > 0 && charSequence.length() == start + count && charSequence.charAt(charSequence.length() - 1) == '\n') {
|
2020-07-26 10:03:38 +02:00
|
|
|
nextChangeIsSend = true;
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
isPaste = false;
|
2015-02-26 02:32:51 +01:00
|
|
|
checkSendButton(true);
|
2016-06-24 12:27:15 +02:00
|
|
|
CharSequence message = AndroidUtilities.getTrimmedString(charSequence.toString());
|
2015-02-26 02:32:51 +01:00
|
|
|
if (delegate != null) {
|
2016-03-06 02:49:31 +01:00
|
|
|
if (!ignoreTextChange) {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (count > 2 || TextUtils.isEmpty(charSequence)) {
|
2016-10-11 13:57:01 +02:00
|
|
|
messageWebPageSearch = true;
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
delegate.onTextChanged(charSequence, before > count + 1 || (count - before) > 2);
|
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (innerTextChange != 2 && (count - before) > 1) {
|
2015-07-22 20:56:37 +02:00
|
|
|
processChange = true;
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
if (editingMessageObject == null && !canWriteToChannel && message.length() != 0 && lastTypingTimeSend < System.currentTimeMillis() - 5000 && !ignoreTextChange) {
|
2015-02-26 02:32:51 +01:00
|
|
|
lastTypingTimeSend = System.currentTimeMillis();
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.needSendTyping();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void afterTextChanged(Editable editable) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (innerTextChange == 0) {
|
|
|
|
if (nextChangeIsSend) {
|
|
|
|
sendMessage();
|
|
|
|
nextChangeIsSend = false;
|
|
|
|
}
|
|
|
|
if (processChange) {
|
|
|
|
ImageSpan[] spans = editable.getSpans(0, editable.length(), ImageSpan.class);
|
|
|
|
for (int i = 0; i < spans.length; i++) {
|
|
|
|
editable.removeSpan(spans[i]);
|
|
|
|
}
|
|
|
|
Emoji.replaceEmoji(editable, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
|
|
|
processChange = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int beforeLimit;
|
|
|
|
codePointCount = Character.codePointCount(editable, 0, editable.length());
|
|
|
|
boolean doneButtonEnabledLocal = true;
|
|
|
|
if (currentLimit > 0 && (beforeLimit = currentLimit - codePointCount) <= 100) {
|
|
|
|
if (beforeLimit < -9999) {
|
|
|
|
beforeLimit = -9999;
|
|
|
|
}
|
|
|
|
captionLimitView.setNumber(beforeLimit, captionLimitView.getVisibility() == View.VISIBLE);
|
|
|
|
if (captionLimitView.getVisibility() != View.VISIBLE) {
|
|
|
|
captionLimitView.setVisibility(View.VISIBLE);
|
|
|
|
captionLimitView.setAlpha(0);
|
|
|
|
captionLimitView.setScaleX(0.5f);
|
|
|
|
captionLimitView.setScaleY(0.5f);
|
|
|
|
}
|
|
|
|
captionLimitView.animate().setListener(null).cancel();
|
|
|
|
captionLimitView.animate().alpha(1f).scaleX(1f).scaleY(1f).setDuration(100).start();
|
|
|
|
if (beforeLimit < 0) {
|
|
|
|
doneButtonEnabledLocal = false;
|
|
|
|
captionLimitView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
|
|
|
} else {
|
|
|
|
captionLimitView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
captionLimitView.animate().alpha(0).scaleX(0.5f).scaleY(0.5f).setDuration(100).setListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
captionLimitView.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
if (doneButtonEnabled != doneButtonEnabledLocal) {
|
|
|
|
doneButtonEnabled = doneButtonEnabledLocal;
|
|
|
|
if (doneButtonColorAnimator != null) {
|
|
|
|
doneButtonColorAnimator.cancel();
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
doneButtonColorAnimator = ValueAnimator.ofFloat(doneButtonEnabled ? 0 : 1f, doneButtonEnabled ? 1f : 0);
|
|
|
|
doneButtonColorAnimator.addUpdateListener(valueAnimator -> {
|
|
|
|
int color = Theme.getColor(Theme.key_chat_messagePanelVoicePressed);
|
|
|
|
int defaultAlpha = Color.alpha(color);
|
|
|
|
doneButtonEnabledProgress = (float) valueAnimator.getAnimatedValue();
|
|
|
|
doneCheckDrawable.setColorFilter(new PorterDuffColorFilter(ColorUtils.setAlphaComponent(color, (int) (defaultAlpha * (0.58f + 0.42f * doneButtonEnabledProgress))), PorterDuff.Mode.MULTIPLY));
|
|
|
|
doneButtonImage.invalidate();
|
|
|
|
});
|
|
|
|
doneButtonColorAnimator.setDuration(150).start();
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
if (isChat) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (parentFragment != null) {
|
|
|
|
Drawable drawable1 = context.getResources().getDrawable(R.drawable.input_calendar1).mutate();
|
|
|
|
Drawable drawable2 = context.getResources().getDrawable(R.drawable.input_calendar2).mutate();
|
|
|
|
drawable1.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
|
|
|
drawable2.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_recordedVoiceDot), PorterDuff.Mode.MULTIPLY));
|
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(drawable1, drawable2);
|
|
|
|
|
|
|
|
scheduledButton = new ImageView(context);
|
|
|
|
scheduledButton.setImageDrawable(combinedDrawable);
|
|
|
|
scheduledButton.setVisibility(GONE);
|
|
|
|
scheduledButton.setContentDescription(LocaleController.getString("ScheduledMessages", R.string.ScheduledMessages));
|
|
|
|
scheduledButton.setScaleType(ImageView.ScaleType.CENTER);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
scheduledButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
frameLayout.addView(scheduledButton, LayoutHelper.createFrame(48, 48, Gravity.BOTTOM | Gravity.RIGHT));
|
|
|
|
scheduledButton.setOnClickListener(v -> {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.openScheduledMessages();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout = new LinearLayout(context);
|
|
|
|
attachLayout.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
attachLayout.setEnabled(false);
|
|
|
|
attachLayout.setPivotX(AndroidUtilities.dp(48));
|
2020-03-30 14:00:09 +02:00
|
|
|
attachLayout.setClipChildren(false);
|
2017-03-31 01:58:05 +02:00
|
|
|
frameLayout.addView(attachLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 48, Gravity.BOTTOM | Gravity.RIGHT));
|
2015-06-29 19:12:11 +02:00
|
|
|
|
|
|
|
botButton = new ImageView(context);
|
2020-09-30 15:48:47 +02:00
|
|
|
botButton.setImageDrawable(botButtonDrawablel = new ReplaceableIconDrawable(context));
|
|
|
|
botButtonDrawablel.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
|
|
|
botButtonDrawablel.setIcon(R.drawable.input_bot2, false);
|
2015-06-29 19:12:11 +02:00
|
|
|
botButton.setScaleType(ImageView.ScaleType.CENTER);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
botButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
botButton.setVisibility(GONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.addView(botButton, LayoutHelper.createLinear(48, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
botButton.setOnClickListener(v -> {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2018-08-27 10:33:11 +02:00
|
|
|
emojiView.closeSearch(false);
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
|
|
|
if (botReplyMarkup != null) {
|
|
|
|
if (!isPopupShowing() || currentPopupContentType != 1) {
|
|
|
|
showPopup(1, 1);
|
|
|
|
SharedPreferences preferences1 = MessagesController.getMainSettings(currentAccount);
|
|
|
|
preferences1.edit().remove("hidekeyboard_" + dialog_id).commit();
|
|
|
|
} else {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (botButtonsMessageObject != null) {
|
2018-08-27 10:33:11 +02:00
|
|
|
SharedPreferences preferences1 = MessagesController.getMainSettings(currentAccount);
|
|
|
|
preferences1.edit().putInt("hidekeyboard_" + dialog_id, botButtonsMessageObject.getId()).commit();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
openKeyboardInternal();
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else if (hasBotCommands) {
|
|
|
|
setFieldText("/");
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
openKeyboard();
|
|
|
|
}
|
|
|
|
if (stickersExpanded) {
|
|
|
|
setStickersExpanded(false, false, false);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
});
|
2015-09-24 22:52:02 +02:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
notifyButton = new ImageView(context);
|
2021-01-28 15:15:51 +01:00
|
|
|
notifySilentDrawable = new CrossOutDrawable(context, R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
|
|
|
|
notifyButton.setImageDrawable(notifySilentDrawable);
|
|
|
|
notifySilentDrawable.setCrossOut(silent, false);
|
2019-05-14 14:08:05 +02:00
|
|
|
notifyButton.setContentDescription(silent ? LocaleController.getString("AccDescrChanSilentOn", R.string.AccDescrChanSilentOn) : LocaleController.getString("AccDescrChanSilentOff", R.string.AccDescrChanSilentOff));
|
2017-03-31 01:58:05 +02:00
|
|
|
notifyButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
2016-03-06 02:49:31 +01:00
|
|
|
notifyButton.setScaleType(ImageView.ScaleType.CENTER);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
notifyButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
notifyButton.setVisibility(canWriteToChannel && (delegate == null || !delegate.hasScheduledMessages()) ? VISIBLE : GONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.addView(notifyButton, LayoutHelper.createLinear(48, 48));
|
2016-03-06 02:49:31 +01:00
|
|
|
notifyButton.setOnClickListener(new OnClickListener() {
|
2016-10-11 13:57:01 +02:00
|
|
|
|
|
|
|
private Toast visibleToast;
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
silent = !silent;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (notifySilentDrawable == null) {
|
|
|
|
notifySilentDrawable = new CrossOutDrawable(context, R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
|
|
|
|
}
|
|
|
|
notifySilentDrawable.setCrossOut(silent, true);
|
|
|
|
notifyButton.setImageDrawable(notifySilentDrawable);
|
2018-07-30 04:07:02 +02:00
|
|
|
MessagesController.getNotificationsSettings(currentAccount).edit().putBoolean("silent_" + dialog_id, silent).commit();
|
|
|
|
NotificationsController.getInstance(currentAccount).updateServerNotificationsSettings(dialog_id);
|
2016-10-11 13:57:01 +02:00
|
|
|
try {
|
|
|
|
if (visibleToast != null) {
|
|
|
|
visibleToast.cancel();
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2021-01-30 07:18:23 +01:00
|
|
|
fragment.getUndoView().showWithAction(0, !silent ? UndoView.ACTION_NOTIFY_ON : UndoView.ACTION_NOTIFY_OFF, null);
|
2019-05-14 14:08:05 +02:00
|
|
|
notifyButton.setContentDescription(silent ? LocaleController.getString("AccDescrChanSilentOn", R.string.AccDescrChanSilentOn) : LocaleController.getString("AccDescrChanSilentOff", R.string.AccDescrChanSilentOff));
|
2021-01-28 15:15:51 +01:00
|
|
|
updateFieldHint(true);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
});
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
attachButton = new ImageView(context);
|
|
|
|
attachButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
2019-05-14 14:08:05 +02:00
|
|
|
attachButton.setImageResource(R.drawable.input_attach);
|
2017-03-31 01:58:05 +02:00
|
|
|
attachButton.setScaleType(ImageView.ScaleType.CENTER);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
attachButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.addView(attachButton, LayoutHelper.createLinear(48, 48));
|
2020-09-30 15:48:47 +02:00
|
|
|
attachButton.setOnClickListener(v -> {
|
|
|
|
if (adjustPanLayoutHelper != null && adjustPanLayoutHelper.animationInProgress()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delegate.didPressAttachButton();
|
|
|
|
});
|
2019-05-14 14:08:05 +02:00
|
|
|
attachButton.setContentDescription(LocaleController.getString("AccDescrAttachButton", R.string.AccDescrAttachButton));
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
recordedAudioPanel = new FrameLayout(context);
|
2016-03-06 02:49:31 +01:00
|
|
|
recordedAudioPanel.setVisibility(audioToSend == null ? GONE : VISIBLE);
|
|
|
|
recordedAudioPanel.setFocusable(true);
|
|
|
|
recordedAudioPanel.setFocusableInTouchMode(true);
|
|
|
|
recordedAudioPanel.setClickable(true);
|
|
|
|
frameLayout.addView(recordedAudioPanel, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM));
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
recordDeleteImageView = new RLottieImageView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
recordDeleteImageView.setScaleType(ImageView.ScaleType.CENTER);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordDeleteImageView.setAnimation(R.raw.chat_audio_record_delete_2, 28, 28);
|
|
|
|
recordDeleteImageView.getAnimatedDrawable().setInvalidateOnProgressSet(true);
|
|
|
|
updateRecordedDeleteIconColors();
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
recordDeleteImageView.setContentDescription(LocaleController.getString("Delete", R.string.Delete));
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
recordDeleteImageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
recordedAudioPanel.addView(recordDeleteImageView, LayoutHelper.createFrame(48, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
recordDeleteImageView.setOnClickListener(v -> {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (runningAnimationAudio != null && runningAnimationAudio.isRunning()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (videoToSendMessageObject != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.needStartRecordVideo(2, true, 0);
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
MessageObject playing = MediaController.getInstance().getPlayingMessageObject();
|
|
|
|
if (playing != null && playing == audioToSendMessageObject) {
|
|
|
|
MediaController.getInstance().cleanupPlayer(true, true);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (audioToSendPath != null) {
|
|
|
|
new File(audioToSendPath).delete();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
hideRecordedAudioPanel(false);
|
2018-08-27 10:33:11 +02:00
|
|
|
checkSendButton(true);
|
2016-03-06 02:49:31 +01:00
|
|
|
});
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
videoTimelineView = new VideoTimelineView(context);
|
2019-09-10 12:56:11 +02:00
|
|
|
videoTimelineView.setColor(Theme.getColor(Theme.key_chat_messagePanelVideoFrame));
|
2017-07-08 18:32:04 +02:00
|
|
|
videoTimelineView.setRoundFrames(true);
|
|
|
|
videoTimelineView.setDelegate(new VideoTimelineView.VideoTimelineViewDelegate() {
|
|
|
|
@Override
|
|
|
|
public void onLeftProgressChanged(float progress) {
|
|
|
|
if (videoToSendMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
videoToSendMessageObject.startTime = (long) (progress * videoToSendMessageObject.estimatedDuration);
|
|
|
|
delegate.needChangeVideoPreviewState(2, progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-07-23 14:56:38 +02:00
|
|
|
public void onRightProgressChanged(float progress) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (videoToSendMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
videoToSendMessageObject.endTime = (long) (progress * videoToSendMessageObject.estimatedDuration);
|
|
|
|
delegate.needChangeVideoPreviewState(2, progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didStartDragging() {
|
|
|
|
delegate.needChangeVideoPreviewState(1, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didStopDragging() {
|
|
|
|
delegate.needChangeVideoPreviewState(0, 0);
|
|
|
|
}
|
|
|
|
});
|
2020-03-30 14:00:09 +02:00
|
|
|
recordedAudioPanel.addView(videoTimelineView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.LEFT, 56, 0, 8, 0));
|
|
|
|
VideoTimelineView.TimeHintView videoTimeHintView = new VideoTimelineView.TimeHintView(context);
|
|
|
|
videoTimelineView.setTimeHintView(videoTimeHintView);
|
|
|
|
sizeNotifierLayout.addView(videoTimeHintView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 52));
|
2017-07-08 18:32:04 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
recordedAudioBackground = new View(context);
|
2019-06-04 12:14:50 +02:00
|
|
|
recordedAudioBackground.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(18), Theme.getColor(Theme.key_chat_recordedVoiceBackground)));
|
2017-07-08 18:32:04 +02:00
|
|
|
recordedAudioPanel.addView(recordedAudioBackground, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL | Gravity.LEFT, 48, 0, 0, 0));
|
2016-03-06 02:49:31 +01:00
|
|
|
|
|
|
|
recordedAudioSeekBar = new SeekBarWaveformView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
LinearLayout waveFormTimerLayout = new LinearLayout(context);
|
|
|
|
waveFormTimerLayout.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
recordedAudioPanel.addView(waveFormTimerLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 32, Gravity.CENTER_VERTICAL | Gravity.LEFT, 48 + 44, 0, 13, 0));
|
|
|
|
playPauseDrawable = new MediaActionDrawable();
|
2016-03-06 02:49:31 +01:00
|
|
|
recordedAudioPlayButton = new ImageView(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
Matrix matrix = new Matrix();
|
|
|
|
matrix.postScale(0.8f, 0.8f, AndroidUtilities.dpf2(24), AndroidUtilities.dpf2(24));
|
|
|
|
recordedAudioPlayButton.setImageMatrix(matrix);
|
|
|
|
recordedAudioPlayButton.setImageDrawable(playPauseDrawable);
|
|
|
|
recordedAudioPlayButton.setScaleType(ImageView.ScaleType.MATRIX);
|
2019-05-14 14:08:05 +02:00
|
|
|
recordedAudioPlayButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay));
|
2020-03-30 14:00:09 +02:00
|
|
|
recordedAudioPanel.addView(recordedAudioPlayButton, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.BOTTOM, 48, 0, 13, 0));
|
2018-08-27 10:33:11 +02:00
|
|
|
recordedAudioPlayButton.setOnClickListener(v -> {
|
|
|
|
if (audioToSend == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (MediaController.getInstance().isPlayingMessage(audioToSendMessageObject) && !MediaController.getInstance().isMessagePaused()) {
|
|
|
|
MediaController.getInstance().pauseMessage(audioToSendMessageObject);
|
2020-03-30 14:00:09 +02:00
|
|
|
playPauseDrawable.setIcon(MediaActionDrawable.ICON_PLAY, true);
|
2019-05-14 14:08:05 +02:00
|
|
|
recordedAudioPlayButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay));
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
playPauseDrawable.setIcon(MediaActionDrawable.ICON_PAUSE, true);
|
2018-08-27 10:33:11 +02:00
|
|
|
MediaController.getInstance().playMessage(audioToSendMessageObject);
|
2019-05-14 14:08:05 +02:00
|
|
|
recordedAudioPlayButton.setContentDescription(LocaleController.getString("AccActionPause", R.string.AccActionPause));
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
recordedAudioTimeTextView = new TextView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
recordedAudioTimeTextView.setTextColor(Theme.getColor(Theme.key_chat_messagePanelVoiceDuration));
|
2016-03-06 02:49:31 +01:00
|
|
|
recordedAudioTimeTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
|
2020-03-30 14:00:09 +02:00
|
|
|
waveFormTimerLayout.addView(recordedAudioSeekBar, LayoutHelper.createLinear(0, 32, 1f, Gravity.CENTER_VERTICAL, 0, 0, 4, 0));
|
|
|
|
waveFormTimerLayout.addView(recordedAudioTimeTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, 0f, Gravity.CENTER_VERTICAL));
|
2016-03-06 02:49:31 +01:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
recordPanel = new FrameLayout(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordPanel.setClipChildren(false);
|
2015-02-26 02:32:51 +01:00
|
|
|
recordPanel.setVisibility(GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
frameLayout.addView(recordPanel, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
recordPanel.setOnTouchListener((v, event) -> true);
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
slideText = new SlideTextView(context);
|
|
|
|
recordPanel.addView(slideText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.NO_GRAVITY, 45, 0, 0, 0));
|
2017-07-08 18:32:04 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
recordTimeContainer = new LinearLayout(context);
|
|
|
|
recordTimeContainer.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
recordTimeContainer.setPadding(AndroidUtilities.dp(13), 0, 0, 0);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordPanel.addView(recordTimeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
recordDot = new RecordDot(context);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordTimeContainer.addView(recordDot, LayoutHelper.createLinear(28, 28, Gravity.CENTER_VERTICAL, 0, 0, 0, 0));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
recordTimerView = new TimerView(context);
|
|
|
|
recordTimeContainer.addView(recordTimerView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL, 6, 0, 0, 0));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
sendButtonContainer = new FrameLayout(context);
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButtonContainer.setClipChildren(false);
|
|
|
|
sendButtonContainer.setClipToPadding(false);
|
2016-03-06 02:49:31 +01:00
|
|
|
textFieldContainer.addView(sendButtonContainer, LayoutHelper.createLinear(48, 48, Gravity.BOTTOM));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer = new FrameLayout(context);
|
|
|
|
audioVideoButtonContainer.setSoundEffectsEnabled(false);
|
|
|
|
sendButtonContainer.addView(audioVideoButtonContainer, LayoutHelper.createFrame(48, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
audioVideoButtonContainer.setOnTouchListener((view, motionEvent) -> {
|
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
if (recordCircle.isSendButtonVisible()) {
|
|
|
|
if (!hasRecordVideo || calledRecordRunnable) {
|
2017-03-31 01:58:05 +02:00
|
|
|
startedDraggingX = -1;
|
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.needStartRecordVideo(1, true, 0);
|
2015-02-27 20:57:58 +01:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (recordingAudioVideo && isInScheduleMode()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.needStartRecordAudio(0);
|
2015-02-27 20:57:58 +01:00
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
recordingAudioVideo = false;
|
2021-03-19 11:25:58 +01:00
|
|
|
AndroidUtilities.runOnUIThread(moveToSendStateRunnable = () -> {
|
|
|
|
moveToSendStateRunnable = null;
|
|
|
|
messageTransitionIsRunning = false;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_SENDING);
|
|
|
|
}, 200);
|
2015-02-27 20:57:58 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (parentFragment != null) {
|
|
|
|
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
2019-01-23 18:03:33 +01:00
|
|
|
if (chat != null && !ChatObject.canSendMedia(chat)) {
|
|
|
|
delegate.needShowMediaBanHint();
|
|
|
|
return false;
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
if (hasRecordVideo) {
|
|
|
|
calledRecordRunnable = false;
|
|
|
|
recordAudioVideoRunnableStarted = true;
|
|
|
|
AndroidUtilities.runOnUIThread(recordAudioVideoRunnable, 150);
|
|
|
|
} else {
|
|
|
|
recordAudioVideoRunnable.run();
|
|
|
|
}
|
|
|
|
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_CANCEL && recordingAudioVideo) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (recordCircle.slideToCancelProgress < 0.7f) {
|
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
|
|
|
delegate.needStartRecordVideo(2, true, 0);
|
|
|
|
} else {
|
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
MediaController.getInstance().stopRecording(0, false, 0);
|
|
|
|
}
|
|
|
|
recordingAudioVideo = false;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL_BY_GESTURE);
|
|
|
|
} else {
|
|
|
|
recordCircle.sendButtonVisible = true;
|
|
|
|
startLockTransition();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
return false;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
if (recordCircle.isSendButtonVisible() || recordedAudioPanel.getVisibility() == VISIBLE) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (recordAudioVideoRunnableStarted) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(recordAudioVideoRunnable);
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
float x = motionEvent.getX() + audioVideoButtonContainer.getX();
|
|
|
|
float dist = (x - startedDraggingX);
|
|
|
|
float alpha = 1.0f + dist / distCanMove;
|
|
|
|
if (alpha < 0.45) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.needStartRecordVideo(2, true, 0);
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
delegate.needStartRecordAudio(0);
|
2020-03-30 14:00:09 +02:00
|
|
|
MediaController.getInstance().stopRecording(0, false, 0);
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
recordingAudioVideo = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL_BY_GESTURE);
|
|
|
|
} else {
|
|
|
|
if (recordAudioVideoRunnableStarted) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(recordAudioVideoRunnable);
|
|
|
|
delegate.onSwitchRecordMode(videoSendButton.getTag() == null);
|
|
|
|
setRecordVideoButtonVisible(videoSendButton.getTag() == null, true);
|
|
|
|
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);
|
|
|
|
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED);
|
|
|
|
} else if (!hasRecordVideo || calledRecordRunnable) {
|
|
|
|
startedDraggingX = -1;
|
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
|
|
|
delegate.needStartRecordVideo(1, true, 0);
|
|
|
|
} else {
|
|
|
|
if (recordingAudioVideo && isInScheduleMode()) {
|
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (notify, scheduleDate) -> MediaController.getInstance().stopRecording(1, notify, scheduleDate), () -> MediaController.getInstance().stopRecording(0, false, 0));
|
|
|
|
}
|
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
MediaController.getInstance().stopRecording(isInScheduleMode() ? 3 : 1, true, 0);
|
|
|
|
}
|
|
|
|
recordingAudioVideo = false;
|
2021-03-19 11:25:58 +01:00
|
|
|
AndroidUtilities.runOnUIThread(moveToSendStateRunnable = () -> {
|
|
|
|
moveToSendStateRunnable = null;
|
|
|
|
messageTransitionIsRunning = false;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_SENDING);
|
|
|
|
}, 500);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
} else if (motionEvent.getAction() == MotionEvent.ACTION_MOVE && recordingAudioVideo) {
|
|
|
|
float x = motionEvent.getX();
|
|
|
|
float y = motionEvent.getY();
|
|
|
|
if (recordCircle.isSendButtonVisible()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (recordCircle.setLockTranslation(y) == 2) {
|
2020-03-30 14:00:09 +02:00
|
|
|
startLockTransition();
|
2018-08-27 10:33:11 +02:00
|
|
|
return false;
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
|
|
|
recordCircle.setMovingCords(x, y);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (startedDraggingX == -1) {
|
|
|
|
startedDraggingX = x;
|
|
|
|
distCanMove = (float) (sizeNotifierLayout.getMeasuredWidth() * 0.35);
|
|
|
|
if (distCanMove > AndroidUtilities.dp(140)) {
|
|
|
|
distCanMove = AndroidUtilities.dp(140);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x = x + audioVideoButtonContainer.getX();
|
2020-03-30 14:00:09 +02:00
|
|
|
float dist = (x - startedDraggingX);
|
|
|
|
float alpha = 1.0f + dist / distCanMove;
|
2018-08-27 10:33:11 +02:00
|
|
|
if (startedDraggingX != -1) {
|
|
|
|
if (alpha > 1) {
|
|
|
|
alpha = 1;
|
|
|
|
} else if (alpha < 0) {
|
|
|
|
alpha = 0;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
slideText.setSlideX(alpha);
|
|
|
|
recordCircle.setSlideToCancelProgress(alpha);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (alpha == 0) {
|
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
|
|
|
delegate.needStartRecordVideo(2, true, 0);
|
|
|
|
} else {
|
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
MediaController.getInstance().stopRecording(0, false, 0);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
recordingAudioVideo = false;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL_BY_GESTURE);
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
view.onTouchEvent(motionEvent);
|
|
|
|
return true;
|
2014-07-03 00:39:05 +02:00
|
|
|
});
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
audioSendButton = new ImageView(context);
|
|
|
|
audioSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
audioSendButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
2019-05-14 14:08:05 +02:00
|
|
|
audioSendButton.setImageResource(R.drawable.input_mic);
|
2017-03-31 01:58:05 +02:00
|
|
|
audioSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
2019-05-14 14:08:05 +02:00
|
|
|
audioSendButton.setContentDescription(LocaleController.getString("AccDescrVoiceMessage", R.string.AccDescrVoiceMessage));
|
|
|
|
audioSendButton.setFocusable(true);
|
|
|
|
audioSendButton.setAccessibilityDelegate(mediaMessageButtonsDelegate);
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.addView(audioSendButton, LayoutHelper.createFrame(48, 48));
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
if (isChat) {
|
2017-03-31 01:58:05 +02:00
|
|
|
videoSendButton = new ImageView(context);
|
|
|
|
videoSendButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
videoSendButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelIcons), PorterDuff.Mode.MULTIPLY));
|
2019-05-14 14:08:05 +02:00
|
|
|
videoSendButton.setImageResource(R.drawable.input_video);
|
2017-03-31 01:58:05 +02:00
|
|
|
videoSendButton.setPadding(0, 0, AndroidUtilities.dp(4), 0);
|
2019-05-14 14:08:05 +02:00
|
|
|
videoSendButton.setContentDescription(LocaleController.getString("AccDescrVideoMessage", R.string.AccDescrVideoMessage));
|
|
|
|
videoSendButton.setFocusable(true);
|
|
|
|
videoSendButton.setAccessibilityDelegate(mediaMessageButtonsDelegate);
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.addView(videoSendButton, LayoutHelper.createFrame(48, 48));
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
recordCircle = new RecordCircle(context);
|
|
|
|
recordCircle.setVisibility(GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
sizeNotifierLayout.addView(recordCircle, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 0));
|
2015-10-29 18:10:07 +01:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton = new ImageView(context);
|
|
|
|
cancelBotButton.setVisibility(INVISIBLE);
|
|
|
|
cancelBotButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
|
|
|
cancelBotButton.setImageDrawable(progressDrawable = new CloseProgressDrawable2());
|
2019-05-14 14:08:05 +02:00
|
|
|
cancelBotButton.setContentDescription(LocaleController.getString("Cancel", R.string.Cancel));
|
2017-03-31 01:58:05 +02:00
|
|
|
progressDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelCancelInlineBot), PorterDuff.Mode.MULTIPLY));
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setSoundEffectsEnabled(false);
|
2016-06-24 12:27:15 +02:00
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
cancelBotButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
sendButtonContainer.addView(cancelBotButton, LayoutHelper.createFrame(48, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
cancelBotButton.setOnClickListener(view -> {
|
|
|
|
String text = messageEditText.getText().toString();
|
|
|
|
int idx = text.indexOf(' ');
|
|
|
|
if (idx == -1 || idx == text.length() - 1) {
|
|
|
|
setFieldText("");
|
|
|
|
} else {
|
|
|
|
setFieldText(text.substring(0, idx + 1));
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
if (isInScheduleMode()) {
|
|
|
|
sendButtonDrawable = context.getResources().getDrawable(R.drawable.input_schedule).mutate();
|
|
|
|
sendButtonInverseDrawable = context.getResources().getDrawable(R.drawable.input_schedule).mutate();
|
|
|
|
inactinveSendButtonDrawable = context.getResources().getDrawable(R.drawable.input_schedule).mutate();
|
|
|
|
} else {
|
|
|
|
sendButtonDrawable = context.getResources().getDrawable(R.drawable.ic_send).mutate();
|
|
|
|
sendButtonInverseDrawable = context.getResources().getDrawable(R.drawable.ic_send).mutate();
|
|
|
|
inactinveSendButtonDrawable = context.getResources().getDrawable(R.drawable.ic_send).mutate();
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton = new View(context) {
|
|
|
|
|
|
|
|
private int drawableColor;
|
|
|
|
private float animationProgress;
|
|
|
|
private float animateBounce;
|
|
|
|
private long lastAnimationTime;
|
|
|
|
private float animationDuration;
|
2019-12-31 14:08:08 +01:00
|
|
|
private int prevColorType;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2019-09-10 12:56:11 +02:00
|
|
|
int x = (getMeasuredWidth() - sendButtonDrawable.getIntrinsicWidth()) / 2;
|
2019-08-22 01:53:26 +02:00
|
|
|
int y = (getMeasuredHeight() - sendButtonDrawable.getIntrinsicHeight()) / 2;
|
2019-09-10 12:56:11 +02:00
|
|
|
if (isInScheduleMode()) {
|
|
|
|
y -= AndroidUtilities.dp(1);
|
|
|
|
} else {
|
|
|
|
x += AndroidUtilities.dp(2);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
int color;
|
|
|
|
boolean showingPopup;
|
2019-12-31 14:08:08 +01:00
|
|
|
int colorType;
|
2019-08-22 01:53:26 +02:00
|
|
|
if (showingPopup = (sendPopupWindow != null && sendPopupWindow.isShowing())) {
|
2019-09-10 12:56:11 +02:00
|
|
|
color = Theme.getColor(Theme.key_chat_messagePanelVoicePressed);
|
2019-12-31 14:08:08 +01:00
|
|
|
colorType = 1;
|
2019-08-22 01:53:26 +02:00
|
|
|
} else {
|
|
|
|
color = Theme.getColor(Theme.key_chat_messagePanelSend);
|
2019-12-31 14:08:08 +01:00
|
|
|
colorType = 2;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
if (color != drawableColor) {
|
2020-01-23 07:15:40 +01:00
|
|
|
lastAnimationTime = SystemClock.elapsedRealtime();
|
2019-12-31 14:08:08 +01:00
|
|
|
if (prevColorType != 0 && prevColorType != colorType) {
|
2020-09-30 15:48:47 +02:00
|
|
|
animationProgress = 0.0f;
|
2019-12-31 14:08:08 +01:00
|
|
|
if (showingPopup) {
|
|
|
|
animationDuration = 200.0f;
|
|
|
|
} else {
|
|
|
|
animationDuration = 120.0f;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
} else {
|
|
|
|
animationProgress = 1.0f;
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
prevColorType = colorType;
|
2019-08-22 01:53:26 +02:00
|
|
|
drawableColor = color;
|
|
|
|
sendButtonDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelSend), PorterDuff.Mode.MULTIPLY));
|
|
|
|
int c = Theme.getColor(Theme.key_chat_messagePanelIcons);
|
|
|
|
inactinveSendButtonDrawable.setColorFilter(new PorterDuffColorFilter(Color.argb(0xb4, Color.red(c), Color.green(c), Color.blue(c)), PorterDuff.Mode.MULTIPLY));
|
|
|
|
sendButtonInverseDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoicePressed), PorterDuff.Mode.MULTIPLY));
|
|
|
|
}
|
|
|
|
if (animationProgress < 1.0f) {
|
2020-01-23 07:15:40 +01:00
|
|
|
long newTime = SystemClock.elapsedRealtime();
|
2019-08-22 01:53:26 +02:00
|
|
|
long dt = newTime - lastAnimationTime;
|
|
|
|
animationProgress += dt / animationDuration;
|
|
|
|
if (animationProgress > 1.0f) {
|
|
|
|
animationProgress = 1.0f;
|
|
|
|
}
|
|
|
|
lastAnimationTime = newTime;
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
if (!showingPopup) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer == Integer.MAX_VALUE && !isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
inactinveSendButtonDrawable.setBounds(x, y, x + sendButtonDrawable.getIntrinsicWidth(), y + sendButtonDrawable.getIntrinsicHeight());
|
|
|
|
inactinveSendButtonDrawable.draw(canvas);
|
|
|
|
} else {
|
|
|
|
sendButtonDrawable.setBounds(x, y, x + sendButtonDrawable.getIntrinsicWidth(), y + sendButtonDrawable.getIntrinsicHeight());
|
|
|
|
sendButtonDrawable.draw(canvas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (showingPopup || animationProgress != 1.0f) {
|
|
|
|
Theme.dialogs_onlineCirclePaint.setColor(Theme.getColor(Theme.key_chat_messagePanelSend));
|
|
|
|
int rad = AndroidUtilities.dp(20);
|
|
|
|
if (showingPopup) {
|
|
|
|
sendButtonInverseDrawable.setAlpha(255);
|
|
|
|
float p = animationProgress;
|
|
|
|
if (p <= 0.25f) {
|
|
|
|
float progress = p / 0.25f;
|
|
|
|
rad += AndroidUtilities.dp(2) * CubicBezierInterpolator.EASE_IN.getInterpolation(progress);
|
|
|
|
} else {
|
|
|
|
p -= 0.25f;
|
|
|
|
if (p <= 0.5f) {
|
|
|
|
float progress = p / 0.5f;
|
|
|
|
rad += AndroidUtilities.dp(2) - AndroidUtilities.dp(3) * CubicBezierInterpolator.EASE_IN.getInterpolation(progress);
|
|
|
|
} else {
|
|
|
|
p -= 0.5f;
|
|
|
|
float progress = p / 0.25f;
|
|
|
|
rad += -AndroidUtilities.dp(1) + AndroidUtilities.dp(1) * CubicBezierInterpolator.EASE_IN.getInterpolation(progress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int alpha = (int) (255 * (1.0f - animationProgress));
|
|
|
|
Theme.dialogs_onlineCirclePaint.setAlpha(alpha);
|
|
|
|
sendButtonInverseDrawable.setAlpha(alpha);
|
|
|
|
}
|
|
|
|
canvas.drawCircle(getMeasuredWidth() / 2, getMeasuredHeight() / 2, rad, Theme.dialogs_onlineCirclePaint);
|
|
|
|
sendButtonInverseDrawable.setBounds(x, y, x + sendButtonDrawable.getIntrinsicWidth(), y + sendButtonDrawable.getIntrinsicHeight());
|
|
|
|
sendButtonInverseDrawable.draw(canvas);
|
|
|
|
}
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
if (getAlpha() <= 0f) { // for accessibility
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
};
|
2016-04-22 15:49:00 +02:00
|
|
|
sendButton.setVisibility(INVISIBLE);
|
2019-08-22 01:53:26 +02:00
|
|
|
int color = Theme.getColor(Theme.key_chat_messagePanelSend);
|
2019-05-14 14:08:05 +02:00
|
|
|
sendButton.setContentDescription(LocaleController.getString("Send", R.string.Send));
|
2015-03-27 11:32:33 +01:00
|
|
|
sendButton.setSoundEffectsEnabled(false);
|
2016-06-24 12:27:15 +02:00
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
sendButton.setBackgroundDrawable(Theme.createSelectorDrawable(Color.argb(24, Color.red(color), Color.green(color), Color.blue(color)), 1));
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
sendButtonContainer.addView(sendButton, LayoutHelper.createFrame(48, 48));
|
2020-01-01 19:32:12 +01:00
|
|
|
sendButton.setOnClickListener(view -> {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing() || (runningAnimationAudio != null && runningAnimationAudio.isRunning())) {
|
2020-01-01 19:32:12 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
sendMessage();
|
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
sendButton.setOnLongClickListener(this::onSendLongClick);
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
slowModeButton = new SimpleTextView(context);
|
|
|
|
slowModeButton.setTextSize(18);
|
|
|
|
slowModeButton.setVisibility(INVISIBLE);
|
|
|
|
slowModeButton.setSoundEffectsEnabled(false);
|
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
|
|
|
slowModeButton.setPadding(0, 0, AndroidUtilities.dp(13), 0);
|
|
|
|
slowModeButton.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
|
|
|
|
slowModeButton.setTextColor(Theme.getColor(Theme.key_chat_messagePanelIcons));
|
|
|
|
sendButtonContainer.addView(slowModeButton, LayoutHelper.createFrame(64, 48, Gravity.RIGHT | Gravity.TOP));
|
|
|
|
slowModeButton.setOnClickListener(v -> {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(slowModeButton, true, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
});
|
2019-09-10 12:56:11 +02:00
|
|
|
slowModeButton.setOnLongClickListener(v -> {
|
|
|
|
if (messageEditText.length() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return onSendLongClick(v);
|
|
|
|
});
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
expandStickersButton = new ImageView(context) {
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
if (getAlpha() <= 0f) { // for accessibility
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
}
|
|
|
|
};
|
2017-07-23 14:56:38 +02:00
|
|
|
expandStickersButton.setScaleType(ImageView.ScaleType.CENTER);
|
2019-01-23 18:03:33 +01:00
|
|
|
expandStickersButton.setImageDrawable(stickersArrow = new AnimatedArrowDrawable(Theme.getColor(Theme.key_chat_messagePanelIcons), false));
|
2017-07-23 14:56:38 +02:00
|
|
|
expandStickersButton.setVisibility(GONE);
|
|
|
|
expandStickersButton.setScaleX(0.1f);
|
|
|
|
expandStickersButton.setScaleY(0.1f);
|
|
|
|
expandStickersButton.setAlpha(0.0f);
|
2019-12-31 14:08:08 +01:00
|
|
|
if (Build.VERSION.SDK_INT >= 21) {
|
|
|
|
expandStickersButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector)));
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
sendButtonContainer.addView(expandStickersButton, LayoutHelper.createFrame(48, 48));
|
2018-08-27 10:33:11 +02:00
|
|
|
expandStickersButton.setOnClickListener(v -> {
|
2020-10-30 11:26:29 +01:00
|
|
|
if (expandStickersButton.getVisibility() != VISIBLE || expandStickersButton.getAlpha() != 1.0f || waitingForKeyboardOpen || (keyboardVisible && messageEditText.isFocused())) {
|
2018-08-27 10:33:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stickersExpanded) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2018-08-27 10:33:11 +02:00
|
|
|
emojiView.closeSearch(true);
|
|
|
|
emojiView.hideSearchKeyboard();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (emojiTabOpen) {
|
|
|
|
checkSendButton(true);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (!stickersDragging) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.showSearchField(false);
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else if (!stickersDragging) {
|
|
|
|
emojiView.showSearchField(true);
|
|
|
|
}
|
|
|
|
if (!stickersDragging) {
|
|
|
|
setStickersExpanded(!stickersExpanded, true, false);
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
});
|
2019-05-14 14:08:05 +02:00
|
|
|
expandStickersButton.setContentDescription(LocaleController.getString("AccDescrExpandPanel", R.string.AccDescrExpandPanel));
|
2017-07-23 14:56:38 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
doneButtonContainer = new FrameLayout(context);
|
|
|
|
doneButtonContainer.setVisibility(GONE);
|
|
|
|
textFieldContainer.addView(doneButtonContainer, LayoutHelper.createLinear(48, 48, Gravity.BOTTOM));
|
2018-08-27 10:33:11 +02:00
|
|
|
doneButtonContainer.setOnClickListener(view -> doneEditingMessage());
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
Drawable doneCircleDrawable = Theme.createCircleDrawable(AndroidUtilities.dp(16), Theme.getColor(Theme.key_chat_messagePanelSend));
|
|
|
|
doneCheckDrawable = context.getResources().getDrawable(R.drawable.input_done).mutate();
|
|
|
|
doneCheckDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_messagePanelVoicePressed), PorterDuff.Mode.MULTIPLY));
|
|
|
|
CombinedDrawable combinedDrawable = new CombinedDrawable(doneCircleDrawable, doneCheckDrawable, 0, AndroidUtilities.dp(1));
|
2019-05-14 14:08:05 +02:00
|
|
|
combinedDrawable.setCustomSize(AndroidUtilities.dp(32), AndroidUtilities.dp(32));
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
doneButtonImage = new ImageView(context);
|
|
|
|
doneButtonImage.setScaleType(ImageView.ScaleType.CENTER);
|
2019-05-14 14:08:05 +02:00
|
|
|
doneButtonImage.setImageDrawable(combinedDrawable);
|
|
|
|
doneButtonImage.setContentDescription(LocaleController.getString("Done", R.string.Done));
|
2017-03-31 01:58:05 +02:00
|
|
|
doneButtonContainer.addView(doneButtonImage, LayoutHelper.createFrame(48, 48));
|
|
|
|
|
|
|
|
doneButtonProgress = new ContextProgressView(context, 0);
|
|
|
|
doneButtonProgress.setVisibility(View.INVISIBLE);
|
|
|
|
doneButtonContainer.addView(doneButtonProgress, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences sharedPreferences = MessagesController.getGlobalEmojiSettings();
|
2015-06-29 19:12:11 +02:00
|
|
|
keyboardHeight = sharedPreferences.getInt("kbd_height", AndroidUtilities.dp(200));
|
|
|
|
keyboardHeightLand = sharedPreferences.getInt("kbd_height_land3", AndroidUtilities.dp(200));
|
2015-05-03 13:48:36 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
setRecordVideoButtonVisible(false, false);
|
2015-06-29 19:12:11 +02:00
|
|
|
checkSendButton(false);
|
2017-07-08 18:32:04 +02:00
|
|
|
checkChannelRights();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
protected void onLineCountChanged(int oldLineCount, int newLineCount) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void startLockTransition() {
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
|
|
|
|
|
|
ObjectAnimator translate = ObjectAnimator.ofFloat(recordCircle, "lockAnimatedTranslation", recordCircle.startTranslation);
|
|
|
|
translate.setStartDelay(100);
|
|
|
|
translate.setDuration(350);
|
|
|
|
ObjectAnimator snap = ObjectAnimator.ofFloat(recordCircle, "snapAnimationProgress", 1f);
|
|
|
|
snap.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
|
|
|
|
snap.setDuration(250);
|
|
|
|
|
|
|
|
SharedConfig.removeLockRecordAudioVideoHint();
|
|
|
|
|
|
|
|
animatorSet.playTogether(
|
|
|
|
snap,
|
|
|
|
translate,
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, "slideToCancelProgress", 1f).setDuration(200),
|
|
|
|
ObjectAnimator.ofFloat(slideText, "cancelToProgress", 1f)
|
|
|
|
);
|
|
|
|
|
|
|
|
animatorSet.start();
|
|
|
|
}
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
public int getBackgroundTop() {
|
|
|
|
int t = getTop();
|
|
|
|
if (topView != null && topView.getVisibility() == View.VISIBLE) {
|
|
|
|
t += topView.getLayoutParams().height;
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
@Override
|
|
|
|
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
|
2020-07-26 10:03:38 +02:00
|
|
|
boolean clip = child == topView || child == textFieldContainer;
|
|
|
|
if (clip) {
|
2016-06-24 12:27:15 +02:00
|
|
|
canvas.save();
|
2020-07-26 10:03:38 +02:00
|
|
|
if (child == textFieldContainer) {
|
|
|
|
int top = animatedTop + AndroidUtilities.dp(2);
|
|
|
|
if (topView != null && topView.getVisibility() == View.VISIBLE) {
|
|
|
|
top += topView.getHeight();
|
|
|
|
}
|
|
|
|
canvas.clipRect(0, top, getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
} else {
|
|
|
|
canvas.clipRect(0, animatedTop, getMeasuredWidth(), animatedTop + child.getLayoutParams().height + AndroidUtilities.dp(2));
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
}
|
|
|
|
boolean result = super.drawChild(canvas, child, drawingTime);
|
2020-07-26 10:03:38 +02:00
|
|
|
if (clip) {
|
2016-06-24 12:27:15 +02:00
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2020-06-04 18:47:15 +02:00
|
|
|
int top = animatedTop;
|
|
|
|
if (topView != null && topView.getVisibility() == View.VISIBLE) {
|
|
|
|
top += (1f - topViewEnterProgress) * topView.getLayoutParams().height;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
int bottom = top + Theme.chat_composeShadowDrawable.getIntrinsicHeight();
|
2020-06-04 18:47:15 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
Theme.chat_composeShadowDrawable.setBounds(0, top, getMeasuredWidth(), bottom);
|
|
|
|
Theme.chat_composeShadowDrawable.draw(canvas);
|
2019-01-23 18:03:33 +01:00
|
|
|
canvas.drawRect(0, bottom, getWidth(), getHeight(), Theme.chat_composeBackgroundPaint);
|
2016-06-24 12:27:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasOverlappingRendering() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
private boolean onSendLongClick(View view) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (parentFragment == null || isInScheduleMode()) {
|
2019-09-10 12:56:11 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
|
|
|
TLRPC.User user = parentFragment.getCurrentUser();
|
|
|
|
|
|
|
|
if (sendPopupLayout == null) {
|
|
|
|
sendPopupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(parentActivity);
|
|
|
|
sendPopupLayout.setAnimationEnabled(false);
|
|
|
|
sendPopupLayout.setOnTouchListener(new OnTouchListener() {
|
|
|
|
|
|
|
|
private android.graphics.Rect popupRect = new android.graphics.Rect();
|
|
|
|
|
|
|
|
@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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
sendPopupLayout.setDispatchKeyEventListener(keyEvent -> {
|
|
|
|
if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
});
|
2021-03-19 11:25:58 +01:00
|
|
|
sendPopupLayout.setShownFromBotton(false);
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
for (int a = 0; a < 2; a++) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (a == 0 && !parentFragment.canScheduleMessage() || a == 1 && (UserObject.isUserSelf(user) || slowModeTimer > 0 && !isInScheduleMode())) {
|
2019-09-10 12:56:11 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
int num = a;
|
2020-12-23 08:48:30 +01:00
|
|
|
ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getContext(), a == 0, a == 1);
|
2019-09-10 12:56:11 +02:00
|
|
|
if (num == 0) {
|
|
|
|
if (UserObject.isUserSelf(user)) {
|
|
|
|
cell.setTextAndIcon(LocaleController.getString("SetReminder", R.string.SetReminder), R.drawable.msg_schedule);
|
|
|
|
} else {
|
|
|
|
cell.setTextAndIcon(LocaleController.getString("ScheduleMessage", R.string.ScheduleMessage), R.drawable.msg_schedule);
|
|
|
|
}
|
2020-10-30 11:26:29 +01:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
cell.setTextAndIcon(LocaleController.getString("SendWithoutSound", R.string.SendWithoutSound), R.drawable.input_notify_off);
|
|
|
|
}
|
|
|
|
cell.setMinimumWidth(AndroidUtilities.dp(196));
|
2020-07-26 10:03:38 +02:00
|
|
|
sendPopupLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48));
|
2019-09-10 12:56:11 +02:00
|
|
|
cell.setOnClickListener(v -> {
|
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupWindow.dismiss();
|
|
|
|
}
|
|
|
|
if (num == 0) {
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), this::sendMessageInternal);
|
2020-10-30 11:26:29 +01:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
sendMessageInternal(false, 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
sendPopupLayout.setupRadialSelectors(Theme.getColor(Theme.key_dialogButtonSelector));
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
sendPopupWindow = new ActionBarPopupWindow(sendPopupLayout, LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT) {
|
|
|
|
@Override
|
|
|
|
public void dismiss() {
|
|
|
|
super.dismiss();
|
|
|
|
sendButton.invalidate();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
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);
|
2020-01-23 07:15:40 +01:00
|
|
|
SharedConfig.removeScheduledOrNoSuoundHint();
|
|
|
|
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onSendLongClick();
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sendPopupLayout.measure(MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(1000), MeasureSpec.AT_MOST));
|
|
|
|
sendPopupWindow.setFocusable(true);
|
|
|
|
int[] location = new int[2];
|
|
|
|
view.getLocationInWindow(location);
|
|
|
|
int y;
|
|
|
|
if (keyboardVisible && ChatActivityEnterView.this.getMeasuredHeight() > AndroidUtilities.dp(topView != null && topView.getVisibility() == VISIBLE ? 48 + 58 : 58)) {
|
|
|
|
y = location[1] + view.getMeasuredHeight();
|
|
|
|
} else {
|
|
|
|
y = location[1] - sendPopupLayout.getMeasuredHeight() - AndroidUtilities.dp(2);
|
|
|
|
}
|
|
|
|
sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - sendPopupLayout.getMeasuredWidth() + AndroidUtilities.dp(8), y);
|
|
|
|
sendPopupWindow.dimBehind();
|
|
|
|
sendButton.invalidate();
|
|
|
|
view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
public boolean isSendButtonVisible() {
|
|
|
|
return sendButton.getVisibility() == VISIBLE;
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
private void setRecordVideoButtonVisible(boolean visible, boolean animated) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (videoSendButton == null) {
|
2017-03-31 01:58:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
videoSendButton.setTag(visible ? 1 : null);
|
|
|
|
if (audioVideoButtonAnimation != null) {
|
|
|
|
audioVideoButtonAnimation.cancel();
|
|
|
|
audioVideoButtonAnimation = null;
|
|
|
|
}
|
|
|
|
if (animated) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
2017-07-08 18:32:04 +02:00
|
|
|
boolean isChannel = false;
|
|
|
|
if ((int) dialog_id < 0) {
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-(int) dialog_id);
|
2017-07-08 18:32:04 +02:00
|
|
|
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
|
|
|
|
}
|
|
|
|
preferences.edit().putBoolean(isChannel ? "currentModeVideoChannel" : "currentModeVideo", visible).commit();
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonAnimation = new AnimatorSet();
|
|
|
|
audioVideoButtonAnimation.playTogether(
|
2019-05-14 14:08:05 +02:00
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.SCALE_X, visible ? 1.0f : 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.SCALE_Y, visible ? 1.0f : 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, visible ? 1.0f : 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.SCALE_X, visible ? 0.1f : 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.SCALE_Y, visible ? 0.1f : 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, visible ? 0.0f : 1.0f));
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (animation.equals(audioVideoButtonAnimation)) {
|
|
|
|
audioVideoButtonAnimation = null;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
(videoSendButton.getTag() == null ? audioSendButton : videoSendButton).sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
audioVideoButtonAnimation.setInterpolator(new DecelerateInterpolator());
|
|
|
|
audioVideoButtonAnimation.setDuration(150);
|
|
|
|
audioVideoButtonAnimation.start();
|
|
|
|
} else {
|
|
|
|
videoSendButton.setScaleX(visible ? 1.0f : 0.1f);
|
|
|
|
videoSendButton.setScaleY(visible ? 1.0f : 0.1f);
|
|
|
|
videoSendButton.setAlpha(visible ? 1.0f : 0.0f);
|
|
|
|
audioSendButton.setScaleX(visible ? 0.1f : 1.0f);
|
|
|
|
audioSendButton.setScaleY(visible ? 0.1f : 1.0f);
|
|
|
|
audioSendButton.setAlpha(visible ? 0.0f : 1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
public boolean isRecordingAudioVideo() {
|
2020-03-30 14:00:09 +02:00
|
|
|
return recordingAudioVideo || (runningAnimationAudio != null && runningAnimationAudio.isRunning());
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isRecordLocked() {
|
|
|
|
return recordingAudioVideo && recordCircle.isSendButtonVisible();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void cancelRecordingAudioVideo() {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (hasRecordVideo && videoSendButton != null && videoSendButton.getTag() != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.needStartRecordVideo(5, true, 0);
|
2017-07-08 18:32:04 +02:00
|
|
|
} else {
|
|
|
|
delegate.needStartRecordAudio(0);
|
2019-09-10 12:56:11 +02:00
|
|
|
MediaController.getInstance().stopRecording(0, false, 0);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
recordingAudioVideo = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
public void showContextProgress(boolean show) {
|
2016-04-22 15:49:00 +02:00
|
|
|
if (progressDrawable == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (show) {
|
|
|
|
progressDrawable.startAnimation();
|
|
|
|
} else {
|
|
|
|
progressDrawable.stopAnimation();
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCaption(String caption) {
|
|
|
|
if (messageEditText != null) {
|
|
|
|
messageEditText.setCaption(caption);
|
2016-04-22 15:49:00 +02:00
|
|
|
checkSendButton(true);
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
public void setSlowModeTimer(int time) {
|
|
|
|
slowModeTimer = time;
|
|
|
|
updateSlowModeText();
|
|
|
|
}
|
|
|
|
|
|
|
|
public CharSequence getSlowModeTimer() {
|
|
|
|
return slowModeTimer > 0 ? slowModeButton.getText() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateSlowModeText() {
|
|
|
|
int serverTime = ConnectionsManager.getInstance(currentAccount).getCurrentTime();
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(updateSlowModeRunnable);
|
|
|
|
updateSlowModeRunnable = null;
|
|
|
|
int currentTime;
|
|
|
|
boolean isUploading;
|
|
|
|
if (info != null && info.slowmode_seconds != 0 && info.slowmode_next_send_date <= serverTime && (
|
|
|
|
(isUploading = SendMessagesHelper.getInstance(currentAccount).isUploadingMessageIdDialog(dialog_id)) ||
|
|
|
|
SendMessagesHelper.getInstance(currentAccount).isSendingMessageIdDialog(dialog_id))) {
|
|
|
|
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(info.id);
|
|
|
|
if (!ChatObject.hasAdminRights(chat)) {
|
|
|
|
currentTime = info.slowmode_seconds;
|
|
|
|
slowModeTimer = isUploading ? Integer.MAX_VALUE : Integer.MAX_VALUE - 1;
|
|
|
|
} else {
|
|
|
|
currentTime = 0;
|
|
|
|
}
|
|
|
|
} else if (slowModeTimer >= Integer.MAX_VALUE - 1) {
|
|
|
|
currentTime = 0;
|
|
|
|
if (info != null) {
|
|
|
|
accountInstance.getMessagesController().loadFullChat(info.id, 0, true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
currentTime = slowModeTimer - serverTime;
|
|
|
|
}
|
|
|
|
if (slowModeTimer != 0 && currentTime > 0) {
|
2020-01-03 16:45:22 +01:00
|
|
|
slowModeButton.setText(AndroidUtilities.formatDurationNoHours(Math.max(1, currentTime), false));
|
2019-08-22 01:53:26 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(slowModeButton, false, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
AndroidUtilities.runOnUIThread(updateSlowModeRunnable = this::updateSlowModeText, 100);
|
|
|
|
} else {
|
|
|
|
slowModeTimer = 0;
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (!isInScheduleMode()) {
|
|
|
|
checkSendButton(true);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
public void addTopView(View view, View lineView, int height) {
|
2015-03-19 00:09:45 +01:00
|
|
|
if (view == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView = lineView;
|
|
|
|
topLineView.setVisibility(GONE);
|
|
|
|
topLineView.setAlpha(0.0f);
|
|
|
|
addView(topLineView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 1, Gravity.TOP | Gravity.LEFT, 0, 1 + height, 0, 0));
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
topView = view;
|
|
|
|
topView.setVisibility(GONE);
|
2020-06-04 18:47:15 +02:00
|
|
|
topViewEnterProgress = 0f;
|
2016-06-24 12:27:15 +02:00
|
|
|
topView.setTranslationY(height);
|
2015-06-29 19:12:11 +02:00
|
|
|
addView(topView, 0, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, height, Gravity.TOP | Gravity.LEFT, 0, 2, 0, 0));
|
2015-03-19 00:09:45 +01:00
|
|
|
needShowTopView = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setForceShowSendButton(boolean value, boolean animated) {
|
|
|
|
forceShowSendButton = value;
|
|
|
|
checkSendButton(animated);
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
public void setAllowStickersAndGifs(boolean value, boolean value2) {
|
2020-09-30 15:48:47 +02:00
|
|
|
setAllowStickersAndGifs(value, value2, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAllowStickersAndGifs(boolean value, boolean value2, boolean waitingForKeyboardOpen) {
|
2016-03-06 02:49:31 +01:00
|
|
|
if ((allowStickers != value || allowGifs != value2) && emojiView != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (!SharedConfig.smoothKeyboard) {
|
|
|
|
if (emojiViewVisible) {
|
|
|
|
hidePopup(false);
|
|
|
|
}
|
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
|
|
|
emojiView = null;
|
|
|
|
} else {
|
2020-10-15 02:39:36 +02:00
|
|
|
if (emojiViewVisible && !waitingForKeyboardOpen) {
|
2020-09-30 15:48:47 +02:00
|
|
|
removeEmojiViewAfterAnimation = true;
|
|
|
|
hidePopup(false);
|
|
|
|
} else {
|
|
|
|
if (waitingForKeyboardOpen) {
|
|
|
|
openKeyboardInternal();
|
|
|
|
}
|
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
|
|
|
emojiView = null;
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
allowStickers = value;
|
2016-01-11 18:19:48 +01:00
|
|
|
allowGifs = value2;
|
2019-05-14 14:08:05 +02:00
|
|
|
setEmojiButtonImage(false, !isPaused);
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
public void addEmojiToRecent(String code) {
|
|
|
|
createEmojiView();
|
|
|
|
emojiView.addEmojiToRecent(code);
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
public void setOpenGifsTabFirst() {
|
|
|
|
createEmojiView();
|
2019-07-18 15:01:39 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).loadRecents(MediaDataController.TYPE_IMAGE, true, true, false);
|
2016-01-11 18:19:48 +01:00
|
|
|
emojiView.switchToGifRecent();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
private final ValueAnimator.AnimatorUpdateListener topViewUpdateListener = animation -> {
|
|
|
|
if (topView != null) {
|
|
|
|
float v = (float) animation.getAnimatedValue();
|
|
|
|
topViewEnterProgress = v;
|
|
|
|
topView.setTranslationY(animatedTop + (1f - v) * topView.getLayoutParams().height);
|
|
|
|
topLineView.setAlpha(v);
|
|
|
|
topLineView.setTranslationY(animatedTop);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-11-26 22:04:02 +01:00
|
|
|
public void showTopView(boolean animated, final boolean openKeyboard) {
|
2020-09-30 15:48:47 +02:00
|
|
|
showTopView(animated, openKeyboard, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showTopView(boolean animated, final boolean openKeyboard, boolean skipAwait) {
|
2015-09-24 22:52:02 +02:00
|
|
|
if (topView == null || topViewShowed || getVisibility() != VISIBLE) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (recordedAudioPanel.getVisibility() != VISIBLE && (!forceShowSendButton || openKeyboard)) {
|
|
|
|
openKeyboard();
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
boolean openKeyboardInternal = recordedAudioPanel.getVisibility() != VISIBLE && (!forceShowSendButton || openKeyboard) && (botReplyMarkup == null || editingMessageObject != null);
|
|
|
|
if (!skipAwait && animated && openKeyboardInternal && !(keyboardVisible || isPopupShowing())) {
|
|
|
|
openKeyboard();
|
|
|
|
if (showTopViewRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(showTopViewRunnable);
|
|
|
|
}
|
|
|
|
AndroidUtilities.runOnUIThread(showTopViewRunnable = () -> {
|
|
|
|
showTopView(true, false, true);
|
|
|
|
showTopViewRunnable = null;
|
|
|
|
}, 200);
|
|
|
|
return;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
needShowTopView = true;
|
2015-04-09 20:00:14 +02:00
|
|
|
topViewShowed = true;
|
2015-03-19 00:09:45 +01:00
|
|
|
if (allowShowTopView) {
|
|
|
|
topView.setVisibility(VISIBLE);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setVisibility(VISIBLE);
|
2015-04-09 20:00:14 +02:00
|
|
|
if (currentTopViewAnimation != null) {
|
|
|
|
currentTopViewAnimation.cancel();
|
|
|
|
currentTopViewAnimation = null;
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
resizeForTopView(true);
|
2015-03-19 00:09:45 +01:00
|
|
|
if (animated) {
|
2020-06-04 18:47:15 +02:00
|
|
|
currentTopViewAnimation = ValueAnimator.ofFloat(topViewEnterProgress, 1f);
|
|
|
|
currentTopViewAnimation.addUpdateListener(topViewUpdateListener);
|
2019-05-14 14:08:05 +02:00
|
|
|
currentTopViewAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) {
|
|
|
|
currentTopViewAnimation = null;
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
});
|
|
|
|
currentTopViewAnimation.setDuration(250);
|
|
|
|
currentTopViewAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
|
|
|
currentTopViewAnimation.start();
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2015-03-19 00:09:45 +01:00
|
|
|
} else {
|
2020-06-04 18:47:15 +02:00
|
|
|
topViewEnterProgress = 1f;
|
2016-06-24 12:27:15 +02:00
|
|
|
topView.setTranslationY(0);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setAlpha(1.0f);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (openKeyboardInternal) {
|
2019-05-14 14:08:05 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
openKeyboard();
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
public void onEditTimeExpired() {
|
|
|
|
doneButtonContainer.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void showEditDoneProgress(final boolean show, boolean animated) {
|
|
|
|
if (doneButtonAnimation != null) {
|
|
|
|
doneButtonAnimation.cancel();
|
|
|
|
}
|
|
|
|
if (!animated) {
|
|
|
|
if (show) {
|
|
|
|
doneButtonImage.setScaleX(0.1f);
|
|
|
|
doneButtonImage.setScaleY(0.1f);
|
|
|
|
doneButtonImage.setAlpha(0.0f);
|
|
|
|
doneButtonProgress.setScaleX(1.0f);
|
|
|
|
doneButtonProgress.setScaleY(1.0f);
|
|
|
|
doneButtonProgress.setAlpha(1.0f);
|
|
|
|
doneButtonImage.setVisibility(View.INVISIBLE);
|
|
|
|
doneButtonProgress.setVisibility(View.VISIBLE);
|
|
|
|
doneButtonContainer.setEnabled(false);
|
|
|
|
} else {
|
|
|
|
doneButtonProgress.setScaleX(0.1f);
|
|
|
|
doneButtonProgress.setScaleY(0.1f);
|
|
|
|
doneButtonProgress.setAlpha(0.0f);
|
|
|
|
doneButtonImage.setScaleX(1.0f);
|
|
|
|
doneButtonImage.setScaleY(1.0f);
|
|
|
|
doneButtonImage.setAlpha(1.0f);
|
|
|
|
doneButtonImage.setVisibility(View.VISIBLE);
|
|
|
|
doneButtonProgress.setVisibility(View.INVISIBLE);
|
|
|
|
doneButtonContainer.setEnabled(true);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
doneButtonAnimation = new AnimatorSet();
|
|
|
|
if (show) {
|
|
|
|
doneButtonProgress.setVisibility(View.VISIBLE);
|
|
|
|
doneButtonContainer.setEnabled(false);
|
|
|
|
doneButtonAnimation.playTogether(
|
2019-05-14 14:08:05 +02:00
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.SCALE_X, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.SCALE_Y, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.ALPHA, 1.0f));
|
2017-03-31 01:58:05 +02:00
|
|
|
} else {
|
|
|
|
doneButtonImage.setVisibility(View.VISIBLE);
|
|
|
|
doneButtonContainer.setEnabled(true);
|
|
|
|
doneButtonAnimation.playTogether(
|
2019-05-14 14:08:05 +02:00
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.SCALE_X, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.SCALE_Y, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonProgress, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(doneButtonImage, View.ALPHA, 1.0f));
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
doneButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (doneButtonAnimation != null && doneButtonAnimation.equals(animation)) {
|
|
|
|
if (!show) {
|
|
|
|
doneButtonProgress.setVisibility(View.INVISIBLE);
|
|
|
|
} else {
|
|
|
|
doneButtonImage.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
|
|
|
if (doneButtonAnimation != null && doneButtonAnimation.equals(animation)) {
|
|
|
|
doneButtonAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
doneButtonAnimation.setDuration(150);
|
|
|
|
doneButtonAnimation.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
public void hideTopView(final boolean animated) {
|
|
|
|
if (topView == null || !topViewShowed) {
|
2015-03-19 00:09:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
if (showTopViewRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(showTopViewRunnable);
|
|
|
|
}
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
topViewShowed = false;
|
2015-03-19 00:09:45 +01:00
|
|
|
needShowTopView = false;
|
|
|
|
if (allowShowTopView) {
|
2015-04-09 20:00:14 +02:00
|
|
|
if (currentTopViewAnimation != null) {
|
|
|
|
currentTopViewAnimation.cancel();
|
|
|
|
currentTopViewAnimation = null;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
if (animated) {
|
2020-06-04 18:47:15 +02:00
|
|
|
currentTopViewAnimation = ValueAnimator.ofFloat(topViewEnterProgress, 0);
|
|
|
|
currentTopViewAnimation.addUpdateListener(topViewUpdateListener);
|
2017-03-31 01:58:05 +02:00
|
|
|
currentTopViewAnimation.addListener(new AnimatorListenerAdapter() {
|
2015-03-19 00:09:45 +01:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animation) {
|
2015-10-29 18:10:07 +01:00
|
|
|
if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) {
|
2015-04-09 20:00:14 +02:00
|
|
|
topView.setVisibility(GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setVisibility(GONE);
|
2016-06-24 12:27:15 +02:00
|
|
|
resizeForTopView(false);
|
2015-04-09 20:00:14 +02:00
|
|
|
currentTopViewAnimation = null;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationCancel(Animator animation) {
|
2016-04-22 15:49:00 +02:00
|
|
|
if (currentTopViewAnimation != null && currentTopViewAnimation.equals(animation)) {
|
|
|
|
currentTopViewAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
});
|
2020-06-04 18:47:15 +02:00
|
|
|
currentTopViewAnimation.setDuration(220);
|
|
|
|
currentTopViewAnimation.setStartDelay(50);
|
2019-01-23 18:03:33 +01:00
|
|
|
currentTopViewAnimation.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2015-04-09 20:00:14 +02:00
|
|
|
currentTopViewAnimation.start();
|
2015-03-19 00:09:45 +01:00
|
|
|
} else {
|
2020-06-04 18:47:15 +02:00
|
|
|
topViewEnterProgress = 0f;
|
2015-03-19 00:09:45 +01:00
|
|
|
topView.setVisibility(GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setVisibility(GONE);
|
|
|
|
topLineView.setAlpha(0.0f);
|
2017-03-31 01:58:05 +02:00
|
|
|
resizeForTopView(false);
|
2016-06-24 12:27:15 +02:00
|
|
|
topView.setTranslationY(topView.getLayoutParams().height);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isTopViewVisible() {
|
|
|
|
return topView != null && topView.getVisibility() == VISIBLE;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public void onAdjustPanTransitionStart(boolean keyboardVisible) {
|
|
|
|
if (keyboardVisible && showTopViewRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(showTopViewRunnable);
|
|
|
|
showTopViewRunnable.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (setTextFieldRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(setTextFieldRunnable);
|
|
|
|
setTextFieldRunnable.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private void onWindowSizeChanged() {
|
|
|
|
int size = sizeNotifierLayout.getHeight();
|
|
|
|
if (!keyboardVisible) {
|
|
|
|
size -= emojiPadding;
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onWindowSizeChanged(size);
|
|
|
|
}
|
|
|
|
if (topView != null) {
|
2015-07-22 20:56:37 +02:00
|
|
|
if (size < AndroidUtilities.dp(72) + ActionBar.getCurrentActionBarHeight()) {
|
2015-03-19 00:09:45 +01:00
|
|
|
if (allowShowTopView) {
|
|
|
|
allowShowTopView = false;
|
|
|
|
if (needShowTopView) {
|
2016-04-22 15:49:00 +02:00
|
|
|
topView.setVisibility(GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setVisibility(GONE);
|
|
|
|
topLineView.setAlpha(0.0f);
|
2016-06-24 12:27:15 +02:00
|
|
|
resizeForTopView(false);
|
2020-06-04 18:47:15 +02:00
|
|
|
topViewEnterProgress = 0f;
|
2016-06-24 12:27:15 +02:00
|
|
|
topView.setTranslationY(topView.getLayoutParams().height);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!allowShowTopView) {
|
|
|
|
allowShowTopView = true;
|
|
|
|
if (needShowTopView) {
|
2016-04-22 15:49:00 +02:00
|
|
|
topView.setVisibility(VISIBLE);
|
2019-05-14 14:08:05 +02:00
|
|
|
topLineView.setVisibility(VISIBLE);
|
|
|
|
topLineView.setAlpha(1.0f);
|
2016-06-24 12:27:15 +02:00
|
|
|
resizeForTopView(true);
|
2020-06-04 18:47:15 +02:00
|
|
|
topViewEnterProgress = 1f;
|
2016-06-24 12:27:15 +02:00
|
|
|
topView.setTranslationY(0);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
private void resizeForTopView(boolean show) {
|
|
|
|
LayoutParams layoutParams = (LayoutParams) textFieldContainer.getLayoutParams();
|
|
|
|
layoutParams.topMargin = AndroidUtilities.dp(2) + (show ? topView.getLayoutParams().height : 0);
|
|
|
|
textFieldContainer.setLayoutParams(layoutParams);
|
2019-05-14 14:08:05 +02:00
|
|
|
setMinimumHeight(AndroidUtilities.dp(51) + (show ? topView.getLayoutParams().height : 0));
|
2018-07-30 04:07:02 +02:00
|
|
|
if (stickersExpanded) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType == 0) {
|
|
|
|
setStickersExpanded(false, true, false);
|
|
|
|
} else {
|
|
|
|
checkStickresExpandHeight();
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
}
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
public void onDestroy() {
|
2018-07-30 04:07:02 +02:00
|
|
|
destroyed = true;
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStarted);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStartError);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStopped);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordProgressChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.closeChats);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.audioDidSent);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.audioRouteChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidReset);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoad);
|
2019-08-22 01:53:26 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.sendingMessagesChanged);
|
2020-03-30 14:00:09 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.audioRecordTooShort);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
|
2016-03-06 02:49:31 +01:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.onDestroy();
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (updateSlowModeRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(updateSlowModeRunnable);
|
|
|
|
updateSlowModeRunnable = null;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (wakeLock != null) {
|
2015-02-26 02:32:51 +01:00
|
|
|
try {
|
2017-03-31 01:58:05 +02:00
|
|
|
wakeLock.release();
|
|
|
|
wakeLock = null;
|
2015-02-26 02:32:51 +01:00
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
if (sizeNotifierLayout != null) {
|
2015-06-29 19:12:11 +02:00
|
|
|
sizeNotifierLayout.setDelegate(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
public void checkChannelRights() {
|
|
|
|
if (parentFragment == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
2019-01-23 18:03:33 +01:00
|
|
|
if (chat != null) {
|
|
|
|
audioVideoButtonContainer.setAlpha(ChatObject.canSendMedia(chat) ? 1.0f : 0.5f);
|
2017-07-08 18:32:04 +02:00
|
|
|
if (emojiView != null) {
|
2019-01-23 18:03:33 +01:00
|
|
|
emojiView.setStickersBanned(!ChatObject.canSendStickers(chat), chat.id);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-18 15:01:39 +02:00
|
|
|
public void onBeginHide() {
|
|
|
|
if (focusRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(focusRunnable);
|
|
|
|
focusRunnable = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
private Runnable hideKeyboardRunnable;
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public void onPause() {
|
|
|
|
isPaused = true;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (keyboardVisible) {
|
|
|
|
showKeyboardOnResume = true;
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
AndroidUtilities.runOnUIThread(hideKeyboardRunnable = () -> {
|
|
|
|
closeKeyboard();
|
|
|
|
hideKeyboardRunnable = null;
|
|
|
|
}, 500);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onResume() {
|
|
|
|
isPaused = false;
|
2020-12-23 08:48:30 +01:00
|
|
|
if (hideKeyboardRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(hideKeyboardRunnable);
|
|
|
|
hideKeyboardRunnable = null;
|
|
|
|
}
|
2019-07-18 15:01:39 +02:00
|
|
|
int visibility = getVisibility();
|
2015-06-29 19:12:11 +02:00
|
|
|
if (showKeyboardOnResume) {
|
|
|
|
showKeyboardOnResume = false;
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType == 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
AndroidUtilities.showKeyboard(messageEditText);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow) {
|
2015-06-29 19:12:11 +02:00
|
|
|
waitingForKeyboardOpen = true;
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
|
|
|
|
AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
|
2015-05-21 23:27:27 +02:00
|
|
|
}
|
2015-02-26 02:32:51 +01:00
|
|
|
}
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2019-07-18 15:01:39 +02:00
|
|
|
@Override
|
|
|
|
public void setVisibility(int visibility) {
|
|
|
|
super.setVisibility(visibility);
|
|
|
|
messageEditText.setEnabled(visibility == VISIBLE);
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public void setDialogId(long id, int account) {
|
2015-02-26 02:32:51 +01:00
|
|
|
dialog_id = id;
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentAccount != account) {
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStarted);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStartError);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordStopped);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.recordProgressChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.closeChats);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.audioDidSent);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.audioRouteChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidReset);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.featuredStickersDidLoad);
|
2019-08-22 01:53:26 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.sendingMessagesChanged);
|
2018-07-30 04:07:02 +02:00
|
|
|
currentAccount = account;
|
2019-08-22 01:53:26 +02:00
|
|
|
accountInstance = AccountInstance.getInstance(currentAccount);
|
2018-07-30 04:07:02 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStarted);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStartError);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordStopped);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.recordProgressChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.closeChats);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.audioDidSent);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.audioRouteChanged);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingDidReset);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.featuredStickersDidLoad);
|
2019-08-22 01:53:26 +02:00
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.messageReceivedByServer);
|
|
|
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.sendingMessagesChanged);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
updateScheduleButton(false);
|
2017-07-08 18:32:04 +02:00
|
|
|
checkRoundVideo();
|
2021-01-28 15:15:51 +01:00
|
|
|
updateFieldHint(false);
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
public void setChatInfo(TLRPC.ChatFull chatInfo) {
|
|
|
|
info = chatInfo;
|
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.setChatInfo(info);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
setSlowModeTimer(chatInfo.slowmode_next_send_date);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
public void checkRoundVideo() {
|
|
|
|
if (hasRecordVideo) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (attachLayout == null || Build.VERSION.SDK_INT < 18) {
|
|
|
|
hasRecordVideo = false;
|
|
|
|
setRecordVideoButtonVisible(false, false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int lower_id = (int) dialog_id;
|
|
|
|
int high_id = (int) (dialog_id >> 32);
|
|
|
|
if (lower_id == 0 && high_id != 0) {
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.EncryptedChat encryptedChat = accountInstance.getMessagesController().getEncryptedChat(high_id);
|
2017-07-08 18:32:04 +02:00
|
|
|
if (AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 66) {
|
|
|
|
hasRecordVideo = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
hasRecordVideo = true;
|
|
|
|
}
|
|
|
|
boolean isChannel = false;
|
|
|
|
if ((int) dialog_id < 0) {
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-(int) dialog_id);
|
2017-07-08 18:32:04 +02:00
|
|
|
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
|
|
|
|
if (isChannel && !chat.creator && (chat.admin_rights == null || !chat.admin_rights.post_messages)) {
|
|
|
|
hasRecordVideo = false;
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!SharedConfig.inappCamera) {
|
2017-12-08 18:35:59 +01:00
|
|
|
hasRecordVideo = false;
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if (hasRecordVideo) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (SharedConfig.hasCameraCache) {
|
|
|
|
CameraController.getInstance().initCamera(null);
|
|
|
|
}
|
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
2017-07-08 18:32:04 +02:00
|
|
|
boolean currentModeVideo = preferences.getBoolean(isChannel ? "currentModeVideoChannel" : "currentModeVideo", isChannel);
|
|
|
|
setRecordVideoButtonVisible(currentModeVideo, false);
|
|
|
|
} else {
|
|
|
|
setRecordVideoButtonVisible(false, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInVideoMode() {
|
2020-03-30 14:00:09 +02:00
|
|
|
return videoSendButton != null && videoSendButton.getTag() != null;
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasRecordVideo() {
|
|
|
|
return hasRecordVideo;
|
|
|
|
}
|
|
|
|
|
2021-01-28 15:15:51 +01:00
|
|
|
private void updateFieldHint(boolean animated) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (editingMessageObject != null) {
|
|
|
|
messageEditText.setHintText(editingCaption ? LocaleController.getString("Caption", R.string.Caption) : LocaleController.getString("TypeMessage", R.string.TypeMessage));
|
2020-09-30 15:48:47 +02:00
|
|
|
} else {
|
|
|
|
boolean isChannel = false;
|
|
|
|
boolean anonymously = false;
|
|
|
|
if ((int) dialog_id < 0) {
|
|
|
|
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-(int) dialog_id);
|
|
|
|
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
|
|
|
|
anonymously = ChatObject.shouldSendAnonymously(chat);
|
|
|
|
}
|
|
|
|
if (anonymously) {
|
|
|
|
messageEditText.setHintText(LocaleController.getString("SendAnonymously", R.string.SendAnonymously));
|
2016-03-06 02:49:31 +01:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (parentFragment != null && parentFragment.isThreadChat()) {
|
|
|
|
if (parentFragment.isReplyChatComment()) {
|
|
|
|
messageEditText.setHintText(LocaleController.getString("Comment", R.string.Comment));
|
|
|
|
} else {
|
|
|
|
messageEditText.setHintText(LocaleController.getString("Reply", R.string.Reply));
|
|
|
|
}
|
|
|
|
} else if (isChannel) {
|
|
|
|
if (silent) {
|
2021-01-28 15:15:51 +01:00
|
|
|
messageEditText.setHintText(LocaleController.getString("ChannelSilentBroadcast", R.string.ChannelSilentBroadcast), animated);
|
2020-09-30 15:48:47 +02:00
|
|
|
} else {
|
2021-01-28 15:15:51 +01:00
|
|
|
messageEditText.setHintText(LocaleController.getString("ChannelBroadcast", R.string.ChannelBroadcast), animated);
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
messageEditText.setHintText(LocaleController.getString("TypeMessage", R.string.TypeMessage));
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
public void setReplyingMessageObject(MessageObject messageObject) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (messageObject != null) {
|
|
|
|
if (botMessageObject == null && botButtonsMessageObject != replyingMessageObject) {
|
|
|
|
botMessageObject = botButtonsMessageObject;
|
|
|
|
}
|
|
|
|
replyingMessageObject = messageObject;
|
|
|
|
setButtons(replyingMessageObject, true);
|
2020-10-30 11:26:29 +01:00
|
|
|
} else if (replyingMessageObject == botButtonsMessageObject) {
|
2015-06-29 19:12:11 +02:00
|
|
|
replyingMessageObject = null;
|
|
|
|
setButtons(botMessageObject, false);
|
|
|
|
botMessageObject = null;
|
|
|
|
} else {
|
2020-10-30 11:26:29 +01:00
|
|
|
replyingMessageObject = null;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
MediaController.getInstance().setReplyingMessage(messageObject, getThreadMessage());
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
|
2015-04-09 20:00:14 +02:00
|
|
|
public void setWebPage(TLRPC.WebPage webPage, boolean searchWebPages) {
|
|
|
|
messageWebPage = webPage;
|
|
|
|
messageWebPageSearch = searchWebPages;
|
|
|
|
}
|
|
|
|
|
2015-05-03 13:48:36 +02:00
|
|
|
public boolean isMessageWebPageSearchEnabled() {
|
|
|
|
return messageWebPageSearch;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void hideRecordedAudioPanel(boolean wasSent) {
|
|
|
|
if (recordPannelAnimation != null && recordPannelAnimation.isRunning()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
audioToSendPath = null;
|
|
|
|
audioToSend = null;
|
|
|
|
audioToSendMessageObject = null;
|
2017-07-08 18:32:04 +02:00
|
|
|
videoToSendMessageObject = null;
|
|
|
|
videoTimelineView.destroy();
|
2016-03-06 02:49:31 +01:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
if (videoSendButton != null && isInVideoMode()) {
|
|
|
|
videoSendButton.setVisibility(View.VISIBLE);
|
|
|
|
} else if (audioSendButton != null) {
|
|
|
|
audioSendButton.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wasSent) {
|
|
|
|
attachButton.setAlpha(0f);
|
|
|
|
emojiButton[0].setAlpha(0f);
|
|
|
|
emojiButton[1].setAlpha(0f);
|
|
|
|
|
|
|
|
attachButton.setScaleX(0);
|
|
|
|
emojiButton[0].setScaleX(0);
|
|
|
|
emojiButton[1].setScaleX(0);
|
|
|
|
|
|
|
|
attachButton.setScaleY(0);
|
|
|
|
emojiButton[0].setScaleY(0);
|
|
|
|
emojiButton[1].setScaleY(0);
|
|
|
|
|
|
|
|
recordPannelAnimation = new AnimatorSet();
|
|
|
|
recordPannelAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_X, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_Y, 0.0f),
|
|
|
|
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioPanel, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 1f),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
recordPannelAnimation.setDuration(150);
|
|
|
|
recordPannelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
recordedAudioPanel.setVisibility(GONE);
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
recordDeleteImageView.playAnimation();
|
|
|
|
AnimatorSet exitAnimation = new AnimatorSet();
|
|
|
|
|
|
|
|
if (isInVideoMode()) {
|
|
|
|
exitAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(videoTimelineView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(videoTimelineView, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 1f),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
messageEditText.setAlpha(1f);
|
|
|
|
messageEditText.setTranslationX(0);
|
|
|
|
exitAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioSeekBar, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioPlayButton, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioBackground, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioTimeTextView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioSeekBar, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioPlayButton, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioBackground, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioTimeTextView, View.TRANSLATION_X, -AndroidUtilities.dp(20))
|
|
|
|
);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
exitAnimation.setDuration(200);
|
|
|
|
|
2020-10-30 13:41:45 +01:00
|
|
|
AnimatorSet attachIconAnimator;
|
|
|
|
if (attachButton != null) {
|
|
|
|
attachButton.setAlpha(0f);
|
|
|
|
attachButton.setScaleX(0);
|
|
|
|
attachButton.setScaleY(0);
|
|
|
|
|
|
|
|
attachIconAnimator = new AnimatorSet();
|
|
|
|
attachIconAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_Y, 1.0f)
|
|
|
|
);
|
|
|
|
attachIconAnimator.setDuration(150);
|
|
|
|
} else {
|
|
|
|
attachIconAnimator = null;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
emojiButton[0].setAlpha(0f);
|
|
|
|
emojiButton[1].setAlpha(0f);
|
|
|
|
|
|
|
|
emojiButton[0].setScaleX(0);
|
|
|
|
emojiButton[1].setScaleX(0);
|
|
|
|
|
|
|
|
emojiButton[0].setScaleY(0);
|
|
|
|
emojiButton[1].setScaleY(0);
|
|
|
|
|
|
|
|
AnimatorSet iconsEndAnimator = new AnimatorSet();
|
|
|
|
|
|
|
|
iconsEndAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_X, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_Y, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.ALPHA, 0.0f),
|
|
|
|
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 1.0f),
|
|
|
|
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1.0f)
|
|
|
|
);
|
|
|
|
iconsEndAnimator.setDuration(150);
|
|
|
|
iconsEndAnimator.setStartDelay(600);
|
|
|
|
|
|
|
|
recordPannelAnimation = new AnimatorSet();
|
2020-10-30 13:41:45 +01:00
|
|
|
if (attachIconAnimator != null) {
|
|
|
|
recordPannelAnimation.playTogether(
|
|
|
|
exitAnimation,
|
|
|
|
attachIconAnimator,
|
|
|
|
iconsEndAnimator
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
recordPannelAnimation.playTogether(
|
|
|
|
exitAnimation,
|
|
|
|
iconsEndAnimator
|
|
|
|
);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
recordPannelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
recordedAudioPanel.setVisibility(GONE);
|
|
|
|
recordedAudioSeekBar.setAlpha(1f);
|
|
|
|
recordedAudioSeekBar.setTranslationX(0);
|
|
|
|
recordedAudioPlayButton.setAlpha(1f);
|
|
|
|
recordedAudioPlayButton.setTranslationX(0);
|
|
|
|
recordedAudioBackground.setAlpha(1f);
|
|
|
|
recordedAudioBackground.setTranslationX(0);
|
|
|
|
recordedAudioTimeTextView.setAlpha(1f);
|
|
|
|
recordedAudioTimeTextView.setTranslationX(0);
|
|
|
|
videoTimelineView.setAlpha(1f);
|
|
|
|
videoTimelineView.setTranslationX(0);
|
|
|
|
messageEditText.setAlpha(1f);
|
|
|
|
messageEditText.setTranslationX(0);
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
recordPannelAnimation.start();
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
private void sendMessage() {
|
|
|
|
if (isInScheduleMode()) {
|
2019-12-31 14:08:08 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), this::sendMessageInternal);
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
|
|
|
sendMessageInternal(true, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void sendMessageInternal(boolean notify, int scheduleDate) {
|
|
|
|
if (slowModeTimer == Integer.MAX_VALUE && !isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.scrollToSendingMessage();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (parentFragment != null) {
|
|
|
|
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
|
|
|
TLRPC.User user = parentFragment.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_" + dialog_id, !notify).commit();
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (stickersExpanded) {
|
|
|
|
setStickersExpanded(false, true, false);
|
|
|
|
if (searchingType != 0) {
|
|
|
|
emojiView.closeSearch(false);
|
|
|
|
emojiView.hideSearchKeyboard();
|
|
|
|
}
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if (videoToSendMessageObject != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.needStartRecordVideo(4, notify, scheduleDate);
|
2020-03-30 14:00:09 +02:00
|
|
|
hideRecordedAudioPanel(true);
|
2017-07-08 18:32:04 +02:00
|
|
|
checkSendButton(true);
|
|
|
|
return;
|
|
|
|
} else if (audioToSend != null) {
|
2016-03-06 02:49:31 +01:00
|
|
|
MessageObject playing = MediaController.getInstance().getPlayingMessageObject();
|
|
|
|
if (playing != null && playing == audioToSendMessageObject) {
|
|
|
|
MediaController.getInstance().cleanupPlayer(true, true);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(audioToSend, null, audioToSendPath, dialog_id, replyingMessageObject, getThreadMessage(), null, null, null, null, notify, scheduleDate, 0, null);
|
2016-03-06 02:49:31 +01:00
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(null, notify, scheduleDate);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
hideRecordedAudioPanel(true);
|
2016-03-06 02:49:31 +01:00
|
|
|
checkSendButton(true);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-25 23:49:47 +02:00
|
|
|
CharSequence message = messageEditText.getText();
|
2019-08-22 01:53:26 +02:00
|
|
|
if (parentFragment != null) {
|
|
|
|
TLRPC.Chat chat = parentFragment.getCurrentChat();
|
|
|
|
if (chat != null && chat.slowmode_enabled && !ChatObject.hasAdminRights(chat)) {
|
|
|
|
if (message.length() > accountInstance.getMessagesController().maxMessageLength) {
|
|
|
|
AlertsCreator.showSimpleAlert(parentFragment, LocaleController.getString("Slowmode", R.string.Slowmode), LocaleController.getString("SlowmodeSendErrorTooLong", R.string.SlowmodeSendErrorTooLong));
|
|
|
|
return;
|
|
|
|
} else if (forceShowSendButton && message.length() > 0) {
|
|
|
|
AlertsCreator.showSimpleAlert(parentFragment, LocaleController.getString("Slowmode", R.string.Slowmode), LocaleController.getString("SlowmodeSendError", R.string.SlowmodeSendError));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (processSendingText(message, notify, scheduleDate)) {
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setText("");
|
2014-07-03 00:39:05 +02:00
|
|
|
lastTypingTimeSend = 0;
|
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(message, notify, scheduleDate);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
} else if (forceShowSendButton) {
|
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(null, notify, scheduleDate);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
public void doneEditingMessage() {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (editingMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (currentLimit - codePointCount < 0) {
|
|
|
|
AndroidUtilities.shakeView(captionLimitView, 2, 0);
|
|
|
|
Vibrator v = (Vibrator) captionLimitView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
|
|
|
|
if (v != null) {
|
|
|
|
v.vibrate(200);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-12-24 20:58:45 +01:00
|
|
|
CharSequence[] message = new CharSequence[]{AndroidUtilities.getTrimmedString(messageEditText.getText())};
|
2020-12-23 08:48:30 +01:00
|
|
|
ArrayList<TLRPC.MessageEntity> entities = MediaDataController.getInstance(currentAccount).getEntities(message, supportsSendingNewEntities());
|
|
|
|
if (!TextUtils.equals(message[0], editingMessageObject.messageText) || entities != null && !entities.isEmpty() || editingMessageObject.messageOwner.media instanceof TLRPC.TL_messageMediaWebPage) {
|
|
|
|
editingMessageObject.editingMessage = message[0];
|
|
|
|
editingMessageObject.editingMessageEntities = entities;
|
|
|
|
editingMessageObject.editingMessageSearchWebPage = messageWebPageSearch;
|
|
|
|
SendMessagesHelper.getInstance(currentAccount).editMessage(editingMessageObject, null, null, null, null, null, false, null);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
setEditingMessageObject(null, false);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
public boolean processSendingText(CharSequence text, boolean notify, int scheduleDate) {
|
2016-06-24 12:27:15 +02:00
|
|
|
text = AndroidUtilities.getTrimmedString(text);
|
2019-12-31 14:08:08 +01:00
|
|
|
boolean supportsNewEntities = supportsSendingNewEntities();
|
|
|
|
int maxLength = accountInstance.getMessagesController().maxMessageLength;
|
|
|
|
if (text.length() != 0) {
|
2020-06-04 18:47:15 +02:00
|
|
|
if (delegate != null && parentFragment != null && (scheduleDate != 0) == parentFragment.isInScheduleMode()) {
|
|
|
|
delegate.prepareMessageSending();
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
int end;
|
|
|
|
int start = 0;
|
|
|
|
do {
|
|
|
|
int whitespaceIndex = -1;
|
|
|
|
int dotIndex = -1;
|
|
|
|
int tabIndex = -1;
|
|
|
|
int enterIndex = -1;
|
|
|
|
if (text.length() > start + maxLength) {
|
|
|
|
int i = start + maxLength - 1;
|
|
|
|
int k = 0;
|
|
|
|
while (i > start && k < 300) {
|
|
|
|
char c = text.charAt(i);
|
|
|
|
char c2 = i > 0 ? text.charAt(i - 1) : ' ';
|
|
|
|
if (c == '\n' && c2 == '\n') {
|
|
|
|
tabIndex = i;
|
|
|
|
break;
|
|
|
|
} else if (c == '\n') {
|
|
|
|
enterIndex = i;
|
|
|
|
} else if (dotIndex < 0 && Character.isWhitespace(c) && c2 == '.') {
|
|
|
|
dotIndex = i;
|
|
|
|
} else if (whitespaceIndex < 0 && Character.isWhitespace(c)) {
|
|
|
|
whitespaceIndex = i;
|
|
|
|
}
|
|
|
|
i--;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end = Math.min(start + maxLength, text.length());
|
|
|
|
if (tabIndex > 0) {
|
|
|
|
end = tabIndex;
|
|
|
|
} else if (enterIndex > 0) {
|
|
|
|
end = enterIndex;
|
|
|
|
} else if (dotIndex > 0) {
|
|
|
|
end = dotIndex;
|
|
|
|
} else if (whitespaceIndex > 0) {
|
|
|
|
end = whitespaceIndex;
|
|
|
|
}
|
|
|
|
CharSequence[] message = new CharSequence[]{AndroidUtilities.getTrimmedString(text.subSequence(start, end))};
|
2019-12-31 14:08:08 +01:00
|
|
|
ArrayList<TLRPC.MessageEntity> entities = MediaDataController.getInstance(currentAccount).getEntities(message, supportsNewEntities);
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(message[0].toString(), dialog_id, replyingMessageObject, getThreadMessage(), messageWebPage, messageWebPageSearch, entities, null, null, notify, scheduleDate);
|
2020-12-23 08:48:30 +01:00
|
|
|
start = end + 1;
|
|
|
|
} while (end != text.length());
|
2019-12-31 14:08:08 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean supportsSendingNewEntities() {
|
|
|
|
TLRPC.EncryptedChat encryptedChat = parentFragment != null ? parentFragment.getCurrentEncryptedChat() : null;
|
|
|
|
return encryptedChat == null || AndroidUtilities.getPeerLayerVersion(encryptedChat.layer) >= 101;
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
private void checkSendButton(boolean animated) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (editingMessageObject != null || recordingAudioVideo) {
|
2016-03-06 02:49:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
if (isPaused) {
|
|
|
|
animated = false;
|
|
|
|
}
|
|
|
|
CharSequence message = AndroidUtilities.getTrimmedString(messageEditText.getText());
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer > 0 && slowModeTimer != Integer.MAX_VALUE && !isInScheduleMode()) {
|
|
|
|
if (slowModeButton.getVisibility() != VISIBLE) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (animated) {
|
|
|
|
if (runningAnimationType == 5) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (runningAnimation != null) {
|
|
|
|
runningAnimation.cancel();
|
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
if (runningAnimation2 != null) {
|
|
|
|
runningAnimation2.cancel();
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attachLayout != null) {
|
|
|
|
runningAnimation2 = new AnimatorSet();
|
2019-09-10 12:56:11 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.SCALE_X, 0.0f));
|
|
|
|
scheduleButtonHidden = false;
|
|
|
|
boolean hasScheduled = delegate != null && delegate.hasScheduledMessages();
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
if (hasScheduled) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
scheduledButton.setPivotX(AndroidUtilities.dp(48));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48)));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 1.0f));
|
|
|
|
} else {
|
|
|
|
scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48));
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runningAnimation2.playTogether(animators);
|
2019-08-22 01:53:26 +02:00
|
|
|
runningAnimation2.setDuration(100);
|
|
|
|
runningAnimation2.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation2)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
attachLayout.setVisibility(GONE);
|
2019-09-10 12:56:11 +02:00
|
|
|
runningAnimation2 = null;
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation2)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
runningAnimation2.start();
|
|
|
|
updateFieldRight(0);
|
2020-01-05 12:50:11 +01:00
|
|
|
if (delegate != null && getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonHidden();
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
runningAnimationType = 5;
|
|
|
|
runningAnimation = new AnimatorSet();
|
|
|
|
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
if (audioVideoButtonContainer.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 0.0f));
|
|
|
|
}
|
|
|
|
if (expandStickersButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.ALPHA, 0.0f));
|
|
|
|
}
|
|
|
|
if (sendButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.ALPHA, 0.0f));
|
|
|
|
}
|
|
|
|
if (cancelBotButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.ALPHA, 0.0f));
|
|
|
|
}
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_Y, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.ALPHA, 1.0f));
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(true);
|
2019-08-22 01:53:26 +02:00
|
|
|
runningAnimation.playTogether(animators);
|
|
|
|
runningAnimation.setDuration(150);
|
|
|
|
runningAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
cancelBotButton.setVisibility(GONE);
|
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
expandStickersButton.setVisibility(GONE);
|
|
|
|
runningAnimation = null;
|
|
|
|
runningAnimationType = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
runningAnimation.start();
|
|
|
|
} else {
|
|
|
|
slowModeButton.setScaleX(1.0f);
|
|
|
|
slowModeButton.setScaleY(1.0f);
|
|
|
|
slowModeButton.setAlpha(1.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(true);
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
audioVideoButtonContainer.setScaleX(0.1f);
|
|
|
|
audioVideoButtonContainer.setScaleY(0.1f);
|
|
|
|
audioVideoButtonContainer.setAlpha(0.0f);
|
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
|
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
|
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
|
|
|
cancelBotButton.setVisibility(GONE);
|
|
|
|
|
|
|
|
if (expandStickersButton.getVisibility() == VISIBLE) {
|
|
|
|
expandStickersButton.setScaleX(0.1f);
|
|
|
|
expandStickersButton.setScaleY(0.1f);
|
|
|
|
expandStickersButton.setAlpha(0.0f);
|
|
|
|
expandStickersButton.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setVisibility(GONE);
|
2020-01-05 12:50:11 +01:00
|
|
|
if (delegate != null && getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonHidden();
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
updateFieldRight(0);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
scheduleButtonHidden = false;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (delegate != null && delegate.hasScheduledMessages()) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
}
|
|
|
|
scheduledButton.setTranslationX(AndroidUtilities.dp(botButton != null && botButton.getVisibility() == VISIBLE ? 96 : 48));
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
} else if (message.length() > 0 || forceShowSendButton || audioToSend != null || videoToSendMessageObject != null || slowModeTimer == Integer.MAX_VALUE && !isInScheduleMode()) {
|
2017-03-31 01:58:05 +02:00
|
|
|
final String caption = messageEditText.getCaption();
|
2017-07-23 14:56:38 +02:00
|
|
|
boolean showBotButton = caption != null && (sendButton.getVisibility() == VISIBLE || expandStickersButton.getVisibility() == VISIBLE);
|
|
|
|
boolean showSendButton = caption == null && (cancelBotButton.getVisibility() == VISIBLE || expandStickersButton.getVisibility() == VISIBLE);
|
2019-08-22 01:53:26 +02:00
|
|
|
int color;
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer == Integer.MAX_VALUE && !isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
color = Theme.getColor(Theme.key_chat_messagePanelIcons);
|
|
|
|
} else {
|
|
|
|
color = Theme.getColor(Theme.key_chat_messagePanelSend);
|
|
|
|
}
|
|
|
|
Theme.setSelectorDrawableColor(sendButton.getBackground(), Color.argb(24, Color.red(color), Color.green(color), Color.blue(color)), true);
|
|
|
|
if (audioVideoButtonContainer.getVisibility() == VISIBLE || slowModeButton.getVisibility() == VISIBLE || showBotButton || showSendButton) {
|
2014-11-17 03:44:57 +01:00
|
|
|
if (animated) {
|
2017-03-31 01:58:05 +02:00
|
|
|
if (runningAnimationType == 1 && messageEditText.getCaption() == null || runningAnimationType == 3 && caption != null) {
|
2014-10-07 22:14:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (runningAnimation != null) {
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.cancel();
|
2014-10-07 22:14:27 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
if (runningAnimation2 != null) {
|
|
|
|
runningAnimation2.cancel();
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
if (attachLayout != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimation2 = new AnimatorSet();
|
2019-09-10 12:56:11 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.SCALE_X, 0.0f));
|
|
|
|
boolean hasScheduled = delegate != null && delegate.hasScheduledMessages();
|
|
|
|
scheduleButtonHidden = true;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
if (hasScheduled) {
|
|
|
|
scheduledButton.setTag(null);
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 0.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96)));
|
|
|
|
} else {
|
|
|
|
scheduledButton.setAlpha(0.0f);
|
|
|
|
scheduledButton.setScaleX(0.0f);
|
|
|
|
scheduledButton.setTranslationX(AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runningAnimation2.playTogether(animators);
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation2.setDuration(100);
|
2017-03-31 01:58:05 +02:00
|
|
|
runningAnimation2.addListener(new AnimatorListenerAdapter() {
|
2014-11-17 03:44:57 +01:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation2)) {
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.setVisibility(GONE);
|
2019-09-10 12:56:11 +02:00
|
|
|
if (hasScheduled) {
|
|
|
|
scheduledButton.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
runningAnimation2 = null;
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation2)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
});
|
|
|
|
runningAnimation2.start();
|
2015-07-22 20:56:37 +02:00
|
|
|
updateFieldRight(0);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (delegate != null && getVisibility() == VISIBLE) {
|
2016-03-06 02:49:31 +01:00
|
|
|
delegate.onAttachButtonHidden();
|
|
|
|
}
|
2014-11-14 16:40:15 +01:00
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimation = new AnimatorSet();
|
2014-11-17 03:44:57 +01:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
2017-03-31 01:58:05 +02:00
|
|
|
if (audioVideoButtonContainer.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 0.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
if (expandStickersButton.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.ALPHA, 0.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (slowModeButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.ALPHA, 0.0f));
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
if (showBotButton) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.ALPHA, 0.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (showSendButton) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.ALPHA, 0.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (caption != null) {
|
2016-04-22 15:49:00 +02:00
|
|
|
runningAnimationType = 3;
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_Y, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.ALPHA, 1.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(VISIBLE);
|
|
|
|
} else {
|
|
|
|
runningAnimationType = 1;
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_Y, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.ALPHA, 1.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
sendButton.setVisibility(VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
runningAnimation.playTogether(animators);
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.setDuration(150);
|
2017-03-31 01:58:05 +02:00
|
|
|
runningAnimation.addListener(new AnimatorListenerAdapter() {
|
2014-10-07 22:14:27 +02:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2017-03-31 01:58:05 +02:00
|
|
|
if (caption != null) {
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(VISIBLE);
|
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
} else {
|
|
|
|
sendButton.setVisibility(VISIBLE);
|
|
|
|
cancelBotButton.setVisibility(GONE);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
2017-07-23 14:56:38 +02:00
|
|
|
expandStickersButton.setVisibility(GONE);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2014-10-07 22:14:27 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
runningAnimationType = 0;
|
|
|
|
}
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
});
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.start();
|
2014-10-07 22:14:27 +02:00
|
|
|
} else {
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.setScaleX(0.1f);
|
|
|
|
audioVideoButtonContainer.setScaleY(0.1f);
|
|
|
|
audioVideoButtonContainer.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
if (slowModeButton.getVisibility() == VISIBLE) {
|
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (caption != null) {
|
2016-06-24 12:27:15 +02:00
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton.setVisibility(GONE);
|
2016-06-24 12:27:15 +02:00
|
|
|
cancelBotButton.setScaleX(1.0f);
|
|
|
|
cancelBotButton.setScaleY(1.0f);
|
|
|
|
cancelBotButton.setAlpha(1.0f);
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(VISIBLE);
|
|
|
|
} else {
|
2016-06-24 12:27:15 +02:00
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton.setVisibility(VISIBLE);
|
2016-06-24 12:27:15 +02:00
|
|
|
sendButton.setScaleX(1.0f);
|
|
|
|
sendButton.setScaleY(1.0f);
|
|
|
|
sendButton.setAlpha(1.0f);
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(GONE);
|
|
|
|
}
|
2019-07-18 15:01:39 +02:00
|
|
|
if (expandStickersButton.getVisibility() == VISIBLE) {
|
|
|
|
expandStickersButton.setScaleX(0.1f);
|
|
|
|
expandStickersButton.setScaleY(0.1f);
|
|
|
|
expandStickersButton.setAlpha(0.0f);
|
|
|
|
expandStickersButton.setVisibility(GONE);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setVisibility(GONE);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (delegate != null && getVisibility() == VISIBLE) {
|
2016-03-06 02:49:31 +01:00
|
|
|
delegate.onAttachButtonHidden();
|
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
updateFieldRight(0);
|
2014-11-14 16:40:15 +01:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
scheduleButtonHidden = true;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (delegate != null && delegate.hasScheduledMessages()) {
|
|
|
|
scheduledButton.setVisibility(GONE);
|
|
|
|
scheduledButton.setTag(null);
|
|
|
|
}
|
|
|
|
scheduledButton.setAlpha(0.0f);
|
|
|
|
scheduledButton.setScaleX(0.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
scheduledButton.setTranslationX(AndroidUtilities.dp(botButton == null || botButton.getVisibility() == GONE ? 48 : 96));
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
} else if (emojiView != null && emojiViewVisible && (stickersTabOpen || emojiTabOpen && searchingType == 2) && !AndroidUtilities.isInMultiwindow) {
|
2017-07-23 14:56:38 +02:00
|
|
|
if (animated) {
|
|
|
|
if (runningAnimationType == 4) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runningAnimation != null) {
|
|
|
|
runningAnimation.cancel();
|
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
if (runningAnimation2 != null) {
|
|
|
|
runningAnimation2.cancel();
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
|
2020-10-30 11:26:29 +01:00
|
|
|
if (attachLayout != null && recordInterfaceState == 0) {
|
2017-07-23 14:56:38 +02:00
|
|
|
attachLayout.setVisibility(VISIBLE);
|
|
|
|
runningAnimation2 = new AnimatorSet();
|
2019-09-10 12:56:11 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.SCALE_X, 1.0f));
|
|
|
|
boolean hasScheduled = delegate != null && delegate.hasScheduledMessages();
|
|
|
|
scheduleButtonHidden = false;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
if (hasScheduled) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
scheduledButton.setPivotX(AndroidUtilities.dp(48));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0));
|
|
|
|
} else {
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setTranslationX(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runningAnimation2.playTogether(animators);
|
2017-07-23 14:56:38 +02:00
|
|
|
runningAnimation2.setDuration(100);
|
2019-09-10 12:56:11 +02:00
|
|
|
runningAnimation2.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (animation.equals(runningAnimation2)) {
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
|
|
|
if (animation.equals(runningAnimation2)) {
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2017-07-23 14:56:38 +02:00
|
|
|
runningAnimation2.start();
|
|
|
|
updateFieldRight(1);
|
|
|
|
if (getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonShow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
expandStickersButton.setVisibility(VISIBLE);
|
|
|
|
runningAnimation = new AnimatorSet();
|
|
|
|
runningAnimationType = 4;
|
|
|
|
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_Y, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.ALPHA, 1.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
if (cancelBotButton.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.ALPHA, 0.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
} else if (audioVideoButtonContainer.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 0.0f));
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (slowModeButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.ALPHA, 0.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.ALPHA, 0.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
runningAnimation.playTogether(animators);
|
2020-09-30 15:48:47 +02:00
|
|
|
runningAnimation.setDuration(AdjustPanLayoutHelper.keyboardDuration);
|
2017-07-23 14:56:38 +02:00
|
|
|
runningAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2017-07-23 14:56:38 +02:00
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
cancelBotButton.setVisibility(GONE);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2017-07-23 14:56:38 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
expandStickersButton.setVisibility(VISIBLE);
|
|
|
|
runningAnimation = null;
|
|
|
|
runningAnimationType = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2017-07-23 14:56:38 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
runningAnimation.start();
|
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2017-07-23 14:56:38 +02:00
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton.setVisibility(GONE);
|
2017-07-23 14:56:38 +02:00
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
cancelBotButton.setVisibility(GONE);
|
2017-07-23 14:56:38 +02:00
|
|
|
audioVideoButtonContainer.setScaleX(0.1f);
|
|
|
|
audioVideoButtonContainer.setScaleY(0.1f);
|
|
|
|
audioVideoButtonContainer.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
2017-07-23 14:56:38 +02:00
|
|
|
expandStickersButton.setScaleX(1.0f);
|
|
|
|
expandStickersButton.setScaleY(1.0f);
|
|
|
|
expandStickersButton.setAlpha(1.0f);
|
|
|
|
expandStickersButton.setVisibility(VISIBLE);
|
|
|
|
if (attachLayout != null) {
|
|
|
|
if (getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonShow();
|
|
|
|
}
|
|
|
|
attachLayout.setVisibility(VISIBLE);
|
|
|
|
updateFieldRight(1);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
scheduleButtonHidden = false;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (delegate != null && delegate.hasScheduledMessages()) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
}
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
scheduledButton.setTranslationX(0);
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (sendButton.getVisibility() == VISIBLE || cancelBotButton.getVisibility() == VISIBLE || expandStickersButton.getVisibility() == VISIBLE || slowModeButton.getVisibility() == VISIBLE) {
|
2014-11-17 03:44:57 +01:00
|
|
|
if (animated) {
|
2014-10-07 22:14:27 +02:00
|
|
|
if (runningAnimationType == 2) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (runningAnimation != null) {
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.cancel();
|
2014-10-07 22:14:27 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
if (runningAnimation2 != null) {
|
|
|
|
runningAnimation2.cancel();
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setVisibility(VISIBLE);
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimation2 = new AnimatorSet();
|
2019-09-10 12:56:11 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(attachLayout, View.SCALE_X, 1.0f));
|
|
|
|
boolean hasScheduled = delegate != null && delegate.hasScheduledMessages();
|
|
|
|
scheduleButtonHidden = false;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (hasScheduled) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
scheduledButton.setPivotX(AndroidUtilities.dp(48));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0));
|
|
|
|
} else {
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
scheduledButton.setTranslationX(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runningAnimation2.playTogether(animators);
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation2.setDuration(100);
|
2019-09-10 12:56:11 +02:00
|
|
|
runningAnimation2.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (animation.equals(runningAnimation2)) {
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationCancel(Animator animation) {
|
|
|
|
if (animation.equals(runningAnimation2)) {
|
|
|
|
runningAnimation2 = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation2.start();
|
2015-07-22 20:56:37 +02:00
|
|
|
updateFieldRight(1);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonShow();
|
|
|
|
}
|
2014-11-14 16:40:15 +01:00
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(VISIBLE);
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimation = new AnimatorSet();
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimationType = 2;
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_X, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_Y, 1.0f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
if (cancelBotButton.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(cancelBotButton, View.ALPHA, 0.0f));
|
2017-07-23 14:56:38 +02:00
|
|
|
} else if (expandStickersButton.getVisibility() == VISIBLE) {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(expandStickersButton, View.ALPHA, 0.0f));
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (slowModeButton.getVisibility() == VISIBLE) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(slowModeButton, View.ALPHA, 0.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_X, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.SCALE_Y, 0.1f));
|
|
|
|
animators.add(ObjectAnimator.ofFloat(sendButton, View.ALPHA, 0.0f));
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
runningAnimation.playTogether(animators);
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.setDuration(150);
|
2017-03-31 01:58:05 +02:00
|
|
|
runningAnimation.addListener(new AnimatorListenerAdapter() {
|
2014-10-07 22:14:27 +02:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2014-10-07 22:14:27 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
runningAnimationType = 0;
|
2020-03-30 18:49:17 +02:00
|
|
|
|
|
|
|
if (audioVideoButtonContainer != null) {
|
|
|
|
audioVideoButtonContainer.setVisibility(VISIBLE);
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationCancel(Animator animation) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animation.equals(runningAnimation)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
runningAnimation = null;
|
|
|
|
}
|
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
});
|
2014-11-17 03:44:57 +01:00
|
|
|
runningAnimation.start();
|
2014-10-07 22:14:27 +02:00
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2016-06-24 12:27:15 +02:00
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
sendButton.setVisibility(GONE);
|
2016-06-24 12:27:15 +02:00
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
cancelBotButton.setVisibility(GONE);
|
2017-07-23 14:56:38 +02:00
|
|
|
expandStickersButton.setScaleX(0.1f);
|
|
|
|
expandStickersButton.setScaleY(0.1f);
|
|
|
|
expandStickersButton.setAlpha(0.0f);
|
2019-08-22 01:53:26 +02:00
|
|
|
expandStickersButton.setVisibility(GONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.setScaleX(1.0f);
|
|
|
|
audioVideoButtonContainer.setScaleY(1.0f);
|
|
|
|
audioVideoButtonContainer.setAlpha(1.0f);
|
|
|
|
audioVideoButtonContainer.setVisibility(VISIBLE);
|
|
|
|
if (attachLayout != null) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonShow();
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
attachLayout.setAlpha(1.0f);
|
|
|
|
attachLayout.setScaleX(1.0f);
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.setVisibility(VISIBLE);
|
2015-07-22 20:56:37 +02:00
|
|
|
updateFieldRight(1);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
scheduleButtonHidden = false;
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (delegate != null && delegate.hasScheduledMessages()) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
scheduledButton.setTag(1);
|
|
|
|
}
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
scheduledButton.setTranslationX(0);
|
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:45:22 +01:00
|
|
|
private void setSlowModeButtonVisible(boolean visible) {
|
|
|
|
slowModeButton.setVisibility(visible ? VISIBLE : GONE);
|
|
|
|
int padding = visible ? AndroidUtilities.dp(16) : 0;
|
|
|
|
if (messageEditText.getPaddingRight() != padding) {
|
|
|
|
messageEditText.setPadding(0, AndroidUtilities.dp(11), padding, AndroidUtilities.dp(12));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-22 20:56:37 +02:00
|
|
|
private void updateFieldRight(int attachVisible) {
|
2016-03-06 02:49:31 +01:00
|
|
|
if (messageEditText == null || editingMessageObject != null) {
|
2015-07-22 20:56:37 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messageEditText.getLayoutParams();
|
2019-12-31 14:08:08 +01:00
|
|
|
int oldRightMargin = layoutParams.rightMargin;
|
2015-07-22 20:56:37 +02:00
|
|
|
if (attachVisible == 1) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (botButton != null && botButton.getVisibility() == VISIBLE && scheduledButton != null && scheduledButton.getVisibility() == VISIBLE && attachLayout != null && attachLayout.getVisibility() == VISIBLE) {
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(146);
|
|
|
|
} else if (botButton != null && botButton.getVisibility() == VISIBLE || notifyButton != null && notifyButton.getVisibility() == VISIBLE || scheduledButton != null && scheduledButton.getTag() != null) {
|
2015-07-22 20:56:37 +02:00
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(98);
|
|
|
|
} else {
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
|
|
|
}
|
|
|
|
} else if (attachVisible == 2) {
|
|
|
|
if (layoutParams.rightMargin != AndroidUtilities.dp(2)) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (botButton != null && botButton.getVisibility() == VISIBLE && scheduledButton != null && scheduledButton.getVisibility() == VISIBLE && attachLayout != null && attachLayout.getVisibility() == VISIBLE) {
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(146);
|
|
|
|
} else if (botButton != null && botButton.getVisibility() == VISIBLE || notifyButton != null && notifyButton.getVisibility() == VISIBLE || scheduledButton != null && scheduledButton.getTag() != null) {
|
2015-07-22 20:56:37 +02:00
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(98);
|
|
|
|
} else {
|
2014-11-19 02:23:46 +01:00
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
2014-11-14 16:40:15 +01:00
|
|
|
}
|
2014-10-07 22:14:27 +02:00
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (scheduledButton != null && scheduledButton.getTag() != null) {
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(50);
|
|
|
|
} else {
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(2);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
if (oldRightMargin != layoutParams.rightMargin) {
|
|
|
|
messageEditText.setLayoutParams(layoutParams);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
public void startMessageTransition() {
|
|
|
|
if (moveToSendStateRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(moveToSendStateRunnable);
|
|
|
|
moveToSendStateRunnable = null;
|
|
|
|
}
|
|
|
|
messageTransitionIsRunning = true;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_SENDING);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canShowVoiceMessageTransition() {
|
|
|
|
return moveToSendStateRunnable != null;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
private void updateRecordIntefrace(int recordState) {
|
2021-03-19 11:25:58 +01:00
|
|
|
if (moveToSendStateRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(moveToSendStateRunnable);
|
|
|
|
moveToSendStateRunnable = null;
|
|
|
|
}
|
|
|
|
recordCircle.voiceEnterTransitionInProgress = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
if (recordingAudioVideo) {
|
|
|
|
if (recordInterfaceState == 1) {
|
2014-11-17 23:04:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
recordInterfaceState = 1;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.setEnabled(false);
|
|
|
|
}
|
|
|
|
if (emojiButtonAnimation != null) {
|
|
|
|
emojiButtonAnimation.cancel();
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
try {
|
2017-03-31 01:58:05 +02:00
|
|
|
if (wakeLock == null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
2019-01-23 18:03:33 +01:00
|
|
|
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "telegram:audio_record_lock");
|
2017-03-31 01:58:05 +02:00
|
|
|
wakeLock.acquire();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
AndroidUtilities.lockOrientation(parentActivity);
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (runningAnimationAudio != null) {
|
|
|
|
runningAnimationAudio.cancel();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (recordPannelAnimation != null) {
|
|
|
|
recordPannelAnimation.cancel();
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
recordPanel.setVisibility(VISIBLE);
|
|
|
|
recordCircle.setVisibility(VISIBLE);
|
|
|
|
recordCircle.setAmplitude(0);
|
|
|
|
recordDot.resetAlpha();
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimationAudio = new AnimatorSet();
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
recordDot.setScaleX(0);
|
|
|
|
recordDot.setScaleY(0);
|
|
|
|
recordDot.enterAnimation = true;
|
|
|
|
recordTimerView.setTranslationX(AndroidUtilities.dp(20));
|
|
|
|
recordTimerView.setAlpha(0);
|
|
|
|
slideText.setTranslationX(AndroidUtilities.dp(20));
|
|
|
|
slideText.setAlpha(0);
|
|
|
|
slideText.setCancelToProgress(0f);
|
|
|
|
slideText.setSlideX(1f);
|
|
|
|
recordCircle.setLockTranslation(10000);
|
|
|
|
slideText.setEnabled(true);
|
|
|
|
|
|
|
|
recordIsCanceled = false;
|
|
|
|
|
|
|
|
//ENTER TRANSITION
|
|
|
|
AnimatorSet iconChanges = new AnimatorSet();
|
|
|
|
iconChanges.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.ALPHA, 1)
|
|
|
|
);
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
iconChanges.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, 0));
|
|
|
|
}
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
iconChanges.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, 0));
|
|
|
|
}
|
|
|
|
iconChanges.setStartDelay(150);
|
|
|
|
|
|
|
|
AnimatorSet viewTransition = new AnimatorSet();
|
|
|
|
viewTransition.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.TRANSLATION_X, AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioPanel, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
viewTransition.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, AndroidUtilities.dp(30)),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 0f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
|
|
|
viewTransition.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.TRANSLATION_X, AndroidUtilities.dp(30)),
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 0f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
iconChanges.setDuration(150),
|
|
|
|
viewTransition.setDuration(150),
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, recordCircleScale, 1).setDuration(300)
|
|
|
|
);
|
2017-03-31 01:58:05 +02:00
|
|
|
runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
|
2014-11-17 03:44:57 +01:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animator) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animator.equals(runningAnimationAudio)) {
|
2015-10-29 18:10:07 +01:00
|
|
|
runningAnimationAudio = null;
|
2014-11-17 23:04:31 +01:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
slideText.setAlpha(1f);
|
|
|
|
slideText.setTranslationX(0);
|
|
|
|
|
|
|
|
recordCircle.showTooltipIfNeed();
|
|
|
|
messageEditText.setVisibility(View.GONE);
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
|
|
|
});
|
2015-10-29 18:10:07 +01:00
|
|
|
runningAnimationAudio.setInterpolator(new DecelerateInterpolator());
|
2014-11-17 23:04:31 +01:00
|
|
|
runningAnimationAudio.start();
|
2020-03-30 14:00:09 +02:00
|
|
|
recordTimerView.start();
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (recordIsCanceled && recordState == RECORD_STATE_PREPARING) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (wakeLock != null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
try {
|
2017-03-31 01:58:05 +02:00
|
|
|
wakeLock.release();
|
|
|
|
wakeLock = null;
|
2014-07-03 00:39:05 +02:00
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
AndroidUtilities.unlockOrientation(parentActivity);
|
2020-03-30 14:00:09 +02:00
|
|
|
wasSendTyping = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
if (recordInterfaceState == 0) {
|
2014-11-17 23:04:31 +01:00
|
|
|
return;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
accountInstance.getMessagesController().sendTyping(dialog_id, getThreadMessageId(), 2, 0);
|
2017-03-31 01:58:05 +02:00
|
|
|
recordInterfaceState = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.setEnabled(true);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean shouldShowFastTransition = false;
|
2014-11-17 23:04:31 +01:00
|
|
|
if (runningAnimationAudio != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
shouldShowFastTransition = runningAnimationAudio.isRunning();
|
2020-07-26 10:03:38 +02:00
|
|
|
if (videoSendButton != null) {
|
|
|
|
videoSendButton.setScaleX(1f);
|
|
|
|
videoSendButton.setScaleY(1f);
|
|
|
|
}
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
audioSendButton.setScaleX(1f);
|
|
|
|
audioSendButton.setScaleY(1f);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
runningAnimationAudio.removeAllListeners();
|
2014-11-17 23:04:31 +01:00
|
|
|
runningAnimationAudio.cancel();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (recordPannelAnimation != null) {
|
|
|
|
recordPannelAnimation.cancel();
|
|
|
|
}
|
|
|
|
messageEditText.setVisibility(View.VISIBLE);
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
runningAnimationAudio = new AnimatorSet();
|
2020-03-30 14:00:09 +02:00
|
|
|
//EXIT TRANSITION
|
|
|
|
if (shouldShowFastTransition || recordState == RECORD_STATE_CANCEL_BY_TIME) {
|
|
|
|
if (videoSendButton != null && isInVideoMode()) {
|
|
|
|
videoSendButton.setVisibility(View.VISIBLE);
|
|
|
|
} else if (audioSendButton != null) {
|
|
|
|
audioSendButton.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, recordCircleScale, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, recordCircleScale, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, "slideToCancelProgress", 1f)
|
|
|
|
);
|
|
|
|
if (audioSendButton != null) {
|
2020-07-26 10:03:38 +02:00
|
|
|
audioSendButton.setScaleX(1f);
|
|
|
|
audioSendButton.setScaleY(1f);
|
2020-03-30 14:00:09 +02:00
|
|
|
runningAnimationAudio.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, isInVideoMode() ? 0 : 1));
|
|
|
|
}
|
|
|
|
if (videoSendButton != null) {
|
2020-07-26 10:03:38 +02:00
|
|
|
videoSendButton.setScaleX(1f);
|
|
|
|
videoSendButton.setScaleY(1f);
|
2020-03-30 14:00:09 +02:00
|
|
|
runningAnimationAudio.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, isInVideoMode() ? 1 : 0));
|
|
|
|
}
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
recordIsCanceled = true;
|
|
|
|
runningAnimationAudio.setDuration(150);
|
|
|
|
} else if (recordState == RECORD_STATE_PREPARING) {
|
|
|
|
slideText.setEnabled(false);
|
|
|
|
if (isInVideoMode()) {
|
|
|
|
recordedAudioBackground.setVisibility(GONE);
|
|
|
|
recordedAudioTimeTextView.setVisibility(GONE);
|
|
|
|
recordedAudioPlayButton.setVisibility(GONE);
|
|
|
|
recordedAudioSeekBar.setVisibility(GONE);
|
|
|
|
recordedAudioPanel.setAlpha(1.0f);
|
|
|
|
recordedAudioPanel.setVisibility(VISIBLE);
|
|
|
|
recordDeleteImageView.setProgress(0);
|
|
|
|
recordDeleteImageView.stopAnimation();
|
|
|
|
} else {
|
|
|
|
videoTimelineView.setVisibility(GONE);
|
|
|
|
recordedAudioBackground.setVisibility(VISIBLE);
|
|
|
|
recordedAudioTimeTextView.setVisibility(VISIBLE);
|
|
|
|
recordedAudioPlayButton.setVisibility(VISIBLE);
|
|
|
|
recordedAudioSeekBar.setVisibility(VISIBLE);
|
|
|
|
|
|
|
|
recordedAudioPanel.setAlpha(1.0f);
|
|
|
|
recordedAudioBackground.setAlpha(0f);
|
|
|
|
recordedAudioTimeTextView.setAlpha(0f);
|
|
|
|
recordedAudioPlayButton.setAlpha(0f);
|
|
|
|
recordedAudioSeekBar.setAlpha(0f);
|
|
|
|
recordedAudioPanel.setVisibility(VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
recordDeleteImageView.setAlpha(0f);
|
|
|
|
recordDeleteImageView.setScaleX(0f);
|
|
|
|
recordDeleteImageView.setScaleY(0f);
|
|
|
|
recordDeleteImageView.setProgress(0);
|
|
|
|
recordDeleteImageView.stopAnimation();
|
|
|
|
|
|
|
|
ValueAnimator transformToSeekbar = ValueAnimator.ofFloat(0, 1f);
|
|
|
|
transformToSeekbar.addUpdateListener(animation -> {
|
|
|
|
float value = (float) animation.getAnimatedValue();
|
|
|
|
if (!isInVideoMode()) {
|
|
|
|
recordCircle.setTransformToSeekbar(value);
|
|
|
|
seekBarWaveform.setWaveScaling(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
recordedAudioSeekBar.invalidate();
|
|
|
|
recordedAudioTimeTextView.setAlpha(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
recordedAudioPlayButton.setAlpha(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
recordedAudioPlayButton.setScaleX(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
recordedAudioPlayButton.setScaleY(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
recordedAudioSeekBar.setAlpha(recordCircle.getTransformToSeekbarProgressStep3());
|
|
|
|
} else {
|
|
|
|
recordCircle.setExitTransition(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
ViewGroup.LayoutParams oldLayoutParams = null;
|
|
|
|
ViewGroup parent = null;
|
|
|
|
if (!isInVideoMode()) {
|
|
|
|
parent = (ViewGroup) recordedAudioPanel.getParent();
|
|
|
|
oldLayoutParams = recordedAudioPanel.getLayoutParams();
|
|
|
|
parent.removeView(recordedAudioPanel);
|
|
|
|
|
|
|
|
FrameLayout.LayoutParams newLayoutParams = new FrameLayout.LayoutParams(parent.getMeasuredWidth(), AndroidUtilities.dp(48));
|
|
|
|
newLayoutParams.gravity = Gravity.BOTTOM;
|
|
|
|
sizeNotifierLayout.addView(recordedAudioPanel, newLayoutParams);
|
|
|
|
videoTimelineView.setVisibility(GONE);
|
|
|
|
} else {
|
|
|
|
videoTimelineView.setVisibility(VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
recordDeleteImageView.setAlpha(0f);
|
|
|
|
recordDeleteImageView.setScaleX(0f);
|
|
|
|
recordDeleteImageView.setScaleY(0f);
|
|
|
|
|
|
|
|
AnimatorSet iconsAnimator = new AnimatorSet();
|
|
|
|
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_Y, 1f),
|
|
|
|
ObjectAnimator.ofFloat(recordDeleteImageView, View.SCALE_X, 1f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 0),
|
|
|
|
ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 0)
|
|
|
|
);
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, isInVideoMode() ? 1 : 0),
|
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(videoSendButton, View.SCALE_Y, 1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, isInVideoMode() ? 0 : 1),
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(audioSendButton, View.SCALE_Y, 1)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
iconsAnimator.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
videoSendButton.setScaleX(1f);
|
|
|
|
videoSendButton.setScaleY(1f);
|
|
|
|
}
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
audioSendButton.setScaleX(1f);
|
|
|
|
audioSendButton.setScaleY(1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
iconsAnimator.setDuration(150);
|
|
|
|
iconsAnimator.setStartDelay(150);
|
|
|
|
|
|
|
|
AnimatorSet videoAdditionalAnimations = new AnimatorSet();
|
|
|
|
if (isInVideoMode()) {
|
|
|
|
recordedAudioTimeTextView.setAlpha(0);
|
|
|
|
videoTimelineView.setAlpha(0);
|
|
|
|
videoAdditionalAnimations.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordedAudioTimeTextView, View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(videoTimelineView, View.ALPHA, 1)
|
|
|
|
);
|
|
|
|
videoAdditionalAnimations.setDuration(150);
|
|
|
|
videoAdditionalAnimations.setStartDelay(430);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
transformToSeekbar.setDuration(isInVideoMode() ? 490 : 580);
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
iconsAnimator,
|
|
|
|
transformToSeekbar,
|
|
|
|
videoAdditionalAnimations
|
|
|
|
);
|
|
|
|
|
|
|
|
ViewGroup finalParent = parent;
|
|
|
|
ViewGroup.LayoutParams finalOldLayoutParams = oldLayoutParams;
|
|
|
|
runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (finalParent != null) {
|
|
|
|
sizeNotifierLayout.removeView(recordedAudioPanel);
|
|
|
|
finalParent.addView(recordedAudioPanel, finalOldLayoutParams);
|
|
|
|
}
|
|
|
|
recordedAudioPanel.setAlpha(1.0f);
|
|
|
|
recordedAudioBackground.setAlpha(1f);
|
|
|
|
recordedAudioTimeTextView.setAlpha(1f);
|
|
|
|
recordedAudioPlayButton.setAlpha(1f);
|
|
|
|
recordedAudioPlayButton.setScaleY(1f);
|
|
|
|
recordedAudioPlayButton.setScaleX(1f);
|
|
|
|
recordedAudioSeekBar.setAlpha(1f);
|
2020-07-26 10:03:38 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < 2; i++) {
|
|
|
|
emojiButton[i].setScaleY(0f);
|
|
|
|
emojiButton[i].setScaleX(0f);
|
|
|
|
emojiButton[i].setAlpha(0f);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (recordState == RECORD_STATE_CANCEL || recordState == RECORD_STATE_CANCEL_BY_GESTURE) {
|
|
|
|
if (videoSendButton != null && isInVideoMode()) {
|
|
|
|
videoSendButton.setVisibility(View.VISIBLE);
|
|
|
|
} else if (audioSendButton != null) {
|
|
|
|
audioSendButton.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
recordIsCanceled = true;
|
|
|
|
AnimatorSet iconsAnimator = new AnimatorSet();
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_X, 0)
|
|
|
|
);
|
|
|
|
|
|
|
|
AnimatorSet recordTimer = new AnimatorSet();
|
|
|
|
recordTimer.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.TRANSLATION_X, -AndroidUtilities.dp(20)),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.TRANSLATION_X, -AndroidUtilities.dp(20))
|
|
|
|
);
|
|
|
|
|
|
|
|
if (recordState != RECORD_STATE_CANCEL_BY_GESTURE) {
|
|
|
|
audioVideoButtonContainer.setScaleX(0);
|
|
|
|
audioVideoButtonContainer.setScaleY(0);
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
if (attachButton != null && attachButton.getVisibility() == View.VISIBLE) {
|
2020-03-30 14:00:09 +02:00
|
|
|
attachButton.setScaleX(0);
|
|
|
|
attachButton.setScaleY(0);
|
|
|
|
}
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
if (botButton != null && botButton.getVisibility() == View.VISIBLE) {
|
|
|
|
botButton.setScaleX(0);
|
|
|
|
botButton.setScaleY(0);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, "slideToCancelProgress", 1f),
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_X, 1f),
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.SCALE_Y, 1f),
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
if (attachLayout != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1f),
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (attachButton != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_X, 1f),
|
|
|
|
ObjectAnimator.ofFloat(attachButton, View.SCALE_Y, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (botButton != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(botButton, View.SCALE_X, 1f),
|
|
|
|
ObjectAnimator.ofFloat(botButton, View.SCALE_Y, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, isInVideoMode() ? 1 : 0));
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.SCALE_X, 1));
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.SCALE_Y, 1));
|
|
|
|
}
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, isInVideoMode() ? 0 : 1));
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.SCALE_X, 1));
|
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.SCALE_Y, 1));
|
|
|
|
}
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1f),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AnimatorSet icons2 = new AnimatorSet();
|
|
|
|
icons2.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1.0f)
|
|
|
|
);
|
|
|
|
if (attachLayout != null) {
|
|
|
|
icons2.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.TRANSLATION_X, 0),
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
icons2.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1f),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.TRANSLATION_X, 0)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
icons2.setDuration(150);
|
|
|
|
icons2.setStartDelay(110);
|
|
|
|
icons2.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
super.onAnimationEnd(animation);
|
|
|
|
if (audioSendButton != null) {
|
|
|
|
audioSendButton.setAlpha(isInVideoMode() ? 0 : 1f);
|
|
|
|
}
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
videoSendButton.setAlpha(isInVideoMode() ? 1f : 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
runningAnimationAudio.playTogether(icons2);
|
|
|
|
}
|
|
|
|
|
|
|
|
iconsAnimator.setDuration(150);
|
|
|
|
iconsAnimator.setStartDelay(700);
|
|
|
|
|
|
|
|
recordTimer.setDuration(200);
|
|
|
|
recordTimer.setStartDelay(200);
|
|
|
|
|
|
|
|
|
|
|
|
messageEditText.setTranslationX(0f);
|
|
|
|
ObjectAnimator messageEditTextAniamtor = ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 1);
|
|
|
|
messageEditTextAniamtor.setStartDelay(300);
|
|
|
|
messageEditTextAniamtor.setDuration(200);
|
|
|
|
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
iconsAnimator,
|
|
|
|
recordTimer,
|
|
|
|
messageEditTextAniamtor,
|
|
|
|
ObjectAnimator.ofFloat(recordCircle, "lockAnimatedTranslation", recordCircle.startTranslation).setDuration(200)
|
|
|
|
);
|
|
|
|
|
|
|
|
if (recordState == RECORD_STATE_CANCEL_BY_GESTURE) {
|
|
|
|
recordCircle.canceledByGesture();
|
|
|
|
ObjectAnimator cancel = ObjectAnimator.ofFloat(recordCircle, "slideToCancelProgress", 1f).setDuration(200);
|
|
|
|
cancel.setInterpolator(CubicBezierInterpolator.EASE_BOTH);
|
|
|
|
runningAnimationAudio.playTogether(cancel);
|
|
|
|
} else {
|
|
|
|
Animator recordCircleAnimator = ObjectAnimator.ofFloat(recordCircle, "exitTransition", 1.0f);
|
|
|
|
recordCircleAnimator.setDuration(360);
|
|
|
|
recordCircleAnimator.setStartDelay(490);
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
recordCircleAnimator
|
|
|
|
);
|
|
|
|
}
|
|
|
|
recordDot.playDeleteAnimation();
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (videoSendButton != null && isInVideoMode()) {
|
|
|
|
videoSendButton.setVisibility(View.VISIBLE);
|
|
|
|
} else if (audioSendButton != null) {
|
|
|
|
audioSendButton.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
AnimatorSet iconsAnimator = new AnimatorSet();
|
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1),
|
|
|
|
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_Y, 0),
|
|
|
|
ObjectAnimator.ofFloat(recordDot, View.SCALE_X, 0),
|
|
|
|
|
|
|
|
ObjectAnimator.ofFloat(audioVideoButtonContainer, View.ALPHA, 1.0f)
|
|
|
|
);
|
|
|
|
if (audioSendButton != null) {
|
2020-07-26 10:03:38 +02:00
|
|
|
audioSendButton.setScaleX(1f);
|
|
|
|
audioSendButton.setScaleY(1f);
|
2020-03-30 14:00:09 +02:00
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(audioSendButton, View.ALPHA, isInVideoMode() ? 0 : 1));
|
|
|
|
}
|
|
|
|
if (videoSendButton != null) {
|
2020-07-26 10:03:38 +02:00
|
|
|
videoSendButton.setScaleX(1f);
|
|
|
|
videoSendButton.setScaleY(1f);
|
2020-03-30 14:00:09 +02:00
|
|
|
iconsAnimator.playTogether(ObjectAnimator.ofFloat(videoSendButton, View.ALPHA, isInVideoMode() ? 1 : 0));
|
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
2021-03-19 11:25:58 +01:00
|
|
|
attachLayout.setTranslationX(0);
|
2020-03-30 14:00:09 +02:00
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(attachLayout, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (scheduledButton != null) {
|
2021-03-19 11:25:58 +01:00
|
|
|
scheduledButton.setTranslationX(0);
|
2020-03-30 14:00:09 +02:00
|
|
|
iconsAnimator.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, 1f)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
iconsAnimator.setDuration(150);
|
|
|
|
iconsAnimator.setStartDelay(200);
|
|
|
|
|
|
|
|
AnimatorSet recordTimer = new AnimatorSet();
|
|
|
|
recordTimer.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(recordTimerView, View.TRANSLATION_X, AndroidUtilities.dp(40)),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(slideText, View.TRANSLATION_X, AndroidUtilities.dp(40))
|
|
|
|
);
|
|
|
|
|
|
|
|
recordTimer.setDuration(150);
|
|
|
|
|
|
|
|
Animator recordCircleAnimator = ObjectAnimator.ofFloat(recordCircle, "exitTransition", 1.0f);
|
2021-03-19 11:25:58 +01:00
|
|
|
recordCircleAnimator.setDuration(messageTransitionIsRunning ? 220 : 360);
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
messageEditText.setTranslationX(0f);
|
|
|
|
ObjectAnimator messageEditTextAniamtor = ObjectAnimator.ofFloat(messageEditText, View.ALPHA, 1);
|
|
|
|
messageEditTextAniamtor.setStartDelay(150);
|
|
|
|
messageEditTextAniamtor.setDuration(200);
|
|
|
|
|
|
|
|
runningAnimationAudio.playTogether(
|
|
|
|
iconsAnimator,
|
|
|
|
recordTimer,
|
|
|
|
messageEditTextAniamtor,
|
|
|
|
recordCircleAnimator
|
|
|
|
);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
runningAnimationAudio.addListener(new AnimatorListenerAdapter() {
|
2014-11-17 03:44:57 +01:00
|
|
|
@Override
|
2016-06-24 12:27:15 +02:00
|
|
|
public void onAnimationEnd(Animator animator) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (animator.equals(runningAnimationAudio)) {
|
2016-04-22 15:49:00 +02:00
|
|
|
recordPanel.setVisibility(GONE);
|
|
|
|
recordCircle.setVisibility(GONE);
|
2017-07-08 18:32:04 +02:00
|
|
|
recordCircle.setSendButtonInvisible();
|
2015-10-29 18:10:07 +01:00
|
|
|
runningAnimationAudio = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (recordState != RECORD_STATE_PREPARING) {
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
|
|
|
recordedAudioBackground.setAlpha(1f);
|
2020-03-30 18:49:17 +02:00
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setTranslationX(0);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
slideText.setCancelToProgress(0f);
|
|
|
|
|
|
|
|
delegate.onAudioVideoInterfaceUpdated();
|
2014-11-17 23:04:31 +01:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
|
|
|
});
|
2014-11-17 23:04:31 +01:00
|
|
|
runningAnimationAudio.start();
|
2020-03-30 14:00:09 +02:00
|
|
|
recordTimerView.stop();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.onAudioVideoInterfaceUpdated();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
|
|
if (recordingAudioVideo) {
|
|
|
|
getParent().requestDisallowInterceptTouchEvent(true);
|
|
|
|
}
|
|
|
|
return super.onInterceptTouchEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDelegate(ChatActivityEnterViewDelegate chatActivityEnterViewDelegate) {
|
|
|
|
delegate = chatActivityEnterViewDelegate;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
|
2015-11-26 22:04:02 +01:00
|
|
|
public void setCommand(MessageObject messageObject, String command, boolean longPress, boolean username) {
|
2015-09-24 22:52:02 +02:00
|
|
|
if (command == null || getVisibility() != VISIBLE) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
if (longPress) {
|
|
|
|
String text = messageEditText.getText().toString();
|
2020-09-30 15:48:47 +02:00
|
|
|
TLRPC.User user = messageObject != null && (int) dialog_id < 0 ? accountInstance.getMessagesController().getUser(messageObject.messageOwner.from_id.user_id) : null;
|
2015-11-26 22:04:02 +01:00
|
|
|
if ((botCount != 1 || username) && user != null && user.bot && !command.contains("@")) {
|
|
|
|
text = String.format(Locale.US, "%s@%s", command, user.username) + " " + text.replaceFirst("^/[a-zA-Z@\\d_]{1,255}(\\s|$)", "");
|
|
|
|
} else {
|
|
|
|
text = command + " " + text.replaceFirst("^/[a-zA-Z@\\d_]{1,255}(\\s|$)", "");
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
ignoreTextChange = true;
|
|
|
|
messageEditText.setText(text);
|
|
|
|
messageEditText.setSelection(messageEditText.getText().length());
|
|
|
|
ignoreTextChange = false;
|
2016-03-06 02:49:31 +01:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onTextChanged(messageEditText.getText(), true);
|
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
if (!keyboardVisible && currentPopupContentType == -1) {
|
|
|
|
openKeyboard();
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer > 0 && !isInScheduleMode()) {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(slowModeButton, true, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
TLRPC.User user = messageObject != null && (int) dialog_id < 0 ? accountInstance.getMessagesController().getUser(messageObject.messageOwner.from_id.user_id) : null;
|
2015-11-26 22:04:02 +01:00
|
|
|
if ((botCount != 1 || username) && user != null && user.bot && !command.contains("@")) {
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(String.format(Locale.US, "%s@%s", command, user.username), dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0);
|
2015-10-29 18:10:07 +01:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(command, dialog_id, replyingMessageObject, getThreadMessage(), null, false, null, null, null, true, 0);
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
public void setEditingMessageObject(MessageObject messageObject, boolean caption) {
|
2017-07-08 18:32:04 +02:00
|
|
|
if (audioToSend != null || videoToSendMessageObject != null || editingMessageObject == messageObject) {
|
2016-03-06 02:49:31 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
editingMessageObject = messageObject;
|
|
|
|
editingCaption = caption;
|
2020-09-30 15:48:47 +02:00
|
|
|
CharSequence textToSetWithKeyboard;
|
2016-03-06 02:49:31 +01:00
|
|
|
if (editingMessageObject != null) {
|
2017-03-31 01:58:05 +02:00
|
|
|
if (doneButtonAnimation != null) {
|
|
|
|
doneButtonAnimation.cancel();
|
|
|
|
doneButtonAnimation = null;
|
|
|
|
}
|
|
|
|
doneButtonContainer.setVisibility(View.VISIBLE);
|
2020-12-23 08:48:30 +01:00
|
|
|
doneButtonImage.setScaleX(0.1f);
|
|
|
|
doneButtonImage.setScaleY(0.1f);
|
|
|
|
doneButtonImage.setAlpha(0.0f);
|
|
|
|
doneButtonImage.animate().alpha(1f).scaleX(1).scaleY(1).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
|
2017-03-31 01:58:05 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
CharSequence editingText;
|
2016-03-06 02:49:31 +01:00
|
|
|
if (caption) {
|
2020-12-23 08:48:30 +01:00
|
|
|
currentLimit = accountInstance.getMessagesController().maxCaptionLength;
|
2018-07-30 04:07:02 +02:00
|
|
|
editingText = editingMessageObject.caption;
|
2016-03-06 02:49:31 +01:00
|
|
|
} else {
|
2020-12-23 08:48:30 +01:00
|
|
|
currentLimit = accountInstance.getMessagesController().maxMessageLength;
|
2018-07-30 04:07:02 +02:00
|
|
|
editingText = editingMessageObject.messageText;
|
|
|
|
}
|
|
|
|
if (editingText != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
ArrayList<TLRPC.MessageEntity> entities = editingMessageObject.messageOwner.entities;
|
2019-07-18 15:01:39 +02:00
|
|
|
MediaDataController.sortEntities(entities);
|
2018-07-30 04:07:02 +02:00
|
|
|
SpannableStringBuilder stringBuilder = new SpannableStringBuilder(editingText);
|
2019-06-04 12:14:50 +02:00
|
|
|
Object[] spansToRemove = stringBuilder.getSpans(0, stringBuilder.length(), Object.class);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (spansToRemove != null && spansToRemove.length > 0) {
|
|
|
|
for (int a = 0; a < spansToRemove.length; a++) {
|
|
|
|
stringBuilder.removeSpan(spansToRemove[a]);
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
if (entities != null) {
|
|
|
|
try {
|
|
|
|
for (int a = 0; a < entities.size(); a++) {
|
|
|
|
TLRPC.MessageEntity entity = entities.get(a);
|
2019-07-18 15:01:39 +02:00
|
|
|
if (entity.offset + entity.length > stringBuilder.length()) {
|
2018-07-30 04:07:02 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (entity instanceof TLRPC.TL_inputMessageEntityMentionName) {
|
2019-07-18 15:01:39 +02:00
|
|
|
if (entity.offset + entity.length < stringBuilder.length() && stringBuilder.charAt(entity.offset + entity.length) == ' ') {
|
2018-07-30 04:07:02 +02:00
|
|
|
entity.length++;
|
2017-03-31 01:58:05 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
stringBuilder.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_inputMessageEntityMentionName) entity).user_id.user_id, 3), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityMentionName) {
|
2019-07-18 15:01:39 +02:00
|
|
|
if (entity.offset + entity.length < stringBuilder.length() && stringBuilder.charAt(entity.offset + entity.length) == ' ') {
|
2018-07-30 04:07:02 +02:00
|
|
|
entity.length++;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
stringBuilder.setSpan(new URLSpanUserMention("" + ((TLRPC.TL_messageEntityMentionName) entity).user_id, 3), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
2019-07-18 15:01:39 +02:00
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityCode || entity instanceof TLRPC.TL_messageEntityPre) {
|
|
|
|
TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
|
|
|
|
run.flags |= TextStyleSpan.FLAG_STYLE_MONO;
|
|
|
|
MediaDataController.addStyleToText(new TextStyleSpan(run), entity.offset, entity.offset + entity.length, stringBuilder, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityBold) {
|
2019-07-18 15:01:39 +02:00
|
|
|
TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
|
|
|
|
run.flags |= TextStyleSpan.FLAG_STYLE_BOLD;
|
|
|
|
MediaDataController.addStyleToText(new TextStyleSpan(run), entity.offset, entity.offset + entity.length, stringBuilder, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityItalic) {
|
2019-07-18 15:01:39 +02:00
|
|
|
TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
|
|
|
|
run.flags |= TextStyleSpan.FLAG_STYLE_ITALIC;
|
|
|
|
MediaDataController.addStyleToText(new TextStyleSpan(run), entity.offset, entity.offset + entity.length, stringBuilder, true);
|
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityStrike) {
|
|
|
|
TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
|
|
|
|
run.flags |= TextStyleSpan.FLAG_STYLE_STRIKE;
|
|
|
|
MediaDataController.addStyleToText(new TextStyleSpan(run), entity.offset, entity.offset + entity.length, stringBuilder, true);
|
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityUnderline) {
|
|
|
|
TextStyleSpan.TextStyleRun run = new TextStyleSpan.TextStyleRun();
|
|
|
|
run.flags |= TextStyleSpan.FLAG_STYLE_UNDERLINE;
|
|
|
|
MediaDataController.addStyleToText(new TextStyleSpan(run), entity.offset, entity.offset + entity.length, stringBuilder, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (entity instanceof TLRPC.TL_messageEntityTextUrl) {
|
2019-07-18 15:01:39 +02:00
|
|
|
stringBuilder.setSpan(new URLSpanReplacement(entity.url), entity.offset, entity.offset + entity.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
2016-05-25 23:49:47 +02:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
textToSetWithKeyboard = Emoji.replaceEmoji(new SpannableStringBuilder(stringBuilder), messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
textToSetWithKeyboard = "";
|
|
|
|
}
|
|
|
|
if (!keyboardVisible) {
|
|
|
|
AndroidUtilities.runOnUIThread(setTextFieldRunnable = () -> {
|
|
|
|
setFieldText(textToSetWithKeyboard);
|
|
|
|
setTextFieldRunnable = null;
|
|
|
|
}, 200);
|
|
|
|
} else {
|
|
|
|
if (setTextFieldRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(setTextFieldRunnable);
|
|
|
|
setTextFieldRunnable = null;
|
|
|
|
}
|
|
|
|
setFieldText(textToSetWithKeyboard);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2021-03-19 11:25:58 +01:00
|
|
|
messageEditText.requestFocus();
|
2016-03-06 02:49:31 +01:00
|
|
|
openKeyboard();
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) messageEditText.getLayoutParams();
|
|
|
|
layoutParams.rightMargin = AndroidUtilities.dp(4);
|
|
|
|
messageEditText.setLayoutParams(layoutParams);
|
|
|
|
sendButton.setVisibility(GONE);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(GONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
attachLayout.setVisibility(GONE);
|
2016-03-06 02:49:31 +01:00
|
|
|
sendButtonContainer.setVisibility(GONE);
|
2019-09-10 12:56:11 +02:00
|
|
|
if (scheduledButton != null) {
|
|
|
|
scheduledButton.setVisibility(GONE);
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (setTextFieldRunnable != null) {
|
|
|
|
AndroidUtilities.cancelRunOnUIThread(setTextFieldRunnable);
|
|
|
|
setTextFieldRunnable = null;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
doneButtonContainer.setVisibility(View.GONE);
|
2020-12-23 08:48:30 +01:00
|
|
|
currentLimit = -1;
|
2016-05-25 23:49:47 +02:00
|
|
|
delegate.onMessageEditEnd(false);
|
2016-03-06 02:49:31 +01:00
|
|
|
sendButtonContainer.setVisibility(VISIBLE);
|
2016-06-24 12:27:15 +02:00
|
|
|
cancelBotButton.setScaleX(0.1f);
|
|
|
|
cancelBotButton.setScaleY(0.1f);
|
|
|
|
cancelBotButton.setAlpha(0.0f);
|
2016-04-22 15:49:00 +02:00
|
|
|
cancelBotButton.setVisibility(GONE);
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer > 0 && !isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (slowModeTimer == Integer.MAX_VALUE) {
|
|
|
|
sendButton.setScaleX(1.0f);
|
|
|
|
sendButton.setScaleY(1.0f);
|
|
|
|
sendButton.setAlpha(1.0f);
|
|
|
|
sendButton.setVisibility(VISIBLE);
|
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2019-08-22 01:53:26 +02:00
|
|
|
} else {
|
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
slowModeButton.setScaleX(1.0f);
|
|
|
|
slowModeButton.setScaleY(1.0f);
|
|
|
|
slowModeButton.setAlpha(1.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(true);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
|
|
|
attachLayout.setScaleX(0.01f);
|
|
|
|
attachLayout.setAlpha(0.0f);
|
|
|
|
attachLayout.setVisibility(GONE);
|
|
|
|
audioVideoButtonContainer.setScaleX(0.1f);
|
|
|
|
audioVideoButtonContainer.setScaleY(0.1f);
|
|
|
|
audioVideoButtonContainer.setAlpha(0.0f);
|
|
|
|
audioVideoButtonContainer.setVisibility(GONE);
|
|
|
|
} else {
|
|
|
|
sendButton.setScaleX(0.1f);
|
|
|
|
sendButton.setScaleY(0.1f);
|
|
|
|
sendButton.setAlpha(0.0f);
|
|
|
|
sendButton.setVisibility(GONE);
|
|
|
|
slowModeButton.setScaleX(0.1f);
|
|
|
|
slowModeButton.setScaleY(0.1f);
|
|
|
|
slowModeButton.setAlpha(0.0f);
|
2020-01-03 16:45:22 +01:00
|
|
|
setSlowModeButtonVisible(false);
|
2019-08-22 01:53:26 +02:00
|
|
|
attachLayout.setScaleX(1.0f);
|
|
|
|
attachLayout.setAlpha(1.0f);
|
|
|
|
attachLayout.setVisibility(VISIBLE);
|
|
|
|
audioVideoButtonContainer.setScaleX(1.0f);
|
|
|
|
audioVideoButtonContainer.setScaleY(1.0f);
|
|
|
|
audioVideoButtonContainer.setAlpha(1.0f);
|
|
|
|
audioVideoButtonContainer.setVisibility(VISIBLE);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (scheduledButton.getTag() != null) {
|
|
|
|
scheduledButton.setScaleX(1.0f);
|
|
|
|
scheduledButton.setScaleY(1.0f);
|
|
|
|
scheduledButton.setAlpha(1.0f);
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
messageEditText.setText("");
|
2016-10-11 13:57:01 +02:00
|
|
|
if (getVisibility() == VISIBLE) {
|
|
|
|
delegate.onAttachButtonShow();
|
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
updateFieldRight(1);
|
|
|
|
}
|
2021-01-28 15:15:51 +01:00
|
|
|
updateFieldHint(false);
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
public ImageView getAttachButton() {
|
|
|
|
return attachButton;
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
public View getSendButton() {
|
|
|
|
return sendButton.getVisibility() == VISIBLE ? sendButton : audioVideoButtonContainer;
|
|
|
|
}
|
|
|
|
|
2021-03-19 11:25:58 +01:00
|
|
|
public View getAudioVideoButtonContainer() {
|
|
|
|
return audioVideoButtonContainer;
|
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
public EmojiView getEmojiView() {
|
|
|
|
return emojiView;
|
|
|
|
}
|
|
|
|
|
2020-06-04 18:47:15 +02:00
|
|
|
public TrendingStickersAlert getTrendingStickersAlert() {
|
|
|
|
return trendingStickersAlert;
|
|
|
|
}
|
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
public void updateColors() {
|
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.updateColors();
|
|
|
|
}
|
|
|
|
if (sendPopupLayout != null) {
|
|
|
|
for (int a = 0, count = sendPopupLayout.getChildCount(); a < count; a++) {
|
|
|
|
final View view = sendPopupLayout.getChildAt(a);
|
|
|
|
if (view instanceof ActionBarMenuSubItem) {
|
|
|
|
final ActionBarMenuSubItem item = (ActionBarMenuSubItem) view;
|
|
|
|
item.setColors(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon));
|
|
|
|
item.setSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sendPopupLayout.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground));
|
|
|
|
if (sendPopupWindow != null && sendPopupWindow.isShowing()) {
|
|
|
|
sendPopupLayout.invalidate();
|
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
updateRecordedDeleteIconColors();
|
|
|
|
recordCircle.updateColors();
|
|
|
|
recordDot.updateColors();
|
|
|
|
slideText.updateColors();
|
|
|
|
recordTimerView.updateColors();
|
|
|
|
videoTimelineView.updateColors();
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
if (captionLimitView != null && messageEditText != null) {
|
|
|
|
if (codePointCount - currentLimit < 0) {
|
|
|
|
captionLimitView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText));
|
|
|
|
} else {
|
|
|
|
captionLimitView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int color = Theme.getColor(Theme.key_chat_messagePanelVoicePressed);
|
|
|
|
int defaultAlpha = Color.alpha(color);
|
|
|
|
doneCheckDrawable.setColorFilter(new PorterDuffColorFilter(ColorUtils.setAlphaComponent(color, (int) (defaultAlpha * (0.58f + 0.42f * doneButtonEnabledProgress))), PorterDuff.Mode.MULTIPLY));
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateRecordedDeleteIconColors() {
|
|
|
|
int dotColor = Theme.getColor(Theme.key_chat_recordedVoiceDot);
|
|
|
|
int background = Theme.getColor(Theme.key_chat_messagePanelBackground);
|
|
|
|
int greyColor = Theme.getColor(Theme.key_chat_messagePanelVoiceDelete);
|
|
|
|
|
|
|
|
recordDeleteImageView.setLayerColor("Cup Red.**", dotColor);
|
|
|
|
recordDeleteImageView.setLayerColor("Box Red.**", dotColor);
|
|
|
|
recordDeleteImageView.setLayerColor("Cup Grey.**", greyColor);
|
|
|
|
recordDeleteImageView.setLayerColor("Box Grey.**", greyColor);
|
|
|
|
|
|
|
|
recordDeleteImageView.setLayerColor("Line 1.**", background);
|
|
|
|
recordDeleteImageView.setLayerColor("Line 2.**", background);
|
|
|
|
recordDeleteImageView.setLayerColor("Line 3.**", background);
|
2019-12-31 14:08:08 +01:00
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
public void setFieldText(CharSequence text) {
|
2019-05-14 14:08:05 +02:00
|
|
|
setFieldText(text, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFieldText(CharSequence text, boolean ignoreChange) {
|
2015-03-26 18:34:47 +01:00
|
|
|
if (messageEditText == null) {
|
2014-11-19 11:32:27 +01:00
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
ignoreTextChange = ignoreChange;
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setText(text);
|
|
|
|
messageEditText.setSelection(messageEditText.getText().length());
|
2014-07-03 00:39:05 +02:00
|
|
|
ignoreTextChange = false;
|
2019-07-18 15:01:39 +02:00
|
|
|
if (ignoreChange && delegate != null) {
|
2015-04-09 20:00:14 +02:00
|
|
|
delegate.onTextChanged(messageEditText.getText(), true);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
public void setSelection(int start) {
|
|
|
|
if (messageEditText == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
messageEditText.setSelection(start, messageEditText.length());
|
|
|
|
}
|
|
|
|
|
2015-03-19 00:09:45 +01:00
|
|
|
public int getCursorPosition() {
|
2015-03-26 18:34:47 +01:00
|
|
|
if (messageEditText == null) {
|
2015-03-19 00:09:45 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-03-26 18:34:47 +01:00
|
|
|
return messageEditText.getSelectionStart();
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
public int getSelectionLength() {
|
|
|
|
if (messageEditText == null) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
return messageEditText.getSelectionEnd() - messageEditText.getSelectionStart();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
public void replaceWithText(int start, int len, CharSequence text, boolean parseEmoji) {
|
2015-03-19 00:09:45 +01:00
|
|
|
try {
|
2016-05-25 23:49:47 +02:00
|
|
|
SpannableStringBuilder builder = new SpannableStringBuilder(messageEditText.getText());
|
2015-03-19 00:09:45 +01:00
|
|
|
builder.replace(start, start + len, text);
|
2017-12-08 18:35:59 +01:00
|
|
|
if (parseEmoji) {
|
|
|
|
Emoji.replaceEmoji(builder, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
|
|
|
}
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.setText(builder);
|
|
|
|
messageEditText.setSelection(start + text.length());
|
2015-03-19 00:09:45 +01:00
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2015-03-19 00:09:45 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
public void setFieldFocused() {
|
2020-03-30 14:00:09 +02:00
|
|
|
AccessibilityManager am = (AccessibilityManager) parentActivity.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
2019-05-14 14:08:05 +02:00
|
|
|
if (messageEditText != null && !am.isTouchExplorationEnabled()) {
|
2016-06-24 12:27:15 +02:00
|
|
|
try {
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2016-06-24 12:27:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
public void setFieldFocused(boolean focus) {
|
2019-05-14 14:08:05 +02:00
|
|
|
AccessibilityManager am = (AccessibilityManager) parentActivity.getSystemService(Context.ACCESSIBILITY_SERVICE);
|
|
|
|
if (messageEditText == null || am.isTouchExplorationEnabled()) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (focus) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType == 0 && !messageEditText.isFocused()) {
|
2019-07-18 15:01:39 +02:00
|
|
|
AndroidUtilities.runOnUIThread(focusRunnable = () -> {
|
|
|
|
focusRunnable = null;
|
2018-08-27 10:33:11 +02:00
|
|
|
boolean allowFocus;
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
if (parentActivity instanceof LaunchActivity) {
|
|
|
|
LaunchActivity launchActivity = (LaunchActivity) parentActivity;
|
2020-10-30 11:26:29 +01:00
|
|
|
View layout = launchActivity.getLayersActionBarLayout();
|
|
|
|
allowFocus = layout == null || layout.getVisibility() != View.VISIBLE;
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
|
|
|
allowFocus = true;
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
allowFocus = true;
|
|
|
|
}
|
2019-07-18 15:01:39 +02:00
|
|
|
if (!isPaused && allowFocus && messageEditText != null) {
|
2018-08-27 10:33:11 +02:00
|
|
|
try {
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 600);
|
|
|
|
}
|
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (messageEditText != null && messageEditText.isFocused() && (!keyboardVisible || isPaused)) {
|
2015-03-26 18:34:47 +01:00
|
|
|
messageEditText.clearFocus();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasText() {
|
2015-03-26 18:34:47 +01:00
|
|
|
return messageEditText != null && messageEditText.length() > 0;
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public EditTextCaption getEditField() {
|
|
|
|
return messageEditText;
|
|
|
|
}
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
public CharSequence getFieldText() {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (hasText()) {
|
2016-06-24 12:27:15 +02:00
|
|
|
return messageEditText.getText();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
public void updateScheduleButton(boolean animated) {
|
|
|
|
boolean notifyVisible = false;
|
|
|
|
if ((int) dialog_id < 0) {
|
|
|
|
TLRPC.Chat currentChat = accountInstance.getMessagesController().getChat(-(int) dialog_id);
|
|
|
|
silent = MessagesController.getNotificationsSettings(currentAccount).getBoolean("silent_" + dialog_id, false);
|
|
|
|
canWriteToChannel = ChatObject.isChannel(currentChat) && (currentChat.creator || currentChat.admin_rights != null && currentChat.admin_rights.post_messages) && !currentChat.megagroup;
|
|
|
|
if (notifyButton != null) {
|
|
|
|
notifyVisible = canWriteToChannel;
|
2021-01-28 15:15:51 +01:00
|
|
|
if (notifySilentDrawable == null) {
|
|
|
|
notifySilentDrawable = new CrossOutDrawable(getContext(), R.drawable.input_notify_on, Theme.key_chat_messagePanelIcons);
|
|
|
|
}
|
|
|
|
notifySilentDrawable.setCrossOut(silent, false);
|
|
|
|
notifyButton.setImageDrawable(notifySilentDrawable);
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
|
|
|
updateFieldRight(attachLayout.getVisibility() == VISIBLE ? 1 : 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean hasScheduled = delegate != null && !isInScheduleMode() && delegate.hasScheduledMessages();
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean visible = hasScheduled && !scheduleButtonHidden && !recordingAudioVideo;
|
2019-09-10 12:56:11 +02:00
|
|
|
if (scheduledButton != null) {
|
|
|
|
if (scheduledButton.getTag() != null && visible || scheduledButton.getTag() == null && !visible) {
|
|
|
|
if (notifyButton != null) {
|
|
|
|
int newVisibility = !hasScheduled && notifyVisible && scheduledButton.getVisibility() != VISIBLE ? VISIBLE : GONE;
|
|
|
|
if (newVisibility != notifyButton.getVisibility()) {
|
|
|
|
notifyButton.setVisibility(newVisibility);
|
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setPivotX(AndroidUtilities.dp((botButton == null || botButton.getVisibility() == GONE) && (notifyButton == null || notifyButton.getVisibility() == GONE) ? 48 : 96));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
scheduledButton.setTag(visible ? 1 : null);
|
|
|
|
}
|
|
|
|
if (scheduledButtonAnimation != null) {
|
|
|
|
scheduledButtonAnimation.cancel();
|
|
|
|
scheduledButtonAnimation = null;
|
|
|
|
}
|
|
|
|
if (!animated || notifyVisible) {
|
|
|
|
if (scheduledButton != null) {
|
|
|
|
scheduledButton.setVisibility(visible ? VISIBLE : GONE);
|
|
|
|
scheduledButton.setAlpha(visible ? 1.0f : 0.0f);
|
|
|
|
scheduledButton.setScaleX(visible ? 1.0f : 0.1f);
|
|
|
|
scheduledButton.setScaleY(visible ? 1.0f : 0.1f);
|
2020-10-30 11:26:29 +01:00
|
|
|
if (notifyButton != null) {
|
|
|
|
notifyButton.setVisibility(notifyVisible && scheduledButton.getVisibility() != VISIBLE ? VISIBLE : GONE);
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
2020-10-30 11:26:29 +01:00
|
|
|
} else if (scheduledButton != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (visible) {
|
|
|
|
scheduledButton.setVisibility(VISIBLE);
|
|
|
|
}
|
|
|
|
scheduledButton.setPivotX(AndroidUtilities.dp(24));
|
|
|
|
scheduledButtonAnimation = new AnimatorSet();
|
|
|
|
scheduledButtonAnimation.playTogether(ObjectAnimator.ofFloat(scheduledButton, View.ALPHA, visible ? 1.0f : 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.SCALE_X, visible ? 1.0f : 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(scheduledButton, View.SCALE_Y, visible ? 1.0f : 0.1f));
|
|
|
|
scheduledButtonAnimation.setDuration(180);
|
|
|
|
scheduledButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
scheduledButtonAnimation = null;
|
|
|
|
if (!visible) {
|
|
|
|
scheduledButton.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
scheduledButtonAnimation.start();
|
|
|
|
}
|
|
|
|
if (attachLayout != null) {
|
|
|
|
attachLayout.setPivotX(AndroidUtilities.dp((botButton == null || botButton.getVisibility() == GONE) && (notifyButton == null || notifyButton.getVisibility() == GONE) ? 48 : 96));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
private void updateBotButton() {
|
|
|
|
if (botButton == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (hasBotCommands || botReplyMarkup != null) {
|
|
|
|
if (botButton.getVisibility() != VISIBLE) {
|
|
|
|
botButton.setVisibility(VISIBLE);
|
|
|
|
}
|
|
|
|
if (botReplyMarkup != null) {
|
|
|
|
if (isPopupShowing() && currentPopupContentType == 1) {
|
2020-09-30 15:48:47 +02:00
|
|
|
botButtonDrawablel.setIcon(R.drawable.input_keyboard, true);
|
2019-05-14 14:08:05 +02:00
|
|
|
botButton.setContentDescription(LocaleController.getString("AccDescrShowKeyboard", R.string.AccDescrShowKeyboard));
|
2015-06-29 19:12:11 +02:00
|
|
|
} else {
|
2020-12-23 08:48:30 +01:00
|
|
|
botButtonDrawablel.setIcon(R.drawable.input_bot2, true);
|
2019-05-14 14:08:05 +02:00
|
|
|
botButton.setContentDescription(LocaleController.getString("AccDescrBotKeyboard", R.string.AccDescrBotKeyboard));
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-12-23 08:48:30 +01:00
|
|
|
botButtonDrawablel.setIcon(R.drawable.input_bot1, true);
|
2019-05-14 14:08:05 +02:00
|
|
|
botButton.setContentDescription(LocaleController.getString("AccDescrBotCommands", R.string.AccDescrBotCommands));
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
botButton.setVisibility(GONE);
|
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
updateFieldRight(2);
|
2017-03-31 01:58:05 +02:00
|
|
|
attachLayout.setPivotX(AndroidUtilities.dp((botButton == null || botButton.getVisibility() == GONE) && (notifyButton == null || notifyButton.getVisibility() == GONE) ? 48 : 96));
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
public boolean isRtlText() {
|
|
|
|
try {
|
|
|
|
return messageEditText.getLayout().getParagraphDirection(0) == Layout.DIR_RIGHT_TO_LEFT;
|
|
|
|
} catch (Throwable ignore) {
|
|
|
|
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public void setBotsCount(int count, boolean hasCommands) {
|
|
|
|
botCount = count;
|
|
|
|
if (hasBotCommands != hasCommands) {
|
|
|
|
hasBotCommands = hasCommands;
|
|
|
|
updateBotButton();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setButtons(MessageObject messageObject) {
|
|
|
|
setButtons(messageObject, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setButtons(MessageObject messageObject, boolean openKeyboard) {
|
|
|
|
if (replyingMessageObject != null && replyingMessageObject == botButtonsMessageObject && replyingMessageObject != messageObject) {
|
|
|
|
botMessageObject = messageObject;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (botButton == null || botButtonsMessageObject != null && botButtonsMessageObject == messageObject || botButtonsMessageObject == null && messageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (botKeyboardView == null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
botKeyboardView = new BotKeyboardView(parentActivity) {
|
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (panelAnimation != null && animatingContentType == 1) {
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.bottomPanelTranslationYChanged(translationY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2015-06-29 19:12:11 +02:00
|
|
|
botKeyboardView.setVisibility(GONE);
|
2020-01-03 16:45:22 +01:00
|
|
|
botKeyboardViewVisible = false;
|
2018-08-27 10:33:11 +02:00
|
|
|
botKeyboardView.setDelegate(button -> {
|
|
|
|
MessageObject object = replyingMessageObject != null ? replyingMessageObject : ((int) dialog_id < 0 ? botButtonsMessageObject : null);
|
2020-01-23 07:15:40 +01:00
|
|
|
boolean open = didPressedBotButton(button, object, replyingMessageObject != null ? replyingMessageObject : botButtonsMessageObject);
|
2018-08-27 10:33:11 +02:00
|
|
|
if (replyingMessageObject != null) {
|
|
|
|
openKeyboardInternal();
|
|
|
|
setButtons(botMessageObject, false);
|
2020-10-02 23:48:16 +02:00
|
|
|
} else if (botButtonsMessageObject != null && botButtonsMessageObject.messageOwner.reply_markup.single_use) {
|
2020-01-23 07:15:40 +01:00
|
|
|
if (open) {
|
|
|
|
openKeyboardInternal();
|
|
|
|
} else {
|
|
|
|
showPopup(0, 0);
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
|
|
|
|
preferences.edit().putInt("answered_" + dialog_id, botButtonsMessageObject.getId()).commit();
|
|
|
|
}
|
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(null, true, 0);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
});
|
2019-08-22 01:53:26 +02:00
|
|
|
sizeNotifierLayout.addView(botKeyboardView, sizeNotifierLayout.getChildCount() - 1);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
botButtonsMessageObject = messageObject;
|
|
|
|
botReplyMarkup = messageObject != null && messageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyKeyboardMarkup ? (TLRPC.TL_replyKeyboardMarkup) messageObject.messageOwner.reply_markup : null;
|
|
|
|
|
|
|
|
botKeyboardView.setPanelHeight(AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight);
|
2020-09-30 15:48:47 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
if (botReplyMarkup != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
|
2015-09-02 00:14:21 +02:00
|
|
|
boolean keyboardHidden = preferences.getInt("hidekeyboard_" + dialog_id, 0) == messageObject.getId();
|
2019-05-14 14:08:05 +02:00
|
|
|
boolean showPopup = true;
|
2015-11-26 22:04:02 +01:00
|
|
|
if (botButtonsMessageObject != replyingMessageObject && botReplyMarkup.single_use) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (preferences.getInt("answered_" + dialog_id, 0) == messageObject.getId()) {
|
2019-05-14 14:08:05 +02:00
|
|
|
showPopup = false;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (showPopup && !keyboardHidden && messageEditText.length() == 0 && !isPopupShowing()) {
|
2015-06-29 19:12:11 +02:00
|
|
|
showPopup(1, 1);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
botKeyboardView.setButtons(botReplyMarkup);
|
2015-06-29 19:12:11 +02:00
|
|
|
} else {
|
|
|
|
if (isPopupShowing() && currentPopupContentType == 1) {
|
|
|
|
if (openKeyboard) {
|
2020-09-30 15:48:47 +02:00
|
|
|
clearBotButtonsOnKeyboardOpen = true;
|
2015-06-29 19:12:11 +02:00
|
|
|
openKeyboardInternal();
|
|
|
|
} else {
|
|
|
|
showPopup(0, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateBotButton();
|
|
|
|
}
|
|
|
|
|
2020-01-23 07:15:40 +01:00
|
|
|
public boolean didPressedBotButton(final TLRPC.KeyboardButton button, final MessageObject replyMessageObject, final MessageObject messageObject) {
|
2016-04-22 15:49:00 +02:00
|
|
|
if (button == null || messageObject == null) {
|
2020-01-23 07:15:40 +01:00
|
|
|
return false;
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
if (button instanceof TLRPC.TL_keyboardButton) {
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendMessage(button.text, dialog_id, replyMessageObject, getThreadMessage(), null, false, null, null, null, true, 0);
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonUrl) {
|
2020-06-04 18:47:15 +02:00
|
|
|
AlertsCreator.showOpenUrlAlert(parentFragment, button.url, false, true);
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonRequestPhone) {
|
2019-07-18 15:01:39 +02:00
|
|
|
parentFragment.shareMyContact(2, messageObject);
|
2020-01-23 07:15:40 +01:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonRequestPoll) {
|
|
|
|
parentFragment.openPollCreate((button.flags & 1) != 0 ? button.quiz : null);
|
|
|
|
return false;
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonRequestGeoLocation) {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
|
|
|
builder.setTitle(LocaleController.getString("ShareYouLocationTitle", R.string.ShareYouLocationTitle));
|
|
|
|
builder.setMessage(LocaleController.getString("ShareYouLocationInfo", R.string.ShareYouLocationInfo));
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && parentActivity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
parentActivity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, 2);
|
|
|
|
pendingMessageObject = messageObject;
|
|
|
|
pendingLocationButton = button;
|
|
|
|
return;
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendCurrentLocation(messageObject, button);
|
2016-04-22 15:49:00 +02:00
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
parentFragment.showDialog(builder.create());
|
2019-06-04 12:14:50 +02:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonCallback || button instanceof TLRPC.TL_keyboardButtonGame || button instanceof TLRPC.TL_keyboardButtonBuy || button instanceof TLRPC.TL_keyboardButtonUrlAuth) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendCallback(true, messageObject, button, parentFragment);
|
2016-04-22 15:49:00 +02:00
|
|
|
} else if (button instanceof TLRPC.TL_keyboardButtonSwitchInline) {
|
|
|
|
if (parentFragment.processSwitchButton((TLRPC.TL_keyboardButtonSwitchInline) button)) {
|
2020-01-23 07:15:40 +01:00
|
|
|
return true;
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (button.same_peer) {
|
2020-09-30 15:48:47 +02:00
|
|
|
int uid = messageObject.messageOwner.from_id.user_id;
|
2016-10-11 13:57:01 +02:00
|
|
|
if (messageObject.messageOwner.via_bot_id != 0) {
|
|
|
|
uid = messageObject.messageOwner.via_bot_id;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.User user = accountInstance.getMessagesController().getUser(uid);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (user == null) {
|
2020-01-23 07:15:40 +01:00
|
|
|
return true;
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
setFieldText("@" + user.username + " " + button.query);
|
|
|
|
} else {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
args.putInt("dialogsType", 1);
|
|
|
|
DialogsActivity fragment = new DialogsActivity(args);
|
2018-08-27 10:33:11 +02:00
|
|
|
fragment.setDelegate((fragment1, dids, message, param) -> {
|
2020-09-30 15:48:47 +02:00
|
|
|
int uid = messageObject.messageOwner.from_id.user_id;
|
2018-08-27 10:33:11 +02:00
|
|
|
if (messageObject.messageOwner.via_bot_id != 0) {
|
|
|
|
uid = messageObject.messageOwner.via_bot_id;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
TLRPC.User user = accountInstance.getMessagesController().getUser(uid);
|
2018-08-27 10:33:11 +02:00
|
|
|
if (user == null) {
|
|
|
|
fragment1.finishFragment();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
long did = dids.get(0);
|
2020-09-30 15:48:47 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).saveDraft(did, 0, "@" + user.username + " " + button.query, null, null, true);
|
2018-08-27 10:33:11 +02:00
|
|
|
if (did != dialog_id) {
|
|
|
|
int lower_part = (int) did;
|
|
|
|
if (lower_part != 0) {
|
|
|
|
Bundle args1 = new Bundle();
|
|
|
|
if (lower_part > 0) {
|
|
|
|
args1.putInt("user_id", lower_part);
|
2020-10-30 11:26:29 +01:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
args1.putInt("chat_id", -lower_part);
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
if (!accountInstance.getMessagesController().checkCanOpenChat(args1, fragment1)) {
|
2018-08-27 10:33:11 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ChatActivity chatActivity = new ChatActivity(args1);
|
|
|
|
if (parentFragment.presentFragment(chatActivity, true)) {
|
|
|
|
if (!AndroidUtilities.isTablet()) {
|
|
|
|
parentFragment.removeSelfFromStack();
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
fragment1.finishFragment();
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
fragment1.finishFragment();
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
} else {
|
|
|
|
fragment1.finishFragment();
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
});
|
|
|
|
parentFragment.presentFragment(fragment);
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
2020-01-23 07:15:40 +01:00
|
|
|
return true;
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public boolean isPopupView(View view) {
|
|
|
|
return view == botKeyboardView || view == emojiView;
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
public boolean isRecordCircle(View view) {
|
|
|
|
return view == recordCircle;
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
private void createEmojiView() {
|
|
|
|
if (emojiView != null) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
emojiView = new EmojiView(allowStickers, allowGifs, parentActivity, true, info) {
|
|
|
|
@Override
|
|
|
|
public void setTranslationY(float translationY) {
|
|
|
|
super.setTranslationY(translationY);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (panelAnimation != null && animatingContentType == 0) {
|
2020-03-30 14:00:09 +02:00
|
|
|
delegate.bottomPanelTranslationYChanged(translationY);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2016-01-11 18:19:48 +01:00
|
|
|
emojiView.setVisibility(GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
emojiView.setDelegate(new EmojiView.EmojiViewDelegate() {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
@Override
|
2016-01-11 18:19:48 +01:00
|
|
|
public boolean onBackspace() {
|
|
|
|
if (messageEditText.length() == 0) {
|
|
|
|
return false;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
messageEditText.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
|
|
|
|
return true;
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
2016-01-11 18:19:48 +01:00
|
|
|
public void onEmojiSelected(String symbol) {
|
|
|
|
int i = messageEditText.getSelectionEnd();
|
|
|
|
if (i < 0) {
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
innerTextChange = 2;
|
|
|
|
CharSequence localCharSequence = Emoji.replaceEmoji(symbol, messageEditText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(20), false);
|
|
|
|
messageEditText.setText(messageEditText.getText().insert(i, localCharSequence));
|
|
|
|
int j = i + localCharSequence.length();
|
|
|
|
messageEditText.setSelection(j, j);
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
FileLog.e(e);
|
2016-01-11 18:19:48 +01:00
|
|
|
} finally {
|
|
|
|
innerTextChange = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
2020-12-23 08:48:30 +01:00
|
|
|
public void onStickerSelected(View view, TLRPC.Document sticker, String query, Object parent, boolean notify, int scheduleDate) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (trendingStickersAlert != null) {
|
|
|
|
trendingStickersAlert.dismiss();
|
|
|
|
trendingStickersAlert = null;
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (slowModeTimer > 0 && !isInScheduleMode()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(view != null ? view : slowModeButton, true, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (stickersExpanded) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
emojiView.closeSearch(true, MessageObject.getStickerSetId(sticker));
|
|
|
|
emojiView.hideSearchKeyboard();
|
|
|
|
}
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(false, true, false);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
ChatActivityEnterView.this.onStickerSelected(sticker, query, parent, false, notify, scheduleDate);
|
2019-01-23 18:03:33 +01:00
|
|
|
if ((int) dialog_id == 0 && MessageObject.isGifDocument(sticker)) {
|
2019-08-22 01:53:26 +02:00
|
|
|
accountInstance.getMessagesController().saveGif(parent, sticker);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
2015-12-09 19:27:52 +01:00
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
@Override
|
|
|
|
public void onStickersSettingsClick() {
|
|
|
|
if (parentFragment != null) {
|
2019-07-18 15:01:39 +02:00
|
|
|
parentFragment.presentFragment(new StickersActivity(MediaDataController.TYPE_IMAGE));
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-12-23 08:48:30 +01:00
|
|
|
public void onGifSelected(View view, Object gif, String query, Object parent, boolean notify, int scheduleDate) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (isInScheduleMode() && scheduleDate == 0) {
|
2020-12-23 08:48:30 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (n, s) -> onGifSelected(view, gif, query, parent, n, s));
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
|
|
|
if (slowModeTimer > 0 && !isInScheduleMode()) {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(view != null ? view : slowModeButton, true, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
return;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (stickersExpanded) {
|
|
|
|
if (searchingType != 0) {
|
|
|
|
emojiView.hideSearchKeyboard();
|
|
|
|
}
|
|
|
|
setStickersExpanded(false, true, false);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (gif instanceof TLRPC.Document) {
|
|
|
|
TLRPC.Document document = (TLRPC.Document) gif;
|
2020-12-23 08:48:30 +01:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendSticker(document, query, dialog_id, replyingMessageObject, getThreadMessage(), parent, notify, scheduleDate);
|
2019-09-10 12:56:11 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).addRecentGif(document, (int) (System.currentTimeMillis() / 1000));
|
2019-05-14 14:08:05 +02:00
|
|
|
if ((int) dialog_id == 0) {
|
2019-09-10 12:56:11 +02:00
|
|
|
accountInstance.getMessagesController().saveGif(parent, document);
|
2015-12-09 19:27:52 +01:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
} else if (gif instanceof TLRPC.BotInlineResult) {
|
|
|
|
TLRPC.BotInlineResult result = (TLRPC.BotInlineResult) gif;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
if (result.document != null) {
|
|
|
|
MediaDataController.getInstance(currentAccount).addRecentGif(result.document, (int) (System.currentTimeMillis() / 1000));
|
|
|
|
if ((int) dialog_id == 0) {
|
|
|
|
accountInstance.getMessagesController().saveGif(parent, result.document);
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
TLRPC.User bot = (TLRPC.User) parent;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
HashMap<String, String> params = new HashMap<>();
|
|
|
|
params.put("id", result.id);
|
|
|
|
params.put("query_id", "" + result.query_id);
|
2020-06-04 18:47:15 +02:00
|
|
|
params.put("force_gif", "1");
|
2019-05-14 14:08:05 +02:00
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
SendMessagesHelper.prepareSendingBotContextResult(accountInstance, result, params, dialog_id, replyingMessageObject, getThreadMessage(), notify, scheduleDate);
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
|
|
|
emojiView.closeSearch(true);
|
|
|
|
emojiView.hideSearchKeyboard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onMessageSend(null, notify, scheduleDate);
|
2015-12-09 19:27:52 +01:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onTabOpened(int type) {
|
|
|
|
delegate.onStickersTab(type == 3);
|
2017-07-23 14:56:38 +02:00
|
|
|
post(updateExpandabilityRunnable);
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClearEmojiRecent() {
|
|
|
|
if (parentFragment == null || parentActivity == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.getString("ClearRecentEmoji", R.string.ClearRecentEmoji));
|
2018-08-27 10:33:11 +02:00
|
|
|
builder.setPositiveButton(LocaleController.getString("ClearButton", R.string.ClearButton).toUpperCase(), (dialogInterface, i) -> emojiView.clearRecentEmoji());
|
2016-03-16 13:26:32 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
|
|
|
parentFragment.showDialog(builder.create());
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
|
|
|
@Override
|
2017-03-31 01:58:05 +02:00
|
|
|
public void onShowStickerSet(TLRPC.StickerSet stickerSet, TLRPC.InputStickerSet inputStickerSet) {
|
2020-04-24 11:21:58 +02:00
|
|
|
if (trendingStickersAlert != null && !trendingStickersAlert.isDismissed()) {
|
|
|
|
trendingStickersAlert.getLayout().showStickerSet(stickerSet, inputStickerSet);
|
|
|
|
return;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (parentFragment == null || parentActivity == null) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (stickerSet != null) {
|
|
|
|
inputStickerSet = new TLRPC.TL_inputStickerSetID();
|
|
|
|
inputStickerSet.access_hash = stickerSet.access_hash;
|
|
|
|
inputStickerSet.id = stickerSet.id;
|
|
|
|
}
|
|
|
|
parentFragment.showDialog(new StickersAlert(parentActivity, parentFragment, inputStickerSet, null, ChatActivityEnterView.this));
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet) {
|
2020-03-30 14:00:09 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).toggleStickerSet(parentActivity, stickerSet, 2, parentFragment, false, false);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet) {
|
2020-03-30 14:00:09 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).toggleStickerSet(parentActivity, stickerSet, 0, parentFragment, false, false);
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickersGroupClick(int chatId) {
|
|
|
|
if (parentFragment != null) {
|
|
|
|
if (AndroidUtilities.isTablet()) {
|
|
|
|
hidePopup(false);
|
|
|
|
}
|
|
|
|
GroupStickersActivity fragment = new GroupStickersActivity(chatId);
|
|
|
|
fragment.setInfo(info);
|
|
|
|
parentFragment.presentFragment(fragment);
|
|
|
|
}
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
@Override
|
2019-05-14 14:08:05 +02:00
|
|
|
public void onSearchOpenClose(int type) {
|
|
|
|
searchingType = type;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (type != 0) {
|
|
|
|
// expandStickersWithKeyboard = true;
|
|
|
|
// if (expandStickersWithKeyboard) {
|
|
|
|
// expandStickersWithKeyboard = false;
|
2020-12-23 08:48:30 +01:00
|
|
|
setStickersExpanded(true, true, false);
|
|
|
|
// }
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (emojiTabOpen && searchingType == 2) {
|
|
|
|
checkStickresExpandHeight();
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSearchOpened() {
|
2019-05-14 14:08:05 +02:00
|
|
|
return searchingType != 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isExpanded() {
|
|
|
|
return stickersExpanded;
|
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canSchedule() {
|
|
|
|
return parentFragment != null && parentFragment.canScheduleMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isInScheduleMode() {
|
|
|
|
return parentFragment != null && parentFragment.isInScheduleMode();
|
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getDialogId() {
|
|
|
|
return dialog_id;
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void showTrendingStickersAlert(TrendingStickersLayout layout) {
|
|
|
|
if (parentActivity != null && parentFragment != null) {
|
|
|
|
trendingStickersAlert = new TrendingStickersAlert(parentActivity, parentFragment, layout) {
|
|
|
|
@Override
|
|
|
|
public void dismiss() {
|
|
|
|
super.dismiss();
|
2020-06-04 18:47:15 +02:00
|
|
|
if (trendingStickersAlert == this) {
|
|
|
|
trendingStickersAlert = null;
|
|
|
|
}
|
2020-10-30 11:26:29 +01:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onTrendingStickersShowed(false);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
}
|
|
|
|
};
|
2020-10-30 11:26:29 +01:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onTrendingStickersShowed(true);
|
|
|
|
}
|
2020-04-24 11:21:58 +02:00
|
|
|
trendingStickersAlert.show();
|
|
|
|
}
|
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
});
|
2017-07-23 14:56:38 +02:00
|
|
|
emojiView.setDragListener(new EmojiView.DragListener() {
|
|
|
|
|
|
|
|
boolean wasExpanded;
|
|
|
|
int initialOffset;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDragStart() {
|
|
|
|
if (!allowDragging()) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (stickersExpansionAnim != null) {
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpansionAnim.cancel();
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersDragging = true;
|
|
|
|
wasExpanded = stickersExpanded;
|
|
|
|
stickersExpanded = true;
|
2019-07-18 15:01:39 +02:00
|
|
|
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 1);
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpandedHeight = sizeNotifierLayout.getHeight() - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? AndroidUtilities.statusBarHeight : 0) - ActionBar.getCurrentActionBarHeight() - getHeight() + Theme.chat_composeShadowDrawable.getIntrinsicHeight();
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType == 2) {
|
|
|
|
stickersExpandedHeight = Math.min(stickersExpandedHeight, AndroidUtilities.dp(120) + (AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight));
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
emojiView.getLayoutParams().height = stickersExpandedHeight;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2018-07-30 04:07:02 +02:00
|
|
|
sizeNotifierLayout.setForeground(new ScrimDrawable());
|
2017-07-23 14:56:38 +02:00
|
|
|
initialOffset = (int) getTranslationY();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onStickersExpandedChange();
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDragEnd(float velocity) {
|
2018-08-27 10:33:11 +02:00
|
|
|
if (!allowDragging()) {
|
2017-07-23 14:56:38 +02:00
|
|
|
return;
|
2018-08-27 10:33:11 +02:00
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersDragging = false;
|
|
|
|
if ((wasExpanded && velocity >= AndroidUtilities.dp(200)) || (!wasExpanded && velocity <= AndroidUtilities.dp(-200)) || (wasExpanded && stickersExpansionProgress <= 0.6f) || (!wasExpanded && stickersExpansionProgress >= 0.4f)) {
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(!wasExpanded, true, true);
|
2017-07-23 14:56:38 +02:00
|
|
|
} else {
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(wasExpanded, true, true);
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDragCancel() {
|
|
|
|
if (!stickersTabOpen) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
stickersDragging = false;
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(wasExpanded, true, false);
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDrag(int offset) {
|
|
|
|
if (!allowDragging()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int origHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
|
|
|
offset += initialOffset;
|
|
|
|
offset = Math.max(Math.min(offset, 0), -(stickersExpandedHeight - origHeight));
|
|
|
|
emojiView.setTranslationY(offset);
|
|
|
|
setTranslationY(offset);
|
|
|
|
stickersExpansionProgress = (float) offset / (-(stickersExpandedHeight - origHeight));
|
|
|
|
sizeNotifierLayout.invalidate();
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private boolean allowDragging() {
|
2020-10-30 11:26:29 +01:00
|
|
|
return stickersTabOpen && !(!stickersExpanded && messageEditText.length() > 0) && emojiView.areThereAnyStickers() && !waitingForKeyboardOpen;
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
});
|
2019-08-22 01:53:26 +02:00
|
|
|
sizeNotifierLayout.addView(emojiView, sizeNotifierLayout.getChildCount() - 1);
|
2017-07-08 18:32:04 +02:00
|
|
|
checkChannelRights();
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
|
2016-04-22 15:49:00 +02:00
|
|
|
@Override
|
2020-12-23 08:48:30 +01:00
|
|
|
public void onStickerSelected(TLRPC.Document sticker, String query, Object parent, boolean clearsInputField, boolean notify, int scheduleDate) {
|
2019-09-10 12:56:11 +02:00
|
|
|
if (isInScheduleMode() && scheduleDate == 0) {
|
2020-12-23 08:48:30 +01:00
|
|
|
AlertsCreator.createScheduleDatePickerDialog(parentActivity, parentFragment.getDialogId(), (n, s) -> onStickerSelected(sticker, query, parent, clearsInputField, n, s));
|
2019-09-10 12:56:11 +02:00
|
|
|
} else {
|
|
|
|
if (slowModeTimer > 0 && !isInScheduleMode()) {
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onUpdateSlowModeButton(slowModeButton, true, slowModeButton.getText());
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
|
|
|
emojiView.closeSearch(true);
|
|
|
|
emojiView.hideSearchKeyboard();
|
|
|
|
}
|
|
|
|
setStickersExpanded(false, true, false);
|
2020-12-23 08:48:30 +01:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendSticker(sticker, query, dialog_id, replyingMessageObject, getThreadMessage(), parent, notify, scheduleDate);
|
2019-08-22 01:53:26 +02:00
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(null, true, scheduleDate);
|
2019-08-22 01:53:26 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
if (clearsInputField) {
|
|
|
|
setFieldText("");
|
|
|
|
}
|
|
|
|
MediaDataController.getInstance(currentAccount).addRecentSticker(MediaDataController.TYPE_IMAGE, parent, sticker, (int) (System.currentTimeMillis() / 1000), false);
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canSchedule() {
|
|
|
|
return parentFragment != null && parentFragment.canScheduleMessage();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isInScheduleMode() {
|
|
|
|
return parentFragment != null && parentFragment.isInScheduleMode();
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
public void addStickerToRecent(TLRPC.Document sticker) {
|
|
|
|
createEmojiView();
|
|
|
|
emojiView.addRecentSticker(sticker);
|
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
public void hideEmojiView() {
|
|
|
|
if (!emojiViewVisible && emojiView != null && emojiView.getVisibility() != GONE) {
|
2019-07-18 15:01:39 +02:00
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
2019-05-14 14:08:05 +02:00
|
|
|
emojiView.setVisibility(GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-22 01:53:26 +02:00
|
|
|
public void showEmojiView() {
|
|
|
|
showPopup(1, 0);
|
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
private void showPopup(int show, int contentType) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (show == 2) {
|
|
|
|
return;
|
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
if (show == 1) {
|
|
|
|
if (contentType == 0 && emojiView == null) {
|
|
|
|
if (parentActivity == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
createEmojiView();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
View currentView = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean anotherPanelWasVisible = false;
|
2020-09-30 15:48:47 +02:00
|
|
|
boolean samePannelWasVisible = false;
|
|
|
|
int previusHeight = 0;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (contentType == 0) {
|
2019-07-18 15:01:39 +02:00
|
|
|
if (emojiView.getParent() == null) {
|
2019-08-22 01:53:26 +02:00
|
|
|
sizeNotifierLayout.addView(emojiView, sizeNotifierLayout.getChildCount() - 1);
|
2019-07-18 15:01:39 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
samePannelWasVisible = emojiViewVisible && emojiView.getVisibility() == View.VISIBLE;
|
2015-06-29 19:12:11 +02:00
|
|
|
emojiView.setVisibility(VISIBLE);
|
2019-05-14 14:08:05 +02:00
|
|
|
emojiViewVisible = true;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (botKeyboardView != null && botKeyboardView.getVisibility() != GONE) {
|
|
|
|
botKeyboardView.setVisibility(GONE);
|
2020-03-30 14:00:09 +02:00
|
|
|
botKeyboardViewVisible = false;
|
|
|
|
anotherPanelWasVisible = true;
|
2020-09-30 15:48:47 +02:00
|
|
|
previusHeight = botKeyboardView.getMeasuredHeight();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
currentView = emojiView;
|
2020-09-30 15:48:47 +02:00
|
|
|
animatingContentType = 0;
|
2015-06-29 19:12:11 +02:00
|
|
|
} else if (contentType == 1) {
|
2020-09-30 15:48:47 +02:00
|
|
|
samePannelWasVisible = botKeyboardViewVisible && botKeyboardView.getVisibility() == View.VISIBLE;
|
2020-01-03 16:45:22 +01:00
|
|
|
botKeyboardViewVisible = true;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (emojiView != null && emojiView.getVisibility() != GONE) {
|
2019-07-18 15:01:39 +02:00
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
2015-06-29 19:12:11 +02:00
|
|
|
emojiView.setVisibility(GONE);
|
2019-05-14 14:08:05 +02:00
|
|
|
emojiViewVisible = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
anotherPanelWasVisible = true;
|
2020-09-30 15:48:47 +02:00
|
|
|
previusHeight = emojiView.getMeasuredHeight();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
botKeyboardView.setVisibility(VISIBLE);
|
|
|
|
currentView = botKeyboardView;
|
2020-09-30 15:48:47 +02:00
|
|
|
animatingContentType = 1;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
currentPopupContentType = contentType;
|
|
|
|
|
|
|
|
if (keyboardHeight <= 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
keyboardHeight = MessagesController.getGlobalEmojiSettings().getInt("kbd_height", AndroidUtilities.dp(200));
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
if (keyboardHeightLand <= 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
keyboardHeightLand = MessagesController.getGlobalEmojiSettings().getInt("kbd_height_land3", AndroidUtilities.dp(200));
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
int currentHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
2020-10-02 13:25:02 +02:00
|
|
|
/*if (!samePannelWasVisible && !anotherPanelWasVisible) {
|
2020-09-30 15:48:47 +02:00
|
|
|
currentHeight = 0;
|
2020-12-23 08:48:30 +01:00
|
|
|
} else */
|
|
|
|
if (contentType == 1) {
|
2015-06-29 19:12:11 +02:00
|
|
|
currentHeight = Math.min(botKeyboardView.getKeyboardHeight(), currentHeight);
|
|
|
|
}
|
|
|
|
if (botKeyboardView != null) {
|
|
|
|
botKeyboardView.setPanelHeight(currentHeight);
|
|
|
|
}
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams();
|
|
|
|
layoutParams.height = currentHeight;
|
|
|
|
currentView.setLayoutParams(layoutParams);
|
2016-10-11 13:57:01 +02:00
|
|
|
if (!AndroidUtilities.isInMultiwindow) {
|
|
|
|
AndroidUtilities.hideKeyboard(messageEditText);
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (sizeNotifierLayout != null) {
|
|
|
|
emojiPadding = currentHeight;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2019-05-14 14:08:05 +02:00
|
|
|
setEmojiButtonImage(true, true);
|
2015-06-29 19:12:11 +02:00
|
|
|
updateBotButton();
|
|
|
|
onWindowSizeChanged();
|
2020-09-30 15:48:47 +02:00
|
|
|
if (smoothKeyboard && !keyboardVisible && currentHeight != previusHeight) {
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation = new AnimatorSet();
|
2020-09-30 15:48:47 +02:00
|
|
|
currentView.setTranslationY(currentHeight - previusHeight);
|
|
|
|
panelAnimation.playTogether(ObjectAnimator.ofFloat(currentView, View.TRANSLATION_Y, currentHeight - previusHeight, 0));
|
|
|
|
panelAnimation.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator);
|
|
|
|
panelAnimation.setDuration(AdjustPanLayoutHelper.keyboardDuration);
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
panelAnimation = null;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
panelAnimation.start();
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (emojiButton != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
setEmojiButtonImage(false, true);
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
2015-10-29 18:10:07 +01:00
|
|
|
currentPopupContentType = -1;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (emojiView != null) {
|
2019-07-18 15:01:39 +02:00
|
|
|
if (show != 2 || AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (smoothKeyboard && !keyboardVisible && !stickersExpanded) {
|
|
|
|
if (emojiViewVisible = true) {
|
|
|
|
animatingContentType = 0;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation = new AnimatorSet();
|
|
|
|
panelAnimation.playTogether(ObjectAnimator.ofFloat(emojiView, View.TRANSLATION_Y, emojiView.getMeasuredHeight()));
|
2020-09-30 15:48:47 +02:00
|
|
|
panelAnimation.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator);
|
|
|
|
panelAnimation.setDuration(AdjustPanLayoutHelper.keyboardDuration);
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (show == 0) {
|
|
|
|
emojiPadding = 0;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
panelAnimation = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.setTranslationY(0);
|
|
|
|
emojiView.setVisibility(GONE);
|
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (removeEmojiViewAfterAnimation) {
|
|
|
|
removeEmojiViewAfterAnimation = false;
|
|
|
|
emojiView = null;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
});
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation.start();
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
|
|
|
emojiPadding = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
|
|
|
emojiView.setVisibility(GONE);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
} else {
|
|
|
|
removeEmojiViewAfterAnimation = false;
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
|
|
|
sizeNotifierLayout.removeView(emojiView);
|
|
|
|
emojiView = null;
|
2019-05-14 14:08:05 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
emojiViewVisible = false;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
if (botKeyboardView != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
if (show != 2 || AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow) {
|
2020-12-23 08:48:30 +01:00
|
|
|
if (smoothKeyboard && !keyboardVisible) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (botKeyboardViewVisible) {
|
|
|
|
animatingContentType = 1;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation = new AnimatorSet();
|
|
|
|
panelAnimation.playTogether(ObjectAnimator.ofFloat(botKeyboardView, View.TRANSLATION_Y, botKeyboardView.getMeasuredHeight()));
|
2020-09-30 15:48:47 +02:00
|
|
|
panelAnimation.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator);
|
|
|
|
panelAnimation.setDuration(AdjustPanLayoutHelper.keyboardDuration);
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (show == 0) {
|
|
|
|
emojiPadding = 0;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
panelAnimation = null;
|
2020-03-30 14:00:09 +02:00
|
|
|
botKeyboardView.setTranslationY(0);
|
|
|
|
botKeyboardView.setVisibility(GONE);
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2020-09-30 15:48:47 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
});
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2020-03-30 14:00:09 +02:00
|
|
|
panelAnimation.start();
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
2020-03-30 14:00:09 +02:00
|
|
|
} else {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (!waitingForKeyboardOpen) {
|
|
|
|
botKeyboardView.setVisibility(GONE);
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
2020-01-03 16:45:22 +01:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
botKeyboardViewVisible = false;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
if (sizeNotifierLayout != null) {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (!SharedConfig.smoothKeyboard && show == 0) {
|
2015-06-29 19:12:11 +02:00
|
|
|
emojiPadding = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
sizeNotifierLayout.requestLayout();
|
|
|
|
onWindowSizeChanged();
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
updateBotButton();
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
if (stickersTabOpen || emojiTabOpen) {
|
2017-07-23 14:56:38 +02:00
|
|
|
checkSendButton(true);
|
|
|
|
}
|
2017-12-08 18:35:59 +01:00
|
|
|
if (stickersExpanded && show != 1) {
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(false, false, false);
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void setEmojiButtonImage(boolean byOpen, boolean animated) {
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean showingRecordInterface = recordInterfaceState == 1 || (recordedAudioPanel != null && recordedAudioPanel.getVisibility() == View.VISIBLE);
|
|
|
|
if (showingRecordInterface) {
|
|
|
|
emojiButton[0].setScaleX(0);
|
|
|
|
emojiButton[0].setScaleY(0);
|
|
|
|
emojiButton[0].setAlpha(0f);
|
|
|
|
emojiButton[1].setScaleX(0);
|
|
|
|
emojiButton[1].setScaleY(0);
|
|
|
|
emojiButton[1].setAlpha(0f);
|
|
|
|
animated = false;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (animated && currentEmojiIcon == -1) {
|
|
|
|
animated = false;
|
|
|
|
}
|
|
|
|
int nextIcon;
|
|
|
|
if (byOpen && currentPopupContentType == 0) {
|
|
|
|
nextIcon = 0;
|
2016-10-11 13:57:01 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
int currentPage;
|
|
|
|
if (emojiView == null) {
|
|
|
|
currentPage = MessagesController.getGlobalEmojiSettings().getInt("selected_page", 0);
|
|
|
|
} else {
|
|
|
|
currentPage = emojiView.getCurrentPage();
|
|
|
|
}
|
|
|
|
if (currentPage == 0 || !allowStickers && !allowGifs) {
|
|
|
|
nextIcon = 1;
|
|
|
|
} else if (currentPage == 1) {
|
|
|
|
nextIcon = 2;
|
|
|
|
} else {
|
|
|
|
nextIcon = 3;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (currentEmojiIcon == nextIcon) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (emojiButtonAnimation != null) {
|
|
|
|
emojiButtonAnimation.cancel();
|
|
|
|
emojiButtonAnimation = null;
|
|
|
|
}
|
|
|
|
if (nextIcon == 0) {
|
|
|
|
emojiButton[animated ? 1 : 0].setImageResource(R.drawable.input_keyboard);
|
|
|
|
} else if (nextIcon == 1) {
|
|
|
|
emojiButton[animated ? 1 : 0].setImageResource(R.drawable.input_smile);
|
|
|
|
} else if (nextIcon == 2) {
|
|
|
|
emojiButton[animated ? 1 : 0].setImageResource(R.drawable.input_sticker);
|
|
|
|
} else if (nextIcon == 3) {
|
|
|
|
emojiButton[animated ? 1 : 0].setImageResource(R.drawable.input_gif);
|
|
|
|
}
|
|
|
|
emojiButton[animated ? 1 : 0].setTag(nextIcon == 2 ? 1 : null);
|
|
|
|
currentEmojiIcon = nextIcon;
|
|
|
|
if (animated) {
|
|
|
|
emojiButton[1].setVisibility(VISIBLE);
|
2020-03-30 14:00:09 +02:00
|
|
|
emojiButton[1].setAlpha(0f);
|
|
|
|
emojiButton[1].setScaleX(0.1f);
|
|
|
|
emojiButton[1].setScaleY(0.1f);
|
2019-05-14 14:08:05 +02:00
|
|
|
emojiButtonAnimation = new AnimatorSet();
|
|
|
|
emojiButtonAnimation.playTogether(
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_X, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.SCALE_Y, 0.1f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[0], View.ALPHA, 0.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_X, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.SCALE_Y, 1.0f),
|
|
|
|
ObjectAnimator.ofFloat(emojiButton[1], View.ALPHA, 1.0f));
|
|
|
|
emojiButtonAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (animation.equals(emojiButtonAnimation)) {
|
|
|
|
emojiButtonAnimation = null;
|
|
|
|
ImageView temp = emojiButton[1];
|
|
|
|
emojiButton[1] = emojiButton[0];
|
|
|
|
emojiButton[0] = temp;
|
|
|
|
emojiButton[1].setVisibility(INVISIBLE);
|
|
|
|
emojiButton[1].setAlpha(0.0f);
|
|
|
|
emojiButton[1].setScaleX(0.1f);
|
|
|
|
emojiButton[1].setScaleY(0.1f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
emojiButtonAnimation.setDuration(150);
|
|
|
|
emojiButtonAnimation.start();
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2020-06-04 18:47:15 +02:00
|
|
|
onEmojiIconChanged(nextIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void onEmojiIconChanged(int currentIcon) {
|
|
|
|
if (currentIcon == 3 && emojiView == null) {
|
|
|
|
MediaDataController.getInstance(currentAccount).loadRecents(MediaDataController.TYPE_IMAGE, true, true, false);
|
|
|
|
final ArrayList<String> gifSearchEmojies = MessagesController.getInstance(currentAccount).gifSearchEmojies;
|
|
|
|
for (int i = 0, N = Math.min(10, gifSearchEmojies.size()); i < N; i++) {
|
|
|
|
Emoji.preloadEmoji(gifSearchEmojies.get(i));
|
|
|
|
}
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
|
|
|
|
2015-09-02 00:14:21 +02:00
|
|
|
public void hidePopup(boolean byBackButton) {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (isPopupShowing()) {
|
2015-09-02 00:14:21 +02:00
|
|
|
if (currentPopupContentType == 1 && byBackButton && botButtonsMessageObject != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
|
2015-09-02 00:14:21 +02:00
|
|
|
preferences.edit().putInt("hidekeyboard_" + dialog_id, botButtonsMessageObject.getId()).commit();
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (byBackButton && searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2020-12-23 08:48:30 +01:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.closeSearch(true);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
messageEditText.requestFocus();
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(false, true, false);
|
2019-05-14 14:08:05 +02:00
|
|
|
if (emojiTabOpen) {
|
|
|
|
checkSendButton(true);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
|
|
|
searchingType = 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
emojiView.closeSearch(false);
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
|
|
|
showPopup(0, 0);
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void openKeyboardInternal() {
|
2020-10-15 02:39:36 +02:00
|
|
|
showPopup(AndroidUtilities.usingHardwareInput || AndroidUtilities.isInMultiwindow || parentFragment != null && parentFragment.isInBubbleMode() || isPaused ? 0 : 2, 0);
|
2015-06-29 19:12:11 +02:00
|
|
|
messageEditText.requestFocus();
|
|
|
|
AndroidUtilities.showKeyboard(messageEditText);
|
|
|
|
if (isPaused) {
|
|
|
|
showKeyboardOnResume = true;
|
2020-10-15 02:39:36 +02:00
|
|
|
} else if (!AndroidUtilities.usingHardwareInput && !keyboardVisible && !AndroidUtilities.isInMultiwindow && (parentFragment == null || !parentFragment.isInBubbleMode())) {
|
2015-06-29 19:12:11 +02:00
|
|
|
waitingForKeyboardOpen = true;
|
2020-10-30 11:26:29 +01:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.onTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_CANCEL, 0, 0, 0));
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
|
|
|
|
AndroidUtilities.runOnUIThread(openKeyboardRunnable, 100);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
public boolean isEditingMessage() {
|
|
|
|
return editingMessageObject != null;
|
|
|
|
}
|
|
|
|
|
2016-05-25 23:49:47 +02:00
|
|
|
public MessageObject getEditingMessageObject() {
|
|
|
|
return editingMessageObject;
|
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
public boolean isEditingCaption() {
|
|
|
|
return editingCaption;
|
|
|
|
}
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
public boolean hasAudioToSend() {
|
2017-07-08 18:32:04 +02:00
|
|
|
return audioToSendMessageObject != null || videoToSendMessageObject != null;
|
2016-03-16 13:26:32 +01:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public void openKeyboard() {
|
2021-03-19 11:25:58 +01:00
|
|
|
if (!AndroidUtilities.showKeyboard(messageEditText)) {
|
|
|
|
messageEditText.clearFocus();
|
|
|
|
messageEditText.requestFocus();
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
|
2015-11-26 22:04:02 +01:00
|
|
|
public void closeKeyboard() {
|
|
|
|
AndroidUtilities.hideKeyboard(messageEditText);
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
public boolean isPopupShowing() {
|
2020-01-03 16:45:22 +01:00
|
|
|
return emojiViewVisible || botKeyboardViewVisible;
|
2014-11-14 16:40:15 +01:00
|
|
|
}
|
|
|
|
|
2016-01-11 18:19:48 +01:00
|
|
|
public boolean isKeyboardVisible() {
|
|
|
|
return keyboardVisible;
|
|
|
|
}
|
|
|
|
|
2016-10-11 13:57:01 +02:00
|
|
|
public void addRecentGif(TLRPC.Document searchImage) {
|
2019-07-18 15:01:39 +02:00
|
|
|
MediaDataController.getInstance(currentAccount).addRecentGif(searchImage, (int) (System.currentTimeMillis() / 1000));
|
2017-03-31 01:58:05 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.addRecentGif(searchImage);
|
2016-01-11 18:19:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
@Override
|
|
|
|
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
|
|
|
super.onSizeChanged(w, h, oldw, oldh);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (w != oldw && stickersExpanded) {
|
2019-05-14 14:08:05 +02:00
|
|
|
searchingType = 0;
|
2018-07-30 04:07:02 +02:00
|
|
|
emojiView.closeSearch(false);
|
2018-08-27 10:33:11 +02:00
|
|
|
setStickersExpanded(false, false, false);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
videoTimelineView.clearFrames();
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
public boolean isStickersExpanded() {
|
|
|
|
return stickersExpanded;
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
2015-03-26 18:34:47 +01:00
|
|
|
public void onSizeChanged(int height, boolean isWidthGreater) {
|
2019-05-14 14:08:05 +02:00
|
|
|
if (searchingType != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
lastSizeChangeValue1 = height;
|
|
|
|
lastSizeChangeValue2 = isWidthGreater;
|
|
|
|
keyboardVisible = height > 0;
|
|
|
|
return;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (height > AndroidUtilities.dp(50) && keyboardVisible && !AndroidUtilities.isInMultiwindow) {
|
2015-03-26 18:34:47 +01:00
|
|
|
if (isWidthGreater) {
|
2014-07-03 00:39:05 +02:00
|
|
|
keyboardHeightLand = height;
|
2018-07-30 04:07:02 +02:00
|
|
|
MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height_land3", keyboardHeightLand).commit();
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
|
|
|
keyboardHeight = height;
|
2018-07-30 04:07:02 +02:00
|
|
|
MessagesController.getGlobalEmojiSettings().edit().putInt("kbd_height", keyboardHeight).commit();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
if (keyboardVisible) {
|
|
|
|
if (emojiViewVisible && emojiView == null) {
|
|
|
|
emojiViewVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
if (isPopupShowing()) {
|
2015-05-21 23:27:27 +02:00
|
|
|
int newHeight = isWidthGreater ? keyboardHeightLand : keyboardHeight;
|
2015-06-29 19:12:11 +02:00
|
|
|
if (currentPopupContentType == 1 && !botKeyboardView.isFullSize()) {
|
|
|
|
newHeight = Math.min(botKeyboardView.getKeyboardHeight(), newHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
View currentView = null;
|
|
|
|
if (currentPopupContentType == 0) {
|
|
|
|
currentView = emojiView;
|
|
|
|
} else if (currentPopupContentType == 1) {
|
|
|
|
currentView = botKeyboardView;
|
|
|
|
}
|
|
|
|
if (botKeyboardView != null) {
|
|
|
|
botKeyboardView.setPanelHeight(newHeight);
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
if (currentView != null) {
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) currentView.getLayoutParams();
|
|
|
|
if (!closeAnimationInProgress && (layoutParams.width != AndroidUtilities.displaySize.x || layoutParams.height != newHeight) && !stickersExpanded) {
|
|
|
|
layoutParams.width = AndroidUtilities.displaySize.x;
|
|
|
|
layoutParams.height = newHeight;
|
|
|
|
currentView.setLayoutParams(layoutParams);
|
|
|
|
if (sizeNotifierLayout != null) {
|
|
|
|
int oldHeight = emojiPadding;
|
|
|
|
emojiPadding = layoutParams.height;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
|
|
|
onWindowSizeChanged();
|
2020-12-23 08:48:30 +01:00
|
|
|
if (smoothKeyboard && !keyboardVisible && oldHeight != emojiPadding && pannelAnimationEnabled()) {
|
2020-09-30 15:48:47 +02:00
|
|
|
panelAnimation = new AnimatorSet();
|
|
|
|
panelAnimation.playTogether(ObjectAnimator.ofFloat(currentView, View.TRANSLATION_Y, emojiPadding - oldHeight, 0));
|
|
|
|
panelAnimation.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator);
|
|
|
|
panelAnimation.setDuration(AdjustPanLayoutHelper.keyboardDuration);
|
|
|
|
panelAnimation.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
panelAnimation = null;
|
|
|
|
if (delegate != null) {
|
|
|
|
delegate.bottomPanelTranslationYChanged(0);
|
|
|
|
}
|
|
|
|
requestLayout();
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2020-09-30 15:48:47 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
panelAnimation.start();
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2020-09-30 15:48:47 +02:00
|
|
|
requestLayout();
|
|
|
|
}
|
|
|
|
}
|
2014-10-06 12:38:00 +02:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
if (lastSizeChangeValue1 == height && lastSizeChangeValue2 == isWidthGreater) {
|
|
|
|
onWindowSizeChanged();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lastSizeChangeValue1 = height;
|
|
|
|
lastSizeChangeValue2 = isWidthGreater;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
boolean oldValue = keyboardVisible;
|
|
|
|
keyboardVisible = height > 0;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (keyboardVisible && isPopupShowing() && stickersExpansionAnim == null) {
|
2015-06-29 19:12:11 +02:00
|
|
|
showPopup(0, currentPopupContentType);
|
|
|
|
}
|
|
|
|
if (emojiPadding != 0 && !keyboardVisible && keyboardVisible != oldValue && !isPopupShowing()) {
|
|
|
|
emojiPadding = 0;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (keyboardVisible && waitingForKeyboardOpen) {
|
|
|
|
waitingForKeyboardOpen = false;
|
2020-09-30 15:48:47 +02:00
|
|
|
if (clearBotButtonsOnKeyboardOpen) {
|
|
|
|
clearBotButtonsOnKeyboardOpen = false;
|
|
|
|
botKeyboardView.setButtons(botReplyMarkup);
|
|
|
|
}
|
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
AndroidUtilities.cancelRunOnUIThread(openKeyboardRunnable);
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
onWindowSizeChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getEmojiPadding() {
|
|
|
|
return emojiPadding;
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
private MessageObject getThreadMessage() {
|
|
|
|
return parentFragment != null ? parentFragment.getThreadMessage() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
private int getThreadMessageId() {
|
|
|
|
return parentFragment != null && parentFragment.getThreadMessage() != null ? parentFragment.getThreadMessage().getId() : 0;
|
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
2018-07-30 04:07:02 +02:00
|
|
|
public void didReceivedNotification(int id, int account, Object... args) {
|
2019-01-23 18:03:33 +01:00
|
|
|
if (id == NotificationCenter.emojiDidLoad) {
|
2014-07-03 00:39:05 +02:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.invalidateViews();
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
if (botKeyboardView != null) {
|
|
|
|
botKeyboardView.invalidateViews();
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.recordProgressChanged) {
|
2019-09-10 12:56:11 +02:00
|
|
|
int guid = (Integer) args[0];
|
|
|
|
if (guid != recordingGuid) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
if (recordInterfaceState != 0 && !wasSendTyping && !isInScheduleMode()) {
|
|
|
|
wasSendTyping = true;
|
2020-09-30 15:48:47 +02:00
|
|
|
accountInstance.getMessagesController().sendTyping(dialog_id, getThreadMessageId(), videoSendButton != null && videoSendButton.getTag() != null ? 7 : 1, 0);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
if (recordCircle != null) {
|
2020-03-30 14:00:09 +02:00
|
|
|
recordCircle.setAmplitude((Double) args[1]);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.closeChats) {
|
2015-03-26 18:34:47 +01:00
|
|
|
if (messageEditText != null && messageEditText.isFocused()) {
|
|
|
|
AndroidUtilities.hideKeyboard(messageEditText);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.recordStartError || id == NotificationCenter.recordStopped) {
|
2019-09-10 12:56:11 +02:00
|
|
|
int guid = (Integer) args[0];
|
|
|
|
if (guid != recordingGuid) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (recordingAudioVideo) {
|
|
|
|
recordingAudioVideo = false;
|
2020-03-30 14:00:09 +02:00
|
|
|
if (id == NotificationCenter.recordStopped) {
|
|
|
|
Integer reason = (Integer) args[1];
|
|
|
|
int state;
|
|
|
|
if (reason == 4) {
|
|
|
|
state = RECORD_STATE_CANCEL_BY_TIME;
|
|
|
|
} else if (isInVideoMode() && reason == 5) {
|
|
|
|
state = RECORD_STATE_SENDING;
|
|
|
|
} else {
|
|
|
|
if (reason == 0) {
|
|
|
|
state = RECORD_STATE_CANCEL_BY_GESTURE;
|
|
|
|
} else if (reason == 6) {
|
|
|
|
state = RECORD_STATE_CANCEL;
|
|
|
|
} else {
|
|
|
|
state = RECORD_STATE_PREPARING;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (state != RECORD_STATE_PREPARING) {
|
|
|
|
updateRecordIntefrace(state);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
if (id == NotificationCenter.recordStopped) {
|
2019-09-10 12:56:11 +02:00
|
|
|
Integer reason = (Integer) args[1];
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.recordStarted) {
|
2019-09-10 12:56:11 +02:00
|
|
|
int guid = (Integer) args[0];
|
|
|
|
if (guid != recordingGuid) {
|
|
|
|
return;
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
boolean audio = (Boolean) args[1];
|
|
|
|
if (videoSendButton != null) {
|
|
|
|
videoSendButton.setTag(audio ? null : 1);
|
|
|
|
videoSendButton.setVisibility(audio ? View.GONE : View.VISIBLE);
|
|
|
|
videoSendButton.setVisibility(audio ? View.VISIBLE : View.GONE);
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
if (!recordingAudioVideo) {
|
|
|
|
recordingAudioVideo = true;
|
2020-03-30 14:00:09 +02:00
|
|
|
updateRecordIntefrace(RECORD_STATE_ENTER);
|
|
|
|
} else {
|
|
|
|
recordCircle.showWaves(true, true);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
recordTimerView.start();
|
|
|
|
recordDot.enterAnimation = false;
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.audioDidSent) {
|
2019-09-10 12:56:11 +02:00
|
|
|
int guid = (Integer) args[0];
|
|
|
|
if (guid != recordingGuid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Object audio = args[1];
|
2017-07-08 18:32:04 +02:00
|
|
|
if (audio instanceof VideoEditedInfo) {
|
|
|
|
videoToSendMessageObject = (VideoEditedInfo) audio;
|
|
|
|
|
2019-09-10 12:56:11 +02:00
|
|
|
audioToSendPath = (String) args[2];
|
2020-03-30 14:00:09 +02:00
|
|
|
ArrayList<Bitmap> keyframes = (ArrayList<Bitmap>) args[3];
|
2017-07-08 18:32:04 +02:00
|
|
|
|
|
|
|
videoTimelineView.setVideoPath(audioToSendPath);
|
2020-03-30 14:00:09 +02:00
|
|
|
videoTimelineView.setKeyframes(keyframes);
|
2017-07-08 18:32:04 +02:00
|
|
|
videoTimelineView.setVisibility(VISIBLE);
|
|
|
|
videoTimelineView.setMinProgressDiff(1000.0f / videoToSendMessageObject.estimatedDuration);
|
2020-03-30 14:00:09 +02:00
|
|
|
updateRecordIntefrace(RECORD_STATE_PREPARING);
|
2016-03-06 02:49:31 +01:00
|
|
|
checkSendButton(false);
|
|
|
|
} else {
|
2019-09-10 12:56:11 +02:00
|
|
|
audioToSend = (TLRPC.TL_document) args[1];
|
|
|
|
audioToSendPath = (String) args[2];
|
2017-07-08 18:32:04 +02:00
|
|
|
if (audioToSend != null) {
|
|
|
|
if (recordedAudioPanel == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TLRPC.TL_message message = new TLRPC.TL_message();
|
|
|
|
message.out = true;
|
|
|
|
message.id = 0;
|
2020-09-30 15:48:47 +02:00
|
|
|
message.peer_id = new TLRPC.TL_peerUser();
|
|
|
|
message.from_id = new TLRPC.TL_peerUser();
|
|
|
|
message.peer_id.user_id = message.from_id.user_id = UserConfig.getInstance(currentAccount).getClientUserId();
|
2017-07-08 18:32:04 +02:00
|
|
|
message.date = (int) (System.currentTimeMillis() / 1000);
|
2018-07-30 04:07:02 +02:00
|
|
|
message.message = "";
|
2017-07-08 18:32:04 +02:00
|
|
|
message.attachPath = audioToSendPath;
|
|
|
|
message.media = new TLRPC.TL_messageMediaDocument();
|
2017-07-23 14:56:38 +02:00
|
|
|
message.media.flags |= 3;
|
2017-07-08 18:32:04 +02:00
|
|
|
message.media.document = audioToSend;
|
|
|
|
message.flags |= TLRPC.MESSAGE_FLAG_HAS_MEDIA | TLRPC.MESSAGE_FLAG_HAS_FROM_ID;
|
2020-08-14 18:58:22 +02:00
|
|
|
audioToSendMessageObject = new MessageObject(UserConfig.selectedAccount, message, false, true);
|
2017-07-08 18:32:04 +02:00
|
|
|
|
|
|
|
recordedAudioPanel.setAlpha(1.0f);
|
|
|
|
recordedAudioPanel.setVisibility(VISIBLE);
|
2020-03-30 14:00:09 +02:00
|
|
|
recordDeleteImageView.setVisibility(VISIBLE);
|
|
|
|
recordDeleteImageView.setAlpha(0f);
|
|
|
|
recordDeleteImageView.setScaleY(0f);
|
|
|
|
recordDeleteImageView.setScaleX(0f);
|
2017-07-08 18:32:04 +02:00
|
|
|
int duration = 0;
|
|
|
|
for (int a = 0; a < audioToSend.attributes.size(); a++) {
|
|
|
|
TLRPC.DocumentAttribute attribute = audioToSend.attributes.get(a);
|
|
|
|
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
|
|
|
|
duration = attribute.duration;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int a = 0; a < audioToSend.attributes.size(); a++) {
|
|
|
|
TLRPC.DocumentAttribute attribute = audioToSend.attributes.get(a);
|
|
|
|
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
|
|
|
|
if (attribute.waveform == null || attribute.waveform.length == 0) {
|
|
|
|
attribute.waveform = MediaController.getInstance().getWaveform(audioToSendPath);
|
|
|
|
}
|
|
|
|
recordedAudioSeekBar.setWaveform(attribute.waveform);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
recordedAudioTimeTextView.setText(AndroidUtilities.formatShortDuration(duration));
|
2017-07-08 18:32:04 +02:00
|
|
|
checkSendButton(false);
|
2020-03-30 14:00:09 +02:00
|
|
|
updateRecordIntefrace(RECORD_STATE_PREPARING);
|
2017-07-08 18:32:04 +02:00
|
|
|
} else {
|
|
|
|
if (delegate != null) {
|
2019-09-10 12:56:11 +02:00
|
|
|
delegate.onMessageSend(null, true, 0);
|
2017-07-08 18:32:04 +02:00
|
|
|
}
|
2016-03-06 02:49:31 +01:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
} else if (id == NotificationCenter.audioRouteChanged) {
|
|
|
|
if (parentActivity != null) {
|
|
|
|
boolean frontSpeaker = (Boolean) args[0];
|
|
|
|
parentActivity.setVolumeControlStream(frontSpeaker ? AudioManager.STREAM_VOICE_CALL : AudioManager.USE_DEFAULT_STREAM_TYPE);
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
} else if (id == NotificationCenter.messagePlayingDidReset) {
|
|
|
|
if (audioToSendMessageObject != null && !MediaController.getInstance().isPlayingMessage(audioToSendMessageObject)) {
|
2020-03-30 14:00:09 +02:00
|
|
|
playPauseDrawable.setIcon(MediaActionDrawable.ICON_PLAY, true);
|
2019-05-14 14:08:05 +02:00
|
|
|
recordedAudioPlayButton.setContentDescription(LocaleController.getString("AccActionPlay", R.string.AccActionPlay));
|
2016-03-06 02:49:31 +01:00
|
|
|
recordedAudioSeekBar.setProgress(0);
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
} else if (id == NotificationCenter.messagePlayingProgressDidChanged) {
|
2016-03-06 02:49:31 +01:00
|
|
|
Integer mid = (Integer) args[0];
|
2017-07-08 18:32:04 +02:00
|
|
|
if (audioToSendMessageObject != null && MediaController.getInstance().isPlayingMessage(audioToSendMessageObject)) {
|
2016-03-06 02:49:31 +01:00
|
|
|
MessageObject player = MediaController.getInstance().getPlayingMessageObject();
|
|
|
|
audioToSendMessageObject.audioProgress = player.audioProgress;
|
|
|
|
audioToSendMessageObject.audioProgressSec = player.audioProgressSec;
|
|
|
|
if (!recordedAudioSeekBar.isDragging()) {
|
|
|
|
recordedAudioSeekBar.setProgress(audioToSendMessageObject.audioProgress);
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.featuredStickersDidLoad) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (emojiButton != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
for (int a = 0; a < emojiButton.length; a++) {
|
|
|
|
emojiButton[a].invalidate();
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
} else if (id == NotificationCenter.messageReceivedByServer) {
|
2019-09-10 12:56:11 +02:00
|
|
|
Boolean scheduled = (Boolean) args[6];
|
|
|
|
if (scheduled) {
|
|
|
|
return;
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
long did = (Long) args[3];
|
|
|
|
if (did == dialog_id && info != null && info.slowmode_seconds != 0) {
|
|
|
|
TLRPC.Chat chat = accountInstance.getMessagesController().getChat(info.id);
|
|
|
|
if (chat != null && !ChatObject.hasAdminRights(chat)) {
|
|
|
|
info.slowmode_next_send_date = ConnectionsManager.getInstance(currentAccount).getCurrentTime() + info.slowmode_seconds;
|
|
|
|
info.flags |= 262144;
|
|
|
|
setSlowModeTimer(info.slowmode_next_send_date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (id == NotificationCenter.sendingMessagesChanged) {
|
|
|
|
if (info != null) {
|
|
|
|
updateSlowModeText();
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
} else if (id == NotificationCenter.audioRecordTooShort) {
|
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL_BY_TIME);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
2016-04-22 15:49:00 +02:00
|
|
|
|
|
|
|
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
if (requestCode == 2) {
|
|
|
|
if (pendingLocationButton != null) {
|
|
|
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
2018-07-30 04:07:02 +02:00
|
|
|
SendMessagesHelper.getInstance(currentAccount).sendCurrentLocation(pendingMessageObject, pendingLocationButton);
|
2016-04-22 15:49:00 +02:00
|
|
|
}
|
|
|
|
pendingLocationButton = null;
|
|
|
|
pendingMessageObject = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
|
2019-05-14 14:08:05 +02:00
|
|
|
private void checkStickresExpandHeight() {
|
2020-09-30 15:48:47 +02:00
|
|
|
if (emojiView == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
final int origHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
|
|
|
int newHeight = originalViewHeight - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? AndroidUtilities.statusBarHeight : 0) - ActionBar.getCurrentActionBarHeight() - getHeight() + Theme.chat_composeShadowDrawable.getIntrinsicHeight();
|
|
|
|
if (searchingType == 2) {
|
|
|
|
newHeight = Math.min(newHeight, AndroidUtilities.dp(120) + origHeight);
|
|
|
|
}
|
|
|
|
int currentHeight = emojiView.getLayoutParams().height;
|
|
|
|
if (currentHeight == newHeight) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (stickersExpansionAnim != null) {
|
|
|
|
stickersExpansionAnim.cancel();
|
|
|
|
stickersExpansionAnim = null;
|
|
|
|
}
|
|
|
|
stickersExpandedHeight = newHeight;
|
|
|
|
if (currentHeight > newHeight) {
|
|
|
|
AnimatorSet anims = new AnimatorSet();
|
|
|
|
anims.playTogether(
|
|
|
|
ObjectAnimator.ofInt(this, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight)),
|
|
|
|
ObjectAnimator.ofInt(emojiView, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight))
|
|
|
|
);
|
|
|
|
((ObjectAnimator) anims.getChildAnimations().get(0)).addUpdateListener(animation -> sizeNotifierLayout.invalidate());
|
2020-09-30 15:48:47 +02:00
|
|
|
anims.setDuration(300);
|
|
|
|
anims.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2019-05-14 14:08:05 +02:00
|
|
|
anims.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
stickersExpansionAnim = null;
|
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.getLayoutParams().height = stickersExpandedHeight;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_NONE, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
stickersExpansionAnim = anims;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
|
|
|
anims.start();
|
|
|
|
} else {
|
|
|
|
emojiView.getLayoutParams().height = stickersExpandedHeight;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
|
|
|
int start = messageEditText.getSelectionStart();
|
|
|
|
int end = messageEditText.getSelectionEnd();
|
|
|
|
messageEditText.setText(messageEditText.getText()); // dismiss action mode, if any
|
|
|
|
messageEditText.setSelection(start, end);
|
|
|
|
AnimatorSet anims = new AnimatorSet();
|
|
|
|
anims.playTogether(
|
|
|
|
ObjectAnimator.ofInt(this, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight)),
|
|
|
|
ObjectAnimator.ofInt(emojiView, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight))
|
|
|
|
);
|
|
|
|
((ObjectAnimator) anims.getChildAnimations().get(0)).addUpdateListener(animation -> sizeNotifierLayout.invalidate());
|
2020-09-30 15:48:47 +02:00
|
|
|
anims.setDuration(300);
|
|
|
|
anims.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2019-05-14 14:08:05 +02:00
|
|
|
anims.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
stickersExpansionAnim = null;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_NONE, null);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
stickersExpansionAnim = anims;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
|
|
|
anims.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public void setStickersExpanded(boolean expanded, boolean animated, boolean byDrag) {
|
|
|
|
if (adjustPanLayoutHelper != null && adjustPanLayoutHelper.animationInProgress() || waitingForKeyboardOpenAfterAnimation) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (emojiView == null || !byDrag && stickersExpanded == expanded) {
|
2017-07-23 14:56:38 +02:00
|
|
|
return;
|
2017-12-08 18:35:59 +01:00
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpanded = expanded;
|
2018-07-30 04:07:02 +02:00
|
|
|
if (delegate != null) {
|
|
|
|
delegate.onStickersExpandedChange();
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
final int origHeight = AndroidUtilities.displaySize.x > AndroidUtilities.displaySize.y ? keyboardHeightLand : keyboardHeight;
|
2017-12-08 18:35:59 +01:00
|
|
|
if (stickersExpansionAnim != null) {
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpansionAnim.cancel();
|
2017-12-08 18:35:59 +01:00
|
|
|
stickersExpansionAnim = null;
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
if (stickersExpanded) {
|
2019-07-18 15:01:39 +02:00
|
|
|
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.stopAllHeavyOperations, 1);
|
2019-05-14 14:08:05 +02:00
|
|
|
originalViewHeight = sizeNotifierLayout.getHeight();
|
|
|
|
stickersExpandedHeight = originalViewHeight - (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? AndroidUtilities.statusBarHeight : 0) - ActionBar.getCurrentActionBarHeight() - getHeight() + Theme.chat_composeShadowDrawable.getIntrinsicHeight();
|
|
|
|
if (searchingType == 2) {
|
|
|
|
stickersExpandedHeight = Math.min(stickersExpandedHeight, AndroidUtilities.dp(120) + origHeight);
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
emojiView.getLayoutParams().height = stickersExpandedHeight;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2018-07-30 04:07:02 +02:00
|
|
|
sizeNotifierLayout.setForeground(new ScrimDrawable());
|
2019-05-14 14:08:05 +02:00
|
|
|
int start = messageEditText.getSelectionStart();
|
|
|
|
int end = messageEditText.getSelectionEnd();
|
2017-07-23 14:56:38 +02:00
|
|
|
messageEditText.setText(messageEditText.getText()); // dismiss action mode, if any
|
2019-05-14 14:08:05 +02:00
|
|
|
messageEditText.setSelection(start, end);
|
2017-07-23 14:56:38 +02:00
|
|
|
if (animated) {
|
|
|
|
AnimatorSet anims = new AnimatorSet();
|
|
|
|
anims.playTogether(
|
|
|
|
ObjectAnimator.ofInt(this, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight)),
|
|
|
|
ObjectAnimator.ofInt(emojiView, roundedTranslationYProperty, -(stickersExpandedHeight - origHeight)),
|
|
|
|
ObjectAnimator.ofFloat(stickersArrow, "animationProgress", 1)
|
|
|
|
);
|
2020-09-30 15:48:47 +02:00
|
|
|
anims.setDuration(300);
|
|
|
|
anims.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2018-08-27 10:33:11 +02:00
|
|
|
((ObjectAnimator) anims.getChildAnimations().get(0)).addUpdateListener(animation -> {
|
2020-09-30 15:48:47 +02:00
|
|
|
stickersExpansionProgress = Math.abs(getTranslationY() / (-(stickersExpandedHeight - origHeight)));
|
2018-08-27 10:33:11 +02:00
|
|
|
sizeNotifierLayout.invalidate();
|
2017-07-23 14:56:38 +02:00
|
|
|
});
|
|
|
|
anims.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
stickersExpansionAnim = null;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_NONE, null);
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
stickersExpansionAnim = anims;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2020-09-30 15:48:47 +02:00
|
|
|
stickersExpansionProgress = 0f;
|
|
|
|
sizeNotifierLayout.invalidate();
|
2017-07-23 14:56:38 +02:00
|
|
|
anims.start();
|
|
|
|
} else {
|
|
|
|
stickersExpansionProgress = 1;
|
|
|
|
setTranslationY(-(stickersExpandedHeight - origHeight));
|
|
|
|
emojiView.setTranslationY(-(stickersExpandedHeight - origHeight));
|
|
|
|
stickersArrow.setAnimationProgress(1);
|
|
|
|
}
|
|
|
|
} else {
|
2019-07-18 15:01:39 +02:00
|
|
|
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 1);
|
2017-07-23 14:56:38 +02:00
|
|
|
if (animated) {
|
2018-07-30 04:07:02 +02:00
|
|
|
closeAnimationInProgress = true;
|
2017-07-23 14:56:38 +02:00
|
|
|
AnimatorSet anims = new AnimatorSet();
|
|
|
|
anims.playTogether(
|
|
|
|
ObjectAnimator.ofInt(this, roundedTranslationYProperty, 0),
|
|
|
|
ObjectAnimator.ofInt(emojiView, roundedTranslationYProperty, 0),
|
|
|
|
ObjectAnimator.ofFloat(stickersArrow, "animationProgress", 0)
|
|
|
|
);
|
2020-09-30 15:48:47 +02:00
|
|
|
anims.setDuration(300);
|
|
|
|
anims.setInterpolator(CubicBezierInterpolator.DEFAULT);
|
2018-08-27 10:33:11 +02:00
|
|
|
((ObjectAnimator) anims.getChildAnimations().get(0)).addUpdateListener(animation -> {
|
|
|
|
stickersExpansionProgress = getTranslationY() / (-(stickersExpandedHeight - origHeight));
|
|
|
|
sizeNotifierLayout.invalidate();
|
2017-07-23 14:56:38 +02:00
|
|
|
});
|
|
|
|
anims.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
2018-07-30 04:07:02 +02:00
|
|
|
closeAnimationInProgress = false;
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpansionAnim = null;
|
2019-01-23 18:03:33 +01:00
|
|
|
if (emojiView != null) {
|
|
|
|
emojiView.getLayoutParams().height = origHeight;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_NONE, null);
|
|
|
|
}
|
|
|
|
if (sizeNotifierLayout != null) {
|
|
|
|
sizeNotifierLayout.requestLayout();
|
|
|
|
sizeNotifierLayout.setForeground(null);
|
|
|
|
sizeNotifierLayout.setWillNotDraw(false);
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
if (keyboardVisible && isPopupShowing()) {
|
|
|
|
showPopup(0, currentPopupContentType);
|
|
|
|
}
|
2020-10-31 22:13:37 +01:00
|
|
|
NotificationCenter.getInstance(currentAccount).onAnimationFinish(notificationsIndex);
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
});
|
2020-09-30 15:48:47 +02:00
|
|
|
stickersExpansionProgress = 1f;
|
|
|
|
sizeNotifierLayout.invalidate();
|
2017-07-23 14:56:38 +02:00
|
|
|
stickersExpansionAnim = anims;
|
|
|
|
emojiView.setLayerType(LAYER_TYPE_HARDWARE, null);
|
2020-10-31 22:13:37 +01:00
|
|
|
notificationsIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(notificationsIndex, null);
|
2017-07-23 14:56:38 +02:00
|
|
|
anims.start();
|
|
|
|
} else {
|
|
|
|
stickersExpansionProgress = 0;
|
|
|
|
setTranslationY(0);
|
|
|
|
emojiView.setTranslationY(0);
|
|
|
|
emojiView.getLayoutParams().height = origHeight;
|
|
|
|
sizeNotifierLayout.requestLayout();
|
2018-07-30 04:07:02 +02:00
|
|
|
sizeNotifierLayout.setForeground(null);
|
2017-07-23 14:56:38 +02:00
|
|
|
sizeNotifierLayout.setWillNotDraw(false);
|
|
|
|
stickersArrow.setAnimationProgress(0);
|
|
|
|
}
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (expanded) {
|
2020-03-30 14:00:09 +02:00
|
|
|
expandStickersButton.setContentDescription(LocaleController.getString("AccDescrCollapsePanel", R.string.AccDescrCollapsePanel));
|
2019-05-14 14:08:05 +02:00
|
|
|
} else {
|
|
|
|
expandStickersButton.setContentDescription(LocaleController.getString("AccDescrExpandPanel", R.string.AccDescrExpandPanel));
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
public boolean swipeToBackEnabled() {
|
|
|
|
if (recordingAudioVideo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if ((videoSendButton != null) && isInVideoMode() && recordedAudioPanel != null && recordedAudioPanel.getVisibility() == View.VISIBLE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-12-23 08:48:30 +01:00
|
|
|
public int getHeightWithTopView() {
|
|
|
|
int h = getMeasuredHeight();
|
|
|
|
if (topView != null && topView.getVisibility() == View.VISIBLE) {
|
|
|
|
h -= (1f - topViewEnterProgress) * topView.getLayoutParams().height;
|
|
|
|
}
|
|
|
|
return h;
|
|
|
|
}
|
2020-09-30 15:48:47 +02:00
|
|
|
|
|
|
|
public void setAdjustPanLayoutHelper(AdjustPanLayoutHelper adjustPanLayoutHelper) {
|
|
|
|
this.adjustPanLayoutHelper = adjustPanLayoutHelper;
|
|
|
|
}
|
|
|
|
|
2020-10-30 11:26:29 +01:00
|
|
|
public AdjustPanLayoutHelper getAdjustPanLayoutHelper() {
|
|
|
|
return adjustPanLayoutHelper;
|
|
|
|
}
|
|
|
|
|
2020-09-30 15:48:47 +02:00
|
|
|
public boolean pannelAniamationInProgress() {
|
|
|
|
return panelAnimation != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getTopViewTranslation() {
|
|
|
|
if (topView == null || topView.getVisibility() == View.GONE) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return topView.getTranslationY();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAnimatedTop() {
|
|
|
|
return animatedTop;
|
|
|
|
}
|
|
|
|
|
2020-10-30 11:26:29 +01:00
|
|
|
public void checkAnimation() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-23 14:56:38 +02:00
|
|
|
private class ScrimDrawable extends Drawable {
|
|
|
|
|
|
|
|
private Paint paint;
|
|
|
|
|
|
|
|
public ScrimDrawable() {
|
|
|
|
paint = new Paint();
|
|
|
|
paint.setColor(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void draw(Canvas canvas) {
|
2019-01-23 18:03:33 +01:00
|
|
|
if (emojiView == null) {
|
|
|
|
return;
|
|
|
|
}
|
2017-07-23 14:56:38 +02:00
|
|
|
paint.setAlpha(Math.round(102 * stickersExpansionProgress));
|
|
|
|
canvas.drawRect(0, 0, getWidth(), emojiView.getY() - getHeight() + Theme.chat_composeShadowDrawable.getIntrinsicHeight(), paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setAlpha(int alpha) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void setColorFilter(ColorFilter colorFilter) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getOpacity() {
|
2018-07-30 04:07:02 +02:00
|
|
|
return PixelFormat.TRANSPARENT;
|
2017-07-23 14:56:38 +02:00
|
|
|
}
|
|
|
|
}
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
private class SlideTextView extends View {
|
|
|
|
|
|
|
|
TextPaint grayPaint;
|
|
|
|
TextPaint bluePaint;
|
|
|
|
|
|
|
|
Paint arrowPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
|
|
|
|
String slideToCancelString;
|
|
|
|
String cancelString;
|
|
|
|
|
|
|
|
float slideToCancelWidth;
|
|
|
|
float cancelWidth;
|
|
|
|
float cancelToProgress;
|
|
|
|
float slideProgress;
|
|
|
|
|
|
|
|
float slideToAlpha;
|
|
|
|
float cancelAlpha;
|
|
|
|
|
|
|
|
float xOffset = 0;
|
|
|
|
boolean moveForward;
|
|
|
|
long lastUpdateTime;
|
|
|
|
|
|
|
|
int cancelCharOffset;
|
|
|
|
|
|
|
|
Path arrowPath = new Path();
|
|
|
|
|
|
|
|
StaticLayout slideToLayout;
|
|
|
|
StaticLayout cancelLayout;
|
|
|
|
|
|
|
|
private boolean pressed;
|
|
|
|
private Rect cancelRect = new Rect();
|
|
|
|
|
|
|
|
Drawable selectableBackground;
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_UP) {
|
|
|
|
setPressed(false);
|
|
|
|
}
|
|
|
|
if (cancelToProgress == 0 || !isEnabled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
int x = (int) event.getX();
|
|
|
|
int y = (int) event.getY();
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
pressed = cancelRect.contains(x, y);
|
|
|
|
if (pressed) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
2020-07-26 10:03:38 +02:00
|
|
|
selectableBackground.setHotspot(x, y);
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
setPressed(true);
|
|
|
|
}
|
|
|
|
return pressed;
|
|
|
|
} else if (pressed) {
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_MOVE && !cancelRect.contains(x, y)) {
|
|
|
|
setPressed(false);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (event.getAction() == MotionEvent.ACTION_UP && cancelRect.contains(x, y)) {
|
|
|
|
if (hasRecordVideo && videoSendButton.getTag() != null) {
|
|
|
|
CameraController.getInstance().cancelOnInitRunnable(onFinishInitCameraRunnable);
|
|
|
|
delegate.needStartRecordVideo(5, true, 0);
|
|
|
|
} else {
|
|
|
|
delegate.needStartRecordAudio(0);
|
|
|
|
MediaController.getInstance().stopRecording(0, false, 0);
|
|
|
|
}
|
|
|
|
recordingAudioVideo = false;
|
|
|
|
updateRecordIntefrace(RECORD_STATE_CANCEL);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return pressed;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean smallSize;
|
|
|
|
|
|
|
|
public SlideTextView(@NonNull Context context) {
|
|
|
|
super(context);
|
|
|
|
smallSize = AndroidUtilities.displaySize.x <= AndroidUtilities.dp(320);
|
|
|
|
grayPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
grayPaint.setTextSize(AndroidUtilities.dp(smallSize ? 13 : 15));
|
|
|
|
|
|
|
|
bluePaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
bluePaint.setTextSize(AndroidUtilities.dp(15));
|
|
|
|
|
|
|
|
bluePaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
|
|
|
|
arrowPaint.setColor(Theme.getColor(Theme.key_chat_messagePanelIcons));
|
|
|
|
arrowPaint.setStyle(Paint.Style.STROKE);
|
|
|
|
arrowPaint.setStrokeWidth(AndroidUtilities.dpf2(smallSize ? 1f : 1.6f));
|
|
|
|
arrowPaint.setStrokeCap(Paint.Cap.ROUND);
|
|
|
|
arrowPaint.setStrokeJoin(Paint.Join.ROUND);
|
|
|
|
|
|
|
|
slideToCancelString = LocaleController.getString("SlideToCancel", R.string.SlideToCancel);
|
|
|
|
slideToCancelString = slideToCancelString.charAt(0) + slideToCancelString.substring(1).toLowerCase();
|
|
|
|
|
|
|
|
cancelString = LocaleController.getString("Cancel", R.string.Cancel).toUpperCase();
|
|
|
|
|
|
|
|
cancelCharOffset = slideToCancelString.indexOf(cancelString);
|
|
|
|
|
|
|
|
updateColors();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateColors() {
|
|
|
|
grayPaint.setColor(Theme.getColor(Theme.key_chat_recordTime));
|
|
|
|
bluePaint.setColor(Theme.getColor(Theme.key_chat_recordVoiceCancel));
|
|
|
|
slideToAlpha = grayPaint.getAlpha();
|
|
|
|
cancelAlpha = bluePaint.getAlpha();
|
|
|
|
selectableBackground = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(60), 0, ColorUtils.setAlphaComponent(Theme.getColor(Theme.key_chat_recordVoiceCancel), 26));
|
|
|
|
selectableBackground.setCallback(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void drawableStateChanged() {
|
|
|
|
super.drawableStateChanged();
|
|
|
|
selectableBackground.setState(getDrawableState());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean verifyDrawable(Drawable drawable) {
|
|
|
|
return selectableBackground == drawable || super.verifyDrawable(drawable);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void jumpDrawablesToCurrentState() {
|
|
|
|
super.jumpDrawablesToCurrentState();
|
|
|
|
if (selectableBackground != null) {
|
|
|
|
selectableBackground.jumpToCurrentState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("DrawAllocation")
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
slideToCancelWidth = grayPaint.measureText(slideToCancelString);
|
|
|
|
cancelWidth = bluePaint.measureText(cancelString);
|
|
|
|
lastUpdateTime = System.currentTimeMillis();
|
|
|
|
|
|
|
|
int heightHalf = getMeasuredHeight() >> 1;
|
|
|
|
arrowPath.reset();
|
|
|
|
if (smallSize) {
|
|
|
|
arrowPath.setLastPoint(AndroidUtilities.dpf2(2.5f), heightHalf - AndroidUtilities.dpf2(3.12f));
|
|
|
|
arrowPath.lineTo(0, heightHalf);
|
|
|
|
arrowPath.lineTo(AndroidUtilities.dpf2(2.5f), heightHalf + AndroidUtilities.dpf2(3.12f));
|
|
|
|
} else {
|
|
|
|
arrowPath.setLastPoint(AndroidUtilities.dpf2(4f), heightHalf - AndroidUtilities.dpf2(5f));
|
|
|
|
arrowPath.lineTo(0, heightHalf);
|
|
|
|
arrowPath.lineTo(AndroidUtilities.dpf2(4f), heightHalf + AndroidUtilities.dpf2(5f));
|
|
|
|
}
|
|
|
|
|
|
|
|
slideToLayout = new StaticLayout(slideToCancelString, grayPaint, (int) slideToCancelWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
cancelLayout = new StaticLayout(cancelString, bluePaint, (int) cancelWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
if (slideToLayout == null || cancelLayout == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int w = cancelLayout.getWidth() + AndroidUtilities.dp(16);
|
|
|
|
|
|
|
|
grayPaint.setColor(Theme.getColor(Theme.key_chat_recordTime));
|
|
|
|
grayPaint.setAlpha((int) (slideToAlpha * (1f - cancelToProgress) * slideProgress));
|
|
|
|
bluePaint.setAlpha((int) (cancelAlpha * cancelToProgress));
|
|
|
|
arrowPaint.setColor(grayPaint.getColor());
|
|
|
|
|
|
|
|
if (smallSize) {
|
|
|
|
xOffset = AndroidUtilities.dp(16);
|
|
|
|
} else {
|
|
|
|
long dt = (System.currentTimeMillis() - lastUpdateTime);
|
|
|
|
lastUpdateTime = System.currentTimeMillis();
|
|
|
|
if (cancelToProgress == 0 && slideProgress > 0.8f) {
|
|
|
|
if (moveForward) {
|
|
|
|
xOffset += (AndroidUtilities.dp(3) / 250f) * dt;
|
|
|
|
if (xOffset > AndroidUtilities.dp(6)) {
|
|
|
|
xOffset = AndroidUtilities.dp(6);
|
|
|
|
moveForward = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
xOffset -= (AndroidUtilities.dp(3) / 250f) * dt;
|
|
|
|
if (xOffset < -AndroidUtilities.dp(6)) {
|
|
|
|
xOffset = -AndroidUtilities.dp(6);
|
|
|
|
moveForward = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean enableTransition = cancelCharOffset >= 0;
|
|
|
|
|
|
|
|
int slideX = (int) ((getMeasuredWidth() - slideToCancelWidth) / 2) + AndroidUtilities.dp(5);
|
|
|
|
int cancelX = (int) ((getMeasuredWidth() - cancelWidth) / 2);
|
|
|
|
float offset = enableTransition ? slideToLayout.getPrimaryHorizontal(cancelCharOffset) : 0;
|
|
|
|
float cancelDiff = enableTransition ? slideX + offset - cancelX : 0;
|
|
|
|
float x = slideX + xOffset * (1f - cancelToProgress) * slideProgress - cancelDiff * cancelToProgress + AndroidUtilities.dp(16);
|
|
|
|
|
|
|
|
float offsetY = enableTransition ? 0 : cancelToProgress * AndroidUtilities.dp(12);
|
|
|
|
|
|
|
|
if (cancelToProgress != 1) {
|
|
|
|
int slideDelta = (int) (-getMeasuredWidth() / 4 * (1f - slideProgress));
|
|
|
|
canvas.save();
|
|
|
|
canvas.clipRect(recordTimerView.getLeftProperty() + AndroidUtilities.dp(4), 0, getMeasuredWidth(), getMeasuredHeight());
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate((int) x - (smallSize ? AndroidUtilities.dp(7) : AndroidUtilities.dp(10)) + slideDelta, offsetY);
|
|
|
|
canvas.drawPath(arrowPath, arrowPaint);
|
|
|
|
canvas.restore();
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate((int) x + slideDelta, (getMeasuredHeight() - slideToLayout.getHeight()) / 2f + offsetY);
|
|
|
|
slideToLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cancelToProgress > 0) {
|
|
|
|
selectableBackground.setBounds(
|
|
|
|
getMeasuredWidth() / 2 - w, getMeasuredHeight() / 2 - w,
|
|
|
|
getMeasuredWidth() / 2 + w, getMeasuredHeight() / 2 + w
|
|
|
|
);
|
|
|
|
selectableBackground.draw(canvas);
|
|
|
|
|
|
|
|
float xi;
|
|
|
|
float yi = (getMeasuredHeight() - cancelLayout.getHeight()) / 2f;
|
|
|
|
if (!enableTransition) {
|
|
|
|
yi -= (AndroidUtilities.dp(12) - offsetY);
|
|
|
|
}
|
|
|
|
if (enableTransition) {
|
|
|
|
xi = x + offset;
|
|
|
|
} else {
|
|
|
|
xi = cancelX;
|
|
|
|
}
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(xi, yi);
|
|
|
|
cancelRect.set((int) xi, (int) yi, (int) (xi + cancelLayout.getWidth()), (int) (yi + cancelLayout.getHeight()));
|
|
|
|
cancelRect.inset(-AndroidUtilities.dp(16), -AndroidUtilities.dp(16));
|
|
|
|
cancelLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
} else {
|
|
|
|
setPressed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cancelToProgress != 1) {
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public void setCancelToProgress(float cancelToProgress) {
|
|
|
|
this.cancelToProgress = cancelToProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Keep
|
|
|
|
public float getSlideToCancelWidth() {
|
|
|
|
return slideToCancelWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSlideX(float v) {
|
|
|
|
slideProgress = v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class TimerView extends View {
|
|
|
|
boolean isRunning;
|
|
|
|
boolean stoppedInternal;
|
|
|
|
String oldString;
|
|
|
|
long startTime;
|
|
|
|
long stopTime;
|
2020-07-26 10:03:38 +02:00
|
|
|
long lastSendTypingTime;
|
2020-03-30 14:00:09 +02:00
|
|
|
|
|
|
|
SpannableStringBuilder replaceIn = new SpannableStringBuilder();
|
|
|
|
SpannableStringBuilder replaceOut = new SpannableStringBuilder();
|
|
|
|
SpannableStringBuilder replaceStable = new SpannableStringBuilder();
|
|
|
|
|
|
|
|
StaticLayout inLayout;
|
|
|
|
StaticLayout outLayout;
|
|
|
|
|
|
|
|
float replaceTransition;
|
|
|
|
|
|
|
|
final TextPaint textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
|
|
|
|
final float replaceDistance = AndroidUtilities.dp(15);
|
|
|
|
float left;
|
|
|
|
|
|
|
|
|
|
|
|
public TimerView(Context context) {
|
|
|
|
super(context);
|
|
|
|
textPaint.setTextSize(AndroidUtilities.dp(15));
|
|
|
|
textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
updateColors();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void start() {
|
|
|
|
isRunning = true;
|
|
|
|
startTime = System.currentTimeMillis();
|
2020-07-26 10:03:38 +02:00
|
|
|
lastSendTypingTime = startTime;
|
2020-03-30 14:00:09 +02:00
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void stop() {
|
|
|
|
if (isRunning) {
|
|
|
|
isRunning = false;
|
|
|
|
if (startTime > 0) {
|
|
|
|
stopTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
invalidate();
|
|
|
|
}
|
2020-07-26 10:03:38 +02:00
|
|
|
lastSendTypingTime = 0;
|
2020-03-30 14:00:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("DrawAllocation")
|
|
|
|
@Override
|
|
|
|
protected void onDraw(Canvas canvas) {
|
2020-07-26 10:03:38 +02:00
|
|
|
long currentTimeMillis = System.currentTimeMillis();
|
|
|
|
long t = isRunning ? (currentTimeMillis - startTime) : stopTime - startTime;
|
2020-03-30 14:00:09 +02:00
|
|
|
long time = t / 1000;
|
|
|
|
int ms = (int) (t % 1000L) / 10;
|
|
|
|
|
|
|
|
if (videoSendButton != null && videoSendButton.getTag() != null) {
|
|
|
|
if (t >= 59500 && !stoppedInternal) {
|
|
|
|
startedDraggingX = -1;
|
|
|
|
delegate.needStartRecordVideo(3, true, 0);
|
|
|
|
stoppedInternal = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-26 10:03:38 +02:00
|
|
|
if (isRunning && currentTimeMillis > lastSendTypingTime + 5000) {
|
|
|
|
lastSendTypingTime = currentTimeMillis;
|
2020-09-30 15:48:47 +02:00
|
|
|
MessagesController.getInstance(currentAccount).sendTyping(dialog_id, getThreadMessageId(), videoSendButton != null && videoSendButton.getTag() != null ? 7 : 1, 0);
|
2020-07-26 10:03:38 +02:00
|
|
|
}
|
|
|
|
|
2020-03-30 14:00:09 +02:00
|
|
|
String newString;
|
|
|
|
if (time / 60 >= 60) {
|
|
|
|
newString = String.format(Locale.US, "%01d:%02d:%02d,%d", (time / 60) / 60, (time / 60) % 60, time % 60, ms / 10);
|
|
|
|
} else {
|
|
|
|
newString = String.format(Locale.US, "%01d:%02d,%d", time / 60, time % 60, ms / 10);
|
|
|
|
}
|
|
|
|
if (newString.length() >= 3 && oldString != null && oldString.length() >= 3 && newString.length() == oldString.length() && newString.charAt(newString.length() - 3) != oldString.charAt(newString.length() - 3)) {
|
|
|
|
int n = newString.length();
|
|
|
|
|
|
|
|
replaceIn.clear();
|
|
|
|
replaceOut.clear();
|
|
|
|
replaceStable.clear();
|
|
|
|
replaceIn.append(newString);
|
|
|
|
replaceOut.append(oldString);
|
|
|
|
replaceStable.append(newString);
|
|
|
|
|
|
|
|
int inLast = -1;
|
|
|
|
int inCount = 0;
|
|
|
|
int outLast = -1;
|
|
|
|
int outCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < n - 1; i++) {
|
|
|
|
if (oldString.charAt(i) != newString.charAt(i)) {
|
|
|
|
if (outCount == 0) {
|
|
|
|
outLast = i;
|
|
|
|
}
|
|
|
|
outCount++;
|
|
|
|
|
|
|
|
if (inCount != 0) {
|
|
|
|
EmptyStubSpan span = new EmptyStubSpan();
|
|
|
|
if (i == n - 2) {
|
|
|
|
inCount++;
|
|
|
|
}
|
|
|
|
replaceIn.setSpan(span, inLast, inLast + inCount, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
replaceOut.setSpan(span, inLast, inLast + inCount, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
inCount = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (inCount == 0) {
|
|
|
|
inLast = i;
|
|
|
|
}
|
|
|
|
inCount++;
|
|
|
|
if (outCount != 0) {
|
|
|
|
replaceStable.setSpan(new EmptyStubSpan(), outLast, outLast + outCount, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
outCount = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inCount != 0) {
|
|
|
|
EmptyStubSpan span = new EmptyStubSpan();
|
|
|
|
replaceIn.setSpan(span, inLast, inLast + inCount + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
replaceOut.setSpan(span, inLast, inLast + inCount + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
}
|
|
|
|
if (outCount != 0) {
|
|
|
|
replaceStable.setSpan(new EmptyStubSpan(), outLast, outLast + outCount, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
|
}
|
|
|
|
|
|
|
|
inLayout = new StaticLayout(replaceIn, textPaint, getMeasuredWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
outLayout = new StaticLayout(replaceOut, textPaint, getMeasuredWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
|
|
|
|
replaceTransition = 1f;
|
|
|
|
} else {
|
|
|
|
if (replaceStable == null) {
|
|
|
|
replaceStable = new SpannableStringBuilder(newString);
|
|
|
|
}
|
|
|
|
if (replaceStable.length() == 0 || replaceStable.length() != newString.length()) {
|
|
|
|
replaceStable.clear();
|
|
|
|
replaceStable.append(newString);
|
|
|
|
} else {
|
|
|
|
replaceStable.replace(replaceStable.length() - 1, replaceStable.length(), newString, newString.length() - 1 - (newString.length() - replaceStable.length()), newString.length());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (replaceTransition != 0) {
|
|
|
|
replaceTransition -= 0.15f;
|
|
|
|
if (replaceTransition < 0f) {
|
|
|
|
replaceTransition = 0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float y = getMeasuredHeight() / 2;
|
|
|
|
float x = 0;
|
|
|
|
|
|
|
|
if (replaceTransition == 0) {
|
|
|
|
replaceStable.clearSpans();
|
|
|
|
StaticLayout staticLayout = new StaticLayout(replaceStable, textPaint, getMeasuredWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
canvas.save();
|
|
|
|
canvas.translate(x, y - staticLayout.getHeight() / 2f);
|
|
|
|
staticLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
left = x + staticLayout.getLineWidth(0);
|
|
|
|
} else {
|
|
|
|
if (inLayout != null) {
|
|
|
|
canvas.save();
|
|
|
|
textPaint.setAlpha((int) (255 * (1f - replaceTransition)));
|
|
|
|
canvas.translate(x, y - inLayout.getHeight() / 2f - (replaceDistance * replaceTransition));
|
|
|
|
inLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outLayout != null) {
|
|
|
|
canvas.save();
|
|
|
|
textPaint.setAlpha((int) (255 * replaceTransition));
|
|
|
|
canvas.translate(x, y - outLayout.getHeight() / 2f + (replaceDistance * (1f - replaceTransition)));
|
|
|
|
outLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
canvas.save();
|
|
|
|
textPaint.setAlpha(255);
|
|
|
|
StaticLayout staticLayout = new StaticLayout(replaceStable, textPaint, getMeasuredWidth(), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
|
|
|
|
canvas.translate(x, y - staticLayout.getHeight() / 2f);
|
|
|
|
staticLayout.draw(canvas);
|
|
|
|
canvas.restore();
|
|
|
|
left = x + staticLayout.getLineWidth(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
oldString = newString;
|
|
|
|
|
|
|
|
if (isRunning || replaceTransition != 0) {
|
|
|
|
invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateColors() {
|
|
|
|
textPaint.setColor(Theme.getColor(Theme.key_chat_recordTime));
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getLeftProperty() {
|
|
|
|
return left;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void reset() {
|
|
|
|
isRunning = false;
|
|
|
|
stopTime = startTime = 0;
|
|
|
|
stoppedInternal = false;
|
|
|
|
}
|
|
|
|
}
|
2020-12-23 08:48:30 +01:00
|
|
|
|
|
|
|
protected boolean pannelAnimationEnabled() {
|
|
|
|
return true;
|
|
|
|
}
|
2021-03-19 11:25:58 +01:00
|
|
|
|
|
|
|
public RecordCircle getRecordCicle() {
|
|
|
|
return recordCircle;
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|