Home | History | Annotate | Download | only in service
      1 /*
      2  * Copyright (C) 2016 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.service;
     18 
     19 import android.support.annotation.Nullable;
     20 import android.view.View;
     21 import android.view.ViewStub;
     22 import android.widget.QuickContactBadge;
     23 import android.widget.TextView;
     24 
     25 import java.util.List;
     26 
     27 /**
     28  * Interface responsible for rendering spam buttons.
     29  */
     30 public interface ExtendedBlockingButtonRenderer {
     31 
     32     final class ViewHolderInfo {
     33 
     34         public final List<View> completeListItemViews;
     35         public final List<View> extendedBlockedViews;
     36         public final List<View> blockedNumberViews;
     37         public final String phoneNumber;
     38         public final String countryIso;
     39         public final String nameOrNumber;
     40         public final String displayNumber;
     41 
     42         public ViewHolderInfo(
     43                 /* All existing views amongst the list item actions, even if invisible */
     44                 List<View> completeListItemViews,
     45                 /* Views that should be seen if the number is in the blacklist */
     46                 List<View> extendedBlockedViews,
     47                 /* Views that should be seen if the number is in the extended blacklist */
     48                 List<View> blockedNumberViews,
     49                 String phoneNumber,
     50                 String countryIso,
     51                 String nameOrNumber,
     52                 String displayNumber) {
     53 
     54             this.completeListItemViews = completeListItemViews;
     55             this.extendedBlockedViews = extendedBlockedViews;
     56             this.blockedNumberViews = blockedNumberViews;
     57             this.phoneNumber = phoneNumber;
     58             this.countryIso = countryIso;
     59             this.nameOrNumber = nameOrNumber;
     60             this.displayNumber = displayNumber;
     61         }
     62     }
     63 
     64     interface Listener {
     65         void onBlockedNumber(String number, @Nullable String countryIso);
     66         void onUnblockedNumber(String number, @Nullable String countryIso);
     67     }
     68 
     69     /**
     70      * Renders buttons for a phone number.
     71      */
     72     void render(ViewStub viewStub);
     73 
     74     void setViewHolderInfo(ViewHolderInfo info);
     75 
     76     /**
     77      * Updates the photo and label for the given phone number and country iso.
     78      *
     79      * @param number Phone number for which the rendering occurs.
     80      * @param countryIso Two-letter country code.
     81      * @param badge {@link QuickContactBadge} in which the photo should be rendered.
     82      * @param view Textview that will hold the new label.
     83      */
     84     void updatePhotoAndLabelIfNecessary(
     85             String number, String countryIso, QuickContactBadge badge, TextView view);
     86 }
     87