blob: 7453af0bba6cb8087fec84988875796e18eb2701 [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 Lerdaa024c3f2011-06-10 10:47:07 +010019import android.view.View;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010020import android.widget.LinearLayout;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010021import android.widget.TextView;
22
23/**
24 * Encapsulates the views that are used to display the details of a phone call in the call log.
25 */
26public final class PhoneCallDetailsViews {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010027 public final TextView nameView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010028 public final LinearLayout callTypeIcons;
29 public final TextView callTypeText;
30 public final View callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010031 public final TextView dateView;
32 public final TextView numberView;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010033
Flavio Lerda4586feb2011-07-09 17:03:48 +010034 private PhoneCallDetailsViews(TextView nameView, LinearLayout callTypeIcons,
35 TextView callTypeText, View callTypeSeparator, TextView dateView, TextView numberView) {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010036 this.nameView = nameView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010037 this.callTypeIcons = callTypeIcons;
38 this.callTypeText = callTypeText;
39 this.callTypeSeparator = callTypeSeparator;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010040 this.dateView = dateView;
41 this.numberView = numberView;
Flavio Lerda696e8132011-07-05 19:00:23 +010042 }
43
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010044 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010045 * Create a new instance by extracting the elements from the given view.
46 * <p>
47 * The view should contain three text views with identifiers {@code R.id.name},
Flavio Lerda7d7473a2011-07-06 14:21:46 +010048 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
49 * {@code R.id.call_types}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010050 */
Flavio Lerda696e8132011-07-05 19:00:23 +010051 public static PhoneCallDetailsViews fromView(View view) {
52 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
Flavio Lerda4586feb2011-07-09 17:03:48 +010053 (LinearLayout) view.findViewById(R.id.call_type_icons),
54 (TextView) view.findViewById(R.id.call_type_name),
55 view.findViewById(R.id.call_type_separator),
Flavio Lerda7d7473a2011-07-06 14:21:46 +010056 (TextView) view.findViewById(R.id.date),
Flavio Lerda696e8132011-07-05 19:00:23 +010057 (TextView) view.findViewById(R.id.number));
58 }
59
60 public static PhoneCallDetailsViews createForTest(TextView nameView,
Flavio Lerda4586feb2011-07-09 17:03:48 +010061 LinearLayout callTypeIcons, TextView callTypeText, View callTypeSeparator,
62 TextView dateView, TextView numberView) {
63 return new PhoneCallDetailsViews(nameView, callTypeIcons, callTypeText, callTypeSeparator,
64 dateView, numberView);
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010065 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010066}