diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java index 343380cc766e6..1ff56656cd3a5 100644 --- a/core/java/android/app/SearchDialog.java +++ b/core/java/android/app/SearchDialog.java @@ -31,6 +31,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Configuration; import android.content.res.Resources; import android.database.Cursor; +import android.graphics.drawable.AnimationDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -103,6 +104,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS private Button mGoButton; private ImageButton mVoiceButton; private View mSearchPlate; + private AnimationDrawable mWorkingSpinner; // interaction with searchable application private SearchableInfo mSearchable; @@ -182,6 +184,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mGoButton = (Button) findViewById(com.android.internal.R.id.search_go_btn); mVoiceButton = (ImageButton) findViewById(com.android.internal.R.id.search_voice_btn); mSearchPlate = findViewById(com.android.internal.R.id.search_plate); + mWorkingSpinner = (AnimationDrawable) getContext().getResources(). + getDrawable(com.android.internal.R.drawable.search_spinner); // attach listeners mSearchAutoComplete.addTextChangedListener(mTextWatcher); @@ -239,7 +243,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS return doShow(initialQuery, selectInitialQuery, componentName, appSearchData, globalSearch); } - /** * Called in response to a press of the hard search button in * {@link #onKeyDown(int, KeyEvent)}, this method toggles between in-app @@ -395,6 +398,24 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS mPreviousComponents = null; } + /** + * Sets the search dialog to the 'working' state, which shows a working spinner in the + * right hand size of the text field. + * + * @param working true to show spinner, false to hide spinner + */ + public void setWorking(boolean working) { + if (working) { + mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds( + null, null, mWorkingSpinner, null); + mWorkingSpinner.start(); + } else { + mSearchAutoComplete.setCompoundDrawablesWithIntrinsicBounds( + null, null, null, null); + mWorkingSpinner.stop(); + } + } + /** * Closes and gets rid of the suggestions adapter. */ @@ -563,8 +584,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS // attach the suggestions adapter, if suggestions are available // The existence of a suggestions authority is the proxy for "suggestions available here" if (mSearchable.getSuggestAuthority() != null) { - mSuggestionsAdapter = new SuggestionsAdapter(getContext(), mSearchable, - mOutsideDrawablesCache); + mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, + mOutsideDrawablesCache, mGlobalSearchMode); mSearchAutoComplete.setAdapter(mSuggestionsAdapter); } } diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 6a02fc930a1c3..2fe9a8da766a4 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -25,6 +25,7 @@ import android.graphics.BitmapFactory; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; +import android.os.Bundle; import android.server.search.SearchableInfo; import android.text.Html; import android.text.TextUtils; @@ -45,12 +46,18 @@ import java.util.WeakHashMap; * @hide */ class SuggestionsAdapter extends ResourceCursorAdapter { + // The value used to query a cursor whether it is still expecting more input, + // so we can correctly display (or not display) the 'working' spinner in the search dialog. + public static final String IS_WORKING = "isWorking"; + private static final boolean DBG = false; private static final String LOG_TAG = "SuggestionsAdapter"; + private SearchDialog mSearchDialog; private SearchableInfo mSearchable; private Context mProviderContext; private WeakHashMap mOutsideDrawablesCache; + private boolean mGlobalSearchMode; // Cached column indexes, updated when the cursor changes. private int mFormatCol; @@ -61,12 +68,13 @@ class SuggestionsAdapter extends ResourceCursorAdapter { private int mIconBitmap1Col; private int mIconBitmap2Col; - public SuggestionsAdapter(Context context, SearchableInfo searchable, - WeakHashMap outsideDrawablesCache) { + public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable, + WeakHashMap outsideDrawablesCache, boolean globalSearchMode) { super(context, com.android.internal.R.layout.search_dropdown_item_icons_2line, null, // no initial cursor true); // auto-requery + mSearchDialog = searchDialog; mSearchable = searchable; // set up provider resources (gives us icons, etc.) @@ -74,6 +82,7 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mProviderContext = mSearchable.getProviderContext(mContext, activityContext); mOutsideDrawablesCache = outsideDrawablesCache; + mGlobalSearchMode = globalSearchMode; } /** @@ -118,6 +127,28 @@ class SuggestionsAdapter extends ResourceCursorAdapter { mIconBitmap1Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_1_BITMAP); mIconBitmap2Col = c.getColumnIndex(SearchManager.SUGGEST_COLUMN_ICON_2_BITMAP); } + updateWorking(); + } + + @Override + public void notifyDataSetChanged() { + super.notifyDataSetChanged(); + updateWorking(); + } + + /** + * Updates the search dialog according to the current working status of the cursor. + */ + private void updateWorking() { + if (!mGlobalSearchMode || mCursor == null) return; + + Bundle request = new Bundle(); + request.putString(SearchManager.EXTRA_DATA_KEY, IS_WORKING); + Bundle response = mCursor.respond(request); + if (response.containsKey(IS_WORKING)) { + boolean isWorking = response.getBoolean(IS_WORKING); + mSearchDialog.setWorking(isWorking); + } } /** diff --git a/core/res/res/drawable/search_spinner.xml b/core/res/res/drawable/search_spinner.xml new file mode 100644 index 0000000000000..34c163d45098d --- /dev/null +++ b/core/res/res/drawable/search_spinner.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/core/res/res/drawable/search_spinner_anim1.png b/core/res/res/drawable/search_spinner_anim1.png new file mode 100755 index 0000000000000..e55b60dc6cce8 Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim1.png differ diff --git a/core/res/res/drawable/search_spinner_anim10.png b/core/res/res/drawable/search_spinner_anim10.png new file mode 100755 index 0000000000000..9611d9733df0b Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim10.png differ diff --git a/core/res/res/drawable/search_spinner_anim11.png b/core/res/res/drawable/search_spinner_anim11.png new file mode 100755 index 0000000000000..426170458ce7c Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim11.png differ diff --git a/core/res/res/drawable/search_spinner_anim12.png b/core/res/res/drawable/search_spinner_anim12.png new file mode 100755 index 0000000000000..0602314590aaa Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim12.png differ diff --git a/core/res/res/drawable/search_spinner_anim2.png b/core/res/res/drawable/search_spinner_anim2.png new file mode 100755 index 0000000000000..05d58e00372dc Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim2.png differ diff --git a/core/res/res/drawable/search_spinner_anim3.png b/core/res/res/drawable/search_spinner_anim3.png new file mode 100755 index 0000000000000..69fa9c1e47de7 Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim3.png differ diff --git a/core/res/res/drawable/search_spinner_anim4.png b/core/res/res/drawable/search_spinner_anim4.png new file mode 100755 index 0000000000000..9201bacdc2bb1 Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim4.png differ diff --git a/core/res/res/drawable/search_spinner_anim5.png b/core/res/res/drawable/search_spinner_anim5.png new file mode 100755 index 0000000000000..f0c7101c0296b Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim5.png differ diff --git a/core/res/res/drawable/search_spinner_anim6.png b/core/res/res/drawable/search_spinner_anim6.png new file mode 100755 index 0000000000000..99d1d4e71c8be Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim6.png differ diff --git a/core/res/res/drawable/search_spinner_anim7.png b/core/res/res/drawable/search_spinner_anim7.png new file mode 100755 index 0000000000000..8ca3358e9e890 Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim7.png differ diff --git a/core/res/res/drawable/search_spinner_anim8.png b/core/res/res/drawable/search_spinner_anim8.png new file mode 100755 index 0000000000000..408d7238032a5 Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim8.png differ diff --git a/core/res/res/drawable/search_spinner_anim9.png b/core/res/res/drawable/search_spinner_anim9.png new file mode 100755 index 0000000000000..42a2c6525c52c Binary files /dev/null and b/core/res/res/drawable/search_spinner_anim9.png differ diff --git a/core/res/res/layout/search_bar.xml b/core/res/res/layout/search_bar.xml index b5124904e4279..7b7f8a67f5ff1 100644 --- a/core/res/res/layout/search_bar.xml +++ b/core/res/res/layout/search_bar.xml @@ -71,6 +71,7 @@ android:layout_weight="1.0" android:paddingLeft="8dip" android:paddingRight="6dip" + android:drawablePadding="2dip" android:singleLine="true" android:inputType="text|textAutoComplete" android:dropDownWidth="fill_parent"