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