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
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index f67f73f..1831755 100644
--- a/src/com/android/settings/SettingsActivity.java
+++ b/src/com/android/settings/SettingsActivity.java
@@ -138,6 +138,8 @@
import com.android.settings.qstile.DevelopmentTiles;
import com.android.settings.search.DynamicIndexableContentMonitor;
import com.android.settings.search.Index;
+import com.android.settings.search2.SearchFeatureProvider;
+import com.android.settings.search2.SearchFragment;
import com.android.settings.sim.SimSettings;
import com.android.settings.system.SystemDashboardFragment;
import com.android.settings.tts.TextToSpeechSettings;
@@ -479,6 +481,8 @@
private SearchResultsSummary mSearchResultsFragment;
private String mSearchQuery;
+ private SearchFeatureProvider mSearchFeatureProvider;
+
// Categories
private ArrayList<DashboardCategory> mCategories = new ArrayList<DashboardCategory>();
@@ -528,9 +532,14 @@
}
MenuInflater inflater = getMenuInflater();
+ if (mSearchFeatureProvider.isEnabled()) {
+ mSearchFeatureProvider.setUpSearchMenu(menu, this);
+ return true;
+ }
inflater.inflate(R.menu.options_menu, menu);
- // Cache the search query (can be overriden by the OnQueryTextListener)
+
+ // Cache the search query (can be overridden by the OnQueryTextListener)
final String query = mSearchQuery;
mSearchMenuItem = menu.findItem(R.id.search);
@@ -553,7 +562,6 @@
mSearchMenuItem.expandActionView();
}
mSearchView.setQuery(query, true /* submit */);
-
return true;
}
@@ -596,8 +604,12 @@
protected void onCreate(Bundle savedState) {
super.onCreate(savedState);
long startTime = System.currentTimeMillis();
- mDashboardFeatureProvider =
- FeatureFactory.getFactory(this).getDashboardFeatureProvider(this);
+
+ final FeatureFactory factory = FeatureFactory.getFactory(this);
+
+ mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
+ mSearchFeatureProvider = factory.getSearchFeatureProvider(this);
+
// Should happen before any call to getIntent()
getMetaData();
@@ -1274,19 +1286,24 @@
return super.shouldUpRecreateTask(new Intent(this, SettingsActivity.class));
}
+ @Deprecated
@Override
public boolean onQueryTextSubmit(String query) {
- switchToSearchResultsFragmentIfNeeded();
+ if (mSearchFeatureProvider.isEnabled()) {
+ return false;
+ }
mSearchQuery = query;
+ switchToSearchResultsFragmentIfNeeded();
return mSearchResultsFragment.onQueryTextSubmit(query);
}
+ @Deprecated
@Override
public boolean onQueryTextChange(String newText) {
- mSearchQuery = newText;
- if (mSearchResultsFragment == null) {
+ if (mSearchFeatureProvider.isEnabled() || mSearchResultsFragment == null) {
return false;
}
+ mSearchQuery = newText;
return mSearchResultsFragment.onQueryTextChange(newText);
}
@@ -1330,6 +1347,7 @@
}
}
+ @Deprecated
private void switchToSearchResultsFragmentIfNeeded() {
if (mSearchResultsFragment != null) {
return;
@@ -1347,10 +1365,12 @@
mSearchMenuItemExpanded = true;
}
+ @Deprecated
public void needToRevertToInitialFragment() {
mNeedToRevertToInitialFragment = true;
}
+ @Deprecated
private void revertToInitialFragment() {
mNeedToRevertToInitialFragment = false;
mSearchResultsFragment = null;