blob: c2819c30fc9ddc7f4c19cc04beb0c5cb03176935 [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;
20import android.widget.TextView;
21
22/**
23 * Encapsulates the views that are used to display the details of a phone call in the call log.
24 */
25public final class PhoneCallDetailsViews {
26 public final TextView mNameView;
27 public final TextView mCallTypeAndDateView;
28 public final TextView mNumberView;
29
Flavio Lerda696e8132011-07-05 19:00:23 +010030 private PhoneCallDetailsViews(TextView nameView, TextView callTypeAndDateView,
31 TextView numberView) {
32 mNameView = nameView;
33 mCallTypeAndDateView = callTypeAndDateView;
34 mNumberView = numberView;
35 }
36
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010037 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010038 * Create a new instance by extracting the elements from the given view.
39 * <p>
40 * The view should contain three text views with identifiers {@code R.id.name},
41 * {@code R.id.call_type}, and {@code R.id.number}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010042 */
Flavio Lerda696e8132011-07-05 19:00:23 +010043 public static PhoneCallDetailsViews fromView(View view) {
44 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
45 (TextView) view.findViewById(R.id.call_type),
46 (TextView) view.findViewById(R.id.number));
47 }
48
49 public static PhoneCallDetailsViews createForTest(TextView nameView,
50 TextView callTypeAndDateView, TextView numberView) {
51 return new PhoneCallDetailsViews(nameView, callTypeAndDateView, numberView);
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010052 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010053}