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 button on the entry. */ 38 public final ImageView secondaryActionView; 39 /** The details of the phone call. */ 40 public final PhoneCallDetailsViews phoneCallDetailsViews; 41 /** The text of the header of a section. */ 42 public final TextView listHeaderTextView; 43 44 private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, 45 ImageView secondaryActionView, PhoneCallDetailsViews phoneCallDetailsViews, 46 TextView listHeaderTextView) { 47 this.quickContactView = quickContactView; 48 this.primaryActionView = primaryActionView; 49 this.secondaryActionView = secondaryActionView; 50 this.phoneCallDetailsViews = phoneCallDetailsViews; 51 this.listHeaderTextView = listHeaderTextView; 52 } 53 54 public static CallLogListItemViews fromView(View view) { 55 return new CallLogListItemViews( 56 (QuickContactBadge) view.findViewById(R.id.quick_contact_photo), 57 view.findViewById(R.id.primary_action_view), 58 (ImageView) view.findViewById(R.id.secondary_action_icon), 59 PhoneCallDetailsViews.fromView(view), 60 (TextView) view.findViewById(R.id.call_log_header)); 61 } 62 63 @NeededForTesting 64 public static CallLogListItemViews createForTest(Context context) { 65 return new CallLogListItemViews( 66 new QuickContactBadge(context), 67 new View(context), 68 new ImageView(context), 69 PhoneCallDetailsViews.createForTest(context), 70 new TextView(context)); 71 } 72 } 73