Change the layout of the call log list items.
This fixes selection and touch targets.
Instead of the whole list item being clickable, split out the various
parts.
Bug: 5063588
Change-Id: Ifb433d637d26dadc3998e4686c80ca0cb18a3ebc
diff --git a/res/layout/call_log_list_item.xml b/res/layout/call_log_list_item.xml
index 5447f65..8bd6a19 100644
--- a/res/layout/call_log_list_item.xml
+++ b/res/layout/call_log_list_item.xml
@@ -19,7 +19,6 @@
class="com.android.contacts.calllog.CallLogListItemView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:padding="@dimen/call_log_inner_margin"
>
<!--
This layout may represent either a call log item or one of the
@@ -45,22 +44,25 @@
android:layout_height="@dimen/call_log_list_contact_photo_size"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
- android:layout_marginLeft="@dimen/call_log_inner_margin"
+ android:layout_marginLeft="@dimen/call_log_outer_margin"
+ android:layout_marginTop="@dimen/call_log_inner_margin"
+ android:layout_marginBottom="@dimen/call_log_inner_margin"
/>
<LinearLayout
android:id="@+id/divider"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_alignParentRight="true"
- android:layout_centerInParent="true"
+ android:layout_centerVertical="true"
+ android:layout_alignTop="@+id/primary_action_view"
+ android:layout_alignBottom="@+id/primary_action_view"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/unheard_icon"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/call_log_inner_margin"
- android:layout_gravity="center_vertical"
+ android:layout_height="match_parent"
+ android:paddingRight="@dimen/call_log_inner_margin"
android:scaleType="center"
android:src="@drawable/ic_unheard_voicemail_holo_dark"
android:visibility="gone"
@@ -69,27 +71,32 @@
<View
android:layout_width="1px"
android:layout_height="@dimen/call_log_call_action_size"
- android:layout_gravity="center_vertical"
- android:layout_marginLeft="@dimen/call_log_inner_margin"
android:background="@drawable/ic_divider_dashed_holo_dark"
+ android:layout_gravity="center_vertical"
/>
- <ImageView
+ <ImageButton
android:id="@+id/secondary_action_icon"
android:layout_width="@dimen/call_log_call_action_width"
- android:layout_height="@dimen/call_log_call_action_height"
- android:layout_gravity="center_vertical"
+ android:layout_height="match_parent"
+ android:paddingLeft="@dimen/call_log_inner_margin"
+ android:paddingTop="@dimen/call_log_inner_margin"
+ android:paddingBottom="@dimen/call_log_inner_margin"
+ android:paddingRight="@dimen/call_log_outer_margin"
android:scaleType="center"
android:background="@drawable/list_selector"
/>
</LinearLayout>
<LinearLayout
+ android:id="@+id/primary_action_view"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:layout_toRightOf="@id/quick_contact_photo"
android:layout_toLeftOf="@id/divider"
android:layout_centerVertical="true"
- android:layout_marginLeft="@dimen/call_log_inner_margin"
+ android:padding="@dimen/call_log_inner_margin"
android:orientation="vertical"
+ android:background="@drawable/list_selector"
+ android:focusable="true"
>
<TextView
android:id="@+id/name"
@@ -139,8 +146,12 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/call_log_inner_margin"
+ android:layout_marginRight="@dimen/call_log_inner_margin"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="?attr/call_log_header_color"
+ android:padding="@dimen/call_log_inner_margin"
+ android:focusable="true"
+ android:drawableBottom="@android:color/holo_blue_light"
/>
</view>
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 328faf2..462d382 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -17,7 +17,6 @@
package com.android.contacts.calllog;
import com.android.common.widget.GroupingListAdapter;
-import com.android.contacts.CallDetailActivity;
import com.android.contacts.ContactPhotoManager;
import com.android.contacts.ContactsUtils;
import com.android.contacts.PhoneCallDetails;
@@ -34,7 +33,6 @@
import com.google.common.annotations.VisibleForTesting;
import android.app.ListFragment;
-import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
@@ -275,7 +273,18 @@
/** Can be set to true by tests to disable processing of requests. */
private volatile boolean mRequestProcessingDisabled = false;
- private final View.OnClickListener mCallPlayOnClickListener = new View.OnClickListener() {
+ /** Listener for the primary action in the list, opens the call details. */
+ private final View.OnClickListener mPrimaryActionListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ IntentProvider intentProvider = (IntentProvider) view.getTag();
+ if (intentProvider != null) {
+ mContext.startActivity(intentProvider.getIntent(mContext));
+ }
+ }
+ };
+ /** Listener for the secondary action in the list, either call or play. */
+ private final View.OnClickListener mSecondaryActionListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
IntentProvider intentProvider = (IntentProvider) view.getTag();
@@ -663,7 +672,8 @@
private void findAndCacheViews(View view) {
// Get the views to bind to.
CallLogListItemViews views = CallLogListItemViews.fromView(view);
- views.secondaryActionView.setOnClickListener(mCallPlayOnClickListener);
+ views.primaryActionView.setOnClickListener(mPrimaryActionListener);
+ views.secondaryActionView.setOnClickListener(mSecondaryActionListener);
view.setTag(views);
}
@@ -701,6 +711,9 @@
final String formattedNumber;
final String countryIso = c.getString(CallLogQuery.COUNTRY_ISO);
+ views.primaryActionView.setTag(
+ IntentProvider.getCallDetailIntentProvider(
+ this, c.getPosition(), c.getLong(CallLogQuery.ID), count));
// Store away the voicemail information so we can play it directly.
if (callType == Calls.VOICEMAIL_TYPE) {
String voicemailUri = c.getString(CallLogQuery.VOICEMAIL_URI);
@@ -907,6 +920,7 @@
mAdapter = new CallLogAdapter(getActivity(), mCallLogQueryHandler, currentCountryIso,
getVoiceMailNumber());
setListAdapter(mAdapter);
+ getListView().setItemsCanFocus(true);
}
@Override
@@ -1101,38 +1115,6 @@
}
}
- @Override
- public void onListItemClick(ListView l, View v, int position, long id) {
- Cursor cursor = (Cursor) mAdapter.getItem(position);
- if (CallLogQuery.isSectionHeader(cursor)) {
- // Do nothing when a header is clicked.
- return;
- }
- Intent intent = new Intent(getActivity(), CallDetailActivity.class);
- if (mAdapter.isGroupHeader(position)) {
- // We want to restore the position in the cursor at the end.
- int currentPosition = cursor.getPosition();
- int groupSize = mAdapter.getGroupSize(position);
- long[] ids = new long[groupSize];
- // Copy the ids of the rows in the group.
- for (int index = 0; index < groupSize; ++index) {
- ids[index] = cursor.getLong(CallLogQuery.ID);
- cursor.moveToNext();
- }
- intent.putExtra(CallDetailActivity.EXTRA_CALL_LOG_IDS, ids);
- cursor.moveToPosition(currentPosition);
- } else {
- // If there is a single item, use the direct URI for it.
- intent.setData(ContentUris.withAppendedId(Calls.CONTENT_URI_WITH_VOICEMAIL, id));
- String voicemailUri = cursor.getString(CallLogQuery.VOICEMAIL_URI);
- if (voicemailUri != null) {
- intent.putExtra(CallDetailActivity.EXTRA_VOICEMAIL_URI, Uri.parse(voicemailUri));
- }
- intent.putExtra(CallDetailActivity.EXTRA_VOICEMAIL_START_PLAYBACK, false);
- }
- startActivity(intent);
- }
-
@VisibleForTesting
public CallLogAdapter getAdapter() {
return mAdapter;
diff --git a/src/com/android/contacts/calllog/CallLogListItemViews.java b/src/com/android/contacts/calllog/CallLogListItemViews.java
index 040d0ad..fbf91cc 100644
--- a/src/com/android/contacts/calllog/CallLogListItemViews.java
+++ b/src/com/android/contacts/calllog/CallLogListItemViews.java
@@ -31,6 +31,8 @@
public final class CallLogListItemViews {
/** The quick contact badge for the contact. */
public final QuickContactBadge quickContactView;
+ /** The primary action view of the entry. */
+ public final View primaryActionView;
/** The secondary action button on the entry. */
public final ImageView secondaryActionView;
/** The icon used for unheard voicemail. */
@@ -44,11 +46,12 @@
/** The text of the header in a stand-alone row, or null for other types of rows. */
public final TextView listHeaderTextView;
- private CallLogListItemViews(QuickContactBadge quickContactView,
+ private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView,
ImageView secondaryActionView, View unheardView, View dividerView,
PhoneCallDetailsViews phoneCallDetailsViews, View listItemView,
TextView listHeaderTextView) {
this.quickContactView = quickContactView;
+ this.primaryActionView = primaryActionView;
this.secondaryActionView = secondaryActionView;
this.unheardView = unheardView;
this.dividerView = dividerView;
@@ -60,6 +63,7 @@
public static CallLogListItemViews fromView(View view) {
return new CallLogListItemViews(
(QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
+ view.findViewById(R.id.primary_action_view),
(ImageView) view.findViewById(R.id.secondary_action_icon),
view.findViewById(R.id.unheard_icon),
view.findViewById(R.id.divider),
@@ -71,6 +75,7 @@
public static CallLogListItemViews createForTest(Context context) {
return new CallLogListItemViews(
new QuickContactBadge(context),
+ new View(context),
new ImageView(context),
new View(context),
new View(context),
diff --git a/src/com/android/contacts/calllog/IntentProvider.java b/src/com/android/contacts/calllog/IntentProvider.java
index 035d90a..8173238 100644
--- a/src/com/android/contacts/calllog/IntentProvider.java
+++ b/src/com/android/contacts/calllog/IntentProvider.java
@@ -17,10 +17,13 @@
package com.android.contacts.calllog;
import com.android.contacts.CallDetailActivity;
+import com.android.contacts.calllog.CallLogFragment.CallLogAdapter;
+import com.android.contacts.calllog.CallLogFragment.CallLogQuery;
import android.content.ContentUris;
import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.telephony.PhoneNumberUtils;
@@ -68,4 +71,41 @@
}
};
}
+
+ public static IntentProvider getCallDetailIntentProvider(
+ final CallLogAdapter adapter, final int position, final long id, final int groupSize) {
+ return new IntentProvider() {
+ @Override
+ public Intent getIntent(Context context) {
+ Cursor cursor = adapter.getCursor();
+ cursor.moveToPosition(position);
+ if (CallLogQuery.isSectionHeader(cursor)) {
+ // Do nothing when a header is clicked.
+ return null;
+ }
+ Intent intent = new Intent(context, CallDetailActivity.class);
+ if (adapter.isGroupHeader(position)) {
+ // We want to restore the position in the cursor at the end.
+ long[] ids = new long[groupSize];
+ // Copy the ids of the rows in the group.
+ for (int index = 0; index < groupSize; ++index) {
+ ids[index] = cursor.getLong(CallLogQuery.ID);
+ cursor.moveToNext();
+ }
+ intent.putExtra(CallDetailActivity.EXTRA_CALL_LOG_IDS, ids);
+ } else {
+ // If there is a single item, use the direct URI for it.
+ intent.setData(ContentUris.withAppendedId(
+ Calls.CONTENT_URI_WITH_VOICEMAIL, id));
+ String voicemailUri = cursor.getString(CallLogQuery.VOICEMAIL_URI);
+ if (voicemailUri != null) {
+ intent.putExtra(CallDetailActivity.EXTRA_VOICEMAIL_URI,
+ Uri.parse(voicemailUri));
+ }
+ intent.putExtra(CallDetailActivity.EXTRA_VOICEMAIL_START_PLAYBACK, false);
+ }
+ return intent;
+ }
+ };
+ }
}