mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -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:
parent
9d802e807e
commit
f70d835404
@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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
|
||||
android:id="@+id/search_remote"
|
||||
android:icon="?attr/iconActionRemoteSearch"
|
||||
|
@ -464,6 +464,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
onEditPrefs();
|
||||
return true;
|
||||
}
|
||||
case R.id.search: {
|
||||
mMessageListFragment.onSearchRequested();
|
||||
return true;
|
||||
}
|
||||
case R.id.search_remote: {
|
||||
mMessageListFragment.onRemoteSearch();
|
||||
return true;
|
||||
@ -519,6 +523,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
return;
|
||||
}
|
||||
|
||||
menu.findItem(R.id.search).setVisible(false);
|
||||
menu.findItem(R.id.search_remote).setVisible(false);
|
||||
|
||||
if (mMessageListFragment == null) {
|
||||
@ -548,6 +553,7 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
}
|
||||
|
||||
} else {
|
||||
menu.findItem(R.id.search).setVisible(true);
|
||||
menu.findItem(R.id.folder_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,
|
||||
null, null, senderAddress, null, null, false);
|
||||
|
||||
addMessageListFragment(fragment);
|
||||
addMessageListFragment(fragment, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -714,19 +720,19 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remoteSearch(String searchAccount, String searchFolder, String queryString) {
|
||||
MessageListFragment fragment = MessageListFragment.newInstance(searchAccount, searchFolder,
|
||||
queryString, true);
|
||||
|
||||
addMessageListFragment(fragment);
|
||||
mMenu.findItem(R.id.search_remote).setVisible(false);
|
||||
addMessageListFragment(fragment, false);
|
||||
}
|
||||
|
||||
private void addMessageListFragment(MessageListFragment fragment) {
|
||||
private void addMessageListFragment(MessageListFragment fragment, boolean addToBackStack) {
|
||||
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
|
||||
|
||||
ft.replace(R.id.message_list_container, fragment);
|
||||
ft.addToBackStack(null);
|
||||
if (addToBackStack)
|
||||
ft.addToBackStack(null);
|
||||
|
||||
mMessageListFragment = fragment;
|
||||
ft.commit();
|
||||
|
Loading…
Reference in New Issue
Block a user