2021-06-27 20:44:35 +00:00
package com.discord.views ;
import android.content.Context ;
import android.content.res.TypedArray ;
import android.graphics.drawable.Drawable ;
import android.util.AttributeSet ;
import android.view.LayoutInflater ;
import android.view.View ;
import android.view.ViewGroup ;
import android.view.inputmethod.BaseInputConnection ;
import android.view.inputmethod.EditorInfo ;
import android.view.inputmethod.InputConnection ;
import android.view.inputmethod.InputMethodManager ;
import android.widget.LinearLayout ;
import android.widget.TextView ;
import androidx.core.content.ContextCompat ;
import androidx.core.view.ViewCompat ;
2021-07-13 20:23:20 +00:00
import c.a.i.u1 ;
2021-06-27 20:44:35 +00:00
import c.a.z.b ;
import c.a.z.c ;
import c.a.z.d ;
import c.a.z.e ;
import com.discord.R ;
import d0.g0.w ;
import d0.t.n ;
import d0.z.d.m ;
import java.util.List ;
import java.util.Objects ;
import kotlin.Unit ;
import kotlin.jvm.functions.Function1 ;
import kotlin.jvm.internal.DefaultConstructorMarker ;
/* compiled from: CodeVerificationView.kt */
public final class CodeVerificationView extends LinearLayout {
public static final a i = a . NUMERIC ;
2021-07-13 20:23:20 +00:00
public final u1 j ;
2021-06-27 20:44:35 +00:00
public final List < TextView > k ;
public final Drawable l ;
public final Drawable m ;
public a n ;
public String o ;
public Function1 < ? super String , Unit > p ;
/* compiled from: CodeVerificationView.kt */
public enum a {
NUMERIC ,
/* Fake field, exist only in values array */
ALPHANUMERIC ;
public static final a [ ] k = values ( ) ;
2021-07-13 20:23:20 +00:00
public static final C0181a l = new C0181a ( null ) ;
2021-06-27 20:44:35 +00:00
/* compiled from: CodeVerificationView.kt */
/* renamed from: com.discord.views.CodeVerificationView$a$a reason: collision with other inner class name */
2021-07-13 20:23:20 +00:00
public static final class C0181a {
public C0181a ( DefaultConstructorMarker defaultConstructorMarker ) {
2021-06-27 20:44:35 +00:00
}
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public CodeVerificationView ( Context context , AttributeSet attributeSet ) {
super ( context , attributeSet , 0 ) ;
m . checkNotNullParameter ( context , " context " ) ;
2021-07-13 20:23:20 +00:00
View inflate = LayoutInflater . from ( context ) . inflate ( 2131558742 , ( ViewGroup ) this , false ) ;
2021-06-27 20:44:35 +00:00
addView ( inflate ) ;
2021-07-13 20:23:20 +00:00
int i2 = 2131365600 ;
TextView textView = ( TextView ) inflate . findViewById ( 2131365600 ) ;
2021-06-27 20:44:35 +00:00
if ( textView ! = null ) {
2021-07-13 20:23:20 +00:00
i2 = 2131365601 ;
TextView textView2 = ( TextView ) inflate . findViewById ( 2131365601 ) ;
2021-06-27 20:44:35 +00:00
if ( textView2 ! = null ) {
2021-07-13 20:23:20 +00:00
i2 = 2131365602 ;
TextView textView3 = ( TextView ) inflate . findViewById ( 2131365602 ) ;
2021-06-27 20:44:35 +00:00
if ( textView3 ! = null ) {
2021-07-13 20:23:20 +00:00
i2 = 2131365603 ;
TextView textView4 = ( TextView ) inflate . findViewById ( 2131365603 ) ;
2021-06-27 20:44:35 +00:00
if ( textView4 ! = null ) {
2021-07-13 20:23:20 +00:00
i2 = 2131365604 ;
TextView textView5 = ( TextView ) inflate . findViewById ( 2131365604 ) ;
2021-06-27 20:44:35 +00:00
if ( textView5 ! = null ) {
2021-07-13 20:23:20 +00:00
i2 = 2131365605 ;
TextView textView6 = ( TextView ) inflate . findViewById ( 2131365605 ) ;
2021-06-27 20:44:35 +00:00
if ( textView6 ! = null ) {
2021-07-13 20:23:20 +00:00
u1 u1Var = new u1 ( ( LinearLayout ) inflate , textView , textView2 , textView3 , textView4 , textView5 , textView6 ) ;
m . checkNotNullExpressionValue ( u1Var , " ViewCodeVerificationBind…rom(context), this, true) " ) ;
this . j = u1Var ;
2021-06-27 20:44:35 +00:00
this . o = " " ;
this . p = e . i ;
if ( attributeSet ! = null ) {
TypedArray obtainStyledAttributes = getContext ( ) . obtainStyledAttributes ( attributeSet , R . a . CodeVerificationView , 0 , 0 ) ;
m . checkNotNullExpressionValue ( obtainStyledAttributes , " context.obtainStyledAttr…deVerificationView, 0, 0) " ) ;
try {
int i3 = obtainStyledAttributes . getInt ( 0 , i . ordinal ( ) ) ;
2021-07-13 20:23:20 +00:00
a . C0181a aVar = a . l ;
2021-06-27 20:44:35 +00:00
this . n = a . k [ i3 ] ;
} finally {
obtainStyledAttributes . recycle ( ) ;
}
}
setClickable ( true ) ;
setFocusable ( true ) ;
setFocusableInTouchMode ( true ) ;
setOnFocusChangeListener ( new b ( this ) ) ;
setOnClickListener ( new c ( this ) ) ;
setOnKeyListener ( new d ( this ) ) ;
m . checkNotNullExpressionValue ( textView , " binding.verifyChar1 " ) ;
m . checkNotNullExpressionValue ( textView2 , " binding.verifyChar2 " ) ;
m . checkNotNullExpressionValue ( textView3 , " binding.verifyChar3 " ) ;
m . checkNotNullExpressionValue ( textView4 , " binding.verifyChar4 " ) ;
m . checkNotNullExpressionValue ( textView5 , " binding.verifyChar5 " ) ;
m . checkNotNullExpressionValue ( textView6 , " binding.verifyChar6 " ) ;
List < TextView > listOf = n . listOf ( ( Object [ ] ) new TextView [ ] { textView , textView2 , textView3 , textView4 , textView5 , textView6 } ) ;
this . k = listOf ;
listOf . get ( 0 ) . requestFocus ( ) ;
TextView textView7 = listOf . get ( 0 ) ;
if ( ! ViewCompat . isLaidOut ( textView7 ) | | textView7 . isLayoutRequested ( ) ) {
textView7 . addOnLayoutChangeListener ( new c . a . z . a ( this ) ) ;
} else {
a ( this ) ;
}
2021-07-13 20:23:20 +00:00
this . l = ContextCompat . getDrawable ( context , 2131231228 ) ;
this . m = ContextCompat . getDrawable ( context , 2131231229 ) ;
2021-06-27 20:44:35 +00:00
e ( ) ;
return ;
}
}
}
}
}
}
throw new NullPointerException ( " Missing required view with ID: " . concat ( inflate . getResources ( ) . getResourceName ( i2 ) ) ) ;
}
public static final void a ( CodeVerificationView codeVerificationView ) {
Object systemService = codeVerificationView . getContext ( ) . getSystemService ( " input_method " ) ;
Objects . requireNonNull ( systemService , " null cannot be cast to non-null type android.view.inputmethod.InputMethodManager " ) ;
( ( InputMethodManager ) systemService ) . showSoftInput ( codeVerificationView , 2 ) ;
}
public final void b ( ) {
if ( this . o . length ( ) > 0 ) {
this . o = " " ;
d ( ) ;
}
}
public final void c ( char c2 ) {
if ( this . o . length ( ) < 6 ) {
String str = this . o ;
this . o = str + c2 ;
d ( ) ;
}
}
public final void d ( ) {
int i2 = 0 ;
for ( Object obj : this . k ) {
int i3 = i2 + 1 ;
if ( i2 < 0 ) {
n . throwIndexOverflow ( ) ;
}
TextView textView = ( TextView ) obj ;
if ( i2 < = w . getLastIndex ( this . o ) ) {
textView . setText ( String . valueOf ( this . o . charAt ( i2 ) ) ) ;
} else {
textView . setText ( " " ) ;
}
i2 = i3 ;
}
if ( this . o . length ( ) = = 6 ) {
this . p . invoke ( this . o ) ;
}
e ( ) ;
}
public final void e ( ) {
int min = Math . min ( this . o . length ( ) , n . getLastIndex ( this . k ) ) ;
int i2 = 0 ;
for ( Object obj : this . k ) {
int i3 = i2 + 1 ;
if ( i2 < 0 ) {
n . throwIndexOverflow ( ) ;
}
( ( TextView ) obj ) . setBackground ( i2 = = min ? this . m : this . l ) ;
i2 = i3 ;
}
}
public final String getCode ( ) {
return this . o ;
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super java.lang.String, kotlin.Unit>, kotlin.jvm.functions.Function1<java.lang.String, kotlin.Unit> */
public final Function1 < String , Unit > getOnCodeEntered ( ) {
return this . p ;
}
@Override // android.view.View
public boolean onCheckIsTextEditor ( ) {
return true ;
}
@Override // android.view.View
public InputConnection onCreateInputConnection ( EditorInfo editorInfo ) {
m . checkNotNullParameter ( editorInfo , " outAttrs " ) ;
a aVar = this . n ;
if ( aVar = = null ) {
m . throwUninitializedPropertyAccessException ( " inputType " ) ;
}
if ( aVar ! = a . NUMERIC ) {
return super . onCreateInputConnection ( editorInfo ) ;
}
BaseInputConnection baseInputConnection = new BaseInputConnection ( this , false ) ;
editorInfo . inputType = 18 ;
return baseInputConnection ;
}
public final void setCode ( CharSequence charSequence ) {
m . checkNotNullParameter ( charSequence , " code " ) ;
String str = this . o ;
String obj = charSequence . toString ( ) ;
this . o = obj ;
if ( ! m . areEqual ( str , obj ) ) {
d ( ) ;
}
}
public final void setOnCodeEntered ( Function1 < ? super String , Unit > function1 ) {
m . checkNotNullParameter ( function1 , " <set-?> " ) ;
this . p = function1 ;
}
}