blob: fa06879dee89fd1f155e74a6059d2cbae8d538b2 [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
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070019import com.android.contacts.calllog.CallTypeIconsView;
20
Flavio Lerda40569562011-07-22 21:51:29 +010021import android.content.Context;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010022import android.view.View;
23import 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 */
28public final class PhoneCallDetailsViews {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010029 public final TextView nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010030 public final View callTypeView;
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070031 public final CallTypeIconsView callTypeIcons;
Flavio Lerdafe170262011-08-03 06:40:47 +010032 public final TextView callTypeAndDate;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010033 public final TextView numberView;
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010034
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070035 private PhoneCallDetailsViews(TextView nameView, View callTypeView,
Flavio Lerdafe170262011-08-03 06:40:47 +010036 CallTypeIconsView callTypeIcons, TextView callTypeAndDate, TextView numberView) {
Flavio Lerda7d7473a2011-07-06 14:21:46 +010037 this.nameView = nameView;
Flavio Lerda40569562011-07-22 21:51:29 +010038 this.callTypeView = callTypeView;
Flavio Lerda4586feb2011-07-09 17:03:48 +010039 this.callTypeIcons = callTypeIcons;
Flavio Lerdafe170262011-08-03 06:40:47 +010040 this.callTypeAndDate = callTypeAndDate;
Flavio Lerda7d7473a2011-07-06 14:21:46 +010041 this.numberView = numberView;
Flavio Lerda696e8132011-07-05 19:00:23 +010042 }
43
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010044 /**
Flavio Lerda696e8132011-07-05 19:00:23 +010045 * 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 Lerda7d7473a2011-07-06 14:21:46 +010048 * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
49 * {@code R.id.call_types}.
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010050 */
Flavio Lerda696e8132011-07-05 19:00:23 +010051 public static PhoneCallDetailsViews fromView(View view) {
52 return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
Flavio Lerda40569562011-07-22 21:51:29 +010053 view.findViewById(R.id.call_type),
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070054 (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
Flavio Lerdafe170262011-08-03 06:40:47 +010055 (TextView) view.findViewById(R.id.call_count_and_date),
Flavio Lerda696e8132011-07-05 19:00:23 +010056 (TextView) view.findViewById(R.id.number));
57 }
58
Flavio Lerda40569562011-07-22 21:51:29 +010059 public static PhoneCallDetailsViews createForTest(Context context) {
60 return new PhoneCallDetailsViews(
61 new TextView(context),
62 new View(context),
Daniel Lehmann6ecb7322011-08-01 21:39:29 -070063 new CallTypeIconsView(context),
Flavio Lerda40569562011-07-22 21:51:29 +010064 new TextView(context),
Flavio Lerda40569562011-07-22 21:51:29 +010065 new TextView(context));
Flavio Lerdaa024c3f2011-06-10 10:47:07 +010066 }
Flavio Lerdaafb93bb2011-07-05 14:46:10 +010067}