NekoX/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java

1052 lines
48 KiB
Java
Raw Normal View History

2013-10-25 17:19:00 +02:00
/*
2019-01-23 18:03:33 +01:00
* This is the source code of Telegram for Android v. 5.x.x.
2013-10-25 17:19:00 +02:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2019-01-23 18:03:33 +01:00
* Copyright Nikolai Kudashov, 2013-2018.
2013-10-25 17:19:00 +02:00
*/
package org.telegram.ui;
2017-03-31 01:58:05 +02:00
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
2019-01-23 18:03:33 +01:00
import android.animation.StateListAnimator;
import android.annotation.SuppressLint;
2020-07-26 10:03:38 +02:00
import android.app.Dialog;
2013-10-25 17:19:00 +02:00
import android.content.Context;
import android.content.Intent;
2017-03-31 01:58:05 +02:00
import android.graphics.Canvas;
2019-01-23 18:03:33 +01:00
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.ColorDrawable;
2017-03-31 01:58:05 +02:00
import android.graphics.drawable.Drawable;
2019-07-18 15:01:39 +02:00
import android.location.Location;
2019-01-23 18:03:33 +01:00
import android.os.Build;
2013-10-25 17:19:00 +02:00
import android.os.Bundle;
2017-03-31 01:58:05 +02:00
import android.os.Vibrator;
2015-09-24 22:52:02 +02:00
import android.text.InputFilter;
2014-11-14 16:40:15 +01:00
import android.view.Gravity;
2013-10-25 17:19:00 +02:00
import android.view.View;
import android.view.ViewGroup;
2019-01-23 18:03:33 +01:00
import android.view.ViewOutlineProvider;
2014-11-14 16:40:15 +01:00
import android.widget.FrameLayout;
2019-01-23 18:03:33 +01:00
import android.widget.ImageView;
2014-11-14 16:40:15 +01:00
import android.widget.LinearLayout;
2013-10-25 17:19:00 +02:00
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ChatObject;
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.MessagesStorage;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
2013-12-20 20:25:49 +01:00
import org.telegram.messenger.FileLog;
2015-09-24 22:52:02 +02:00
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
2013-10-25 17:19:00 +02:00
import org.telegram.messenger.R;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.GroupCreateUserCell;
2014-11-13 21:10:14 +01:00
import org.telegram.ui.ActionBar.ActionBar;
2019-01-23 18:03:33 +01:00
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.ShadowSectionCell;
2019-07-18 15:01:39 +02:00
import org.telegram.ui.Cells.TextSettingsCell;
import org.telegram.ui.Components.AvatarDrawable;
2019-01-23 18:03:33 +01:00
import org.telegram.ui.Components.CombinedDrawable;
import org.telegram.ui.Components.EditTextEmoji;
2021-01-28 15:15:51 +01:00
import org.telegram.ui.Components.RLottieDrawable;
import org.telegram.ui.Components.RLottieImageView;
2020-07-26 10:03:38 +02:00
import org.telegram.ui.Components.VerticalPositionAutoAnimator;
2018-07-30 04:07:02 +02:00
import org.telegram.ui.Components.ImageUpdater;
import org.telegram.ui.Components.BackupImageView;
2014-11-13 21:10:14 +01:00
import org.telegram.ui.ActionBar.BaseFragment;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.Components.ContextProgressView;
import org.telegram.ui.Components.GroupCreateDividerItemDecoration;
import org.telegram.ui.Components.LayoutHelper;
2019-01-23 18:03:33 +01:00
import org.telegram.ui.Components.RadialProgressView;
2017-03-31 01:58:05 +02:00
import org.telegram.ui.Components.RecyclerListView;
2019-01-23 18:03:33 +01:00
import org.telegram.ui.Components.SizeNotifierFrameLayout;
2013-10-25 17:19:00 +02:00
import java.util.ArrayList;
2018-07-30 04:07:02 +02:00
import java.util.concurrent.CountDownLatch;
2013-10-25 17:19:00 +02:00
2019-05-14 14:08:05 +02:00
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
2018-07-30 04:07:02 +02:00
public class GroupCreateFinalActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ImageUpdater.ImageUpdaterDelegate {
2014-11-17 23:04:31 +01:00
2017-03-31 01:58:05 +02:00
private GroupCreateAdapter adapter;
2019-07-18 15:01:39 +02:00
private RecyclerListView listView;
2019-01-23 18:03:33 +01:00
private EditTextEmoji editText;
2017-03-31 01:58:05 +02:00
private BackupImageView avatarImage;
2019-01-23 18:03:33 +01:00
private View avatarOverlay;
2021-01-28 15:15:51 +01:00
private RLottieImageView avatarEditor;
2019-01-23 18:03:33 +01:00
private AnimatorSet avatarAnimation;
private RadialProgressView avatarProgressView;
2017-03-31 01:58:05 +02:00
private AvatarDrawable avatarDrawable;
private ContextProgressView progressView;
private AnimatorSet doneItemAnimation;
private FrameLayout editTextContainer;
2019-01-23 18:03:33 +01:00
private ImageView floatingButtonIcon;
private FrameLayout floatingButtonContainer;
private Drawable shadowDrawable;
2017-03-31 01:58:05 +02:00
2013-10-25 17:19:00 +02:00
private TLRPC.FileLocation avatar;
2019-01-23 18:03:33 +01:00
private TLRPC.FileLocation avatarBig;
2020-07-26 10:03:38 +02:00
private TLRPC.InputFile inputPhoto;
private TLRPC.InputFile inputVideo;
private String inputVideoPath;
private double videoTimestamp;
2021-09-20 07:54:41 +02:00
private ArrayList<Long> selectedContacts;
2013-10-25 17:19:00 +02:00
private boolean createAfterUpload;
private boolean donePressed;
2019-01-23 18:03:33 +01:00
private ImageUpdater imageUpdater;
2017-03-31 01:58:05 +02:00
private String nameToSet;
2019-01-23 18:03:33 +01:00
private int chatType;
2013-10-25 17:19:00 +02:00
2021-01-28 15:15:51 +01:00
private RLottieDrawable cameraDrawable;
private boolean forImport;
2019-07-18 15:01:39 +02:00
private String currentGroupCreateAddress;
private Location currentGroupCreateLocation;
2017-03-31 01:58:05 +02:00
private int reqId;
private final static int done_button = 1;
2019-06-04 12:14:50 +02:00
public interface GroupCreateFinalActivityDelegate {
void didStartChatCreation();
2021-09-20 07:54:41 +02:00
void didFinishChatCreation(GroupCreateFinalActivity fragment, long chatId);
2019-06-04 12:14:50 +02:00
void didFailChatCreation();
}
private GroupCreateFinalActivityDelegate delegate;
public GroupCreateFinalActivity(Bundle args) {
super(args);
2015-09-24 22:52:02 +02:00
chatType = args.getInt("chatType", ChatObject.CHAT_TYPE_CHAT);
2014-11-10 12:05:22 +01:00
avatarDrawable = new AvatarDrawable();
2019-07-18 15:01:39 +02:00
currentGroupCreateAddress = args.getString("address");
currentGroupCreateLocation = args.getParcelable("location");
2021-01-28 15:15:51 +01:00
forImport = args.getBoolean("forImport", false);
nameToSet = args.getString("title", null);
}
2013-10-25 17:19:00 +02:00
@Override
public boolean onFragmentCreate() {
2018-07-30 04:07:02 +02:00
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatDidCreated);
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.chatDidFailCreate);
2020-07-26 10:03:38 +02:00
imageUpdater = new ImageUpdater(true);
2018-07-30 04:07:02 +02:00
imageUpdater.parentFragment = this;
2020-07-26 10:03:38 +02:00
imageUpdater.setDelegate(this);
2021-09-20 07:54:41 +02:00
long[] contacts = getArguments().getLongArray("result");
if (contacts != null) {
selectedContacts = new ArrayList<>(contacts.length);
for (int a = 0; a < contacts.length; a++) {
selectedContacts.add(contacts[a]);
}
}
final ArrayList<Long> usersToLoad = new ArrayList<>();
2017-03-31 01:58:05 +02:00
for (int a = 0; a < selectedContacts.size(); a++) {
2021-09-20 07:54:41 +02:00
Long uid = selectedContacts.get(a);
2021-01-28 15:15:51 +01:00
if (getMessagesController().getUser(uid) == null) {
usersToLoad.add(uid);
}
}
if (!usersToLoad.isEmpty()) {
2018-07-30 04:07:02 +02:00
final CountDownLatch countDownLatch = new CountDownLatch(1);
final ArrayList<TLRPC.User> users = new ArrayList<>();
2019-01-23 18:03:33 +01:00
MessagesStorage.getInstance(currentAccount).getStorageQueue().postRunnable(() -> {
users.addAll(MessagesStorage.getInstance(currentAccount).getUsers(usersToLoad));
countDownLatch.countDown();
});
try {
2018-07-30 04:07:02 +02:00
countDownLatch.await();
} catch (Exception e) {
2017-03-31 01:58:05 +02:00
FileLog.e(e);
}
2014-10-23 17:30:35 +02:00
if (usersToLoad.size() != users.size()) {
return false;
}
if (!users.isEmpty()) {
for (TLRPC.User user : users) {
2021-01-28 15:15:51 +01:00
getMessagesController().putUser(user, true);
}
} else {
return false;
}
}
return super.onFragmentCreate();
2013-10-25 17:19:00 +02:00
}
@Override
public void onFragmentDestroy() {
super.onFragmentDestroy();
2018-07-30 04:07:02 +02:00
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.updateInterfaces);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatDidCreated);
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.chatDidFailCreate);
imageUpdater.clear();
2017-03-31 01:58:05 +02:00
if (reqId != 0) {
2018-07-30 04:07:02 +02:00
ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
2017-03-31 01:58:05 +02:00
}
2019-01-23 18:03:33 +01:00
if (editText != null) {
editText.onDestroy();
}
AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid);
2013-10-25 17:19:00 +02:00
}
2014-11-17 23:04:31 +01:00
@Override
public void onResume() {
super.onResume();
2019-01-23 18:03:33 +01:00
if (editText != null) {
editText.onResume();
}
2017-03-31 01:58:05 +02:00
if (adapter != null) {
adapter.notifyDataSetChanged();
2014-11-17 23:04:31 +01:00
}
2020-07-26 10:03:38 +02:00
imageUpdater.onResume();
2019-01-23 18:03:33 +01:00
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
}
@Override
public void onPause() {
super.onPause();
if (editText != null) {
editText.onPause();
}
2020-07-26 10:03:38 +02:00
imageUpdater.onPause();
}
@Override
public void dismissCurrentDialog() {
if (imageUpdater.dismissCurrentDialog(visibleDialog)) {
return;
}
super.dismissCurrentDialog();
}
@Override
public boolean dismissDialogOnPause(Dialog dialog) {
return imageUpdater.dismissDialogOnPause(dialog) && super.dismissDialogOnPause(dialog);
}
@Override
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
imageUpdater.onRequestPermissionsResultFragment(requestCode, permissions, grantResults);
2019-01-23 18:03:33 +01:00
}
@Override
public boolean onBackPressed() {
if (editText != null && editText.isPopupShowing()) {
editText.hidePopup(true);
return false;
}
return true;
2014-11-17 23:04:31 +01:00
}
2020-07-26 10:03:38 +02:00
@Override
protected boolean hideKeyboardOnShow() {
return false;
}
2013-10-25 17:19:00 +02:00
@Override
2015-07-22 20:56:37 +02:00
public View createView(Context context) {
2019-01-23 18:03:33 +01:00
if (editText != null) {
editText.onDestroy();
}
2015-04-09 20:00:14 +02:00
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
actionBar.setAllowOverlayTitle(true);
2017-03-31 01:58:05 +02:00
actionBar.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup));
2015-04-09 20:00:14 +02:00
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
2019-01-23 18:03:33 +01:00
}
}
});
2020-09-30 15:48:47 +02:00
SizeNotifierFrameLayout sizeNotifierFrameLayout = new SizeNotifierFrameLayout(context) {
2019-01-23 18:03:33 +01:00
2019-05-14 14:08:05 +02:00
private boolean ignoreLayout;
2019-01-23 18:03:33 +01:00
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSize = MeasureSpec.getSize(widthMeasureSpec);
int heightSize = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
2020-09-30 15:48:47 +02:00
int keyboardSize = measureKeyboardHeight();
2019-05-14 14:08:05 +02:00
if (keyboardSize > AndroidUtilities.dp(20)) {
ignoreLayout = true;
editText.hideEmojiView();
ignoreLayout = false;
}
2019-01-23 18:03:33 +01:00
2019-05-14 14:08:05 +02:00
int childCount = getChildCount();
2019-01-23 18:03:33 +01:00
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
if (child == null || child.getVisibility() == GONE || child == actionBar) {
continue;
2015-04-09 20:00:14 +02:00
}
2019-01-23 18:03:33 +01:00
if (editText != null && editText.isPopupView(child)) {
if (AndroidUtilities.isInMultiwindow || AndroidUtilities.isTablet()) {
if (AndroidUtilities.isTablet()) {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(Math.min(AndroidUtilities.dp(AndroidUtilities.isTablet() ? 200 : 320), heightSize - AndroidUtilities.statusBarHeight + getPaddingTop()), MeasureSpec.EXACTLY));
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize - AndroidUtilities.statusBarHeight + getPaddingTop(), MeasureSpec.EXACTLY));
}
} else {
child.measure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(child.getLayoutParams().height, MeasureSpec.EXACTLY));
2017-03-31 01:58:05 +02:00
}
2019-01-23 18:03:33 +01:00
} else {
measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0);
2015-04-09 20:00:14 +02:00
}
2019-01-23 18:03:33 +01:00
}
}
2019-01-23 18:03:33 +01:00
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int count = getChildCount();
2020-09-30 15:48:47 +02:00
int keyboardSize = measureKeyboardHeight();
2020-02-13 19:26:53 +01:00
int paddingBottom = keyboardSize <= AndroidUtilities.dp(20) && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isTablet() ? editText.getEmojiPadding() : 0;
2019-01-23 18:03:33 +01:00
setBottomClip(paddingBottom);
for (int i = 0; i < count; i++) {
final View child = getChildAt(i);
if (child.getVisibility() == GONE) {
continue;
}
final LayoutParams lp = (LayoutParams) child.getLayoutParams();
final int width = child.getMeasuredWidth();
final int height = child.getMeasuredHeight();
int childLeft;
int childTop;
int gravity = lp.gravity;
if (gravity == -1) {
gravity = Gravity.TOP | Gravity.LEFT;
}
final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
case Gravity.CENTER_HORIZONTAL:
childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
break;
case Gravity.RIGHT:
childLeft = r - width - lp.rightMargin;
break;
case Gravity.LEFT:
default:
childLeft = lp.leftMargin;
}
switch (verticalGravity) {
case Gravity.TOP:
childTop = lp.topMargin + getPaddingTop();
break;
case Gravity.CENTER_VERTICAL:
childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
break;
default:
childTop = lp.topMargin;
}
if (editText != null && editText.isPopupView(child)) {
if (AndroidUtilities.isTablet()) {
childTop = getMeasuredHeight() - child.getMeasuredHeight();
} else {
2020-02-13 19:26:53 +01:00
childTop = getMeasuredHeight() + keyboardSize - child.getMeasuredHeight();
2019-01-23 18:03:33 +01:00
}
}
2019-01-23 18:03:33 +01:00
child.layout(childLeft, childTop, childLeft + width, childTop + height);
}
2019-01-23 18:03:33 +01:00
notifyHeightChanged();
2015-04-09 20:00:14 +02:00
}
2019-05-14 14:08:05 +02:00
@Override
public void requestLayout() {
if (ignoreLayout) {
return;
}
super.requestLayout();
}
2019-01-23 18:03:33 +01:00
};
fragmentView = sizeNotifierFrameLayout;
fragmentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
fragmentView.setOnTouchListener((v, event) -> true);
2013-10-25 17:19:00 +02:00
2019-01-23 18:03:33 +01:00
shadowDrawable = context.getResources().getDrawable(R.drawable.greydivider_top).mutate();
2015-04-09 20:00:14 +02:00
2019-01-23 18:03:33 +01:00
LinearLayout linearLayout = new LinearLayout(context) {
2017-03-31 01:58:05 +02:00
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
boolean result = super.drawChild(canvas, child, drawingTime);
2019-01-23 18:03:33 +01:00
if (child == listView && shadowDrawable != null) {
int y = editTextContainer.getMeasuredHeight();
shadowDrawable.setBounds(0, y, getMeasuredWidth(), y + shadowDrawable.getIntrinsicHeight());
shadowDrawable.draw(canvas);
2017-03-31 01:58:05 +02:00
}
return result;
}
};
2015-04-09 20:00:14 +02:00
linearLayout.setOrientation(LinearLayout.VERTICAL);
2019-01-23 18:03:33 +01:00
sizeNotifierFrameLayout.addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
2015-04-09 20:00:14 +02:00
2017-03-31 01:58:05 +02:00
editTextContainer = new FrameLayout(context);
linearLayout.addView(editTextContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));
2015-04-09 20:00:14 +02:00
2019-01-23 18:03:33 +01:00
avatarImage = new BackupImageView(context) {
@Override
public void invalidate() {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate();
}
@Override
public void invalidate(int l, int t, int r, int b) {
if (avatarOverlay != null) {
avatarOverlay.invalidate();
}
super.invalidate(l, t, r, b);
}
};
2015-04-09 20:00:14 +02:00
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
2019-09-10 12:56:11 +02:00
avatarDrawable.setInfo(5, null, null);
2015-04-09 20:00:14 +02:00
avatarImage.setImageDrawable(avatarDrawable);
2019-05-14 14:08:05 +02:00
avatarImage.setContentDescription(LocaleController.getString("ChoosePhoto", R.string.ChoosePhoto));
2017-03-31 01:58:05 +02:00
editTextContainer.addView(avatarImage, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
2013-10-25 17:19:00 +02:00
2019-01-23 18:03:33 +01:00
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(0x55000000);
2013-10-25 17:19:00 +02:00
2019-01-23 18:03:33 +01:00
avatarOverlay = new View(context) {
@Override
protected void onDraw(Canvas canvas) {
if (avatarImage != null && avatarProgressView.getVisibility() == VISIBLE) {
paint.setAlpha((int) (0x55 * avatarImage.getImageReceiver().getCurrentAlpha() * avatarProgressView.getAlpha()));
2020-07-26 10:03:38 +02:00
canvas.drawCircle(getMeasuredWidth() / 2.0f, getMeasuredHeight() / 2.0f, getMeasuredWidth() / 2.0f, paint);
2015-04-09 20:00:14 +02:00
}
2019-01-23 18:03:33 +01:00
}
};
editTextContainer.addView(avatarOverlay, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
2021-01-28 15:15:51 +01:00
avatarOverlay.setOnClickListener(view -> {
imageUpdater.openMenu(avatar != null, () -> {
avatar = null;
avatarBig = null;
inputPhoto = null;
inputVideo = null;
inputVideoPath = null;
videoTimestamp = 0;
showAvatarProgress(false, true);
avatarImage.setImage(null, null, avatarDrawable, null);
avatarEditor.setAnimation(cameraDrawable);
cameraDrawable.setCurrentFrame(0);
}, dialog -> {
2021-08-31 21:06:39 +02:00
if (!imageUpdater.isUploadingImage()) {
cameraDrawable.setCustomEndFrame(86);
avatarEditor.playAnimation();
} else {
cameraDrawable.setCurrentFrame(0, false);
}
2021-01-28 15:15:51 +01:00
});
cameraDrawable.setCurrentFrame(0);
cameraDrawable.setCustomEndFrame(43);
avatarEditor.playAnimation();
});
cameraDrawable = new RLottieDrawable(R.raw.camera, "" + R.raw.camera, AndroidUtilities.dp(60), AndroidUtilities.dp(60), false, null);
avatarEditor = new RLottieImageView(context) {
2019-01-23 18:03:33 +01:00
@Override
public void invalidate(int l, int t, int r, int b) {
super.invalidate(l, t, r, b);
avatarOverlay.invalidate();
}
2014-11-14 16:40:15 +01:00
2019-01-23 18:03:33 +01:00
@Override
public void invalidate() {
super.invalidate();
avatarOverlay.invalidate();
2017-03-31 01:58:05 +02:00
}
2019-01-23 18:03:33 +01:00
};
avatarEditor.setScaleType(ImageView.ScaleType.CENTER);
2021-01-28 15:15:51 +01:00
avatarEditor.setAnimation(cameraDrawable);
2019-01-23 18:03:33 +01:00
avatarEditor.setEnabled(false);
avatarEditor.setClickable(false);
2021-01-28 15:15:51 +01:00
avatarEditor.setPadding(AndroidUtilities.dp(2), 0, 0, AndroidUtilities.dp(1));
2019-01-23 18:03:33 +01:00
editTextContainer.addView(avatarEditor, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
avatarProgressView = new RadialProgressView(context) {
@Override
public void setAlpha(float alpha) {
super.setAlpha(alpha);
avatarOverlay.invalidate();
}
};
avatarProgressView.setSize(AndroidUtilities.dp(30));
avatarProgressView.setProgressColor(0xffffffff);
2020-07-26 10:03:38 +02:00
avatarProgressView.setNoProgress(false);
2019-01-23 18:03:33 +01:00
editTextContainer.addView(avatarProgressView, LayoutHelper.createFrame(64, 64, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 16, 16, LocaleController.isRTL ? 16 : 0, 16));
showAvatarProgress(false, false);
2017-03-31 01:58:05 +02:00
2019-05-14 14:08:05 +02:00
editText = new EditTextEmoji(context, sizeNotifierFrameLayout, this, EditTextEmoji.STYLE_FRAGMENT);
2019-06-04 12:14:50 +02:00
editText.setHint(chatType == ChatObject.CHAT_TYPE_CHAT || chatType == ChatObject.CHAT_TYPE_MEGAGROUP ? LocaleController.getString("EnterGroupNamePlaceholder", R.string.EnterGroupNamePlaceholder) : LocaleController.getString("EnterListName", R.string.EnterListName));
2015-04-09 20:00:14 +02:00
if (nameToSet != null) {
2017-03-31 01:58:05 +02:00
editText.setText(nameToSet);
2015-04-09 20:00:14 +02:00
nameToSet = null;
}
2015-09-24 22:52:02 +02:00
InputFilter[] inputFilters = new InputFilter[1];
inputFilters[0] = new InputFilter.LengthFilter(100);
2017-03-31 01:58:05 +02:00
editText.setFilters(inputFilters);
2019-01-23 18:03:33 +01:00
editTextContainer.addView(editText, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL, LocaleController.isRTL ? 5 : 96, 0, LocaleController.isRTL ? 96 : 5, 0));
2015-04-09 20:00:14 +02:00
2017-03-31 01:58:05 +02:00
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false);
2015-04-09 20:00:14 +02:00
2017-03-31 01:58:05 +02:00
listView = new RecyclerListView(context);
listView.setAdapter(adapter = new GroupCreateAdapter(context));
listView.setLayoutManager(linearLayoutManager);
2015-04-09 20:00:14 +02:00
listView.setVerticalScrollBarEnabled(false);
2017-03-31 01:58:05 +02:00
listView.setVerticalScrollbarPosition(LocaleController.isRTL ? View.SCROLLBAR_POSITION_LEFT : View.SCROLLBAR_POSITION_RIGHT);
2019-01-23 18:03:33 +01:00
GroupCreateDividerItemDecoration decoration = new GroupCreateDividerItemDecoration();
2019-07-18 15:01:39 +02:00
decoration.setSkipRows(currentGroupCreateAddress != null ? 5 : 2);
2019-01-23 18:03:33 +01:00
listView.addItemDecoration(decoration);
2017-03-31 01:58:05 +02:00
linearLayout.addView(listView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
listView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
AndroidUtilities.hideKeyboard(editText);
}
}
});
2019-07-18 15:01:39 +02:00
listView.setOnItemClickListener((view, position) -> {
if (view instanceof TextSettingsCell) {
if (!AndroidUtilities.isGoogleMapsInstalled(GroupCreateFinalActivity.this)) {
return;
}
LocationActivity fragment = new LocationActivity(LocationActivity.LOCATION_TYPE_GROUP);
fragment.setDialogId(0);
2019-09-10 12:56:11 +02:00
fragment.setDelegate((location, live, notify, scheduleDate) -> {
2019-07-18 15:01:39 +02:00
currentGroupCreateLocation.setLatitude(location.geo.lat);
currentGroupCreateLocation.setLongitude(location.geo._long);
currentGroupCreateAddress = location.address;
});
presentFragment(fragment);
}
});
2015-04-09 20:00:14 +02:00
2019-01-23 18:03:33 +01:00
floatingButtonContainer = new FrameLayout(context);
Drawable drawable = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(56), Theme.getColor(Theme.key_chats_actionBackground), Theme.getColor(Theme.key_chats_actionPressedBackground));
if (Build.VERSION.SDK_INT < 21) {
Drawable shadowDrawable = context.getResources().getDrawable(R.drawable.floating_shadow).mutate();
shadowDrawable.setColorFilter(new PorterDuffColorFilter(0xff000000, PorterDuff.Mode.MULTIPLY));
CombinedDrawable combinedDrawable = new CombinedDrawable(shadowDrawable, drawable, 0, 0);
combinedDrawable.setIconSize(AndroidUtilities.dp(56), AndroidUtilities.dp(56));
drawable = combinedDrawable;
}
floatingButtonContainer.setBackgroundDrawable(drawable);
if (Build.VERSION.SDK_INT >= 21) {
StateListAnimator animator = new StateListAnimator();
animator.addState(new int[]{android.R.attr.state_pressed}, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(2), AndroidUtilities.dp(4)).setDuration(200));
animator.addState(new int[]{}, ObjectAnimator.ofFloat(floatingButtonIcon, "translationZ", AndroidUtilities.dp(4), AndroidUtilities.dp(2)).setDuration(200));
floatingButtonContainer.setStateListAnimator(animator);
floatingButtonContainer.setOutlineProvider(new ViewOutlineProvider() {
@SuppressLint("NewApi")
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, AndroidUtilities.dp(56), AndroidUtilities.dp(56));
}
});
}
2020-07-26 10:03:38 +02:00
VerticalPositionAutoAnimator.attach(floatingButtonContainer);
2019-01-23 18:03:33 +01:00
sizeNotifierFrameLayout.addView(floatingButtonContainer, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.BOTTOM, LocaleController.isRTL ? 14 : 0, 0, LocaleController.isRTL ? 0 : 14, 14));
floatingButtonContainer.setOnClickListener(view -> {
if (donePressed) {
return;
}
if (editText.length() == 0) {
Vibrator v = (Vibrator) getParentActivity().getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(200);
}
AndroidUtilities.shakeView(editText, 2, 0);
return;
}
donePressed = true;
AndroidUtilities.hideKeyboard(editText);
editText.setEnabled(false);
2020-07-26 10:03:38 +02:00
if (imageUpdater.isUploadingImage()) {
2019-01-23 18:03:33 +01:00
createAfterUpload = true;
} else {
showEditDoneProgress(true);
2021-01-28 15:15:51 +01:00
reqId = getMessagesController().createChat(editText.getText().toString(), selectedContacts, null, chatType, forImport, currentGroupCreateLocation, currentGroupCreateAddress, GroupCreateFinalActivity.this);
2019-01-23 18:03:33 +01:00
}
});
floatingButtonIcon = new ImageView(context);
floatingButtonIcon.setScaleType(ImageView.ScaleType.CENTER);
floatingButtonIcon.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY));
floatingButtonIcon.setImageResource(R.drawable.checkbig);
floatingButtonIcon.setPadding(0, AndroidUtilities.dp(2), 0, 0);
2019-05-14 14:08:05 +02:00
floatingButtonContainer.setContentDescription(LocaleController.getString("Done", R.string.Done));
2019-01-23 18:03:33 +01:00
floatingButtonContainer.addView(floatingButtonIcon, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60));
progressView = new ContextProgressView(context, 1);
progressView.setAlpha(0.0f);
progressView.setScaleX(0.1f);
progressView.setScaleY(0.1f);
progressView.setVisibility(View.INVISIBLE);
floatingButtonContainer.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
2013-10-25 17:19:00 +02:00
return fragmentView;
}
@Override
2020-07-26 10:03:38 +02:00
public void onUploadProgressChanged(float progress) {
if (avatarProgressView == null) {
return;
}
avatarProgressView.setProgress(progress);
}
@Override
public void didStartUpload(boolean isVideo) {
if (avatarProgressView == null) {
return;
}
avatarProgressView.setProgress(0.0f);
}
@Override
public void didUploadPhoto(final TLRPC.InputFile photo, final TLRPC.InputFile video, double videoStartTimestamp, String videoPath, final TLRPC.PhotoSize bigSize, final TLRPC.PhotoSize smallSize) {
2019-01-23 18:03:33 +01:00
AndroidUtilities.runOnUIThread(() -> {
2020-07-26 10:03:38 +02:00
if (photo != null || video != null) {
inputPhoto = photo;
inputVideo = video;
inputVideoPath = videoPath;
videoTimestamp = videoStartTimestamp;
2013-10-25 17:19:00 +02:00
if (createAfterUpload) {
2019-06-04 12:14:50 +02:00
if (delegate != null) {
delegate.didStartChatCreation();
}
2021-01-28 15:15:51 +01:00
getMessagesController().createChat(editText.getText().toString(), selectedContacts, null, chatType, forImport, currentGroupCreateLocation, currentGroupCreateAddress, GroupCreateFinalActivity.this);
2013-10-25 17:19:00 +02:00
}
2019-01-23 18:03:33 +01:00
showAvatarProgress(false, true);
avatarEditor.setImageDrawable(null);
} else {
avatar = smallSize.location;
avatarBig = bigSize.location;
2019-05-14 14:08:05 +02:00
avatarImage.setImage(ImageLocation.getForLocal(avatar), "50_50", avatarDrawable, null);
2019-01-23 18:03:33 +01:00
showAvatarProgress(true, false);
2013-10-25 17:19:00 +02:00
}
});
}
2019-01-23 18:03:33 +01:00
@Override
public String getInitialSearchString() {
return editText.getText().toString();
}
2019-06-04 12:14:50 +02:00
public void setDelegate(GroupCreateFinalActivityDelegate groupCreateFinalActivityDelegate) {
delegate = groupCreateFinalActivityDelegate;
}
2019-01-23 18:03:33 +01:00
private void showAvatarProgress(boolean show, boolean animated) {
if (avatarEditor == null) {
return;
}
if (avatarAnimation != null) {
avatarAnimation.cancel();
avatarAnimation = null;
}
if (animated) {
avatarAnimation = new AnimatorSet();
if (show) {
avatarProgressView.setVisibility(View.VISIBLE);
avatarAnimation.playTogether(ObjectAnimator.ofFloat(avatarEditor, View.ALPHA, 0.0f),
ObjectAnimator.ofFloat(avatarProgressView, View.ALPHA, 1.0f));
} else {
avatarEditor.setVisibility(View.VISIBLE);
avatarAnimation.playTogether(ObjectAnimator.ofFloat(avatarEditor, View.ALPHA, 1.0f),
ObjectAnimator.ofFloat(avatarProgressView, View.ALPHA, 0.0f));
}
avatarAnimation.setDuration(180);
avatarAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (avatarAnimation == null || avatarEditor == null) {
return;
}
if (show) {
avatarEditor.setVisibility(View.INVISIBLE);
} else {
avatarProgressView.setVisibility(View.INVISIBLE);
}
avatarAnimation = null;
}
@Override
public void onAnimationCancel(Animator animation) {
avatarAnimation = null;
}
});
avatarAnimation.start();
} else {
if (show) {
avatarEditor.setAlpha(1.0f);
avatarEditor.setVisibility(View.INVISIBLE);
avatarProgressView.setAlpha(1.0f);
avatarProgressView.setVisibility(View.VISIBLE);
} else {
avatarEditor.setAlpha(1.0f);
avatarEditor.setVisibility(View.VISIBLE);
avatarProgressView.setAlpha(0.0f);
avatarProgressView.setVisibility(View.INVISIBLE);
}
}
}
2013-10-25 17:19:00 +02:00
@Override
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
2018-07-30 04:07:02 +02:00
imageUpdater.onActivityResult(requestCode, resultCode, data);
2013-10-25 17:19:00 +02:00
}
@Override
public void saveSelfArgs(Bundle args) {
2018-07-30 04:07:02 +02:00
if (imageUpdater != null && imageUpdater.currentPicturePath != null) {
args.putString("path", imageUpdater.currentPicturePath);
}
2017-03-31 01:58:05 +02:00
if (editText != null) {
String text = editText.getText().toString();
2021-09-20 07:54:41 +02:00
if (text.length() != 0) {
args.putString("nameTextView", text);
}
}
}
@Override
public void restoreSelfArgs(Bundle args) {
2018-07-30 04:07:02 +02:00
if (imageUpdater != null) {
imageUpdater.currentPicturePath = args.getString("path");
}
String text = args.getString("nameTextView");
if (text != null) {
2017-03-31 01:58:05 +02:00
if (editText != null) {
editText.setText(text);
} else {
nameToSet = text;
}
}
}
@Override
2015-10-29 18:10:07 +01:00
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen) {
2019-01-23 18:03:33 +01:00
editText.openKeyboard();
2015-10-29 18:10:07 +01:00
}
}
2013-10-25 17:19:00 +02:00
@Override
2018-07-30 04:07:02 +02:00
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.updateInterfaces) {
2017-03-31 01:58:05 +02:00
if (listView == null) {
return;
2013-10-25 17:19:00 +02:00
}
2017-03-31 01:58:05 +02:00
int mask = (Integer) args[0];
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(mask);
}
}
}
2017-03-31 01:58:05 +02:00
} else if (id == NotificationCenter.chatDidFailCreate) {
reqId = 0;
2013-10-25 17:19:00 +02:00
donePressed = false;
2017-03-31 01:58:05 +02:00
showEditDoneProgress(false);
if (editText != null) {
editText.setEnabled(true);
2015-05-21 23:27:27 +02:00
}
2019-06-04 12:14:50 +02:00
if (delegate != null) {
delegate.didFailChatCreation();
}
2017-03-31 01:58:05 +02:00
} else if (id == NotificationCenter.chatDidCreated) {
reqId = 0;
2021-09-20 07:54:41 +02:00
long chatId = (Long) args[0];
2019-06-04 12:14:50 +02:00
if (delegate != null) {
2021-09-20 07:54:41 +02:00
delegate.didFinishChatCreation(this, chatId);
2019-06-04 12:14:50 +02:00
} else {
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.closeChats);
Bundle args2 = new Bundle();
2021-09-20 07:54:41 +02:00
args2.putLong("chat_id", chatId);
2019-06-04 12:14:50 +02:00
presentFragment(new ChatActivity(args2), true);
}
2020-07-26 10:03:38 +02:00
if (inputPhoto != null || inputVideo != null) {
2021-09-20 07:54:41 +02:00
getMessagesController().changeChatAvatar(chatId, null, inputPhoto, inputVideo, videoTimestamp, inputVideoPath, avatar, avatarBig, null);
2015-05-21 23:27:27 +02:00
}
2013-10-25 17:19:00 +02:00
}
}
2017-03-31 01:58:05 +02:00
private void showEditDoneProgress(final boolean show) {
2019-06-04 12:14:50 +02:00
if (floatingButtonIcon == null) {
return;
}
2017-03-31 01:58:05 +02:00
if (doneItemAnimation != null) {
doneItemAnimation.cancel();
}
doneItemAnimation = new AnimatorSet();
if (show) {
progressView.setVisibility(View.VISIBLE);
2019-01-23 18:03:33 +01:00
floatingButtonContainer.setEnabled(false);
2017-03-31 01:58:05 +02:00
doneItemAnimation.playTogether(
2019-01-23 18:03:33 +01:00
ObjectAnimator.ofFloat(floatingButtonIcon, "scaleX", 0.1f),
ObjectAnimator.ofFloat(floatingButtonIcon, "scaleY", 0.1f),
ObjectAnimator.ofFloat(floatingButtonIcon, "alpha", 0.0f),
2017-03-31 01:58:05 +02:00
ObjectAnimator.ofFloat(progressView, "scaleX", 1.0f),
ObjectAnimator.ofFloat(progressView, "scaleY", 1.0f),
ObjectAnimator.ofFloat(progressView, "alpha", 1.0f));
} else {
2019-01-23 18:03:33 +01:00
floatingButtonIcon.setVisibility(View.VISIBLE);
floatingButtonContainer.setEnabled(true);
2017-03-31 01:58:05 +02:00
doneItemAnimation.playTogether(
ObjectAnimator.ofFloat(progressView, "scaleX", 0.1f),
ObjectAnimator.ofFloat(progressView, "scaleY", 0.1f),
ObjectAnimator.ofFloat(progressView, "alpha", 0.0f),
2019-01-23 18:03:33 +01:00
ObjectAnimator.ofFloat(floatingButtonIcon, "scaleX", 1.0f),
ObjectAnimator.ofFloat(floatingButtonIcon, "scaleY", 1.0f),
ObjectAnimator.ofFloat(floatingButtonIcon, "alpha", 1.0f));
2017-03-31 01:58:05 +02:00
}
2017-03-31 01:58:05 +02:00
doneItemAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (doneItemAnimation != null && doneItemAnimation.equals(animation)) {
if (!show) {
progressView.setVisibility(View.INVISIBLE);
} else {
2019-01-23 18:03:33 +01:00
floatingButtonIcon.setVisibility(View.INVISIBLE);
2017-03-31 01:58:05 +02:00
}
}
}
@Override
public void onAnimationCancel(Animator animation) {
if (doneItemAnimation != null && doneItemAnimation.equals(animation)) {
doneItemAnimation = null;
}
}
});
doneItemAnimation.setDuration(150);
doneItemAnimation.start();
}
2017-03-31 01:58:05 +02:00
public class GroupCreateAdapter extends RecyclerListView.SelectionAdapter {
private Context context;
2019-07-18 15:01:39 +02:00
private int usersStartRow;
2013-10-25 17:19:00 +02:00
2017-03-31 01:58:05 +02:00
public GroupCreateAdapter(Context ctx) {
context = ctx;
2013-10-25 17:19:00 +02:00
}
@Override
2017-03-31 01:58:05 +02:00
public int getItemCount() {
2019-07-18 15:01:39 +02:00
int count = 2 + selectedContacts.size();
if (currentGroupCreateAddress != null) {
count += 3;
}
return count;
2013-10-25 17:19:00 +02:00
}
@Override
2017-03-31 01:58:05 +02:00
public boolean isEnabled(RecyclerView.ViewHolder holder) {
2019-07-18 15:01:39 +02:00
return holder.getItemViewType() == 3;
2013-10-25 17:19:00 +02:00
}
@Override
2017-03-31 01:58:05 +02:00
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view;
switch (viewType) {
2019-01-23 18:03:33 +01:00
case 0: {
view = new ShadowSectionCell(context);
Drawable drawable = Theme.getThemedDrawable(context, R.drawable.greydivider_top, Theme.key_windowBackgroundGrayShadow);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
combinedDrawable.setFullsize(true);
view.setBackgroundDrawable(combinedDrawable);
2017-03-31 01:58:05 +02:00
break;
2019-01-23 18:03:33 +01:00
}
case 1:
HeaderCell headerCell = new HeaderCell(context);
headerCell.setHeight(46);
view = headerCell;
break;
case 2:
2021-03-19 11:25:58 +01:00
view = new GroupCreateUserCell(context, 0, 3, false);
2017-03-31 01:58:05 +02:00
break;
2019-07-18 15:01:39 +02:00
case 3:
default:
view = new TextSettingsCell(context);
break;
2013-12-20 20:25:49 +01:00
}
2017-03-31 01:58:05 +02:00
return new RecyclerListView.Holder(view);
2014-11-14 16:40:15 +01:00
}
2013-10-25 17:19:00 +02:00
2014-11-14 16:40:15 +01:00
@Override
2017-03-31 01:58:05 +02:00
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
2019-01-23 18:03:33 +01:00
case 1: {
HeaderCell cell = (HeaderCell) holder.itemView;
2019-07-18 15:01:39 +02:00
if (currentGroupCreateAddress != null && position == 1) {
cell.setText(LocaleController.getString("AttachLocation", R.string.AttachLocation));
} else {
cell.setText(LocaleController.formatPluralString("Members", selectedContacts.size()));
}
2017-03-31 01:58:05 +02:00
break;
}
2019-01-23 18:03:33 +01:00
case 2: {
2017-03-31 01:58:05 +02:00
GroupCreateUserCell cell = (GroupCreateUserCell) holder.itemView;
2021-01-28 15:15:51 +01:00
TLRPC.User user = getMessagesController().getUser(selectedContacts.get(position - usersStartRow));
2019-06-04 12:14:50 +02:00
cell.setObject(user, null, null);
2017-03-31 01:58:05 +02:00
break;
}
2019-07-18 15:01:39 +02:00
case 3: {
TextSettingsCell cell = (TextSettingsCell) holder.itemView;
cell.setText(currentGroupCreateAddress, false);
break;
}
2017-03-31 01:58:05 +02:00
}
2014-11-14 16:40:15 +01:00
}
@Override
2017-03-31 01:58:05 +02:00
public int getItemViewType(int position) {
2019-07-18 15:01:39 +02:00
if (currentGroupCreateAddress != null) {
if (position == 0) {
return 0;
} else if (position == 1) {
return 1;
} else if (position == 2) {
return 3;
} else {
position -= 3;
}
usersStartRow = 5;
} else {
usersStartRow = 2;
}
2017-03-31 01:58:05 +02:00
switch (position) {
case 0:
return 0;
2019-01-23 18:03:33 +01:00
case 1:
2017-03-31 01:58:05 +02:00
return 1;
2019-01-23 18:03:33 +01:00
case 2:
default:
return 2;
2017-03-31 01:58:05 +02:00
}
2014-11-14 16:40:15 +01:00
}
@Override
2017-03-31 01:58:05 +02:00
public void onViewRecycled(RecyclerView.ViewHolder holder) {
2019-01-23 18:03:33 +01:00
if (holder.getItemViewType() == 2) {
2017-03-31 01:58:05 +02:00
((GroupCreateUserCell) holder.itemView).recycle();
}
2013-10-25 17:19:00 +02:00
}
}
2017-03-31 01:58:05 +02:00
@Override
2020-04-24 11:21:58 +02:00
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> themeDescriptions = new ArrayList<>();
2019-01-23 18:03:33 +01:00
ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> {
if (listView != null) {
int count = listView.getChildCount();
for (int a = 0; a < count; a++) {
View child = listView.getChildAt(a);
if (child instanceof GroupCreateUserCell) {
((GroupCreateUserCell) child).update(0);
2017-03-31 01:58:05 +02:00
}
}
}
};
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
themeDescriptions.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollActive));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollInactive));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_FASTSCROLL, null, null, null, null, Theme.key_fastScrollText));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{View.class}, Theme.dividerPaint, null, null, Theme.key_divider));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_groupcreate_hintText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_CURSORCOLOR, null, null, null, null, Theme.key_groupcreate_cursor));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGrayShadow));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_CELLBACKGROUNDCOLOR, new Class[]{ShadowSectionCell.class}, null, null, null, Theme.key_windowBackgroundGray));
2019-01-23 18:03:33 +01:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{HeaderCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueHeader));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR, new Class[]{GroupCreateUserCell.class}, new String[]{"textView"}, null, null, null, Theme.key_groupcreate_sectionText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{GroupCreateUserCell.class}, new String[]{"statusTextView"}, null, null, null, Theme.key_windowBackgroundWhiteBlueText));
themeDescriptions.add(new ThemeDescription(listView, ThemeDescription.FLAG_TEXTCOLOR | ThemeDescription.FLAG_CHECKTAG, new Class[]{GroupCreateUserCell.class}, new String[]{"statusTextView"}, null, null, null, Theme.key_windowBackgroundWhiteGrayText));
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{GroupCreateUserCell.class}, null, Theme.avatarDrawables, cellDelegate, Theme.key_avatar_text));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundOrange));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundViolet));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundGreen));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundCyan));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue));
themeDescriptions.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(listView, 0, new Class[]{TextSettingsCell.class}, new String[]{"textView"}, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
2019-07-18 15:01:39 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(progressView, 0, null, null, null, null, Theme.key_contextProgressInner2));
themeDescriptions.add(new ThemeDescription(progressView, 0, null, null, null, null, Theme.key_contextProgressOuter2));
2017-03-31 01:58:05 +02:00
2020-04-24 11:21:58 +02:00
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
themeDescriptions.add(new ThemeDescription(editText, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText));
return themeDescriptions;
2017-03-31 01:58:05 +02:00
}
2013-10-25 17:19:00 +02:00
}