Home | History | Annotate | Download | only in dialer
      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.dialer;
     18 
     19 import android.content.Context;
     20 import android.view.View;
     21 import android.widget.TextView;
     22 
     23 import com.android.dialer.calllog.CallTypeIconsView;
     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 {
     29     public final TextView nameView;
     30     public final View callTypeView;
     31     public final CallTypeIconsView callTypeIcons;
     32     public final TextView callTypeAndDate;
     33     public final TextView labelView;
     34 
     35     private PhoneCallDetailsViews(TextView nameView, View callTypeView,
     36             CallTypeIconsView callTypeIcons, TextView callTypeAndDate, TextView labelView) {
     37         this.nameView = nameView;
     38         this.callTypeView = callTypeView;
     39         this.callTypeIcons = callTypeIcons;
     40         this.callTypeAndDate = callTypeAndDate;
     41         this.labelView = labelView;
     42     }
     43 
     44     /**
     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},
     48      * {@code R.id.date}, and {@code R.id.number}, and a linear layout with identifier
     49      * {@code R.id.call_types}.
     50      */
     51     public static PhoneCallDetailsViews fromView(View view) {
     52         return new PhoneCallDetailsViews((TextView) view.findViewById(R.id.name),
     53                 view.findViewById(R.id.call_type),
     54                 (CallTypeIconsView) view.findViewById(R.id.call_type_icons),
     55                 (TextView) view.findViewById(R.id.call_count_and_date),
     56                 (TextView) view.findViewById(R.id.label));
     57     }
     58 
     59     public static PhoneCallDetailsViews createForTest(Context context) {
     60         return new PhoneCallDetailsViews(
     61                 new TextView(context),
     62                 new View(context),
     63                 new CallTypeIconsView(context),
     64                 new TextView(context),
     65                 new TextView(context));
     66     }
     67 }
     68