Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.contacts; |
| 18 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 19 | import android.view.View; |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 20 | import android.widget.LinearLayout; |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 21 | import 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 | */ |
| 26 | public final class PhoneCallDetailsViews { |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 27 | public final TextView nameView; |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 28 | public final LinearLayout callTypeIcons; |
| 29 | public final TextView callTypeText; |
| 30 | public final View callTypeSeparator; |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 31 | public final TextView dateView; |
| 32 | public final TextView numberView; |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 33 | |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 34 | private PhoneCallDetailsViews(TextView nameView, LinearLayout callTypeIcons, |
| 35 | TextView callTypeText, View callTypeSeparator, TextView dateView, TextView numberView) { |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 36 | this.nameView = nameView; |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 37 | this.callTypeIcons = callTypeIcons; |
| 38 | this.callTypeText = callTypeText; |
| 39 | this.callTypeSeparator = callTypeSeparator; |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 40 | this.dateView = dateView; |
| 41 | this.numberView = numberView; |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 42 | } |
| 43 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 44 | /** |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 45 | * 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 Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 48 | * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier |
| 49 | * {@code R.id.call_types}. |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 50 | */ |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 51 | public static PhoneCallDetailsViews fromView(View view) { |
| 52 | return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 53 | (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 Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 56 | (TextView) view.findViewById(R.id.date), |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 57 | (TextView) view.findViewById(R.id.number)); |
| 58 | } |
| 59 | |
| 60 | public static PhoneCallDetailsViews createForTest(TextView nameView, |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 61 | LinearLayout callTypeIcons, TextView callTypeText, View callTypeSeparator, |
| 62 | TextView dateView, TextView numberView) { |
| 63 | return new PhoneCallDetailsViews(nameView, callTypeIcons, callTypeText, callTypeSeparator, |
| 64 | dateView, numberView); |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 65 | } |
Flavio Lerda | afb93bb | 2011-07-05 14:46:10 +0100 | [diff] [blame] | 66 | } |