summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChiao Cheng <chiaocheng@google.com>2012-11-07 11:01:38 -0800
committerChiao Cheng <chiaocheng@google.com>2012-11-08 16:10:27 -0800
commite2ff8fa4ad0d1c1bba9d42a7f8669b36ceebfbfe (patch)
tree3321e871c303f7fc30347fc422b3fd4cdb88a0d2 /src
parentac834156f56a4d4edcf207865f8235647fa26980 (diff)
Prune selected call log filter options from overflow menu.
Bug: 7205096 Change-Id: Ib81e81195475e74f06ed7eda600b3f777a28ad70
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index eb0b371b2..86a383aa9 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -77,8 +77,6 @@ public class CallLogFragment extends ListFragment
/** Whether there is at least one voicemail source installed. */
private boolean mVoicemailSourcesAvailable = false;
- /** Whether we are currently filtering over voicemail. */
- private boolean mShowingVoicemailOnly = false;
private VoicemailStatusHelper mVoicemailStatusHelper;
private View mStatusMessageView;
@@ -317,10 +315,6 @@ public class CallLogFragment extends ListFragment
public void startCallsQuery() {
mAdapter.setLoading(true);
mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
- if (mShowingVoicemailOnly) {
- mShowingVoicemailOnly = false;
- getActivity().invalidateOptionsMenu();
- }
}
private void startVoicemailStatusQuery() {
@@ -340,10 +334,49 @@ public class CallLogFragment extends ListFragment
// menu items are ready if the first item is non-null.
if (itemDeleteAll != null) {
itemDeleteAll.setEnabled(mAdapter != null && !mAdapter.isEmpty());
- menu.findItem(R.id.show_voicemails_only).setVisible(mVoicemailSourcesAvailable);
+
+ showAllFilterMenuOptions(menu);
+ hideCurrentFilterMenuOption(menu);
+
+ // Only hide if not available. Let the above calls handle showing.
+ if (!mVoicemailSourcesAvailable) {
+ menu.findItem(R.id.show_voicemails_only).setVisible(false);
+ }
+ }
+ }
+
+ private void hideCurrentFilterMenuOption(Menu menu) {
+ MenuItem item = null;
+ switch (mCallTypeFilter) {
+ case CallLogQueryHandler.CALL_TYPE_ALL:
+ item = menu.findItem(R.id.show_all_calls);
+ break;
+ case Calls.INCOMING_TYPE:
+ item = menu.findItem(R.id.show_incoming_only);
+ break;
+ case Calls.OUTGOING_TYPE:
+ item = menu.findItem(R.id.show_outgoing_only);
+ break;
+ case Calls.MISSED_TYPE:
+ item = menu.findItem(R.id.show_missed_only);
+ break;
+ case Calls.VOICEMAIL_TYPE:
+ menu.findItem(R.id.show_voicemails_only);
+ break;
+ }
+ if (item != null) {
+ item.setVisible(false);
}
}
+ private void showAllFilterMenuOptions(Menu menu) {
+ menu.findItem(R.id.show_all_calls).setVisible(true);
+ menu.findItem(R.id.show_incoming_only).setVisible(true);
+ menu.findItem(R.id.show_outgoing_only).setVisible(true);
+ menu.findItem(R.id.show_missed_only).setVisible(true);
+ menu.findItem(R.id.show_voicemails_only).setVisible(true);
+ }
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
@@ -375,7 +408,6 @@ public class CallLogFragment extends ListFragment
registerPhoneCallReceiver();
mCallLogQueryHandler.fetchCalls(Calls.VOICEMAIL_TYPE);
updateFilterTypeAndHeader(Calls.VOICEMAIL_TYPE);
- mShowingVoicemailOnly = true;
return true;
case R.id.show_all_calls:
@@ -383,7 +415,6 @@ public class CallLogFragment extends ListFragment
unregisterPhoneCallReceiver();
mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL);
updateFilterTypeAndHeader(CallLogQueryHandler.CALL_TYPE_ALL);
- mShowingVoicemailOnly = false;
return true;
default: