194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/* 294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Copyright (C) 2011 The Android Open Source Project 394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * you may not use this file except in compliance with the License. 694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * You may obtain a copy of the License at 794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 1094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Unless required by applicable law or agreed to in writing, software 1194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * See the License for the specific language governing permissions and 1494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * limitations under the License. 1594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 1694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpackage com.android.dialer; 1894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.Context; 2094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.view.View; 2187ba489564b25d4a64c9faaeafea46e2f72d8933Nancy Chenimport android.widget.ImageView; 2294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.widget.TextView; 2394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 2494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport com.android.dialer.calllog.CallTypeIconsView; 2594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 2694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/** 2794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Encapsulates the views that are used to display the details of a phone call in the call log. 2894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 2994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpublic final class PhoneCallDetailsViews { 3094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public final TextView nameView; 3194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public final View callTypeView; 3294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public final CallTypeIconsView callTypeIcons; 331d1bd0da0b32a5b8cb1c7c5585acccb180b19849Ihab Awad public final ImageView callAccountIcon; 34146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn public final TextView callLocationAndDate; 35146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn public final TextView voicemailTranscriptionView; 3694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 3794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng private PhoneCallDetailsViews(TextView nameView, View callTypeView, 381d1bd0da0b32a5b8cb1c7c5585acccb180b19849Ihab Awad CallTypeIconsView callTypeIcons, ImageView callAccountIcon, 3987ba489564b25d4a64c9faaeafea46e2f72d8933Nancy Chen TextView callLocationAndDate, TextView voicemailTranscriptionView) { 4094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng this.nameView = nameView; 4194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng this.callTypeView = callTypeView; 4294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng this.callTypeIcons = callTypeIcons; 431d1bd0da0b32a5b8cb1c7c5585acccb180b19849Ihab Awad this.callAccountIcon = callAccountIcon; 44146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn this.callLocationAndDate = callLocationAndDate; 45146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn this.voicemailTranscriptionView = voicemailTranscriptionView; 4694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 4794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 4894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 4994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Create a new instance by extracting the elements from the given view. 5094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * <p> 5194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * The view should contain three text views with identifiers {@code R.id.name}, 5294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier 5394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * {@code R.id.call_types}. 5494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 5594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public static PhoneCallDetailsViews fromView(View view) { 5694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), 5794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng view.findViewById(R.id.call_type), 5894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng (CallTypeIconsView) view.findViewById(R.id.call_type_icons), 591d1bd0da0b32a5b8cb1c7c5585acccb180b19849Ihab Awad (ImageView) view.findViewById(R.id.call_account_icon), 60146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn (TextView) view.findViewById(R.id.call_location_and_date), 61146a4cdf57f0d4d0cd85e808f1df2bdea639b24cTyler Gunn (TextView) view.findViewById(R.id.voicemail_transcription)); 6294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 6394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 6494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public static PhoneCallDetailsViews createForTest(Context context) { 6594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return new PhoneCallDetailsViews( 6694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng new TextView(context), 6794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng new View(context), 6894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng new CallTypeIconsView(context), 6987ba489564b25d4a64c9faaeafea46e2f72d8933Nancy Chen new ImageView(context), 7094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng new TextView(context), 7194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng new TextView(context)); 7294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 7394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng} 74