package androidx.appcompat.widget; import android.app.PendingIntent; import android.app.SearchableInfo; import android.content.ActivityNotFoundException; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.text.Editable; import android.text.SpannableStringBuilder; import android.text.TextUtils; import android.text.TextWatcher; import android.text.style.ImageSpan; import android.util.AttributeSet; import android.util.Log; import android.util.TypedValue; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.TouchDelegate; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.AutoCompleteTextView; import android.widget.ImageView; import android.widget.TextView; import java.lang.reflect.Method; import java.util.WeakHashMap; import p007c.C0485a; import p007c.C0488d; import p007c.C0490f; import p007c.C0491g; import p007c.C0492h; import p007c.C0494j; import p022h.InterfaceC0745c; import p023h0.C0829h1; import p028j.C1074c; import p028j.C1106g3; import p028j.C1134k3; import p028j.C1187q3; import p028j.View$OnClickListenerC1066a3; import p035l0.AbstractC1415a; import p038m0.AbstractC1459a; /* loaded from: classes.dex */ public class SearchView extends C0173c implements InterfaceC0745c { /* renamed from: q0 */ public static final C0148o f500q0; /* renamed from: A */ public final View f501A; /* renamed from: B */ public C0151q f502B; /* renamed from: C */ public Rect f503C; /* renamed from: D */ public Rect f504D; /* renamed from: E */ public int[] f505E; /* renamed from: F */ public int[] f506F; /* renamed from: G */ public final ImageView f507G; /* renamed from: H */ public final Drawable f508H; /* renamed from: I */ public final int f509I; /* renamed from: J */ public final int f510J; /* renamed from: K */ public final Intent f511K; /* renamed from: L */ public final Intent f512L; /* renamed from: M */ public final CharSequence f513M; /* renamed from: N */ public View.OnFocusChangeListener f514N; /* renamed from: O */ public View.OnClickListener f515O; /* renamed from: P */ public boolean f516P; /* renamed from: Q */ public boolean f517Q; /* renamed from: R */ public AbstractC1415a f518R; /* renamed from: S */ public boolean f519S; /* renamed from: T */ public CharSequence f520T; /* renamed from: U */ public boolean f521U; /* renamed from: V */ public boolean f522V; /* renamed from: W */ public int f523W; /* renamed from: a0 */ public boolean f524a0; /* renamed from: b0 */ public CharSequence f525b0; /* renamed from: c0 */ public CharSequence f526c0; /* renamed from: d0 */ public boolean f527d0; /* renamed from: e0 */ public int f528e0; /* renamed from: f0 */ public SearchableInfo f529f0; /* renamed from: g0 */ public Bundle f530g0; /* renamed from: h0 */ public final Runnable f531h0; /* renamed from: i0 */ public Runnable f532i0; /* renamed from: j0 */ public final WeakHashMap f533j0; /* renamed from: k0 */ public final View.OnClickListener f534k0; /* renamed from: l0 */ public View.OnKeyListener f535l0; /* renamed from: m0 */ public final TextView.OnEditorActionListener f536m0; /* renamed from: n0 */ public final AdapterView.OnItemClickListener f537n0; /* renamed from: o0 */ public final AdapterView.OnItemSelectedListener f538o0; /* renamed from: p0 */ public TextWatcher f539p0; /* renamed from: s */ public final SearchAutoComplete f540s; /* renamed from: t */ public final View f541t; /* renamed from: u */ public final View f542u; /* renamed from: v */ public final View f543v; /* renamed from: w */ public final ImageView f544w; /* renamed from: x */ public final ImageView f545x; /* renamed from: y */ public final ImageView f546y; /* renamed from: z */ public final ImageView f547z; /* loaded from: classes.dex */ public static class SearchAutoComplete extends C1074c { /* renamed from: h */ public int f548h; /* renamed from: i */ public SearchView f549i; /* renamed from: j */ public boolean f550j; /* renamed from: k */ public final Runnable f551k; /* renamed from: androidx.appcompat.widget.SearchView$SearchAutoComplete$a */ /* loaded from: classes.dex */ public class RunnableC0133a implements Runnable { public RunnableC0133a() { } @Override // java.lang.Runnable public void run() { SearchAutoComplete.this.m4723d(); } } public SearchAutoComplete(Context context, AttributeSet attributeSet) { this(context, attributeSet, C0485a.autoCompleteTextViewStyle); } public SearchAutoComplete(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.f551k = new RunnableC0133a(); this.f548h = getThreshold(); } private int getSearchViewTextMinWidthDp() { Configuration configuration = getResources().getConfiguration(); int i = configuration.screenWidthDp; int i2 = configuration.screenHeightDp; if (i < 960 || i2 < 720 || configuration.orientation != 2) { if (i < 600) { return (i < 640 || i2 < 480) ? 160 : 192; } return 192; } return 256; } /* renamed from: b */ public void m4725b() { if (Build.VERSION.SDK_INT < 29) { SearchView.f500q0.m4718c(this); return; } C0144k.m4721b(this, 1); if (enoughToFilter()) { showDropDown(); } } /* renamed from: c */ public boolean m4724c() { return TextUtils.getTrimmedLength(getText()) == 0; } /* renamed from: d */ public void m4723d() { if (this.f550j) { ((InputMethodManager) getContext().getSystemService("input_method")).showSoftInput(this, 0); this.f550j = false; } } @Override // android.widget.AutoCompleteTextView public boolean enoughToFilter() { return this.f548h <= 0 || super.enoughToFilter(); } @Override // p028j.C1074c, android.widget.TextView, android.view.View public InputConnection onCreateInputConnection(EditorInfo editorInfo) { InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo); if (this.f550j) { removeCallbacks(this.f551k); post(this.f551k); } return onCreateInputConnection; } @Override // android.view.View public void onFinishInflate() { super.onFinishInflate(); setMinWidth((int) TypedValue.applyDimension(1, getSearchViewTextMinWidthDp(), getResources().getDisplayMetrics())); } @Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View public void onFocusChanged(boolean z, int i, Rect rect) { super.onFocusChanged(z, i, rect); this.f549i.m4741V(); } @Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View public boolean onKeyPreIme(int i, KeyEvent keyEvent) { if (i == 4) { if (keyEvent.getAction() == 0 && keyEvent.getRepeatCount() == 0) { KeyEvent.DispatcherState keyDispatcherState = getKeyDispatcherState(); if (keyDispatcherState != null) { keyDispatcherState.startTracking(keyEvent, this); } return true; } else if (keyEvent.getAction() == 1) { KeyEvent.DispatcherState keyDispatcherState2 = getKeyDispatcherState(); if (keyDispatcherState2 != null) { keyDispatcherState2.handleUpEvent(keyEvent); } if (keyEvent.isTracking() && !keyEvent.isCanceled()) { this.f549i.clearFocus(); setImeVisibility(false); return true; } } } return super.onKeyPreIme(i, keyEvent); } @Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View public void onWindowFocusChanged(boolean z) { super.onWindowFocusChanged(z); if (z && this.f549i.hasFocus() && getVisibility() == 0) { this.f550j = true; if (SearchView.m4754I(getContext())) { m4725b(); } } } @Override // android.widget.AutoCompleteTextView public void performCompletion() { } @Override // android.widget.AutoCompleteTextView public void replaceText(CharSequence charSequence) { } public void setImeVisibility(boolean z) { InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService("input_method"); if (!z) { this.f550j = false; removeCallbacks(this.f551k); inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0); } else if (!inputMethodManager.isActive(this)) { this.f550j = true; } else { this.f550j = false; removeCallbacks(this.f551k); inputMethodManager.showSoftInput(this, 0); } } public void setSearchView(SearchView searchView) { this.f549i = searchView; } @Override // android.widget.AutoCompleteTextView public void setThreshold(int i) { super.setThreshold(i); this.f548h = i; } } /* renamed from: androidx.appcompat.widget.SearchView$a */ /* loaded from: classes.dex */ public class C0134a implements TextWatcher { public C0134a() { } @Override // android.text.TextWatcher public void afterTextChanged(Editable editable) { } @Override // android.text.TextWatcher public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) { } @Override // android.text.TextWatcher public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) { SearchView.this.m4742U(charSequence); } } /* renamed from: androidx.appcompat.widget.SearchView$b */ /* loaded from: classes.dex */ public class RunnableC0135b implements Runnable { public RunnableC0135b() { } @Override // java.lang.Runnable public void run() { SearchView.this.m4735b0(); } } /* renamed from: androidx.appcompat.widget.SearchView$c */ /* loaded from: classes.dex */ public class RunnableC0136c implements Runnable { public RunnableC0136c() { } @Override // java.lang.Runnable public void run() { AbstractC1415a abstractC1415a = SearchView.this.f518R; if (abstractC1415a instanceof View$OnClickListenerC1066a3) { abstractC1415a.mo1390a(null); } } } /* renamed from: androidx.appcompat.widget.SearchView$d */ /* loaded from: classes.dex */ public class View$OnFocusChangeListenerC0137d implements View.OnFocusChangeListener { public View$OnFocusChangeListenerC0137d() { } @Override // android.view.View.OnFocusChangeListener public void onFocusChange(View view, boolean z) { SearchView searchView = SearchView.this; View.OnFocusChangeListener onFocusChangeListener = searchView.f514N; if (onFocusChangeListener != null) { onFocusChangeListener.onFocusChange(searchView, z); } } } /* renamed from: androidx.appcompat.widget.SearchView$e */ /* loaded from: classes.dex */ public class View$OnLayoutChangeListenerC0138e implements View.OnLayoutChangeListener { public View$OnLayoutChangeListenerC0138e() { } @Override // android.view.View.OnLayoutChangeListener public void onLayoutChange(View view, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8) { SearchView.this.m4728x(); } } /* renamed from: androidx.appcompat.widget.SearchView$f */ /* loaded from: classes.dex */ public class View$OnClickListenerC0139f implements View.OnClickListener { public View$OnClickListenerC0139f() { } @Override // android.view.View.OnClickListener public void onClick(View view) { SearchView searchView = SearchView.this; if (view == searchView.f544w) { searchView.m4745R(); } else if (view == searchView.f546y) { searchView.m4749N(); } else if (view == searchView.f545x) { searchView.m4744S(); } else if (view == searchView.f547z) { searchView.m4740W(); } else if (view == searchView.f540s) { searchView.m4759D(); } } } /* renamed from: androidx.appcompat.widget.SearchView$g */ /* loaded from: classes.dex */ public class View$OnKeyListenerC0140g implements View.OnKeyListener { public View$OnKeyListenerC0140g() { } @Override // android.view.View.OnKeyListener public boolean onKey(View view, int i, KeyEvent keyEvent) { SearchView searchView = SearchView.this; if (searchView.f529f0 == null) { return false; } if (!searchView.f540s.isPopupShowing() || SearchView.this.f540s.getListSelection() == -1) { if (!SearchView.this.f540s.m4724c() && keyEvent.hasNoModifiers() && keyEvent.getAction() == 1 && i == 66) { view.cancelLongPress(); SearchView searchView2 = SearchView.this; searchView2.m4751L(0, null, searchView2.f540s.getText().toString()); return true; } return false; } return SearchView.this.m4743T(view, i, keyEvent); } } /* renamed from: androidx.appcompat.widget.SearchView$h */ /* loaded from: classes.dex */ public class C0141h implements TextView.OnEditorActionListener { public C0141h() { } @Override // android.widget.TextView.OnEditorActionListener public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { SearchView.this.m4744S(); return true; } } /* renamed from: androidx.appcompat.widget.SearchView$i */ /* loaded from: classes.dex */ public class C0142i implements AdapterView.OnItemClickListener { public C0142i() { } @Override // android.widget.AdapterView.OnItemClickListener public void onItemClick(AdapterView adapterView, View view, int i, long j) { SearchView.this.m4748O(i, 0, null); } } /* renamed from: androidx.appcompat.widget.SearchView$j */ /* loaded from: classes.dex */ public class C0143j implements AdapterView.OnItemSelectedListener { public C0143j() { } @Override // android.widget.AdapterView.OnItemSelectedListener public void onItemSelected(AdapterView adapterView, View view, int i, long j) { SearchView.this.m4747P(i); } @Override // android.widget.AdapterView.OnItemSelectedListener public void onNothingSelected(AdapterView adapterView) { } } /* renamed from: androidx.appcompat.widget.SearchView$k */ /* loaded from: classes.dex */ public static class C0144k { /* renamed from: a */ public static void m4722a(AutoCompleteTextView autoCompleteTextView) { autoCompleteTextView.refreshAutoCompleteResults(); } /* renamed from: b */ public static void m4721b(SearchAutoComplete searchAutoComplete, int i) { searchAutoComplete.setInputMethodMode(i); } } /* renamed from: androidx.appcompat.widget.SearchView$l */ /* loaded from: classes.dex */ public interface InterfaceC0145l { } /* renamed from: androidx.appcompat.widget.SearchView$m */ /* loaded from: classes.dex */ public interface InterfaceC0146m { } /* renamed from: androidx.appcompat.widget.SearchView$n */ /* loaded from: classes.dex */ public interface InterfaceC0147n { } /* renamed from: androidx.appcompat.widget.SearchView$o */ /* loaded from: classes.dex */ public static class C0148o { /* renamed from: a */ public Method f563a; /* renamed from: b */ public Method f564b; /* renamed from: c */ public Method f565c; public C0148o() { this.f563a = null; this.f564b = null; this.f565c = null; m4717d(); try { Method declaredMethod = AutoCompleteTextView.class.getDeclaredMethod("doBeforeTextChanged", new Class[0]); this.f563a = declaredMethod; declaredMethod.setAccessible(true); } catch (NoSuchMethodException unused) { } try { Method declaredMethod2 = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged", new Class[0]); this.f564b = declaredMethod2; declaredMethod2.setAccessible(true); } catch (NoSuchMethodException unused2) { } try { Method method = AutoCompleteTextView.class.getMethod("ensureImeVisible", Boolean.TYPE); this.f565c = method; method.setAccessible(true); } catch (NoSuchMethodException unused3) { } } /* renamed from: d */ public static void m4717d() { if (Build.VERSION.SDK_INT >= 29) { throw new UnsupportedClassVersionError("This function can only be used for API Level < 29."); } } /* renamed from: a */ public void m4720a(AutoCompleteTextView autoCompleteTextView) { m4717d(); Method method = this.f564b; if (method != null) { try { method.invoke(autoCompleteTextView, new Object[0]); } catch (Exception unused) { } } } /* renamed from: b */ public void m4719b(AutoCompleteTextView autoCompleteTextView) { m4717d(); Method method = this.f563a; if (method != null) { try { method.invoke(autoCompleteTextView, new Object[0]); } catch (Exception unused) { } } } /* renamed from: c */ public void m4718c(AutoCompleteTextView autoCompleteTextView) { m4717d(); Method method = this.f565c; if (method != null) { try { method.invoke(autoCompleteTextView, Boolean.TRUE); } catch (Exception unused) { } } } } /* renamed from: androidx.appcompat.widget.SearchView$p */ /* loaded from: classes.dex */ public static class C0149p extends AbstractC1459a { public static final Parcelable.Creator CREATOR = new C0150a(); /* renamed from: f */ public boolean f566f; /* renamed from: androidx.appcompat.widget.SearchView$p$a */ /* loaded from: classes.dex */ public class C0150a implements Parcelable.ClassLoaderCreator { @Override // android.os.Parcelable.Creator /* renamed from: a */ public C0149p createFromParcel(Parcel parcel) { return new C0149p(parcel, null); } @Override // android.os.Parcelable.ClassLoaderCreator /* renamed from: b */ public C0149p createFromParcel(Parcel parcel, ClassLoader classLoader) { return new C0149p(parcel, classLoader); } @Override // android.os.Parcelable.Creator /* renamed from: c */ public C0149p[] newArray(int i) { return new C0149p[i]; } } public C0149p(Parcel parcel, ClassLoader classLoader) { super(parcel, classLoader); this.f566f = ((Boolean) parcel.readValue(null)).booleanValue(); } public C0149p(Parcelable parcelable) { super(parcelable); } public String toString() { return "SearchView.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " isIconified=" + this.f566f + "}"; } @Override // p038m0.AbstractC1459a, android.os.Parcelable public void writeToParcel(Parcel parcel, int i) { super.writeToParcel(parcel, i); parcel.writeValue(Boolean.valueOf(this.f566f)); } } /* renamed from: androidx.appcompat.widget.SearchView$q */ /* loaded from: classes.dex */ public static class C0151q extends TouchDelegate { /* renamed from: a */ public final View f567a; /* renamed from: b */ public final Rect f568b; /* renamed from: c */ public final Rect f569c; /* renamed from: d */ public final Rect f570d; /* renamed from: e */ public final int f571e; /* renamed from: f */ public boolean f572f; public C0151q(Rect rect, Rect rect2, View view) { super(rect, view); this.f571e = ViewConfiguration.get(view.getContext()).getScaledTouchSlop(); this.f568b = new Rect(); this.f570d = new Rect(); this.f569c = new Rect(); m4713a(rect, rect2); this.f567a = view; } /* renamed from: a */ public void m4713a(Rect rect, Rect rect2) { this.f568b.set(rect); this.f570d.set(rect); Rect rect3 = this.f570d; int i = this.f571e; rect3.inset(-i, -i); this.f569c.set(rect2); } @Override // android.view.TouchDelegate public boolean onTouchEvent(MotionEvent motionEvent) { boolean z; float f; int i; boolean z2; int x = (int) motionEvent.getX(); int y = (int) motionEvent.getY(); int action = motionEvent.getAction(); boolean z3 = true; if (action != 0) { if (action == 1 || action == 2) { z2 = this.f572f; if (z2 && !this.f570d.contains(x, y)) { z3 = z2; z = false; } } else { if (action == 3) { z2 = this.f572f; this.f572f = false; } z = true; z3 = false; } z3 = z2; z = true; } else { if (this.f568b.contains(x, y)) { this.f572f = true; z = true; } z = true; z3 = false; } if (z3) { if (!z || this.f569c.contains(x, y)) { Rect rect = this.f569c; f = x - rect.left; i = y - rect.top; } else { f = this.f567a.getWidth() / 2; i = this.f567a.getHeight() / 2; } motionEvent.setLocation(f, i); return this.f567a.dispatchTouchEvent(motionEvent); } return false; } } static { f500q0 = Build.VERSION.SDK_INT < 29 ? new C0148o() : null; } public SearchView(Context context) { this(context, null); } public SearchView(Context context, AttributeSet attributeSet) { this(context, attributeSet, C0485a.searchViewStyle); } public SearchView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); this.f503C = new Rect(); this.f504D = new Rect(); this.f505E = new int[2]; this.f506F = new int[2]; this.f531h0 = new RunnableC0135b(); this.f532i0 = new RunnableC0136c(); this.f533j0 = new WeakHashMap<>(); View$OnClickListenerC0139f view$OnClickListenerC0139f = new View$OnClickListenerC0139f(); this.f534k0 = view$OnClickListenerC0139f; this.f535l0 = new View$OnKeyListenerC0140g(); C0141h c0141h = new C0141h(); this.f536m0 = c0141h; C0142i c0142i = new C0142i(); this.f537n0 = c0142i; C0143j c0143j = new C0143j(); this.f538o0 = c0143j; this.f539p0 = new C0134a(); int[] iArr = C0494j.f1829f2; C1106g3 m2160u = C1106g3.m2160u(context, attributeSet, iArr, i, 0); C0829h1.m2850M(this, context, iArr, attributeSet, m2160u.m2164q(), i, 0); LayoutInflater.from(context).inflate(m2160u.m2168m(C0494j.f1879p2, C0491g.abc_search_view), (ViewGroup) this, true); SearchAutoComplete searchAutoComplete = (SearchAutoComplete) findViewById(C0490f.search_src_text); this.f540s = searchAutoComplete; searchAutoComplete.setSearchView(this); this.f541t = findViewById(C0490f.search_edit_frame); View findViewById = findViewById(C0490f.search_plate); this.f542u = findViewById; View findViewById2 = findViewById(C0490f.submit_area); this.f543v = findViewById2; ImageView imageView = (ImageView) findViewById(C0490f.search_button); this.f544w = imageView; ImageView imageView2 = (ImageView) findViewById(C0490f.search_go_btn); this.f545x = imageView2; ImageView imageView3 = (ImageView) findViewById(C0490f.search_close_btn); this.f546y = imageView3; ImageView imageView4 = (ImageView) findViewById(C0490f.search_voice_btn); this.f547z = imageView4; ImageView imageView5 = (ImageView) findViewById(C0490f.search_mag_icon); this.f507G = imageView5; C0829h1.m2845R(findViewById, m2160u.m2175f(C0494j.f1884q2)); C0829h1.m2845R(findViewById2, m2160u.m2175f(C0494j.f1904u2)); int i2 = C0494j.f1899t2; imageView.setImageDrawable(m2160u.m2175f(i2)); imageView2.setImageDrawable(m2160u.m2175f(C0494j.f1869n2)); imageView3.setImageDrawable(m2160u.m2175f(C0494j.f1854k2)); imageView4.setImageDrawable(m2160u.m2175f(C0494j.f1914w2)); imageView5.setImageDrawable(m2160u.m2175f(i2)); this.f508H = m2160u.m2175f(C0494j.f1894s2); C1134k3.m2064a(imageView, getResources().getString(C0492h.abc_searchview_description_search)); this.f509I = m2160u.m2168m(C0494j.f1909v2, C0491g.abc_search_dropdown_item_icons_2line); this.f510J = m2160u.m2168m(C0494j.f1859l2, 0); imageView.setOnClickListener(view$OnClickListenerC0139f); imageView3.setOnClickListener(view$OnClickListenerC0139f); imageView2.setOnClickListener(view$OnClickListenerC0139f); imageView4.setOnClickListener(view$OnClickListenerC0139f); searchAutoComplete.setOnClickListener(view$OnClickListenerC0139f); searchAutoComplete.addTextChangedListener(this.f539p0); searchAutoComplete.setOnEditorActionListener(c0141h); searchAutoComplete.setOnItemClickListener(c0142i); searchAutoComplete.setOnItemSelectedListener(c0143j); searchAutoComplete.setOnKeyListener(this.f535l0); searchAutoComplete.setOnFocusChangeListener(new View$OnFocusChangeListenerC0137d()); setIconifiedByDefault(m2160u.m2180a(C0494j.f1874o2, true)); int m2176e = m2160u.m2176e(C0494j.f1839h2, -1); if (m2176e != -1) { setMaxWidth(m2176e); } this.f513M = m2160u.m2166o(C0494j.f1864m2); this.f520T = m2160u.m2166o(C0494j.f1889r2); int m2171j = m2160u.m2171j(C0494j.f1849j2, -1); if (m2171j != -1) { setImeOptions(m2171j); } int m2171j2 = m2160u.m2171j(C0494j.f1844i2, -1); if (m2171j2 != -1) { setInputType(m2171j2); } setFocusable(m2160u.m2180a(C0494j.f1834g2, true)); m2160u.m2159v(); Intent intent = new Intent("android.speech.action.WEB_SEARCH"); this.f511K = intent; intent.addFlags(268435456); intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "web_search"); Intent intent2 = new Intent("android.speech.action.RECOGNIZE_SPEECH"); this.f512L = intent2; intent2.addFlags(268435456); View findViewById3 = findViewById(searchAutoComplete.getDropDownAnchor()); this.f501A = findViewById3; if (findViewById3 != null) { findViewById3.addOnLayoutChangeListener(new View$OnLayoutChangeListenerC0138e()); } m4730g0(this.f516P); m4734c0(); } /* renamed from: I */ public static boolean m4754I(Context context) { return context.getResources().getConfiguration().orientation == 2; } private int getPreferredHeight() { return getContext().getResources().getDimensionPixelSize(C0488d.abc_search_view_preferred_height); } private int getPreferredWidth() { return getContext().getResources().getDimensionPixelSize(C0488d.abc_search_view_preferred_width); } private void setQuery(CharSequence charSequence) { this.f540s.setText(charSequence); this.f540s.setSelection(TextUtils.isEmpty(charSequence) ? 0 : charSequence.length()); } /* renamed from: A */ public final Intent m4762A(Intent intent, SearchableInfo searchableInfo) { ComponentName searchActivity = searchableInfo.getSearchActivity(); Intent intent2 = new Intent("android.intent.action.SEARCH"); intent2.setComponent(searchActivity); PendingIntent activity = PendingIntent.getActivity(getContext(), 0, intent2, 1107296256); Bundle bundle = new Bundle(); Bundle bundle2 = this.f530g0; if (bundle2 != null) { bundle.putParcelable("app_data", bundle2); } Intent intent3 = new Intent(intent); Resources resources = getResources(); String string = searchableInfo.getVoiceLanguageModeId() != 0 ? resources.getString(searchableInfo.getVoiceLanguageModeId()) : "free_form"; String string2 = searchableInfo.getVoicePromptTextId() != 0 ? resources.getString(searchableInfo.getVoicePromptTextId()) : null; String string3 = searchableInfo.getVoiceLanguageId() != 0 ? resources.getString(searchableInfo.getVoiceLanguageId()) : null; int voiceMaxResults = searchableInfo.getVoiceMaxResults() != 0 ? searchableInfo.getVoiceMaxResults() : 1; intent3.putExtra("android.speech.extra.LANGUAGE_MODEL", string); intent3.putExtra("android.speech.extra.PROMPT", string2); intent3.putExtra("android.speech.extra.LANGUAGE", string3); intent3.putExtra("android.speech.extra.MAX_RESULTS", voiceMaxResults); intent3.putExtra("calling_package", searchActivity != null ? searchActivity.flattenToShortString() : null); intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", activity); intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", bundle); return intent3; } /* renamed from: B */ public final Intent m4761B(Intent intent, SearchableInfo searchableInfo) { Intent intent2 = new Intent(intent); ComponentName searchActivity = searchableInfo.getSearchActivity(); intent2.putExtra("calling_package", searchActivity == null ? null : searchActivity.flattenToShortString()); return intent2; } /* renamed from: C */ public final void m4760C() { this.f540s.dismissDropDown(); } /* renamed from: D */ public void m4759D() { if (Build.VERSION.SDK_INT >= 29) { C0144k.m4722a(this.f540s); return; } C0148o c0148o = f500q0; c0148o.m4719b(this.f540s); c0148o.m4720a(this.f540s); } /* renamed from: E */ public final void m4758E(View view, Rect rect) { view.getLocationInWindow(this.f505E); getLocationInWindow(this.f506F); int[] iArr = this.f505E; int i = iArr[1]; int[] iArr2 = this.f506F; int i2 = i - iArr2[1]; int i3 = iArr[0] - iArr2[0]; rect.set(i3, i2, view.getWidth() + i3, view.getHeight() + i2); } /* renamed from: F */ public final CharSequence m4757F(CharSequence charSequence) { if (!this.f516P || this.f508H == null) { return charSequence; } double textSize = this.f540s.getTextSize(); Double.isNaN(textSize); int i = (int) (textSize * 1.25d); this.f508H.setBounds(0, 0, i, i); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(" "); spannableStringBuilder.setSpan(new ImageSpan(this.f508H), 1, 2, 33); spannableStringBuilder.append(charSequence); return spannableStringBuilder; } /* renamed from: G */ public final boolean m4756G() { SearchableInfo searchableInfo = this.f529f0; if (searchableInfo == null || !searchableInfo.getVoiceSearchEnabled()) { return false; } Intent intent = this.f529f0.getVoiceSearchLaunchWebSearch() ? this.f511K : this.f529f0.getVoiceSearchLaunchRecognizer() ? this.f512L : null; return (intent == null || getContext().getPackageManager().resolveActivity(intent, 65536) == null) ? false : true; } /* renamed from: H */ public boolean m4755H() { return this.f517Q; } /* renamed from: J */ public final boolean m4753J() { return (this.f519S || this.f524a0) && !m4755H(); } /* renamed from: K */ public final void m4752K(Intent intent) { if (intent == null) { return; } try { getContext().startActivity(intent); } catch (RuntimeException e) { Log.e("SearchView", "Failed launch activity: " + intent, e); } } /* renamed from: L */ public void m4751L(int i, String str, String str2) { getContext().startActivity(m4727y("android.intent.action.SEARCH", null, null, str2, i, str)); } /* renamed from: M */ public final boolean m4750M(int i, int i2, String str) { Cursor mo1389b = this.f518R.mo1389b(); if (mo1389b == null || !mo1389b.moveToPosition(i)) { return false; } m4752K(m4726z(mo1389b, i2, str)); return true; } /* renamed from: N */ public void m4749N() { if (!TextUtils.isEmpty(this.f540s.getText())) { this.f540s.setText(""); this.f540s.requestFocus(); this.f540s.setImeVisibility(true); } else if (this.f516P) { clearFocus(); m4730g0(true); } } /* renamed from: O */ public boolean m4748O(int i, int i2, String str) { m4750M(i, 0, null); this.f540s.setImeVisibility(false); m4760C(); return true; } /* renamed from: P */ public boolean m4747P(int i) { m4738Y(i); return true; } /* renamed from: Q */ public void m4746Q(CharSequence charSequence) { setQuery(charSequence); } /* renamed from: R */ public void m4745R() { m4730g0(false); this.f540s.requestFocus(); this.f540s.setImeVisibility(true); View.OnClickListener onClickListener = this.f515O; if (onClickListener != null) { onClickListener.onClick(this); } } /* renamed from: S */ public void m4744S() { Editable text = this.f540s.getText(); if (text == null || TextUtils.getTrimmedLength(text) <= 0) { return; } if (this.f529f0 != null) { m4751L(0, null, text.toString()); } this.f540s.setImeVisibility(false); m4760C(); } /* renamed from: T */ public boolean m4743T(View view, int i, KeyEvent keyEvent) { if (this.f529f0 != null && this.f518R != null && keyEvent.getAction() == 0 && keyEvent.hasNoModifiers()) { if (i == 66 || i == 84 || i == 61) { return m4748O(this.f540s.getListSelection(), 0, null); } if (i == 21 || i == 22) { this.f540s.setSelection(i == 21 ? 0 : this.f540s.length()); this.f540s.setListSelection(0); this.f540s.clearListSelection(); this.f540s.m4725b(); return true; } else if (i == 19) { this.f540s.getListSelection(); return false; } } return false; } /* renamed from: U */ public void m4742U(CharSequence charSequence) { Editable text = this.f540s.getText(); this.f526c0 = text; boolean z = !TextUtils.isEmpty(text); m4731f0(z); m4729h0(!z); m4736a0(); m4732e0(); this.f525b0 = charSequence.toString(); } /* renamed from: V */ public void m4741V() { m4730g0(m4755H()); m4739X(); if (this.f540s.hasFocus()) { m4759D(); } } /* renamed from: W */ public void m4740W() { Intent m4762A; SearchableInfo searchableInfo = this.f529f0; if (searchableInfo == null) { return; } try { if (searchableInfo.getVoiceSearchLaunchWebSearch()) { m4762A = m4761B(this.f511K, searchableInfo); } else if (!searchableInfo.getVoiceSearchLaunchRecognizer()) { return; } else { m4762A = m4762A(this.f512L, searchableInfo); } getContext().startActivity(m4762A); } catch (ActivityNotFoundException unused) { Log.w("SearchView", "Could not find voice search activity"); } } /* renamed from: X */ public final void m4739X() { post(this.f531h0); } /* renamed from: Y */ public final void m4738Y(int i) { CharSequence convertToString; Editable text = this.f540s.getText(); Cursor mo1389b = this.f518R.mo1389b(); if (mo1389b == null) { return; } if (!mo1389b.moveToPosition(i) || (convertToString = this.f518R.convertToString(mo1389b)) == null) { setQuery(text); } else { setQuery(convertToString); } } /* renamed from: Z */ public void m4737Z(CharSequence charSequence, boolean z) { this.f540s.setText(charSequence); if (charSequence != null) { SearchAutoComplete searchAutoComplete = this.f540s; searchAutoComplete.setSelection(searchAutoComplete.length()); this.f526c0 = charSequence; } if (!z || TextUtils.isEmpty(charSequence)) { return; } m4744S(); } /* renamed from: a0 */ public final void m4736a0() { boolean z = true; boolean z2 = !TextUtils.isEmpty(this.f540s.getText()); if (!z2 && (!this.f516P || this.f527d0)) { z = false; } this.f546y.setVisibility(z ? 0 : 8); Drawable drawable = this.f546y.getDrawable(); if (drawable != null) { drawable.setState(z2 ? ViewGroup.ENABLED_STATE_SET : ViewGroup.EMPTY_STATE_SET); } } /* renamed from: b0 */ public void m4735b0() { int[] iArr = this.f540s.hasFocus() ? ViewGroup.FOCUSED_STATE_SET : ViewGroup.EMPTY_STATE_SET; Drawable background = this.f542u.getBackground(); if (background != null) { background.setState(iArr); } Drawable background2 = this.f543v.getBackground(); if (background2 != null) { background2.setState(iArr); } invalidate(); } /* renamed from: c0 */ public final void m4734c0() { CharSequence queryHint = getQueryHint(); SearchAutoComplete searchAutoComplete = this.f540s; if (queryHint == null) { queryHint = ""; } searchAutoComplete.setHint(m4757F(queryHint)); } @Override // android.view.ViewGroup, android.view.View public void clearFocus() { this.f522V = true; super.clearFocus(); this.f540s.clearFocus(); this.f540s.setImeVisibility(false); this.f522V = false; } /* renamed from: d0 */ public final void m4733d0() { this.f540s.setThreshold(this.f529f0.getSuggestThreshold()); this.f540s.setImeOptions(this.f529f0.getImeOptions()); int inputType = this.f529f0.getInputType(); if ((inputType & 15) == 1) { inputType &= -65537; if (this.f529f0.getSuggestAuthority() != null) { inputType = inputType | 65536 | 524288; } } this.f540s.setInputType(inputType); AbstractC1415a abstractC1415a = this.f518R; if (abstractC1415a != null) { abstractC1415a.mo1390a(null); } if (this.f529f0.getSuggestAuthority() != null) { View$OnClickListenerC1066a3 view$OnClickListenerC1066a3 = new View$OnClickListenerC1066a3(getContext(), this, this.f529f0, this.f533j0); this.f518R = view$OnClickListenerC1066a3; this.f540s.setAdapter(view$OnClickListenerC1066a3); ((View$OnClickListenerC1066a3) this.f518R).m2272w(this.f521U ? 2 : 1); } } /* renamed from: e0 */ public final void m4732e0() { this.f543v.setVisibility((m4753J() && (this.f545x.getVisibility() == 0 || this.f547z.getVisibility() == 0)) ? 0 : 8); } /* renamed from: f0 */ public final void m4731f0(boolean z) { this.f545x.setVisibility((this.f519S && m4753J() && hasFocus() && (z || !this.f524a0)) ? 0 : 8); } /* renamed from: g0 */ public final void m4730g0(boolean z) { this.f517Q = z; int i = 0; int i2 = z ? 0 : 8; boolean z2 = !TextUtils.isEmpty(this.f540s.getText()); this.f544w.setVisibility(i2); m4731f0(z2); this.f541t.setVisibility(z ? 8 : 0); this.f507G.setVisibility((this.f507G.getDrawable() == null || this.f516P) ? 8 : 8); m4736a0(); m4729h0(!z2); m4732e0(); } public int getImeOptions() { return this.f540s.getImeOptions(); } public int getInputType() { return this.f540s.getInputType(); } public int getMaxWidth() { return this.f523W; } public CharSequence getQuery() { return this.f540s.getText(); } public CharSequence getQueryHint() { CharSequence charSequence = this.f520T; if (charSequence != null) { return charSequence; } SearchableInfo searchableInfo = this.f529f0; return (searchableInfo == null || searchableInfo.getHintId() == 0) ? this.f513M : getContext().getText(this.f529f0.getHintId()); } public int getSuggestionCommitIconResId() { return this.f510J; } public int getSuggestionRowLayout() { return this.f509I; } public AbstractC1415a getSuggestionsAdapter() { return this.f518R; } /* renamed from: h0 */ public final void m4729h0(boolean z) { int i = 8; if (this.f524a0 && !m4755H() && z) { this.f545x.setVisibility(8); i = 0; } this.f547z.setVisibility(i); } @Override // p022h.InterfaceC0745c public void onActionViewCollapsed() { m4737Z("", false); clearFocus(); m4730g0(true); this.f540s.setImeOptions(this.f528e0); this.f527d0 = false; } @Override // p022h.InterfaceC0745c public void onActionViewExpanded() { if (this.f527d0) { return; } this.f527d0 = true; int imeOptions = this.f540s.getImeOptions(); this.f528e0 = imeOptions; this.f540s.setImeOptions(imeOptions | 33554432); this.f540s.setText(""); setIconified(false); } @Override // android.view.ViewGroup, android.view.View public void onDetachedFromWindow() { removeCallbacks(this.f531h0); post(this.f532i0); super.onDetachedFromWindow(); } @Override // androidx.appcompat.widget.C0173c, android.view.ViewGroup, android.view.View public void onLayout(boolean z, int i, int i2, int i3, int i4) { super.onLayout(z, i, i2, i3, i4); if (z) { m4758E(this.f540s, this.f503C); Rect rect = this.f504D; Rect rect2 = this.f503C; rect.set(rect2.left, 0, rect2.right, i4 - i2); C0151q c0151q = this.f502B; if (c0151q != null) { c0151q.m4713a(this.f504D, this.f503C); return; } C0151q c0151q2 = new C0151q(this.f504D, this.f503C, this.f540s); this.f502B = c0151q2; setTouchDelegate(c0151q2); } } /* JADX WARN: Code restructure failed: missing block: B:12:0x001f, code lost: if (r0 <= 0) goto L13; */ /* JADX WARN: Removed duplicated region for block: B:25:0x0043 */ /* JADX WARN: Removed duplicated region for block: B:28:0x004b */ @Override // androidx.appcompat.widget.C0173c, android.view.View /* Code decompiled incorrectly, please refer to instructions dump. */ public void onMeasure(int i, int i2) { int i3; int mode; if (m4755H()) { super.onMeasure(i, i2); return; } int mode2 = View.MeasureSpec.getMode(i); int size = View.MeasureSpec.getSize(i); if (mode2 != Integer.MIN_VALUE) { if (mode2 == 0) { size = this.f523W; if (size <= 0) { size = getPreferredWidth(); } } else if (mode2 == 1073741824) { i3 = this.f523W; } mode = View.MeasureSpec.getMode(i2); int size2 = View.MeasureSpec.getSize(i2); if (mode != Integer.MIN_VALUE) { size2 = Math.min(getPreferredHeight(), size2); } else if (mode == 0) { size2 = getPreferredHeight(); } super.onMeasure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824)); } i3 = this.f523W; if (i3 <= 0) { i3 = getPreferredWidth(); } size = Math.min(i3, size); mode = View.MeasureSpec.getMode(i2); int size22 = View.MeasureSpec.getSize(i2); if (mode != Integer.MIN_VALUE) { } super.onMeasure(View.MeasureSpec.makeMeasureSpec(size, 1073741824), View.MeasureSpec.makeMeasureSpec(size22, 1073741824)); } @Override // android.view.View public void onRestoreInstanceState(Parcelable parcelable) { if (!(parcelable instanceof C0149p)) { super.onRestoreInstanceState(parcelable); return; } C0149p c0149p = (C0149p) parcelable; super.onRestoreInstanceState(c0149p.m1308a()); m4730g0(c0149p.f566f); requestLayout(); } @Override // android.view.View public Parcelable onSaveInstanceState() { C0149p c0149p = new C0149p(super.onSaveInstanceState()); c0149p.f566f = m4755H(); return c0149p; } @Override // android.view.View public void onWindowFocusChanged(boolean z) { super.onWindowFocusChanged(z); m4739X(); } @Override // android.view.ViewGroup, android.view.View public boolean requestFocus(int i, Rect rect) { if (!this.f522V && isFocusable()) { if (m4755H()) { return super.requestFocus(i, rect); } boolean requestFocus = this.f540s.requestFocus(i, rect); if (requestFocus) { m4730g0(false); } return requestFocus; } return false; } public void setAppSearchData(Bundle bundle) { this.f530g0 = bundle; } public void setIconified(boolean z) { if (z) { m4749N(); } else { m4745R(); } } public void setIconifiedByDefault(boolean z) { if (this.f516P == z) { return; } this.f516P = z; m4730g0(z); m4734c0(); } public void setImeOptions(int i) { this.f540s.setImeOptions(i); } public void setInputType(int i) { this.f540s.setInputType(i); } public void setMaxWidth(int i) { this.f523W = i; requestLayout(); } public void setOnCloseListener(InterfaceC0145l interfaceC0145l) { } public void setOnQueryTextFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener) { this.f514N = onFocusChangeListener; } public void setOnQueryTextListener(InterfaceC0146m interfaceC0146m) { } public void setOnSearchClickListener(View.OnClickListener onClickListener) { this.f515O = onClickListener; } public void setOnSuggestionListener(InterfaceC0147n interfaceC0147n) { } public void setQueryHint(CharSequence charSequence) { this.f520T = charSequence; m4734c0(); } public void setQueryRefinementEnabled(boolean z) { this.f521U = z; AbstractC1415a abstractC1415a = this.f518R; if (abstractC1415a instanceof View$OnClickListenerC1066a3) { ((View$OnClickListenerC1066a3) abstractC1415a).m2272w(z ? 2 : 1); } } public void setSearchableInfo(SearchableInfo searchableInfo) { this.f529f0 = searchableInfo; if (searchableInfo != null) { m4733d0(); m4734c0(); } boolean m4756G = m4756G(); this.f524a0 = m4756G; if (m4756G) { this.f540s.setPrivateImeOptions("nm"); } m4730g0(m4755H()); } public void setSubmitButtonEnabled(boolean z) { this.f519S = z; m4730g0(m4755H()); } public void setSuggestionsAdapter(AbstractC1415a abstractC1415a) { this.f518R = abstractC1415a; this.f540s.setAdapter(abstractC1415a); } /* renamed from: x */ public void m4728x() { if (this.f501A.getWidth() > 1) { Resources resources = getContext().getResources(); int paddingLeft = this.f542u.getPaddingLeft(); Rect rect = new Rect(); boolean m1905b = C1187q3.m1905b(this); int dimensionPixelSize = this.f516P ? resources.getDimensionPixelSize(C0488d.abc_dropdownitem_icon_width) + resources.getDimensionPixelSize(C0488d.abc_dropdownitem_text_padding_left) : 0; this.f540s.getDropDownBackground().getPadding(rect); int i = rect.left; this.f540s.setDropDownHorizontalOffset(m1905b ? -i : paddingLeft - (i + dimensionPixelSize)); this.f540s.setDropDownWidth((((this.f501A.getWidth() + rect.left) + rect.right) + dimensionPixelSize) - paddingLeft); } } /* renamed from: y */ public final Intent m4727y(String str, Uri uri, String str2, String str3, int i, String str4) { Intent intent = new Intent(str); intent.addFlags(268435456); if (uri != null) { intent.setData(uri); } intent.putExtra("user_query", this.f526c0); if (str3 != null) { intent.putExtra("query", str3); } if (str2 != null) { intent.putExtra("intent_extra_data_key", str2); } Bundle bundle = this.f530g0; if (bundle != null) { intent.putExtra("app_data", bundle); } if (i != 0) { intent.putExtra("action_key", i); intent.putExtra("action_msg", str4); } intent.setComponent(this.f529f0.getSearchActivity()); return intent; } /* renamed from: z */ public final Intent m4726z(Cursor cursor, int i, String str) { int i2; String m2281n; try { String m2281n2 = View$OnClickListenerC1066a3.m2281n(cursor, "suggest_intent_action"); if (m2281n2 == null) { m2281n2 = this.f529f0.getSuggestIntentAction(); } if (m2281n2 == null) { m2281n2 = "android.intent.action.SEARCH"; } String str2 = m2281n2; String m2281n3 = View$OnClickListenerC1066a3.m2281n(cursor, "suggest_intent_data"); if (m2281n3 == null) { m2281n3 = this.f529f0.getSuggestIntentData(); } if (m2281n3 != null && (m2281n = View$OnClickListenerC1066a3.m2281n(cursor, "suggest_intent_data_id")) != null) { m2281n3 = m2281n3 + "/" + Uri.encode(m2281n); } return m4727y(str2, m2281n3 == null ? null : Uri.parse(m2281n3), View$OnClickListenerC1066a3.m2281n(cursor, "suggest_intent_extra_data"), View$OnClickListenerC1066a3.m2281n(cursor, "suggest_intent_query"), i, str); } catch (RuntimeException e) { try { i2 = cursor.getPosition(); } catch (RuntimeException unused) { i2 = -1; } Log.w("SearchView", "Search suggestions cursor at row " + i2 + " returned exception.", e); return null; } } }