blob: c07e3370f5375c3cb9a831953dc4e748d71d778f [file] [log] [blame]
Flavio Lerdaa024c3f2011-06-10 10:47:07 +01001/*
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.contacts;
18
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070019import com.android.contacts.calllog.CallTypeIconsView;
20
Flavio Lerda40569562011-07-22 21:51:29 +010021import android.content.Context;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010022import android.view.View;
23import android.widget.TextView;
24
25/**
26 * Encapsulates the views that are used to display the details of a phone call in the call log.
27 */
28public final class PhoneCallDetailsViews {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010029 public final TextView nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010030 public final View callTypeView;
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070031 public final CallTypeIconsView callTypeIcons;
Flavio Lerda4586feb2011-07-09 17:03:48 +010032 public final TextView callTypeText;
33 public final View callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010034 public final TextView dateView;
35 public final TextView numberView;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010036
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070037 private PhoneCallDetailsViews(TextView nameView, View callTypeView,
38 CallTypeIconsView callTypeIcons, TextView callTypeText, View callTypeSeparator,
39 TextView dateView, TextView numberView) {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010040 this.nameView = nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010041 this.callTypeView = callTypeView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010042 this.callTypeIcons = callTypeIcons;
43 this.callTypeText = callTypeText;
44 this.callTypeSeparator = callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010045 this.dateView = dateView;
46 this.numberView = numberView;
Flavio Lerda696e8132011-07-05 19:00:23 +010047 }
48
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010049 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010050 * Create a new instance by extracting the elements from the given view.
51 * <p>
52 * The view should contain three text views with identifiers {@code R.id.name},
Flavio Lerda7d7473a2011-07-06 14:21:46 +010053 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
54 * {@code R.id.call_types}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010055 */
Flavio Lerda696e8132011-07-05 19:00:23 +010056 public static PhoneCallDetailsViews fromView(View view) {
57 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
Flavio Lerda40569562011-07-22 21:51:29 +010058 view.findViewById(R.id.call_type),
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070059 (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
Flavio Lerda4586feb2011-07-09 17:03:48 +010060 (TextView) view.findViewById(R.id.call_type_name),
61 view.findViewById(R.id.call_type_separator),
Flavio Lerda7d7473a2011-07-06 14:21:46 +010062 (TextView) view.findViewById(R.id.date),
Flavio Lerda696e8132011-07-05 19:00:23 +010063 (TextView) view.findViewById(R.id.number));
64 }
65
Flavio Lerda40569562011-07-22 21:51:29 +010066 public static PhoneCallDetailsViews createForTest(Context context) {
67 return new PhoneCallDetailsViews(
68 new TextView(context),
69 new View(context),
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070070 new CallTypeIconsView(context),
Flavio Lerda40569562011-07-22 21:51:29 +010071 new TextView(context),
72 new View(context),
73 new TextView(context),
74 new TextView(context));
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010075 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010076}