Fork Search code to independantly develop and test search.
This is the start of the new search in Settings. It is a nearly complete replacement of the old search code in a more modular and flexible architecture. It is expanding the datasources that it queries, including the same Settings database, which will now include more first party apps and be extended to support inline results where the user can change settings directly from the search view. Search will also fan out to query new sources (local or remote), and is built in a way such that adding additional sources is roughly the same amount of work had they been added in the initial writing of this code. Query interpretation will now be source-dependant, allowing for future upgrades to fuzzy search where it is applicable. Change-Id: Ib0bac1fe92bf8a662d33abf9a99bb6ee2090ec8f Fixes: 32115225, 32378927 Test: make RunSettingsRoboTests
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.search2;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.SearchView;
|
||||
import android.view.Menu;
|
||||
|
||||
import android.view.MenuItem;
|
||||
import com.android.settings.R;
|
||||
|
||||
/**
|
||||
* FeatureProvider for the refactored search code.
|
||||
*/
|
||||
public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
||||
protected Context mContext;
|
||||
|
||||
|
||||
public SearchFeatureProviderImpl(Context context) {
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUpSearchMenu(Menu menu, final Activity activity) {
|
||||
if (menu == null || activity == null) {
|
||||
return;
|
||||
}
|
||||
String menuTitle = mContext.getString(R.string.search_menu);
|
||||
MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, menuTitle)
|
||||
.setIcon(R.drawable.abc_ic_search_api_material)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
Intent intent = new Intent(activity, SearchActivity.class);
|
||||
activity.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user