Home | History | Annotate | Download | only in voicemail
      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.voicemail;
     18 
     19 import android.database.Cursor;
     20 import android.net.Uri;
     21 import android.provider.VoicemailContract.Status;
     22 
     23 import java.util.List;
     24 
     25 /**
     26  * Interface used by the call log UI to determine what user message, if any, related to voicemail
     27  * source status needs to be shown. The messages are returned in the order of importance.
     28  * <p>
     29  * The implementation of this interface interacts with the voicemail content provider to fetch
     30  * statuses of all the registered voicemail sources and determines if any status message needs to
     31  * be shown. The user of this interface must observe/listen to provider changes and invoke
     32  * this class to check if any message needs to be shown.
     33  */
     34 public interface VoicemailStatusHelper {
     35     public class StatusMessage {
     36         /** Package of the source on behalf of which this message has to be shown.*/
     37         public final String sourcePackage;
     38         /**
     39          * The string resource id of the status message that should be shown in the call log
     40          * page. Set to -1, if this message is not to be shown in call log.
     41          */
     42         public final int callLogMessageId;
     43         /**
     44          * The string resource id of the status message that should be shown in the call details
     45          * page. Set to -1, if this message is not to be shown in call details page.
     46          */
     47         public final int callDetailsMessageId;
     48         /** The string resource id of the action message that should be shown. */
     49         public final int actionMessageId;
     50         /** URI for the corrective action, where applicable. Null if no action URI is available. */
     51         public final Uri actionUri;
     52         public StatusMessage(String sourcePackage, int callLogMessageId, int callDetailsMessageId,
     53                 int actionMessageId, Uri actionUri) {
     54             this.sourcePackage = sourcePackage;
     55             this.callLogMessageId = callLogMessageId;
     56             this.callDetailsMessageId = callDetailsMessageId;
     57             this.actionMessageId = actionMessageId;
     58             this.actionUri = actionUri;
     59         }
     60 
     61         /** Whether this message should be shown in the call log page. */
     62         public boolean showInCallLog() {
     63             return callLogMessageId != -1;
     64         }
     65 
     66         /** Whether this message should be shown in the call details page. */
     67         public boolean showInCallDetails() {
     68             return callDetailsMessageId != -1;
     69         }
     70     }
     71 
     72     /**
     73      * Returns a list of messages, in the order or priority that should be shown to the user. An
     74      * empty list is returned if no message needs to be shown.
     75      * @param cursor The cursor pointing to the query on {@link Status#CONTENT_URI}. The projection
     76      *      to be used is defined by the implementation class of this interface.
     77      */
     78     public List<StatusMessage> getStatusMessages(Cursor cursor);
     79 
     80     /**
     81      * Returns the number of active voicemail sources installed.
     82      * <p>
     83      * The number of sources is counted by querying the voicemail status table.
     84      */
     85     public int getNumberActivityVoicemailSources(Cursor cursor);
     86 }
     87