Simplifying the startSearch call in launcher callbacks
Change-Id: I722e110903cced237f05667c4d711468d7cd3daa
This commit is contained in:
@@ -1232,7 +1232,8 @@ public class Launcher extends Activity
|
||||
return mDefaultKeySsb.toString();
|
||||
}
|
||||
|
||||
private void clearTypedText() {
|
||||
@Override
|
||||
public void clearTypedText() {
|
||||
mDefaultKeySsb.clear();
|
||||
mDefaultKeySsb.clearSpans();
|
||||
Selection.setSelection(mDefaultKeySsb, 0);
|
||||
@@ -1997,42 +1998,20 @@ public class Launcher extends Activity
|
||||
appSearchData.putString("source", "launcher-search");
|
||||
}
|
||||
|
||||
// TODO send proper bounds.
|
||||
Rect sourceBounds = null;
|
||||
|
||||
boolean clearTextImmediately = startSearch(initialQuery, selectInitialQuery,
|
||||
appSearchData, sourceBounds);
|
||||
if (clearTextImmediately) {
|
||||
clearTypedText();
|
||||
if (mLauncherCallbacks == null ||
|
||||
!mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData)) {
|
||||
// Starting search from the callbacks failed. Start the default global search.
|
||||
startGlobalSearch(initialQuery, selectInitialQuery, appSearchData, null);
|
||||
}
|
||||
|
||||
// We need to show the workspace after starting the search
|
||||
showWorkspace(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start a text search.
|
||||
*
|
||||
* @return {@code true} if the search will start immediately, so any further keypresses
|
||||
* will be handled directly by the search UI. {@code false} if {@link Launcher} should continue
|
||||
* to buffer keypresses.
|
||||
*/
|
||||
public boolean startSearch(String initialQuery,
|
||||
boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
|
||||
if (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch()) {
|
||||
return mLauncherCallbacks.startSearch(initialQuery, selectInitialQuery, appSearchData,
|
||||
sourceBounds);
|
||||
}
|
||||
|
||||
startGlobalSearch(initialQuery, selectInitialQuery,
|
||||
appSearchData, sourceBounds);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the global search activity. This code is a copied from SearchManager
|
||||
*/
|
||||
private void startGlobalSearch(String initialQuery,
|
||||
public void startGlobalSearch(String initialQuery,
|
||||
boolean selectInitialQuery, Bundle appSearchData, Rect sourceBounds) {
|
||||
final SearchManager searchManager =
|
||||
(SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||
@@ -3426,10 +3405,6 @@ public class Launcher extends Activity
|
||||
// TODO
|
||||
}
|
||||
|
||||
public boolean launcherCallbacksProvidesSearch() {
|
||||
return (mLauncherCallbacks != null && mLauncherCallbacks.providesSearch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
|
||||
final boolean result = super.dispatchPopulateAccessibilityEvent(event);
|
||||
|
||||
@@ -79,9 +79,11 @@ public interface LauncherCallbacks {
|
||||
@Deprecated
|
||||
public void onWorkspaceLockedChanged();
|
||||
|
||||
public boolean providesSearch();
|
||||
public boolean startSearch(String initialQuery, boolean selectInitialQuery,
|
||||
Bundle appSearchData, Rect sourceBounds);
|
||||
/**
|
||||
* Starts a search with {@param initialQuery}. Return false if search was not started.
|
||||
*/
|
||||
public boolean startSearch(
|
||||
String initialQuery, boolean selectInitialQuery, Bundle appSearchData);
|
||||
public boolean hasCustomContentToLeft();
|
||||
public void populateCustomContentContainer();
|
||||
public View getQsbBar();
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface LauncherExterns {
|
||||
public SharedPreferences getSharedPrefs();
|
||||
|
||||
public void setLauncherOverlay(Launcher.LauncherOverlay overlay);
|
||||
|
||||
void clearTypedText();
|
||||
}
|
||||
|
||||
@@ -138,14 +138,9 @@ public class LauncherExtension extends Launcher {
|
||||
public void onInteractionEnd() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean providesSearch() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startSearch(String initialQuery, boolean selectInitialQuery,
|
||||
Bundle appSearchData, Rect sourceBounds) {
|
||||
Bundle appSearchData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user