summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike LeBeau <mlebeau@android.com>2009-05-20 17:22:13 -0700
committerMike LeBeau <mlebeau@android.com>2009-05-20 17:22:13 -0700
commit1480eb27f5321ef5fc2faeee87c7464e279a4912 (patch)
tree3ac06112d42626ab117af69b50fc6ae061fea774
parentb204d4f12773ec67c7f0ded41cb111018f154476 (diff)
downloadframeworks_base-1480eb27f5321ef5fc2faeee87c7464e279a4912.zip
frameworks_base-1480eb27f5321ef5fc2faeee87c7464e279a4912.tar.gz
frameworks_base-1480eb27f5321ef5fc2faeee87c7464e279a4912.tar.bz2
Add support to SuggestionsAdapter to query the 'working' status
of its underlying cursor and update a spinner in the search dialog accordingly.
-rw-r--r--core/java/android/app/SearchDialog.java27
-rw-r--r--core/java/android/app/SuggestionsAdapter.java35
-rw-r--r--core/res/res/drawable/search_spinner.xml36
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim1.pngbin0 -> 523 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim10.pngbin0 -> 529 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim11.pngbin0 -> 525 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim12.pngbin0 -> 527 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim2.pngbin0 -> 525 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim3.pngbin0 -> 522 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim4.pngbin0 -> 519 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim5.pngbin0 -> 521 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim6.pngbin0 -> 509 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim7.pngbin0 -> 517 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim8.pngbin0 -> 533 bytes
-rwxr-xr-xcore/res/res/drawable/search_spinner_anim9.pngbin0 -> 534 bytes
-rw-r--r--core/res/res/layout/search_bar.xml1
16 files changed, 94 insertions, 5 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 343380c..1ff5665 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
@@ -396,6 +399,24 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
}
/**
+ * 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.
*/
private void closeSuggestionsAdapter() {
@@ -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 6a02fc9..2fe9a8d 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<String, Drawable> 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<String, Drawable> outsideDrawablesCache) {
+ public SuggestionsAdapter(Context context, SearchDialog searchDialog, SearchableInfo searchable,
+ WeakHashMap<String, Drawable> 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 0000000..34c163d
--- /dev/null
+++ b/core/res/res/drawable/search_spinner.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2008, 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.
+*/
+-->
+<animation-list
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:oneshot="false">
+ <item android:drawable="@drawable/search_spinner_anim1" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim2" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim3" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim4" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim5" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim6" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim7" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim8" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim9" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim10" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim11" android:duration="150" />
+ <item android:drawable="@drawable/search_spinner_anim12" android:duration="150" />
+</animation-list>
+
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 0000000..e55b60d
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim1.png
Binary files 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 0000000..9611d97
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim10.png
Binary files 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 0000000..4261704
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim11.png
Binary files 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 0000000..0602314
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim12.png
Binary files 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 0000000..05d58e0
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim2.png
Binary files 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 0000000..69fa9c1
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim3.png
Binary files 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 0000000..9201bac
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim4.png
Binary files 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 0000000..f0c7101
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim5.png
Binary files 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 0000000..99d1d4e
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim6.png
Binary files 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 0000000..8ca3358
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim7.png
Binary files 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 0000000..408d723
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim8.png
Binary files 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 0000000..42a2c65
--- /dev/null
+++ b/core/res/res/drawable/search_spinner_anim9.png
Binary files differ
diff --git a/core/res/res/layout/search_bar.xml b/core/res/res/layout/search_bar.xml
index b512490..7b7f8a6 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"