正在查看: Plus 12 v10.13.1.1 应用的 ThemeEditorView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Plus 12 v10.13.1.1 应用的 ThemeEditorView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui.Components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ComposeShader;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.RadialGradient;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.text.Editable;
import android.text.InputFilter;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.Property;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.DecelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Keep;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import org.telegram.messenger.Utilities;
import org.telegram.ui.ActionBar.ActionBar;
import org.telegram.ui.ActionBar.AlertDialog;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeColors;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Cells.TextColorThemeCell;
import org.telegram.ui.Components.HistorySelectorView;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.ThemeEditorView;
import org.telegram.ui.Components.WallpaperUpdater;
import org.telegram.ui.LaunchActivity;
public class ThemeEditorView {
@SuppressLint({"StaticFieldLeak"})
public static volatile ThemeEditorView Instance;
public ArrayList<ThemeDescription> currentThemeDesription;
public int currentThemeDesriptionPosition;
public DecelerateInterpolator decelerateInterpolator;
public EditorAlert editorAlert;
public boolean keyEditing;
public Activity parentActivity;
public SharedPreferences preferences;
public Theme.ThemeInfo themeInfo;
public WallpaperUpdater wallpaperUpdater;
public WindowManager.LayoutParams windowLayoutParams;
public WindowManager windowManager;
public FrameLayout windowView;
public final int editorWidth = AndroidUtilities.dp(54.0f);
public final int editorHeight = AndroidUtilities.dp(54.0f);
public boolean sortAlphabetically = false;
public static ThemeEditorView getInstance() {
return Instance;
}
public void destroy() {
FrameLayout frameLayout;
this.wallpaperUpdater.cleanup();
if (this.parentActivity == null || (frameLayout = this.windowView) == null) {
return;
}
try {
this.windowManager.removeViewImmediate(frameLayout);
this.windowView = null;
} catch (Exception e) {
FileLog.e(e, false);
}
try {
EditorAlert editorAlert = this.editorAlert;
if (editorAlert != null) {
editorAlert.dismiss();
this.editorAlert = null;
}
} catch (Exception e2) {
FileLog.e(e2);
}
this.parentActivity = null;
Instance = null;
}
public class EditorAlert extends BottomSheet {
public boolean animationInProgress;
public FrameLayout bottomLayout;
public FrameLayout bottomSaveLayout;
public AnimatorSet colorChangeAnimation;
public ColorPicker colorPicker;
public FrameLayout frameLayout;
public HistorySelectorView history;
public boolean ignoreTextChange;
public TextView keyTextView;
public LinearLayoutManager layoutManager;
public ListAdapter listAdapter;
public RecyclerListView listView;
public int previousScrollPosition;
public int scrollOffsetY;
public SearchAdapter searchAdapter;
public EmptyTextProgressView searchEmptyView;
public SearchField searchField;
public View[] shadow;
public AnimatorSet[] shadowAnimation;
public Drawable shadowDrawable;
public boolean startedColorChange;
public int topBeforeSwitch;
public boolean canDismissWithSwipe() {
return false;
}
public class SearchField extends FrameLayout {
public ImageView clearSearchImageView;
public EditTextBoldCursor searchEditText;
public SearchField(Context context) {
super(context);
View view = new View(context);
view.setBackgroundDrawable(Theme.createRoundRectDrawable(AndroidUtilities.dp(18.0f), Theme.getColor(Theme.key_dialogSearchBackground)));
addView(view, LayoutHelper.createFrame(-1, 36.0f, 51, 14.0f, 11.0f, 14.0f, 0.0f));
ImageView imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setImageResource(R.drawable.smiles_inputsearch);
imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_dialogSearchIcon), PorterDuff.Mode.MULTIPLY));
addView(imageView, LayoutHelper.createFrame(36, 36.0f, 51, 16.0f, 11.0f, 0.0f, 0.0f));
ImageView imageView2 = new ImageView(context);
this.clearSearchImageView = imageView2;
imageView2.setScaleType(ImageView.ScaleType.CENTER);
ImageView imageView3 = this.clearSearchImageView;
CloseProgressDrawable2 closeProgressDrawable2 = new CloseProgressDrawable2(this, EditorAlert.this) {
@Override
public int getCurrentColor() {
return Theme.getColor(Theme.key_dialogSearchIcon);
}
};
imageView3.setImageDrawable(closeProgressDrawable2);
closeProgressDrawable2.setSide(AndroidUtilities.dp(7.0f));
this.clearSearchImageView.setScaleX(0.1f);
this.clearSearchImageView.setScaleY(0.1f);
this.clearSearchImageView.setAlpha(0.0f);
addView(this.clearSearchImageView, LayoutHelper.createFrame(36, 36.0f, 53, 14.0f, 11.0f, 14.0f, 0.0f));
this.clearSearchImageView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.SearchField.this.lambda$new$0(view2);
}
});
EditTextBoldCursor editTextBoldCursor = new EditTextBoldCursor(context, EditorAlert.this) {
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
MotionEvent obtain = MotionEvent.obtain(event);
obtain.setLocation(obtain.getRawX(), obtain.getRawY() - ((BottomSheet) EditorAlert.this).containerView.getTranslationY());
EditorAlert.this.listView.dispatchTouchEvent(obtain);
obtain.recycle();
return super.dispatchTouchEvent(event);
}
};
this.searchEditText = editTextBoldCursor;
editTextBoldCursor.setTextSize(1, 16.0f);
this.searchEditText.setHintTextColor(Theme.getColor(Theme.key_dialogSearchHint));
this.searchEditText.setTextColor(Theme.getColor(Theme.key_dialogSearchText));
this.searchEditText.setBackgroundDrawable(null);
this.searchEditText.setPadding(0, 0, 0, 0);
this.searchEditText.setMaxLines(1);
this.searchEditText.setLines(1);
this.searchEditText.setSingleLine(true);
this.searchEditText.setImeOptions(268435459);
this.searchEditText.setHint(LocaleController.getString("Search", R.string.Search));
this.searchEditText.setCursorColor(Theme.getColor(Theme.key_chat_TextSelectionCursor));
this.searchEditText.setCursorSize(AndroidUtilities.dp(20.0f));
this.searchEditText.setCursorWidth(1.5f);
addView(this.searchEditText, LayoutHelper.createFrame(-1, 40.0f, 51, 54.0f, 9.0f, 46.0f, 0.0f));
this.searchEditText.addTextChangedListener(new TextWatcher(EditorAlert.this) {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
boolean z = SearchField.this.searchEditText.length() > 0;
if (z != (SearchField.this.clearSearchImageView.getAlpha() != 0.0f)) {
SearchField.this.clearSearchImageView.animate().alpha(z ? 1.0f : 0.0f).setDuration(150L).scaleX(z ? 1.0f : 0.1f).scaleY(z ? 1.0f : 0.1f).start();
}
String obj = SearchField.this.searchEditText.getText().toString();
if (obj.length() != 0) {
if (EditorAlert.this.searchEmptyView != null) {
EditorAlert.this.searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
}
} else if (EditorAlert.this.listView.getAdapter() != EditorAlert.this.listAdapter) {
int currentTop = EditorAlert.this.getCurrentTop();
EditorAlert.this.searchEmptyView.setText(LocaleController.getString("NoChats", R.string.NoChats));
EditorAlert.this.searchEmptyView.showTextView();
EditorAlert.this.listView.setAdapter(EditorAlert.this.listAdapter);
EditorAlert.this.listAdapter.notifyDataSetChanged();
if (currentTop > 0) {
EditorAlert.this.layoutManager.scrollToPositionWithOffset(0, -currentTop);
}
}
if (EditorAlert.this.searchAdapter != null) {
EditorAlert.this.searchAdapter.searchDialogs(obj);
}
}
});
this.searchEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
boolean lambda$new$1;
lambda$new$1 = ThemeEditorView.EditorAlert.SearchField.this.lambda$new$1(textView, i, keyEvent);
return lambda$new$1;
}
});
}
public void lambda$new$0(View view) {
this.searchEditText.setText(BuildConfig.APP_CENTER_HASH);
AndroidUtilities.showKeyboard(this.searchEditText);
}
public boolean lambda$new$1(TextView textView, int i, KeyEvent keyEvent) {
if (keyEvent == null) {
return false;
}
if ((keyEvent.getAction() != 1 || keyEvent.getKeyCode() != 84) && (keyEvent.getAction() != 0 || keyEvent.getKeyCode() != 66)) {
return false;
}
AndroidUtilities.hideKeyboard(this.searchEditText);
return false;
}
public void showKeyboard() {
this.searchEditText.requestFocus();
AndroidUtilities.showKeyboard(this.searchEditText);
}
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
super.requestDisallowInterceptTouchEvent(disallowIntercept);
}
}
public class ColorPicker extends FrameLayout {
public float alpha;
public LinearGradient alphaGradient;
public boolean alphaPressed;
public Drawable circleDrawable;
public Paint circlePaint;
public boolean circlePressed;
public EditTextBoldCursor[] colorEditText;
public LinearGradient colorGradient;
public float[] colorHSV;
public boolean colorPressed;
public Bitmap colorWheelBitmap;
public Paint colorWheelPaint;
public int colorWheelRadius;
public DecelerateInterpolator decelerateInterpolator;
public EditTextBoldCursor[] hexColorEditText;
public float[] hsvTemp;
public LinearLayout linearLayout;
public LinearLayout linearLayout2;
public final int paramValueSliderWidth;
public Paint valueSliderPaint;
public ColorPicker(Context context) {
super(context);
this.paramValueSliderWidth = AndroidUtilities.dp(30.0f);
this.colorEditText = new EditTextBoldCursor[4];
this.colorHSV = new float[]{0.0f, 0.0f, 1.0f};
this.alpha = 1.0f;
this.hsvTemp = new float[3];
this.decelerateInterpolator = new DecelerateInterpolator();
?? r5 = 0;
setWillNotDraw(false);
this.circlePaint = new Paint(1);
this.circleDrawable = context.getResources().getDrawable(R.drawable.knob_shadow).mutate();
Paint paint = new Paint();
this.colorWheelPaint = paint;
paint.setAntiAlias(true);
this.colorWheelPaint.setDither(true);
Paint paint2 = new Paint();
this.valueSliderPaint = paint2;
paint2.setAntiAlias(true);
this.valueSliderPaint.setDither(true);
LinearLayout linearLayout = new LinearLayout(context);
this.linearLayout = linearLayout;
linearLayout.setOrientation(0);
addView(this.linearLayout, LayoutHelper.createFrame(-2, -2, 49));
LinearLayout linearLayout2 = new LinearLayout(context);
this.linearLayout2 = linearLayout2;
linearLayout2.setOrientation(0);
addView(this.linearLayout2, LayoutHelper.createFrame(-2, -2.0f, 49, 0.0f, 40.0f, 0.0f, 0.0f));
EditorAlert.this.history = new HistorySelectorView(context, 1);
EditorAlert.this.history.setWillNotDraw(false);
EditorAlert.this.history.setOnColorChangedListener(new HistorySelectorView.OnColorChangedListener(EditorAlert.this) {
@Override
public void colorChanged(int color) {
EditorAlert.this.colorPicker.setColor(color);
for (int i = 0; i < ThemeEditorView.this.currentThemeDesription.size(); i++) {
((ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i)).setColor(ColorPicker.this.getColor(), false);
}
}
});
EditorAlert.this.history.setOrientation(0);
addView(EditorAlert.this.history, LayoutHelper.createFrame(-2, -2, 81));
EditorAlert.this.keyTextView = new TextView(context);
EditorAlert.this.keyTextView.setTextSize(2, 12.0f);
EditorAlert.this.keyTextView.setTextColor(Theme.getColor(Theme.key_dialogSearchText));
addView(EditorAlert.this.keyTextView, LayoutHelper.createFrame(-2, -2.0f, 83, 4.0f, 0.0f, 0.0f, 54.0f));
int i = 0;
for (int i2 = 4; i < i2; i2 = 4) {
this.colorEditText[i] = new EditTextBoldCursor(context);
this.colorEditText[i].setInputType(2);
EditTextBoldCursor editTextBoldCursor = this.colorEditText[i];
int i3 = Theme.key_dialogSearchText;
editTextBoldCursor.setTextColor(Theme.getColor(i3));
this.colorEditText[i].setCursorColor(Theme.getColor(i3));
this.colorEditText[i].setCursorSize(AndroidUtilities.dp(20.0f));
this.colorEditText[i].setCursorWidth(1.5f);
this.colorEditText[i].setTextSize(1, 18.0f);
this.colorEditText[i].setBackground(null);
this.colorEditText[i].setLineColors(Theme.getColor(Theme.key_dialogInputField), Theme.getColor(Theme.key_dialogInputFieldActivated), Theme.getColor(Theme.key_text_RedBold));
this.colorEditText[i].setMaxLines(1);
this.colorEditText[i].setTag(Integer.valueOf(i));
this.colorEditText[i].setGravity(17);
if (i == 0) {
this.colorEditText[i].setHint("red");
} else if (i == 1) {
this.colorEditText[i].setHint("green");
} else if (i == 2) {
this.colorEditText[i].setHint("blue");
} else if (i == 3) {
this.colorEditText[i].setHint("alpha");
}
this.colorEditText[i].setImeOptions((i == 3 ? 6 : 5) | 268435456);
this.colorEditText[i].setFilters(new InputFilter[]{new InputFilter.LengthFilter(3)});
this.linearLayout.addView(this.colorEditText[i], LayoutHelper.createLinear(55, 36, 0.0f, 0.0f, i != 3 ? 16.0f : 0.0f, 0.0f));
this.colorEditText[i].addTextChangedListener(new TextWatcher(EditorAlert.this, i) {
public final int val$num;
@Override
public void beforeTextChanged(CharSequence charSequence, int i4, int i22, int i32) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i4, int i22, int i32) {
}
{
this.val$num = i;
}
@Override
public void afterTextChanged(android.text.Editable r8) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Components.ThemeEditorView.EditorAlert.ColorPicker.AnonymousClass2.afterTextChanged(android.text.Editable):void");
}
});
this.colorEditText[i].setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView, int i4, KeyEvent keyEvent) {
boolean lambda$new$0;
lambda$new$0 = ThemeEditorView.EditorAlert.ColorPicker.lambda$new$0(textView, i4, keyEvent);
return lambda$new$0;
}
});
i++;
}
this.hexColorEditText = new EditTextBoldCursor[2];
int i4 = 0;
while (true) {
EditTextBoldCursor[] editTextBoldCursorArr = this.hexColorEditText;
if (i4 >= editTextBoldCursorArr.length) {
return;
}
if (i4 % 2 == 0) {
editTextBoldCursorArr[i4] = new EditTextBoldCursor(context, EditorAlert.this, i4) {
public final int val$num;
{
this.val$num = i4;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (getAlpha() == 1.0f && event.getAction() == 0) {
if (ColorPicker.this.hexColorEditText[this.val$num + 1].isFocused()) {
AndroidUtilities.showKeyboard(ColorPicker.this.hexColorEditText[this.val$num + 1]);
} else {
ColorPicker.this.hexColorEditText[this.val$num + 1].requestFocus();
}
}
return false;
}
};
this.hexColorEditText[i4].setBackgroundDrawable(null);
this.hexColorEditText[i4].setText("#");
this.hexColorEditText[i4].setEnabled(r5);
this.hexColorEditText[i4].setFocusable((boolean) r5);
this.linearLayout2.addView(this.hexColorEditText[i4], LayoutHelper.createLinear(-2, -1));
} else {
editTextBoldCursorArr[i4] = new EditTextBoldCursor(context, EditorAlert.this, i4) {
public final int val$num;
{
this.val$num = i4;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (getAlpha() != 1.0f) {
return false;
}
if (!isFocused()) {
requestFocus();
return false;
}
AndroidUtilities.showKeyboard(this);
return super.onTouchEvent(event);
}
@Override
public boolean getGlobalVisibleRect(android.graphics.Rect r, android.graphics.Point globalOffset) {
boolean globalVisibleRect = super.getGlobalVisibleRect(r, globalOffset);
r.bottom += AndroidUtilities.dp(40.0f);
return globalVisibleRect;
}
@Override
public void invalidate() {
super.invalidate();
ColorPicker.this.hexColorEditText[this.val$num - 1].invalidate();
}
};
this.hexColorEditText[i4].setBackgroundDrawable(null);
EditTextBoldCursor editTextBoldCursor2 = this.hexColorEditText[i4];
InputFilter[] inputFilterArr = new InputFilter[1];
inputFilterArr[r5] = new InputFilter.LengthFilter(8);
editTextBoldCursor2.setFilters(inputFilterArr);
this.hexColorEditText[i4].setHint("FF009688");
this.linearLayout2.addView(this.hexColorEditText[i4], LayoutHelper.createLinear(-2, -1));
this.hexColorEditText[i4].addTextChangedListener(new TextWatcher(EditorAlert.this, i4) {
public final int val$num;
@Override
public void beforeTextChanged(CharSequence charSequence, int i5, int i22, int i32) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i5, int i22, int i32) {
}
{
this.val$num = i4;
}
@Override
public void afterTextChanged(Editable editable) {
if (EditorAlert.this.ignoreTextChange) {
return;
}
EditorAlert.this.ignoreTextChange = true;
int i5 = 0;
while (i5 < editable.length()) {
char charAt = editable.charAt(i5);
if ((charAt < '0' || charAt > '9') && ((charAt < 'a' || charAt > 'f') && (charAt < 'A' || charAt > 'F'))) {
editable.replace(i5, i5 + 1, BuildConfig.APP_CENTER_HASH);
i5--;
}
i5++;
}
if (editable.length() == 0) {
EditorAlert.this.ignoreTextChange = false;
return;
}
try {
int parseColor = Color.parseColor("#" + String.format("%-8s", editable).replace(' ', '0'));
int red = Color.red(parseColor);
int green = Color.green(parseColor);
int blue = Color.blue(parseColor);
int alpha = Color.alpha(parseColor);
if (editable.length() == 8) {
editable.replace(0, editable.length(), String.format("%02x%02x%02x%02x", Byte.valueOf((byte) alpha), Byte.valueOf((byte) red), Byte.valueOf((byte) green), Byte.valueOf((byte) blue)).toUpperCase());
ColorPicker.this.hexColorEditText[this.val$num].setSelection(editable.length());
}
ColorPicker.this.colorEditText[0].setText(BuildConfig.APP_CENTER_HASH + red);
ColorPicker.this.colorEditText[1].setText(BuildConfig.APP_CENTER_HASH + green);
ColorPicker.this.colorEditText[2].setText(BuildConfig.APP_CENTER_HASH + blue);
ColorPicker.this.colorEditText[3].setText(BuildConfig.APP_CENTER_HASH + alpha);
for (int i6 = 0; i6 < 4; i6++) {
ColorPicker.this.colorEditText[i6].setSelection(ColorPicker.this.colorEditText[i6].length());
}
ColorPicker.this.setColor(parseColor);
for (int i7 = 0; i7 < ThemeEditorView.this.currentThemeDesription.size(); i7++) {
((ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i7)).setColor(ColorPicker.this.getColor(), false);
}
} catch (Exception e) {
e.printStackTrace();
}
EditorAlert.this.ignoreTextChange = false;
}
});
this.hexColorEditText[i4].setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public final boolean onEditorAction(TextView textView, int i5, KeyEvent keyEvent) {
boolean lambda$new$1;
lambda$new$1 = ThemeEditorView.EditorAlert.ColorPicker.lambda$new$1(textView, i5, keyEvent);
return lambda$new$1;
}
});
}
this.hexColorEditText[i4].setTextSize(1, 18.0f);
EditTextBoldCursor editTextBoldCursor3 = this.hexColorEditText[i4];
int i5 = Theme.key_dialogSearchText;
editTextBoldCursor3.setTextColor(Theme.getColor(i5));
this.hexColorEditText[i4].setCursorColor(Theme.getColor(i5));
this.hexColorEditText[i4].setCursorSize(AndroidUtilities.dp(20.0f));
this.hexColorEditText[i4].setCursorWidth(1.5f);
this.hexColorEditText[i4].setSingleLine(true);
this.hexColorEditText[i4].setBackground(null);
this.hexColorEditText[i4].setLineColors(Theme.getColor(Theme.key_dialogInputField), Theme.getColor(Theme.key_dialogInputFieldActivated), Theme.getColor(Theme.key_text_RedBold));
this.hexColorEditText[i4].setGravity(17);
this.hexColorEditText[i4].setInputType(524416);
this.hexColorEditText[i4].setImeOptions(268435462);
if (i4 == 1) {
this.hexColorEditText[i4].requestFocus();
} else if (i4 == 2 || i4 == 3) {
this.hexColorEditText[i4].setVisibility(8);
}
i4++;
r5 = 0;
}
}
public static boolean lambda$new$0(TextView textView, int i, KeyEvent keyEvent) {
if (i != 6) {
return false;
}
AndroidUtilities.hideKeyboard(textView);
return true;
}
public static boolean lambda$new$1(TextView textView, int i, KeyEvent keyEvent) {
if (i != 6) {
return false;
}
AndroidUtilities.hideKeyboard(textView);
return true;
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int min = Math.min(View.MeasureSpec.getSize(widthMeasureSpec), View.MeasureSpec.getSize(heightMeasureSpec));
measureChild(this.linearLayout, widthMeasureSpec, heightMeasureSpec);
measureChild(this.linearLayout2, widthMeasureSpec, heightMeasureSpec);
measureChild(EditorAlert.this.keyTextView, widthMeasureSpec, heightMeasureSpec);
measureChild(EditorAlert.this.history, widthMeasureSpec, heightMeasureSpec);
setMeasuredDimension(min, min);
}
@Override
public void onDraw(Canvas canvas) {
float f;
int width = (getWidth() / 2) - (this.paramValueSliderWidth * 2);
int height = (getHeight() / 2) - AndroidUtilities.dp(8.0f);
Bitmap bitmap = this.colorWheelBitmap;
int i = this.colorWheelRadius;
canvas.drawBitmap(bitmap, width - i, height - i, (Paint) null);
double radians = (float) Math.toRadians(this.colorHSV[0]);
double d = -Math.cos(radians);
double d2 = this.colorHSV[1];
Double.isNaN(d2);
double d3 = d * d2;
double d4 = this.colorWheelRadius;
Double.isNaN(d4);
int i2 = ((int) (d3 * d4)) + width;
double d5 = -Math.sin(radians);
float[] fArr = this.colorHSV;
double d6 = fArr[1];
Double.isNaN(d6);
double d7 = d5 * d6;
double d8 = this.colorWheelRadius;
Double.isNaN(d8);
float[] fArr2 = this.hsvTemp;
fArr2[0] = fArr[0];
fArr2[1] = fArr[1];
fArr2[2] = 1.0f;
drawPointerArrow(canvas, i2, ((int) (d7 * d8)) + height, Color.HSVToColor(fArr2));
int i3 = this.colorWheelRadius;
int i4 = width + i3 + this.paramValueSliderWidth;
int i5 = height - i3;
int dp = AndroidUtilities.dp(9.0f);
int i6 = this.colorWheelRadius * 2;
if (this.colorGradient == null) {
this.colorGradient = new LinearGradient(i4, i5, i4 + dp, i5 + i6, new int[]{-16777216, Color.HSVToColor(this.hsvTemp)}, (float[]) null, Shader.TileMode.CLAMP);
}
this.valueSliderPaint.setShader(this.colorGradient);
float f2 = i5;
float f3 = i5 + i6;
canvas.drawRect(i4, f2, i4 + dp, f3, this.valueSliderPaint);
int i7 = dp / 2;
float[] fArr3 = this.colorHSV;
float f4 = i6;
drawPointerArrow(canvas, i4 + i7, (int) ((fArr3[2] * f4) + f2), Color.HSVToColor(fArr3));
int i8 = i4 + (this.paramValueSliderWidth * 2);
if (this.alphaGradient == null) {
int HSVToColor = Color.HSVToColor(this.hsvTemp);
f = f3;
this.alphaGradient = new LinearGradient(i8, f2, i8 + dp, f, new int[]{HSVToColor, HSVToColor & 16777215}, (float[]) null, Shader.TileMode.CLAMP);
} else {
f = f3;
}
this.valueSliderPaint.setShader(this.alphaGradient);
canvas.drawRect(i8, f2, dp + i8, f, this.valueSliderPaint);
drawPointerArrow(canvas, i8 + i7, (int) (f2 + ((1.0f - this.alpha) * f4)), (Color.HSVToColor(this.colorHSV) & 16777215) | (((int) (this.alpha * 255.0f)) << 24));
}
public final void drawPointerArrow(Canvas canvas, int x, int y, int color) {
int dp = AndroidUtilities.dp(13.0f);
this.circleDrawable.setBounds(x - dp, y - dp, x + dp, dp + y);
this.circleDrawable.draw(canvas);
this.circlePaint.setColor(-1);
float f = x;
float f2 = y;
canvas.drawCircle(f, f2, AndroidUtilities.dp(11.0f), this.circlePaint);
this.circlePaint.setColor(color);
canvas.drawCircle(f, f2, AndroidUtilities.dp(9.0f), this.circlePaint);
}
@Override
public void onSizeChanged(int width, int height, int oldw, int oldh) {
int max = Math.max(1, ((width / 2) - (this.paramValueSliderWidth * 2)) - AndroidUtilities.dp(20.0f));
this.colorWheelRadius = max;
this.colorWheelBitmap = createColorWheelBitmap(max * 2, max * 2);
this.colorGradient = null;
this.alphaGradient = null;
}
public final Bitmap createColorWheelBitmap(int width, int height) {
Bitmap createBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
int[] iArr = new int[13];
float[] fArr = {0.0f, 1.0f, 1.0f};
for (int i = 0; i < 13; i++) {
fArr[0] = ((i * 30) + 180) % 360;
iArr[i] = Color.HSVToColor(fArr);
}
iArr[12] = iArr[0];
float f = width / 2;
float f2 = height / 2;
this.colorWheelPaint.setShader(new ComposeShader(new SweepGradient(f, f2, iArr, (float[]) null), new RadialGradient(f, f2, this.colorWheelRadius, -1, 16777215, Shader.TileMode.CLAMP), PorterDuff.Mode.SRC_OVER));
new Canvas(createBitmap).drawCircle(f, f2, this.colorWheelRadius, this.colorWheelPaint);
return createBitmap;
}
public final void startColorChange(boolean start) {
if (EditorAlert.this.startedColorChange == start || ThemeEditorView.this.keyEditing) {
return;
}
if (EditorAlert.this.colorChangeAnimation != null) {
EditorAlert.this.colorChangeAnimation.cancel();
}
EditorAlert.this.startedColorChange = start;
EditorAlert.this.colorChangeAnimation = new AnimatorSet();
AnimatorSet animatorSet = EditorAlert.this.colorChangeAnimation;
Animator[] animatorArr = new Animator[2];
ColorDrawable colorDrawable = ((BottomSheet) EditorAlert.this).backDrawable;
Property<ColorDrawable, Integer> property = AnimationProperties.COLOR_DRAWABLE_ALPHA;
int[] iArr = new int[1];
iArr[0] = start ? 0 : 51;
animatorArr[0] = ObjectAnimator.ofInt(colorDrawable, property, iArr);
ViewGroup viewGroup = ((BottomSheet) EditorAlert.this).containerView;
Property property2 = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = start ? 0.2f : 1.0f;
animatorArr[1] = ObjectAnimator.ofFloat(viewGroup, (Property<ViewGroup, Float>) property2, fArr);
animatorSet.playTogether(animatorArr);
EditorAlert.this.colorChangeAnimation.setDuration(150L);
EditorAlert.this.colorChangeAnimation.setInterpolator(this.decelerateInterpolator);
EditorAlert.this.colorChangeAnimation.start();
}
@Override
public boolean onTouchEvent(android.view.MotionEvent r17) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Components.ThemeEditorView.EditorAlert.ColorPicker.onTouchEvent(android.view.MotionEvent):boolean");
}
public void setColor(int color) {
int red = Color.red(color);
int green = Color.green(color);
int blue = Color.blue(color);
int alpha = Color.alpha(color);
if (!EditorAlert.this.ignoreTextChange) {
EditorAlert.this.ignoreTextChange = true;
this.colorEditText[0].setText(BuildConfig.APP_CENTER_HASH + red);
this.colorEditText[1].setText(BuildConfig.APP_CENTER_HASH + green);
this.colorEditText[2].setText(BuildConfig.APP_CENTER_HASH + blue);
this.colorEditText[3].setText(BuildConfig.APP_CENTER_HASH + alpha);
for (int i = 0; i < 4; i++) {
EditTextBoldCursor[] editTextBoldCursorArr = this.colorEditText;
editTextBoldCursorArr[i].setSelection(editTextBoldCursorArr[i].length());
}
String upperCase = String.format("%02x%02x%02x%02x", Byte.valueOf((byte) alpha), Byte.valueOf((byte) red), Byte.valueOf((byte) green), Byte.valueOf((byte) blue)).toUpperCase();
this.hexColorEditText[1].setText(upperCase);
this.hexColorEditText[1].setSelection(upperCase.length());
EditorAlert.this.ignoreTextChange = false;
}
this.alphaGradient = null;
this.colorGradient = null;
this.alpha = alpha / 255.0f;
Color.colorToHSV(color, this.colorHSV);
invalidate();
}
public int getColor() {
return (Color.HSVToColor(this.colorHSV) & 16777215) | (((int) (this.alpha * 255.0f)) << 24);
}
}
public EditorAlert(final Context context, ArrayList<ThemeDescription> items) {
super(context, true);
this.shadow = new View[2];
this.shadowAnimation = new AnimatorSet[2];
Drawable mutate = context.getResources().getDrawable(R.drawable.sheet_shadow_round).mutate();
this.shadowDrawable = mutate;
mutate.setColorFilter(new PorterDuffColorFilter(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray), PorterDuff.Mode.MULTIPLY));
FrameLayout frameLayout = new FrameLayout(context, ThemeEditorView.this) {
public boolean ignoreLayout = false;
public RectF rect1 = new RectF();
public Boolean statusBarOpen;
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == 0 && EditorAlert.this.scrollOffsetY != 0 && ev.getY() < EditorAlert.this.scrollOffsetY) {
EditorAlert.this.dismiss();
return true;
}
return super.onInterceptTouchEvent(ev);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
return !EditorAlert.this.isDismissed() && super.onTouchEvent(e);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int size = View.MeasureSpec.getSize(widthMeasureSpec);
int size2 = View.MeasureSpec.getSize(heightMeasureSpec);
int i = Build.VERSION.SDK_INT;
if (i >= 21 && !((BottomSheet) EditorAlert.this).isFullscreen) {
this.ignoreLayout = true;
setPadding(((BottomSheet) EditorAlert.this).backgroundPaddingLeft, AndroidUtilities.statusBarHeight, ((BottomSheet) EditorAlert.this).backgroundPaddingLeft, 0);
this.ignoreLayout = false;
}
int dp = (((size2 - (i >= 21 ? AndroidUtilities.statusBarHeight : 0)) + AndroidUtilities.dp(8.0f)) - Math.min(size, size2 - (i >= 21 ? AndroidUtilities.statusBarHeight : 0))) - AndroidUtilities.dp(40.0f);
if (EditorAlert.this.listView.getPaddingTop() != dp) {
this.ignoreLayout = true;
EditorAlert.this.listView.getPaddingTop();
EditorAlert.this.listView.setPadding(0, dp, 0, AndroidUtilities.dp(48.0f));
if (EditorAlert.this.colorPicker.getVisibility() == 0) {
EditorAlert editorAlert = EditorAlert.this;
editorAlert.setScrollOffsetY(editorAlert.listView.getPaddingTop());
EditorAlert.this.previousScrollPosition = 0;
}
this.ignoreLayout = false;
}
super.onMeasure(widthMeasureSpec, View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
}
@Override
public void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
EditorAlert.this.updateLayout();
}
@Override
public void requestLayout() {
if (this.ignoreLayout) {
return;
}
super.requestLayout();
}
@Override
public void onDraw(android.graphics.Canvas r14) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Components.ThemeEditorView.EditorAlert.AnonymousClass1.onDraw(android.graphics.Canvas):void");
}
public final void updateLightStatusBar(boolean open) {
Boolean bool = this.statusBarOpen;
if (bool == null || bool.booleanValue() != open) {
boolean z = AndroidUtilities.computePerceivedBrightness(EditorAlert.this.getThemedColor(Theme.key_dialogBackground)) > 0.721f;
boolean z2 = AndroidUtilities.computePerceivedBrightness(Theme.blendOver(EditorAlert.this.getThemedColor(Theme.key_actionBarDefault), 855638016)) > 0.721f;
Boolean valueOf = Boolean.valueOf(open);
this.statusBarOpen = valueOf;
if (!valueOf.booleanValue()) {
z = z2;
}
AndroidUtilities.setLightStatusBar(EditorAlert.this.getWindow(), z);
}
}
};
((BottomSheet) this).containerView = frameLayout;
frameLayout.setWillNotDraw(false);
ViewGroup viewGroup = ((BottomSheet) this).containerView;
int i = ((BottomSheet) this).backgroundPaddingLeft;
viewGroup.setPadding(i, 0, i, 0);
FrameLayout frameLayout2 = new FrameLayout(context);
this.frameLayout = frameLayout2;
frameLayout2.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray));
SearchField searchField = new SearchField(context);
this.searchField = searchField;
this.frameLayout.addView(searchField, LayoutHelper.createFrame(-1, -1, 51));
RecyclerListView recyclerListView = new RecyclerListView(context, ThemeEditorView.this) {
@Override
public boolean allowSelectChildAtPosition(float x, float y) {
return y >= ((float) ((EditorAlert.this.scrollOffsetY + AndroidUtilities.dp(48.0f)) + (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0)));
}
};
this.listView = recyclerListView;
recyclerListView.setSelectorDrawableColor(251658240);
this.listView.setPadding(0, 0, 0, AndroidUtilities.dp(48.0f));
this.listView.setClipToPadding(false);
RecyclerListView recyclerListView2 = this.listView;
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
this.layoutManager = linearLayoutManager;
recyclerListView2.setLayoutManager(linearLayoutManager);
this.listView.setHorizontalScrollBarEnabled(false);
this.listView.setVerticalScrollBarEnabled(false);
((BottomSheet) this).containerView.addView((View) this.listView, LayoutHelper.createFrame(-1, -1, 51));
RecyclerListView recyclerListView3 = this.listView;
ListAdapter listAdapter = new ListAdapter(this, context, items);
this.listAdapter = listAdapter;
recyclerListView3.setAdapter(listAdapter);
this.searchAdapter = new SearchAdapter(context);
this.listView.setGlowColor(Theme.getColor(Theme.key_dialogScrollGlow));
this.listView.setItemAnimator((RecyclerView.ItemAnimator) null);
this.listView.setLayoutAnimation(null);
this.listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() {
@Override
public final void onItemClick(View view, int i2) {
ThemeEditorView.EditorAlert.this.lambda$new$0(view, i2);
}
});
this.listView.setOnScrollListener(new RecyclerView.OnScrollListener(ThemeEditorView.this) {
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
EditorAlert.this.updateLayout();
}
});
this.listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
@Override
public final boolean onItemClick(View view, int i2) {
boolean lambda$new$1;
lambda$new$1 = ThemeEditorView.EditorAlert.this.lambda$new$1(view, i2);
return lambda$new$1;
}
});
EmptyTextProgressView emptyTextProgressView = new EmptyTextProgressView(context);
this.searchEmptyView = emptyTextProgressView;
emptyTextProgressView.setShowAtCenter(true);
this.searchEmptyView.showTextView();
this.searchEmptyView.setText(LocaleController.getString("NoResult", R.string.NoResult));
this.listView.setEmptyView(this.searchEmptyView);
((BottomSheet) this).containerView.addView(this.searchEmptyView, LayoutHelper.createFrame(-1, -1.0f, 51, 0.0f, 52.0f, 0.0f, 0.0f));
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, AndroidUtilities.getShadowHeight(), 51);
layoutParams.topMargin = AndroidUtilities.dp(58.0f);
this.shadow[0] = new View(context);
View view = this.shadow[0];
int i2 = Theme.key_dialogShadowLine;
view.setBackgroundColor(Theme.getColor(i2));
this.shadow[0].setAlpha(0.0f);
this.shadow[0].setTag(1);
((BottomSheet) this).containerView.addView(this.shadow[0], layoutParams);
((BottomSheet) this).containerView.addView(this.frameLayout, LayoutHelper.createFrame(-1, 58, 51));
ColorPicker colorPicker = new ColorPicker(context);
this.colorPicker = colorPicker;
colorPicker.setVisibility(8);
this.colorPicker.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray));
((BottomSheet) this).containerView.addView(this.colorPicker, LayoutHelper.createFrame(-1, -1, 1));
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(-1, AndroidUtilities.getShadowHeight(), 83);
layoutParams2.bottomMargin = AndroidUtilities.dp(48.0f);
this.shadow[1] = new View(context);
this.shadow[1].setBackgroundColor(Theme.getColor(i2));
((BottomSheet) this).containerView.addView(this.shadow[1], layoutParams2);
FrameLayout frameLayout3 = new FrameLayout(context);
this.bottomSaveLayout = frameLayout3;
frameLayout3.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray));
((BottomSheet) this).containerView.addView(this.bottomSaveLayout, LayoutHelper.createFrame(-1, 48, 83));
TextView textView = new TextView(context);
textView.setTextSize(1, 14.0f);
int i3 = Theme.key_chat_fieldOverlayText;
textView.setTextColor(Theme.getColor(i3));
textView.setGravity(17);
textView.setBackgroundDrawable(Theme.createSelectorDrawable(788529152, 0));
textView.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
textView.setText(LocaleController.getString("CloseEditor", R.string.CloseEditor).toUpperCase());
textView.setTypeface(AndroidUtilities.bold());
this.bottomSaveLayout.addView(textView, LayoutHelper.createFrame(-2, -1, 51));
textView.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.this.lambda$new$2(view2);
}
});
TextView textView2 = new TextView(context);
textView2.setTextSize(1, 14.0f);
textView2.setTextColor(Theme.getColor(i3));
textView2.setGravity(17);
textView2.setBackgroundDrawable(Theme.createSelectorDrawable(788529152, 0));
textView2.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
textView2.setText(LocaleController.getString("SaveTheme", R.string.SaveTheme).toUpperCase());
textView2.setTypeface(AndroidUtilities.bold());
this.bottomSaveLayout.addView(textView2, LayoutHelper.createFrame(-2, -1, 53));
textView2.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.this.lambda$new$3(view2);
}
});
FrameLayout frameLayout4 = new FrameLayout(context);
this.bottomLayout = frameLayout4;
frameLayout4.setVisibility(8);
this.bottomLayout.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray));
((BottomSheet) this).containerView.addView(this.bottomLayout, LayoutHelper.createFrame(-1, 48, 83));
TextView textView3 = new TextView(context);
textView3.setTextSize(1, 14.0f);
textView3.setTextColor(Theme.getColor(i3));
textView3.setGravity(17);
textView3.setBackgroundDrawable(Theme.createSelectorDrawable(788529152, 0));
textView3.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
textView3.setText(LocaleController.getString("Cancel", R.string.Cancel).toUpperCase());
textView3.setTypeface(AndroidUtilities.bold());
this.bottomLayout.addView(textView3, LayoutHelper.createFrame(-2, -1, 51));
textView3.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.this.lambda$new$4(view2);
}
});
textView3.setOnLongClickListener(new View.OnLongClickListener(ThemeEditorView.this) {
@Override
public boolean onLongClick(View v) {
if (EditorAlert.this.keyTextView == null) {
return true;
}
EditorAlert.this.keyTextView.setVisibility(EditorAlert.this.keyTextView.getVisibility() == 0 ? 8 : 0);
return true;
}
});
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(0);
this.bottomLayout.addView(linearLayout, LayoutHelper.createFrame(-2, -1, 53));
TextView textView4 = new TextView(context);
textView4.setTextSize(1, 14.0f);
textView4.setTextColor(Theme.getColor(i3));
textView4.setGravity(17);
textView4.setBackgroundDrawable(Theme.createSelectorDrawable(788529152, 0));
textView4.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
textView4.setText(LocaleController.getString("Default", R.string.Default).toUpperCase());
textView4.setTypeface(AndroidUtilities.bold());
linearLayout.addView(textView4, LayoutHelper.createFrame(-2, -1, 51));
textView4.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.this.lambda$new$5(view2);
}
});
TextView textView5 = new TextView(context);
textView5.setTextSize(1, 14.0f);
textView5.setTextColor(Theme.getColor(i3));
textView5.setGravity(17);
textView5.setBackgroundDrawable(Theme.createSelectorDrawable(788529152, 0));
textView5.setPadding(AndroidUtilities.dp(18.0f), 0, AndroidUtilities.dp(18.0f), 0);
textView5.setText(LocaleController.getString("Save", R.string.Save).toUpperCase());
textView5.setTypeface(AndroidUtilities.bold());
linearLayout.addView(textView5, LayoutHelper.createFrame(-2, -1, 51));
textView5.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view2) {
ThemeEditorView.EditorAlert.this.lambda$new$6(view2);
}
});
}
public void lambda$new$0(View view, int i) {
if (i == 0) {
return;
}
RecyclerView.Adapter adapter = this.listView.getAdapter();
ListAdapter listAdapter = this.listAdapter;
if (adapter == listAdapter) {
ThemeEditorView.this.currentThemeDesription = listAdapter.getItem(i - 1);
} else {
ThemeEditorView.this.currentThemeDesription = this.searchAdapter.getItem(i - 1);
}
ThemeEditorView.this.currentThemeDesriptionPosition = i;
for (int i2 = 0; i2 < ThemeEditorView.this.currentThemeDesription.size(); i2++) {
ThemeDescription themeDescription = (ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i2);
if (themeDescription.getCurrentKey() == Theme.key_chat_wallpaper) {
ThemeEditorView.this.wallpaperUpdater.showAlert(true);
return;
}
themeDescription.startEditing();
if (i2 == 0) {
this.colorPicker.setColor(themeDescription.getCurrentColor());
TextView textView = this.keyTextView;
if (textView != null) {
textView.setText(themeDescription.getTitle());
}
}
}
setColorPickerVisible(true);
}
public boolean lambda$new$1(View view, int i) {
if (i == 0) {
return true;
}
RecyclerView.Adapter adapter = this.listView.getAdapter();
ListAdapter listAdapter = this.listAdapter;
if (adapter == listAdapter) {
ThemeEditorView.this.currentThemeDesription = listAdapter.getItem(i - 1);
} else {
ThemeEditorView.this.currentThemeDesription = this.searchAdapter.getItem(i - 1);
}
ThemeEditorView.this.currentThemeDesriptionPosition = i;
String obj = view.getTag() != null ? view.getTag().toString() : BuildConfig.APP_CENTER_HASH;
for (int i2 = 0; i2 < ThemeEditorView.this.currentThemeDesription.size(); i2++) {
ThemeDescription themeDescription = (ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i2);
themeDescription.startEditing();
if (i2 == 0) {
obj = themeDescription.getTitle();
}
}
AlertDialog.Builder builder = new AlertDialog.Builder(ThemeEditorView.this.parentActivity);
ArrayList arrayList = new ArrayList();
ArrayList arrayList2 = new ArrayList();
if (obj != null && !obj.isEmpty()) {
builder.setTitle(obj);
}
arrayList.add(LocaleController.getString("CopyLink", R.string.CopyLink));
arrayList2.add(0);
arrayList.add(LocaleController.getString("ShareLink", R.string.ShareLink));
arrayList2.add(2);
builder.setItems((CharSequence[]) arrayList.toArray(new CharSequence[arrayList.size()]), new AnonymousClass4(arrayList2, obj, arrayList));
builder.create().show();
return true;
}
public class AnonymousClass4 implements DialogInterface.OnClickListener {
public final ArrayList val$actions;
public final ArrayList val$items1;
public final String val$prefix;
public AnonymousClass4(final ArrayList val$actions, final String val$prefix, final ArrayList val$items1) {
this.val$actions = val$actions;
this.val$prefix = val$prefix;
this.val$items1 = val$items1;
}
@Override
public void onClick(DialogInterface dialogInterface, int i) {
int intValue = ((Integer) this.val$actions.get(i)).intValue();
final String format = String.format("https://t.me/thememods/%s", this.val$prefix);
if (intValue == 0) {
try {
((ClipboardManager) ApplicationLoader.applicationContext.getSystemService("clipboard")).setPrimaryClip(ClipData.newPlainText("label", format));
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public void run() {
Toast.makeText(EditorAlert.this.getContext(), format, 0).show();
}
});
return;
} catch (Exception e) {
FileLog.e(e);
return;
}
}
if (intValue == 1) {
final ArrayList arrayList = this.val$items1;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemeEditorView.EditorAlert.AnonymousClass4.this.lambda$onClick$0(arrayList);
}
});
} else if (intValue == 2) {
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.setType("text/plain");
intent.putExtra("android.intent.extra.TEXT", format);
ThemeEditorView.this.parentActivity.startActivityForResult(Intent.createChooser(intent, LocaleController.getString("ShareLink", R.string.ShareLink)), 500);
} catch (Exception e2) {
FileLog.e(e2);
}
}
}
public void lambda$onClick$0(ArrayList arrayList) {
Toast.makeText(ThemeEditorView.this.parentActivity, ((CharSequence) arrayList.get(0)).toString(), 0).show();
}
}
public void lambda$new$2(View view) {
dismiss();
}
public void lambda$new$3(View view) {
Theme.saveCurrentTheme(ThemeEditorView.this.themeInfo, true, false, false);
setOnDismissListener(null);
dismiss();
ThemeEditorView.this.close();
if (ThemeEditorView.this.sortAlphabetically) {
ThemeEditorView.this.sortAlphabetically = false;
ThemeEditorView.this.editorAlert = null;
}
}
public void lambda$new$4(View view) {
for (int i = 0; i < ThemeEditorView.this.currentThemeDesription.size(); i++) {
((ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i)).setPreviousColor();
}
setColorPickerVisible(false);
}
public void lambda$new$5(View view) {
for (int i = 0; i < ThemeEditorView.this.currentThemeDesription.size(); i++) {
((ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i)).setDefaultColor();
}
setColorPickerVisible(false);
if (ThemeEditorView.this.keyEditing) {
dismiss();
}
}
public void lambda$new$6(View view) {
this.history.selectColor(((ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(0)).getCurrentColor());
setColorPickerVisible(false);
this.history.makeColorList();
this.colorPicker.invalidate();
}
public final void runShadowAnimation(final int num, final boolean show) {
if ((!show || this.shadow[num].getTag() == null) && (show || this.shadow[num].getTag() != null)) {
return;
}
this.shadow[num].setTag(show ? null : 1);
if (show) {
this.shadow[num].setVisibility(0);
}
AnimatorSet[] animatorSetArr = this.shadowAnimation;
if (animatorSetArr[num] != null) {
animatorSetArr[num].cancel();
}
this.shadowAnimation[num] = new AnimatorSet();
AnimatorSet animatorSet = this.shadowAnimation[num];
Animator[] animatorArr = new Animator[1];
View view = this.shadow[num];
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = show ? 1.0f : 0.0f;
animatorArr[0] = ObjectAnimator.ofFloat(view, (Property<View, Float>) property, fArr);
animatorSet.playTogether(animatorArr);
this.shadowAnimation[num].setDuration(150L);
this.shadowAnimation[num].addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (EditorAlert.this.shadowAnimation[num] == null || !EditorAlert.this.shadowAnimation[num].equals(animation)) {
return;
}
if (!show) {
EditorAlert.this.shadow[num].setVisibility(4);
}
EditorAlert.this.shadowAnimation[num] = null;
}
@Override
public void onAnimationCancel(Animator animation) {
if (EditorAlert.this.shadowAnimation[num] == null || !EditorAlert.this.shadowAnimation[num].equals(animation)) {
return;
}
EditorAlert.this.shadowAnimation[num] = null;
}
});
this.shadowAnimation[num].start();
}
public void dismissInternal() {
super.dismissInternal();
if (this.searchField.searchEditText.isFocused()) {
AndroidUtilities.hideKeyboard(this.searchField.searchEditText);
}
}
public final void setColorPickerVisible(boolean visible) {
if (visible) {
this.animationInProgress = true;
this.colorPicker.setVisibility(0);
this.bottomLayout.setVisibility(0);
this.colorPicker.setAlpha(0.0f);
this.bottomLayout.setAlpha(0.0f);
this.previousScrollPosition = this.scrollOffsetY;
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.colorPicker, (Property<ColorPicker, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.bottomLayout, (Property<FrameLayout, Float>) View.ALPHA, 1.0f), ObjectAnimator.ofFloat(this.listView, (Property<RecyclerListView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.frameLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.shadow[0], (Property<View, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.searchEmptyView, (Property<EmptyTextProgressView, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofFloat(this.bottomSaveLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f), ObjectAnimator.ofInt(this, "scrollOffsetY", this.listView.getPaddingTop()));
animatorSet.setDuration(150L);
animatorSet.setInterpolator(ThemeEditorView.this.decelerateInterpolator);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
EditorAlert.this.listView.setVisibility(4);
EditorAlert.this.searchField.setVisibility(4);
EditorAlert.this.bottomSaveLayout.setVisibility(4);
EditorAlert.this.animationInProgress = false;
}
});
animatorSet.start();
return;
}
if (ThemeEditorView.this.parentActivity != null) {
ThemeEditorView.this.parentActivity.rebuildAllFragments(false);
}
Theme.saveCurrentTheme(ThemeEditorView.this.themeInfo, false, false, false);
if (this.listView.getAdapter() == this.listAdapter) {
AndroidUtilities.hideKeyboard(getCurrentFocus());
}
this.animationInProgress = true;
this.listView.setVisibility(0);
this.bottomSaveLayout.setVisibility(0);
this.searchField.setVisibility(0);
this.listView.setAlpha(0.0f);
AnimatorSet animatorSet2 = new AnimatorSet();
Animator[] animatorArr = new Animator[8];
animatorArr[0] = ObjectAnimator.ofFloat(this.colorPicker, (Property<ColorPicker, Float>) View.ALPHA, 0.0f);
animatorArr[1] = ObjectAnimator.ofFloat(this.bottomLayout, (Property<FrameLayout, Float>) View.ALPHA, 0.0f);
animatorArr[2] = ObjectAnimator.ofFloat(this.listView, (Property<RecyclerListView, Float>) View.ALPHA, 1.0f);
animatorArr[3] = ObjectAnimator.ofFloat(this.frameLayout, (Property<FrameLayout, Float>) View.ALPHA, 1.0f);
View[] viewArr = this.shadow;
View view = viewArr[0];
Property property = View.ALPHA;
float[] fArr = new float[1];
fArr[0] = viewArr[0].getTag() == null ? 1.0f : 0.0f;
animatorArr[4] = ObjectAnimator.ofFloat(view, (Property<View, Float>) property, fArr);
animatorArr[5] = ObjectAnimator.ofFloat(this.searchEmptyView, (Property<EmptyTextProgressView, Float>) View.ALPHA, 1.0f);
animatorArr[6] = ObjectAnimator.ofFloat(this.bottomSaveLayout, (Property<FrameLayout, Float>) View.ALPHA, 1.0f);
animatorArr[7] = ObjectAnimator.ofInt(this, "scrollOffsetY", this.previousScrollPosition);
animatorSet2.playTogether(animatorArr);
animatorSet2.setDuration(150L);
animatorSet2.setInterpolator(ThemeEditorView.this.decelerateInterpolator);
animatorSet2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (EditorAlert.this.listView.getAdapter() == EditorAlert.this.searchAdapter) {
EditorAlert.this.searchField.showKeyboard();
}
EditorAlert.this.colorPicker.setVisibility(8);
EditorAlert.this.bottomLayout.setVisibility(8);
EditorAlert.this.animationInProgress = false;
}
});
animatorSet2.start();
this.listView.getAdapter().notifyItemChanged(ThemeEditorView.this.currentThemeDesriptionPosition);
if (ThemeEditorView.this.keyEditing) {
dismiss();
}
}
public final int getCurrentTop() {
if (this.listView.getChildCount() == 0) {
return -1000;
}
int i = 0;
View childAt = this.listView.getChildAt(0);
RecyclerListView.Holder holder = (RecyclerListView.Holder) this.listView.findContainingViewHolder(childAt);
if (holder == null) {
return -1000;
}
int paddingTop = this.listView.getPaddingTop();
if (holder.getAdapterPosition() == 0 && childAt.getTop() >= 0) {
i = childAt.getTop();
}
return paddingTop - i;
}
@SuppressLint({"NewApi"})
public final void updateLayout() {
int paddingTop;
if (this.listView.getChildCount() <= 0 || this.listView.getVisibility() != 0 || this.animationInProgress) {
return;
}
int i = 0;
View childAt = this.listView.getChildAt(0);
RecyclerListView.Holder holder = (RecyclerListView.Holder) this.listView.findContainingViewHolder(childAt);
if (this.listView.getVisibility() != 0 || this.animationInProgress) {
paddingTop = this.listView.getPaddingTop();
} else {
paddingTop = childAt.getTop() - AndroidUtilities.dp(8.0f);
}
if (paddingTop > (-AndroidUtilities.dp(1.0f)) && holder != null && holder.getAdapterPosition() == 0) {
runShadowAnimation(0, false);
i = paddingTop;
} else {
runShadowAnimation(0, true);
}
if (this.scrollOffsetY != i) {
setScrollOffsetY(i);
}
}
@Keep
public int getScrollOffsetY() {
return this.scrollOffsetY;
}
@Keep
public void setScrollOffsetY(int value) {
RecyclerListView recyclerListView = this.listView;
this.scrollOffsetY = value;
recyclerListView.setTopGlowOffset(value);
this.frameLayout.setTranslationY(this.scrollOffsetY);
this.colorPicker.setTranslationY(this.scrollOffsetY);
this.searchEmptyView.setTranslationY(this.scrollOffsetY);
((BottomSheet) this).containerView.invalidate();
}
public class SearchAdapter extends RecyclerListView.SelectionAdapter {
public Context context;
public int lastSearchId;
public String lastSearchText;
public Runnable searchRunnable;
public ArrayList<ArrayList<ThemeDescription>> searchResult = new ArrayList<>();
public ArrayList<CharSequence> searchNames = new ArrayList<>();
public int getItemViewType(int i) {
return i == 0 ? 1 : 0;
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return true;
}
public SearchAdapter(Context context) {
this.context = context;
}
public CharSequence generateSearchName(String name, String q) {
if (TextUtils.isEmpty(name)) {
return BuildConfig.APP_CENTER_HASH;
}
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
String trim = name.trim();
String lowerCase = trim.toLowerCase();
int i = 0;
while (true) {
int indexOf = lowerCase.indexOf(q, i);
if (indexOf == -1) {
break;
}
int length = q.length() + indexOf;
if (i != 0 && i != indexOf + 1) {
spannableStringBuilder.append((CharSequence) trim.substring(i, indexOf));
} else if (i == 0 && indexOf != 0) {
spannableStringBuilder.append((CharSequence) trim.substring(0, indexOf));
}
String substring = trim.substring(indexOf, Math.min(trim.length(), length));
if (substring.startsWith(" ")) {
spannableStringBuilder.append((CharSequence) " ");
}
String trim2 = substring.trim();
int length2 = spannableStringBuilder.length();
spannableStringBuilder.append((CharSequence) trim2);
spannableStringBuilder.setSpan(new ForegroundColorSpan(Theme.getColor(Theme.key_chat_fieldOverlayText)), length2, trim2.length() + length2, 33);
i = length;
}
if (i != -1 && i < trim.length()) {
spannableStringBuilder.append((CharSequence) trim.substring(i));
}
return spannableStringBuilder;
}
public final void lambda$searchDialogs$1(final String query, final int searchId) {
try {
String lowerCase = query.trim().toLowerCase();
if (lowerCase.length() == 0) {
this.lastSearchId = -1;
updateSearchResults(new ArrayList<>(), new ArrayList<>(), this.lastSearchId);
return;
}
String translitString = LocaleController.getInstance().getTranslitString(lowerCase);
if (lowerCase.equals(translitString) || translitString.length() == 0) {
translitString = null;
}
int i = (translitString != null ? 1 : 0) + 1;
String[] strArr = new String[i];
strArr[0] = lowerCase;
if (translitString != null) {
strArr[1] = translitString;
}
ArrayList<ArrayList<ThemeDescription>> arrayList = new ArrayList<>();
ArrayList<CharSequence> arrayList2 = new ArrayList<>();
int size = EditorAlert.this.listAdapter.items.size();
for (int i2 = 0; i2 < size; i2++) {
ArrayList<ThemeDescription> arrayList3 = (ArrayList) EditorAlert.this.listAdapter.items.get(i2);
String stringName = ThemeColors.getStringName(arrayList3.get(0).getCurrentKey());
String lowerCase2 = stringName.toLowerCase();
int i3 = 0;
while (true) {
if (i3 < i) {
String str = strArr[i3];
if (lowerCase2.contains(str)) {
arrayList.add(arrayList3);
arrayList2.add(generateSearchName(stringName, str));
break;
}
i3++;
}
}
}
updateSearchResults(arrayList, arrayList2, searchId);
} catch (Exception e) {
FileLog.e(e);
}
}
public final void updateSearchResults(final ArrayList<ArrayList<ThemeDescription>> result, final ArrayList<CharSequence> names, final int searchId) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
ThemeEditorView.EditorAlert.SearchAdapter.this.lambda$updateSearchResults$0(searchId, result, names);
}
});
}
public void lambda$updateSearchResults$0(int i, ArrayList arrayList, ArrayList arrayList2) {
if (i != this.lastSearchId) {
return;
}
if (EditorAlert.this.listView.getAdapter() != EditorAlert.this.searchAdapter) {
EditorAlert editorAlert = EditorAlert.this;
editorAlert.topBeforeSwitch = editorAlert.getCurrentTop();
EditorAlert.this.listView.setAdapter(EditorAlert.this.searchAdapter);
EditorAlert.this.searchAdapter.notifyDataSetChanged();
}
boolean z = !this.searchResult.isEmpty() && arrayList.isEmpty();
boolean z2 = this.searchResult.isEmpty() && arrayList.isEmpty();
if (z) {
EditorAlert editorAlert2 = EditorAlert.this;
editorAlert2.topBeforeSwitch = editorAlert2.getCurrentTop();
}
this.searchResult = arrayList;
this.searchNames = arrayList2;
notifyDataSetChanged();
if (!z2 && !z && EditorAlert.this.topBeforeSwitch > 0) {
EditorAlert.this.layoutManager.scrollToPositionWithOffset(0, -EditorAlert.this.topBeforeSwitch);
EditorAlert.this.topBeforeSwitch = -1000;
}
EditorAlert.this.searchEmptyView.showTextView();
}
public void searchDialogs(final String query) {
if (query == null || !query.equals(this.lastSearchText)) {
this.lastSearchText = query;
if (this.searchRunnable != null) {
Utilities.searchQueue.cancelRunnable(this.searchRunnable);
this.searchRunnable = null;
}
if (query == null || query.length() == 0) {
this.searchResult.clear();
EditorAlert editorAlert = EditorAlert.this;
editorAlert.topBeforeSwitch = editorAlert.getCurrentTop();
this.lastSearchId = -1;
notifyDataSetChanged();
return;
}
final int i = this.lastSearchId + 1;
this.lastSearchId = i;
this.searchRunnable = new Runnable() {
@Override
public final void run() {
ThemeEditorView.EditorAlert.SearchAdapter.this.lambda$searchDialogs$1(query, i);
}
};
Utilities.searchQueue.postRunnable(this.searchRunnable, 300L);
}
}
public int getItemCount() {
if (this.searchResult.isEmpty()) {
return 0;
}
return this.searchResult.size() + 1;
}
public ArrayList<ThemeDescription> getItem(int i) {
if (i < 0 || i >= this.searchResult.size()) {
return null;
}
return this.searchResult.get(i);
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View textColorThemeCell;
if (viewType == 0) {
textColorThemeCell = new TextColorThemeCell(this.context);
textColorThemeCell.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
} else {
textColorThemeCell = new View(this.context);
textColorThemeCell.setLayoutParams(new RecyclerView.LayoutParams(-1, AndroidUtilities.dp(56.0f)));
}
return new RecyclerListView.Holder(textColorThemeCell);
}
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == 0) {
int i = position - 1;
ThemeDescription themeDescription = this.searchResult.get(i).get(0);
holder.itemView.setTextAndColor(this.searchNames.get(i), themeDescription.getCurrentKey() != Theme.key_chat_wallpaper ? themeDescription.getSetColor() : 0);
}
}
}
public class ListAdapter extends RecyclerListView.SelectionAdapter {
public Context context;
public ArrayList<ArrayList<ThemeDescription>> items = new ArrayList<>();
public int getItemViewType(int i) {
return i == 0 ? 1 : 0;
}
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder) {
return true;
}
public ListAdapter(final EditorAlert this$1, Context context, ArrayList<ThemeDescription> descriptions) {
this.context = context;
HashMap hashMap = new HashMap();
boolean unused = ThemeEditorView.this.sortAlphabetically;
int size = descriptions.size();
for (int i = 0; i < size; i++) {
ThemeDescription themeDescription = descriptions.get(i);
int currentKey = themeDescription.getCurrentKey();
ArrayList<ThemeDescription> arrayList = (ArrayList) hashMap.get(Integer.valueOf(currentKey));
if (arrayList == null) {
arrayList = new ArrayList<>();
hashMap.put(Integer.valueOf(currentKey), arrayList);
this.items.add(arrayList);
}
arrayList.add(themeDescription);
}
if (Build.VERSION.SDK_INT >= 26) {
int i2 = Theme.key_windowBackgroundGray;
if (hashMap.containsKey(Integer.valueOf(i2))) {
return;
}
ArrayList<ThemeDescription> arrayList2 = new ArrayList<>();
arrayList2.add(new ThemeDescription((View) null, 0, (Class[]) null, (Paint) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, i2));
this.items.add(arrayList2);
}
}
public int getItemCount() {
if (this.items.isEmpty()) {
return 0;
}
return this.items.size() + 1;
}
public ArrayList<ThemeDescription> getItem(int i) {
if (i < 0 || i >= this.items.size()) {
return null;
}
return this.items.get(i);
}
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View textColorThemeCell;
if (viewType == 0) {
textColorThemeCell = new TextColorThemeCell(this.context);
textColorThemeCell.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
} else {
textColorThemeCell = new View(this.context);
textColorThemeCell.setLayoutParams(new RecyclerView.LayoutParams(-1, AndroidUtilities.dp(56.0f)));
}
return new RecyclerListView.Holder(textColorThemeCell);
}
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == 0) {
ThemeDescription themeDescription = this.items.get(position - 1).get(0);
holder.itemView.setTextAndColor(themeDescription.getTitle(), themeDescription.getCurrentKey() != Theme.key_chat_wallpaper ? themeDescription.getSetColor() : 0);
holder.itemView.setBackgroundColor(Theme.usePlusTheme ? Theme.prefBGColor : Theme.getColor(Theme.key_windowBackgroundGray));
}
}
}
}
public void showKey(Activity activity, String key) {
showKey(activity, ThemeColors.stringKeyToInt(key));
}
public void showKey(final Activity activity, int key) {
this.keyEditing = true;
ArrayList arrayList = new ArrayList();
ThemeDescription themeDescription = new ThemeDescription(new View(activity), 0, (Class[]) null, (Paint) null, (Drawable[]) null, (ThemeDescription.ThemeDescriptionDelegate) null, key);
arrayList.add(themeDescription);
this.currentThemeDesription = new ArrayList<>(arrayList);
show(activity, this.themeInfo);
hide();
this.parentActivity = activity;
?? editorAlert = new EditorAlert(activity, arrayList);
this.editorAlert = editorAlert;
editorAlert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public final void onDismiss(DialogInterface dialogInterface) {
ThemeEditorView.this.lambda$showKey$0(activity, dialogInterface);
}
});
this.editorAlert.show();
themeDescription.startEditing();
this.editorAlert.colorPicker.setColor(themeDescription.getCurrentColor());
if (this.editorAlert.keyTextView != null) {
this.editorAlert.keyTextView.setText(themeDescription.getTitle());
}
this.editorAlert.setColorPickerVisible(true);
}
public void lambda$showKey$0(Activity activity, DialogInterface dialogInterface) {
this.editorAlert = null;
Theme.applyTheme(Theme.getCurrentTheme());
((LaunchActivity) activity).rebuildAllFragments(true);
}
public void show(Activity activity, final Theme.ThemeInfo theme) {
if (Instance != null) {
Instance.destroy();
}
this.themeInfo = theme;
if (theme == null) {
this.themeInfo = Theme.getCurrentTheme();
}
this.windowView = new AnonymousClass1(activity);
this.windowManager = (WindowManager) activity.getSystemService("window");
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", 0);
this.preferences = sharedPreferences;
int i = sharedPreferences.getInt("sidex", 1);
int i2 = this.preferences.getInt("sidey", 0);
float f = this.preferences.getFloat("px", 0.0f);
float f2 = this.preferences.getFloat("py", 0.0f);
try {
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
this.windowLayoutParams = layoutParams;
int i3 = this.editorWidth;
layoutParams.width = i3;
layoutParams.height = this.editorHeight;
layoutParams.x = getSideCoord(true, i, f, i3);
this.windowLayoutParams.y = getSideCoord(false, i2, f2, this.editorHeight);
WindowManager.LayoutParams layoutParams2 = this.windowLayoutParams;
layoutParams2.format = -3;
layoutParams2.gravity = 51;
layoutParams2.type = 99;
layoutParams2.flags = 16777736;
this.windowManager.addView(this.windowView, layoutParams2);
this.wallpaperUpdater = new WallpaperUpdater(activity, null, new WallpaperUpdater.WallpaperUpdaterDelegate() {
@Override
public void didSelectWallpaper(File file, Bitmap bitmap, boolean gallery) {
Theme.setThemeWallpaper(ThemeEditorView.this.themeInfo, bitmap, file);
}
@Override
public void needOpenColorPicker() {
for (int i4 = 0; i4 < ThemeEditorView.this.currentThemeDesription.size(); i4++) {
ThemeDescription themeDescription = (ThemeDescription) ThemeEditorView.this.currentThemeDesription.get(i4);
themeDescription.startEditing();
if (i4 == 0) {
ThemeEditorView.this.editorAlert.colorPicker.setColor(themeDescription.getCurrentColor());
}
}
ThemeEditorView.this.editorAlert.setColorPickerVisible(true);
}
});
Instance = this;
this.parentActivity = activity;
showWithAnimation();
} catch (Exception e) {
FileLog.e(e);
}
}
public class AnonymousClass1 extends FrameLayout {
public boolean dragging;
public float startX;
public float startY;
public static void lambda$onTouchEvent$0(DialogInterface dialogInterface) {
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
return true;
}
public AnonymousClass1(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(android.view.MotionEvent r11) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Components.ThemeEditorView.AnonymousClass1.onTouchEvent(android.view.MotionEvent):boolean");
}
public void lambda$onTouchEvent$1(DialogInterface dialogInterface) {
ThemeEditorView.this.editorAlert = null;
ThemeEditorView.this.show();
}
}
public final void showWithAnimation() {
this.windowView.setBackgroundResource(R.drawable.theme_picker);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.ALPHA, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.SCALE_X, 0.0f, 1.0f), ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.SCALE_Y, 0.0f, 1.0f));
animatorSet.setInterpolator(this.decelerateInterpolator);
animatorSet.setDuration(150L);
animatorSet.start();
}
public static int getSideCoord(boolean isX, int side, float p, int sideSize) {
int i;
int round;
if (isX) {
i = AndroidUtilities.displaySize.x;
} else {
i = AndroidUtilities.displaySize.y - sideSize;
sideSize = ActionBar.getCurrentActionBarHeight();
}
int i2 = i - sideSize;
if (side == 0) {
round = AndroidUtilities.dp(10.0f);
} else if (side == 1) {
round = i2 - AndroidUtilities.dp(10.0f);
} else {
round = Math.round((i2 - AndroidUtilities.dp(20.0f)) * p) + AndroidUtilities.dp(10.0f);
}
return !isX ? round + ActionBar.getCurrentActionBarHeight() : round;
}
public final void hide() {
if (this.parentActivity == null) {
return;
}
try {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.ALPHA, 1.0f, 0.0f), ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.SCALE_X, 1.0f, 0.0f), ObjectAnimator.ofFloat(this.windowView, (Property<FrameLayout, Float>) View.SCALE_Y, 1.0f, 0.0f));
animatorSet.setInterpolator(this.decelerateInterpolator);
animatorSet.setDuration(150L);
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (ThemeEditorView.this.windowView != null) {
ThemeEditorView.this.windowView.setBackground(null);
ThemeEditorView.this.windowManager.removeView(ThemeEditorView.this.windowView);
}
}
});
animatorSet.start();
} catch (Exception unused) {
}
}
public final void show() {
if (this.parentActivity == null) {
return;
}
try {
this.windowManager.addView(this.windowView, this.windowLayoutParams);
showWithAnimation();
} catch (Exception unused) {
}
}
public void close() {
try {
this.windowManager.removeView(this.windowView);
} catch (Exception unused) {
}
this.parentActivity = null;
}
public void onConfigurationChanged() {
int i = this.preferences.getInt("sidex", 1);
int i2 = this.preferences.getInt("sidey", 0);
float f = this.preferences.getFloat("px", 0.0f);
float f2 = this.preferences.getFloat("py", 0.0f);
this.windowLayoutParams.x = getSideCoord(true, i, f, this.editorWidth);
this.windowLayoutParams.y = getSideCoord(false, i2, f2, this.editorHeight);
try {
if (this.windowView.getParent() != null) {
this.windowManager.updateViewLayout(this.windowView, this.windowLayoutParams);
}
} catch (Exception e) {
FileLog.e(e);
}
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
WallpaperUpdater wallpaperUpdater = this.wallpaperUpdater;
if (wallpaperUpdater != null) {
wallpaperUpdater.onActivityResult(requestCode, resultCode, data);
}
}
public final void animateToBoundsMaybe() {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Components.ThemeEditorView.animateToBoundsMaybe():void");
}
@Keep
public int getX() {
return this.windowLayoutParams.x;
}
@Keep
public int getY() {
return this.windowLayoutParams.y;
}
@Keep
public void setX(int value) {
WindowManager.LayoutParams layoutParams = this.windowLayoutParams;
layoutParams.x = value;
this.windowManager.updateViewLayout(this.windowView, layoutParams);
}
@Keep
public void setY(int value) {
WindowManager.LayoutParams layoutParams = this.windowLayoutParams;
layoutParams.y = value;
this.windowManager.updateViewLayout(this.windowView, layoutParams);
}
}