blob: 483ec6520ab73bcb8fac31c6d0da4d6f23af41c3 [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;
28 public final LinearLayout callTypesLayout;
29 public final TextView dateView;
30 public final TextView numberView;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010031
Flavio Lerda7d7473a2011-07-06 14:21:46 +010032 private PhoneCallDetailsViews(TextView nameView, LinearLayout callTypesLayout,
33 TextView dateView, TextView numberView) {
34 this.nameView = nameView;
35 this.callTypesLayout = callTypesLayout;
36 this.dateView = dateView;
37 this.numberView = numberView;
Flavio Lerda696e8132011-07-05 19:00:23 +010038 }
39
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010040 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010041 * Create a new instance by extracting the elements from the given view.
42 * <p>
43 * The view should contain three text views with identifiers {@code R.id.name},
Flavio Lerda7d7473a2011-07-06 14:21:46 +010044 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
45 * {@code R.id.call_types}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010046 */
Flavio Lerda696e8132011-07-05 19:00:23 +010047 public static PhoneCallDetailsViews fromView(View view) {
48 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
Flavio Lerda7d7473a2011-07-06 14:21:46 +010049 (LinearLayout) view.findViewById(R.id.call_types),
50 (TextView) view.findViewById(R.id.date),
Flavio Lerda696e8132011-07-05 19:00:23 +010051 (TextView) view.findViewById(R.id.number));
52 }
53
54 public static PhoneCallDetailsViews createForTest(TextView nameView,
Flavio Lerda7d7473a2011-07-06 14:21:46 +010055 LinearLayout callTypesLayout, TextView dateView, TextView numberView) {
56 return new PhoneCallDetailsViews(nameView, callTypesLayout, dateView, numberView);
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010057 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010058}