discord-jadx/app/src/main/java/c/i/a/g/j/p.java

123 lines
4.7 KiB
Java

package c.i.a.g.j;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import com.google.android.material.R;
import com.google.android.material.internal.TextWatcherAdapter;
import com.google.android.material.textfield.TextInputLayout;
/* compiled from: PasswordToggleEndIconDelegate */
public class p extends m {
public final TextWatcher d = new a();
public final TextInputLayout.OnEditTextAttachedListener e = new b();
public final TextInputLayout.OnEndIconChangedListener f = new c();
/* compiled from: PasswordToggleEndIconDelegate */
public class a extends TextWatcherAdapter {
public a() {
}
@Override // com.google.android.material.internal.TextWatcherAdapter, android.text.TextWatcher
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
p pVar = p.this;
pVar.f1254c.setChecked(!p.d(pVar));
}
}
/* compiled from: PasswordToggleEndIconDelegate */
public class b implements TextInputLayout.OnEditTextAttachedListener {
public b() {
}
@Override // com.google.android.material.textfield.TextInputLayout.OnEditTextAttachedListener
public void onEditTextAttached(@NonNull TextInputLayout textInputLayout) {
EditText editText = textInputLayout.getEditText();
textInputLayout.setEndIconVisible(true);
textInputLayout.setEndIconCheckable(true);
p pVar = p.this;
pVar.f1254c.setChecked(!p.d(pVar));
editText.removeTextChangedListener(p.this.d);
editText.addTextChangedListener(p.this.d);
}
}
/* compiled from: PasswordToggleEndIconDelegate */
public class c implements TextInputLayout.OnEndIconChangedListener {
/* compiled from: PasswordToggleEndIconDelegate */
public class a implements Runnable {
public final /* synthetic */ EditText i;
public a(EditText editText) {
this.i = editText;
}
@Override // java.lang.Runnable
public void run() {
this.i.removeTextChangedListener(p.this.d);
}
}
public c() {
}
@Override // com.google.android.material.textfield.TextInputLayout.OnEndIconChangedListener
public void onEndIconChanged(@NonNull TextInputLayout textInputLayout, int i) {
EditText editText = textInputLayout.getEditText();
if (editText != null && i == 1) {
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
editText.post(new a(editText));
}
}
}
/* compiled from: PasswordToggleEndIconDelegate */
public class d implements View.OnClickListener {
public d() {
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
EditText editText = p.this.a.getEditText();
if (editText != null) {
int selectionEnd = editText.getSelectionEnd();
if (p.d(p.this)) {
editText.setTransformationMethod(null);
} else {
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
if (selectionEnd >= 0) {
editText.setSelection(selectionEnd);
}
p.this.a.refreshEndIconDrawableState();
}
}
}
public p(@NonNull TextInputLayout textInputLayout) {
super(textInputLayout);
}
public static boolean d(p pVar) {
EditText editText = pVar.a.getEditText();
return editText != null && (editText.getTransformationMethod() instanceof PasswordTransformationMethod);
}
@Override // c.i.a.g.j.m
public void a() {
this.a.setEndIconDrawable(AppCompatResources.getDrawable(this.b, R.drawable.design_password_eye));
TextInputLayout textInputLayout = this.a;
textInputLayout.setEndIconContentDescription(textInputLayout.getResources().getText(R.string.password_toggle_content_description));
this.a.setEndIconOnClickListener(new d());
this.a.addOnEditTextAttachedListener(this.e);
this.a.addOnEndIconChangedListener(this.f);
EditText editText = this.a.getEditText();
if (editText != null && (editText.getInputType() == 16 || editText.getInputType() == 128 || editText.getInputType() == 144 || editText.getInputType() == 224)) {
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
}
}