use of android.app.SearchManager in project ActionBarSherlock by JakeWharton.
the class Issue659 method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getSupportMenuInflater();
inflater.inflate(R.menu.issue659, menu);
// Get the SearchView and set the searchable configuration
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
return true;
}
use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.
the class AssistUtils method getAssistComponentForUser.
public ComponentName getAssistComponentForUser(int userId) {
final String setting = Settings.Secure.getStringForUser(mContext.getContentResolver(), Settings.Secure.ASSISTANT, userId);
if (setting != null) {
return ComponentName.unflattenFromString(setting);
}
// Fallback to keep backward compatible behavior when there is no user setting.
if (activeServiceSupportsAssistGesture()) {
return getActiveServiceComponentName();
}
Intent intent = ((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).getAssistIntent(false);
PackageManager pm = mContext.getPackageManager();
ResolveInfo info = pm.resolveActivityAsUser(intent, PackageManager.MATCH_DEFAULT_ONLY, userId);
if (info != null) {
return new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name);
}
return null;
}
use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.
the class SearchManagerTest method testSearchManagerInvocations.
/**
* The goal of this test is to confirm that we can start and then
* stop a simple search.
*/
public void testSearchManagerInvocations() throws Exception {
SearchManager searchManager = (SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE);
assertNotNull(searchManager);
// These tests should simply run to completion w/o exceptions
searchManager.startSearch(null, false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", false, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
searchManager.startSearch("test search string", true, SEARCHABLE_ACTIVITY, null, false);
searchManager.stopSearch();
}
use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.
the class PhoneWindowManager method launchAssistLongPressAction.
private void launchAssistLongPressAction() {
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
// launch the search activity
Intent intent = new Intent(Intent.ACTION_SEARCH_LONG_PRESS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
// TODO: This only stops the factory-installed search manager.
// Need to formalize an API to handle others
SearchManager searchManager = getSearchManager();
if (searchManager != null) {
searchManager.stopSearch();
}
startActivityAsUser(intent, UserHandle.CURRENT);
} catch (ActivityNotFoundException e) {
Slog.w(TAG, "No activity to handle assist long press action.", e);
}
}
use of android.app.SearchManager in project android_frameworks_base by DirtyUnicorns.
the class PhoneWindowManager method launchAssistAction.
private void launchAssistAction(String hint, int deviceId) {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_ASSIST);
if (!isUserSetupComplete()) {
// Disable opening assist window during setup
return;
}
Bundle args = null;
if (deviceId > Integer.MIN_VALUE) {
args = new Bundle();
args.putInt(Intent.EXTRA_ASSIST_INPUT_DEVICE_ID, deviceId);
}
if ((mContext.getResources().getConfiguration().uiMode & Configuration.UI_MODE_TYPE_MASK) == Configuration.UI_MODE_TYPE_TELEVISION) {
// On TV, use legacy handling until assistants are implemented in the proper way.
((SearchManager) mContext.getSystemService(Context.SEARCH_SERVICE)).launchLegacyAssist(hint, UserHandle.myUserId(), args);
} else {
if (hint != null) {
if (args == null) {
args = new Bundle();
}
args.putBoolean(hint, true);
}
StatusBarManagerInternal statusbar = getStatusBarManagerInternal();
if (statusbar != null) {
statusbar.startAssist(args);
}
}
}
Aggregations