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; |
| 28 | public final LinearLayout callTypesLayout; |
| 29 | public final TextView dateView; |
| 30 | public final TextView numberView; |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 31 | |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame^] | 32 | 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 Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 38 | } |
| 39 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 40 | /** |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 41 | * 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 Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame^] | 44 | * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier |
| 45 | * {@code R.id.call_types}. |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 46 | */ |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 47 | public static PhoneCallDetailsViews fromView(View view) { |
| 48 | return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame^] | 49 | (LinearLayout) view.findViewById(R.id.call_types), |
| 50 | (TextView) view.findViewById(R.id.date), |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 51 | (TextView) view.findViewById(R.id.number)); |
| 52 | } |
| 53 | |
| 54 | public static PhoneCallDetailsViews createForTest(TextView nameView, |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame^] | 55 | LinearLayout callTypesLayout, TextView dateView, TextView numberView) { |
| 56 | return new PhoneCallDetailsViews(nameView, callTypesLayout, dateView, numberView); |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 57 | } |
Flavio Lerda | afb93bb | 2011-07-05 14:46:10 +0100 | [diff] [blame] | 58 | } |