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
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
import android.animation.Animator;
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
import android.animation.ObjectAnimator;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.KeyguardManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.content.pm.PackageManager;
|
2014-07-10 02:15:58 +02:00
|
|
|
import android.content.res.Configuration;
|
2015-10-29 18:10:07 +01:00
|
|
|
import android.net.Uri;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.PowerManager;
|
2014-11-17 03:44:57 +01:00
|
|
|
import android.text.TextUtils;
|
2014-07-10 02:15:58 +02:00
|
|
|
import android.util.AttributeSet;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.util.TypedValue;
|
2014-07-10 14:14:36 +02:00
|
|
|
import android.view.Gravity;
|
2014-07-10 02:15:58 +02:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.VelocityTracker;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2014-07-10 02:15:58 +02:00
|
|
|
import android.view.ViewTreeObserver;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.view.WindowManager;
|
2014-07-10 02:15:58 +02:00
|
|
|
import android.widget.FrameLayout;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.widget.LinearLayout;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.widget.RelativeLayout;
|
2017-03-31 01:58:05 +02:00
|
|
|
import android.widget.ScrollView;
|
2014-07-03 00:39:05 +02:00
|
|
|
import android.widget.TextView;
|
|
|
|
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
|
|
|
import org.telegram.messenger.ContactsController;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.DownloadController;
|
2019-05-14 14:08:05 +02:00
|
|
|
import org.telegram.messenger.ImageLocation;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
import org.telegram.messenger.MediaController;
|
|
|
|
import org.telegram.messenger.MessagesController;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.NotificationsController;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.SendMessagesHelper;
|
|
|
|
import org.telegram.messenger.SharedConfig;
|
|
|
|
import org.telegram.messenger.UserConfig;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.UserObject;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
2014-08-22 16:24:33 +02:00
|
|
|
import org.telegram.messenger.FileLoader;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.messenger.FileLog;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2014-07-03 00:39:05 +02:00
|
|
|
import org.telegram.messenger.R;
|
2018-07-30 04:07:02 +02:00
|
|
|
import org.telegram.messenger.WebFile;
|
2015-09-24 22:52:02 +02:00
|
|
|
import org.telegram.tgnet.ConnectionsManager;
|
|
|
|
import org.telegram.tgnet.TLRPC;
|
|
|
|
import org.telegram.messenger.MessageObject;
|
2014-11-13 21:10:14 +01:00
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenuItem;
|
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.AvatarDrawable;
|
|
|
|
import org.telegram.ui.Components.BackupImageView;
|
|
|
|
import org.telegram.ui.Components.ChatActivityEnterView;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.PlayingGameDrawable;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.PopupAudioView;
|
2015-05-03 13:48:36 +02:00
|
|
|
import org.telegram.ui.Components.RecordStatusDrawable;
|
2017-07-08 18:32:04 +02:00
|
|
|
import org.telegram.ui.Components.RoundStatusDrawable;
|
2017-03-31 01:58:05 +02:00
|
|
|
import org.telegram.ui.Components.SendingFileDrawable;
|
2015-06-29 19:12:11 +02:00
|
|
|
import org.telegram.ui.Components.SizeNotifierFrameLayout;
|
2016-04-22 15:49:00 +02:00
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
2017-07-08 18:32:04 +02:00
|
|
|
import org.telegram.ui.Components.StatusDrawable;
|
2014-12-01 18:56:31 +01:00
|
|
|
import org.telegram.ui.Components.TypingDotsDrawable;
|
2014-07-10 02:15:58 +02:00
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.util.ArrayList;
|
2014-07-03 00:39:05 +02:00
|
|
|
|
|
|
|
public class PopupNotificationActivity extends Activity implements NotificationCenter.NotificationCenterDelegate {
|
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
private ActionBar actionBar;
|
2014-07-03 00:39:05 +02:00
|
|
|
private ChatActivityEnterView chatActivityEnterView;
|
|
|
|
private BackupImageView avatarImageView;
|
2014-11-17 03:44:57 +01:00
|
|
|
private TextView nameTextView;
|
|
|
|
private TextView onlineTextView;
|
|
|
|
private FrameLayout avatarContainer;
|
2014-07-03 00:39:05 +02:00
|
|
|
private TextView countText;
|
2014-07-10 02:15:58 +02:00
|
|
|
private ViewGroup messageContainer;
|
|
|
|
private ViewGroup centerView;
|
|
|
|
private ViewGroup leftView;
|
|
|
|
private ViewGroup rightView;
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
private ViewGroup centerButtonsView;
|
|
|
|
private ViewGroup leftButtonsView;
|
|
|
|
private ViewGroup rightButtonsView;
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
private RelativeLayout popupContainer;
|
2015-01-02 23:15:07 +01:00
|
|
|
private ArrayList<ViewGroup> textViews = new ArrayList<>();
|
|
|
|
private ArrayList<ViewGroup> imageViews = new ArrayList<>();
|
|
|
|
private ArrayList<ViewGroup> audioViews = new ArrayList<>();
|
2014-07-10 02:15:58 +02:00
|
|
|
private VelocityTracker velocityTracker = null;
|
2017-07-08 18:32:04 +02:00
|
|
|
private StatusDrawable[] statusDrawables = new StatusDrawable[5];
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private final static int id_chat_compose_panel = 1000;
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
private int classGuid;
|
2018-07-30 04:07:02 +02:00
|
|
|
private int lastResumedAccount = -1;
|
2014-07-03 00:39:05 +02:00
|
|
|
private TLRPC.User currentUser;
|
|
|
|
private TLRPC.Chat currentChat;
|
|
|
|
private boolean finished = false;
|
|
|
|
private CharSequence lastPrintString;
|
|
|
|
private MessageObject currentMessageObject = null;
|
|
|
|
private int currentMessageNum = 0;
|
|
|
|
private PowerManager.WakeLock wakeLock = null;
|
2014-07-10 02:15:58 +02:00
|
|
|
private boolean animationInProgress = false;
|
|
|
|
private long animationStartTime = 0;
|
|
|
|
private float moveStartX = -1;
|
|
|
|
private boolean startedMoving = false;
|
|
|
|
private Runnable onAnimationEndRunnable = null;
|
2016-10-11 13:57:01 +02:00
|
|
|
private boolean isReply;
|
|
|
|
private ArrayList<MessageObject> popupMessages = new ArrayList<>();
|
2014-07-10 02:15:58 +02:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
private class FrameLayoutTouch extends FrameLayout {
|
2014-07-10 02:15:58 +02:00
|
|
|
public FrameLayoutTouch(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public FrameLayoutTouch(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public FrameLayoutTouch(Context context, AttributeSet attrs, int defStyle) {
|
|
|
|
super(context, attrs, defStyle);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
|
|
|
return checkTransitionAnimation() || ((PopupNotificationActivity) getContext()).onTouchEventMy(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent ev) {
|
|
|
|
return checkTransitionAnimation() || ((PopupNotificationActivity) getContext()).onTouchEventMy(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
2017-03-31 01:58:05 +02:00
|
|
|
((PopupNotificationActivity) getContext()).onTouchEventMy(null);
|
2014-07-10 02:15:58 +02:00
|
|
|
super.requestDisallowInterceptTouchEvent(disallowIntercept);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
2017-03-31 01:58:05 +02:00
|
|
|
Theme.createChatResources(this, false);
|
2015-07-22 20:56:37 +02:00
|
|
|
|
2019-12-31 14:08:08 +01:00
|
|
|
AndroidUtilities.fillStatusBarHeight(this);
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
|
|
|
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.messagePlayingDidReset);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(a).addObserver(this, NotificationCenter.contactsDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.pushMessagesUpdated);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
classGuid = ConnectionsManager.generateClassGuid();
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
statusDrawables[0] = new TypingDotsDrawable();
|
|
|
|
statusDrawables[1] = new RecordStatusDrawable();
|
|
|
|
statusDrawables[2] = new SendingFileDrawable();
|
|
|
|
statusDrawables[3] = new PlayingGameDrawable();
|
|
|
|
statusDrawables[4] = new RoundStatusDrawable();
|
2014-09-24 04:17:27 +02:00
|
|
|
|
2015-06-29 19:12:11 +02:00
|
|
|
SizeNotifierFrameLayout contentView = new SizeNotifierFrameLayout(this) {
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
|
|
|
int heightMode = MeasureSpec.getMode(heightMeasureSpec);
|
|
|
|
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
|
|
|
|
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
|
|
|
|
|
|
|
|
setMeasuredDimension(widthSize, heightSize);
|
|
|
|
|
|
|
|
int keyboardSize = getKeyboardHeight();
|
|
|
|
|
|
|
|
if (keyboardSize <= AndroidUtilities.dp(20)) {
|
|
|
|
heightSize -= chatActivityEnterView.getEmojiPadding();
|
|
|
|
}
|
|
|
|
|
|
|
|
int childCount = getChildCount();
|
|
|
|
for (int i = 0; i < childCount; i++) {
|
|
|
|
View child = getChildAt(i);
|
|
|
|
if (child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (chatActivityEnterView.isPopupView(child)) {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
|
2015-10-29 18:10:07 +01:00
|
|
|
} else if (chatActivityEnterView.isRecordCircle(child)) {
|
|
|
|
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
|
2015-06-29 19:12:11 +02:00
|
|
|
} else {
|
|
|
|
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.max(AndroidUtilities.dp(10), heightSize + AndroidUtilities.dp(2)), MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
final int count = getChildCount();
|
|
|
|
|
|
|
|
int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) ? chatActivityEnterView.getEmojiPadding() : 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
final View child = getChildAt(i);
|
|
|
|
if (child.getVisibility() == GONE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
|
|
|
|
|
|
|
int width = child.getMeasuredWidth();
|
|
|
|
int height = child.getMeasuredHeight();
|
|
|
|
|
|
|
|
int childLeft;
|
|
|
|
int childTop;
|
|
|
|
|
|
|
|
int gravity = lp.gravity;
|
|
|
|
if (gravity == -1) {
|
|
|
|
gravity = Gravity.TOP | Gravity.LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
|
|
|
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
|
|
|
|
|
|
|
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
|
|
|
|
case Gravity.CENTER_HORIZONTAL:
|
|
|
|
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.RIGHT:
|
|
|
|
childLeft = r - width - lp.rightMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.LEFT:
|
|
|
|
default:
|
|
|
|
childLeft = lp.leftMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (verticalGravity) {
|
|
|
|
case Gravity.TOP:
|
|
|
|
childTop = lp.topMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.CENTER_VERTICAL:
|
|
|
|
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
|
|
|
|
break;
|
|
|
|
case Gravity.BOTTOM:
|
|
|
|
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
childTop = lp.topMargin;
|
|
|
|
}
|
|
|
|
if (chatActivityEnterView.isPopupView(child)) {
|
|
|
|
childTop = paddingBottom != 0 ? getMeasuredHeight() - paddingBottom : getMeasuredHeight();
|
2015-10-29 18:10:07 +01:00
|
|
|
} else if (chatActivityEnterView.isRecordCircle(child)) {
|
|
|
|
childTop = popupContainer.getTop() + popupContainer.getMeasuredHeight() - child.getMeasuredHeight() - lp.bottomMargin;
|
|
|
|
childLeft = popupContainer.getLeft() + popupContainer.getMeasuredWidth() - child.getMeasuredWidth() - lp.rightMargin;
|
2015-06-29 19:12:11 +02:00
|
|
|
}
|
|
|
|
child.layout(childLeft, childTop, childLeft + width, childTop + height);
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyHeightChanged();
|
|
|
|
}
|
|
|
|
};
|
2015-02-26 02:32:51 +01:00
|
|
|
setContentView(contentView);
|
|
|
|
contentView.setBackgroundColor(0x99000000);
|
|
|
|
|
|
|
|
RelativeLayout relativeLayout = new RelativeLayout(this);
|
2015-06-29 19:12:11 +02:00
|
|
|
contentView.addView(relativeLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
popupContainer = new RelativeLayout(this) {
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
int w = chatActivityEnterView.getMeasuredWidth();
|
|
|
|
int h = chatActivityEnterView.getMeasuredHeight();
|
|
|
|
for (int a = 0, count; a < getChildCount(); a++) {
|
|
|
|
View v = getChildAt(a);
|
|
|
|
if (v.getTag() instanceof String) {
|
|
|
|
v.measure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(h - AndroidUtilities.dp(3), MeasureSpec.EXACTLY));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
super.onLayout(changed, l, t, r, b);
|
|
|
|
for (int a = 0, count; a < getChildCount(); a++) {
|
|
|
|
View v = getChildAt(a);
|
|
|
|
if (v.getTag() instanceof String) {
|
|
|
|
v.layout(v.getLeft(), chatActivityEnterView.getTop() + AndroidUtilities.dp(3), v.getRight(), chatActivityEnterView.getBottom());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-03-31 01:58:05 +02:00
|
|
|
popupContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
2015-06-29 19:12:11 +02:00
|
|
|
relativeLayout.addView(popupContainer, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, 240, 12, 0, 12, 0, RelativeLayout.CENTER_IN_PARENT));
|
2015-02-26 02:32:51 +01:00
|
|
|
|
|
|
|
if (chatActivityEnterView != null) {
|
|
|
|
chatActivityEnterView.onDestroy();
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
chatActivityEnterView = new ChatActivityEnterView(this, contentView, null, false);
|
2018-07-30 04:07:02 +02:00
|
|
|
chatActivityEnterView.setId(id_chat_compose_panel);
|
2015-06-29 19:12:11 +02:00
|
|
|
popupContainer.addView(chatActivityEnterView, LayoutHelper.createRelative(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, RelativeLayout.ALIGN_PARENT_BOTTOM));
|
2014-07-03 00:39:05 +02:00
|
|
|
chatActivityEnterView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() {
|
|
|
|
@Override
|
2019-09-10 12:56:11 +02:00
|
|
|
public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) {
|
2014-07-10 02:15:58 +02:00
|
|
|
if (currentMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
if (currentMessageNum >= 0 && currentMessageNum < popupMessages.size()) {
|
|
|
|
popupMessages.remove(currentMessageNum);
|
2014-09-14 01:40:36 +02:00
|
|
|
}
|
2019-09-10 12:56:11 +02:00
|
|
|
MessagesController.getInstance(currentMessageObject.currentAccount).markDialogAsRead(currentMessageObject.getDialogId(), currentMessageObject.getId(), Math.max(0, currentMessageObject.getId()), currentMessageObject.messageOwner.date, true, 0, true, 0);
|
2014-07-03 00:39:05 +02:00
|
|
|
currentMessageObject = null;
|
|
|
|
getNewMessage();
|
|
|
|
}
|
|
|
|
|
2015-01-02 23:15:07 +01:00
|
|
|
@Override
|
2015-04-09 20:00:14 +02:00
|
|
|
public void onTextChanged(CharSequence text, boolean big) {
|
2015-01-02 23:15:07 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
@Override
|
|
|
|
public void onTextSelectionChanged(int start, int end) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onTextSpansChanged(CharSequence text) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickersExpandedChange() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-08 18:32:04 +02:00
|
|
|
@Override
|
|
|
|
public void onSwitchRecordMode(boolean video) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPreAudioVideoRecord() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-03-06 02:49:31 +01:00
|
|
|
@Override
|
2016-05-25 23:49:47 +02:00
|
|
|
public void onMessageEditEnd(boolean loading) {
|
2016-03-06 02:49:31 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
public void needSendTyping() {
|
|
|
|
if (currentMessageObject != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
MessagesController.getInstance(currentMessageObject.currentAccount).sendTyping(currentMessageObject.getDialogId(), 0, classGuid);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
2014-11-19 02:23:46 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttachButtonHidden() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttachButtonShow() {
|
|
|
|
|
|
|
|
}
|
2015-01-02 23:15:07 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onWindowSizeChanged(int size) {
|
|
|
|
|
|
|
|
}
|
2016-01-11 18:19:48 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onStickersTab(boolean opened) {
|
|
|
|
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didPressedAttachButton() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-09-10 12:56:11 +02:00
|
|
|
public void needStartRecordVideo(int state, boolean notify, int scheduleDate) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needStartRecordAudio(int state) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needChangeVideoPreviewState(int state, float seekProgress) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void needShowMediaBanHint() {
|
|
|
|
|
|
|
|
}
|
2019-08-22 01:53:26 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onUpdateSlowModeButton(View button, boolean show, CharSequence time) {
|
|
|
|
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
});
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
messageContainer = new FrameLayoutTouch(this);
|
|
|
|
popupContainer.addView(messageContainer, 0);
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar = new ActionBar(this);
|
2014-11-17 03:44:57 +01:00
|
|
|
actionBar.setOccupyStatusBar(false);
|
2017-03-31 01:58:05 +02:00
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_close_white);
|
|
|
|
actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault));
|
|
|
|
actionBar.setItemsBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSelector), false);
|
2014-07-03 00:39:05 +02:00
|
|
|
popupContainer.addView(actionBar);
|
|
|
|
ViewGroup.LayoutParams layoutParams = actionBar.getLayoutParams();
|
|
|
|
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
|
actionBar.setLayoutParams(layoutParams);
|
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
ActionBarMenu menu = actionBar.createMenu();
|
2017-03-31 01:58:05 +02:00
|
|
|
ActionBarMenuItem view = menu.addItemWithWidth(2, 0, AndroidUtilities.dp(56));
|
|
|
|
countText = new TextView(this);
|
|
|
|
countText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
|
|
|
|
countText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
countText.setGravity(Gravity.CENTER);
|
|
|
|
view.addView(countText, LayoutHelper.createFrame(56, LayoutHelper.MATCH_PARENT));
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
avatarContainer = new FrameLayout(this);
|
2014-11-17 03:44:57 +01:00
|
|
|
avatarContainer.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
|
|
|
actionBar.addView(avatarContainer);
|
|
|
|
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) avatarContainer.getLayoutParams();
|
2015-05-03 13:48:36 +02:00
|
|
|
layoutParams2.height = LayoutHelper.MATCH_PARENT;
|
|
|
|
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams2.rightMargin = AndroidUtilities.dp(48);
|
|
|
|
layoutParams2.leftMargin = AndroidUtilities.dp(60);
|
|
|
|
layoutParams2.gravity = Gravity.TOP | Gravity.LEFT;
|
|
|
|
avatarContainer.setLayoutParams(layoutParams2);
|
|
|
|
|
|
|
|
avatarImageView = new BackupImageView(this);
|
2015-04-09 20:00:14 +02:00
|
|
|
avatarImageView.setRoundRadius(AndroidUtilities.dp(21));
|
2014-11-17 03:44:57 +01:00
|
|
|
avatarContainer.addView(avatarImageView);
|
|
|
|
layoutParams2 = (FrameLayout.LayoutParams) avatarImageView.getLayoutParams();
|
|
|
|
layoutParams2.width = AndroidUtilities.dp(42);
|
|
|
|
layoutParams2.height = AndroidUtilities.dp(42);
|
|
|
|
layoutParams2.topMargin = AndroidUtilities.dp(3);
|
|
|
|
avatarImageView.setLayoutParams(layoutParams2);
|
|
|
|
|
|
|
|
nameTextView = new TextView(this);
|
2017-03-31 01:58:05 +02:00
|
|
|
nameTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultTitle));
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
nameTextView.setLines(1);
|
|
|
|
nameTextView.setMaxLines(1);
|
|
|
|
nameTextView.setSingleLine(true);
|
|
|
|
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
|
|
|
nameTextView.setGravity(Gravity.LEFT);
|
|
|
|
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
avatarContainer.addView(nameTextView);
|
|
|
|
layoutParams2 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
2015-05-03 13:48:36 +02:00
|
|
|
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
|
|
|
|
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams2.leftMargin = AndroidUtilities.dp(54);
|
|
|
|
layoutParams2.bottomMargin = AndroidUtilities.dp(22);
|
|
|
|
layoutParams2.gravity = Gravity.BOTTOM;
|
|
|
|
nameTextView.setLayoutParams(layoutParams2);
|
|
|
|
|
|
|
|
onlineTextView = new TextView(this);
|
2017-03-31 01:58:05 +02:00
|
|
|
onlineTextView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubtitle));
|
2014-11-17 03:44:57 +01:00
|
|
|
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
onlineTextView.setLines(1);
|
|
|
|
onlineTextView.setMaxLines(1);
|
|
|
|
onlineTextView.setSingleLine(true);
|
|
|
|
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
|
|
|
|
onlineTextView.setGravity(Gravity.LEFT);
|
|
|
|
avatarContainer.addView(onlineTextView);
|
|
|
|
layoutParams2 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
|
2015-05-03 13:48:36 +02:00
|
|
|
layoutParams2.width = LayoutHelper.WRAP_CONTENT;
|
|
|
|
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams2.leftMargin = AndroidUtilities.dp(54);
|
|
|
|
layoutParams2.bottomMargin = AndroidUtilities.dp(4);
|
|
|
|
layoutParams2.gravity = Gravity.BOTTOM;
|
|
|
|
onlineTextView.setLayoutParams(layoutParams2);
|
2014-07-03 00:39:05 +02:00
|
|
|
|
2014-11-11 23:16:17 +01:00
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
2014-07-10 02:15:58 +02:00
|
|
|
onFinish();
|
2014-07-03 00:39:05 +02:00
|
|
|
finish();
|
|
|
|
} else if (id == 1) {
|
|
|
|
openCurrentMessage();
|
|
|
|
} else if (id == 2) {
|
2014-07-10 02:15:58 +02:00
|
|
|
switchToNextMessage();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
PowerManager pm = (PowerManager) ApplicationLoader.applicationContext.getSystemService(Context.POWER_SERVICE);
|
2014-07-03 00:39:05 +02:00
|
|
|
wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "screen");
|
2014-07-10 14:14:36 +02:00
|
|
|
wakeLock.setReferenceCounted(false);
|
2014-07-03 00:39:05 +02:00
|
|
|
|
|
|
|
handleIntent(getIntent());
|
|
|
|
}
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
@Override
|
|
|
|
public void onConfigurationChanged(Configuration newConfig) {
|
|
|
|
super.onConfigurationChanged(newConfig);
|
2016-10-11 13:57:01 +02:00
|
|
|
AndroidUtilities.checkDisplaySize(this, newConfig);
|
2014-07-10 02:15:58 +02:00
|
|
|
fixLayout();
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:39:05 +02:00
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
handleIntent(intent);
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:10:07 +01:00
|
|
|
@Override
|
|
|
|
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
if (requestCode == 3) {
|
|
|
|
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setMessage(LocaleController.getString("PermissionNoAudio", R.string.PermissionNoAudio));
|
2019-01-23 18:03:33 +01:00
|
|
|
builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
|
|
intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
|
|
|
|
startActivity(intent);
|
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e(e);
|
2015-10-29 18:10:07 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
private void switchToNextMessage() {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (popupMessages.size() > 1) {
|
|
|
|
if (currentMessageNum < popupMessages.size() - 1) {
|
2014-07-10 02:15:58 +02:00
|
|
|
currentMessageNum++;
|
|
|
|
} else {
|
|
|
|
currentMessageNum = 0;
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
currentMessageObject = popupMessages.get(currentMessageNum);
|
2014-07-10 02:15:58 +02:00
|
|
|
updateInterfaceForCurrentMessage(2);
|
2016-10-11 13:57:01 +02:00
|
|
|
countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void switchToPreviousMessage() {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (popupMessages.size() > 1) {
|
2014-07-10 02:15:58 +02:00
|
|
|
if (currentMessageNum > 0) {
|
|
|
|
currentMessageNum--;
|
|
|
|
} else {
|
2016-10-11 13:57:01 +02:00
|
|
|
currentMessageNum = popupMessages.size() - 1;
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
currentMessageObject = popupMessages.get(currentMessageNum);
|
2014-07-10 02:15:58 +02:00
|
|
|
updateInterfaceForCurrentMessage(1);
|
2016-10-11 13:57:01 +02:00
|
|
|
countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean checkTransitionAnimation() {
|
|
|
|
if (animationInProgress && animationStartTime < System.currentTimeMillis() - 400) {
|
|
|
|
animationInProgress = false;
|
|
|
|
if (onAnimationEndRunnable != null) {
|
|
|
|
onAnimationEndRunnable.run();
|
|
|
|
onAnimationEndRunnable = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return animationInProgress;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean onTouchEventMy(MotionEvent motionEvent) {
|
|
|
|
if (checkTransitionAnimation()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (motionEvent != null && motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
|
moveStartX = motionEvent.getX();
|
|
|
|
} else if (motionEvent != null && motionEvent.getAction() == MotionEvent.ACTION_MOVE) {
|
|
|
|
float x = motionEvent.getX();
|
2017-03-31 01:58:05 +02:00
|
|
|
int diff = (int) (x - moveStartX);
|
2014-07-10 02:15:58 +02:00
|
|
|
if (moveStartX != -1 && !startedMoving) {
|
|
|
|
if (Math.abs(diff) > AndroidUtilities.dp(10)) {
|
|
|
|
startedMoving = true;
|
|
|
|
moveStartX = x;
|
|
|
|
AndroidUtilities.lockOrientation(this);
|
|
|
|
diff = 0;
|
|
|
|
if (velocityTracker == null) {
|
|
|
|
velocityTracker = VelocityTracker.obtain();
|
|
|
|
} else {
|
|
|
|
velocityTracker.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (startedMoving) {
|
|
|
|
if (leftView == null && diff > 0) {
|
|
|
|
diff = 0;
|
|
|
|
}
|
|
|
|
if (rightView == null && diff < 0) {
|
|
|
|
diff = 0;
|
|
|
|
}
|
|
|
|
if (velocityTracker != null) {
|
|
|
|
velocityTracker.addMovement(motionEvent);
|
|
|
|
}
|
|
|
|
applyViewsLayoutParams(diff);
|
|
|
|
}
|
|
|
|
} else if (motionEvent == null || motionEvent.getAction() == MotionEvent.ACTION_UP || motionEvent.getAction() == MotionEvent.ACTION_CANCEL) {
|
|
|
|
if (motionEvent != null && startedMoving) {
|
2017-03-31 01:58:05 +02:00
|
|
|
int diff = (int) (motionEvent.getX() - moveStartX);
|
2014-07-10 02:15:58 +02:00
|
|
|
int width = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
|
2018-07-30 04:07:02 +02:00
|
|
|
float moveDiff = 0;
|
2014-07-10 02:15:58 +02:00
|
|
|
int forceMove = 0;
|
|
|
|
View otherView = null;
|
2018-07-30 04:07:02 +02:00
|
|
|
View otherButtonsView = null;
|
2014-07-10 02:15:58 +02:00
|
|
|
if (velocityTracker != null) {
|
|
|
|
velocityTracker.computeCurrentVelocity(1000);
|
|
|
|
if (velocityTracker.getXVelocity() >= 3500) {
|
|
|
|
forceMove = 1;
|
|
|
|
} else if (velocityTracker.getXVelocity() <= -3500) {
|
|
|
|
forceMove = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((forceMove == 1 || diff > width / 3) && leftView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
moveDiff = width - centerView.getTranslationX();
|
2014-07-10 02:15:58 +02:00
|
|
|
otherView = leftView;
|
2018-07-30 04:07:02 +02:00
|
|
|
otherButtonsView = leftButtonsView;
|
2019-01-23 18:03:33 +01:00
|
|
|
onAnimationEndRunnable = () -> {
|
|
|
|
animationInProgress = false;
|
|
|
|
switchToPreviousMessage();
|
|
|
|
AndroidUtilities.unlockOrientation(PopupNotificationActivity.this);
|
2014-07-10 02:15:58 +02:00
|
|
|
};
|
|
|
|
} else if ((forceMove == 2 || diff < -width / 3) && rightView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
moveDiff = -width - centerView.getTranslationX();
|
2014-07-10 02:15:58 +02:00
|
|
|
otherView = rightView;
|
2018-07-30 04:07:02 +02:00
|
|
|
otherButtonsView = rightButtonsView;
|
2019-01-23 18:03:33 +01:00
|
|
|
onAnimationEndRunnable = () -> {
|
|
|
|
animationInProgress = false;
|
|
|
|
switchToNextMessage();
|
|
|
|
AndroidUtilities.unlockOrientation(PopupNotificationActivity.this);
|
2014-07-10 02:15:58 +02:00
|
|
|
};
|
2018-07-30 04:07:02 +02:00
|
|
|
} else if (centerView.getTranslationX() != 0) {
|
|
|
|
moveDiff = -centerView.getTranslationX();
|
2014-07-10 02:15:58 +02:00
|
|
|
otherView = diff > 0 ? leftView : rightView;
|
2018-07-30 04:07:02 +02:00
|
|
|
otherButtonsView = diff > 0 ? leftButtonsView : rightButtonsView;
|
2019-01-23 18:03:33 +01:00
|
|
|
onAnimationEndRunnable = () -> {
|
|
|
|
animationInProgress = false;
|
|
|
|
applyViewsLayoutParams(0);
|
|
|
|
AndroidUtilities.unlockOrientation(PopupNotificationActivity.this);
|
2014-07-10 02:15:58 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
if (moveDiff != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
int time = (int) (Math.abs(moveDiff / (float) width) * 200);
|
|
|
|
ArrayList<Animator> animators = new ArrayList<>();
|
|
|
|
animators.add(ObjectAnimator.ofFloat(centerView, "translationX", centerView.getTranslationX() + moveDiff));
|
|
|
|
if (centerButtonsView != null) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(centerButtonsView, "translationX", centerButtonsView.getTranslationX() + moveDiff));
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
if (otherView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
animators.add(ObjectAnimator.ofFloat(otherView, "translationX", otherView.getTranslationX() + moveDiff));
|
|
|
|
}
|
|
|
|
if (otherButtonsView != null) {
|
|
|
|
animators.add(ObjectAnimator.ofFloat(otherButtonsView, "translationX", otherButtonsView.getTranslationX() + moveDiff));
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
animatorSet.playTogether(animators);
|
|
|
|
animatorSet.setDuration(time);
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
if (onAnimationEndRunnable != null) {
|
|
|
|
onAnimationEndRunnable.run();
|
|
|
|
onAnimationEndRunnable = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
animatorSet.start();
|
2014-07-10 02:15:58 +02:00
|
|
|
animationInProgress = true;
|
|
|
|
animationStartTime = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
applyViewsLayoutParams(0);
|
|
|
|
}
|
|
|
|
if (velocityTracker != null) {
|
|
|
|
velocityTracker.recycle();
|
|
|
|
velocityTracker = null;
|
|
|
|
}
|
|
|
|
startedMoving = false;
|
|
|
|
moveStartX = -1;
|
|
|
|
}
|
|
|
|
return startedMoving;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyViewsLayoutParams(int xOffset) {
|
2015-05-21 23:27:27 +02:00
|
|
|
FrameLayout.LayoutParams layoutParams;
|
2018-07-30 04:07:02 +02:00
|
|
|
RelativeLayout.LayoutParams rLayoutParams;
|
2014-07-10 02:15:58 +02:00
|
|
|
int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
|
|
|
|
if (leftView != null) {
|
2014-07-10 14:14:36 +02:00
|
|
|
layoutParams = (FrameLayout.LayoutParams) leftView.getLayoutParams();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (layoutParams.width != widht) {
|
|
|
|
layoutParams.width = widht;
|
|
|
|
leftView.setLayoutParams(layoutParams);
|
|
|
|
}
|
|
|
|
leftView.setTranslationX(-widht + xOffset);
|
|
|
|
}
|
|
|
|
if (leftButtonsView != null) {
|
|
|
|
leftButtonsView.setTranslationX(-widht + xOffset);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
if (centerView != null) {
|
2014-07-10 14:14:36 +02:00
|
|
|
layoutParams = (FrameLayout.LayoutParams) centerView.getLayoutParams();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (layoutParams.width != widht) {
|
|
|
|
layoutParams.width = widht;
|
|
|
|
centerView.setLayoutParams(layoutParams);
|
|
|
|
}
|
|
|
|
centerView.setTranslationX(xOffset);
|
|
|
|
}
|
|
|
|
if (centerButtonsView != null) {
|
|
|
|
centerButtonsView.setTranslationX(xOffset);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
if (rightView != null) {
|
2014-07-10 14:14:36 +02:00
|
|
|
layoutParams = (FrameLayout.LayoutParams) rightView.getLayoutParams();
|
2018-07-30 04:07:02 +02:00
|
|
|
if (layoutParams.width != widht) {
|
|
|
|
layoutParams.width = widht;
|
|
|
|
rightView.setLayoutParams(layoutParams);
|
|
|
|
}
|
|
|
|
rightView.setTranslationX(widht + xOffset);
|
|
|
|
}
|
|
|
|
if (rightButtonsView != null) {
|
|
|
|
rightButtonsView.setTranslationX(widht + xOffset);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
messageContainer.invalidate();
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private LinearLayout getButtonsViewForMessage(int num, boolean applyOffset) {
|
|
|
|
if (popupMessages.size() == 1 && (num < 0 || num >= popupMessages.size())) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (num == -1) {
|
|
|
|
num = popupMessages.size() - 1;
|
|
|
|
} else if (num == popupMessages.size()) {
|
|
|
|
num = 0;
|
|
|
|
}
|
|
|
|
LinearLayout view = null;
|
|
|
|
final MessageObject messageObject = popupMessages.get(num);
|
|
|
|
int buttonsCount = 0;
|
|
|
|
|
|
|
|
TLRPC.ReplyMarkup markup = messageObject.messageOwner.reply_markup;
|
|
|
|
|
|
|
|
if (messageObject.getDialogId() == 777000 && markup != null) {
|
|
|
|
ArrayList<TLRPC.TL_keyboardButtonRow> rows = markup.rows;
|
|
|
|
for (int a = 0, size = rows.size(); a < size; a++) {
|
|
|
|
TLRPC.TL_keyboardButtonRow row = rows.get(a);
|
|
|
|
for (int b = 0, size2 = row.buttons.size(); b < size2; b++) {
|
|
|
|
TLRPC.KeyboardButton button = row.buttons.get(b);
|
|
|
|
if (button instanceof TLRPC.TL_keyboardButtonCallback) {
|
|
|
|
buttonsCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
final int account = messageObject.currentAccount;
|
|
|
|
if (buttonsCount > 0) {
|
|
|
|
ArrayList<TLRPC.TL_keyboardButtonRow> rows = markup.rows;
|
|
|
|
for (int a = 0, size = rows.size(); a < size; a++) {
|
|
|
|
TLRPC.TL_keyboardButtonRow row = rows.get(a);
|
|
|
|
for (int b = 0, size2 = row.buttons.size(); b < size2; b++) {
|
|
|
|
TLRPC.KeyboardButton button = row.buttons.get(b);
|
|
|
|
if (button instanceof TLRPC.TL_keyboardButtonCallback) {
|
|
|
|
if (view == null) {
|
|
|
|
view = new LinearLayout(this);
|
|
|
|
view.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
|
|
|
|
view.setWeightSum(100);
|
|
|
|
view.setTag("b");
|
2019-01-23 18:03:33 +01:00
|
|
|
view.setOnTouchListener((v, event) -> true);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
TextView textView = new TextView(this);
|
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText));
|
|
|
|
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
textView.setText(button.text.toUpperCase());
|
|
|
|
textView.setTag(button);
|
|
|
|
textView.setGravity(Gravity.CENTER);
|
|
|
|
textView.setBackgroundDrawable(Theme.getSelectorDrawable(true));
|
|
|
|
view.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 100.0f / buttonsCount));
|
2019-01-23 18:03:33 +01:00
|
|
|
textView.setOnClickListener(v -> {
|
|
|
|
TLRPC.KeyboardButton button1 = (TLRPC.KeyboardButton) v.getTag();
|
|
|
|
if (button1 != null) {
|
|
|
|
SendMessagesHelper.getInstance(account).sendNotificationCallback(messageObject.getDialogId(), messageObject.getId(), button1.data);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (view != null) {
|
|
|
|
int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
|
|
|
|
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
|
|
|
|
|
|
|
|
if (applyOffset) {
|
|
|
|
if (num == currentMessageNum) {
|
|
|
|
view.setTranslationX(0);
|
|
|
|
} else if (num == currentMessageNum - 1) {
|
|
|
|
view.setTranslationX(-widht);
|
|
|
|
} else if (num == currentMessageNum + 1) {
|
|
|
|
view.setTranslationX(widht);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
popupContainer.addView(view, layoutParams);
|
|
|
|
}
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
private ViewGroup getViewForMessage(int num, boolean applyOffset) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (popupMessages.size() == 1 && (num < 0 || num >= popupMessages.size())) {
|
2014-07-10 02:15:58 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
if (num == -1) {
|
2016-10-11 13:57:01 +02:00
|
|
|
num = popupMessages.size() - 1;
|
|
|
|
} else if (num == popupMessages.size()) {
|
2014-07-10 02:15:58 +02:00
|
|
|
num = 0;
|
|
|
|
}
|
2015-05-21 23:27:27 +02:00
|
|
|
ViewGroup view;
|
2016-10-11 13:57:01 +02:00
|
|
|
MessageObject messageObject = popupMessages.get(num);
|
2019-01-23 18:03:33 +01:00
|
|
|
if ((messageObject.type == 1 || messageObject.type == 4) && !messageObject.isSecretMedia()) {
|
2014-07-10 02:15:58 +02:00
|
|
|
if (imageViews.size() > 0) {
|
|
|
|
view = imageViews.get(0);
|
|
|
|
imageViews.remove(0);
|
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
view = new FrameLayout(this);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
FrameLayout frameLayout = new FrameLayout(this);
|
|
|
|
frameLayout.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
|
|
|
frameLayout.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
|
|
|
view.addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
BackupImageView backupImageView = new BackupImageView(this);
|
|
|
|
backupImageView.setTag(311);
|
|
|
|
frameLayout.addView(backupImageView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
TextView textView = new TextView(this);
|
|
|
|
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
textView.setGravity(Gravity.CENTER);
|
|
|
|
textView.setTag(312);
|
|
|
|
frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
view.setTag(2);
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
view.setOnClickListener(v -> openCurrentMessage());
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
TextView messageText = view.findViewWithTag(312);
|
|
|
|
BackupImageView imageView = view.findViewWithTag(311);
|
2015-04-09 20:00:14 +02:00
|
|
|
imageView.setAspectFit(true);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
if (messageObject.type == 1) {
|
2015-02-01 19:51:02 +01:00
|
|
|
TLRPC.PhotoSize currentPhotoObject = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize());
|
|
|
|
TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, 100);
|
2014-12-01 18:56:31 +01:00
|
|
|
boolean photoSet = false;
|
|
|
|
if (currentPhotoObject != null) {
|
|
|
|
boolean photoExist = true;
|
|
|
|
if (messageObject.type == 1) {
|
|
|
|
File cacheFile = FileLoader.getPathToMessage(messageObject.messageOwner);
|
|
|
|
if (!cacheFile.exists()) {
|
|
|
|
photoExist = false;
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
if (!messageObject.needDrawBluredPreview()) {
|
2019-01-23 18:03:33 +01:00
|
|
|
if (photoExist || DownloadController.getInstance(messageObject.currentAccount).canDownloadMedia(messageObject)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
imageView.setImage(ImageLocation.getForObject(currentPhotoObject, messageObject.photoThumbsObject), "100_100", ImageLocation.getForObject(thumb, messageObject.photoThumbsObject), "100_100_b", currentPhotoObject.size, messageObject);
|
2014-12-01 18:56:31 +01:00
|
|
|
photoSet = true;
|
2019-01-23 18:03:33 +01:00
|
|
|
} else {
|
|
|
|
if (thumb != null) {
|
2019-05-14 14:08:05 +02:00
|
|
|
imageView.setImage(ImageLocation.getForObject(thumb, messageObject.photoThumbsObject), "100_100_b", null, null, messageObject);
|
2019-01-23 18:03:33 +01:00
|
|
|
photoSet = true;
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
if (!photoSet) {
|
|
|
|
imageView.setVisibility(View.GONE);
|
|
|
|
messageText.setVisibility(View.VISIBLE);
|
2018-07-30 04:07:02 +02:00
|
|
|
messageText.setTextSize(TypedValue.COMPLEX_UNIT_SP, SharedConfig.fontSize);
|
2014-12-01 18:56:31 +01:00
|
|
|
messageText.setText(messageObject.messageText);
|
|
|
|
} else {
|
|
|
|
imageView.setVisibility(View.VISIBLE);
|
|
|
|
messageText.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
} else if (messageObject.type == 4) {
|
|
|
|
messageText.setVisibility(View.GONE);
|
2014-07-10 02:15:58 +02:00
|
|
|
messageText.setText(messageObject.messageText);
|
|
|
|
imageView.setVisibility(View.VISIBLE);
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.GeoPoint geoPoint = messageObject.messageOwner.media.geo;
|
|
|
|
double lat = geoPoint.lat;
|
|
|
|
double lon = geoPoint._long;
|
|
|
|
|
|
|
|
if (MessagesController.getInstance(messageObject.currentAccount).mapProvider == 2) {
|
2019-05-14 14:08:05 +02:00
|
|
|
imageView.setImage(ImageLocation.getForWebFile(WebFile.createWithGeoPoint(geoPoint, 100, 100, 15, Math.min(2, (int) Math.ceil(AndroidUtilities.density)))), null, null, null, messageObject);
|
2018-07-30 04:07:02 +02:00
|
|
|
} else {
|
2019-12-31 14:08:08 +01:00
|
|
|
String currentUrl = AndroidUtilities.formapMapUrl(messageObject.currentAccount, lat, lon, 100, 100, true, 15, -1);
|
2018-07-30 04:07:02 +02:00
|
|
|
imageView.setImage(currentUrl, null, null);
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
} else if (messageObject.type == 2) {
|
2015-05-21 23:27:27 +02:00
|
|
|
PopupAudioView cell;
|
2014-07-10 02:15:58 +02:00
|
|
|
if (audioViews.size() > 0) {
|
|
|
|
view = audioViews.get(0);
|
|
|
|
audioViews.remove(0);
|
2018-07-30 04:07:02 +02:00
|
|
|
cell = view.findViewWithTag(300);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
view = new FrameLayout(this);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
FrameLayout frameLayout = new FrameLayout(this);
|
|
|
|
frameLayout.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
|
|
|
frameLayout.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
|
|
|
view.addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
FrameLayout frameLayout1 = new FrameLayout(this);
|
|
|
|
frameLayout.addView(frameLayout1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 20, 0, 20, 0));
|
|
|
|
cell = new PopupAudioView(this);
|
|
|
|
cell.setTag(300);
|
|
|
|
frameLayout1.addView(cell);
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
view.setTag(3);
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
view.setOnClickListener(v -> openCurrentMessage());
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cell.setMessageObject(messageObject);
|
2018-07-30 04:07:02 +02:00
|
|
|
if (DownloadController.getInstance(messageObject.currentAccount).canDownloadMedia(messageObject)) {
|
2014-07-10 02:15:58 +02:00
|
|
|
cell.downloadAudioIfNeed();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (textViews.size() > 0) {
|
|
|
|
view = textViews.get(0);
|
|
|
|
textViews.remove(0);
|
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
view = new FrameLayout(this);
|
2014-07-10 02:15:58 +02:00
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
ScrollView scrollView = new ScrollView(this);
|
|
|
|
scrollView.setFillViewport(true);
|
|
|
|
view.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
|
|
|
|
|
|
|
|
LinearLayout linearLayout = new LinearLayout(this);
|
|
|
|
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
|
|
|
linearLayout.setBackgroundDrawable(Theme.getSelectorDrawable(false));
|
|
|
|
scrollView.addView(linearLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));
|
|
|
|
linearLayout.setPadding(AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10), AndroidUtilities.dp(10));
|
2019-01-23 18:03:33 +01:00
|
|
|
linearLayout.setOnClickListener(v -> openCurrentMessage());
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
TextView textView = new TextView(this);
|
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
|
|
|
textView.setTag(301);
|
|
|
|
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
textView.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
textView.setGravity(Gravity.CENTER);
|
|
|
|
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
|
|
|
|
|
|
|
|
view.setTag(1);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
TextView messageText = view.findViewWithTag(301);
|
|
|
|
messageText.setTextSize(TypedValue.COMPLEX_UNIT_SP, SharedConfig.fontSize);
|
2014-07-10 02:15:58 +02:00
|
|
|
messageText.setText(messageObject.messageText);
|
|
|
|
}
|
|
|
|
if (view.getParent() == null) {
|
|
|
|
messageContainer.addView(view);
|
|
|
|
}
|
|
|
|
view.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
if (applyOffset) {
|
|
|
|
int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
|
2014-07-10 14:14:36 +02:00
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
|
|
|
|
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
2014-07-10 02:15:58 +02:00
|
|
|
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
|
|
|
layoutParams.width = widht;
|
|
|
|
if (num == currentMessageNum) {
|
2018-07-30 04:07:02 +02:00
|
|
|
view.setTranslationX(0);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (num == currentMessageNum - 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
view.setTranslationX(-widht);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (num == currentMessageNum + 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
view.setTranslationX(widht);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
view.setLayoutParams(layoutParams);
|
|
|
|
view.invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
2018-07-30 04:07:02 +02:00
|
|
|
private void reuseButtonsView(ViewGroup view) {
|
|
|
|
if (view == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
popupContainer.removeView(view);
|
|
|
|
}
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
private void reuseView(ViewGroup view) {
|
|
|
|
if (view == null) {
|
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
int tag = (Integer) view.getTag();
|
2014-07-10 02:15:58 +02:00
|
|
|
view.setVisibility(View.GONE);
|
|
|
|
if (tag == 1) {
|
|
|
|
textViews.add(view);
|
|
|
|
} else if (tag == 2) {
|
|
|
|
imageViews.add(view);
|
|
|
|
} else if (tag == 3) {
|
|
|
|
audioViews.add(view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void prepareLayouts(int move) {
|
2018-07-30 04:07:02 +02:00
|
|
|
int widht = AndroidUtilities.displaySize.x - AndroidUtilities.dp(24);
|
2014-07-10 02:15:58 +02:00
|
|
|
if (move == 0) {
|
|
|
|
reuseView(centerView);
|
|
|
|
reuseView(leftView);
|
|
|
|
reuseView(rightView);
|
2018-07-30 04:07:02 +02:00
|
|
|
reuseButtonsView(centerButtonsView);
|
|
|
|
reuseButtonsView(leftButtonsView);
|
|
|
|
reuseButtonsView(rightButtonsView);
|
2014-07-10 02:15:58 +02:00
|
|
|
for (int a = currentMessageNum - 1; a < currentMessageNum + 2; a++) {
|
|
|
|
if (a == currentMessageNum - 1) {
|
|
|
|
leftView = getViewForMessage(a, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
leftButtonsView = getButtonsViewForMessage(a, true);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (a == currentMessageNum) {
|
|
|
|
centerView = getViewForMessage(a, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
centerButtonsView = getButtonsViewForMessage(a, true);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (a == currentMessageNum + 1) {
|
|
|
|
rightView = getViewForMessage(a, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
rightButtonsView = getButtonsViewForMessage(a, true);
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (move == 1) {
|
|
|
|
reuseView(rightView);
|
2018-07-30 04:07:02 +02:00
|
|
|
reuseButtonsView(rightButtonsView);
|
2014-07-10 02:15:58 +02:00
|
|
|
rightView = centerView;
|
|
|
|
centerView = leftView;
|
|
|
|
leftView = getViewForMessage(currentMessageNum - 1, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
rightButtonsView = centerButtonsView;
|
|
|
|
centerButtonsView = leftButtonsView;
|
|
|
|
leftButtonsView = getButtonsViewForMessage(currentMessageNum - 1, true);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (move == 2) {
|
|
|
|
reuseView(leftView);
|
2018-07-30 04:07:02 +02:00
|
|
|
reuseButtonsView(leftButtonsView);
|
2014-07-10 02:15:58 +02:00
|
|
|
leftView = centerView;
|
|
|
|
centerView = rightView;
|
|
|
|
rightView = getViewForMessage(currentMessageNum + 1, true);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
|
|
|
leftButtonsView = centerButtonsView;
|
|
|
|
centerButtonsView = rightButtonsView;
|
|
|
|
rightButtonsView = getButtonsViewForMessage(currentMessageNum + 1, true);
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (move == 3) {
|
|
|
|
if (rightView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
float offset = rightView.getTranslationX();
|
2014-07-10 02:15:58 +02:00
|
|
|
reuseView(rightView);
|
2016-06-24 12:27:15 +02:00
|
|
|
if ((rightView = getViewForMessage(currentMessageNum + 1, false)) != null) {
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) rightView.getLayoutParams();
|
|
|
|
layoutParams.width = widht;
|
|
|
|
rightView.setLayoutParams(layoutParams);
|
2018-07-30 04:07:02 +02:00
|
|
|
rightView.setTranslationX(offset);
|
2016-06-24 12:27:15 +02:00
|
|
|
rightView.invalidate();
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (rightButtonsView != null) {
|
|
|
|
float offset = rightButtonsView.getTranslationX();
|
|
|
|
reuseButtonsView(rightButtonsView);
|
|
|
|
if ((rightButtonsView = getButtonsViewForMessage(currentMessageNum + 1, false)) != null) {
|
|
|
|
rightButtonsView.setTranslationX(offset);
|
|
|
|
}
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
} else if (move == 4) {
|
|
|
|
if (leftView != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
float offset = leftView.getTranslationX();
|
2014-07-10 02:15:58 +02:00
|
|
|
reuseView(leftView);
|
2016-06-24 12:27:15 +02:00
|
|
|
if ((leftView = getViewForMessage(0, false)) != null) {
|
|
|
|
FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) leftView.getLayoutParams();
|
|
|
|
layoutParams.width = widht;
|
|
|
|
leftView.setLayoutParams(layoutParams);
|
2018-07-30 04:07:02 +02:00
|
|
|
leftView.setTranslationX(offset);
|
2016-06-24 12:27:15 +02:00
|
|
|
leftView.invalidate();
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (leftButtonsView != null) {
|
|
|
|
float offset = leftButtonsView.getTranslationX();
|
|
|
|
reuseButtonsView(leftButtonsView);
|
|
|
|
if ((leftButtonsView = getButtonsViewForMessage(0, false)) != null) {
|
|
|
|
leftButtonsView.setTranslationX(offset);
|
|
|
|
}
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fixLayout() {
|
2014-11-17 03:44:57 +01:00
|
|
|
if (avatarContainer != null) {
|
|
|
|
avatarContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreDraw() {
|
|
|
|
if (avatarContainer != null) {
|
|
|
|
avatarContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
|
|
}
|
2015-07-22 20:56:37 +02:00
|
|
|
int padding = (ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(48)) / 2;
|
2014-11-17 03:44:57 +01:00
|
|
|
avatarContainer.setPadding(avatarContainer.getPaddingLeft(), padding, avatarContainer.getPaddingRight(), padding);
|
2015-06-29 19:12:11 +02:00
|
|
|
return true;
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
2014-11-17 03:44:57 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
if (messageContainer != null) {
|
|
|
|
messageContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreDraw() {
|
|
|
|
messageContainer.getViewTreeObserver().removeOnPreDrawListener(this);
|
|
|
|
if (!checkTransitionAnimation() && !startedMoving) {
|
|
|
|
ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) messageContainer.getLayoutParams();
|
2015-07-22 20:56:37 +02:00
|
|
|
layoutParams.topMargin = ActionBar.getCurrentActionBarHeight();
|
2014-11-17 03:44:57 +01:00
|
|
|
layoutParams.bottomMargin = AndroidUtilities.dp(48);
|
|
|
|
layoutParams.width = ViewGroup.MarginLayoutParams.MATCH_PARENT;
|
|
|
|
layoutParams.height = ViewGroup.MarginLayoutParams.MATCH_PARENT;
|
|
|
|
messageContainer.setLayoutParams(layoutParams);
|
|
|
|
applyViewsLayoutParams(0);
|
|
|
|
}
|
2015-06-29 19:12:11 +02:00
|
|
|
return true;
|
2014-11-17 03:44:57 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void handleIntent(Intent intent) {
|
2016-10-11 13:57:01 +02:00
|
|
|
isReply = intent != null && intent.getBooleanExtra("force", false);
|
2018-07-30 04:07:02 +02:00
|
|
|
popupMessages.clear();
|
2016-10-11 13:57:01 +02:00
|
|
|
if (isReply) {
|
2018-07-30 04:07:02 +02:00
|
|
|
int account = intent != null ? intent.getIntExtra("currentAccount", UserConfig.selectedAccount) : UserConfig.selectedAccount;
|
|
|
|
popupMessages.addAll(NotificationsController.getInstance(account).popupReplyMessages);
|
2016-10-11 13:57:01 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
if (UserConfig.getInstance(a).isClientActivated()) {
|
|
|
|
popupMessages.addAll(NotificationsController.getInstance(a).popupMessages);
|
|
|
|
}
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
|
|
|
|
if (km.inKeyguardRestrictedInputMode() || !ApplicationLoader.isScreenOn) {
|
|
|
|
getWindow().addFlags(
|
2017-03-31 01:58:05 +02:00
|
|
|
WindowManager.LayoutParams.FLAG_DIM_BEHIND |
|
2014-07-03 00:39:05 +02:00
|
|
|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
|
|
|
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
|
|
|
|
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
|
|
|
} else {
|
|
|
|
getWindow().addFlags(
|
2017-03-31 01:58:05 +02:00
|
|
|
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
|
2014-07-03 00:39:05 +02:00
|
|
|
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
|
|
|
|
WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
|
|
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentMessageObject == null) {
|
|
|
|
currentMessageNum = 0;
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
getNewMessage();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void getNewMessage() {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (popupMessages.isEmpty()) {
|
2014-07-10 02:15:58 +02:00
|
|
|
onFinish();
|
2014-07-03 00:39:05 +02:00
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean found = false;
|
2014-07-10 02:15:58 +02:00
|
|
|
if ((currentMessageNum != 0 || chatActivityEnterView.hasText() || startedMoving) && currentMessageObject != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int a = 0, size = popupMessages.size(); a < size; a++) {
|
|
|
|
MessageObject messageObject = popupMessages.get(a);
|
|
|
|
if (messageObject.currentAccount == currentMessageObject.currentAccount && messageObject.getDialogId() == currentMessageObject.getDialogId() && messageObject.getId() == currentMessageObject.getId()) {
|
2014-07-03 00:39:05 +02:00
|
|
|
currentMessageNum = a;
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
2014-07-10 02:15:58 +02:00
|
|
|
currentMessageNum = 0;
|
2016-10-11 13:57:01 +02:00
|
|
|
currentMessageObject = popupMessages.get(0);
|
2014-07-10 02:15:58 +02:00
|
|
|
updateInterfaceForCurrentMessage(0);
|
|
|
|
} else if (startedMoving) {
|
2016-10-11 13:57:01 +02:00
|
|
|
if (currentMessageNum == popupMessages.size() - 1) {
|
2014-07-10 02:15:58 +02:00
|
|
|
prepareLayouts(3);
|
|
|
|
} else if (currentMessageNum == 1) {
|
|
|
|
prepareLayouts(4);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
countText.setText(String.format("%d/%d", currentMessageNum + 1, popupMessages.size()));
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void openCurrentMessage() {
|
|
|
|
if (currentMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
|
|
|
|
long dialog_id = currentMessageObject.getDialogId();
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((int) dialog_id != 0) {
|
|
|
|
int lower_id = (int) dialog_id;
|
2014-07-03 00:39:05 +02:00
|
|
|
if (lower_id < 0) {
|
|
|
|
intent.putExtra("chatId", -lower_id);
|
|
|
|
} else {
|
|
|
|
intent.putExtra("userId", lower_id);
|
|
|
|
}
|
|
|
|
} else {
|
2017-03-31 01:58:05 +02:00
|
|
|
intent.putExtra("encId", (int) (dialog_id >> 32));
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
intent.putExtra("currentAccount", currentMessageObject.currentAccount);
|
2014-07-03 00:39:05 +02:00
|
|
|
intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
|
2018-07-30 04:07:02 +02:00
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
2014-07-03 00:39:05 +02:00
|
|
|
startActivity(intent);
|
2014-07-10 02:15:58 +02:00
|
|
|
onFinish();
|
|
|
|
finish();
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
2014-07-10 02:15:58 +02:00
|
|
|
private void updateInterfaceForCurrentMessage(int move) {
|
2014-11-11 23:16:17 +01:00
|
|
|
if (actionBar == null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (lastResumedAccount != currentMessageObject.currentAccount) {
|
|
|
|
if (lastResumedAccount >= 0) {
|
|
|
|
ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(true, false);
|
|
|
|
}
|
|
|
|
lastResumedAccount = currentMessageObject.currentAccount;
|
|
|
|
ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(false, false);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
currentChat = null;
|
|
|
|
currentUser = null;
|
|
|
|
long dialog_id = currentMessageObject.getDialogId();
|
2018-07-30 04:07:02 +02:00
|
|
|
chatActivityEnterView.setDialogId(dialog_id, currentMessageObject.currentAccount);
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((int) dialog_id != 0) {
|
|
|
|
int lower_id = (int) dialog_id;
|
2014-07-03 00:39:05 +02:00
|
|
|
if (lower_id > 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(lower_id);
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
currentChat = MessagesController.getInstance(currentMessageObject.currentAccount).getChat(-lower_id);
|
|
|
|
currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentMessageObject.messageOwner.from_id);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance(currentMessageObject.currentAccount).getEncryptedChat((int) (dialog_id >> 32));
|
|
|
|
currentUser = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(encryptedChat.user_id);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (currentChat != null && currentUser != null) {
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setText(currentChat.title);
|
2015-06-29 19:12:11 +02:00
|
|
|
onlineTextView.setText(UserObject.getUserName(currentUser));
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
|
|
nameTextView.setCompoundDrawablePadding(0);
|
2014-07-03 00:39:05 +02:00
|
|
|
} else if (currentUser != null) {
|
2015-06-29 19:12:11 +02:00
|
|
|
nameTextView.setText(UserObject.getUserName(currentUser));
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((int) dialog_id == 0) {
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0);
|
|
|
|
nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
|
|
|
nameTextView.setCompoundDrawablePadding(0);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
|
|
|
|
prepareLayouts(move);
|
2014-07-03 00:39:05 +02:00
|
|
|
updateSubtitle();
|
|
|
|
checkAndUpdateAvatar();
|
2014-07-10 02:15:58 +02:00
|
|
|
applyViewsLayoutParams(0);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateSubtitle() {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (actionBar == null || currentMessageObject == null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (currentChat != null || currentUser == null) {
|
|
|
|
return;
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
|
2014-07-03 00:39:05 +02:00
|
|
|
if (currentUser.phone != null && currentUser.phone.length() != 0) {
|
2014-11-17 03:44:57 +01:00
|
|
|
nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
2015-06-29 19:12:11 +02:00
|
|
|
nameTextView.setText(UserObject.getUserName(currentUser));
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
} else {
|
2015-06-29 19:12:11 +02:00
|
|
|
nameTextView.setText(UserObject.getUserName(currentUser));
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentUser != null && currentUser.id == 777000) {
|
|
|
|
onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
|
2014-07-03 00:39:05 +02:00
|
|
|
} else {
|
2018-07-30 04:07:02 +02:00
|
|
|
CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
|
|
|
|
if (printString == null || printString.length() == 0) {
|
|
|
|
lastPrintString = null;
|
|
|
|
setTypingAnimation(false);
|
|
|
|
TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
|
|
|
|
if (user != null) {
|
|
|
|
currentUser = user;
|
|
|
|
}
|
|
|
|
onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
|
|
|
|
} else {
|
|
|
|
lastPrintString = printString;
|
|
|
|
onlineTextView.setText(printString);
|
|
|
|
setTypingAnimation(true);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkAndUpdateAvatar() {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentMessageObject == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
if (currentChat != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.Chat chat = MessagesController.getInstance(currentMessageObject.currentAccount).getChat(currentChat.id);
|
2014-07-03 00:39:05 +02:00
|
|
|
if (chat == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
currentChat = chat;
|
|
|
|
if (avatarImageView != null) {
|
|
|
|
AvatarDrawable avatarDrawable = new AvatarDrawable(currentChat);
|
|
|
|
avatarImageView.setImage(ImageLocation.getForChat(chat, false), "50_50", avatarDrawable, chat);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
} else if (currentUser != null) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
|
2014-07-03 00:39:05 +02:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2019-05-14 14:08:05 +02:00
|
|
|
currentUser = user;
|
|
|
|
if (avatarImageView != null) {
|
|
|
|
AvatarDrawable avatarDrawable = new AvatarDrawable(currentUser);
|
|
|
|
avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setTypingAnimation(boolean start) {
|
2014-11-11 23:16:17 +01:00
|
|
|
if (actionBar == null) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (start) {
|
|
|
|
try {
|
2018-07-30 04:07:02 +02:00
|
|
|
Integer type = MessagesController.getInstance(currentMessageObject.currentAccount).printingStringsTypes.get(currentMessageObject.getDialogId());
|
2017-07-08 18:32:04 +02:00
|
|
|
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(statusDrawables[type], null, null, null);
|
|
|
|
onlineTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4));
|
|
|
|
for (int a = 0; a < statusDrawables.length; a++) {
|
|
|
|
if (a == type) {
|
|
|
|
statusDrawables[a].start();
|
|
|
|
} else {
|
|
|
|
statusDrawables[a].stop();
|
|
|
|
}
|
2015-05-03 13:48:36 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
} else {
|
2014-11-17 03:44:57 +01:00
|
|
|
onlineTextView.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
|
|
|
|
onlineTextView.setCompoundDrawablePadding(0);
|
2017-07-08 18:32:04 +02:00
|
|
|
for (int a = 0; a < statusDrawables.length; a++) {
|
|
|
|
statusDrawables[a].stop();
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
2015-06-29 19:12:11 +02:00
|
|
|
if (chatActivityEnterView.isPopupShowing()) {
|
2015-09-02 00:14:21 +02:00
|
|
|
chatActivityEnterView.hidePopup(true);
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
super.onBackPressed();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
2018-07-30 04:07:02 +02:00
|
|
|
MediaController.getInstance().setFeedbackView(chatActivityEnterView, true);
|
2014-07-03 00:39:05 +02:00
|
|
|
if (chatActivityEnterView != null) {
|
|
|
|
chatActivityEnterView.setFieldFocused(true);
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
fixLayout();
|
2015-04-09 20:00:14 +02:00
|
|
|
checkAndUpdateAvatar();
|
2014-07-10 14:14:36 +02:00
|
|
|
wakeLock.acquire(7000);
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
overridePendingTransition(0, 0);
|
|
|
|
if (chatActivityEnterView != null) {
|
2015-09-02 00:14:21 +02:00
|
|
|
chatActivityEnterView.hidePopup(false);
|
2014-07-03 00:39:05 +02:00
|
|
|
chatActivityEnterView.setFieldFocused(false);
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
if (lastResumedAccount >= 0) {
|
|
|
|
ConnectionsManager.getInstance(lastResumedAccount).setAppPaused(true, false);
|
|
|
|
}
|
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) {
|
2014-08-22 16:24:33 +02:00
|
|
|
if (id == NotificationCenter.appDidLogout) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (account == lastResumedAccount) {
|
|
|
|
onFinish();
|
|
|
|
finish();
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.pushMessagesUpdated) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (!isReply) {
|
|
|
|
popupMessages.clear();
|
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
if (UserConfig.getInstance(a).isClientActivated()) {
|
|
|
|
popupMessages.addAll(NotificationsController.getInstance(a).popupMessages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getNewMessage();
|
|
|
|
}
|
2014-08-22 16:24:33 +02:00
|
|
|
} else if (id == NotificationCenter.updateInterfaces) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (currentMessageObject == null || account != lastResumedAccount) {
|
2014-07-03 00:39:05 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
int updateMask = (Integer) args[0];
|
2014-07-03 00:39:05 +02:00
|
|
|
if ((updateMask & MessagesController.UPDATE_MASK_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_STATUS) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_NAME) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_MEMBERS) != 0) {
|
|
|
|
updateSubtitle();
|
|
|
|
}
|
|
|
|
if ((updateMask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (updateMask & MessagesController.UPDATE_MASK_CHAT_AVATAR) != 0) {
|
|
|
|
checkAndUpdateAvatar();
|
|
|
|
}
|
|
|
|
if ((updateMask & MessagesController.UPDATE_MASK_USER_PRINT) != 0) {
|
2018-07-30 04:07:02 +02:00
|
|
|
CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
|
2014-07-03 00:39:05 +02:00
|
|
|
if (lastPrintString != null && printString == null || lastPrintString == null && printString != null || lastPrintString != null && printString != null && !lastPrintString.equals(printString)) {
|
|
|
|
updateSubtitle();
|
|
|
|
}
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
} else if (id == NotificationCenter.messagePlayingDidReset) {
|
2017-03-31 01:58:05 +02:00
|
|
|
Integer mid = (Integer) args[0];
|
2014-07-10 02:15:58 +02:00
|
|
|
if (messageContainer != null) {
|
|
|
|
int count = messageContainer.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View view = messageContainer.getChildAt(a);
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((Integer) view.getTag() == 3) {
|
2018-07-30 04:07:02 +02:00
|
|
|
PopupAudioView cell = view.findViewWithTag(300);
|
|
|
|
MessageObject messageObject = cell.getMessageObject();
|
|
|
|
if (messageObject != null && messageObject.currentAccount == account && messageObject.getId() == mid) {
|
2014-07-10 02:15:58 +02:00
|
|
|
cell.updateButtonState();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-08 18:32:04 +02:00
|
|
|
} else if (id == NotificationCenter.messagePlayingProgressDidChanged) {
|
2017-03-31 01:58:05 +02:00
|
|
|
Integer mid = (Integer) args[0];
|
2014-07-10 02:15:58 +02:00
|
|
|
if (messageContainer != null) {
|
|
|
|
int count = messageContainer.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View view = messageContainer.getChildAt(a);
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((Integer) view.getTag() == 3) {
|
2018-07-30 04:07:02 +02:00
|
|
|
PopupAudioView cell = view.findViewWithTag(300);
|
|
|
|
MessageObject messageObject = cell.getMessageObject();
|
|
|
|
if (messageObject != null && messageObject.currentAccount == account && messageObject.getId() == mid) {
|
2014-07-10 02:15:58 +02:00
|
|
|
cell.updateProgress();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.emojiDidLoad) {
|
2014-07-10 02:15:58 +02:00
|
|
|
if (messageContainer != null) {
|
|
|
|
int count = messageContainer.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View view = messageContainer.getChildAt(a);
|
2017-03-31 01:58:05 +02:00
|
|
|
if ((Integer) view.getTag() == 1) {
|
2018-07-30 04:07:02 +02:00
|
|
|
TextView textView = view.findViewWithTag(301);
|
2014-12-01 18:56:31 +01:00
|
|
|
if (textView != null) {
|
|
|
|
textView.invalidate();
|
|
|
|
}
|
|
|
|
}
|
2014-07-10 02:15:58 +02:00
|
|
|
}
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
} else if (id == NotificationCenter.contactsDidLoad) {
|
2018-07-30 04:07:02 +02:00
|
|
|
if (account == lastResumedAccount) {
|
|
|
|
updateSubtitle();
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onDestroy() {
|
|
|
|
super.onDestroy();
|
|
|
|
onFinish();
|
2018-07-30 04:07:02 +02:00
|
|
|
MediaController.getInstance().setFeedbackView(chatActivityEnterView, false);
|
2014-07-03 00:39:05 +02:00
|
|
|
if (wakeLock.isHeld()) {
|
|
|
|
wakeLock.release();
|
|
|
|
}
|
2015-03-19 00:09:45 +01:00
|
|
|
if (avatarImageView != null) {
|
|
|
|
avatarImageView.setImageDrawable(null);
|
|
|
|
}
|
2014-07-03 00:39:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected void onFinish() {
|
|
|
|
if (finished) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
finished = true;
|
2016-10-11 13:57:01 +02:00
|
|
|
if (isReply) {
|
|
|
|
popupMessages.clear();
|
|
|
|
}
|
2018-07-30 04:07:02 +02:00
|
|
|
for (int a = 0; a < UserConfig.MAX_ACCOUNT_COUNT; a++) {
|
|
|
|
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.appDidLogout);
|
|
|
|
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
|
|
|
|
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.messagePlayingDidReset);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getInstance(a).removeObserver(this, NotificationCenter.contactsDidLoad);
|
2018-07-30 04:07:02 +02:00
|
|
|
}
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.pushMessagesUpdated);
|
2019-01-23 18:03:33 +01:00
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
|
2014-07-03 00:39:05 +02:00
|
|
|
if (chatActivityEnterView != null) {
|
|
|
|
chatActivityEnterView.onDestroy();
|
|
|
|
}
|
|
|
|
if (wakeLock.isHeld()) {
|
|
|
|
wakeLock.release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|