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 | |
Daniel Lehmann | 6ecb732 | 2011-08-01 21:39:29 -0700 | [diff] [blame] | 19 | import com.android.contacts.calllog.CallTypeIconsView; |
| 20 | |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 21 | import android.content.Context; |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 22 | import android.view.View; |
| 23 | import android.widget.TextView; |
| 24 | |
| 25 | /** |
| 26 | * Encapsulates the views that are used to display the details of a phone call in the call log. |
| 27 | */ |
| 28 | public final class PhoneCallDetailsViews { |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 29 | public final TextView nameView; |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 30 | public final View callTypeView; |
Daniel Lehmann | 6ecb732 | 2011-08-01 21:39:29 -0700 | [diff] [blame] | 31 | public final CallTypeIconsView callTypeIcons; |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 32 | public final TextView callTypeText; |
| 33 | public final View callTypeSeparator; |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 34 | public final TextView dateView; |
| 35 | public final TextView numberView; |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 36 | |
Daniel Lehmann | 6ecb732 | 2011-08-01 21:39:29 -0700 | [diff] [blame] | 37 | private PhoneCallDetailsViews(TextView nameView, View callTypeView, |
| 38 | CallTypeIconsView callTypeIcons, TextView callTypeText, View callTypeSeparator, |
| 39 | TextView dateView, TextView numberView) { |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 40 | this.nameView = nameView; |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 41 | this.callTypeView = callTypeView; |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 42 | this.callTypeIcons = callTypeIcons; |
| 43 | this.callTypeText = callTypeText; |
| 44 | this.callTypeSeparator = callTypeSeparator; |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 45 | this.dateView = dateView; |
| 46 | this.numberView = numberView; |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 47 | } |
| 48 | |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 49 | /** |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 50 | * Create a new instance by extracting the elements from the given view. |
| 51 | * <p> |
| 52 | * 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] | 53 | * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier |
| 54 | * {@code R.id.call_types}. |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 55 | */ |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 56 | public static PhoneCallDetailsViews fromView(View view) { |
| 57 | return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name), |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 58 | view.findViewById(R.id.call_type), |
Daniel Lehmann | 6ecb732 | 2011-08-01 21:39:29 -0700 | [diff] [blame] | 59 | (CallTypeIconsView) view.findViewById(R.id.call_type_icons), |
Flavio Lerda | 4586feb | 2011-07-09 17:03:48 +0100 | [diff] [blame] | 60 | (TextView) view.findViewById(R.id.call_type_name), |
| 61 | view.findViewById(R.id.call_type_separator), |
Flavio Lerda | 7d7473a | 2011-07-06 14:21:46 +0100 | [diff] [blame] | 62 | (TextView) view.findViewById(R.id.date), |
Flavio Lerda | 696e813 | 2011-07-05 19:00:23 +0100 | [diff] [blame] | 63 | (TextView) view.findViewById(R.id.number)); |
| 64 | } |
| 65 | |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 66 | public static PhoneCallDetailsViews createForTest(Context context) { |
| 67 | return new PhoneCallDetailsViews( |
| 68 | new TextView(context), |
| 69 | new View(context), |
Daniel Lehmann | 6ecb732 | 2011-08-01 21:39:29 -0700 | [diff] [blame] | 70 | new CallTypeIconsView(context), |
Flavio Lerda | 4056956 | 2011-07-22 21:51:29 +0100 | [diff] [blame] | 71 | new TextView(context), |
| 72 | new View(context), |
| 73 | new TextView(context), |
| 74 | new TextView(context)); |
Flavio Lerda | a024c3f | 2011-06-10 10:47:07 +0100 | [diff] [blame] | 75 | } |
Flavio Lerda | afb93bb | 2011-07-05 14:46:10 +0100 | [diff] [blame] | 76 | } |