discord-jadx/app/src/main/java/androidx/appcompat/widget/SearchView.java

1465 lines
59 KiB
Java

package androidx.appcompat.widget;
import android.annotation.SuppressLint;
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 androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.appcompat.R;
import androidx.appcompat.view.CollapsibleActionView;
import androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure;
import androidx.core.view.ViewCompat;
import androidx.cursoradapter.widget.CursorAdapter;
import androidx.customview.view.AbsSavedState;
import c.d.b.a.a;
import com.discord.widgets.chat.input.autocomplete.AutocompleteViewModel;
import java.lang.reflect.Method;
import java.util.WeakHashMap;
public class SearchView extends LinearLayoutCompat implements CollapsibleActionView {
public static final boolean DBG = false;
private static final String IME_OPTION_NO_MICROPHONE = "nm";
public static final String LOG_TAG = "SearchView";
public static final PreQAutoCompleteTextViewReflector PRE_API_29_HIDDEN_METHOD_INVOKER = (Build.VERSION.SDK_INT < 29 ? new PreQAutoCompleteTextViewReflector() : null);
private Bundle mAppSearchData;
private boolean mClearingFocus;
public final ImageView mCloseButton;
private final ImageView mCollapsedIcon;
private int mCollapsedImeOptions;
private final CharSequence mDefaultQueryHint;
private final View mDropDownAnchor;
private boolean mExpandedInActionView;
public final ImageView mGoButton;
private boolean mIconified;
private boolean mIconifiedByDefault;
private int mMaxWidth;
private CharSequence mOldQueryText;
private final View.OnClickListener mOnClickListener;
private OnCloseListener mOnCloseListener;
private final TextView.OnEditorActionListener mOnEditorActionListener;
private final AdapterView.OnItemClickListener mOnItemClickListener;
private final AdapterView.OnItemSelectedListener mOnItemSelectedListener;
private OnQueryTextListener mOnQueryChangeListener;
public View.OnFocusChangeListener mOnQueryTextFocusChangeListener;
private View.OnClickListener mOnSearchClickListener;
private OnSuggestionListener mOnSuggestionListener;
private final WeakHashMap<String, Drawable.ConstantState> mOutsideDrawablesCache;
private CharSequence mQueryHint;
private boolean mQueryRefinement;
private Runnable mReleaseCursorRunnable;
public final ImageView mSearchButton;
private final View mSearchEditFrame;
private final Drawable mSearchHintIcon;
private final View mSearchPlate;
public final SearchAutoComplete mSearchSrcTextView;
private Rect mSearchSrcTextViewBounds;
private Rect mSearchSrtTextViewBoundsExpanded;
public SearchableInfo mSearchable;
private final View mSubmitArea;
private boolean mSubmitButtonEnabled;
private final int mSuggestionCommitIconResId;
private final int mSuggestionRowLayout;
public CursorAdapter mSuggestionsAdapter;
private int[] mTemp;
private int[] mTemp2;
public View.OnKeyListener mTextKeyListener;
private TextWatcher mTextWatcher;
private UpdatableTouchDelegate mTouchDelegate;
private final Runnable mUpdateDrawableStateRunnable;
private CharSequence mUserQuery;
private final Intent mVoiceAppSearchIntent;
public final ImageView mVoiceButton;
private boolean mVoiceButtonEnabled;
private final Intent mVoiceWebSearchIntent;
/* renamed from: androidx.appcompat.widget.SearchView$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public AnonymousClass1() {
}
@Override // java.lang.Runnable
public void run() {
SearchView.this.updateFocusedState();
}
}
/* renamed from: androidx.appcompat.widget.SearchView$10 reason: invalid class name */
public class AnonymousClass10 implements TextWatcher {
public AnonymousClass10() {
}
@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.onTextChanged(charSequence);
}
}
/* renamed from: androidx.appcompat.widget.SearchView$2 reason: invalid class name */
public class AnonymousClass2 implements Runnable {
public AnonymousClass2() {
}
@Override // java.lang.Runnable
public void run() {
CursorAdapter cursorAdapter = SearchView.this.mSuggestionsAdapter;
if (cursorAdapter instanceof SuggestionsAdapter) {
cursorAdapter.changeCursor(null);
}
}
}
/* renamed from: androidx.appcompat.widget.SearchView$3 reason: invalid class name */
public class AnonymousClass3 implements View.OnFocusChangeListener {
public AnonymousClass3() {
}
@Override // android.view.View.OnFocusChangeListener
public void onFocusChange(View view, boolean z2) {
SearchView searchView = SearchView.this;
View.OnFocusChangeListener onFocusChangeListener = searchView.mOnQueryTextFocusChangeListener;
if (onFocusChangeListener != null) {
onFocusChangeListener.onFocusChange(searchView, z2);
}
}
}
/* renamed from: androidx.appcompat.widget.SearchView$4 reason: invalid class name */
public class AnonymousClass4 implements View.OnLayoutChangeListener {
public AnonymousClass4() {
}
@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.adjustDropDownSizeAndPosition();
}
}
/* renamed from: androidx.appcompat.widget.SearchView$5 reason: invalid class name */
public class AnonymousClass5 implements View.OnClickListener {
public AnonymousClass5() {
}
@Override // android.view.View.OnClickListener
public void onClick(View view) {
SearchView searchView = SearchView.this;
if (view == searchView.mSearchButton) {
searchView.onSearchClicked();
} else if (view == searchView.mCloseButton) {
searchView.onCloseClicked();
} else if (view == searchView.mGoButton) {
searchView.onSubmitQuery();
} else if (view == searchView.mVoiceButton) {
searchView.onVoiceClicked();
} else if (view == searchView.mSearchSrcTextView) {
searchView.forceSuggestionQuery();
}
}
}
/* renamed from: androidx.appcompat.widget.SearchView$6 reason: invalid class name */
public class AnonymousClass6 implements View.OnKeyListener {
public AnonymousClass6() {
}
@Override // android.view.View.OnKeyListener
public boolean onKey(View view, int i, KeyEvent keyEvent) {
SearchView searchView = SearchView.this;
if (searchView.mSearchable == null) {
return false;
}
if (searchView.mSearchSrcTextView.isPopupShowing() && SearchView.this.mSearchSrcTextView.getListSelection() != -1) {
return SearchView.this.onSuggestionsKey(view, i, keyEvent);
}
if (SearchView.this.mSearchSrcTextView.isEmpty() || !keyEvent.hasNoModifiers() || keyEvent.getAction() != 1 || i != 66) {
return false;
}
view.cancelLongPress();
SearchView searchView2 = SearchView.this;
searchView2.launchQuerySearch(0, null, searchView2.mSearchSrcTextView.getText().toString());
return true;
}
}
/* renamed from: androidx.appcompat.widget.SearchView$7 reason: invalid class name */
public class AnonymousClass7 implements TextView.OnEditorActionListener {
public AnonymousClass7() {
}
@Override // android.widget.TextView.OnEditorActionListener
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
SearchView.this.onSubmitQuery();
return true;
}
}
/* renamed from: androidx.appcompat.widget.SearchView$8 reason: invalid class name */
public class AnonymousClass8 implements AdapterView.OnItemClickListener {
public AnonymousClass8() {
}
@Override // android.widget.AdapterView.OnItemClickListener
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
SearchView.this.onItemClicked(i, 0, null);
}
}
/* renamed from: androidx.appcompat.widget.SearchView$9 reason: invalid class name */
public class AnonymousClass9 implements AdapterView.OnItemSelectedListener {
public AnonymousClass9() {
}
@Override // android.widget.AdapterView.OnItemSelectedListener
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
SearchView.this.onItemSelected(i);
}
@Override // android.widget.AdapterView.OnItemSelectedListener
public void onNothingSelected(AdapterView<?> adapterView) {
}
}
public interface OnCloseListener {
boolean onClose();
}
public interface OnQueryTextListener {
boolean onQueryTextChange(String str);
boolean onQueryTextSubmit(String str);
}
public interface OnSuggestionListener {
boolean onSuggestionClick(int i);
boolean onSuggestionSelect(int i);
}
public static class PreQAutoCompleteTextViewReflector {
private Method mDoAfterTextChanged = null;
private Method mDoBeforeTextChanged = null;
private Method mEnsureImeVisible = null;
@SuppressLint({"DiscouragedPrivateApi", "SoonBlockedPrivateApi"})
public PreQAutoCompleteTextViewReflector() {
preApi29Check();
try {
Method declaredMethod = AutoCompleteTextView.class.getDeclaredMethod("doBeforeTextChanged", new Class[0]);
this.mDoBeforeTextChanged = declaredMethod;
declaredMethod.setAccessible(true);
} catch (NoSuchMethodException unused) {
}
try {
Method declaredMethod2 = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged", new Class[0]);
this.mDoAfterTextChanged = declaredMethod2;
declaredMethod2.setAccessible(true);
} catch (NoSuchMethodException unused2) {
}
try {
Method method = AutoCompleteTextView.class.getMethod("ensureImeVisible", Boolean.TYPE);
this.mEnsureImeVisible = method;
method.setAccessible(true);
} catch (NoSuchMethodException unused3) {
}
}
private static void preApi29Check() {
if (Build.VERSION.SDK_INT >= 29) {
throw new UnsupportedClassVersionError("This function can only be used for API Level < 29.");
}
}
public void doAfterTextChanged(AutoCompleteTextView autoCompleteTextView) {
preApi29Check();
Method method = this.mDoAfterTextChanged;
if (method != null) {
try {
method.invoke(autoCompleteTextView, new Object[0]);
} catch (Exception unused) {
}
}
}
public void doBeforeTextChanged(AutoCompleteTextView autoCompleteTextView) {
preApi29Check();
Method method = this.mDoBeforeTextChanged;
if (method != null) {
try {
method.invoke(autoCompleteTextView, new Object[0]);
} catch (Exception unused) {
}
}
}
public void ensureImeVisible(AutoCompleteTextView autoCompleteTextView) {
preApi29Check();
Method method = this.mEnsureImeVisible;
if (method != null) {
try {
method.invoke(autoCompleteTextView, Boolean.TRUE);
} catch (Exception unused) {
}
}
}
}
public static class SavedState extends AbsSavedState {
public static final Parcelable.Creator<SavedState> CREATOR = new AnonymousClass1();
public boolean isIconified;
/* renamed from: androidx.appcompat.widget.SearchView$SavedState$1 reason: invalid class name */
public class AnonymousClass1 implements Parcelable.ClassLoaderCreator<SavedState> {
@Override // android.os.Parcelable.Creator
public SavedState createFromParcel(Parcel parcel) {
return new SavedState(parcel, null);
}
@Override // android.os.Parcelable.ClassLoaderCreator
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
return new SavedState(parcel, classLoader);
}
@Override // android.os.Parcelable.Creator
public SavedState[] newArray(int i) {
return new SavedState[i];
}
}
public SavedState(Parcel parcel, ClassLoader classLoader) {
super(parcel, classLoader);
this.isIconified = ((Boolean) parcel.readValue(null)).booleanValue();
}
public SavedState(Parcelable parcelable) {
super(parcelable);
}
@Override // java.lang.Object
public String toString() {
StringBuilder L = a.L("SearchView.SavedState{");
L.append(Integer.toHexString(System.identityHashCode(this)));
L.append(" isIconified=");
return a.G(L, this.isIconified, "}");
}
@Override // androidx.customview.view.AbsSavedState, android.os.Parcelable
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeValue(Boolean.valueOf(this.isIconified));
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public static class SearchAutoComplete extends AppCompatAutoCompleteTextView {
private boolean mHasPendingShowSoftInputRequest;
public final Runnable mRunShowSoftInputIfNecessary;
private SearchView mSearchView;
private int mThreshold;
/* renamed from: androidx.appcompat.widget.SearchView$SearchAutoComplete$1 reason: invalid class name */
public class AnonymousClass1 implements Runnable {
public AnonymousClass1() {
}
@Override // java.lang.Runnable
public void run() {
SearchAutoComplete.this.showSoftInputIfNecessary();
}
}
public SearchAutoComplete(Context context) {
this(context, null);
}
public SearchAutoComplete(Context context, AttributeSet attributeSet) {
this(context, attributeSet, R.attr.autoCompleteTextViewStyle);
}
public SearchAutoComplete(Context context, AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mRunShowSoftInputIfNecessary = new AnonymousClass1();
this.mThreshold = getThreshold();
}
private int getSearchViewTextMinWidthDp() {
Configuration configuration = getResources().getConfiguration();
int i = configuration.screenWidthDp;
int i2 = configuration.screenHeightDp;
if (i >= 960 && i2 >= 720 && configuration.orientation == 2) {
return 256;
}
if (i < 600) {
return (i < 640 || i2 < 480) ? 160 : 192;
}
return 192;
}
@Override // android.widget.AutoCompleteTextView
public boolean enoughToFilter() {
return this.mThreshold <= 0 || super.enoughToFilter();
}
public void ensureImeVisible() {
if (Build.VERSION.SDK_INT >= 29) {
setInputMethodMode(1);
if (enoughToFilter()) {
showDropDown();
return;
}
return;
}
SearchView.PRE_API_29_HIDDEN_METHOD_INVOKER.ensureImeVisible(this);
}
public boolean isEmpty() {
return TextUtils.getTrimmedLength(getText()) == 0;
}
@Override // androidx.appcompat.widget.AppCompatAutoCompleteTextView, android.widget.TextView, android.view.View
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo);
if (this.mHasPendingShowSoftInputRequest) {
removeCallbacks(this.mRunShowSoftInputIfNecessary);
post(this.mRunShowSoftInputIfNecessary);
}
return onCreateInputConnection;
}
@Override // android.view.View
public void onFinishInflate() {
super.onFinishInflate();
setMinWidth((int) TypedValue.applyDimension(1, (float) getSearchViewTextMinWidthDp(), getResources().getDisplayMetrics()));
}
@Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View
public void onFocusChanged(boolean z2, int i, Rect rect) {
super.onFocusChanged(z2, i, rect);
this.mSearchView.onTextFocusChanged();
}
@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.mSearchView.clearFocus();
setImeVisibility(false);
return true;
}
}
}
return super.onKeyPreIme(i, keyEvent);
}
@Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View
public void onWindowFocusChanged(boolean z2) {
super.onWindowFocusChanged(z2);
if (z2 && this.mSearchView.hasFocus() && getVisibility() == 0) {
this.mHasPendingShowSoftInputRequest = true;
if (SearchView.isLandscapeMode(getContext())) {
ensureImeVisible();
}
}
}
@Override // android.widget.AutoCompleteTextView
public void performCompletion() {
}
@Override // android.widget.AutoCompleteTextView
public void replaceText(CharSequence charSequence) {
}
public void setImeVisibility(boolean z2) {
InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService("input_method");
if (!z2) {
this.mHasPendingShowSoftInputRequest = false;
removeCallbacks(this.mRunShowSoftInputIfNecessary);
inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
} else if (inputMethodManager.isActive(this)) {
this.mHasPendingShowSoftInputRequest = false;
removeCallbacks(this.mRunShowSoftInputIfNecessary);
inputMethodManager.showSoftInput(this, 0);
} else {
this.mHasPendingShowSoftInputRequest = true;
}
}
public void setSearchView(SearchView searchView) {
this.mSearchView = searchView;
}
@Override // android.widget.AutoCompleteTextView
public void setThreshold(int i) {
super.setThreshold(i);
this.mThreshold = i;
}
public void showSoftInputIfNecessary() {
if (this.mHasPendingShowSoftInputRequest) {
((InputMethodManager) getContext().getSystemService("input_method")).showSoftInput(this, 0);
this.mHasPendingShowSoftInputRequest = false;
}
}
}
public static class UpdatableTouchDelegate extends TouchDelegate {
private final Rect mActualBounds = new Rect();
private boolean mDelegateTargeted;
private final View mDelegateView;
private final int mSlop;
private final Rect mSlopBounds = new Rect();
private final Rect mTargetBounds = new Rect();
public UpdatableTouchDelegate(Rect rect, Rect rect2, View view) {
super(rect, view);
this.mSlop = ViewConfiguration.get(view.getContext()).getScaledTouchSlop();
setBounds(rect, rect2);
this.mDelegateView = view;
}
/* JADX WARNING: Removed duplicated region for block: B:19:0x0041 */
/* JADX WARNING: Removed duplicated region for block: B:26:? A[RETURN, SYNTHETIC] */
@Override // android.view.TouchDelegate
public boolean onTouchEvent(MotionEvent motionEvent) {
boolean z2;
boolean z3;
int x2 = (int) motionEvent.getX();
int y2 = (int) motionEvent.getY();
int action = motionEvent.getAction();
boolean z4 = true;
if (action != 0) {
if (action == 1 || action == 2) {
z3 = this.mDelegateTargeted;
if (z3 && !this.mSlopBounds.contains(x2, y2)) {
z4 = z3;
z2 = false;
if (z4) {
return false;
}
if (!z2 || this.mActualBounds.contains(x2, y2)) {
Rect rect = this.mActualBounds;
motionEvent.setLocation((float) (x2 - rect.left), (float) (y2 - rect.top));
} else {
motionEvent.setLocation((float) (this.mDelegateView.getWidth() / 2), (float) (this.mDelegateView.getHeight() / 2));
}
return this.mDelegateView.dispatchTouchEvent(motionEvent);
}
} else {
if (action == 3) {
z3 = this.mDelegateTargeted;
this.mDelegateTargeted = false;
}
z2 = true;
z4 = false;
if (z4) {
}
}
z4 = z3;
} else {
if (this.mTargetBounds.contains(x2, y2)) {
this.mDelegateTargeted = true;
}
z2 = true;
z4 = false;
if (z4) {
}
}
z2 = true;
if (z4) {
}
}
public void setBounds(Rect rect, Rect rect2) {
this.mTargetBounds.set(rect);
this.mSlopBounds.set(rect);
Rect rect3 = this.mSlopBounds;
int i = this.mSlop;
rect3.inset(-i, -i);
this.mActualBounds.set(rect2);
}
}
public SearchView(@NonNull Context context) {
this(context, null);
}
public SearchView(@NonNull Context context, @Nullable AttributeSet attributeSet) {
this(context, attributeSet, R.attr.searchViewStyle);
}
public SearchView(@NonNull Context context, @Nullable AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.mSearchSrcTextViewBounds = new Rect();
this.mSearchSrtTextViewBoundsExpanded = new Rect();
this.mTemp = new int[2];
this.mTemp2 = new int[2];
this.mUpdateDrawableStateRunnable = new AnonymousClass1();
this.mReleaseCursorRunnable = new AnonymousClass2();
this.mOutsideDrawablesCache = new WeakHashMap<>();
AnonymousClass5 r1 = new AnonymousClass5();
this.mOnClickListener = r1;
this.mTextKeyListener = new AnonymousClass6();
AnonymousClass7 r2 = new AnonymousClass7();
this.mOnEditorActionListener = r2;
AnonymousClass8 r3 = new AnonymousClass8();
this.mOnItemClickListener = r3;
AnonymousClass9 r4 = new AnonymousClass9();
this.mOnItemSelectedListener = r4;
this.mTextWatcher = new AnonymousClass10();
TintTypedArray obtainStyledAttributes = TintTypedArray.obtainStyledAttributes(context, attributeSet, R.styleable.SearchView, i, 0);
LayoutInflater.from(context).inflate(obtainStyledAttributes.getResourceId(R.styleable.SearchView_layout, R.layout.abc_search_view), (ViewGroup) this, true);
SearchAutoComplete searchAutoComplete = (SearchAutoComplete) findViewById(R.id.search_src_text);
this.mSearchSrcTextView = searchAutoComplete;
searchAutoComplete.setSearchView(this);
this.mSearchEditFrame = findViewById(R.id.search_edit_frame);
View findViewById = findViewById(R.id.search_plate);
this.mSearchPlate = findViewById;
View findViewById2 = findViewById(R.id.submit_area);
this.mSubmitArea = findViewById2;
ImageView imageView = (ImageView) findViewById(R.id.search_button);
this.mSearchButton = imageView;
ImageView imageView2 = (ImageView) findViewById(R.id.search_go_btn);
this.mGoButton = imageView2;
ImageView imageView3 = (ImageView) findViewById(R.id.search_close_btn);
this.mCloseButton = imageView3;
ImageView imageView4 = (ImageView) findViewById(R.id.search_voice_btn);
this.mVoiceButton = imageView4;
ImageView imageView5 = (ImageView) findViewById(R.id.search_mag_icon);
this.mCollapsedIcon = imageView5;
ViewCompat.setBackground(findViewById, obtainStyledAttributes.getDrawable(R.styleable.SearchView_queryBackground));
ViewCompat.setBackground(findViewById2, obtainStyledAttributes.getDrawable(R.styleable.SearchView_submitBackground));
int i2 = R.styleable.SearchView_searchIcon;
imageView.setImageDrawable(obtainStyledAttributes.getDrawable(i2));
imageView2.setImageDrawable(obtainStyledAttributes.getDrawable(R.styleable.SearchView_goIcon));
imageView3.setImageDrawable(obtainStyledAttributes.getDrawable(R.styleable.SearchView_closeIcon));
imageView4.setImageDrawable(obtainStyledAttributes.getDrawable(R.styleable.SearchView_voiceIcon));
imageView5.setImageDrawable(obtainStyledAttributes.getDrawable(i2));
this.mSearchHintIcon = obtainStyledAttributes.getDrawable(R.styleable.SearchView_searchHintIcon);
TooltipCompat.setTooltipText(imageView, getResources().getString(R.string.abc_searchview_description_search));
this.mSuggestionRowLayout = obtainStyledAttributes.getResourceId(R.styleable.SearchView_suggestionRowLayout, R.layout.abc_search_dropdown_item_icons_2line);
this.mSuggestionCommitIconResId = obtainStyledAttributes.getResourceId(R.styleable.SearchView_commitIcon, 0);
imageView.setOnClickListener(r1);
imageView3.setOnClickListener(r1);
imageView2.setOnClickListener(r1);
imageView4.setOnClickListener(r1);
searchAutoComplete.setOnClickListener(r1);
searchAutoComplete.addTextChangedListener(this.mTextWatcher);
searchAutoComplete.setOnEditorActionListener(r2);
searchAutoComplete.setOnItemClickListener(r3);
searchAutoComplete.setOnItemSelectedListener(r4);
searchAutoComplete.setOnKeyListener(this.mTextKeyListener);
searchAutoComplete.setOnFocusChangeListener(new AnonymousClass3());
setIconifiedByDefault(obtainStyledAttributes.getBoolean(R.styleable.SearchView_iconifiedByDefault, true));
int dimensionPixelSize = obtainStyledAttributes.getDimensionPixelSize(R.styleable.SearchView_android_maxWidth, -1);
if (dimensionPixelSize != -1) {
setMaxWidth(dimensionPixelSize);
}
this.mDefaultQueryHint = obtainStyledAttributes.getText(R.styleable.SearchView_defaultQueryHint);
this.mQueryHint = obtainStyledAttributes.getText(R.styleable.SearchView_queryHint);
int i3 = obtainStyledAttributes.getInt(R.styleable.SearchView_android_imeOptions, -1);
if (i3 != -1) {
setImeOptions(i3);
}
int i4 = obtainStyledAttributes.getInt(R.styleable.SearchView_android_inputType, -1);
if (i4 != -1) {
setInputType(i4);
}
setFocusable(obtainStyledAttributes.getBoolean(R.styleable.SearchView_android_focusable, true));
obtainStyledAttributes.recycle();
Intent intent = new Intent("android.speech.action.WEB_SEARCH");
this.mVoiceWebSearchIntent = intent;
intent.addFlags(268435456);
intent.putExtra("android.speech.extra.LANGUAGE_MODEL", "web_search");
Intent intent2 = new Intent("android.speech.action.RECOGNIZE_SPEECH");
this.mVoiceAppSearchIntent = intent2;
intent2.addFlags(268435456);
View findViewById3 = findViewById(searchAutoComplete.getDropDownAnchor());
this.mDropDownAnchor = findViewById3;
if (findViewById3 != null) {
findViewById3.addOnLayoutChangeListener(new AnonymousClass4());
}
updateViewsVisibility(this.mIconifiedByDefault);
updateQueryHint();
}
private Intent createIntent(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.mUserQuery);
if (str3 != null) {
intent.putExtra("query", str3);
}
if (str2 != null) {
intent.putExtra("intent_extra_data_key", str2);
}
Bundle bundle = this.mAppSearchData;
if (bundle != null) {
intent.putExtra("app_data", bundle);
}
if (i != 0) {
intent.putExtra("action_key", i);
intent.putExtra("action_msg", str4);
}
intent.setComponent(this.mSearchable.getSearchActivity());
return intent;
}
private Intent createIntentFromSuggestion(Cursor cursor, int i, String str) {
int i2;
String columnString;
try {
String columnString2 = SuggestionsAdapter.getColumnString(cursor, "suggest_intent_action");
if (columnString2 == null) {
columnString2 = this.mSearchable.getSuggestIntentAction();
}
if (columnString2 == null) {
columnString2 = "android.intent.action.SEARCH";
}
String columnString3 = SuggestionsAdapter.getColumnString(cursor, "suggest_intent_data");
if (columnString3 == null) {
columnString3 = this.mSearchable.getSuggestIntentData();
}
if (!(columnString3 == null || (columnString = SuggestionsAdapter.getColumnString(cursor, "suggest_intent_data_id")) == null)) {
columnString3 = columnString3 + AutocompleteViewModel.COMMAND_DISCOVER_TOKEN + Uri.encode(columnString);
}
return createIntent(columnString2, columnString3 == null ? null : Uri.parse(columnString3), SuggestionsAdapter.getColumnString(cursor, "suggest_intent_extra_data"), SuggestionsAdapter.getColumnString(cursor, "suggest_intent_query"), i, str);
} catch (RuntimeException e) {
try {
i2 = cursor.getPosition();
} catch (RuntimeException unused) {
i2 = -1;
}
Log.w(LOG_TAG, "Search suggestions cursor at row " + i2 + " returned exception.", e);
return null;
}
}
private Intent createVoiceAppSearchIntent(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, BasicMeasure.EXACTLY);
Bundle bundle = new Bundle();
Bundle bundle2 = this.mAppSearchData;
if (bundle2 != null) {
bundle.putParcelable("app_data", bundle2);
}
Intent intent3 = new Intent(intent);
int i = 1;
Resources resources = getResources();
String string = searchableInfo.getVoiceLanguageModeId() != 0 ? resources.getString(searchableInfo.getVoiceLanguageModeId()) : "free_form";
String str = null;
String string2 = searchableInfo.getVoicePromptTextId() != 0 ? resources.getString(searchableInfo.getVoicePromptTextId()) : null;
String string3 = searchableInfo.getVoiceLanguageId() != 0 ? resources.getString(searchableInfo.getVoiceLanguageId()) : null;
if (searchableInfo.getVoiceMaxResults() != 0) {
i = searchableInfo.getVoiceMaxResults();
}
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", i);
if (searchActivity != null) {
str = searchActivity.flattenToShortString();
}
intent3.putExtra("calling_package", str);
intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", activity);
intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", bundle);
return intent3;
}
private Intent createVoiceWebSearchIntent(Intent intent, SearchableInfo searchableInfo) {
Intent intent2 = new Intent(intent);
ComponentName searchActivity = searchableInfo.getSearchActivity();
intent2.putExtra("calling_package", searchActivity == null ? null : searchActivity.flattenToShortString());
return intent2;
}
private void dismissSuggestions() {
this.mSearchSrcTextView.dismissDropDown();
}
private void getChildBoundsWithinSearchView(View view, Rect rect) {
view.getLocationInWindow(this.mTemp);
getLocationInWindow(this.mTemp2);
int[] iArr = this.mTemp;
int i = iArr[1];
int[] iArr2 = this.mTemp2;
int i2 = i - iArr2[1];
int i3 = iArr[0] - iArr2[0];
rect.set(i3, i2, view.getWidth() + i3, view.getHeight() + i2);
}
private CharSequence getDecoratedHint(CharSequence charSequence) {
if (!this.mIconifiedByDefault || this.mSearchHintIcon == null) {
return charSequence;
}
int textSize = (int) (((double) this.mSearchSrcTextView.getTextSize()) * 1.25d);
this.mSearchHintIcon.setBounds(0, 0, textSize, textSize);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(" ");
spannableStringBuilder.setSpan(new ImageSpan(this.mSearchHintIcon), 1, 2, 33);
spannableStringBuilder.append(charSequence);
return spannableStringBuilder;
}
private int getPreferredHeight() {
return getContext().getResources().getDimensionPixelSize(R.dimen.abc_search_view_preferred_height);
}
private int getPreferredWidth() {
return getContext().getResources().getDimensionPixelSize(R.dimen.abc_search_view_preferred_width);
}
private boolean hasVoiceSearch() {
SearchableInfo searchableInfo = this.mSearchable;
if (searchableInfo == null || !searchableInfo.getVoiceSearchEnabled()) {
return false;
}
Intent intent = null;
if (this.mSearchable.getVoiceSearchLaunchWebSearch()) {
intent = this.mVoiceWebSearchIntent;
} else if (this.mSearchable.getVoiceSearchLaunchRecognizer()) {
intent = this.mVoiceAppSearchIntent;
}
return (intent == null || getContext().getPackageManager().resolveActivity(intent, 65536) == null) ? false : true;
}
public static boolean isLandscapeMode(Context context) {
return context.getResources().getConfiguration().orientation == 2;
}
private boolean isSubmitAreaEnabled() {
return (this.mSubmitButtonEnabled || this.mVoiceButtonEnabled) && !isIconified();
}
private void launchIntent(Intent intent) {
if (intent != null) {
try {
getContext().startActivity(intent);
} catch (RuntimeException e) {
Log.e(LOG_TAG, "Failed launch activity: " + intent, e);
}
}
}
private boolean launchSuggestion(int i, int i2, String str) {
Cursor cursor = this.mSuggestionsAdapter.getCursor();
if (cursor == null || !cursor.moveToPosition(i)) {
return false;
}
launchIntent(createIntentFromSuggestion(cursor, i2, str));
return true;
}
private void postUpdateFocusedState() {
post(this.mUpdateDrawableStateRunnable);
}
private void rewriteQueryFromSuggestion(int i) {
Editable text = this.mSearchSrcTextView.getText();
Cursor cursor = this.mSuggestionsAdapter.getCursor();
if (cursor != null) {
if (cursor.moveToPosition(i)) {
CharSequence convertToString = this.mSuggestionsAdapter.convertToString(cursor);
if (convertToString != null) {
setQuery(convertToString);
} else {
setQuery(text);
}
} else {
setQuery(text);
}
}
}
private void setQuery(CharSequence charSequence) {
this.mSearchSrcTextView.setText(charSequence);
this.mSearchSrcTextView.setSelection(TextUtils.isEmpty(charSequence) ? 0 : charSequence.length());
}
private void updateCloseButton() {
boolean z2 = true;
boolean z3 = !TextUtils.isEmpty(this.mSearchSrcTextView.getText());
int i = 0;
if (!z3 && (!this.mIconifiedByDefault || this.mExpandedInActionView)) {
z2 = false;
}
ImageView imageView = this.mCloseButton;
if (!z2) {
i = 8;
}
imageView.setVisibility(i);
Drawable drawable = this.mCloseButton.getDrawable();
if (drawable != null) {
drawable.setState(z3 ? ViewGroup.ENABLED_STATE_SET : ViewGroup.EMPTY_STATE_SET);
}
}
private void updateQueryHint() {
CharSequence queryHint = getQueryHint();
SearchAutoComplete searchAutoComplete = this.mSearchSrcTextView;
if (queryHint == null) {
queryHint = "";
}
searchAutoComplete.setHint(getDecoratedHint(queryHint));
}
private void updateSearchAutoComplete() {
this.mSearchSrcTextView.setThreshold(this.mSearchable.getSuggestThreshold());
this.mSearchSrcTextView.setImeOptions(this.mSearchable.getImeOptions());
int inputType = this.mSearchable.getInputType();
int i = 1;
if ((inputType & 15) == 1) {
inputType &= -65537;
if (this.mSearchable.getSuggestAuthority() != null) {
inputType = inputType | 65536 | 524288;
}
}
this.mSearchSrcTextView.setInputType(inputType);
CursorAdapter cursorAdapter = this.mSuggestionsAdapter;
if (cursorAdapter != null) {
cursorAdapter.changeCursor(null);
}
if (this.mSearchable.getSuggestAuthority() != null) {
SuggestionsAdapter suggestionsAdapter = new SuggestionsAdapter(getContext(), this, this.mSearchable, this.mOutsideDrawablesCache);
this.mSuggestionsAdapter = suggestionsAdapter;
this.mSearchSrcTextView.setAdapter(suggestionsAdapter);
SuggestionsAdapter suggestionsAdapter2 = (SuggestionsAdapter) this.mSuggestionsAdapter;
if (this.mQueryRefinement) {
i = 2;
}
suggestionsAdapter2.setQueryRefinement(i);
}
}
private void updateSubmitArea() {
this.mSubmitArea.setVisibility((!isSubmitAreaEnabled() || !(this.mGoButton.getVisibility() == 0 || this.mVoiceButton.getVisibility() == 0)) ? 8 : 0);
}
private void updateSubmitButton(boolean z2) {
this.mGoButton.setVisibility((!this.mSubmitButtonEnabled || !isSubmitAreaEnabled() || !hasFocus() || (!z2 && this.mVoiceButtonEnabled)) ? 8 : 0);
}
private void updateViewsVisibility(boolean z2) {
this.mIconified = z2;
int i = 0;
int i2 = z2 ? 0 : 8;
boolean z3 = !TextUtils.isEmpty(this.mSearchSrcTextView.getText());
this.mSearchButton.setVisibility(i2);
updateSubmitButton(z3);
this.mSearchEditFrame.setVisibility(z2 ? 8 : 0);
if (this.mCollapsedIcon.getDrawable() == null || this.mIconifiedByDefault) {
i = 8;
}
this.mCollapsedIcon.setVisibility(i);
updateCloseButton();
updateVoiceButton(!z3);
updateSubmitArea();
}
private void updateVoiceButton(boolean z2) {
int i = 8;
if (this.mVoiceButtonEnabled && !isIconified() && z2) {
this.mGoButton.setVisibility(8);
i = 0;
}
this.mVoiceButton.setVisibility(i);
}
public void adjustDropDownSizeAndPosition() {
if (this.mDropDownAnchor.getWidth() > 1) {
Resources resources = getContext().getResources();
int paddingLeft = this.mSearchPlate.getPaddingLeft();
Rect rect = new Rect();
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
int dimensionPixelSize = this.mIconifiedByDefault ? resources.getDimensionPixelSize(R.dimen.abc_dropdownitem_text_padding_left) + resources.getDimensionPixelSize(R.dimen.abc_dropdownitem_icon_width) : 0;
this.mSearchSrcTextView.getDropDownBackground().getPadding(rect);
this.mSearchSrcTextView.setDropDownHorizontalOffset(isLayoutRtl ? -rect.left : paddingLeft - (rect.left + dimensionPixelSize));
this.mSearchSrcTextView.setDropDownWidth((((this.mDropDownAnchor.getWidth() + rect.left) + rect.right) + dimensionPixelSize) - paddingLeft);
}
}
@Override // android.view.ViewGroup, android.view.View
public void clearFocus() {
this.mClearingFocus = true;
super.clearFocus();
this.mSearchSrcTextView.clearFocus();
this.mSearchSrcTextView.setImeVisibility(false);
this.mClearingFocus = false;
}
public void forceSuggestionQuery() {
if (Build.VERSION.SDK_INT >= 29) {
this.mSearchSrcTextView.refreshAutoCompleteResults();
return;
}
PreQAutoCompleteTextViewReflector preQAutoCompleteTextViewReflector = PRE_API_29_HIDDEN_METHOD_INVOKER;
preQAutoCompleteTextViewReflector.doBeforeTextChanged(this.mSearchSrcTextView);
preQAutoCompleteTextViewReflector.doAfterTextChanged(this.mSearchSrcTextView);
}
public int getImeOptions() {
return this.mSearchSrcTextView.getImeOptions();
}
public int getInputType() {
return this.mSearchSrcTextView.getInputType();
}
public int getMaxWidth() {
return this.mMaxWidth;
}
public CharSequence getQuery() {
return this.mSearchSrcTextView.getText();
}
@Nullable
public CharSequence getQueryHint() {
CharSequence charSequence = this.mQueryHint;
if (charSequence != null) {
return charSequence;
}
SearchableInfo searchableInfo = this.mSearchable;
return (searchableInfo == null || searchableInfo.getHintId() == 0) ? this.mDefaultQueryHint : getContext().getText(this.mSearchable.getHintId());
}
public int getSuggestionCommitIconResId() {
return this.mSuggestionCommitIconResId;
}
public int getSuggestionRowLayout() {
return this.mSuggestionRowLayout;
}
public CursorAdapter getSuggestionsAdapter() {
return this.mSuggestionsAdapter;
}
public boolean isIconfiedByDefault() {
return this.mIconifiedByDefault;
}
public boolean isIconified() {
return this.mIconified;
}
public boolean isQueryRefinementEnabled() {
return this.mQueryRefinement;
}
public boolean isSubmitButtonEnabled() {
return this.mSubmitButtonEnabled;
}
public void launchQuerySearch(int i, String str, String str2) {
getContext().startActivity(createIntent("android.intent.action.SEARCH", null, null, str2, i, str));
}
@Override // androidx.appcompat.view.CollapsibleActionView
public void onActionViewCollapsed() {
setQuery("", false);
clearFocus();
updateViewsVisibility(true);
this.mSearchSrcTextView.setImeOptions(this.mCollapsedImeOptions);
this.mExpandedInActionView = false;
}
@Override // androidx.appcompat.view.CollapsibleActionView
public void onActionViewExpanded() {
if (!this.mExpandedInActionView) {
this.mExpandedInActionView = true;
int imeOptions = this.mSearchSrcTextView.getImeOptions();
this.mCollapsedImeOptions = imeOptions;
this.mSearchSrcTextView.setImeOptions(imeOptions | 33554432);
this.mSearchSrcTextView.setText("");
setIconified(false);
}
}
public void onCloseClicked() {
if (!TextUtils.isEmpty(this.mSearchSrcTextView.getText())) {
this.mSearchSrcTextView.setText("");
this.mSearchSrcTextView.requestFocus();
this.mSearchSrcTextView.setImeVisibility(true);
} else if (this.mIconifiedByDefault) {
OnCloseListener onCloseListener = this.mOnCloseListener;
if (onCloseListener == null || !onCloseListener.onClose()) {
clearFocus();
updateViewsVisibility(true);
}
}
}
@Override // android.view.ViewGroup, android.view.View
public void onDetachedFromWindow() {
removeCallbacks(this.mUpdateDrawableStateRunnable);
post(this.mReleaseCursorRunnable);
super.onDetachedFromWindow();
}
public boolean onItemClicked(int i, int i2, String str) {
OnSuggestionListener onSuggestionListener = this.mOnSuggestionListener;
if (onSuggestionListener != null && onSuggestionListener.onSuggestionClick(i)) {
return false;
}
launchSuggestion(i, 0, null);
this.mSearchSrcTextView.setImeVisibility(false);
dismissSuggestions();
return true;
}
public boolean onItemSelected(int i) {
OnSuggestionListener onSuggestionListener = this.mOnSuggestionListener;
if (onSuggestionListener != null && onSuggestionListener.onSuggestionSelect(i)) {
return false;
}
rewriteQueryFromSuggestion(i);
return true;
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View
public void onLayout(boolean z2, int i, int i2, int i3, int i4) {
super.onLayout(z2, i, i2, i3, i4);
if (z2) {
getChildBoundsWithinSearchView(this.mSearchSrcTextView, this.mSearchSrcTextViewBounds);
Rect rect = this.mSearchSrtTextViewBoundsExpanded;
Rect rect2 = this.mSearchSrcTextViewBounds;
rect.set(rect2.left, 0, rect2.right, i4 - i2);
UpdatableTouchDelegate updatableTouchDelegate = this.mTouchDelegate;
if (updatableTouchDelegate == null) {
UpdatableTouchDelegate updatableTouchDelegate2 = new UpdatableTouchDelegate(this.mSearchSrtTextViewBoundsExpanded, this.mSearchSrcTextViewBounds, this.mSearchSrcTextView);
this.mTouchDelegate = updatableTouchDelegate2;
setTouchDelegate(updatableTouchDelegate2);
return;
}
updatableTouchDelegate.setBounds(this.mSearchSrtTextViewBoundsExpanded, this.mSearchSrcTextViewBounds);
}
}
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.View
public void onMeasure(int i, int i2) {
int i3;
if (isIconified()) {
super.onMeasure(i, i2);
return;
}
int mode = View.MeasureSpec.getMode(i);
int size = View.MeasureSpec.getSize(i);
if (mode == Integer.MIN_VALUE) {
int i4 = this.mMaxWidth;
size = i4 > 0 ? Math.min(i4, size) : Math.min(getPreferredWidth(), size);
} else if (mode == 0) {
size = this.mMaxWidth;
if (size <= 0) {
size = getPreferredWidth();
}
} else if (mode == 1073741824 && (i3 = this.mMaxWidth) > 0) {
size = Math.min(i3, size);
}
int mode2 = View.MeasureSpec.getMode(i2);
int size2 = View.MeasureSpec.getSize(i2);
if (mode2 == Integer.MIN_VALUE) {
size2 = Math.min(getPreferredHeight(), size2);
} else if (mode2 == 0) {
size2 = getPreferredHeight();
}
super.onMeasure(View.MeasureSpec.makeMeasureSpec(size, BasicMeasure.EXACTLY), View.MeasureSpec.makeMeasureSpec(size2, BasicMeasure.EXACTLY));
}
public void onQueryRefine(CharSequence charSequence) {
setQuery(charSequence);
}
@Override // android.view.View
public void onRestoreInstanceState(Parcelable parcelable) {
if (!(parcelable instanceof SavedState)) {
super.onRestoreInstanceState(parcelable);
return;
}
SavedState savedState = (SavedState) parcelable;
super.onRestoreInstanceState(savedState.getSuperState());
updateViewsVisibility(savedState.isIconified);
requestLayout();
}
@Override // android.view.View
public Parcelable onSaveInstanceState() {
SavedState savedState = new SavedState(super.onSaveInstanceState());
savedState.isIconified = isIconified();
return savedState;
}
public void onSearchClicked() {
updateViewsVisibility(false);
this.mSearchSrcTextView.requestFocus();
this.mSearchSrcTextView.setImeVisibility(true);
View.OnClickListener onClickListener = this.mOnSearchClickListener;
if (onClickListener != null) {
onClickListener.onClick(this);
}
}
public void onSubmitQuery() {
Editable text = this.mSearchSrcTextView.getText();
if (text != null && TextUtils.getTrimmedLength(text) > 0) {
OnQueryTextListener onQueryTextListener = this.mOnQueryChangeListener;
if (onQueryTextListener == null || !onQueryTextListener.onQueryTextSubmit(text.toString())) {
if (this.mSearchable != null) {
launchQuerySearch(0, null, text.toString());
}
this.mSearchSrcTextView.setImeVisibility(false);
dismissSuggestions();
}
}
}
public boolean onSuggestionsKey(View view, int i, KeyEvent keyEvent) {
if (this.mSearchable != null && this.mSuggestionsAdapter != null && keyEvent.getAction() == 0 && keyEvent.hasNoModifiers()) {
if (i == 66 || i == 84 || i == 61) {
return onItemClicked(this.mSearchSrcTextView.getListSelection(), 0, null);
}
if (i == 21 || i == 22) {
this.mSearchSrcTextView.setSelection(i == 21 ? 0 : this.mSearchSrcTextView.length());
this.mSearchSrcTextView.setListSelection(0);
this.mSearchSrcTextView.clearListSelection();
this.mSearchSrcTextView.ensureImeVisible();
return true;
} else if (i != 19 || this.mSearchSrcTextView.getListSelection() == 0) {
return false;
}
}
return false;
}
public void onTextChanged(CharSequence charSequence) {
Editable text = this.mSearchSrcTextView.getText();
this.mUserQuery = text;
boolean z2 = !TextUtils.isEmpty(text);
updateSubmitButton(z2);
updateVoiceButton(!z2);
updateCloseButton();
updateSubmitArea();
if (this.mOnQueryChangeListener != null && !TextUtils.equals(charSequence, this.mOldQueryText)) {
this.mOnQueryChangeListener.onQueryTextChange(charSequence.toString());
}
this.mOldQueryText = charSequence.toString();
}
public void onTextFocusChanged() {
updateViewsVisibility(isIconified());
postUpdateFocusedState();
if (this.mSearchSrcTextView.hasFocus()) {
forceSuggestionQuery();
}
}
public void onVoiceClicked() {
SearchableInfo searchableInfo = this.mSearchable;
if (searchableInfo != null) {
try {
if (searchableInfo.getVoiceSearchLaunchWebSearch()) {
getContext().startActivity(createVoiceWebSearchIntent(this.mVoiceWebSearchIntent, searchableInfo));
} else if (searchableInfo.getVoiceSearchLaunchRecognizer()) {
getContext().startActivity(createVoiceAppSearchIntent(this.mVoiceAppSearchIntent, searchableInfo));
}
} catch (ActivityNotFoundException unused) {
Log.w(LOG_TAG, "Could not find voice search activity");
}
}
}
@Override // android.view.View
public void onWindowFocusChanged(boolean z2) {
super.onWindowFocusChanged(z2);
postUpdateFocusedState();
}
@Override // android.view.ViewGroup, android.view.View
public boolean requestFocus(int i, Rect rect) {
if (this.mClearingFocus || !isFocusable()) {
return false;
}
if (isIconified()) {
return super.requestFocus(i, rect);
}
boolean requestFocus = this.mSearchSrcTextView.requestFocus(i, rect);
if (requestFocus) {
updateViewsVisibility(false);
}
return requestFocus;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
public void setAppSearchData(Bundle bundle) {
this.mAppSearchData = bundle;
}
public void setIconified(boolean z2) {
if (z2) {
onCloseClicked();
} else {
onSearchClicked();
}
}
public void setIconifiedByDefault(boolean z2) {
if (this.mIconifiedByDefault != z2) {
this.mIconifiedByDefault = z2;
updateViewsVisibility(z2);
updateQueryHint();
}
}
public void setImeOptions(int i) {
this.mSearchSrcTextView.setImeOptions(i);
}
public void setInputType(int i) {
this.mSearchSrcTextView.setInputType(i);
}
public void setMaxWidth(int i) {
this.mMaxWidth = i;
requestLayout();
}
public void setOnCloseListener(OnCloseListener onCloseListener) {
this.mOnCloseListener = onCloseListener;
}
public void setOnQueryTextFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener) {
this.mOnQueryTextFocusChangeListener = onFocusChangeListener;
}
public void setOnQueryTextListener(OnQueryTextListener onQueryTextListener) {
this.mOnQueryChangeListener = onQueryTextListener;
}
public void setOnSearchClickListener(View.OnClickListener onClickListener) {
this.mOnSearchClickListener = onClickListener;
}
public void setOnSuggestionListener(OnSuggestionListener onSuggestionListener) {
this.mOnSuggestionListener = onSuggestionListener;
}
public void setQuery(CharSequence charSequence, boolean z2) {
this.mSearchSrcTextView.setText(charSequence);
if (charSequence != null) {
SearchAutoComplete searchAutoComplete = this.mSearchSrcTextView;
searchAutoComplete.setSelection(searchAutoComplete.length());
this.mUserQuery = charSequence;
}
if (z2 && !TextUtils.isEmpty(charSequence)) {
onSubmitQuery();
}
}
public void setQueryHint(@Nullable CharSequence charSequence) {
this.mQueryHint = charSequence;
updateQueryHint();
}
public void setQueryRefinementEnabled(boolean z2) {
this.mQueryRefinement = z2;
CursorAdapter cursorAdapter = this.mSuggestionsAdapter;
if (cursorAdapter instanceof SuggestionsAdapter) {
((SuggestionsAdapter) cursorAdapter).setQueryRefinement(z2 ? 2 : 1);
}
}
public void setSearchableInfo(SearchableInfo searchableInfo) {
this.mSearchable = searchableInfo;
if (searchableInfo != null) {
updateSearchAutoComplete();
updateQueryHint();
}
boolean hasVoiceSearch = hasVoiceSearch();
this.mVoiceButtonEnabled = hasVoiceSearch;
if (hasVoiceSearch) {
this.mSearchSrcTextView.setPrivateImeOptions(IME_OPTION_NO_MICROPHONE);
}
updateViewsVisibility(isIconified());
}
public void setSubmitButtonEnabled(boolean z2) {
this.mSubmitButtonEnabled = z2;
updateViewsVisibility(isIconified());
}
public void setSuggestionsAdapter(CursorAdapter cursorAdapter) {
this.mSuggestionsAdapter = cursorAdapter;
this.mSearchSrcTextView.setAdapter(cursorAdapter);
}
public void updateFocusedState() {
int[] iArr = this.mSearchSrcTextView.hasFocus() ? ViewGroup.FOCUSED_STATE_SET : ViewGroup.EMPTY_STATE_SET;
Drawable background = this.mSearchPlate.getBackground();
if (background != null) {
background.setState(iArr);
}
Drawable background2 = this.mSubmitArea.getBackground();
if (background2 != null) {
background2.setState(iArr);
}
invalidate();
}
}