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