• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import com.android.dialer.widget.BidiTextView;
25 
26 /** Encapsulates the views that are used to display the details of a phone call in the call log. */
27 public final class PhoneCallDetailsViews {
28 
29   public final BidiTextView nameView;
30   public final View callTypeView;
31   public final CallTypeIconsView callTypeIcons;
32   public final TextView callLocationAndDate;
33   public final View transcriptionView;
34   public final TextView voicemailTranscriptionView;
35   public final TextView voicemailTranscriptionBrandingView;
36   public final View voicemailTranscriptionRatingView;
37   public final TextView callAccountLabel;
38 
PhoneCallDetailsViews( BidiTextView nameView, View callTypeView, CallTypeIconsView callTypeIcons, TextView callLocationAndDate, View transcriptionView, TextView voicemailTranscriptionView, TextView voicemailTranscriptionBrandingView, View voicemailTranscriptionRatingView, TextView callAccountLabel)39   private PhoneCallDetailsViews(
40       BidiTextView nameView,
41       View callTypeView,
42       CallTypeIconsView callTypeIcons,
43       TextView callLocationAndDate,
44       View transcriptionView,
45       TextView voicemailTranscriptionView,
46       TextView voicemailTranscriptionBrandingView,
47       View voicemailTranscriptionRatingView,
48       TextView callAccountLabel) {
49     this.nameView = nameView;
50     this.callTypeView = callTypeView;
51     this.callTypeIcons = callTypeIcons;
52     this.callLocationAndDate = callLocationAndDate;
53     this.transcriptionView = transcriptionView;
54     this.voicemailTranscriptionView = voicemailTranscriptionView;
55     this.voicemailTranscriptionBrandingView = voicemailTranscriptionBrandingView;
56     this.voicemailTranscriptionRatingView = voicemailTranscriptionRatingView;
57     this.callAccountLabel = callAccountLabel;
58   }
59 
60   /**
61    * Create a new instance by extracting the elements from the given view.
62    *
63    * <p>The view should contain three text views with identifiers {@code R.id.name}, {@code
64    * R.id.date}, and {@code R.id.number}, and a linear layout with identifier {@code
65    * R.id.call_types}.
66    */
fromView(View view)67   public static PhoneCallDetailsViews fromView(View view) {
68     return new PhoneCallDetailsViews(
69         (BidiTextView) view.findViewById(R.id.name),
70         view.findViewById(R.id.call_type),
71         (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
72         (TextView) view.findViewById(R.id.call_location_and_date),
73         view.findViewById(R.id.transcription),
74         (TextView) view.findViewById(R.id.voicemail_transcription),
75         (TextView) view.findViewById(R.id.voicemail_transcription_branding),
76         view.findViewById(R.id.voicemail_transcription_rating),
77         (TextView) view.findViewById(R.id.call_account_label));
78   }
79 
createForTest(Context context)80   public static PhoneCallDetailsViews createForTest(Context context) {
81     return new PhoneCallDetailsViews(
82         new BidiTextView(context),
83         new View(context),
84         new CallTypeIconsView(context),
85         new TextView(context),
86         new View(context),
87         new TextView(context),
88         new TextView(context),
89         new View(context),
90         new TextView(context));
91   }
92 }
93