1 /*
2  * Copyright (C) 2018 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.promotion;
18 
19 import android.support.annotation.DrawableRes;
20 import android.support.annotation.IntDef;
21 import java.lang.annotation.Retention;
22 import java.lang.annotation.RetentionPolicy;
23 
24 /** Interface for promotion bottom sheet. */
25 public interface Promotion {
26 
27   /**
28    * Type of promotion, which means promotion should be shown as a card in {@link
29    * android.support.v7.widget.RecyclerView} or {@link
30    * android.support.design.bottomsheet.BottomSheetBehavior}.
31    */
32   @Retention(RetentionPolicy.SOURCE)
33   @IntDef({PromotionType.CARD, PromotionType.BOTTOM_SHEET})
34   @interface PromotionType {
35     /** Shown as card in call log or voicemail tab. */
36     int CARD = 1;
37 
38     /** Shown as bottom sheet. */
39     int BOTTOM_SHEET = 2;
40   }
41 
42   /** Returns {@link PromotionType} for this promotion. */
43   @PromotionType
getType()44   int getType();
45 
46   /**
47    * Returns if this promotion should be shown. This usually means the promotion is enabled and not
48    * dismissed yet.
49    */
isEligibleToBeShown()50   boolean isEligibleToBeShown();
51 
52   /** Called when this promotion is first time viewed by user. */
onViewed()53   default void onViewed() {}
54 
55   /** Dismisses this promotion. This is called when user acknowledged the promotion. */
dismiss()56   void dismiss();
57 
58   /** Returns title text of the promotion. */
getTitle()59   CharSequence getTitle();
60 
61   /** Returns details text of the promotion. */
getDetails()62   CharSequence getDetails();
63 
64   /** Returns resource id of the icon for the promotion. */
65   @DrawableRes
getIconRes()66   int getIconRes();
67 }
68