First pass at adding "Searchable" infrastructure

This commit is contained in:
Jesse Vincent 2009-12-27 16:50:37 +00:00
parent 9ba102599f
commit 151ae5a2a3
3 changed files with 35 additions and 0 deletions

View File

@ -27,6 +27,9 @@
<uses-permission android:name="com.fsck.k9.permission.READ_ATTACHMENT"/>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="K9"
>
<meta-data android:name="android.app.default_searchable"
android:value=".Search" />
<activity
android:name="com.fsck.k9.activity.Accounts"
android:label="@string/app_name">
@ -183,6 +186,17 @@
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<!-- Search Activity - searchable -->
<activity android:name="Search"
android:label="@string/search_action"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<receiver android:name="com.fsck.k9.service.BootReceiver"
android:enabled="true"
>

4
res/xml/searchable.xml Normal file
View File

@ -0,0 +1,4 @@
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/search_action"
android:hint="@string/search_action" >
</searchable>

View File

@ -1273,6 +1273,23 @@ public class LocalStore extends Store implements Serializable
}
public Message[] searchForMessages(MessageRetrievalListener listener, String queryString) throws MessagingException {
return getMessages(
listener,
"SELECT "
+ GET_MESSAGES_COLS
+ "FROM messages WHERE html_content LIKE ? OR subject LIKE ? OR sender_list LIKE ? ORDER BY date DESC"
, new String[]
{
queryString,
queryString,
queryString
}
);
}
/*
* Given a query string, actually do the query for the messages and
* call the MessageRetrievalListener for each one