1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dialer.calllog; 18 19 import android.content.Context; 20 import android.view.View; 21 import android.widget.ImageView; 22 import android.widget.QuickContactBadge; 23 import android.widget.TextView; 24 25 import com.android.contacts.common.test.NeededForTesting; 26 import com.android.dialer.PhoneCallDetailsViews; 27 import com.android.dialer.R; 28 29 /** 30 * Simple value object containing the various views within a call log entry. 31 */ 32 public final class CallLogListItemViews { 33 /** The quick contact badge for the contact. */ 34 public final QuickContactBadge quickContactView; 35 /** The primary action view of the entry. */ 36 public final View primaryActionView; 37 /** The secondary action view, which includes both the vertical divider line and 38 * the action button itself. Used so that the button and divider line can be 39 * made visible/hidden as a whole. */ 40 public final View secondaryActionView; 41 /** The secondary action button on the entry. */ 42 public final ImageView secondaryActionButtonView; 43 /** The details of the phone call. */ 44 public final PhoneCallDetailsViews phoneCallDetailsViews; 45 /** The text of the header of a section. */ 46 public final TextView listHeaderTextView; 47 48 private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, 49 View secondaryActionView, ImageView secondaryActionButtonView, 50 PhoneCallDetailsViews phoneCallDetailsViews, 51 TextView listHeaderTextView) { 52 this.quickContactView = quickContactView; 53 this.primaryActionView = primaryActionView; 54 this.secondaryActionView = secondaryActionView; 55 this.secondaryActionButtonView = secondaryActionButtonView; 56 this.phoneCallDetailsViews = phoneCallDetailsViews; 57 this.listHeaderTextView = listHeaderTextView; 58 } 59 60 public static CallLogListItemViews fromView(View view) { 61 return new CallLogListItemViews( 62 (QuickContactBadge) view.findViewById(R.id.quick_contact_photo), 63 view.findViewById(R.id.primary_action_view), 64 view.findViewById(R.id.secondary_action_view), 65 (ImageView) view.findViewById(R.id.secondary_action_icon), 66 PhoneCallDetailsViews.fromView(view), 67 (TextView) view.findViewById(R.id.call_log_header)); 68 } 69 70 @NeededForTesting 71 public static CallLogListItemViews createForTest(Context context) { 72 return new CallLogListItemViews( 73 new QuickContactBadge(context), 74 new View(context), 75 new View(context), 76 new ImageView(context), 77 PhoneCallDetailsViews.createForTest(context), 78 new TextView(context)); 79 } 80 } 81