Adjusting call log filter look and feel.
- Moved filter buttons into overflow menu.
- Added filter header to show users which results are displayed.
Change-Id: I496ecdde8bd235a2065198dffc4179db7012889c
diff --git a/res/layout/call_log_fragment.xml b/res/layout/call_log_fragment.xml
index 9e88c49..5e7061c 100644
--- a/res/layout/call_log_fragment.xml
+++ b/res/layout/call_log_fragment.xml
@@ -33,6 +33,30 @@
<include layout="@layout/call_log_voicemail_status"
/>
</FrameLayout>
+
+ <FrameLayout>
+ <TextView
+ android:id="@+id/filter_status"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingLeft="@dimen/call_log_outer_margin"
+ android:paddingRight="@dimen/call_log_outer_margin"
+ android:paddingTop="@dimen/call_log_inner_margin"
+ android:paddingBottom="@dimen/call_log_inner_margin"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentBottom="true"
+ android:visibility="gone"
+ />
+ <View
+ android:id="@+id/call_log_divider"
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:layout_marginLeft="@dimen/call_log_outer_margin"
+ android:layout_marginRight="@dimen/call_log_outer_margin"
+ android:layout_gravity="bottom"
+ android:background="#55ffffff"
+ />
+ </FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/res/menu/call_log_options.xml b/res/menu/call_log_options.xml
index d393a9e..bf2973f 100644
--- a/res/menu/call_log_options.xml
+++ b/res/menu/call_log_options.xml
@@ -16,44 +16,39 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
- android:id="@+id/show_all_calls"
- android:title="@string/menu_show_all_calls"
- android:icon="@drawable/quickcon_background_texture"
- android:showAsAction="ifRoom"
- android:orderInCategory="1"/>
+ android:id="@+id/show_all_calls"
+ android:title="@string/menu_show_all_calls"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
<item
- android:id="@+id/show_voicemails_only"
- android:title="@string/menu_show_voicemails_only"
- android:icon="@drawable/ic_call_voicemail_holo_dark"
- android:showAsAction="ifRoom"
- android:orderInCategory="1"/>
+ android:id="@+id/show_voicemails_only"
+ android:title="@string/menu_show_voicemails_only"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
<item
- android:id="@+id/show_missed_only"
- android:title="@string/menu_show_missed_only"
- android:icon="@drawable/ic_call_missed_holo_dark"
- android:showAsAction="ifRoom"
- android:orderInCategory="1"/>
+ android:id="@+id/show_missed_only"
+ android:title="@string/menu_show_missed_only"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
<item
- android:id="@+id/show_outgoing_only"
- android:title="@string/menu_show_outgoing_only"
- android:icon="@drawable/ic_call_outgoing_holo_dark"
- android:showAsAction="ifRoom"
- android:orderInCategory="1"/>
+ android:id="@+id/show_outgoing_only"
+ android:title="@string/menu_show_outgoing_only"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
<item
- android:id="@+id/show_incoming_only"
- android:title="@string/menu_show_incoming_only"
- android:icon="@drawable/ic_call_incoming_holo_dark"
- android:showAsAction="ifRoom"
- android:orderInCategory="1"/>
+ android:id="@+id/show_incoming_only"
+ android:title="@string/menu_show_incoming_only"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
<item
- android:id="@+id/delete_all"
- android:title="@string/recentCalls_deleteAll"
- android:showAsAction="withText"
- android:orderInCategory="1"/>
+ android:id="@+id/delete_all"
+ android:title="@string/recentCalls_deleteAll"
+ android:showAsAction="never"
+ android:orderInCategory="1"/>
</menu>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3b5ccd1..8b843b4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1609,9 +1609,21 @@
<!-- The header in the call log used to identify items that have been already consumed [CHAR LIMIT=10] -->
<string name="call_log_old_header">Older</string>
+ <!-- The header to show that call log is only showing voicemail calls. [CHAR LIMIT=40] -->
+ <string name="call_log_voicemail_header">Calls with voicemail</string>
+
+ <!-- The header to show that call log is only showing incoming calls. [CHAR LIMIT=40] -->
+ <string name="call_log_incoming_header">Incoming calls</string>
+
+ <!-- The header to show that call log is only showing outgoing calls. [CHAR LIMIT=40] -->
+ <string name="call_log_outgoing_header">Outgoing calls</string>
+
+ <!-- The header to show that call log is only showing missed calls. [CHAR LIMIT=40] -->
+ <string name="call_log_missed_header">Missed calls</string>
+
<!-- Voicemail status message shown at the top of call log to notify the user that no new
- voicemails are currently available. This can happen when both notification as well as data
- connection to the voicemail server is lost. [CHAR LIMIT=64] -->
+voicemails are currently available. This can happen when both notification as well as data
+connection to the voicemail server is lost. [CHAR LIMIT=64] -->
<string name="voicemail_status_voicemail_not_available">Can\'t connect to voicemail server.</string>
<!-- Voicemail status message shown at the top of call log to notify the user that there is no
data connection to the voicemail server, but there are new voicemails waiting on the server.
diff --git a/src/com/android/contacts/activities/DialtactsActivity.java b/src/com/android/contacts/activities/DialtactsActivity.java
index 2e35213..b71f15a 100644
--- a/src/com/android/contacts/activities/DialtactsActivity.java
+++ b/src/com/android/contacts/activities/DialtactsActivity.java
@@ -1017,7 +1017,7 @@
// When there is a permanent menu key, there is no overflow icon on the right of
// the action bar which would force the search menu item (if it is visible) to the
// left. This is the purpose of showing the emptyRightMenuItem.
- emptyRightMenuItem.setVisible(false);
+ emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
} else {
// This is when the user is looking at the dialer pad. In this case, the real
// ActionBar is hidden and fake menu items are shown.
@@ -1038,11 +1038,11 @@
final MenuItem emptyRightMenuItem = menu.findItem(R.id.empty_right_menu_item);
// prepare the menu items
- searchMenuItem.setVisible(false);
+ searchMenuItem.setVisible(true);
filterOptionMenuItem.setVisible(false);
addContactOptionMenuItem.setVisible(false);
callSettingsMenuItem.setVisible(true);
- emptyRightMenuItem.setVisible(false);
+ emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
}
private void prepareOptionsMenuForFavoritesTab(Menu menu) {
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 739cf35..f9d21c0 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -21,6 +21,7 @@
import android.app.ListFragment;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
@@ -28,6 +29,7 @@
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
+import android.preference.PreferenceManager;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
@@ -69,6 +71,8 @@
*/
private static final int EMPTY_LOADER_ID = 0;
+ private static final String PREF_CALL_LOG_FILTER_LAST_CALL_TYPE = "CallLogFragment_last_filter";
+
private CallLogAdapter mAdapter;
private CallLogQueryHandler mCallLogQueryHandler;
private boolean mScrollToTop;
@@ -82,6 +86,7 @@
private View mStatusMessageView;
private TextView mStatusMessageText;
private TextView mStatusMessageAction;
+ private TextView mFilterStatusView;
private KeyguardManager mKeyguardManager;
private boolean mEmptyLoaderRunning;
@@ -108,6 +113,9 @@
// Exactly same variable is in Fragment as a package private.
private boolean mMenuVisible = true;
+ // Default to all calls.
+ private int mCallTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL;
+
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
@@ -120,6 +128,11 @@
getActivity().getContentResolver().registerContentObserver(
ContactsContract.Contacts.CONTENT_URI, true, mContactsObserver);
setHasOptionsMenu(true);
+
+ // Load the last filter used.
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ mCallTypeFilter = prefs.getInt(PREF_CALL_LOG_FILTER_LAST_CALL_TYPE,
+ CallLogQueryHandler.CALL_TYPE_ALL);
}
/** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */
@@ -148,7 +161,9 @@
mHandler.post(new Runnable() {
@Override
public void run() {
- if (getActivity() == null || getActivity().isFinishing()) return;
+ if (getActivity() == null || getActivity().isFinishing()) {
+ return;
+ }
listView.smoothScrollToPosition(0);
}
});
@@ -202,6 +217,7 @@
mStatusMessageView = view.findViewById(R.id.voicemail_status);
mStatusMessageText = (TextView) view.findViewById(R.id.voicemail_status_message);
mStatusMessageAction = (TextView) view.findViewById(R.id.voicemail_status_action);
+ mFilterStatusView = (TextView) view.findViewById(R.id.filter_status);
return view;
}
@@ -213,6 +229,8 @@
new ContactInfoHelper(getActivity(), currentCountryIso));
setListAdapter(mAdapter);
getListView().setItemsCanFocus(true);
+
+ updateFilterHeader();
}
/**
@@ -279,6 +297,11 @@
super.onPause();
// Kill the requests thread
mAdapter.stopRequestProcessing();
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ prefs.edit()
+ .putInt(PREF_CALL_LOG_FILTER_LAST_CALL_TYPE, mCallTypeFilter)
+ .apply();
}
@Override
@@ -298,16 +321,12 @@
@Override
public void fetchCalls() {
- if (mShowingVoicemailOnly) {
- mCallLogQueryHandler.fetchVoicemailOnly();
- } else {
- mCallLogQueryHandler.fetchAllCalls();
- }
+ mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
}
public void startCallsQuery() {
mAdapter.setLoading(true);
- mCallLogQueryHandler.fetchAllCalls();
+ mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
if (mShowingVoicemailOnly) {
mShowingVoicemailOnly = false;
getActivity().invalidateOptionsMenu();
@@ -343,27 +362,34 @@
return true;
case R.id.show_outgoing_only:
- mCallLogQueryHandler.fetchOutgoing();
-
+ mCallLogQueryHandler.fetchCalls(Calls.OUTGOING_TYPE);
+ mCallTypeFilter = Calls.OUTGOING_TYPE;
+ updateFilterHeader();
return true;
case R.id.show_incoming_only:
- mCallLogQueryHandler.fetchIncoming();
-
+ mCallLogQueryHandler.fetchCalls(Calls.INCOMING_TYPE);
+ mCallTypeFilter = Calls.INCOMING_TYPE;
+ updateFilterHeader();
return true;
case R.id.show_missed_only:
- mCallLogQueryHandler.fetchMissed();
-
+ mCallLogQueryHandler.fetchCalls(Calls.MISSED_TYPE);
+ mCallTypeFilter = Calls.MISSED_TYPE;
+ updateFilterHeader();
return true;
case R.id.show_voicemails_only:
- mCallLogQueryHandler.fetchVoicemailOnly();
+ mCallLogQueryHandler.fetchCalls(Calls.VOICEMAIL_TYPE);
+ mCallTypeFilter = Calls.VOICEMAIL_TYPE;
+ updateFilterHeader();
mShowingVoicemailOnly = true;
return true;
case R.id.show_all_calls:
- mCallLogQueryHandler.fetchAllCalls();
+ mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL);
+ mCallTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL;
+ updateFilterHeader();
mShowingVoicemailOnly = false;
return true;
@@ -372,6 +398,31 @@
}
}
+ private void updateFilterHeader() {
+ switch (mCallTypeFilter) {
+ case CallLogQueryHandler.CALL_TYPE_ALL:
+ mFilterStatusView.setVisibility(View.GONE);
+ break;
+ case Calls.INCOMING_TYPE:
+ showFilterStatus(R.string.call_log_incoming_header);
+ break;
+ case Calls.OUTGOING_TYPE:
+ showFilterStatus(R.string.call_log_outgoing_header);
+ break;
+ case Calls.MISSED_TYPE:
+ showFilterStatus(R.string.call_log_missed_header);
+ break;
+ case Calls.VOICEMAIL_TYPE:
+ showFilterStatus(R.string.call_log_voicemail_header);
+ break;
+ }
+ }
+
+ private void showFilterStatus(int resId) {
+ mFilterStatusView.setText(resId);
+ mFilterStatusView.setVisibility(View.VISIBLE);
+ }
+
public void callSelectedEntry() {
int position = getListView().getSelectedItemPosition();
if (position < 0) {
diff --git a/src/com/android/contacts/calllog/CallLogQueryHandler.java b/src/com/android/contacts/calllog/CallLogQueryHandler.java
index 3ef2f7d..096e882 100644
--- a/src/com/android/contacts/calllog/CallLogQueryHandler.java
+++ b/src/com/android/contacts/calllog/CallLogQueryHandler.java
@@ -64,6 +64,12 @@
private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 58;
/**
+ * Call type similar to Calls.INCOMING_TYPE used to specify all types instead of one particular
+ * type.
+ */
+ public static final int CALL_TYPE_ALL = -1;
+
+ /**
* The time window from the current time within which an unread entry will be added to the new
* section.
*/
@@ -153,48 +159,15 @@
}
/**
- * Fetches the list of calls from the call log.
+ * Fetches the list of calls from the call log for a given type.
* <p>
* It will asynchronously update the content of the list view when the fetch completes.
*/
- public void fetchAllCalls() {
+ public void fetchCalls(int callType) {
cancelFetch();
int requestId = newCallsRequest();
- fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, -1 /*callType*/);
- fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, -1 /*callType*/);
- }
-
- /**
- * Fetches the list of calls from the call log but include only the voicemail.
- * <p>
- * It will asynchronously update the content of the list view when the fetch completes.
- */
- public void fetchVoicemailOnly() {
- cancelFetch();
- int requestId = newCallsRequest();
- fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.VOICEMAIL_TYPE);
- fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.VOICEMAIL_TYPE);
- }
-
- public void fetchOutgoing() {
- cancelFetch();
- int requestId = newCallsRequest();
- fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.OUTGOING_TYPE);
- fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.OUTGOING_TYPE);
- }
-
- public void fetchIncoming() {
- cancelFetch();
- int requestId = newCallsRequest();
- fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.INCOMING_TYPE);
- fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.INCOMING_TYPE);
- }
-
- public void fetchMissed() {
- cancelFetch();
- int requestId = newCallsRequest();
- fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.MISSED_TYPE);
- fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.MISSED_TYPE);
+ fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, callType);
+ fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, callType);
}
public void fetchVoicemailStatus() {
@@ -215,7 +188,7 @@
// Negate the query.
selection = String.format("NOT (%s)", selection);
}
- if (callType > 0) {
+ if (callType > CALL_TYPE_ALL) {
// Add a clause to fetch only items of type voicemail.
selection = String.format("(%s) AND (%s = ?)", selection, Calls.TYPE);
selectionArgs.add(Integer.toString(callType));
@@ -380,8 +353,7 @@
void onVoicemailStatusFetched(Cursor statusCursor);
/**
- * Called when {@link CallLogQueryHandler#fetchAllCalls()} or
- * {@link CallLogQueryHandler#fetchVoicemailOnly()} complete.
+ * Called when {@link CallLogQueryHandler#fetchCalls(int)}complete.
*/
void onCallsFetched(Cursor combinedCursor);
}