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.contacts.calllog; 18 19 import com.android.contacts.PhoneCallDetailsViews; 20 import com.android.contacts.R; 21 22 import android.content.Context; 23 import android.view.View; 24 import android.widget.ImageView; 25 import android.widget.QuickContactBadge; 26 import android.widget.TextView; 27 28 /** 29 * Simple value object containing the various views within a call log entry. 30 */ 31 public final class CallLogListItemViews { 32 /** The quick contact badge for the contact. */ 33 public final QuickContactBadge quickContactView; 34 /** The primary action view of the entry. */ 35 public final View primaryActionView; 36 /** The secondary action button on the entry. */ 37 public final ImageView secondaryActionView; 38 /** The divider between the primary and secondary actions. */ 39 public final View dividerView; 40 /** The details of the phone call. */ 41 public final PhoneCallDetailsViews phoneCallDetailsViews; 42 /** The text of the header of a section. */ 43 public final TextView listHeaderTextView; 44 /** The divider to be shown below items. */ 45 public final View bottomDivider; 46 47 private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, 48 ImageView secondaryActionView, View dividerView, 49 PhoneCallDetailsViews phoneCallDetailsViews, 50 TextView listHeaderTextView, View bottomDivider) { 51 this.quickContactView = quickContactView; 52 this.primaryActionView = primaryActionView; 53 this.secondaryActionView = secondaryActionView; 54 this.dividerView = dividerView; 55 this.phoneCallDetailsViews = phoneCallDetailsViews; 56 this.listHeaderTextView = listHeaderTextView; 57 this.bottomDivider = bottomDivider; 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 (ImageView) view.findViewById(R.id.secondary_action_icon), 65 view.findViewById(R.id.divider), 66 PhoneCallDetailsViews.fromView(view), 67 (TextView) view.findViewById(R.id.call_log_header), 68 view.findViewById(R.id.call_log_divider)); 69 } 70 71 public static CallLogListItemViews createForTest(Context context) { 72 return new CallLogListItemViews( 73 new QuickContactBadge(context), 74 new View(context), 75 new ImageView(context), 76 new View(context), 77 PhoneCallDetailsViews.createForTest(context), 78 new TextView(context), 79 new View(context)); 80 } 81 } 82