summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-03-31 19:19:17 -0700
committerAndrew Lee <anwlee@google.com>2015-03-31 19:20:03 -0700
commit25e732727f5bf2c38c40cd353b739742278940c1 (patch)
tree21a777bb3772eb0d4c642b62fe04fa7608c80b23 /src
parent1d519b3deaf38e76feb9f1891cd2bd20d969e11d (diff)
Move view expand logic to CallLogListItemViews.
Bug: 19372817 Change-Id: I92d9f001155d4a059c89bc4b00abcef4e817f32d
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java82
-rw-r--r--src/com/android/dialer/calllog/CallLogFragment.java4
-rw-r--r--src/com/android/dialer/calllog/CallLogListItemViews.java75
3 files changed, 95 insertions, 66 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index 173306882..d1a164acd 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -64,8 +64,6 @@ public class CallLogAdapter extends GroupingListAdapter
implements ViewTreeObserver.OnPreDrawListener, CallLogGroupBuilder.GroupCreator {
private static final String TAG = CallLogAdapter.class.getSimpleName();
- private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10;
-
/** The enumeration of {@link android.os.AsyncTask} objects used in this class. */
public enum Tasks {
REMOVE_CALL_LOG_ENTRIES,
@@ -257,9 +255,6 @@ public class CallLogAdapter extends GroupingListAdapter
/** Can be set to true by tests to disable processing of requests. */
private volatile boolean mRequestProcessingDisabled = false;
- private int mCallLogBackgroundColor;
- private int mExpandedBackgroundColor;
- private float mExpandedTranslationZ;
private int mPhotoSize;
/** Listener for the primary or secondary actions in the list.
@@ -349,9 +344,6 @@ public class CallLogAdapter extends GroupingListAdapter
Resources resources = mContext.getResources();
CallTypeHelper callTypeHelper = new CallTypeHelper(resources);
- mCallLogBackgroundColor = resources.getColor(R.color.background_dialer_list_items);
- mExpandedBackgroundColor = resources.getColor(R.color.call_log_expanded_background_color);
- mExpandedTranslationZ = resources.getDimension(R.dimen.call_log_expanded_translation_z);
mPhotoSize = resources.getDimensionPixelSize(R.dimen.contact_photo_size);
mContactPhotoManager = ContactPhotoManager.getInstance(mContext);
@@ -733,7 +725,12 @@ public class CallLogAdapter extends GroupingListAdapter
// Restore expansion state of the row on rebind. Inflate the actions ViewStub if required,
// and set its visibility state accordingly.
- expandOrCollapseActions(callLogItemView, isExpanded(rowId));
+ views.expandOrCollapseActions(
+ isExpanded(rowId),
+ mOnReportButtonClickListener,
+ mActionListener,
+ mPhoneNumberUtilsWrapper,
+ mCallLogViewsHelper);
if (TextUtils.isEmpty(name)) {
details = new PhoneCallDetails(number, numberPresentation, formattedNumber, countryIso,
@@ -845,54 +842,6 @@ public class CallLogAdapter extends GroupingListAdapter
}
}
- /**
- * Expands or collapses the view containing the CALLBACK/REDIAL, VOICEMAIL and DETAILS action
- * buttons.
- *
- * @param callLogItem The call log entry parent view.
- * @param isExpanded The new expansion state of the view.
- */
- private void expandOrCollapseActions(View callLogItem, boolean isExpanded) {
- final CallLogListItemViews views = (CallLogListItemViews) callLogItem.getTag();
-
- expandVoicemailTranscriptionView(views, isExpanded);
- if (isExpanded) {
- // Inflate the view stub if necessary, and wire up the event handlers.
- views.inflateActionViewStub(callLogItem, mOnReportButtonClickListener, mActionListener,
- mPhoneNumberUtilsWrapper, mCallLogViewsHelper);
-
- views.actionsView.setVisibility(View.VISIBLE);
- views.actionsView.setAlpha(1.0f);
- views.callLogEntryView.setBackgroundColor(mExpandedBackgroundColor);
- views.callLogEntryView.setTranslationZ(mExpandedTranslationZ);
- callLogItem.setTranslationZ(mExpandedTranslationZ); // WAR
- } else {
- // When recycling a view, it is possible the actionsView ViewStub was previously
- // inflated so we should hide it in this case.
- if (views.actionsView != null) {
- views.actionsView.setVisibility(View.GONE);
- }
-
- views.callLogEntryView.setBackgroundColor(mCallLogBackgroundColor);
- views.callLogEntryView.setTranslationZ(0);
- callLogItem.setTranslationZ(0); // WAR
- }
- }
-
- public static void expandVoicemailTranscriptionView(CallLogListItemViews views,
- boolean isExpanded) {
- if (views.callType != Calls.VOICEMAIL_TYPE) {
- return;
- }
-
- final TextView view = views.phoneCallDetailsViews.voicemailTranscriptionView;
- if (TextUtils.isEmpty(view.getText())) {
- return;
- }
- view.setMaxLines(isExpanded ? VOICEMAIL_TRANSCRIPTION_MAX_LINES : 1);
- view.setSingleLine(!isExpanded);
- }
-
/** Checks whether the contact info from the call log matches the one from the contacts db. */
private boolean callLogInfoMatches(ContactInfo callLogInfo, ContactInfo info) {
// The call log only contains a subset of the fields in the contacts db.
@@ -1070,7 +1019,7 @@ public class CallLogAdapter extends GroupingListAdapter
void bindViewForTest(View view, Context context, Cursor cursor) {
bindStandAloneView(view, context, cursor);
CallLogListItemViews views = CallLogListItemViews.fromView(context, view);
- views.inflateActionViewStub(view, mOnReportButtonClickListener, mActionListener,
+ views.inflateActionViewStub(mOnReportButtonClickListener, mActionListener,
mPhoneNumberUtilsWrapper, mCallLogViewsHelper);
}
@@ -1172,7 +1121,12 @@ public class CallLogAdapter extends GroupingListAdapter
boolean expanded = toggleExpansion(views.rowId);
// Trigger loading of the viewstub and visual expand or collapse.
- expandOrCollapseActions(view, expanded);
+ views.expandOrCollapseActions(
+ expanded,
+ mOnReportButtonClickListener,
+ mActionListener,
+ mPhoneNumberUtilsWrapper,
+ mCallLogViewsHelper);
// Animate the expansion or collapse.
if (mCallItemExpandedListener != null) {
@@ -1182,11 +1136,15 @@ public class CallLogAdapter extends GroupingListAdapter
// Animate the collapse of the previous item if it is still visible on screen.
if (mPreviouslyExpanded != NONE_EXPANDED) {
- View previousItem = mCallItemExpandedListener.getViewForCallId(
- mPreviouslyExpanded);
+ View previousItem = mCallItemExpandedListener.getViewForCallId(mPreviouslyExpanded);
if (previousItem != null) {
- expandOrCollapseActions(previousItem, false);
+ ((CallLogListItemViews) previousItem.getTag()).expandOrCollapseActions(
+ false /* isExpanded */,
+ mOnReportButtonClickListener,
+ mActionListener,
+ mPhoneNumberUtilsWrapper,
+ mCallLogViewsHelper);
if (animate) {
mCallItemExpandedListener.onItemExpanded(previousItem);
}
diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java
index c4e453c33..7b5907c1f 100644
--- a/src/com/android/dialer/calllog/CallLogFragment.java
+++ b/src/com/android/dialer/calllog/CallLogFragment.java
@@ -556,7 +556,7 @@ public class CallLogFragment extends ListFragment
if (!isExpand) {
viewHolder.actionsView.setVisibility(View.VISIBLE);
}
- CallLogAdapter.expandVoicemailTranscriptionView(viewHolder, !isExpand);
+ viewHolder.expandVoicemailTranscriptionView(!isExpand);
// Set up the fade effect for the action buttons.
if (isExpand) {
@@ -625,7 +625,7 @@ public class CallLogFragment extends ListFragment
// is defaulting to the value (0) at the start of the expand animation.
viewHolder.actionsView.setAlpha(1);
}
- CallLogAdapter.expandVoicemailTranscriptionView(viewHolder, isExpand);
+ viewHolder.expandVoicemailTranscriptionView(isExpand);
}
});
diff --git a/src/com/android/dialer/calllog/CallLogListItemViews.java b/src/com/android/dialer/calllog/CallLogListItemViews.java
index b9a76a877..427732e0a 100644
--- a/src/com/android/dialer/calllog/CallLogListItemViews.java
+++ b/src/com/android/dialer/calllog/CallLogListItemViews.java
@@ -17,8 +17,10 @@
package com.android.dialer.calllog;
import android.content.Context;
+import android.content.res.Resources;
import android.provider.CallLog.Calls;
import android.telecom.PhoneAccountHandle;
+import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
@@ -40,6 +42,8 @@ import com.android.dialer.R;
* if the call log list item is eventually represented as a UI component.
*/
public final class CallLogListItemViews {
+ /** The root view of the call log list item */
+ public final View rootView;
/** The quick contact badge for the contact. */
public final QuickContactBadge quickContactView;
/** The primary action view of the entry. */
@@ -123,10 +127,17 @@ public final class CallLogListItemViews {
*/
public boolean canBeReportedAsInvalid;
+ private static final int VOICEMAIL_TRANSCRIPTION_MAX_LINES = 10;
+
private Context mContext;
+ private int mCallLogBackgroundColor;
+ private int mExpandedBackgroundColor;
+ private float mExpandedTranslationZ;
+
private CallLogListItemViews(
Context context,
+ View rootView,
QuickContactBadge quickContactView,
View primaryActionView,
PhoneCallDetailsViews phoneCallDetailsViews,
@@ -134,11 +145,17 @@ public final class CallLogListItemViews {
TextView dayGroupHeader) {
mContext = context;
+ this.rootView = rootView;
this.quickContactView = quickContactView;
this.primaryActionView = primaryActionView;
this.phoneCallDetailsViews = phoneCallDetailsViews;
this.callLogEntryView = callLogEntryView;
this.dayGroupHeader = dayGroupHeader;
+
+ Resources resources = mContext.getResources();
+ mCallLogBackgroundColor = resources.getColor(R.color.background_dialer_list_items);
+ mExpandedBackgroundColor = resources.getColor(R.color.call_log_expanded_background_color);
+ mExpandedTranslationZ = resources.getDimension(R.dimen.call_log_expanded_translation_z);
}
/**
@@ -149,12 +166,11 @@ public final class CallLogListItemViews {
* @param callLogItem The call log list item view.
*/
public void inflateActionViewStub(
- final View callLogItem,
final CallLogAdapter.OnReportButtonClickListener onReportButtonClickListener,
View.OnClickListener actionListener,
PhoneNumberUtilsWrapper phoneNumberUtilsWrapper,
CallLogListItemHelper callLogViewsHelper) {
- ViewStub stub = (ViewStub) callLogItem.findViewById(R.id.call_log_entry_actions_stub);
+ ViewStub stub = (ViewStub) rootView.findViewById(R.id.call_log_entry_actions_stub);
if (stub != null) {
actionsView = (ViewGroup) stub.inflate();
}
@@ -266,9 +282,63 @@ public final class CallLogListItemViews {
callLogViewsHelper.setActionContentDescriptions(this);
}
+ /**
+ * Expands or collapses the view containing the CALLBACK/REDIAL, VOICEMAIL and DETAILS action
+ * buttons.
+ *
+ * TODO: Reduce number of classes which need to be passed in to inflate the action view stub.
+ * 1) Instantiate them in this class, and store local references.
+ * 2) Set them on the CallLogListItemHelper and use it for inflation.
+ * 3) Implement a parent view for a call log list item, and store references in that class.
+ */
+ public void expandOrCollapseActions(
+ boolean isExpanded,
+ final CallLogAdapter.OnReportButtonClickListener onReportButtonClickListener,
+ View.OnClickListener actionListener,
+ PhoneNumberUtilsWrapper phoneNumberUtilsWrapper,
+ CallLogListItemHelper callLogViewsHelper) {
+ expandVoicemailTranscriptionView(isExpanded);
+
+ if (isExpanded) {
+ // Inflate the view stub if necessary, and wire up the event handlers.
+ inflateActionViewStub(onReportButtonClickListener, actionListener,
+ phoneNumberUtilsWrapper, callLogViewsHelper);
+
+ actionsView.setVisibility(View.VISIBLE);
+ actionsView.setAlpha(1.0f);
+ callLogEntryView.setBackgroundColor(mExpandedBackgroundColor);
+ callLogEntryView.setTranslationZ(mExpandedTranslationZ);
+ rootView.setTranslationZ(mExpandedTranslationZ); // WAR
+ } else {
+ // When recycling a view, it is possible the actionsView ViewStub was previously
+ // inflated so we should hide it in this case.
+ if (actionsView != null) {
+ actionsView.setVisibility(View.GONE);
+ }
+
+ callLogEntryView.setBackgroundColor(mCallLogBackgroundColor);
+ callLogEntryView.setTranslationZ(0);
+ rootView.setTranslationZ(0); // WAR
+ }
+ }
+
+ public void expandVoicemailTranscriptionView(boolean isExpanded) {
+ if (callType != Calls.VOICEMAIL_TYPE) {
+ return;
+ }
+
+ final TextView view = phoneCallDetailsViews.voicemailTranscriptionView;
+ if (TextUtils.isEmpty(view.getText())) {
+ return;
+ }
+ view.setMaxLines(isExpanded ? VOICEMAIL_TRANSCRIPTION_MAX_LINES : 1);
+ view.setSingleLine(!isExpanded);
+ }
+
public static CallLogListItemViews fromView(Context context, View view) {
return new CallLogListItemViews(
context,
+ view,
(QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
view.findViewById(R.id.primary_action_view),
PhoneCallDetailsViews.fromView(view),
@@ -280,6 +350,7 @@ public final class CallLogListItemViews {
public static CallLogListItemViews createForTest(Context context) {
CallLogListItemViews views = new CallLogListItemViews(
context,
+ new View(context),
new QuickContactBadge(context),
new View(context),
PhoneCallDetailsViews.createForTest(context),