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