Home | History | Annotate | Download | only in calllog
      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.calllog;
     18 
     19 import android.content.Context;
     20 import android.telecom.PhoneAccountHandle;
     21 import android.view.View;
     22 import android.widget.QuickContactBadge;
     23 import android.widget.TextView;
     24 
     25 import com.android.contacts.common.testing.NeededForTesting;
     26 import com.android.dialer.PhoneCallDetailsViews;
     27 import com.android.dialer.R;
     28 
     29 /**
     30  * Simple value object containing the various views within a call log entry.
     31  */
     32 public final class CallLogListItemViews {
     33     /** The quick contact badge for the contact. */
     34     public final QuickContactBadge quickContactView;
     35     /** The primary action view of the entry. */
     36     public final View primaryActionView;
     37     /** The details of the phone call. */
     38     public final PhoneCallDetailsViews phoneCallDetailsViews;
     39     /** The text of the header for a day grouping. */
     40     public final TextView dayGroupHeader;
     41     /** The view containing the details for the call log row, including the action buttons. */
     42     public final View callLogEntryView;
     43     /** The view containing call log item actions.  Null until the ViewStub is inflated. */
     44     public View actionsView;
     45     /** The "call back" action button - assigned only when the action section is expanded. */
     46     public TextView callBackButtonView;
     47     /** The "video call" action button - assigned only when the action section is expanded. */
     48     public TextView videoCallButtonView;
     49     /** The "voicemail" action button - assigned only when the action section is expanded. */
     50     public TextView voicemailButtonView;
     51     /** The "details" action button - assigned only when the action section is expanded. */
     52     public TextView detailsButtonView;
     53     /** The "report" action button. */
     54     public TextView reportButtonView;
     55 
     56     /**
     57      * The row Id for the first call associated with the call log entry.  Used as a key for the
     58      * map used to track which call log entries have the action button section expanded.
     59      */
     60     public long rowId;
     61 
     62     /**
     63      * The call Ids for the calls represented by the current call log entry.  Used when the user
     64      * deletes a call log entry.
     65      */
     66     public long[] callIds;
     67 
     68     /**
     69      * The callable phone number for the current call log entry.  Cached here as the call back
     70      * intent is set only when the actions ViewStub is inflated.
     71      */
     72     public String number;
     73 
     74     /**
     75      * The phone number presentation for the current call log entry.  Cached here as the call back
     76      * intent is set only when the actions ViewStub is inflated.
     77      */
     78     public int numberPresentation;
     79 
     80     /**
     81      * The type of call for the current call log entry.  Cached here as the call back
     82      * intent is set only when the actions ViewStub is inflated.
     83      */
     84     public int callType;
     85 
     86     /**
     87      * The account for the current call log entry.  Cached here as the call back
     88      * intent is set only when the actions ViewStub is inflated.
     89      */
     90     public PhoneAccountHandle accountHandle;
     91 
     92     /**
     93      * If the call has an associated voicemail message, the URI of the voicemail message for
     94      * playback.  Cached here as the voicemail intent is only set when the actions ViewStub is
     95      * inflated.
     96      */
     97     public String voicemailUri;
     98 
     99     /**
    100      * The name or number associated with the call.  Cached here for use when setting content
    101      * descriptions on buttons in the actions ViewStub when it is inflated.
    102      */
    103     public CharSequence nameOrNumber;
    104 
    105     /**
    106      * Whether or not the item has been reported by user as incorrect.
    107      */
    108     public boolean reported;
    109 
    110     /**
    111      * Whether or not the contact info can be marked as invalid from the source where
    112      * it was obtained.
    113      */
    114     public boolean canBeReportedAsInvalid;
    115 
    116     private CallLogListItemViews(QuickContactBadge quickContactView, View primaryActionView,
    117             PhoneCallDetailsViews phoneCallDetailsViews, View callLogEntryView,
    118             TextView dayGroupHeader) {
    119         this.quickContactView = quickContactView;
    120         this.primaryActionView = primaryActionView;
    121         this.phoneCallDetailsViews = phoneCallDetailsViews;
    122         this.callLogEntryView = callLogEntryView;
    123         this.dayGroupHeader = dayGroupHeader;
    124     }
    125 
    126     public static CallLogListItemViews fromView(View view) {
    127         return new CallLogListItemViews(
    128                 (QuickContactBadge) view.findViewById(R.id.quick_contact_photo),
    129                 view.findViewById(R.id.primary_action_view),
    130                 PhoneCallDetailsViews.fromView(view),
    131                 view.findViewById(R.id.call_log_row),
    132                 (TextView) view.findViewById(R.id.call_log_day_group_label));
    133     }
    134 
    135     @NeededForTesting
    136     public static CallLogListItemViews createForTest(Context context) {
    137         CallLogListItemViews views = new CallLogListItemViews(
    138                 new QuickContactBadge(context),
    139                 new View(context),
    140                 PhoneCallDetailsViews.createForTest(context),
    141                 new View(context),
    142                 new TextView(context));
    143         views.callBackButtonView = new TextView(context);
    144         views.voicemailButtonView = new TextView(context);
    145         views.detailsButtonView = new TextView(context);
    146         views.reportButtonView = new TextView(context);
    147         views.actionsView = new View(context);
    148         return views;
    149     }
    150 }
    151