正在查看: Plus 12 v10.13.1.1 应用的 ChangeUsernameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 ChangeUsernameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.TextPaint;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject;
import org.telegram.messenger.browser.Browser;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.INavigationLayout;
import org.telegram.ui.ActionBar.PlusSettings;
import org.telegram.ui.ActionBar.SimpleTextView;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.HeaderCell;
import org.telegram.ui.Cells.TextInfoPrivacyCell;
import org.telegram.ui.ChangeUsernameActivity;
import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.AnimatedFloat;
import org.telegram.ui.Components.AnimatedTextView;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.CircularProgressDrawable;
import org.telegram.ui.Components.CubicBezierInterpolator;
import org.telegram.ui.Components.EditTextBoldCursor;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.LinkSpanDrawable;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.TypefaceSpan;
import org.telegram.ui.Components.URLSpanNoUnderline;
public class ChangeUsernameActivity extends BaseFragment {
public Adapter adapter;
public long botId;
public int checkReqId;
public Runnable checkRunnable;
public View doneButton;
public UsernameCell editableUsernameCell;
public UsernameHelpCell helpCell;
public boolean ignoreCheck;
public InputCell inputCell;
public ItemTouchHelper itemTouchHelper;
public String lastCheckName;
public RecyclerListView listView;
public ArrayList<String> loadingUsernames;
public boolean needReorder;
public ArrayList<TLRPC.TL_username> notEditableUsernames;
public LinkSpanDrawable.LinksTextView statusTextView;
public String username;
public ArrayList<TLRPC.TL_username> usernames;
public static Paint linkBackgroundActive = new Paint(1);
public static Paint linkBackgroundInactive = new Paint(1);
public static Paint dragPaint = new Paint(1);
public static boolean lambda$createView$0(View view, MotionEvent motionEvent) {
return true;
}
public class LinkSpan extends ClickableSpan {
public String url;
public LinkSpan(String value) {
this.url = value;
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
@Override
public void onClick(View widget) {
try {
((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", this.url));
if (!BulletinFactory.canShowBulletin(ChangeUsernameActivity.this) || PlusSettings.hideMsgDeletedHint) {
return;
}
BulletinFactory.createCopyLinkBulletin(ChangeUsernameActivity.this).show();
} catch (Exception e) {
FileLog.e(e);
}
}
}
public ChangeUsernameActivity() {
this(null);
}
public ChangeUsernameActivity(Bundle args) {
super(args);
this.username = "";
this.notEditableUsernames = new ArrayList<>();
this.usernames = new ArrayList<>();
this.loadingUsernames = new ArrayList<>();
if (args != null) {
this.botId = args.getLong("bot_id");
}
}
public final long getUserId() {
long j = this.botId;
return j != 0 ? j : UserConfig.getInstance(((BaseFragment) this).currentAccount).getClientUserId();
}
public final TLRPC.User getUser() {
long j = this.botId;
int i = ((BaseFragment) this).currentAccount;
return j != 0 ? MessagesController.getInstance(i).getUser(Long.valueOf(this.botId)) : UserConfig.getInstance(i).getCurrentUser();
}
public View createView(Context context) {
String str;
((BaseFragment) this).actionBar.setBackButtonImage(R.drawable.ic_ab_back);
((BaseFragment) this).actionBar.setAllowOverlayTitle(true);
((BaseFragment) this).actionBar.setTitle(LocaleController.getString("Username", R.string.Username));
((BaseFragment) this).actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
@Override
public void onItemClick(int id) {
if (id == -1) {
ChangeUsernameActivity.this.finishFragment();
} else if (id == 1) {
ChangeUsernameActivity.this.sendReorder();
ChangeUsernameActivity.this.saveName();
}
}
});
this.doneButton = ((BaseFragment) this).actionBar.createMenu().addItemWithWidth(1, R.drawable.ic_ab_done, AndroidUtilities.dp(56.0f), LocaleController.getString("Done", R.string.Done));
TLRPC.User user = MessagesController.getInstance(((BaseFragment) this).currentAccount).getUser(Long.valueOf(getUserId()));
if (user == null) {
user = getUser();
}
if (user != null) {
this.username = null;
if (user.usernames != null) {
int i = 0;
while (true) {
if (i >= user.usernames.size()) {
break;
}
TLRPC.TL_username tL_username = (TLRPC.TL_username) user.usernames.get(i);
if (tL_username != null && tL_username.editable) {
this.username = tL_username.username;
break;
}
i++;
}
}
if (this.username == null && (str = user.username) != null) {
this.username = str;
}
if (this.username == null) {
this.username = "";
}
this.notEditableUsernames.clear();
this.usernames.clear();
for (int i2 = 0; i2 < user.usernames.size(); i2++) {
if (((TLRPC.TL_username) user.usernames.get(i2)).active) {
this.usernames.add((TLRPC.TL_username) user.usernames.get(i2));
}
}
for (int i3 = 0; i3 < user.usernames.size(); i3++) {
if (!((TLRPC.TL_username) user.usernames.get(i3)).active) {
this.usernames.add((TLRPC.TL_username) user.usernames.get(i3));
}
}
}
((BaseFragment) this).fragmentView = new FrameLayout(context);
this.listView = new RecyclerListView(context) {
public Paint backgroundPaint = new Paint(1);
public void dispatchDraw(Canvas canvas) {
int childAdapterPosition;
int size = (ChangeUsernameActivity.this.usernames.size() + 4) - 1;
int i4 = Integer.MAX_VALUE;
int i5 = Integer.MIN_VALUE;
for (int i6 = 0; i6 < getChildCount(); i6++) {
View childAt = getChildAt(i6);
if (childAt != null && (childAdapterPosition = getChildAdapterPosition(childAt)) >= 4 && childAdapterPosition <= size) {
i4 = Math.min(childAt.getTop(), i4);
i5 = Math.max(childAt.getBottom(), i5);
}
}
if (i4 < i5) {
this.backgroundPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite, ((RecyclerListView) this).resourcesProvider));
canvas.drawRect(0.0f, i4, getWidth(), i5, this.backgroundPaint);
}
super.dispatchDraw(canvas);
}
};
((BaseFragment) this).fragmentView.setBackgroundColor(getThemedColor(Theme.key_windowBackgroundGray));
this.listView.setLayoutManager(new LinearLayoutManager(context));
RecyclerListView recyclerListView = this.listView;
Adapter adapter = new Adapter();
this.adapter = adapter;
recyclerListView.setAdapter(adapter);
this.listView.setSelectorDrawableColor(getThemedColor(Theme.key_listSelector));
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new TouchHelperCallback());
this.itemTouchHelper = itemTouchHelper;
itemTouchHelper.attachToRecyclerView(this.listView);
((FrameLayout) ((BaseFragment) this).fragmentView).addView((View) this.listView, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -1.0f));
((BaseFragment) this).fragmentView.setOnTouchListener(new View.OnTouchListener() {
@Override
public final boolean onTouch(View view, MotionEvent motionEvent) {
boolean lambda$createView$0;
lambda$createView$0 = ChangeUsernameActivity.lambda$createView$0(view, motionEvent);
return lambda$createView$0;
}
});
this.listView.setOnItemClickListener(new AnonymousClass3());
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$createView$1();
}
}, 40L);
return ((BaseFragment) this).fragmentView;
}
public class AnonymousClass3 implements RecyclerListView.OnItemClickListener {
public AnonymousClass3() {
}
public void onItemClick(final View view, final int position) {
int i;
String str;
int i2;
String str2;
int i3;
String str3;
if (view instanceof UsernameCell) {
UsernameCell usernameCell = (UsernameCell) view;
final TLRPC.TL_username tL_username = usernameCell.currentUsername;
if (tL_username == null || usernameCell.loading) {
return;
}
if (tL_username.editable) {
if (ChangeUsernameActivity.this.botId != 0) {
return;
}
ChangeUsernameActivity.this.listView.smoothScrollToPosition(0);
ChangeUsernameActivity.this.focusUsernameField(true);
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(ChangeUsernameActivity.this.getContext(), ChangeUsernameActivity.this.getResourceProvider());
if (tL_username.active) {
i = R.string.UsernameDeactivateLink;
str = "UsernameDeactivateLink";
} else {
i = R.string.UsernameActivateLink;
str = "UsernameActivateLink";
}
AlertDialog.Builder title = builder.setTitle(LocaleController.getString(str, i));
if (tL_username.active) {
i2 = R.string.UsernameDeactivateLinkProfileMessage;
str2 = "UsernameDeactivateLinkProfileMessage";
} else {
i2 = R.string.UsernameActivateLinkProfileMessage;
str2 = "UsernameActivateLinkProfileMessage";
}
AlertDialog.Builder message = title.setMessage(LocaleController.getString(str2, i2));
if (tL_username.active) {
i3 = R.string.Hide;
str3 = "Hide";
} else {
i3 = R.string.Show;
str3 = "Show";
}
message.setPositiveButton(LocaleController.getString(str3, i3), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i4) {
ChangeUsernameActivity.AnonymousClass3.this.lambda$onItemClick$3(tL_username, position, view, dialogInterface, i4);
}
}).setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i4) {
dialogInterface.dismiss();
}
}).show();
return;
}
if (view instanceof InputCell) {
ChangeUsernameActivity.this.focusUsernameField(true);
}
}
public void lambda$onItemClick$3(final TLRPC.TL_username tL_username, final int i, View view, DialogInterface dialogInterface, int i2) {
TLRPC.TL_account_toggleUsername tL_bots_toggleUsername;
final boolean z = tL_username.active;
final String str = tL_username.username;
final boolean z2 = !z;
if (ChangeUsernameActivity.this.botId == 0) {
tL_bots_toggleUsername = new TLRPC.TL_account_toggleUsername();
tL_bots_toggleUsername.username = str;
tL_bots_toggleUsername.active = z2;
} else {
tL_bots_toggleUsername = new TLRPC.TL_bots_toggleUsername();
((TLRPC.TL_bots_toggleUsername) tL_bots_toggleUsername).bot = MessagesController.getInstance(((BaseFragment) ChangeUsernameActivity.this).currentAccount).getInputUser(ChangeUsernameActivity.this.botId);
((TLRPC.TL_bots_toggleUsername) tL_bots_toggleUsername).username = str;
((TLRPC.TL_bots_toggleUsername) tL_bots_toggleUsername).active = z2;
}
ChangeUsernameActivity.this.getConnectionsManager().sendRequest(tL_bots_toggleUsername, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangeUsernameActivity.AnonymousClass3.this.lambda$onItemClick$2(str, i, z2, tL_username, z, tLObject, tL_error);
}
});
ChangeUsernameActivity.this.loadingUsernames.add(tL_username.username);
((UsernameCell) view).setLoading(true);
}
public void lambda$onItemClick$2(final String str, final int i, final boolean z, final TLRPC.TL_username tL_username, final boolean z2, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.AnonymousClass3.this.lambda$onItemClick$1(str, tLObject, i, z, tL_error, tL_username, z2);
}
});
}
public void lambda$onItemClick$1(String str, TLObject tLObject, int i, boolean z, TLRPC.TL_error tL_error, final TLRPC.TL_username tL_username, final boolean z2) {
ChangeUsernameActivity.this.loadingUsernames.remove(str);
if (tLObject instanceof TLRPC.TL_boolTrue) {
ChangeUsernameActivity.this.toggleUsername(i, z);
} else if (tL_error != null && "USERNAMES_ACTIVE_TOO_MUCH".equals(tL_error.text)) {
tL_username.active = z;
ChangeUsernameActivity.this.toggleUsername(i, z);
new AlertDialog.Builder(ChangeUsernameActivity.this.getContext(), ChangeUsernameActivity.this.getResourceProvider()).setTitle(LocaleController.getString("UsernameActivateErrorTitle", R.string.UsernameActivateErrorTitle)).setMessage(LocaleController.getString("UsernameActivateErrorMessage", R.string.UsernameActivateErrorMessage)).setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public final void onClick(DialogInterface dialogInterface, int i2) {
ChangeUsernameActivity.AnonymousClass3.this.lambda$onItemClick$0(tL_username, z2, dialogInterface, i2);
}
}).show();
} else {
ChangeUsernameActivity.this.toggleUsername(tL_username, z2, true);
}
ChangeUsernameActivity.this.getMessagesController().updateUsernameActiveness(MessagesController.getInstance(((BaseFragment) ChangeUsernameActivity.this).currentAccount).getUser(Long.valueOf(ChangeUsernameActivity.this.getUserId())), tL_username.username, tL_username.active);
}
public void lambda$onItemClick$0(TLRPC.TL_username tL_username, boolean z, DialogInterface dialogInterface, int i) {
ChangeUsernameActivity.this.toggleUsername(tL_username, z, true);
}
}
public void lambda$createView$1() {
String str = this.username;
if (str == null || str.length() > 0) {
this.ignoreCheck = true;
focusUsernameField(this.usernames.size() <= 0);
this.ignoreCheck = false;
}
}
public void toggleUsername(TLRPC.TL_username username, boolean newActive, boolean shake) {
for (int i = 0; i < this.usernames.size(); i++) {
if (this.usernames.get(i) == username) {
toggleUsername(i + 4, newActive, shake);
return;
}
}
}
public void toggleUsername(int position, boolean newActive) {
toggleUsername(position, newActive, false);
}
public void toggleUsername(int r6, boolean r7, boolean r8) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.ChangeUsernameActivity.toggleUsername(int, boolean, boolean):void");
}
public final void focusUsernameField(boolean showKeyboard) {
InputCell inputCell = this.inputCell;
if (inputCell != null) {
if (!inputCell.field.isFocused()) {
EditTextBoldCursor editTextBoldCursor = this.inputCell.field;
editTextBoldCursor.setSelection(editTextBoldCursor.length());
}
this.inputCell.field.requestFocus();
if (showKeyboard) {
AndroidUtilities.showKeyboard(this.inputCell.field);
}
}
}
public class Adapter extends RecyclerListView.SelectionAdapter {
public Adapter() {
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 0) {
HeaderCell headerCell = new HeaderCell(ChangeUsernameActivity.this.getContext());
headerCell.setBackgroundColor(ChangeUsernameActivity.this.getThemedColor(Theme.key_windowBackgroundWhite));
return new RecyclerListView.Holder(headerCell);
}
if (viewType == 1) {
ChangeUsernameActivity changeUsernameActivity = ChangeUsernameActivity.this;
return new RecyclerListView.Holder(changeUsernameActivity.new UsernameHelpCell(changeUsernameActivity.getContext()));
}
if (viewType == 2) {
return new RecyclerListView.Holder(new TextInfoPrivacyCell(ChangeUsernameActivity.this.getContext()));
}
if (viewType == 3) {
ChangeUsernameActivity changeUsernameActivity2 = ChangeUsernameActivity.this;
return new RecyclerListView.Holder(changeUsernameActivity2.new InputCell(changeUsernameActivity2.getContext()));
}
if (viewType != 4) {
return null;
}
return new RecyclerListView.Holder(new UsernameCell(ChangeUsernameActivity.this.getContext(), ChangeUsernameActivity.this.getResourceProvider()) {
{
this.isProfile = true;
}
@Override
public String getUsernameEditable() {
return ChangeUsernameActivity.this.username;
}
});
}
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
String string;
int itemViewType = holder.getItemViewType();
if (itemViewType == 0) {
HeaderCell headerCell = (HeaderCell) holder.itemView;
if (position == 0) {
string = LocaleController.getString(ChangeUsernameActivity.this.botId != 0 ? R.string.BotSetPublicLinkHeader : R.string.SetUsernameHeader);
} else {
string = LocaleController.getString("UsernamesProfileHeader", R.string.UsernamesProfileHeader);
}
headerCell.setText(string);
return;
}
if (itemViewType == 2) {
((TextInfoPrivacyCell) holder.itemView).setText(LocaleController.getString(ChangeUsernameActivity.this.botId != 0 ? R.string.BotUsernamesHelp : R.string.UsernamesProfileHelp));
((TextInfoPrivacyCell) holder.itemView).setBackgroundDrawable(Theme.getThemedDrawableByKey(ChangeUsernameActivity.this.getContext(), R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
return;
}
if (itemViewType == 3) {
ChangeUsernameActivity.this.ignoreCheck = true;
ChangeUsernameActivity changeUsernameActivity = ChangeUsernameActivity.this;
InputCell inputCell = (InputCell) holder.itemView;
changeUsernameActivity.inputCell = inputCell;
inputCell.field.setText(ChangeUsernameActivity.this.username);
ChangeUsernameActivity.this.ignoreCheck = false;
return;
}
if (itemViewType != 4) {
return;
}
TLRPC.TL_username tL_username = (TLRPC.TL_username) ChangeUsernameActivity.this.usernames.get(position - 4);
UsernameCell usernameCell = (UsernameCell) holder.itemView;
if (tL_username.editable) {
ChangeUsernameActivity.this.editableUsernameCell = usernameCell;
} else if (ChangeUsernameActivity.this.editableUsernameCell == usernameCell) {
ChangeUsernameActivity.this.editableUsernameCell = null;
}
usernameCell.set(tL_username, position < getItemCount() - 2, false, ChangeUsernameActivity.this.botId);
}
public int getItemCount() {
return (ChangeUsernameActivity.this.usernames.size() > 0 ? ChangeUsernameActivity.this.usernames.size() + 1 + 1 : 0) + 3;
}
public int getItemViewType(int position) {
if (position == 0) {
return 0;
}
if (position == 1) {
return 3;
}
if (position == 2) {
return 1;
}
if (position == 3) {
return 0;
}
return position != getItemCount() - 1 ? 4 : 2;
}
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return holder.getItemViewType() == 4;
}
public void swapElements(int fromIndex, int toIndex) {
int i = fromIndex - 4;
int i2 = toIndex - 4;
if (i >= ChangeUsernameActivity.this.usernames.size() || i2 >= ChangeUsernameActivity.this.usernames.size()) {
return;
}
if (fromIndex != toIndex) {
ChangeUsernameActivity.this.needReorder = true;
}
swapListElements(ChangeUsernameActivity.this.usernames, i, i2);
notifyItemMoved(fromIndex, toIndex);
int size = (ChangeUsernameActivity.this.usernames.size() + 4) - 1;
if (fromIndex == size || toIndex == size) {
notifyItemChanged(fromIndex, 3);
notifyItemChanged(toIndex, 3);
}
}
public final void swapListElements(List<TLRPC.TL_username> list, int index1, int index2) {
TLRPC.TL_username tL_username = list.get(index1);
list.set(index1, list.get(index2));
list.set(index2, tL_username);
}
public void moveElement(int fromIndex, int toIndex) {
int i = fromIndex - 4;
int i2 = toIndex - 4;
if (i >= ChangeUsernameActivity.this.usernames.size() || i2 >= ChangeUsernameActivity.this.usernames.size()) {
return;
}
ChangeUsernameActivity.this.usernames.add(i2, (TLRPC.TL_username) ChangeUsernameActivity.this.usernames.remove(i));
notifyItemMoved(fromIndex, toIndex);
for (int i3 = 0; i3 < ChangeUsernameActivity.this.usernames.size(); i3++) {
notifyItemChanged(i3 + 4);
}
}
}
public final void sendReorder() {
TLRPC.TL_account_reorderUsernames tL_bots_reorderUsernames;
if (this.needReorder) {
this.needReorder = false;
ArrayList arrayList = new ArrayList();
for (int i = 0; i < this.notEditableUsernames.size(); i++) {
if (this.notEditableUsernames.get(i).active) {
arrayList.add(this.notEditableUsernames.get(i).username);
}
}
for (int i2 = 0; i2 < this.usernames.size(); i2++) {
if (this.usernames.get(i2).active) {
arrayList.add(this.usernames.get(i2).username);
}
}
if (this.botId == 0) {
tL_bots_reorderUsernames = new TLRPC.TL_account_reorderUsernames();
tL_bots_reorderUsernames.order = arrayList;
} else {
tL_bots_reorderUsernames = new TLRPC.TL_bots_reorderUsernames();
((TLRPC.TL_bots_reorderUsernames) tL_bots_reorderUsernames).bot = MessagesController.getInstance(((BaseFragment) this).currentAccount).getInputUser(this.botId);
((TLRPC.TL_bots_reorderUsernames) tL_bots_reorderUsernames).order = arrayList;
}
getConnectionsManager().sendRequest(tL_bots_reorderUsernames, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangeUsernameActivity.lambda$sendReorder$2(tLObject, tL_error);
}
});
updateUser();
}
}
public static void lambda$sendReorder$2(TLObject tLObject, TLRPC.TL_error tL_error) {
boolean z = tLObject instanceof TLRPC.TL_boolTrue;
}
public final void updateUser() {
ArrayList arrayList = new ArrayList();
arrayList.addAll(this.notEditableUsernames);
arrayList.addAll(this.usernames);
TLRPC.User user = MessagesController.getInstance(((BaseFragment) this).currentAccount).getUser(Long.valueOf(getUserId()));
user.usernames = arrayList;
MessagesController.getInstance(((BaseFragment) this).currentAccount).putUser(user, false, true);
}
public class UsernameHelpCell extends FrameLayout {
public Integer height;
public ValueAnimator heightUpdateAnimator;
public LinkSpanDrawable.LinksTextView text1View;
public LinkSpanDrawable.LinksTextView text2View;
public UsernameHelpCell(Context context) {
super(context);
ChangeUsernameActivity.this.helpCell = this;
setPadding(AndroidUtilities.dp(18.0f), AndroidUtilities.dp(10.0f), AndroidUtilities.dp(18.0f), AndroidUtilities.dp(17.0f));
setBackgroundDrawable(Theme.getThemedDrawableByKey(context, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
setClipChildren(false);
LinkSpanDrawable.LinksTextView linksTextView = new LinkSpanDrawable.LinksTextView(context);
this.text1View = linksTextView;
linksTextView.setTextSize(1, 15.0f);
LinkSpanDrawable.LinksTextView linksTextView2 = this.text1View;
int i = Theme.key_windowBackgroundWhiteGrayText8;
linksTextView2.setTextColor(Theme.getColor(i));
this.text1View.setGravity(LocaleController.isRTL ? 5 : 3);
LinkSpanDrawable.LinksTextView linksTextView3 = this.text1View;
int i2 = Theme.key_windowBackgroundWhiteLinkText;
linksTextView3.setLinkTextColor(Theme.getColor(i2));
LinkSpanDrawable.LinksTextView linksTextView4 = this.text1View;
int i3 = Theme.key_windowBackgroundWhiteLinkSelection;
linksTextView4.setHighlightColor(Theme.getColor(i3));
this.text1View.setPadding(AndroidUtilities.dp(3.0f), 0, AndroidUtilities.dp(3.0f), 0);
LinkSpanDrawable.LinksTextView linksTextView5 = new LinkSpanDrawable.LinksTextView(context, ChangeUsernameActivity.this) {
public void setText(CharSequence text, TextView.BufferType type) {
if (text != 0) {
text = AndroidUtilities.replaceTags(text.toString());
int indexOf = text.toString().indexOf(10);
if (indexOf >= 0) {
text.replace(indexOf, indexOf + 1, " ");
text.setSpan(new ForegroundColorSpan(ChangeUsernameActivity.this.getThemedColor(Theme.key_text_RedRegular)), 0, indexOf, 33);
}
TypefaceSpan[] typefaceSpanArr = (TypefaceSpan[]) text.getSpans(0, text.length(), TypefaceSpan.class);
for (int i4 = 0; i4 < typefaceSpanArr.length; i4++) {
text.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
Browser.openUrl(AnonymousClass1.this.getContext(), "https://fragment.com/username/" + ChangeUsernameActivity.this.username);
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setUnderlineText(false);
}
}, text.getSpanStart(typefaceSpanArr[i4]), text.getSpanEnd(typefaceSpanArr[i4]), 33);
text.removeSpan(typefaceSpanArr[i4]);
}
}
super.setText((CharSequence) text, type);
}
};
ChangeUsernameActivity.this.statusTextView = linksTextView5;
this.text2View = linksTextView5;
linksTextView5.setTextSize(1, 15.0f);
this.text2View.setTextColor(Theme.getColor(i));
this.text2View.setGravity(LocaleController.isRTL ? 5 : 3);
this.text2View.setLinkTextColor(Theme.getColor(i2));
this.text2View.setHighlightColor(Theme.getColor(i3));
this.text2View.setPadding(AndroidUtilities.dp(3.0f), 0, AndroidUtilities.dp(3.0f), 0);
addView((View) this.text1View, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -2, 48));
addView((View) this.text2View, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -2, 48));
if (ChangeUsernameActivity.this.botId != 0) {
String string = LocaleController.getString(R.string.BotUsernameHelp);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(string);
int indexOf = string.indexOf(42);
int lastIndexOf = string.lastIndexOf(42);
if (indexOf != -1 && lastIndexOf != -1 && indexOf != lastIndexOf) {
spannableStringBuilder.replace(lastIndexOf, lastIndexOf + 1, (CharSequence) "");
spannableStringBuilder.replace(indexOf, indexOf + 1, (CharSequence) "");
spannableStringBuilder.setSpan(new URLSpanNoUnderline("https://fragment.com"), indexOf, lastIndexOf - 1, 33);
}
this.text1View.setText(spannableStringBuilder);
return;
}
this.text1View.setText(AndroidUtilities.replaceTags(LocaleController.getString(R.string.UsernameHelp)));
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
Integer num = this.height;
if (num != null) {
heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(num.intValue(), 1073741824);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
public final void update() {
if (this.text2View.getVisibility() == 0) {
this.text2View.measure(View.MeasureSpec.makeMeasureSpec((getMeasuredWidth() - getPaddingLeft()) - getPaddingRight(), 1073741824), View.MeasureSpec.makeMeasureSpec(9999999, Integer.MIN_VALUE));
}
ValueAnimator valueAnimator = this.heightUpdateAnimator;
if (valueAnimator != null) {
valueAnimator.cancel();
}
Integer num = this.height;
final int measuredHeight = num == null ? getMeasuredHeight() : num.intValue();
final int dp = AndroidUtilities.dp(27.0f) + this.text1View.getHeight() + ((this.text2View.getVisibility() != 0 || TextUtils.isEmpty(this.text2View.getText())) ? 0 : this.text2View.getMeasuredHeight() + AndroidUtilities.dp(8.0f));
final float translationY = this.text1View.getTranslationY();
final float measuredHeight2 = (this.text2View.getVisibility() != 0 || TextUtils.isEmpty(this.text2View.getText())) ? 0.0f : this.text2View.getMeasuredHeight() + AndroidUtilities.dp(8.0f);
ValueAnimator ofFloat = ValueAnimator.ofFloat(0.0f, 1.0f);
this.heightUpdateAnimator = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
ChangeUsernameActivity.UsernameHelpCell.this.lambda$update$0(translationY, measuredHeight2, measuredHeight, dp, valueAnimator2);
}
});
this.heightUpdateAnimator.setDuration(200L);
this.heightUpdateAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
this.heightUpdateAnimator.start();
}
public void lambda$update$0(float f, float f2, int i, int i2, ValueAnimator valueAnimator) {
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
this.text1View.setTranslationY(AndroidUtilities.lerp(f, f2, floatValue));
this.height = Integer.valueOf(AndroidUtilities.lerp(i, i2, floatValue));
requestLayout();
}
}
public class InputCell extends FrameLayout {
public EditTextBoldCursor field;
public TextView tme;
public InputCell(Context context) {
super(context);
LinearLayout linearLayout = new LinearLayout(getContext());
linearLayout.setOrientation(0);
EditTextBoldCursor editTextBoldCursor = new EditTextBoldCursor(getContext());
this.field = editTextBoldCursor;
editTextBoldCursor.setTextSize(1, 17.0f);
this.field.setHintTextColor(Theme.usePlusTheme ? Theme.prefSummaryColor : Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
this.field.setTextColor(Theme.usePlusTheme ? Theme.prefTitleColor : Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
this.field.setBackgroundDrawable(null);
this.field.setMaxLines(1);
this.field.setLines(1);
this.field.setPadding(0, 0, 0, 0);
this.field.setSingleLine(true);
this.field.setGravity((LocaleController.isRTL ? 5 : 3) | 48);
this.field.setInputType(180224);
this.field.setImeOptions(6);
this.field.setHint(LocaleController.getString("UsernameLinkPlaceholder", R.string.UsernameLinkPlaceholder));
EditTextBoldCursor editTextBoldCursor2 = this.field;
int i = Theme.key_windowBackgroundWhiteBlackText;
editTextBoldCursor2.setCursorColor(Theme.getColor(i));
this.field.setCursorSize(AndroidUtilities.dp(19.0f));
this.field.setCursorWidth(1.5f);
this.field.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView, int i2, KeyEvent keyEvent) {
boolean lambda$new$0;
lambda$new$0 = ChangeUsernameActivity.InputCell.this.lambda$new$0(textView, i2, keyEvent);
return lambda$new$0;
}
});
this.field.setText(ChangeUsernameActivity.this.username);
this.field.addTextChangedListener(new TextWatcher(ChangeUsernameActivity.this) {
@Override
public void beforeTextChanged(CharSequence charSequence, int i2, int i22, int i3) {
String str = ChangeUsernameActivity.this.username;
ChangeUsernameActivity.this.username = charSequence == null ? "" : charSequence.toString();
updateUsernameCell(str);
}
@Override
public void onTextChanged(CharSequence charSequence, int i2, int i22, int i3) {
String str = ChangeUsernameActivity.this.username;
ChangeUsernameActivity.this.username = charSequence == null ? "" : charSequence.toString();
updateUsernameCell(str);
if (ChangeUsernameActivity.this.ignoreCheck) {
return;
}
ChangeUsernameActivity changeUsernameActivity = ChangeUsernameActivity.this;
changeUsernameActivity.checkUserName(changeUsernameActivity.username, false);
}
@Override
public void afterTextChanged(Editable editable) {
if (ChangeUsernameActivity.this.username.startsWith("@")) {
ChangeUsernameActivity changeUsernameActivity = ChangeUsernameActivity.this;
changeUsernameActivity.username = changeUsernameActivity.username.substring(1);
}
if (ChangeUsernameActivity.this.username.length() > 0) {
String str = "https://" + MessagesController.getInstance(((BaseFragment) ChangeUsernameActivity.this).currentAccount).linkPrefix + "/" + ChangeUsernameActivity.this.username;
String formatString = LocaleController.formatString("UsernameHelpLink", R.string.UsernameHelpLink, new Object[]{str});
int indexOf = formatString.indexOf(str);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(formatString);
if (indexOf >= 0) {
spannableStringBuilder.setSpan(ChangeUsernameActivity.this.new LinkSpan(str), indexOf, str.length() + indexOf, 33);
}
}
}
public final void updateUsernameCell(String was) {
if (ChangeUsernameActivity.this.editableUsernameCell == null || was == null) {
return;
}
ChangeUsernameActivity.this.editableUsernameCell.updateUsername(ChangeUsernameActivity.this.username);
}
});
if (ChangeUsernameActivity.this.botId != 0) {
this.field.setEnabled(false);
}
TextView textView = new TextView(getContext());
this.tme = textView;
textView.setMaxLines(1);
this.tme.setLines(1);
this.tme.setPadding(0, 0, 0, 0);
this.tme.setSingleLine(true);
this.tme.setText(ChangeUsernameActivity.this.getMessagesController().linkPrefix + "/");
this.tme.setTextSize(1, 17.0f);
this.tme.setTextColor(Theme.getColor(i));
this.tme.setGravity((LocaleController.isRTL ? 5 : 3) | 48);
this.tme.setTranslationY(-AndroidUtilities.dp(3.0f));
linearLayout.addView(this.tme, LayoutHelper.createLinear(-2, -2, 0.0f, 16, 21, 15, 0, 15));
linearLayout.addView((View) this.field, (ViewGroup.LayoutParams) LayoutHelper.createLinear(-2, -2, 1.0f, 16, 0, 15, 21, 15));
addView(linearLayout, LayoutHelper.createFrame(-1, -1, 48));
setBackgroundColor(ChangeUsernameActivity.this.getThemedColor(Theme.key_windowBackgroundWhite));
if (ChangeUsernameActivity.this.botId != 0) {
this.field.setAlpha(0.6f);
this.tme.setAlpha(0.6f);
}
}
public boolean lambda$new$0(TextView textView, int i, KeyEvent keyEvent) {
if (i != 6 || ChangeUsernameActivity.this.doneButton == null) {
return false;
}
ChangeUsernameActivity.this.doneButton.performClick();
return true;
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(50.0f), 1073741824));
}
}
public static class UsernameCell extends FrameLayout {
public boolean active;
public AnimatedFloat activeFloat;
public AnimatedTextView activeView;
public ValueAnimator activeViewTextColorAnimator;
public float activeViewTextColorT;
public long botId;
public TLRPC.TL_username currentUsername;
public boolean editable;
public boolean isProfile;
public Drawable[] linkDrawables;
public boolean loading;
public ValueAnimator loadingAnimator;
public CircularProgressDrawable loadingDrawable;
public float loadingFloat;
public ImageView loadingView;
public Theme.ResourcesProvider resourcesProvider;
public boolean useDivider;
public AnimatedFloat useDividerAlpha;
public SimpleTextView usernameView;
public String getUsernameEditable() {
return null;
}
public UsernameCell(Context context, Theme.ResourcesProvider resourcesProvider) {
super(context);
this.isProfile = false;
this.useDividerAlpha = new AnimatedFloat(this, 300L, CubicBezierInterpolator.DEFAULT);
this.activeFloat = new AnimatedFloat(this, 400L, CubicBezierInterpolator.EASE_OUT_QUINT);
this.resourcesProvider = resourcesProvider;
setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite, resourcesProvider));
SimpleTextView simpleTextView = new SimpleTextView(getContext());
this.usernameView = simpleTextView;
simpleTextView.setTextSize(16);
this.usernameView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider));
this.usernameView.setEllipsizeByGradient(true);
addView(this.usernameView, LayoutHelper.createFrame(-1, -2.0f, 48, 70.0f, 9.0f, 0.0f, 50.0f));
this.loadingView = new ImageView(getContext());
Drawable circularProgressDrawable = new CircularProgressDrawable(AndroidUtilities.dp(7.0f), AndroidUtilities.dp(1.35f), Theme.getColor(Theme.key_windowBackgroundWhiteBlueText, resourcesProvider));
this.loadingDrawable = circularProgressDrawable;
this.loadingView.setImageDrawable(circularProgressDrawable);
this.loadingView.setAlpha(0.0f);
this.loadingView.setVisibility(0);
this.loadingDrawable.setBounds(0, 0, AndroidUtilities.dp(14.0f), AndroidUtilities.dp(14.0f));
addView(this.loadingView, LayoutHelper.createFrame(14, 14.0f, 48, 70.0f, 35.0f, 0.0f, 0.0f));
AnimatedTextView animatedTextView = new AnimatedTextView(getContext(), false, true, true);
this.activeView = animatedTextView;
animatedTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, resourcesProvider));
this.activeView.setAnimationProperties(0.4f, 0L, 120L, CubicBezierInterpolator.EASE_OUT);
this.activeView.setTextSize(AndroidUtilities.dp(13.0f));
addView((View) this.activeView, (ViewGroup.LayoutParams) LayoutHelper.createFrame(-1, -2.0f, 48, 70.0f, 23.0f, 0.0f, 0.0f));
Drawable[] drawableArr = {ContextCompat.getDrawable(context, R.drawable.msg_link_1).mutate(), ContextCompat.getDrawable(context, R.drawable.msg_link_2).mutate()};
this.linkDrawables = drawableArr;
drawableArr[0].setColorFilter(new PorterDuffColorFilter(-1, PorterDuff.Mode.MULTIPLY));
this.linkDrawables[1].setColorFilter(new PorterDuffColorFilter(-1, PorterDuff.Mode.MULTIPLY));
ChangeUsernameActivity.linkBackgroundActive.setColor(Theme.getColor(Theme.key_featuredStickers_addButton, resourcesProvider));
ChangeUsernameActivity.linkBackgroundInactive.setColor(Theme.getColor(Theme.key_chats_unreadCounterMuted, resourcesProvider));
}
public void setLoading(final boolean loading) {
if (this.loading != loading) {
this.loading = loading;
ValueAnimator valueAnimator = this.loadingAnimator;
if (valueAnimator != null) {
valueAnimator.cancel();
}
this.loadingView.setVisibility(0);
float[] fArr = new float[2];
fArr[0] = this.loadingFloat;
fArr[1] = loading ? 1.0f : 0.0f;
ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
this.loadingAnimator = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
ChangeUsernameActivity.UsernameCell.this.lambda$setLoading$0(valueAnimator2);
}
});
this.loadingAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
UsernameCell.this.loadingView.setVisibility(loading ? 0 : 8);
}
});
this.loadingAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT);
this.loadingAnimator.setDuration(200L);
this.loadingAnimator.start();
}
}
public void lambda$setLoading$0(ValueAnimator valueAnimator) {
float floatValue = ((Float) valueAnimator.getAnimatedValue()).floatValue();
this.loadingFloat = floatValue;
this.activeView.setTranslationX(floatValue * AndroidUtilities.dp(16.0f));
this.loadingView.setAlpha(this.loadingFloat);
}
public void set(TLRPC.TL_username username, boolean useDivider, boolean animated) {
set(username, useDivider, animated, 0L);
}
public void set(TLRPC.TL_username username, boolean useDivider, boolean animated, long botId) {
int i;
String str;
int i2;
String str2;
this.currentUsername = username;
this.useDivider = useDivider;
this.botId = botId;
invalidate();
if (this.currentUsername == null) {
this.active = false;
this.editable = false;
return;
}
this.active = username.active;
this.editable = botId == 0 && username.editable;
updateUsername(username.username);
if (this.isProfile) {
AnimatedTextView animatedTextView = this.activeView;
if (this.editable) {
i2 = R.string.UsernameProfileLinkEditable;
str2 = "UsernameProfileLinkEditable";
} else if (this.active) {
i2 = R.string.UsernameProfileLinkActive;
str2 = "UsernameProfileLinkActive";
} else {
i2 = R.string.UsernameProfileLinkInactive;
str2 = "UsernameProfileLinkInactive";
}
animatedTextView.setText(LocaleController.getString(str2, i2), animated, !this.active);
} else {
AnimatedTextView animatedTextView2 = this.activeView;
if (this.editable) {
i = R.string.UsernameLinkEditable;
str = "UsernameLinkEditable";
} else if (this.active) {
i = R.string.UsernameLinkActive;
str = "UsernameLinkActive";
} else {
i = R.string.UsernameLinkInactive;
str = "UsernameLinkInactive";
}
animatedTextView2.setText(LocaleController.getString(str, i), animated, !this.active);
}
animateValueTextColor(this.active || this.editable, animated);
}
public void updateUsername(String username) {
if (this.editable) {
username = getUsernameEditable();
}
if (TextUtils.isEmpty(username)) {
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("@");
SpannableString spannableString = new SpannableString(LocaleController.getString("UsernameLinkPlaceholder", R.string.UsernameLinkPlaceholder));
spannableString.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_windowBackgroundWhiteHintText, this.resourcesProvider)), 0, spannableString.length(), 33);
spannableStringBuilder.append((CharSequence) spannableString);
this.usernameView.setText(spannableStringBuilder);
return;
}
this.usernameView.setText("@" + username);
}
public final void animateValueTextColor(boolean active, boolean animated) {
ValueAnimator valueAnimator = this.activeViewTextColorAnimator;
if (valueAnimator != null) {
valueAnimator.cancel();
this.activeViewTextColorAnimator = null;
}
if (animated) {
float[] fArr = new float[2];
fArr[0] = this.activeViewTextColorT;
fArr[1] = active ? 1.0f : 0.0f;
ValueAnimator ofFloat = ValueAnimator.ofFloat(fArr);
this.activeViewTextColorAnimator = ofFloat;
ofFloat.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public final void onAnimationUpdate(ValueAnimator valueAnimator2) {
ChangeUsernameActivity.UsernameCell.this.lambda$animateValueTextColor$1(valueAnimator2);
}
});
this.activeViewTextColorAnimator.setDuration(120L);
this.activeViewTextColorAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT);
this.activeViewTextColorAnimator.start();
return;
}
this.activeViewTextColorT = active ? 1.0f : 0.0f;
int blendARGB = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, this.resourcesProvider), Theme.getColor(Theme.key_windowBackgroundWhiteBlueText, this.resourcesProvider), this.activeViewTextColorT);
this.loadingDrawable.setColor(blendARGB);
this.activeView.setTextColor(blendARGB);
}
public void lambda$animateValueTextColor$1(ValueAnimator valueAnimator) {
this.activeViewTextColorT = ((Float) valueAnimator.getAnimatedValue()).floatValue();
int blendARGB = ColorUtils.blendARGB(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2, this.resourcesProvider), Theme.getColor(Theme.key_windowBackgroundWhiteBlueText, this.resourcesProvider), this.activeViewTextColorT);
this.loadingDrawable.setColor(blendARGB);
this.activeView.setTextColor(blendARGB);
}
public void update() {
TLRPC.TL_username tL_username = this.currentUsername;
if (tL_username != null) {
set(tL_username, this.useDivider, true, this.botId);
}
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.getSize(widthMeasureSpec), 1073741824), View.MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(58.0f), 1073741824));
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
float f = this.activeFloat.set(this.active ? 1.0f : 0.0f);
if (f < 1.0f) {
canvas.drawCircle(AndroidUtilities.dp(35.0f), AndroidUtilities.dp(29.0f), AndroidUtilities.dp(16.0f), ChangeUsernameActivity.linkBackgroundInactive);
this.linkDrawables[1].setAlpha((int) ((1.0f - f) * 255.0f));
this.linkDrawables[1].setBounds(AndroidUtilities.dp(35.0f) - (this.linkDrawables[1].getIntrinsicWidth() / 2), AndroidUtilities.dp(29.0f) - (this.linkDrawables[1].getIntrinsicHeight() / 2), AndroidUtilities.dp(35.0f) + (this.linkDrawables[1].getIntrinsicWidth() / 2), AndroidUtilities.dp(29.0f) + (this.linkDrawables[1].getIntrinsicHeight() / 2));
this.linkDrawables[1].draw(canvas);
}
if (f > 0.0f) {
int i = (int) (255.0f * f);
ChangeUsernameActivity.linkBackgroundActive.setAlpha(i);
canvas.drawCircle(AndroidUtilities.dp(35.0f), AndroidUtilities.dp(29.0f), AndroidUtilities.dp(16.0f) * f, ChangeUsernameActivity.linkBackgroundActive);
this.linkDrawables[0].setAlpha(i);
this.linkDrawables[0].setBounds(AndroidUtilities.dp(35.0f) - (this.linkDrawables[0].getIntrinsicWidth() / 2), AndroidUtilities.dp(29.0f) - (this.linkDrawables[0].getIntrinsicHeight() / 2), AndroidUtilities.dp(35.0f) + (this.linkDrawables[0].getIntrinsicWidth() / 2), AndroidUtilities.dp(29.0f) + (this.linkDrawables[0].getIntrinsicHeight() / 2));
this.linkDrawables[0].draw(canvas);
}
float f2 = this.useDividerAlpha.set(this.useDivider ? 1.0f : 0.0f);
if (f2 > 0.0f) {
int alpha = Theme.dividerPaint.getAlpha();
Theme.dividerPaint.setAlpha((int) (alpha * f2));
canvas.drawRect(AndroidUtilities.dp(70.0f), getHeight() - 1, getWidth(), getHeight(), Theme.dividerPaint);
Theme.dividerPaint.setAlpha(alpha);
}
ChangeUsernameActivity.dragPaint.setColor(Theme.getColor(Theme.key_stickers_menu));
ChangeUsernameActivity.dragPaint.setAlpha((int) (ChangeUsernameActivity.dragPaint.getAlpha() * f));
RectF rectF = AndroidUtilities.rectTmp;
rectF.set(getWidth() - AndroidUtilities.dp(37.0f), AndroidUtilities.dp(25.0f), getWidth() - AndroidUtilities.dp(21.0f), AndroidUtilities.dp(27.0f));
canvas.drawRoundRect(rectF, AndroidUtilities.dp(0.3f), AndroidUtilities.dp(0.3f), ChangeUsernameActivity.dragPaint);
rectF.set(getWidth() - AndroidUtilities.dp(37.0f), AndroidUtilities.dp(31.0f), getWidth() - AndroidUtilities.dp(21.0f), AndroidUtilities.dp(33.0f));
canvas.drawRoundRect(rectF, AndroidUtilities.dp(0.3f), AndroidUtilities.dp(0.3f), ChangeUsernameActivity.dragPaint);
}
}
public class TouchHelperCallback extends ItemTouchHelper.Callback {
public boolean isLongPressDragEnabled() {
return true;
}
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
}
public TouchHelperCallback() {
}
public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
if (viewHolder.getItemViewType() != 4 || !((UsernameCell) viewHolder.itemView).active) {
return ItemTouchHelper.Callback.makeMovementFlags(0, 0);
}
return ItemTouchHelper.Callback.makeMovementFlags(3, 0);
}
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder source, RecyclerView.ViewHolder target) {
if (source.getItemViewType() != target.getItemViewType()) {
return false;
}
View view = target.itemView;
if ((view instanceof UsernameCell) && !((UsernameCell) view).active) {
return false;
}
ChangeUsernameActivity.this.adapter.swapElements(source.getAdapterPosition(), target.getAdapterPosition());
return true;
}
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
public void onSelectedChanged(RecyclerView.ViewHolder viewHolder, int actionState) {
if (actionState == 0) {
ChangeUsernameActivity.this.sendReorder();
} else {
ChangeUsernameActivity.this.listView.cancelClickRunnables(false);
viewHolder.itemView.setPressed(true);
}
super.onSelectedChanged(viewHolder, actionState);
}
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder);
viewHolder.itemView.setPressed(false);
}
}
public void onResume() {
super.onResume();
if (!MessagesController.getGlobalMainSettings().getBoolean("view_animations", true)) {
focusUsernameField(false);
}
if (Theme.usePlusTheme) {
updateTheme();
}
}
public final void updateTheme() {
((BaseFragment) this).actionBar.setBackgroundColor(Theme.prefActionbarColor);
((BaseFragment) this).actionBar.setTitleColor(Theme.prefActionbarTitleColor);
Drawable drawable = getParentActivity().getResources().getDrawable(R.drawable.ic_ab_back);
drawable.setColorFilter(Theme.prefActionbarIconsColor, PorterDuff.Mode.MULTIPLY);
((BaseFragment) this).actionBar.setBackButtonDrawable(drawable);
((BaseFragment) this).actionBar.setItemsColor(Theme.prefActionbarIconsColor, false);
}
public final boolean checkUserName(final String name, boolean alert) {
if (name != null && name.startsWith("@")) {
name = name.substring(1);
}
LinkSpanDrawable.LinksTextView linksTextView = this.statusTextView;
if (linksTextView != null) {
linksTextView.setVisibility(!TextUtils.isEmpty(name) ? 0 : 8);
UsernameHelpCell usernameHelpCell = this.helpCell;
if (usernameHelpCell != null) {
usernameHelpCell.update();
}
}
if (alert && name.length() == 0) {
return true;
}
Runnable runnable = this.checkRunnable;
if (runnable != null) {
AndroidUtilities.cancelRunOnUIThread(runnable);
this.checkRunnable = null;
this.lastCheckName = null;
if (this.checkReqId != 0) {
ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).cancelRequest(this.checkReqId, true);
}
}
if (name != null) {
if (name.startsWith("_") || name.endsWith("_")) {
LinkSpanDrawable.LinksTextView linksTextView2 = this.statusTextView;
if (linksTextView2 != null) {
linksTextView2.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
LinkSpanDrawable.LinksTextView linksTextView3 = this.statusTextView;
int i = Theme.key_text_RedRegular;
linksTextView3.setTag(Integer.valueOf(i));
this.statusTextView.setTextColor(Theme.getColor(i));
UsernameHelpCell usernameHelpCell2 = this.helpCell;
if (usernameHelpCell2 != null) {
usernameHelpCell2.update();
}
}
return false;
}
for (int i2 = 0; i2 < name.length(); i2++) {
char charAt = name.charAt(i2);
if (i2 == 0 && charAt >= '0' && charAt <= '9') {
if (alert) {
AlertsCreator.showSimpleAlert(this, LocaleController.getString("UsernameInvalidStartNumber", R.string.UsernameInvalidStartNumber));
} else {
LinkSpanDrawable.LinksTextView linksTextView4 = this.statusTextView;
if (linksTextView4 != null) {
linksTextView4.setText(LocaleController.getString("UsernameInvalidStartNumber", R.string.UsernameInvalidStartNumber));
LinkSpanDrawable.LinksTextView linksTextView5 = this.statusTextView;
int i3 = Theme.key_text_RedRegular;
linksTextView5.setTag(Integer.valueOf(i3));
this.statusTextView.setTextColor(Theme.getColor(i3));
UsernameHelpCell usernameHelpCell3 = this.helpCell;
if (usernameHelpCell3 != null) {
usernameHelpCell3.update();
}
}
}
return false;
}
if ((charAt < '0' || charAt > '9') && ((charAt < 'a' || charAt > 'z') && ((charAt < 'A' || charAt > 'Z') && charAt != '_'))) {
if (alert) {
AlertsCreator.showSimpleAlert(this, LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
} else {
LinkSpanDrawable.LinksTextView linksTextView6 = this.statusTextView;
if (linksTextView6 != null) {
linksTextView6.setText(LocaleController.getString("UsernameInvalid", R.string.UsernameInvalid));
LinkSpanDrawable.LinksTextView linksTextView7 = this.statusTextView;
int i4 = Theme.key_text_RedRegular;
linksTextView7.setTag(Integer.valueOf(i4));
this.statusTextView.setTextColor(Theme.getColor(i4));
UsernameHelpCell usernameHelpCell4 = this.helpCell;
if (usernameHelpCell4 != null) {
usernameHelpCell4.update();
}
}
}
return false;
}
}
}
if (name == null || name.length() < 4) {
if (alert) {
AlertsCreator.showSimpleAlert(this, LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
} else {
LinkSpanDrawable.LinksTextView linksTextView8 = this.statusTextView;
if (linksTextView8 != null) {
linksTextView8.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
LinkSpanDrawable.LinksTextView linksTextView9 = this.statusTextView;
int i5 = Theme.key_text_RedRegular;
linksTextView9.setTag(Integer.valueOf(i5));
this.statusTextView.setTextColor(Theme.getColor(i5));
UsernameHelpCell usernameHelpCell5 = this.helpCell;
if (usernameHelpCell5 != null) {
usernameHelpCell5.update();
}
}
}
return false;
}
if (name.length() > 32) {
if (alert) {
AlertsCreator.showSimpleAlert(this, LocaleController.getString("UsernameInvalidLong", R.string.UsernameInvalidLong));
} else {
LinkSpanDrawable.LinksTextView linksTextView10 = this.statusTextView;
if (linksTextView10 != null) {
linksTextView10.setText(LocaleController.getString("UsernameInvalidLong", R.string.UsernameInvalidLong));
LinkSpanDrawable.LinksTextView linksTextView11 = this.statusTextView;
int i6 = Theme.key_text_RedRegular;
linksTextView11.setTag(Integer.valueOf(i6));
this.statusTextView.setTextColor(Theme.getColor(i6));
UsernameHelpCell usernameHelpCell6 = this.helpCell;
if (usernameHelpCell6 != null) {
usernameHelpCell6.update();
}
}
}
return false;
}
if (!alert) {
String str = getUser().username;
if (str == null) {
str = "";
}
if (name.equals(str)) {
LinkSpanDrawable.LinksTextView linksTextView12 = this.statusTextView;
if (linksTextView12 != null) {
linksTextView12.setText(LocaleController.formatString("UsernameAvailable", R.string.UsernameAvailable, new Object[]{name}));
LinkSpanDrawable.LinksTextView linksTextView13 = this.statusTextView;
int i7 = Theme.key_windowBackgroundWhiteGreenText;
linksTextView13.setTag(Integer.valueOf(i7));
this.statusTextView.setTextColor(Theme.getColor(i7));
UsernameHelpCell usernameHelpCell7 = this.helpCell;
if (usernameHelpCell7 != null) {
usernameHelpCell7.update();
}
}
return true;
}
LinkSpanDrawable.LinksTextView linksTextView14 = this.statusTextView;
if (linksTextView14 != null) {
linksTextView14.setText(LocaleController.getString("UsernameChecking", R.string.UsernameChecking));
LinkSpanDrawable.LinksTextView linksTextView15 = this.statusTextView;
int i8 = Theme.key_windowBackgroundWhiteGrayText8;
linksTextView15.setTag(Integer.valueOf(i8));
this.statusTextView.setTextColor(Theme.getColor(i8));
UsernameHelpCell usernameHelpCell8 = this.helpCell;
if (usernameHelpCell8 != null) {
usernameHelpCell8.update();
}
}
this.lastCheckName = name;
Runnable runnable2 = new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$checkUserName$5(name);
}
};
this.checkRunnable = runnable2;
AndroidUtilities.runOnUIThread(runnable2, 300L);
}
return true;
}
public void lambda$checkUserName$5(final String str) {
final TLRPC.TL_account_checkUsername tL_account_checkUsername = new TLRPC.TL_account_checkUsername();
tL_account_checkUsername.username = str;
this.checkReqId = ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_account_checkUsername, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangeUsernameActivity.this.lambda$checkUserName$4(str, tL_account_checkUsername, tLObject, tL_error);
}
}, 2);
}
public void lambda$checkUserName$4(final String str, final TLRPC.TL_account_checkUsername tL_account_checkUsername, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$checkUserName$3(str, tL_error, tLObject, tL_account_checkUsername);
}
});
}
public void lambda$checkUserName$3(String str, TLRPC.TL_error tL_error, TLObject tLObject, TLRPC.TL_account_checkUsername tL_account_checkUsername) {
this.checkReqId = 0;
String str2 = this.lastCheckName;
if (str2 == null || !str2.equals(str)) {
return;
}
if (tL_error == null && (tLObject instanceof TLRPC.TL_boolTrue)) {
LinkSpanDrawable.LinksTextView linksTextView = this.statusTextView;
if (linksTextView != null) {
linksTextView.setText(LocaleController.formatString("UsernameAvailable", R.string.UsernameAvailable, new Object[]{str}));
LinkSpanDrawable.LinksTextView linksTextView2 = this.statusTextView;
int i = Theme.key_windowBackgroundWhiteGreenText;
linksTextView2.setTag(Integer.valueOf(i));
this.statusTextView.setTextColor(Theme.getColor(i));
UsernameHelpCell usernameHelpCell = this.helpCell;
if (usernameHelpCell != null) {
usernameHelpCell.update();
return;
}
return;
}
return;
}
if (this.statusTextView != null) {
if (tL_error != null && "USERNAME_INVALID".equals(tL_error.text) && tL_account_checkUsername.username.length() == 4) {
this.statusTextView.setText(LocaleController.getString("UsernameInvalidShort", R.string.UsernameInvalidShort));
LinkSpanDrawable.LinksTextView linksTextView3 = this.statusTextView;
int i2 = Theme.key_text_RedRegular;
linksTextView3.setTag(Integer.valueOf(i2));
this.statusTextView.setTextColor(Theme.getColor(i2));
} else if (tL_error != null && "USERNAME_PURCHASE_AVAILABLE".equals(tL_error.text)) {
if (tL_account_checkUsername.username.length() == 4) {
this.statusTextView.setText(LocaleController.getString("UsernameInvalidShortPurchase", R.string.UsernameInvalidShortPurchase));
} else {
this.statusTextView.setText(LocaleController.getString("UsernameInUsePurchase", R.string.UsernameInUsePurchase));
}
LinkSpanDrawable.LinksTextView linksTextView4 = this.statusTextView;
int i3 = Theme.key_windowBackgroundWhiteGrayText8;
linksTextView4.setTag(Integer.valueOf(i3));
this.statusTextView.setTextColor(Theme.getColor(i3));
} else {
this.statusTextView.setText(LocaleController.getString("UsernameInUse", R.string.UsernameInUse));
LinkSpanDrawable.LinksTextView linksTextView5 = this.statusTextView;
int i4 = Theme.key_text_RedRegular;
linksTextView5.setTag(Integer.valueOf(i4));
this.statusTextView.setTextColor(Theme.getColor(i4));
}
UsernameHelpCell usernameHelpCell2 = this.helpCell;
if (usernameHelpCell2 != null) {
usernameHelpCell2.update();
}
}
}
public final void saveName() {
if (this.botId != 0) {
finishFragment();
return;
}
if (this.username.startsWith("@")) {
this.username = this.username.substring(1);
}
if (!this.username.isEmpty() && !checkUserName(this.username, false)) {
shakeIfOff();
return;
}
TLRPC.User user = getUser();
if (getParentActivity() == null || user == null) {
return;
}
String publicUsername = UserObject.getPublicUsername(user);
if (publicUsername == null) {
publicUsername = "";
}
if (publicUsername.equals(this.username)) {
finishFragment();
return;
}
final AlertDialog alertDialog = new AlertDialog(getParentActivity(), 3);
final TLRPC.TL_account_updateUsername tL_account_updateUsername = new TLRPC.TL_account_updateUsername();
tL_account_updateUsername.username = this.username;
NotificationCenter.getInstance(((BaseFragment) this).currentAccount).postNotificationName(NotificationCenter.updateInterfaces, new Object[]{Integer.valueOf(MessagesController.UPDATE_MASK_NAME)});
final int sendRequest = ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).sendRequest(tL_account_updateUsername, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
ChangeUsernameActivity.this.lambda$saveName$10(alertDialog, tL_account_updateUsername, tLObject, tL_error);
}
}, 2);
ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).bindRequestToGuid(sendRequest, ((BaseFragment) this).classGuid);
alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
ChangeUsernameActivity.this.lambda$saveName$11(sendRequest, dialogInterface);
}
});
alertDialog.show();
}
public void lambda$saveName$10(final AlertDialog alertDialog, final TLRPC.TL_account_updateUsername tL_account_updateUsername, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
final TLRPC.User user = (TLRPC.User) tLObject;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$saveName$6(alertDialog, user);
}
});
} else if ("USERNAME_NOT_MODIFIED".equals(tL_error.text)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$saveName$7(alertDialog);
}
});
} else if ("USERNAME_PURCHASE_AVAILABLE".equals(tL_error.text) || "USERNAME_INVALID".equals(tL_error.text)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$saveName$8(alertDialog);
}
});
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ChangeUsernameActivity.this.lambda$saveName$9(alertDialog, tL_error, tL_account_updateUsername);
}
});
}
}
public void lambda$saveName$6(AlertDialog alertDialog, TLRPC.User user) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
ArrayList arrayList = new ArrayList();
arrayList.add(user);
MessagesController.getInstance(((BaseFragment) this).currentAccount).putUsers(arrayList, false);
MessagesStorage.getInstance(((BaseFragment) this).currentAccount).putUsersAndChats(arrayList, (List) null, false, true);
UserConfig.getInstance(((BaseFragment) this).currentAccount).saveConfig(true);
finishFragment();
}
public void lambda$saveName$7(AlertDialog alertDialog) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
finishFragment();
}
public void lambda$saveName$8(AlertDialog alertDialog) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
shakeIfOff();
}
public void lambda$saveName$9(AlertDialog alertDialog, TLRPC.TL_error tL_error, TLRPC.TL_account_updateUsername tL_account_updateUsername) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
AlertsCreator.processError(((BaseFragment) this).currentAccount, tL_error, this, tL_account_updateUsername, new Object[0]);
shakeIfOff();
}
public void lambda$saveName$11(int i, DialogInterface dialogInterface) {
ConnectionsManager.getInstance(((BaseFragment) this).currentAccount).cancelRequest(i, true);
}
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
if (isOpen) {
focusUsernameField(false);
}
}
public void shakeIfOff() {
if (this.listView == null) {
return;
}
for (int i = 0; i < this.listView.getChildCount(); i++) {
View childAt = this.listView.getChildAt(i);
if ((childAt instanceof HeaderCell) && i == 0) {
AndroidUtilities.shakeViewSpring(((HeaderCell) childAt).getTextView());
} else if (childAt instanceof UsernameHelpCell) {
AndroidUtilities.shakeViewSpring(childAt);
} else if (childAt instanceof InputCell) {
InputCell inputCell = (InputCell) childAt;
AndroidUtilities.shakeViewSpring(inputCell.field);
AndroidUtilities.shakeViewSpring(inputCell.tme);
}
}
BotWebViewVibrationEffect.APP_ERROR.vibrate();
}
public ArrayList<ThemeDescription> getThemeDescriptions() {
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
arrayList.add(new ThemeDescription(((BaseFragment) this).fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
arrayList.add(new ThemeDescription(((BaseFragment) this).actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
return arrayList;
}
public void onBecomeFullyVisible() {
super.onBecomeFullyVisible();
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
if (iNavigationLayout == null || iNavigationLayout.getDrawerLayoutContainer() == null) {
return;
}
((BaseFragment) this).parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(getThemedColor(Theme.key_windowBackgroundGray));
}
public void onBecomeFullyHidden() {
super.onBecomeFullyHidden();
INavigationLayout iNavigationLayout = ((BaseFragment) this).parentLayout;
if (iNavigationLayout == null || iNavigationLayout.getDrawerLayoutContainer() == null) {
return;
}
((BaseFragment) this).parentLayout.getDrawerLayoutContainer().setBehindKeyboardColor(Theme.getColor(Theme.key_windowBackgroundWhite));
}
}