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; 18 19 import com.android.contacts.calllog.CallTypeIconsView; 20 21 import android.content.Context; 22 import android.view.View; 23 import android.widget.TextView; 24 25 /** 26 * Encapsulates the views that are used to display the details of a phone call in the call log. 27 */ 28 public final class PhoneCallDetailsViews { 29 public final TextView nameView; 30 public final View callTypeView; 31 public final CallTypeIconsView callTypeIcons; 32 public final TextView callTypeAndDate; 33 public final TextView numberView; 34 public final TextView labelView; 35 PhoneCallDetailsViews(TextView nameView, View callTypeView, CallTypeIconsView callTypeIcons, TextView callTypeAndDate, TextView numberView, TextView labelView)36 private PhoneCallDetailsViews(TextView nameView, View callTypeView, 37 CallTypeIconsView callTypeIcons, TextView callTypeAndDate, TextView numberView, 38 TextView labelView) { 39 this.nameView = nameView; 40 this.callTypeView = callTypeView; 41 this.callTypeIcons = callTypeIcons; 42 this.callTypeAndDate = callTypeAndDate; 43 this.numberView = numberView; 44 this.labelView = labelView; 45 } 46 47 /** 48 * Create a new instance by extracting the elements from the given view. 49 * <p> 50 * The view should contain three text views with identifiers {@code R.id.name}, 51 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier 52 * {@code R.id.call_types}. 53 */ fromView(View view)54 public static PhoneCallDetailsViews fromView(View view) { 55 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), 56 view.findViewById(R.id.call_type), 57 (CallTypeIconsView) view.findViewById(R.id.call_type_icons), 58 (TextView) view.findViewById(R.id.call_count_and_date), 59 (TextView) view.findViewById(R.id.number), 60 (TextView) view.findViewById(R.id.label)); 61 } 62 createForTest(Context context)63 public static PhoneCallDetailsViews createForTest(Context context) { 64 return new PhoneCallDetailsViews( 65 new TextView(context), 66 new View(context), 67 new CallTypeIconsView(context), 68 new TextView(context), 69 new TextView(context), 70 new TextView(context)); 71 } 72 } 73