855 lines
33 KiB
Java
855 lines
33 KiB
Java
package com.jaredrummler.android.colorpicker;
|
|
|
|
import android.app.Dialog;
|
|
import android.content.DialogInterface;
|
|
import android.content.res.ColorStateList;
|
|
import android.graphics.Color;
|
|
import android.graphics.ColorFilter;
|
|
import android.graphics.PorterDuff;
|
|
import android.os.Bundle;
|
|
import android.text.Editable;
|
|
import android.text.InputFilter;
|
|
import android.text.TextWatcher;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.inputmethod.InputMethodManager;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.GridView;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.ListAdapter;
|
|
import android.widget.SeekBar;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.ColorInt;
|
|
import androidx.annotation.DrawableRes;
|
|
import androidx.annotation.FontRes;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.appcompat.app.AlertDialog;
|
|
import androidx.constraintlayout.motion.widget.Key;
|
|
import androidx.core.content.res.ResourcesCompat;
|
|
import androidx.core.graphics.ColorUtils;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.DialogFragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import c.k.a.a.b;
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
import com.google.android.material.shadow.ShadowDrawableWrapper;
|
|
import com.jaredrummler.android.colorpicker.ColorPickerView;
|
|
import java.util.Arrays;
|
|
import java.util.Locale;
|
|
public class ColorPickerDialog extends DialogFragment implements ColorPickerView.c, TextWatcher {
|
|
public static final int[] i = {-769226, -1499549, -54125, -6543440, -10011977, -12627531, -14575885, -16537100, -16728876, -16738680, -11751600, -7617718, -3285959, -5317, -16121, -26624, -8825528, -10453621, -6381922};
|
|
public View A;
|
|
public TextView B;
|
|
public Button C;
|
|
public Button D;
|
|
public TextView E;
|
|
public boolean F;
|
|
public int G;
|
|
public boolean H;
|
|
public int I;
|
|
public final View.OnTouchListener J = new b();
|
|
public c.k.a.a.f j;
|
|
public View k;
|
|
public FrameLayout l;
|
|
public int[] m;
|
|
@ColorInt
|
|
public int n;
|
|
public int o;
|
|
public int p;
|
|
public boolean q;
|
|
public int r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public c.k.a.a.b f2415s;
|
|
public LinearLayout t;
|
|
public SeekBar u;
|
|
public TextView v;
|
|
public ColorPickerView w;
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public ColorPanelView f2416x;
|
|
|
|
/* renamed from: y reason: collision with root package name */
|
|
public EditText f2417y;
|
|
|
|
/* renamed from: z reason: collision with root package name */
|
|
public EditText f2418z;
|
|
|
|
public class a implements View.OnLongClickListener {
|
|
public final /* synthetic */ ColorPanelView i;
|
|
|
|
public a(ColorPickerDialog colorPickerDialog, ColorPanelView colorPanelView) {
|
|
this.i = colorPanelView;
|
|
}
|
|
|
|
@Override // android.view.View.OnLongClickListener
|
|
public boolean onLongClick(View view) {
|
|
this.i.a();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public class b implements View.OnTouchListener {
|
|
public b() {
|
|
}
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
EditText editText = ColorPickerDialog.this.f2418z;
|
|
if (view == editText || !editText.hasFocus()) {
|
|
return false;
|
|
}
|
|
ColorPickerDialog.this.f2418z.clearFocus();
|
|
((InputMethodManager) ColorPickerDialog.this.getActivity().getSystemService("input_method")).hideSoftInputFromWindow(ColorPickerDialog.this.f2418z.getWindowToken(), 0);
|
|
ColorPickerDialog.this.f2418z.clearFocus();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public class c implements View.OnClickListener {
|
|
public c() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
ColorPickerDialog colorPickerDialog = ColorPickerDialog.this;
|
|
ColorPickerDialog.g(colorPickerDialog, colorPickerDialog.n);
|
|
ColorPickerDialog.this.dismiss();
|
|
}
|
|
}
|
|
|
|
public class d implements View.OnClickListener {
|
|
public d() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
ColorPickerDialog colorPickerDialog = ColorPickerDialog.this;
|
|
if (colorPickerDialog.j != null) {
|
|
Log.w("ColorPickerDialog", "Using deprecated listener which may be remove in future releases");
|
|
colorPickerDialog.j.onColorReset(colorPickerDialog.p);
|
|
} else {
|
|
FragmentActivity activity = colorPickerDialog.getActivity();
|
|
if (activity instanceof c.k.a.a.f) {
|
|
((c.k.a.a.f) activity).onColorReset(colorPickerDialog.p);
|
|
} else {
|
|
throw new IllegalStateException("The activity must implement ColorPickerDialogListener");
|
|
}
|
|
}
|
|
ColorPickerDialog.this.dismiss();
|
|
}
|
|
}
|
|
|
|
public class e implements View.OnClickListener {
|
|
public e() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
ColorPickerDialog.this.l.removeAllViews();
|
|
ColorPickerDialog colorPickerDialog = ColorPickerDialog.this;
|
|
int i = colorPickerDialog.o;
|
|
if (i == 0) {
|
|
colorPickerDialog.o = 1;
|
|
Button button = (Button) view;
|
|
int i2 = colorPickerDialog.I;
|
|
if (i2 == 0) {
|
|
i2 = R.e.cpv_custom;
|
|
}
|
|
button.setText(i2);
|
|
ColorPickerDialog colorPickerDialog2 = ColorPickerDialog.this;
|
|
colorPickerDialog2.l.addView(colorPickerDialog2.j());
|
|
} else if (i == 1) {
|
|
colorPickerDialog.o = 0;
|
|
Button button2 = (Button) view;
|
|
int i3 = colorPickerDialog.G;
|
|
if (i3 == 0) {
|
|
i3 = R.e.cpv_presets;
|
|
}
|
|
button2.setText(i3);
|
|
ColorPickerDialog colorPickerDialog3 = ColorPickerDialog.this;
|
|
colorPickerDialog3.l.addView(colorPickerDialog3.i());
|
|
}
|
|
}
|
|
}
|
|
|
|
public class f implements View.OnClickListener {
|
|
public f() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int color = ColorPickerDialog.this.f2416x.getColor();
|
|
ColorPickerDialog colorPickerDialog = ColorPickerDialog.this;
|
|
int i = colorPickerDialog.n;
|
|
if (color == i) {
|
|
ColorPickerDialog.g(colorPickerDialog, i);
|
|
ColorPickerDialog.this.dismiss();
|
|
}
|
|
}
|
|
}
|
|
|
|
public class g implements View.OnFocusChangeListener {
|
|
public g() {
|
|
}
|
|
|
|
@Override // android.view.View.OnFocusChangeListener
|
|
public void onFocusChange(View view, boolean z2) {
|
|
if (z2) {
|
|
((InputMethodManager) ColorPickerDialog.this.getActivity().getSystemService("input_method")).showSoftInput(ColorPickerDialog.this.f2418z, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class h implements b.a {
|
|
public h() {
|
|
}
|
|
}
|
|
|
|
public class i implements Runnable {
|
|
public final /* synthetic */ ColorPanelView i;
|
|
public final /* synthetic */ int j;
|
|
|
|
public i(ColorPickerDialog colorPickerDialog, ColorPanelView colorPanelView, int i) {
|
|
this.i = colorPanelView;
|
|
this.j = i;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
this.i.setColor(this.j);
|
|
}
|
|
}
|
|
|
|
public class j implements View.OnClickListener {
|
|
public final /* synthetic */ ColorPanelView i;
|
|
|
|
public j(ColorPanelView colorPanelView) {
|
|
this.i = colorPanelView;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
if (!(view.getTag() instanceof Boolean) || !((Boolean) view.getTag()).booleanValue()) {
|
|
ColorPickerDialog.this.n = this.i.getColor();
|
|
c.k.a.a.b bVar = ColorPickerDialog.this.f2415s;
|
|
bVar.k = -1;
|
|
bVar.notifyDataSetChanged();
|
|
for (int i = 0; i < ColorPickerDialog.this.t.getChildCount(); i++) {
|
|
FrameLayout frameLayout = (FrameLayout) ColorPickerDialog.this.t.getChildAt(i);
|
|
ColorPanelView colorPanelView = (ColorPanelView) frameLayout.findViewById(R.c.cpv_color_panel_view);
|
|
ImageView imageView = (ImageView) frameLayout.findViewById(R.c.cpv_color_image_view);
|
|
imageView.setImageResource(colorPanelView == view ? R.b.cpv_preset_checked : 0);
|
|
if ((colorPanelView != view || ColorUtils.calculateLuminance(colorPanelView.getColor()) < 0.65d) && Color.alpha(colorPanelView.getColor()) > 165) {
|
|
imageView.setColorFilter((ColorFilter) null);
|
|
} else {
|
|
imageView.setColorFilter(ViewCompat.MEASURED_STATE_MASK, PorterDuff.Mode.SRC_IN);
|
|
}
|
|
colorPanelView.setTag(Boolean.valueOf(colorPanelView == view));
|
|
}
|
|
return;
|
|
}
|
|
ColorPickerDialog colorPickerDialog = ColorPickerDialog.this;
|
|
ColorPickerDialog.g(colorPickerDialog, colorPickerDialog.n);
|
|
ColorPickerDialog.this.dismiss();
|
|
}
|
|
}
|
|
|
|
public static final class k {
|
|
@StringRes
|
|
public int a = R.e.cpv_default_title;
|
|
@StringRes
|
|
public int b = R.e.cpv_presets;
|
|
@StringRes
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public int f2419c = R.e.cpv_custom;
|
|
@StringRes
|
|
public int d = R.e.cpv_select;
|
|
@StringRes
|
|
public int e = 0;
|
|
public int f = 1;
|
|
public int[] g = ColorPickerDialog.i;
|
|
@ColorInt
|
|
public int h = ViewCompat.MEASURED_STATE_MASK;
|
|
public boolean i = false;
|
|
public boolean j = true;
|
|
public boolean k = true;
|
|
public boolean l = true;
|
|
public boolean m = true;
|
|
public int n = 1;
|
|
@ColorInt
|
|
public int o = 0;
|
|
@ColorInt
|
|
public int p = 0;
|
|
@ColorInt
|
|
public int q = 0;
|
|
@ColorInt
|
|
public int r = 0;
|
|
@ColorInt
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public int f2420s = 0;
|
|
@ColorInt
|
|
public int t = 0;
|
|
@DrawableRes
|
|
public int u = 0;
|
|
@ColorInt
|
|
public int v = 0;
|
|
@ColorInt
|
|
public int w = 0;
|
|
@FontRes
|
|
|
|
/* renamed from: x reason: collision with root package name */
|
|
public int f2421x = 0;
|
|
@FontRes
|
|
|
|
/* renamed from: y reason: collision with root package name */
|
|
public int f2422y = 0;
|
|
@FontRes
|
|
|
|
/* renamed from: z reason: collision with root package name */
|
|
public int f2423z = 0;
|
|
|
|
public ColorPickerDialog a() {
|
|
ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putInt(ModelAuditLogEntry.CHANGE_KEY_ID, 0);
|
|
bundle.putInt("dialogType", this.f);
|
|
bundle.putInt(ModelAuditLogEntry.CHANGE_KEY_COLOR, this.h);
|
|
bundle.putIntArray("presets", this.g);
|
|
bundle.putBoolean(Key.ALPHA, this.i);
|
|
bundle.putBoolean("allowCustom", this.k);
|
|
bundle.putBoolean("allowPresets", this.j);
|
|
bundle.putBoolean("allowReset", this.l);
|
|
bundle.putInt("dialogTitle", this.a);
|
|
bundle.putBoolean("showColorShades", this.m);
|
|
bundle.putInt("colorShape", this.n);
|
|
bundle.putInt("presetsButtonText", this.b);
|
|
bundle.putInt("customButtonText", this.f2419c);
|
|
bundle.putInt("customButtonColor", this.o);
|
|
bundle.putInt("customButtonTextColor", this.v);
|
|
bundle.putInt("selectedButtonText", this.d);
|
|
bundle.putInt("selectedButtonColor", this.p);
|
|
bundle.putInt("selectedButtonTextColor", this.w);
|
|
bundle.putInt("resetButtonText", this.e);
|
|
bundle.putInt("buttonFont", this.f2422y);
|
|
bundle.putInt("titleTextColor", this.r);
|
|
bundle.putInt("titleFont", this.f2421x);
|
|
bundle.putInt("dividerColor", this.q);
|
|
bundle.putInt("backgroundColor", this.f2420s);
|
|
bundle.putInt("inputTextColor", this.t);
|
|
bundle.putInt("inputBackground", this.u);
|
|
bundle.putInt("inputFont", this.f2423z);
|
|
colorPickerDialog.setArguments(bundle);
|
|
return colorPickerDialog;
|
|
}
|
|
}
|
|
|
|
public static void g(ColorPickerDialog colorPickerDialog, int i2) {
|
|
if (colorPickerDialog.j != null) {
|
|
Log.w("ColorPickerDialog", "Using deprecated listener which may be remove in future releases");
|
|
colorPickerDialog.j.onColorSelected(colorPickerDialog.p, i2);
|
|
return;
|
|
}
|
|
FragmentActivity activity = colorPickerDialog.getActivity();
|
|
if (activity instanceof c.k.a.a.f) {
|
|
((c.k.a.a.f) activity).onColorSelected(colorPickerDialog.p, i2);
|
|
return;
|
|
}
|
|
throw new IllegalStateException("The activity must implement ColorPickerDialogListener");
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:37:0x011b */
|
|
/* JADX WARNING: Removed duplicated region for block: B:40:? A[RETURN, SYNTHETIC] */
|
|
@Override // android.text.TextWatcher
|
|
public void afterTextChanged(Editable editable) {
|
|
int i2;
|
|
int i3;
|
|
int argb;
|
|
int i4;
|
|
int i5;
|
|
int i6;
|
|
int parseInt;
|
|
int parseInt2;
|
|
int parseInt3;
|
|
if (this.f2418z.isFocused()) {
|
|
String obj = editable.toString();
|
|
if (obj.startsWith("#")) {
|
|
obj = obj.substring(1);
|
|
}
|
|
int i7 = 0;
|
|
int i8 = -1;
|
|
if (obj.length() == 0) {
|
|
i6 = 0;
|
|
} else if (obj.length() <= 2) {
|
|
i6 = Integer.parseInt(obj, 16);
|
|
} else {
|
|
if (obj.length() == 3) {
|
|
parseInt = Integer.parseInt(obj.substring(0, 1), 16);
|
|
parseInt2 = Integer.parseInt(obj.substring(1, 2), 16);
|
|
parseInt3 = Integer.parseInt(obj.substring(2, 3), 16);
|
|
} else if (obj.length() == 4) {
|
|
int parseInt4 = Integer.parseInt(obj.substring(0, 2), 16);
|
|
i5 = Integer.parseInt(obj.substring(2, 4), 16);
|
|
i7 = parseInt4;
|
|
i4 = 0;
|
|
i3 = i4;
|
|
i2 = i5;
|
|
i8 = 255;
|
|
argb = Color.argb(i8, i3, i7, i2);
|
|
if (argb == this.w.getColor()) {
|
|
this.H = true;
|
|
this.w.b(argb, true);
|
|
return;
|
|
}
|
|
return;
|
|
} else if (obj.length() == 5) {
|
|
parseInt = Integer.parseInt(obj.substring(0, 1), 16);
|
|
parseInt2 = Integer.parseInt(obj.substring(1, 3), 16);
|
|
parseInt3 = Integer.parseInt(obj.substring(3, 5), 16);
|
|
} else if (obj.length() == 6) {
|
|
parseInt = Integer.parseInt(obj.substring(0, 2), 16);
|
|
parseInt2 = Integer.parseInt(obj.substring(2, 4), 16);
|
|
parseInt3 = Integer.parseInt(obj.substring(4, 6), 16);
|
|
} else {
|
|
if (obj.length() == 7) {
|
|
i8 = Integer.parseInt(obj.substring(0, 1), 16);
|
|
i3 = Integer.parseInt(obj.substring(1, 3), 16);
|
|
i7 = Integer.parseInt(obj.substring(3, 5), 16);
|
|
i2 = Integer.parseInt(obj.substring(5, 7), 16);
|
|
} else if (obj.length() == 8) {
|
|
i8 = Integer.parseInt(obj.substring(0, 2), 16);
|
|
i3 = Integer.parseInt(obj.substring(2, 4), 16);
|
|
i7 = Integer.parseInt(obj.substring(4, 6), 16);
|
|
i2 = Integer.parseInt(obj.substring(6, 8), 16);
|
|
} else {
|
|
i2 = -1;
|
|
i3 = -1;
|
|
i7 = -1;
|
|
}
|
|
argb = Color.argb(i8, i3, i7, i2);
|
|
if (argb == this.w.getColor()) {
|
|
}
|
|
}
|
|
i5 = parseInt3;
|
|
i4 = parseInt;
|
|
i7 = parseInt2;
|
|
i3 = i4;
|
|
i2 = i5;
|
|
i8 = 255;
|
|
argb = Color.argb(i8, i3, i7, i2);
|
|
if (argb == this.w.getColor()) {
|
|
}
|
|
}
|
|
i5 = i6;
|
|
i4 = 0;
|
|
i3 = i4;
|
|
i2 = i5;
|
|
i8 = 255;
|
|
argb = Color.argb(i8, i3, i7, i2);
|
|
if (argb == this.w.getColor()) {
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
}
|
|
|
|
public void h(@ColorInt int i2) {
|
|
int i3 = 0;
|
|
int[] iArr = {m(i2, 0.9d), m(i2, 0.7d), m(i2, 0.5d), m(i2, 0.333d), m(i2, 0.166d), m(i2, -0.125d), m(i2, -0.25d), m(i2, -0.375d), m(i2, -0.5d), m(i2, -0.675d), m(i2, -0.7d), m(i2, -0.775d)};
|
|
if (this.t.getChildCount() != 0) {
|
|
while (i3 < this.t.getChildCount()) {
|
|
FrameLayout frameLayout = (FrameLayout) this.t.getChildAt(i3);
|
|
ColorPanelView colorPanelView = (ColorPanelView) frameLayout.findViewById(R.c.cpv_color_panel_view);
|
|
colorPanelView.setColor(iArr[i3]);
|
|
colorPanelView.setTag(Boolean.FALSE);
|
|
((ImageView) frameLayout.findViewById(R.c.cpv_color_image_view)).setImageDrawable(null);
|
|
i3++;
|
|
}
|
|
return;
|
|
}
|
|
int dimensionPixelSize = getResources().getDimensionPixelSize(R.a.cpv_item_horizontal_padding);
|
|
while (i3 < 12) {
|
|
int i4 = iArr[i3];
|
|
View inflate = View.inflate(getActivity(), this.r == 0 ? R.d.cpv_color_item_square : R.d.cpv_color_item_circle, null);
|
|
ColorPanelView colorPanelView2 = (ColorPanelView) inflate.findViewById(R.c.cpv_color_panel_view);
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) colorPanelView2.getLayoutParams();
|
|
marginLayoutParams.rightMargin = dimensionPixelSize;
|
|
marginLayoutParams.leftMargin = dimensionPixelSize;
|
|
colorPanelView2.setLayoutParams(marginLayoutParams);
|
|
colorPanelView2.setColor(i4);
|
|
this.t.addView(inflate);
|
|
colorPanelView2.post(new i(this, colorPanelView2, i4));
|
|
colorPanelView2.setOnClickListener(new j(colorPanelView2));
|
|
colorPanelView2.setOnLongClickListener(new a(this, colorPanelView2));
|
|
i3++;
|
|
}
|
|
}
|
|
|
|
public View i() {
|
|
View inflate = View.inflate(getActivity(), R.d.cpv_dialog_color_picker, null);
|
|
this.w = (ColorPickerView) inflate.findViewById(R.c.cpv_color_picker_view);
|
|
this.f2416x = (ColorPanelView) inflate.findViewById(R.c.cpv_color_panel_new);
|
|
this.f2418z = (EditText) inflate.findViewById(R.c.cpv_hex);
|
|
this.f2417y = (EditText) inflate.findViewById(R.c.cpv_hex_prefix);
|
|
this.A = inflate.findViewById(R.c.cpv_hex_container);
|
|
this.w.setAlphaSliderVisible(this.F);
|
|
this.w.b(this.n, true);
|
|
this.f2416x.setColor(this.n);
|
|
l(this.n);
|
|
if (!this.F) {
|
|
this.f2418z.setFilters(new InputFilter[]{new InputFilter.LengthFilter(6)});
|
|
}
|
|
this.f2416x.setOnClickListener(new f());
|
|
inflate.setOnTouchListener(this.J);
|
|
this.w.setOnColorChangedListener(this);
|
|
this.f2418z.addTextChangedListener(this);
|
|
this.f2418z.setOnFocusChangeListener(new g());
|
|
int i2 = getArguments().getInt("inputTextColor", 0);
|
|
if (i2 != 0) {
|
|
this.f2418z.setTextColor(i2);
|
|
this.f2417y.setTextColor(i2);
|
|
}
|
|
int i3 = getArguments().getInt("inputBackground", 0);
|
|
if (i3 != 0) {
|
|
this.A.setBackgroundResource(i3);
|
|
}
|
|
int i4 = getArguments().getInt("inputFont", 0);
|
|
if (i4 != 0) {
|
|
this.f2418z.setTypeface(ResourcesCompat.getFont(requireContext(), i4));
|
|
this.f2417y.setTypeface(ResourcesCompat.getFont(requireContext(), i4));
|
|
}
|
|
return inflate;
|
|
}
|
|
|
|
public View j() {
|
|
boolean z2;
|
|
View inflate = View.inflate(getActivity(), R.d.cpv_dialog_presets, null);
|
|
this.t = (LinearLayout) inflate.findViewById(R.c.shades_layout);
|
|
this.u = (SeekBar) inflate.findViewById(R.c.transparency_seekbar);
|
|
this.v = (TextView) inflate.findViewById(R.c.transparency_text);
|
|
GridView gridView = (GridView) inflate.findViewById(R.c.gridView);
|
|
View findViewById = inflate.findViewById(R.c.shades_divider);
|
|
int alpha = Color.alpha(this.n);
|
|
int[] intArray = getArguments().getIntArray("presets");
|
|
this.m = intArray;
|
|
if (intArray == null) {
|
|
this.m = i;
|
|
}
|
|
int[] iArr = this.m;
|
|
boolean z3 = iArr == i;
|
|
this.m = Arrays.copyOf(iArr, iArr.length);
|
|
if (alpha != 255) {
|
|
int i2 = 0;
|
|
while (true) {
|
|
int[] iArr2 = this.m;
|
|
if (i2 >= iArr2.length) {
|
|
break;
|
|
}
|
|
int i3 = iArr2[i2];
|
|
this.m[i2] = Color.argb(alpha, Color.red(i3), Color.green(i3), Color.blue(i3));
|
|
i2++;
|
|
}
|
|
}
|
|
this.m = n(this.m, this.n);
|
|
int i4 = getArguments().getInt(ModelAuditLogEntry.CHANGE_KEY_COLOR);
|
|
if (i4 != this.n) {
|
|
this.m = n(this.m, i4);
|
|
}
|
|
if (z3) {
|
|
int[] iArr3 = this.m;
|
|
if (iArr3.length == 19) {
|
|
int argb = Color.argb(alpha, 0, 0, 0);
|
|
int length = iArr3.length;
|
|
int i5 = 0;
|
|
while (true) {
|
|
if (i5 >= length) {
|
|
z2 = false;
|
|
break;
|
|
} else if (iArr3[i5] == argb) {
|
|
z2 = true;
|
|
break;
|
|
} else {
|
|
i5++;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
int length2 = iArr3.length + 1;
|
|
int[] iArr4 = new int[length2];
|
|
int i6 = length2 - 1;
|
|
iArr4[i6] = argb;
|
|
System.arraycopy(iArr3, 0, iArr4, 0, i6);
|
|
iArr3 = iArr4;
|
|
}
|
|
this.m = iArr3;
|
|
}
|
|
}
|
|
if (this.q) {
|
|
h(this.n);
|
|
findViewById.setVisibility(0);
|
|
int i7 = getArguments().getInt("dividerColor", 0);
|
|
if (i7 != 0) {
|
|
findViewById.setBackgroundTintList(ColorStateList.valueOf(i7));
|
|
}
|
|
} else {
|
|
this.t.setVisibility(8);
|
|
findViewById.setVisibility(8);
|
|
}
|
|
h hVar = new h();
|
|
int[] iArr5 = this.m;
|
|
int i8 = 0;
|
|
while (true) {
|
|
int[] iArr6 = this.m;
|
|
if (i8 >= iArr6.length) {
|
|
i8 = -1;
|
|
break;
|
|
} else if (iArr6[i8] == this.n) {
|
|
break;
|
|
} else {
|
|
i8++;
|
|
}
|
|
}
|
|
c.k.a.a.b bVar = new c.k.a.a.b(hVar, iArr5, i8, this.r);
|
|
this.f2415s = bVar;
|
|
gridView.setAdapter((ListAdapter) bVar);
|
|
if (this.F) {
|
|
int alpha2 = 255 - Color.alpha(this.n);
|
|
this.u.setMax(255);
|
|
this.u.setProgress(alpha2);
|
|
this.v.setText(String.format(Locale.ENGLISH, "%d%%", Integer.valueOf((int) ((((double) alpha2) * 100.0d) / 255.0d))));
|
|
this.u.setOnSeekBarChangeListener(new c.k.a.a.e(this));
|
|
} else {
|
|
inflate.findViewById(R.c.transparency_layout).setVisibility(8);
|
|
inflate.findViewById(R.c.transparency_title).setVisibility(8);
|
|
}
|
|
return inflate;
|
|
}
|
|
|
|
public void k(int i2) {
|
|
this.n = i2;
|
|
ColorPanelView colorPanelView = this.f2416x;
|
|
if (colorPanelView != null) {
|
|
colorPanelView.setColor(i2);
|
|
}
|
|
if (!this.H && this.f2418z != null) {
|
|
l(i2);
|
|
if (this.f2418z.hasFocus()) {
|
|
((InputMethodManager) getActivity().getSystemService("input_method")).hideSoftInputFromWindow(this.f2418z.getWindowToken(), 0);
|
|
this.f2418z.clearFocus();
|
|
}
|
|
}
|
|
this.H = false;
|
|
}
|
|
|
|
public final void l(int i2) {
|
|
if (this.F) {
|
|
this.f2418z.setText(String.format("%08X", Integer.valueOf(i2)));
|
|
} else {
|
|
this.f2418z.setText(String.format("%06X", Integer.valueOf(i2 & ViewCompat.MEASURED_SIZE_MASK)));
|
|
}
|
|
}
|
|
|
|
public final int m(@ColorInt int i2, double d2) {
|
|
long parseLong = Long.parseLong(String.format("#%06X", Integer.valueOf(16777215 & i2)).substring(1), 16);
|
|
double d3 = ShadowDrawableWrapper.COS_45;
|
|
int i3 = (d2 > ShadowDrawableWrapper.COS_45 ? 1 : (d2 == ShadowDrawableWrapper.COS_45 ? 0 : -1));
|
|
if (i3 >= 0) {
|
|
d3 = 255.0d;
|
|
}
|
|
if (i3 < 0) {
|
|
d2 *= -1.0d;
|
|
}
|
|
long j2 = parseLong >> 16;
|
|
long j3 = (parseLong >> 8) & 255;
|
|
long j4 = parseLong & 255;
|
|
return Color.argb(Color.alpha(i2), (int) (Math.round((d3 - ((double) j2)) * d2) + j2), (int) (Math.round((d3 - ((double) j3)) * d2) + j3), (int) (Math.round((d3 - ((double) j4)) * d2) + j4));
|
|
}
|
|
|
|
public final int[] n(int[] iArr, int i2) {
|
|
boolean z2;
|
|
int length = iArr.length;
|
|
int i3 = 0;
|
|
while (true) {
|
|
if (i3 >= length) {
|
|
z2 = false;
|
|
break;
|
|
} else if (iArr[i3] == i2) {
|
|
z2 = true;
|
|
break;
|
|
} else {
|
|
i3++;
|
|
}
|
|
}
|
|
if (z2) {
|
|
return iArr;
|
|
}
|
|
int length2 = iArr.length + 1;
|
|
int[] iArr2 = new int[length2];
|
|
iArr2[0] = i2;
|
|
System.arraycopy(iArr, 0, iArr2, 1, length2 - 1);
|
|
return iArr2;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.DialogFragment
|
|
public Dialog onCreateDialog(Bundle bundle) {
|
|
this.p = getArguments().getInt(ModelAuditLogEntry.CHANGE_KEY_ID);
|
|
this.F = getArguments().getBoolean(Key.ALPHA);
|
|
this.q = getArguments().getBoolean("showColorShades");
|
|
this.r = getArguments().getInt("colorShape");
|
|
if (bundle == null) {
|
|
this.n = getArguments().getInt(ModelAuditLogEntry.CHANGE_KEY_COLOR);
|
|
this.o = getArguments().getInt("dialogType");
|
|
} else {
|
|
this.n = bundle.getInt(ModelAuditLogEntry.CHANGE_KEY_COLOR);
|
|
this.o = bundle.getInt("dialogType");
|
|
}
|
|
View inflate = LayoutInflater.from(requireContext()).inflate(R.d.cpv_dialog, (ViewGroup) null);
|
|
this.k = inflate;
|
|
FrameLayout frameLayout = (FrameLayout) inflate.findViewById(R.c.cpv_color_picker_content);
|
|
this.l = frameLayout;
|
|
int i2 = this.o;
|
|
if (i2 == 0) {
|
|
frameLayout.addView(i());
|
|
} else if (i2 == 1) {
|
|
frameLayout.addView(j());
|
|
}
|
|
return new AlertDialog.Builder(requireActivity()).setView(this.k).create();
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
@Nullable
|
|
public View onCreateView(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
|
|
return this.k;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.DialogFragment, android.content.DialogInterface.OnDismissListener
|
|
public void onDismiss(DialogInterface dialogInterface) {
|
|
super.onDismiss(dialogInterface);
|
|
if (this.j != null) {
|
|
Log.w("ColorPickerDialog", "Using deprecated listener which may be remove in future releases");
|
|
this.j.onDialogDismissed(this.p);
|
|
return;
|
|
}
|
|
FragmentActivity activity = getActivity();
|
|
if (activity instanceof c.k.a.a.f) {
|
|
((c.k.a.a.f) activity).onDialogDismissed(this.p);
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
|
|
public void onSaveInstanceState(Bundle bundle) {
|
|
bundle.putInt(ModelAuditLogEntry.CHANGE_KEY_COLOR, this.n);
|
|
bundle.putInt("dialogType", this.o);
|
|
super.onSaveInstanceState(bundle);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
|
|
public void onStart() {
|
|
super.onStart();
|
|
AlertDialog alertDialog = (AlertDialog) getDialog();
|
|
alertDialog.getWindow().clearFlags(131080);
|
|
alertDialog.getWindow().setSoftInputMode(4);
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle bundle) {
|
|
int i2;
|
|
super.onViewCreated(view, bundle);
|
|
this.B = (TextView) view.findViewById(R.c.cpv_color_picker_title);
|
|
this.C = (Button) view.findViewById(R.c.cpv_color_picker_custom_button);
|
|
this.D = (Button) view.findViewById(R.c.cpv_color_picker_select_button);
|
|
this.E = (TextView) view.findViewById(R.c.cpv_color_picker_custom_reset);
|
|
int i3 = getArguments().getInt("backgroundColor", 0);
|
|
if (i3 != 0) {
|
|
view.setBackgroundColor(i3);
|
|
}
|
|
int i4 = getArguments().getInt("dialogTitle");
|
|
if (i4 != 0) {
|
|
this.B.setText(i4);
|
|
}
|
|
int i5 = getArguments().getInt("titleTextColor", 0);
|
|
if (i5 != 0) {
|
|
this.B.setTextColor(i5);
|
|
}
|
|
int i6 = getArguments().getInt("selectedButtonText");
|
|
if (i6 == 0) {
|
|
i6 = R.e.cpv_select;
|
|
}
|
|
this.D.setText(i6);
|
|
this.D.setOnClickListener(new c());
|
|
int i7 = getArguments().getInt("resetButtonText");
|
|
if (i7 != 0) {
|
|
this.E.setText(i7);
|
|
}
|
|
this.E.setOnClickListener(new d());
|
|
this.G = getArguments().getInt("presetsButtonText");
|
|
this.I = getArguments().getInt("customButtonText");
|
|
if (this.o == 0 && getArguments().getBoolean("allowPresets")) {
|
|
i2 = this.G;
|
|
if (i2 == 0) {
|
|
i2 = R.e.cpv_presets;
|
|
}
|
|
} else if (this.o != 1 || !getArguments().getBoolean("allowCustom")) {
|
|
i2 = 0;
|
|
} else {
|
|
i2 = this.I;
|
|
if (i2 == 0) {
|
|
i2 = R.e.cpv_custom;
|
|
}
|
|
}
|
|
if (i2 != 0) {
|
|
this.C.setText(i2);
|
|
this.C.setVisibility(0);
|
|
} else {
|
|
this.C.setVisibility(8);
|
|
}
|
|
if (getArguments().getBoolean("allowReset")) {
|
|
this.E.setVisibility(0);
|
|
} else {
|
|
this.E.setVisibility(8);
|
|
}
|
|
int i8 = getArguments().getInt("customButtonColor", 0);
|
|
if (i8 != 0) {
|
|
this.C.setBackgroundTintList(ColorStateList.valueOf(i8));
|
|
}
|
|
int i9 = getArguments().getInt("selectedButtonColor", 0);
|
|
if (i9 != 0) {
|
|
this.D.setBackgroundTintList(ColorStateList.valueOf(i9));
|
|
this.E.setTextColor(i9);
|
|
}
|
|
int i10 = getArguments().getInt("customButtonTextColor", 0);
|
|
if (i10 != 0) {
|
|
this.C.setTextColor(i10);
|
|
}
|
|
int i11 = getArguments().getInt("selectedButtonTextColor", 0);
|
|
if (i11 != 0) {
|
|
this.D.setTextColor(i11);
|
|
}
|
|
int i12 = getArguments().getInt("titleFont", 0);
|
|
if (i12 != 0) {
|
|
this.B.setTypeface(ResourcesCompat.getFont(requireContext(), i12));
|
|
}
|
|
int i13 = getArguments().getInt("buttonFont", 0);
|
|
if (i13 != 0) {
|
|
this.D.setTypeface(ResourcesCompat.getFont(requireContext(), i13));
|
|
this.C.setTypeface(ResourcesCompat.getFont(requireContext(), i13));
|
|
this.E.setTypeface(ResourcesCompat.getFont(requireContext(), i13));
|
|
}
|
|
this.C.setOnClickListener(new e());
|
|
}
|
|
}
|