blob: 19e931fd97b4685ed2d9214fab486cd6be594e77 [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
Flavio Lerda40569562011-07-22 21:51:29 +010019import android.content.Context;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010020import android.view.View;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010021import android.widget.LinearLayout;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010022import android.widget.TextView;
23
24/**
25 * Encapsulates the views that are used to display the details of a phone call in the call log.
26 */
27public final class PhoneCallDetailsViews {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010028 public final TextView nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010029 public final View callTypeView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010030 public final LinearLayout callTypeIcons;
31 public final TextView callTypeText;
32 public final View callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010033 public final TextView dateView;
34 public final TextView numberView;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010035
Flavio Lerda40569562011-07-22 21:51:29 +010036 private PhoneCallDetailsViews(TextView nameView, View callTypeView, LinearLayout callTypeIcons,
Flavio Lerda4586feb2011-07-09 17:03:48 +010037 TextView callTypeText, View callTypeSeparator, TextView dateView, TextView numberView) {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010038 this.nameView = nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010039 this.callTypeView = callTypeView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010040 this.callTypeIcons = callTypeIcons;
41 this.callTypeText = callTypeText;
42 this.callTypeSeparator = callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010043 this.dateView = dateView;
44 this.numberView = numberView;
Flavio Lerda696e8132011-07-05 19:00:23 +010045 }
46
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010047 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010048 * Create a new instance by extracting the elements from the given view.
49 * <p>
50 * The view should contain three text views with identifiers {@code R.id.name},
Flavio Lerda7d7473a2011-07-06 14:21:46 +010051 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
52 * {@code R.id.call_types}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010053 */
Flavio Lerda696e8132011-07-05 19:00:23 +010054 public static PhoneCallDetailsViews fromView(View view) {
55 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
Flavio Lerda40569562011-07-22 21:51:29 +010056 view.findViewById(R.id.call_type),
Flavio Lerda4586feb2011-07-09 17:03:48 +010057 (LinearLayout) view.findViewById(R.id.call_type_icons),
58 (TextView) view.findViewById(R.id.call_type_name),
59 view.findViewById(R.id.call_type_separator),
Flavio Lerda7d7473a2011-07-06 14:21:46 +010060 (TextView) view.findViewById(R.id.date),
Flavio Lerda696e8132011-07-05 19:00:23 +010061 (TextView) view.findViewById(R.id.number));
62 }
63
Flavio Lerda40569562011-07-22 21:51:29 +010064 public static PhoneCallDetailsViews createForTest(Context context) {
65 return new PhoneCallDetailsViews(
66 new TextView(context),
67 new View(context),
68 new LinearLayout(context),
69 new TextView(context),
70 new View(context),
71 new TextView(context),
72 new TextView(context));
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010073 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010074}