• 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.contacts.calllog;
18 
19 import com.android.contacts.PhoneCallDetailsViews;
20 import com.android.contacts.R;
21 import com.android.contacts.test.NeededForTesting;
22 
23 import android.content.Context;
24 import android.view.View;
25 import android.widget.ImageView;
26 import android.widget.QuickContactBadge;
27 import android.widget.TextView;
28 
29 /**
30  * Simple value object containing the various views within a call log entry.
31  */
32 public final class CallLogListItemViews {
33     /** The quick contact badge for the contact. */
34     public final QuickContactBadge quickContactView;
35     /** The primary action view of the entry. */
36     public final View primaryActionView;
37     /** The secondary action button on the entry. */
38     public final ImageView secondaryActionView;
39     /** The divider between the primary and secondary actions. */
40     public final View dividerView;
41     /** The details of the phone call. */
42     public final PhoneCallDetailsViews phoneCallDetailsViews;
43     /** The text of the header of a section. */
44     public final TextView listHeaderTextView;
45     /** The divider to be shown below items. */
46     public final View bottomDivider;
47 
CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView, ImageView secondaryActionView, View dividerView, PhoneCallDetailsViews phoneCallDetailsViews, TextView listHeaderTextView, View bottomDivider)48     private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView,
49             ImageView secondaryActionView, View dividerView,
50             PhoneCallDetailsViews phoneCallDetailsViews,
51             TextView listHeaderTextView, View bottomDivider) {
52         this.quickContactView = quickContactView;
53         this.primaryActionView = primaryActionView;
54         this.secondaryActionView = secondaryActionView;
55         this.dividerView = dividerView;
56         this.phoneCallDetailsViews = phoneCallDetailsViews;
57         this.listHeaderTextView = listHeaderTextView;
58         this.bottomDivider = bottomDivider;
59     }
60 
fromView(View view)61     public static CallLogListItemViews fromView(View view) {
62         return new CallLogListItemViews(
63                 (QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
64                 view.findViewById(R.id.primary_action_view),
65                 (ImageView) view.findViewById(R.id.secondary_action_icon),
66                 view.findViewById(R.id.divider),
67                 PhoneCallDetailsViews.fromView(view),
68                 (TextView) view.findViewById(R.id.call_log_header),
69                 view.findViewById(R.id.call_log_divider));
70     }
71 
72     @NeededForTesting
createForTest(Context context)73     public static CallLogListItemViews createForTest(Context context) {
74         return new CallLogListItemViews(
75                 new QuickContactBadge(context),
76                 new View(context),
77                 new ImageView(context),
78                 new View(context),
79                 PhoneCallDetailsViews.createForTest(context),
80                 new TextView(context),
81                 new View(context));
82     }
83 }
84