1313 lines
45 KiB
Java
1313 lines
45 KiB
Java
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.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.appcompat.R$attr;
|
|
import androidx.appcompat.R$dimen;
|
|
import androidx.appcompat.R$id;
|
|
import androidx.appcompat.R$layout;
|
|
import androidx.appcompat.R$string;
|
|
import androidx.appcompat.R$styleable;
|
|
import androidx.appcompat.view.CollapsibleActionView;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.cursoradapter.widget.CursorAdapter;
|
|
import androidx.customview.view.AbsSavedState;
|
|
import com.ijm.dataencryption.de.DataDecryptTool;
|
|
import com.ubt.jimu.blockly.command.BlocklyCommandController;
|
|
import java.lang.reflect.Method;
|
|
import java.util.WeakHashMap;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class SearchView extends LinearLayoutCompat implements CollapsibleActionView {
|
|
static final AutoCompleteTextViewReflector r0 = new AutoCompleteTextViewReflector();
|
|
private Rect A;
|
|
private Rect B;
|
|
private int[] C;
|
|
private int[] D;
|
|
private final ImageView E;
|
|
private final Drawable F;
|
|
private final int G;
|
|
private final int H;
|
|
private final Intent I;
|
|
private final Intent J;
|
|
private final CharSequence K;
|
|
private OnQueryTextListener L;
|
|
private OnCloseListener M;
|
|
View.OnFocusChangeListener N;
|
|
private OnSuggestionListener O;
|
|
private View.OnClickListener P;
|
|
private boolean Q;
|
|
private boolean R;
|
|
CursorAdapter S;
|
|
private boolean T;
|
|
private CharSequence U;
|
|
private boolean V;
|
|
private boolean W;
|
|
private int a0;
|
|
private boolean b0;
|
|
private CharSequence c0;
|
|
private CharSequence d0;
|
|
private boolean e0;
|
|
private int f0;
|
|
SearchableInfo g0;
|
|
private Bundle h0;
|
|
private final Runnable i0;
|
|
private Runnable j0;
|
|
private final WeakHashMap<String, Drawable.ConstantState> k0;
|
|
private final View.OnClickListener l0;
|
|
View.OnKeyListener m0;
|
|
private final TextView.OnEditorActionListener n0;
|
|
private final AdapterView.OnItemClickListener o0;
|
|
final SearchAutoComplete p;
|
|
private final AdapterView.OnItemSelectedListener p0;
|
|
private final View q;
|
|
private TextWatcher q0;
|
|
private final View r;
|
|
private final View s;
|
|
final ImageView t;
|
|
final ImageView u;
|
|
final ImageView v;
|
|
final ImageView x;
|
|
private final View y;
|
|
private UpdatableTouchDelegate z;
|
|
|
|
public interface OnCloseListener {
|
|
boolean a();
|
|
}
|
|
|
|
public interface OnQueryTextListener {
|
|
boolean a(String str);
|
|
|
|
boolean b(String str);
|
|
}
|
|
|
|
public interface OnSuggestionListener {
|
|
boolean a(int i);
|
|
|
|
boolean b(int i);
|
|
}
|
|
|
|
static class SavedState extends AbsSavedState {
|
|
public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.ClassLoaderCreator<SavedState>() { // from class: androidx.appcompat.widget.SearchView.SavedState.1
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState[] newArray(int i) {
|
|
return new SavedState[i];
|
|
}
|
|
|
|
/* JADX WARN: Can't rename method to resolve collision */
|
|
@Override // android.os.Parcelable.ClassLoaderCreator
|
|
public SavedState createFromParcel(Parcel parcel, ClassLoader classLoader) {
|
|
return new SavedState(parcel, classLoader);
|
|
}
|
|
|
|
@Override // android.os.Parcelable.Creator
|
|
public SavedState createFromParcel(Parcel parcel) {
|
|
return new SavedState(parcel, null);
|
|
}
|
|
};
|
|
boolean isIconified;
|
|
|
|
SavedState(Parcelable parcelable) {
|
|
super(parcelable);
|
|
}
|
|
|
|
public String toString() {
|
|
return "SearchView.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " isIconified=" + 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));
|
|
}
|
|
|
|
public SavedState(Parcel parcel, ClassLoader classLoader) {
|
|
super(parcel, classLoader);
|
|
this.isIconified = ((Boolean) parcel.readValue(null)).booleanValue();
|
|
}
|
|
}
|
|
|
|
public static class SearchAutoComplete extends AppCompatAutoCompleteTextView {
|
|
private int d;
|
|
private SearchView e;
|
|
private boolean f;
|
|
final Runnable g;
|
|
|
|
public SearchAutoComplete(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private int getSearchViewTextMinWidthDp() {
|
|
Configuration configuration = getResources().getConfiguration();
|
|
int i = configuration.screenWidthDp;
|
|
int i2 = configuration.screenHeightDp;
|
|
if (i >= 960 && i2 >= 720 && configuration.orientation == 2) {
|
|
return DataDecryptTool.DECRYPT_ALL_FILE;
|
|
}
|
|
if (i < 600) {
|
|
return (i < 640 || i2 < 480) ? 160 : 192;
|
|
}
|
|
return 192;
|
|
}
|
|
|
|
boolean a() {
|
|
return TextUtils.getTrimmedLength(getText()) == 0;
|
|
}
|
|
|
|
void b() {
|
|
if (this.f) {
|
|
((InputMethodManager) getContext().getSystemService("input_method")).showSoftInput(this, 0);
|
|
this.f = false;
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.AutoCompleteTextView
|
|
public boolean enoughToFilter() {
|
|
return this.d <= 0 || super.enoughToFilter();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.AppCompatAutoCompleteTextView, android.widget.TextView, android.view.View
|
|
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
|
|
InputConnection onCreateInputConnection = super.onCreateInputConnection(editorInfo);
|
|
if (this.f) {
|
|
removeCallbacks(this.g);
|
|
post(this.g);
|
|
}
|
|
return onCreateInputConnection;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onFinishInflate() {
|
|
super.onFinishInflate();
|
|
setMinWidth((int) TypedValue.applyDimension(1, getSearchViewTextMinWidthDp(), getResources().getDisplayMetrics()));
|
|
}
|
|
|
|
@Override // android.widget.AutoCompleteTextView, android.widget.TextView, android.view.View
|
|
protected void onFocusChanged(boolean z, int i, Rect rect) {
|
|
super.onFocusChanged(z, i, rect);
|
|
this.e.j();
|
|
}
|
|
|
|
@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;
|
|
}
|
|
if (keyEvent.getAction() == 1) {
|
|
KeyEvent.DispatcherState keyDispatcherState2 = getKeyDispatcherState();
|
|
if (keyDispatcherState2 != null) {
|
|
keyDispatcherState2.handleUpEvent(keyEvent);
|
|
}
|
|
if (keyEvent.isTracking() && !keyEvent.isCanceled()) {
|
|
this.e.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.e.hasFocus() && getVisibility() == 0) {
|
|
this.f = true;
|
|
if (SearchView.a(getContext())) {
|
|
SearchView.r0.a(this, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // android.widget.AutoCompleteTextView
|
|
public void performCompletion() {
|
|
}
|
|
|
|
@Override // android.widget.AutoCompleteTextView
|
|
protected void replaceText(CharSequence charSequence) {
|
|
}
|
|
|
|
void setImeVisibility(boolean z) {
|
|
InputMethodManager inputMethodManager = (InputMethodManager) getContext().getSystemService("input_method");
|
|
if (!z) {
|
|
this.f = false;
|
|
removeCallbacks(this.g);
|
|
inputMethodManager.hideSoftInputFromWindow(getWindowToken(), 0);
|
|
} else {
|
|
if (!inputMethodManager.isActive(this)) {
|
|
this.f = true;
|
|
return;
|
|
}
|
|
this.f = false;
|
|
removeCallbacks(this.g);
|
|
inputMethodManager.showSoftInput(this, 0);
|
|
}
|
|
}
|
|
|
|
void setSearchView(SearchView searchView) {
|
|
this.e = searchView;
|
|
}
|
|
|
|
@Override // android.widget.AutoCompleteTextView
|
|
public void setThreshold(int i) {
|
|
super.setThreshold(i);
|
|
this.d = i;
|
|
}
|
|
|
|
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.g = new Runnable() { // from class: androidx.appcompat.widget.SearchView.SearchAutoComplete.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SearchAutoComplete.this.b();
|
|
}
|
|
};
|
|
this.d = getThreshold();
|
|
}
|
|
}
|
|
|
|
private static class UpdatableTouchDelegate extends TouchDelegate {
|
|
private final View a;
|
|
private final Rect b;
|
|
private final Rect c;
|
|
private final Rect d;
|
|
private final int e;
|
|
private boolean f;
|
|
|
|
public UpdatableTouchDelegate(Rect rect, Rect rect2, View view) {
|
|
super(rect, view);
|
|
this.e = ViewConfiguration.get(view.getContext()).getScaledTouchSlop();
|
|
this.b = new Rect();
|
|
this.d = new Rect();
|
|
this.c = new Rect();
|
|
a(rect, rect2);
|
|
this.a = view;
|
|
}
|
|
|
|
public void a(Rect rect, Rect rect2) {
|
|
this.b.set(rect);
|
|
this.d.set(rect);
|
|
Rect rect3 = this.d;
|
|
int i = this.e;
|
|
rect3.inset(-i, -i);
|
|
this.c.set(rect2);
|
|
}
|
|
|
|
@Override // android.view.TouchDelegate
|
|
public boolean onTouchEvent(MotionEvent motionEvent) {
|
|
boolean z;
|
|
int x = (int) motionEvent.getX();
|
|
int y = (int) motionEvent.getY();
|
|
int action = motionEvent.getAction();
|
|
boolean z2 = true;
|
|
if (action == 0) {
|
|
if (this.b.contains(x, y)) {
|
|
this.f = true;
|
|
z = true;
|
|
}
|
|
z = false;
|
|
} else if (action == 1 || action == 2) {
|
|
z = this.f;
|
|
if (z && !this.d.contains(x, y)) {
|
|
z2 = false;
|
|
}
|
|
} else {
|
|
if (action == 3) {
|
|
z = this.f;
|
|
this.f = false;
|
|
}
|
|
z = false;
|
|
}
|
|
if (!z) {
|
|
return false;
|
|
}
|
|
if (!z2 || this.c.contains(x, y)) {
|
|
Rect rect = this.c;
|
|
motionEvent.setLocation(x - rect.left, y - rect.top);
|
|
} else {
|
|
motionEvent.setLocation(this.a.getWidth() / 2, this.a.getHeight() / 2);
|
|
}
|
|
return this.a.dispatchTouchEvent(motionEvent);
|
|
}
|
|
}
|
|
|
|
public SearchView(Context context) {
|
|
this(context, null);
|
|
}
|
|
|
|
private void b(boolean z) {
|
|
this.R = z;
|
|
int i = z ? 0 : 8;
|
|
boolean z2 = !TextUtils.isEmpty(this.p.getText());
|
|
this.t.setVisibility(i);
|
|
a(z2);
|
|
this.q.setVisibility(z ? 8 : 0);
|
|
this.E.setVisibility((this.E.getDrawable() == null || this.Q) ? 8 : 0);
|
|
q();
|
|
c(!z2);
|
|
t();
|
|
}
|
|
|
|
private CharSequence c(CharSequence charSequence) {
|
|
if (!this.Q || this.F == null) {
|
|
return charSequence;
|
|
}
|
|
int textSize = (int) (this.p.getTextSize() * 1.25d);
|
|
this.F.setBounds(0, 0, textSize, textSize);
|
|
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(" ");
|
|
spannableStringBuilder.setSpan(new ImageSpan(this.F), 1, 2, 33);
|
|
spannableStringBuilder.append(charSequence);
|
|
return spannableStringBuilder;
|
|
}
|
|
|
|
private void e(int i) {
|
|
Editable text = this.p.getText();
|
|
Cursor a = this.S.a();
|
|
if (a == null) {
|
|
return;
|
|
}
|
|
if (!a.moveToPosition(i)) {
|
|
setQuery(text);
|
|
return;
|
|
}
|
|
CharSequence b = this.S.b(a);
|
|
if (b != null) {
|
|
setQuery(b);
|
|
} else {
|
|
setQuery(text);
|
|
}
|
|
}
|
|
|
|
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 void m() {
|
|
this.p.dismissDropDown();
|
|
}
|
|
|
|
private boolean n() {
|
|
SearchableInfo searchableInfo = this.g0;
|
|
if (searchableInfo == null || !searchableInfo.getVoiceSearchEnabled()) {
|
|
return false;
|
|
}
|
|
Intent intent = null;
|
|
if (this.g0.getVoiceSearchLaunchWebSearch()) {
|
|
intent = this.I;
|
|
} else if (this.g0.getVoiceSearchLaunchRecognizer()) {
|
|
intent = this.J;
|
|
}
|
|
return (intent == null || getContext().getPackageManager().resolveActivity(intent, 65536) == null) ? false : true;
|
|
}
|
|
|
|
private boolean o() {
|
|
return (this.T || this.b0) && !f();
|
|
}
|
|
|
|
private void p() {
|
|
post(this.i0);
|
|
}
|
|
|
|
private void q() {
|
|
boolean z = true;
|
|
boolean z2 = !TextUtils.isEmpty(this.p.getText());
|
|
if (!z2 && (!this.Q || this.e0)) {
|
|
z = false;
|
|
}
|
|
this.v.setVisibility(z ? 0 : 8);
|
|
Drawable drawable = this.v.getDrawable();
|
|
if (drawable != null) {
|
|
drawable.setState(z2 ? ViewGroup.ENABLED_STATE_SET : ViewGroup.EMPTY_STATE_SET);
|
|
}
|
|
}
|
|
|
|
private void r() {
|
|
CharSequence queryHint = getQueryHint();
|
|
SearchAutoComplete searchAutoComplete = this.p;
|
|
if (queryHint == null) {
|
|
queryHint = "";
|
|
}
|
|
searchAutoComplete.setHint(c(queryHint));
|
|
}
|
|
|
|
private void s() {
|
|
this.p.setThreshold(this.g0.getSuggestThreshold());
|
|
this.p.setImeOptions(this.g0.getImeOptions());
|
|
int inputType = this.g0.getInputType();
|
|
if ((inputType & 15) == 1) {
|
|
inputType &= -65537;
|
|
if (this.g0.getSuggestAuthority() != null) {
|
|
inputType = inputType | 65536 | 524288;
|
|
}
|
|
}
|
|
this.p.setInputType(inputType);
|
|
CursorAdapter cursorAdapter = this.S;
|
|
if (cursorAdapter != null) {
|
|
cursorAdapter.a((Cursor) null);
|
|
}
|
|
if (this.g0.getSuggestAuthority() != null) {
|
|
this.S = new SuggestionsAdapter(getContext(), this, this.g0, this.k0);
|
|
this.p.setAdapter(this.S);
|
|
((SuggestionsAdapter) this.S).a(this.V ? 2 : 1);
|
|
}
|
|
}
|
|
|
|
private void setQuery(CharSequence charSequence) {
|
|
this.p.setText(charSequence);
|
|
this.p.setSelection(TextUtils.isEmpty(charSequence) ? 0 : charSequence.length());
|
|
}
|
|
|
|
private void t() {
|
|
this.s.setVisibility((o() && (this.u.getVisibility() == 0 || this.x.getVisibility() == 0)) ? 0 : 8);
|
|
}
|
|
|
|
public void a(CharSequence charSequence, boolean z) {
|
|
this.p.setText(charSequence);
|
|
if (charSequence != null) {
|
|
SearchAutoComplete searchAutoComplete = this.p;
|
|
searchAutoComplete.setSelection(searchAutoComplete.length());
|
|
this.d0 = charSequence;
|
|
}
|
|
if (!z || TextUtils.isEmpty(charSequence)) {
|
|
return;
|
|
}
|
|
i();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public void clearFocus() {
|
|
this.W = true;
|
|
super.clearFocus();
|
|
this.p.clearFocus();
|
|
this.p.setImeVisibility(false);
|
|
this.W = false;
|
|
}
|
|
|
|
void d() {
|
|
if (this.y.getWidth() > 1) {
|
|
Resources resources = getContext().getResources();
|
|
int paddingLeft = this.r.getPaddingLeft();
|
|
Rect rect = new Rect();
|
|
boolean a = ViewUtils.a(this);
|
|
int dimensionPixelSize = this.Q ? resources.getDimensionPixelSize(R$dimen.abc_dropdownitem_icon_width) + resources.getDimensionPixelSize(R$dimen.abc_dropdownitem_text_padding_left) : 0;
|
|
this.p.getDropDownBackground().getPadding(rect);
|
|
this.p.setDropDownHorizontalOffset(a ? -rect.left : paddingLeft - (rect.left + dimensionPixelSize));
|
|
this.p.setDropDownWidth((((this.y.getWidth() + rect.left) + rect.right) + dimensionPixelSize) - paddingLeft);
|
|
}
|
|
}
|
|
|
|
public boolean f() {
|
|
return this.R;
|
|
}
|
|
|
|
void g() {
|
|
if (!TextUtils.isEmpty(this.p.getText())) {
|
|
this.p.setText("");
|
|
this.p.requestFocus();
|
|
this.p.setImeVisibility(true);
|
|
} else if (this.Q) {
|
|
OnCloseListener onCloseListener = this.M;
|
|
if (onCloseListener == null || !onCloseListener.a()) {
|
|
clearFocus();
|
|
b(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int getImeOptions() {
|
|
return this.p.getImeOptions();
|
|
}
|
|
|
|
public int getInputType() {
|
|
return this.p.getInputType();
|
|
}
|
|
|
|
public int getMaxWidth() {
|
|
return this.a0;
|
|
}
|
|
|
|
public CharSequence getQuery() {
|
|
return this.p.getText();
|
|
}
|
|
|
|
public CharSequence getQueryHint() {
|
|
CharSequence charSequence = this.U;
|
|
if (charSequence != null) {
|
|
return charSequence;
|
|
}
|
|
SearchableInfo searchableInfo = this.g0;
|
|
return (searchableInfo == null || searchableInfo.getHintId() == 0) ? this.K : getContext().getText(this.g0.getHintId());
|
|
}
|
|
|
|
int getSuggestionCommitIconResId() {
|
|
return this.H;
|
|
}
|
|
|
|
int getSuggestionRowLayout() {
|
|
return this.G;
|
|
}
|
|
|
|
public CursorAdapter getSuggestionsAdapter() {
|
|
return this.S;
|
|
}
|
|
|
|
void h() {
|
|
b(false);
|
|
this.p.requestFocus();
|
|
this.p.setImeVisibility(true);
|
|
View.OnClickListener onClickListener = this.P;
|
|
if (onClickListener != null) {
|
|
onClickListener.onClick(this);
|
|
}
|
|
}
|
|
|
|
void i() {
|
|
Editable text = this.p.getText();
|
|
if (text == null || TextUtils.getTrimmedLength(text) <= 0) {
|
|
return;
|
|
}
|
|
OnQueryTextListener onQueryTextListener = this.L;
|
|
if (onQueryTextListener == null || !onQueryTextListener.b(text.toString())) {
|
|
if (this.g0 != null) {
|
|
a(0, (String) null, text.toString());
|
|
}
|
|
this.p.setImeVisibility(false);
|
|
m();
|
|
}
|
|
}
|
|
|
|
void j() {
|
|
b(f());
|
|
p();
|
|
if (this.p.hasFocus()) {
|
|
e();
|
|
}
|
|
}
|
|
|
|
void k() {
|
|
SearchableInfo searchableInfo = this.g0;
|
|
if (searchableInfo == null) {
|
|
return;
|
|
}
|
|
try {
|
|
if (searchableInfo.getVoiceSearchLaunchWebSearch()) {
|
|
getContext().startActivity(b(this.I, searchableInfo));
|
|
} else if (searchableInfo.getVoiceSearchLaunchRecognizer()) {
|
|
getContext().startActivity(a(this.J, searchableInfo));
|
|
}
|
|
} catch (ActivityNotFoundException unused) {
|
|
Log.w("SearchView", "Could not find voice search activity");
|
|
}
|
|
}
|
|
|
|
void l() {
|
|
int[] iArr = this.p.hasFocus() ? ViewGroup.FOCUSED_STATE_SET : ViewGroup.EMPTY_STATE_SET;
|
|
Drawable background = this.r.getBackground();
|
|
if (background != null) {
|
|
background.setState(iArr);
|
|
}
|
|
Drawable background2 = this.s.getBackground();
|
|
if (background2 != null) {
|
|
background2.setState(iArr);
|
|
}
|
|
invalidate();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
protected void onDetachedFromWindow() {
|
|
removeCallbacks(this.i0);
|
|
post(this.j0);
|
|
super.onDetachedFromWindow();
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.ViewGroup, android.view.View
|
|
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
|
|
super.onLayout(z, i, i2, i3, i4);
|
|
if (z) {
|
|
a(this.p, this.A);
|
|
Rect rect = this.B;
|
|
Rect rect2 = this.A;
|
|
rect.set(rect2.left, 0, rect2.right, i4 - i2);
|
|
UpdatableTouchDelegate updatableTouchDelegate = this.z;
|
|
if (updatableTouchDelegate != null) {
|
|
updatableTouchDelegate.a(this.B, this.A);
|
|
} else {
|
|
this.z = new UpdatableTouchDelegate(this.B, this.A, this.p);
|
|
setTouchDelegate(this.z);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // androidx.appcompat.widget.LinearLayoutCompat, android.view.View
|
|
protected void onMeasure(int i, int i2) {
|
|
int i3;
|
|
if (f()) {
|
|
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.a0;
|
|
size = i4 > 0 ? Math.min(i4, size) : Math.min(getPreferredWidth(), size);
|
|
} else if (mode == 0) {
|
|
size = this.a0;
|
|
if (size <= 0) {
|
|
size = getPreferredWidth();
|
|
}
|
|
} else if (mode == 1073741824 && (i3 = this.a0) > 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, 1073741824), View.MeasureSpec.makeMeasureSpec(size2, 1073741824));
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected void onRestoreInstanceState(Parcelable parcelable) {
|
|
if (!(parcelable instanceof SavedState)) {
|
|
super.onRestoreInstanceState(parcelable);
|
|
return;
|
|
}
|
|
SavedState savedState = (SavedState) parcelable;
|
|
super.onRestoreInstanceState(savedState.getSuperState());
|
|
b(savedState.isIconified);
|
|
requestLayout();
|
|
}
|
|
|
|
@Override // android.view.View
|
|
protected Parcelable onSaveInstanceState() {
|
|
SavedState savedState = new SavedState(super.onSaveInstanceState());
|
|
savedState.isIconified = f();
|
|
return savedState;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onWindowFocusChanged(boolean z) {
|
|
super.onWindowFocusChanged(z);
|
|
p();
|
|
}
|
|
|
|
@Override // android.view.ViewGroup, android.view.View
|
|
public boolean requestFocus(int i, Rect rect) {
|
|
if (this.W || !isFocusable()) {
|
|
return false;
|
|
}
|
|
if (f()) {
|
|
return super.requestFocus(i, rect);
|
|
}
|
|
boolean requestFocus = this.p.requestFocus(i, rect);
|
|
if (requestFocus) {
|
|
b(false);
|
|
}
|
|
return requestFocus;
|
|
}
|
|
|
|
public void setAppSearchData(Bundle bundle) {
|
|
this.h0 = bundle;
|
|
}
|
|
|
|
public void setIconified(boolean z) {
|
|
if (z) {
|
|
g();
|
|
} else {
|
|
h();
|
|
}
|
|
}
|
|
|
|
public void setIconifiedByDefault(boolean z) {
|
|
if (this.Q == z) {
|
|
return;
|
|
}
|
|
this.Q = z;
|
|
b(z);
|
|
r();
|
|
}
|
|
|
|
public void setImeOptions(int i) {
|
|
this.p.setImeOptions(i);
|
|
}
|
|
|
|
public void setInputType(int i) {
|
|
this.p.setInputType(i);
|
|
}
|
|
|
|
public void setMaxWidth(int i) {
|
|
this.a0 = i;
|
|
requestLayout();
|
|
}
|
|
|
|
public void setOnCloseListener(OnCloseListener onCloseListener) {
|
|
this.M = onCloseListener;
|
|
}
|
|
|
|
public void setOnQueryTextFocusChangeListener(View.OnFocusChangeListener onFocusChangeListener) {
|
|
this.N = onFocusChangeListener;
|
|
}
|
|
|
|
public void setOnQueryTextListener(OnQueryTextListener onQueryTextListener) {
|
|
this.L = onQueryTextListener;
|
|
}
|
|
|
|
public void setOnSearchClickListener(View.OnClickListener onClickListener) {
|
|
this.P = onClickListener;
|
|
}
|
|
|
|
public void setOnSuggestionListener(OnSuggestionListener onSuggestionListener) {
|
|
this.O = onSuggestionListener;
|
|
}
|
|
|
|
public void setQueryHint(CharSequence charSequence) {
|
|
this.U = charSequence;
|
|
r();
|
|
}
|
|
|
|
public void setQueryRefinementEnabled(boolean z) {
|
|
this.V = z;
|
|
CursorAdapter cursorAdapter = this.S;
|
|
if (cursorAdapter instanceof SuggestionsAdapter) {
|
|
((SuggestionsAdapter) cursorAdapter).a(z ? 2 : 1);
|
|
}
|
|
}
|
|
|
|
public void setSearchableInfo(SearchableInfo searchableInfo) {
|
|
this.g0 = searchableInfo;
|
|
if (this.g0 != null) {
|
|
s();
|
|
r();
|
|
}
|
|
this.b0 = n();
|
|
if (this.b0) {
|
|
this.p.setPrivateImeOptions("nm");
|
|
}
|
|
b(f());
|
|
}
|
|
|
|
public void setSubmitButtonEnabled(boolean z) {
|
|
this.T = z;
|
|
b(f());
|
|
}
|
|
|
|
public void setSuggestionsAdapter(CursorAdapter cursorAdapter) {
|
|
this.S = cursorAdapter;
|
|
this.p.setAdapter(this.S);
|
|
}
|
|
|
|
private static class AutoCompleteTextViewReflector {
|
|
private Method a;
|
|
private Method b;
|
|
private Method c;
|
|
|
|
AutoCompleteTextViewReflector() {
|
|
try {
|
|
this.a = AutoCompleteTextView.class.getDeclaredMethod("doBeforeTextChanged", new Class[0]);
|
|
this.a.setAccessible(true);
|
|
} catch (NoSuchMethodException unused) {
|
|
}
|
|
try {
|
|
this.b = AutoCompleteTextView.class.getDeclaredMethod("doAfterTextChanged", new Class[0]);
|
|
this.b.setAccessible(true);
|
|
} catch (NoSuchMethodException unused2) {
|
|
}
|
|
try {
|
|
this.c = AutoCompleteTextView.class.getMethod("ensureImeVisible", Boolean.TYPE);
|
|
this.c.setAccessible(true);
|
|
} catch (NoSuchMethodException unused3) {
|
|
}
|
|
}
|
|
|
|
void a(AutoCompleteTextView autoCompleteTextView) {
|
|
Method method = this.b;
|
|
if (method != null) {
|
|
try {
|
|
method.invoke(autoCompleteTextView, new Object[0]);
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
void b(AutoCompleteTextView autoCompleteTextView) {
|
|
Method method = this.a;
|
|
if (method != null) {
|
|
try {
|
|
method.invoke(autoCompleteTextView, new Object[0]);
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
}
|
|
|
|
void a(AutoCompleteTextView autoCompleteTextView, boolean z) {
|
|
Method method = this.c;
|
|
if (method != null) {
|
|
try {
|
|
method.invoke(autoCompleteTextView, Boolean.valueOf(z));
|
|
} catch (Exception unused) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public SearchView(Context context, AttributeSet attributeSet) {
|
|
this(context, attributeSet, R$attr.searchViewStyle);
|
|
}
|
|
|
|
public SearchView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.A = new Rect();
|
|
this.B = new Rect();
|
|
this.C = new int[2];
|
|
this.D = new int[2];
|
|
this.i0 = new Runnable() { // from class: androidx.appcompat.widget.SearchView.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
SearchView.this.l();
|
|
}
|
|
};
|
|
this.j0 = new Runnable() { // from class: androidx.appcompat.widget.SearchView.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
CursorAdapter cursorAdapter = SearchView.this.S;
|
|
if (cursorAdapter == null || !(cursorAdapter instanceof SuggestionsAdapter)) {
|
|
return;
|
|
}
|
|
cursorAdapter.a((Cursor) null);
|
|
}
|
|
};
|
|
this.k0 = new WeakHashMap<>();
|
|
this.l0 = new View.OnClickListener() { // from class: androidx.appcompat.widget.SearchView.5
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
SearchView searchView = SearchView.this;
|
|
if (view == searchView.t) {
|
|
searchView.h();
|
|
return;
|
|
}
|
|
if (view == searchView.v) {
|
|
searchView.g();
|
|
return;
|
|
}
|
|
if (view == searchView.u) {
|
|
searchView.i();
|
|
} else if (view == searchView.x) {
|
|
searchView.k();
|
|
} else if (view == searchView.p) {
|
|
searchView.e();
|
|
}
|
|
}
|
|
};
|
|
this.m0 = new View.OnKeyListener() { // from class: androidx.appcompat.widget.SearchView.6
|
|
@Override // android.view.View.OnKeyListener
|
|
public boolean onKey(View view, int i2, KeyEvent keyEvent) {
|
|
SearchView searchView = SearchView.this;
|
|
if (searchView.g0 == null) {
|
|
return false;
|
|
}
|
|
if (searchView.p.isPopupShowing() && SearchView.this.p.getListSelection() != -1) {
|
|
return SearchView.this.a(view, i2, keyEvent);
|
|
}
|
|
if (SearchView.this.p.a() || !keyEvent.hasNoModifiers() || keyEvent.getAction() != 1 || i2 != 66) {
|
|
return false;
|
|
}
|
|
view.cancelLongPress();
|
|
SearchView searchView2 = SearchView.this;
|
|
searchView2.a(0, (String) null, searchView2.p.getText().toString());
|
|
return true;
|
|
}
|
|
};
|
|
this.n0 = new TextView.OnEditorActionListener() { // from class: androidx.appcompat.widget.SearchView.7
|
|
@Override // android.widget.TextView.OnEditorActionListener
|
|
public boolean onEditorAction(TextView textView, int i2, KeyEvent keyEvent) {
|
|
SearchView.this.i();
|
|
return true;
|
|
}
|
|
};
|
|
this.o0 = new AdapterView.OnItemClickListener() { // from class: androidx.appcompat.widget.SearchView.8
|
|
@Override // android.widget.AdapterView.OnItemClickListener
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i2, long j) {
|
|
SearchView.this.a(i2, 0, (String) null);
|
|
}
|
|
};
|
|
this.p0 = new AdapterView.OnItemSelectedListener() { // from class: androidx.appcompat.widget.SearchView.9
|
|
@Override // android.widget.AdapterView.OnItemSelectedListener
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i2, long j) {
|
|
SearchView.this.d(i2);
|
|
}
|
|
|
|
@Override // android.widget.AdapterView.OnItemSelectedListener
|
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
|
}
|
|
};
|
|
this.q0 = new TextWatcher() { // from class: androidx.appcompat.widget.SearchView.10
|
|
@Override // android.text.TextWatcher
|
|
public void afterTextChanged(Editable editable) {
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void beforeTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void onTextChanged(CharSequence charSequence, int i2, int i3, int i4) {
|
|
SearchView.this.b(charSequence);
|
|
}
|
|
};
|
|
TintTypedArray a = TintTypedArray.a(context, attributeSet, R$styleable.SearchView, i, 0);
|
|
LayoutInflater.from(context).inflate(a.g(R$styleable.SearchView_layout, R$layout.abc_search_view), (ViewGroup) this, true);
|
|
this.p = (SearchAutoComplete) findViewById(R$id.search_src_text);
|
|
this.p.setSearchView(this);
|
|
this.q = findViewById(R$id.search_edit_frame);
|
|
this.r = findViewById(R$id.search_plate);
|
|
this.s = findViewById(R$id.submit_area);
|
|
this.t = (ImageView) findViewById(R$id.search_button);
|
|
this.u = (ImageView) findViewById(R$id.search_go_btn);
|
|
this.v = (ImageView) findViewById(R$id.search_close_btn);
|
|
this.x = (ImageView) findViewById(R$id.search_voice_btn);
|
|
this.E = (ImageView) findViewById(R$id.search_mag_icon);
|
|
ViewCompat.a(this.r, a.b(R$styleable.SearchView_queryBackground));
|
|
ViewCompat.a(this.s, a.b(R$styleable.SearchView_submitBackground));
|
|
this.t.setImageDrawable(a.b(R$styleable.SearchView_searchIcon));
|
|
this.u.setImageDrawable(a.b(R$styleable.SearchView_goIcon));
|
|
this.v.setImageDrawable(a.b(R$styleable.SearchView_closeIcon));
|
|
this.x.setImageDrawable(a.b(R$styleable.SearchView_voiceIcon));
|
|
this.E.setImageDrawable(a.b(R$styleable.SearchView_searchIcon));
|
|
this.F = a.b(R$styleable.SearchView_searchHintIcon);
|
|
TooltipCompat.a(this.t, getResources().getString(R$string.abc_searchview_description_search));
|
|
this.G = a.g(R$styleable.SearchView_suggestionRowLayout, R$layout.abc_search_dropdown_item_icons_2line);
|
|
this.H = a.g(R$styleable.SearchView_commitIcon, 0);
|
|
this.t.setOnClickListener(this.l0);
|
|
this.v.setOnClickListener(this.l0);
|
|
this.u.setOnClickListener(this.l0);
|
|
this.x.setOnClickListener(this.l0);
|
|
this.p.setOnClickListener(this.l0);
|
|
this.p.addTextChangedListener(this.q0);
|
|
this.p.setOnEditorActionListener(this.n0);
|
|
this.p.setOnItemClickListener(this.o0);
|
|
this.p.setOnItemSelectedListener(this.p0);
|
|
this.p.setOnKeyListener(this.m0);
|
|
this.p.setOnFocusChangeListener(new View.OnFocusChangeListener() { // from class: androidx.appcompat.widget.SearchView.3
|
|
@Override // android.view.View.OnFocusChangeListener
|
|
public void onFocusChange(View view, boolean z) {
|
|
SearchView searchView = SearchView.this;
|
|
View.OnFocusChangeListener onFocusChangeListener = searchView.N;
|
|
if (onFocusChangeListener != null) {
|
|
onFocusChangeListener.onFocusChange(searchView, z);
|
|
}
|
|
}
|
|
});
|
|
setIconifiedByDefault(a.a(R$styleable.SearchView_iconifiedByDefault, true));
|
|
int c = a.c(R$styleable.SearchView_android_maxWidth, -1);
|
|
if (c != -1) {
|
|
setMaxWidth(c);
|
|
}
|
|
this.K = a.e(R$styleable.SearchView_defaultQueryHint);
|
|
this.U = a.e(R$styleable.SearchView_queryHint);
|
|
int d = a.d(R$styleable.SearchView_android_imeOptions, -1);
|
|
if (d != -1) {
|
|
setImeOptions(d);
|
|
}
|
|
int d2 = a.d(R$styleable.SearchView_android_inputType, -1);
|
|
if (d2 != -1) {
|
|
setInputType(d2);
|
|
}
|
|
setFocusable(a.a(R$styleable.SearchView_android_focusable, true));
|
|
a.a();
|
|
this.I = new Intent("android.speech.action.WEB_SEARCH");
|
|
this.I.addFlags(268435456);
|
|
this.I.putExtra("android.speech.extra.LANGUAGE_MODEL", "web_search");
|
|
this.J = new Intent("android.speech.action.RECOGNIZE_SPEECH");
|
|
this.J.addFlags(268435456);
|
|
this.y = findViewById(this.p.getDropDownAnchor());
|
|
View view = this.y;
|
|
if (view != null) {
|
|
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { // from class: androidx.appcompat.widget.SearchView.4
|
|
@Override // android.view.View.OnLayoutChangeListener
|
|
public void onLayoutChange(View view2, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9) {
|
|
SearchView.this.d();
|
|
}
|
|
});
|
|
}
|
|
b(this.Q);
|
|
r();
|
|
}
|
|
|
|
private void a(View view, Rect rect) {
|
|
view.getLocationInWindow(this.C);
|
|
getLocationInWindow(this.D);
|
|
int[] iArr = this.C;
|
|
int i = iArr[1];
|
|
int[] iArr2 = this.D;
|
|
int i2 = i - iArr2[1];
|
|
int i3 = iArr[0] - iArr2[0];
|
|
rect.set(i3, i2, view.getWidth() + i3, view.getHeight() + i2);
|
|
}
|
|
|
|
private void c(boolean z) {
|
|
int i;
|
|
if (this.b0 && !f() && z) {
|
|
i = 0;
|
|
this.u.setVisibility(8);
|
|
} else {
|
|
i = 8;
|
|
}
|
|
this.x.setVisibility(i);
|
|
}
|
|
|
|
void e() {
|
|
r0.b(this.p);
|
|
r0.a(this.p);
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.CollapsibleActionView
|
|
public void c() {
|
|
a("", false);
|
|
clearFocus();
|
|
b(true);
|
|
this.p.setImeOptions(this.f0);
|
|
this.e0 = false;
|
|
}
|
|
|
|
private void a(boolean z) {
|
|
this.u.setVisibility((this.T && o() && hasFocus() && (z || !this.b0)) ? 0 : 8);
|
|
}
|
|
|
|
void b(CharSequence charSequence) {
|
|
Editable text = this.p.getText();
|
|
this.d0 = text;
|
|
boolean z = !TextUtils.isEmpty(text);
|
|
a(z);
|
|
c(!z);
|
|
q();
|
|
t();
|
|
if (this.L != null && !TextUtils.equals(charSequence, this.c0)) {
|
|
this.L.a(charSequence.toString());
|
|
}
|
|
this.c0 = charSequence.toString();
|
|
}
|
|
|
|
void a(CharSequence charSequence) {
|
|
setQuery(charSequence);
|
|
}
|
|
|
|
boolean a(View view, int i, KeyEvent keyEvent) {
|
|
if (this.g0 != null && this.S != null && keyEvent.getAction() == 0 && keyEvent.hasNoModifiers()) {
|
|
if (i == 66 || i == 84 || i == 61) {
|
|
return a(this.p.getListSelection(), 0, (String) null);
|
|
}
|
|
if (i != 21 && i != 22) {
|
|
if (i != 19 || this.p.getListSelection() == 0) {
|
|
return false;
|
|
}
|
|
} else {
|
|
this.p.setSelection(i == 21 ? 0 : this.p.length());
|
|
this.p.setListSelection(0);
|
|
this.p.clearListSelection();
|
|
r0.a(this.p, true);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
boolean d(int i) {
|
|
OnSuggestionListener onSuggestionListener = this.O;
|
|
if (onSuggestionListener != null && onSuggestionListener.a(i)) {
|
|
return false;
|
|
}
|
|
e(i);
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.appcompat.view.CollapsibleActionView
|
|
public void b() {
|
|
if (this.e0) {
|
|
return;
|
|
}
|
|
this.e0 = true;
|
|
this.f0 = this.p.getImeOptions();
|
|
this.p.setImeOptions(this.f0 | 33554432);
|
|
this.p.setText("");
|
|
setIconified(false);
|
|
}
|
|
|
|
boolean a(int i, int i2, String str) {
|
|
OnSuggestionListener onSuggestionListener = this.O;
|
|
if (onSuggestionListener != null && onSuggestionListener.b(i)) {
|
|
return false;
|
|
}
|
|
b(i, 0, null);
|
|
this.p.setImeVisibility(false);
|
|
m();
|
|
return true;
|
|
}
|
|
|
|
private boolean b(int i, int i2, String str) {
|
|
Cursor a = this.S.a();
|
|
if (a == null || !a.moveToPosition(i)) {
|
|
return false;
|
|
}
|
|
a(a(a, i2, str));
|
|
return true;
|
|
}
|
|
|
|
private void a(Intent intent) {
|
|
if (intent == null) {
|
|
return;
|
|
}
|
|
try {
|
|
getContext().startActivity(intent);
|
|
} catch (RuntimeException e) {
|
|
Log.e("SearchView", "Failed launch activity: " + intent, e);
|
|
}
|
|
}
|
|
|
|
private Intent b(Intent intent, SearchableInfo searchableInfo) {
|
|
Intent intent2 = new Intent(intent);
|
|
ComponentName searchActivity = searchableInfo.getSearchActivity();
|
|
intent2.putExtra("calling_package", searchActivity == null ? null : searchActivity.flattenToShortString());
|
|
return intent2;
|
|
}
|
|
|
|
void a(int i, String str, String str2) {
|
|
getContext().startActivity(a("android.intent.action.SEARCH", (Uri) null, (String) null, str2, i, str));
|
|
}
|
|
|
|
private Intent a(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.d0);
|
|
if (str3 != null) {
|
|
intent.putExtra(BlocklyCommandController.QUERY, str3);
|
|
}
|
|
if (str2 != null) {
|
|
intent.putExtra("intent_extra_data_key", str2);
|
|
}
|
|
Bundle bundle = this.h0;
|
|
if (bundle != null) {
|
|
intent.putExtra("app_data", bundle);
|
|
}
|
|
if (i != 0) {
|
|
intent.putExtra("action_key", i);
|
|
intent.putExtra("action_msg", str4);
|
|
}
|
|
intent.setComponent(this.g0.getSearchActivity());
|
|
return intent;
|
|
}
|
|
|
|
private Intent a(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, 1073741824);
|
|
Bundle bundle = new Bundle();
|
|
Bundle bundle2 = this.h0;
|
|
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;
|
|
}
|
|
|
|
private Intent a(Cursor cursor, int i, String str) {
|
|
int i2;
|
|
String a;
|
|
try {
|
|
String a2 = SuggestionsAdapter.a(cursor, "suggest_intent_action");
|
|
if (a2 == null) {
|
|
a2 = this.g0.getSuggestIntentAction();
|
|
}
|
|
if (a2 == null) {
|
|
a2 = "android.intent.action.SEARCH";
|
|
}
|
|
String str2 = a2;
|
|
String a3 = SuggestionsAdapter.a(cursor, "suggest_intent_data");
|
|
if (a3 == null) {
|
|
a3 = this.g0.getSuggestIntentData();
|
|
}
|
|
if (a3 != null && (a = SuggestionsAdapter.a(cursor, "suggest_intent_data_id")) != null) {
|
|
a3 = a3 + "/" + Uri.encode(a);
|
|
}
|
|
return a(str2, a3 == null ? null : Uri.parse(a3), SuggestionsAdapter.a(cursor, "suggest_intent_extra_data"), SuggestionsAdapter.a(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;
|
|
}
|
|
}
|
|
|
|
static boolean a(Context context) {
|
|
return context.getResources().getConfiguration().orientation == 2;
|
|
}
|
|
}
|