From 1480eb27f5321ef5fc2faeee87c7464e279a4912 Mon Sep 17 00:00:00 2001 From: Mike LeBeau Date: Wed, 20 May 2009 17:22:13 -0700 Subject: [PATCH] Add support to SuggestionsAdapter to query the 'working' status of its underlying cursor and update a spinner in the search dialog accordingly. --- core/java/android/app/SearchDialog.java | 27 +++++++++++-- core/java/android/app/SuggestionsAdapter.java | 35 ++++++++++++++++- core/res/res/drawable/search_spinner.xml | 36 ++++++++++++++++++ .../res/res/drawable/search_spinner_anim1.png | Bin 0 -> 523 bytes .../res/drawable/search_spinner_anim10.png | Bin 0 -> 529 bytes .../res/drawable/search_spinner_anim11.png | Bin 0 -> 525 bytes .../res/drawable/search_spinner_anim12.png | Bin 0 -> 527 bytes .../res/res/drawable/search_spinner_anim2.png | Bin 0 -> 525 bytes .../res/res/drawable/search_spinner_anim3.png | Bin 0 -> 522 bytes .../res/res/drawable/search_spinner_anim4.png | Bin 0 -> 519 bytes .../res/res/drawable/search_spinner_anim5.png | Bin 0 -> 521 bytes .../res/res/drawable/search_spinner_anim6.png | Bin 0 -> 509 bytes .../res/res/drawable/search_spinner_anim7.png | Bin 0 -> 517 bytes .../res/res/drawable/search_spinner_anim8.png | Bin 0 -> 533 bytes .../res/res/drawable/search_spinner_anim9.png | Bin 0 -> 534 bytes core/res/res/layout/search_bar.xml | 1 + 16 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 core/res/res/drawable/search_spinner.xml create mode 100755 core/res/res/drawable/search_spinner_anim1.png create mode 100755 core/res/res/drawable/search_spinner_anim10.png create mode 100755 core/res/res/drawable/search_spinner_anim11.png create mode 100755 core/res/res/drawable/search_spinner_anim12.png create mode 100755 core/res/res/drawable/search_spinner_anim2.png create mode 100755 core/res/res/drawable/search_spinner_anim3.png create mode 100755 core/res/res/drawable/search_spinner_anim4.png create mode 100755 core/res/res/drawable/search_spinner_anim5.png create mode 100755 core/res/res/drawable/search_spinner_anim6.png create mode 100755 core/res/res/drawable/search_spinner_anim7.png create mode 100755 core/res/res/drawable/search_spinner_anim8.png create mode 100755 core/res/res/drawable/search_spinner_anim9.png 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 0000000000000000000000000000000000000000..e55b60dc6cce81d2390bb2bfb06fcfdbd85c38bc GIT binary patch literal 523 zcmV+m0`&cfP)?Xck zX;t}Fh7H@4x*5zjakS+AVlic{DXF;Wg%g7<0rvvtWW2*sux?hN+;HtEUZlBvHBxcY z(}{;=Vn$eI+fdJmEd{Y+(J5O}aY6KuPPsk}-+=*DWzyQ4$%to<#?Mwgw N002ovPDHLkV1ffs>jMA) literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..9611d9733df0b9012a3f48561193e3fea66a0201 GIT binary patch literal 529 zcmV+s0`C2ZP)}iIF2o^ds1awNLO>bPLFkca5CjxrD|Qm|#(5h}Rt9WF8qH_NZ)awA$8MHo zj!mxX)**bX#n9Kq#U;41H~0eR3G|8mtycgRLIl(kh*ZG2oN_aX38BZ3QKqu0Szs*# zMrueV%1-Dr6j<>yKzBwhY!ty9S%9g<8gL}vFp-6l^US0i1Pma}W)b`Jsj7&%Hf8J* z^rmD4dnjK@Pgbp62TlnxV9M36sfHK!^$)UReM!??lLk44Z(K6NI@^`^SK1>bpMxL4 z9dHlM*9sZh$@l_zq1FZPv?Ab&KKUyBDn)W_B9<#<_x^$LWy%$44rL9-7WoFgmy+dr zd@1uo@!&jwajfFxPM(#_E@XC1ZZMP{K3GBh3gu2MJE#)shc7;fFbkge=yR1u&3^3m+%hah;5@&ZUNiCC2Wtg zuwh?WmpHC3PtUwhfjgkh5ys~NC-gmA5n>-ZM7Kw_2nm^!!_y#0u`qUJZ6e%JFAqpBExyw7uoW^Kzf|Nw8G+OW49`D-Tb<^q8 zg@Eh==NdPF9ibs#1t`qho47!tD7qq<#t%?^prq*`dyatI8J z&2iD#73`_bCB(!TPP@afY37d@RRBxa$DY)ZCL+6lI)&cGf*WXmkN2?0(C_BpOo2== z_X)d>aTz*d`Uy!$ru8QzBdPmCFgNlCcrufIk0%`md$!!-5(jpPVLC;*FErtMS%eMy z5`CfketA8-tZSeHw5Z|ySRz8FZ&cLRDki#v1A)Z1ZaG=EFCV*qmPD1%QgodaIKFJk z{!!LoYzl4odaFJP|KXnQ&kM;P7mTi^=*l{v%R77v7WI}$cM{lxSm`~>@e2Ei6##4~ zrI|D}S7+(z4JcWjvdXE21taM8oN`L_HT(lq{5MgVvYy9m61h(e)1S_+Q4LR%*Jc#i{#R0p?9v0ZwqNoszyPO$+y1x) R8NdJl002ovPDHLkV1h3I>8}6) literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..05d58e00372dc95f03f68f5f07e859a054b30bed GIT binary patch literal 525 zcmV+o0`mQdP){&G2Pxc`8wEhkd&+-}Jr~&91bZ4H0c$~QLDms)B|fIx zhyDzCrVhS@VA=!t&Y>@3U84(}@KXmLs#Bj3c<&030t@uQls8OV-4!R>gV^)gFjXjP z!jG`M7rbF4PijKOz9~~)7sEIhOWcs43lLS|IFe$6AlLbR9UapC#(ov`t}`7F8S_!-9aTx_*4v6-igqtVFstb{u_Q)B99z`T_k_CV+<} zHhp<}%xEUDPNs#Wnnn^gVsk(vGfoZYBY7I30gaF*!31>5z4M<#_Vbq|SkuhrL^aEa zoT!+Z2K)66#gXO!&S%v;t<=Q3$W|Gk2~OoK$5P)|xvOGJ*nqq-{SsgR3JSo$x7SEv P00000NkvXXu0mjfUsU2$ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..69fa9c1e47de76ad5db60fcdbcc87afb3ef211d4 GIT binary patch literal 522 zcmV+l0`>igP)@8p$sMEH9 ztN|y$q3mPe5;&smpv(Y^=Bph1TTnny8OipH>x?Z||2wEDvYN4X+@wtBSY;$6@O>4m zkc6DyEpUgt7q+|%d;&wRaE?k;Xp3Q|QAnSRs))NmIhhk->3J0rR+##Bg|gDKE$1D| zpy(Wx7yDwE$N4pMvAr7Uoink1-B4HAU*`BFdminHY&inFg<8jz)xoS1+fj-0rU*x0kr)qASPp& zjtNBsF+Ra}jn7OEe*n5Ki9uluH>&`&Y60)D=LUOEe8AVH$cz-R;1$+?Yz%(}duLeO z!jSd|b64Xv|OV_Jj#-cn?cB@ckxBII$ zCDhGYB;yq5nsuBQ)&$&C5?+#q=vtXC!MMD35*BGXmnzdtS8rVnOUm>`lZ@u(nzmJ{ zS#g&!NHCG}aS)h)l6b%QV64f1(}yF02LfdyQ~Njs0*eh;pkha+PLX1MO`BkPr7F*1 z>c3P1^x_ZyV!Z|XmZ7rb|A6%0^$TEq?c)(CmaqX;XZBNo0RYe@$GifFK|cTh002ov JPDHLkV1l!x+yMXp literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..f0c7101c0296b3c126590f59d88f5b5a8baff4e7 GIT binary patch literal 521 zcmV+k0`~ohP)GB)-UEq|hhXFdn1O+z5)4QMp+egv1R6f4UnJ`qq^oM_lh5a~&p$cG z&9clf$#vZ-SO8swbxXFW!dCW~b_INMNi8!_yaI)oy`Z4)e$5{DYv;VW$VuTT4t&ir&o7H0 z|AG(I#eJ|9AcpP{@(I>mmgQC~r2(7j)xO>nve)*-qcKiV3R>IPWSIh`$BFT04Da$2OlM9R|b z&azF}1v>@qfd|+PTt2miIww&MEgfEf9jLAA3RBfIT_EFuA>VmYGu#w0(u7a1$%c*0 znnLF>qbYQke5S|1jil^weC1<{YjL(sH2E~wiK?lm&6)7LAI3ZkIsXb8k+1$E3r#qs z=D$NKBHbY4t()^PGS1J&m*I4bNMrs2q`tmV2dwc}npyVE{s}Mu4kF1dAUPHA00000 LNkvXXu0mjf#=+sP literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..99d1d4e71c8be19e25376d242055d85c07ecd704 GIT binary patch literal 509 zcmV(r*UxA%|y2@5O1*2W)D8~p+?8e%S9&g6U#-oa#Z!Ui08%=o0>|sGGC$M4`=+ycA4?l&`vY8Q(G4{cFRZX0O|sGL+nazdJ5dL% zm{|CkKw04x*mwd49*Kbm;2BsLm|?B!UG#l$U`st?#AtP8Ba?bx6NEQW}&&DaI4mH|VHx{0Q&r^LThVt@ zS|S-iPbE@%vTdEZ@Epj1DbuH%6k2{g&z)@FP|`HdWI)bg`*O^%&vw=QmG(%y9J*12D98MEZll>LvACnDP}C36Ku+z!Mk_+1!rbDyIV zD?iC{<_LHRv8PNAJ(j9z)uH0KrN0LC+iAurGE>3{ki$~@O=52s;zFhZdv_euWAL+- z9PlHTHltV%x*n&9O~0mo13m}u6Wk-HWcsxBJyc%}J)3g-C*VWsBHzFX^#n0f#NPk) z4s)^wOq6~^Ktqojtj^lu7jVmY_4uT&U^~P51?#CD`y;>rH>b#^_5~e<00000NkvXX Hu0mjfY`Nw5 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..408d7238032a59a550c6b1e63a150cf752f09453 GIT binary patch literal 533 zcmV+w0_y#VP)`@)Pz7Q^ zLSpQK5Hn(BX5bh22`2u84J79B1#B?F(g6e`2-?ylO`+krc~_ZJDy0ZZulCvJ=kwj= z>gIXw*y6fw4Jtq^f!!1rLvZD9@P)85*xz=pZxKmi0|+_JBoSEPlo5+X0@w*i2b#mP z3WSD?QWp|6&gh%Y2Wg{}Py(nH!yJ|nYG}ftQC-Y@i~R&E5Y~#_8M@G@sqWxb*KZNhuAeg z(+%K7S~kyD%(pHk**^V;7+*pkb9@2p0-GdvNSZ=FP9KN7cx8p`NRf%$1KWf{{S34? zZXrijdQ*B25x9bCE7yZc)`UjxfZJbNGUG2m_HPfdHtaL?=*pEkg-_bBu+#V;CY$V#+OXl$)Z!W?-d{mrd-c~T6peWe<3$Els4^eQX~`7goZzDNKW+!C`dK^exwuHU*$V$2sgnRBD6w!OJ;g*1#L!72YU& z_dl%w;p{So@e&HoT! Y02;f*9kog}-v9sr07*qoM6N<$f`yp!t^fc4 literal 0 HcmV?d00001 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"