Merge "Add "Show all calls" to options menu."
diff --git a/res/menu/call_log_options.xml b/res/menu/call_log_options.xml
index b50869a..c62be77 100644
--- a/res/menu/call_log_options.xml
+++ b/res/menu/call_log_options.xml
@@ -26,6 +26,11 @@
android:showAsAction="withText" />
<item
+ android:id="@+id/show_all_calls"
+ android:title="@string/menu_show_all_calls"
+ android:showAsAction="withText" />
+
+ <item
android:id="@+id/menu_call_settings_call_log"
android:title="@string/call_settings"
android:icon="@drawable/ic_menu_settings_holo_light"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 810b40a..b7a1868 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1686,6 +1686,9 @@
<!-- Menu item used to show only voicemails in the call log. [CHAR LIMIT=30] -->
<string name="menu_show_voicemails_only">Show voicemails only</string>
+ <!-- Menu item used to show all calls in the call log. [CHAR LIMIT=30] -->
+ <string name="menu_show_all_calls">Show all calls</string>
+
<!-- Used to display as default status when the contact is available for chat [CHAR LIMIT=19] -->
<string name="status_available">Available</string>
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 0713e0e..8dd9e57 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -24,6 +24,7 @@
import com.android.contacts.R;
import com.android.contacts.activities.DialtactsActivity;
import com.android.contacts.activities.DialtactsActivity.ViewPagerVisibilityListener;
+import com.android.contacts.test.NeededForTesting;
import com.android.contacts.util.ExpirableCache;
import com.android.contacts.voicemail.VoicemailStatusHelper;
import com.android.contacts.voicemail.VoicemailStatusHelper.StatusMessage;
@@ -167,6 +168,8 @@
private boolean mScrollToTop;
private boolean mShowOptionsMenu;
+ /** Whether we are currently filtering over voicemail. */
+ private boolean mShowingVoicemailOnly = false;
private VoicemailStatusHelper mVoicemailStatusHelper;
private View mStatusMessageView;
@@ -228,6 +231,10 @@
public void addGroup(int cursorPosition, int size, boolean expanded);
}
+ public interface CallFetcher {
+ public void fetchAllCalls();
+ }
+
/** Adapter class to fill in data for the Call Log */
public static final class CallLogAdapter extends GroupingListAdapter
implements Runnable, ViewTreeObserver.OnPreDrawListener, GroupCreator {
@@ -236,7 +243,7 @@
private final Context mContext;
private final String mCurrentCountryIso;
- private final CallLogQueryHandler mCallLogQueryHandler;
+ private final CallFetcher mCallFetcher;
/**
* A cache of the contact details for the phone numbers in the call log.
@@ -320,13 +327,13 @@
}
};
- public CallLogAdapter(Context context, CallLogQueryHandler callLogQueryHandler,
+ public CallLogAdapter(Context context, CallFetcher callFetcher,
String currentCountryIso, String voicemailNumber) {
super(context);
mContext = context;
mCurrentCountryIso = currentCountryIso;
- mCallLogQueryHandler = callLogQueryHandler;
+ mCallFetcher = callFetcher;
mContactInfoCache = ExpirableCache.create(CONTACT_INFO_CACHE_SIZE);
mRequests = new LinkedList<String>();
@@ -350,9 +357,9 @@
*/
@Override
protected void onContentChanged() {
- // Start async requery
- setLoading(true);
- mCallLogQueryHandler.fetchAllCalls();
+ // When the content changes, always fetch all the calls, in case a new missed call came
+ // in and we were filtering over voicemail only, so that we see the missed call.
+ mCallFetcher.fetchAllCalls();
}
void setLoading(boolean loading) {
@@ -921,8 +928,13 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String currentCountryIso = ContactsUtils.getCurrentCountryIso(getActivity());
- mAdapter = new CallLogAdapter(getActivity(), mCallLogQueryHandler, currentCountryIso,
- getVoiceMailNumber());
+ mAdapter = new CallLogAdapter(getActivity(),
+ new CallFetcher() {
+ @Override
+ public void fetchAllCalls() {
+ startCallsQuery();
+ }
+ }, currentCountryIso, mVoiceMailNumber);
setListAdapter(mAdapter);
getListView().setItemsCanFocus(true);
}
@@ -995,6 +1007,10 @@
private void startCallsQuery() {
mAdapter.setLoading(true);
mCallLogQueryHandler.fetchAllCalls();
+ if (mShowingVoicemailOnly) {
+ mShowingVoicemailOnly = false;
+ getActivity().invalidateOptionsMenu();
+ }
}
private void startVoicemailStatusQuery() {
@@ -1014,21 +1030,28 @@
if (mShowOptionsMenu) {
menu.findItem(R.id.menu_call_settings_call_log)
.setIntent(DialtactsActivity.getCallSettingsIntent());
+ menu.findItem(R.id.show_voicemails_only).setVisible(!mShowingVoicemailOnly);
+ menu.findItem(R.id.show_all_calls).setVisible(mShowingVoicemailOnly);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.delete_all: {
+ case R.id.delete_all:
ClearCallLogDialog.show(getFragmentManager());
return true;
- }
- case R.id.show_voicemails_only: {
+ case R.id.show_voicemails_only:
mCallLogQueryHandler.fetchVoicemailOnly();
+ mShowingVoicemailOnly = true;
return true;
- }
+
+ case R.id.show_all_calls:
+ mCallLogQueryHandler.fetchAllCalls();
+ mShowingVoicemailOnly = false;
+ return true;
+
default:
return false;
}
@@ -1114,12 +1137,12 @@
}
}
- @VisibleForTesting
+ @NeededForTesting
public CallLogAdapter getAdapter() {
return mAdapter;
}
- @VisibleForTesting
+ @NeededForTesting
public String getVoiceMailNumber() {
return mVoiceMailNumber;
}