package android.support.v7.widget;

import android.app.PendingIntent;
import android.app.SearchableInfo;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import com.google.android.gms.common.util.CrashUtils.ErrorDialogData;

class SearchView$6 implements OnClickListener {
    final /* synthetic */ SearchView ary;

    SearchView$6(SearchView searchView) {
        this.ary = searchView;
    }

    public final void onClick(View view) {
        String str = null;
        if (view == this.ary.aqG) {
            this.ary.kK();
        } else if (view == this.ary.aqI) {
            this.ary.kJ();
        } else if (view == this.ary.aqH) {
            this.ary.kI();
        } else if (view == this.ary.aqJ) {
            SearchView searchView = this.ary;
            if (searchView.aro != null) {
                SearchableInfo searchableInfo = searchView.aro;
                try {
                    Intent intent;
                    String str2;
                    if (searchableInfo.getVoiceSearchLaunchWebSearch()) {
                        intent = new Intent(searchView.aqU);
                        ComponentName searchActivity = searchableInfo.getSearchActivity();
                        str2 = "calling_package";
                        if (searchActivity != null) {
                            str = searchActivity.flattenToShortString();
                        }
                        intent.putExtra(str2, str);
                        searchView.getContext().startActivity(intent);
                    } else if (searchableInfo.getVoiceSearchLaunchRecognizer()) {
                        String string;
                        Intent intent2 = searchView.aqV;
                        ComponentName searchActivity2 = searchableInfo.getSearchActivity();
                        intent = new Intent("android.intent.action.SEARCH");
                        intent.setComponent(searchActivity2);
                        PendingIntent activity = PendingIntent.getActivity(searchView.getContext(), 0, intent, ErrorDialogData.SUPPRESSED);
                        Bundle bundle = new Bundle();
                        if (searchView.arp != null) {
                            bundle.putParcelable("app_data", searchView.arp);
                        }
                        Intent intent3 = new Intent(intent2);
                        String str3 = "free_form";
                        int i = 1;
                        Resources resources = searchView.getResources();
                        if (searchableInfo.getVoiceLanguageModeId() != 0) {
                            string = resources.getString(searchableInfo.getVoiceLanguageModeId());
                        } else {
                            string = str3;
                        }
                        if (searchableInfo.getVoicePromptTextId() != 0) {
                            str2 = resources.getString(searchableInfo.getVoicePromptTextId());
                        } else {
                            str2 = null;
                        }
                        if (searchableInfo.getVoiceLanguageId() != 0) {
                            str3 = resources.getString(searchableInfo.getVoiceLanguageId());
                        } else {
                            str3 = null;
                        }
                        if (searchableInfo.getVoiceMaxResults() != 0) {
                            i = searchableInfo.getVoiceMaxResults();
                        }
                        intent3.putExtra("android.speech.extra.LANGUAGE_MODEL", string);
                        intent3.putExtra("android.speech.extra.PROMPT", str2);
                        intent3.putExtra("android.speech.extra.LANGUAGE", str3);
                        intent3.putExtra("android.speech.extra.MAX_RESULTS", i);
                        String str4 = "calling_package";
                        if (searchActivity2 != null) {
                            str = searchActivity2.flattenToShortString();
                        }
                        intent3.putExtra(str4, str);
                        intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT", activity);
                        intent3.putExtra("android.speech.extra.RESULTS_PENDINGINTENT_BUNDLE", bundle);
                        searchView.getContext().startActivity(intent3);
                    }
                } catch (ActivityNotFoundException e) {
                }
            }
        } else if (view == this.ary.aqC) {
            this.ary.kM();
        }
    }
}
