1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 19:52:17 -05:00

Provide menu option to search messages.

Recent phones frequently do not have a hardware search key, so
there is no way to initiate a search without a menu option.

Related to issues 3386, 3428, 4523, and 4643.
This commit is contained in:
Joe Steele 2012-10-23 17:14:01 -04:00 committed by Jesse Vincent
parent 9d802e807e
commit f70d835404
2 changed files with 17 additions and 6 deletions

View File

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/search"
android:icon="?attr/iconActionSearch"
android:showAsAction="always"
android:title="@string/search_action"/>
<item <item
android:id="@+id/search_remote" android:id="@+id/search_remote"
android:icon="?attr/iconActionRemoteSearch" android:icon="?attr/iconActionRemoteSearch"

View File

@ -464,6 +464,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
onEditPrefs(); onEditPrefs();
return true; return true;
} }
case R.id.search: {
mMessageListFragment.onSearchRequested();
return true;
}
case R.id.search_remote: { case R.id.search_remote: {
mMessageListFragment.onRemoteSearch(); mMessageListFragment.onRemoteSearch();
return true; return true;
@ -519,6 +523,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
return; return;
} }
menu.findItem(R.id.search).setVisible(false);
menu.findItem(R.id.search_remote).setVisible(false); menu.findItem(R.id.search_remote).setVisible(false);
if (mMessageListFragment == null) { if (mMessageListFragment == null) {
@ -548,6 +553,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
} }
} else { } else {
menu.findItem(R.id.search).setVisible(true);
menu.findItem(R.id.folder_settings).setVisible(true); menu.findItem(R.id.folder_settings).setVisible(true);
menu.findItem(R.id.account_settings).setVisible(true); menu.findItem(R.id.account_settings).setVisible(true);
@ -669,7 +675,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
MessageListFragment fragment = MessageListFragment.newInstance("From " + senderAddress, MessageListFragment fragment = MessageListFragment.newInstance("From " + senderAddress,
null, null, senderAddress, null, null, false); null, null, senderAddress, null, null, false);
addMessageListFragment(fragment); addMessageListFragment(fragment, true);
} }
@Override @Override
@ -714,18 +720,18 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
} }
} }
@Override
public void remoteSearch(String searchAccount, String searchFolder, String queryString) { public void remoteSearch(String searchAccount, String searchFolder, String queryString) {
MessageListFragment fragment = MessageListFragment.newInstance(searchAccount, searchFolder, MessageListFragment fragment = MessageListFragment.newInstance(searchAccount, searchFolder,
queryString, true); queryString, true);
mMenu.findItem(R.id.search_remote).setVisible(false);
addMessageListFragment(fragment); addMessageListFragment(fragment, false);
} }
private void addMessageListFragment(MessageListFragment fragment) { private void addMessageListFragment(MessageListFragment fragment, boolean addToBackStack) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.replace(R.id.message_list_container, fragment); ft.replace(R.id.message_list_container, fragment);
if (addToBackStack)
ft.addToBackStack(null); ft.addToBackStack(null);
mMessageListFragment = fragment; mMessageListFragment = fragment;