Home | History | Annotate | Download | only in com.example.android.support.wearable.notifications
      1 /*
      2  * Copyright (C) 2014 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.example.android.support.wearable.notifications;
     18 
     19 import android.app.Notification;
     20 import android.content.Context;
     21 
     22 /**
     23  * Base class for notification preset generators.
     24  */
     25 public abstract class NotificationPreset extends NamedPreset {
     26     public final int titleResId;
     27     public final int textResId;
     28 
     29     public NotificationPreset(int nameResId, int titleResId, int textResId) {
     30         super(nameResId);
     31         this.titleResId = titleResId;
     32         this.textResId = textResId;
     33     }
     34 
     35     public static class BuildOptions {
     36         public final CharSequence titlePreset;
     37         public final CharSequence textPreset;
     38         public final PriorityPreset priorityPreset;
     39         public final ActionsPreset actionsPreset;
     40         public final boolean includeLargeIcon;
     41         public final boolean isLocalOnly;
     42         public final boolean hasContentIntent;
     43         public final boolean vibrate;
     44         public final Integer[] backgroundIds;
     45 
     46         public BuildOptions(CharSequence titlePreset, CharSequence textPreset,
     47                 PriorityPreset priorityPreset, ActionsPreset actionsPreset,
     48                 boolean includeLargeIcon, boolean isLocalOnly, boolean hasContentIntent,
     49                 boolean vibrate, Integer[] backgroundIds) {
     50             this.titlePreset = titlePreset;
     51             this.textPreset = textPreset;
     52             this.priorityPreset = priorityPreset;
     53             this.actionsPreset = actionsPreset;
     54             this.includeLargeIcon = includeLargeIcon;
     55             this.isLocalOnly = isLocalOnly;
     56             this.hasContentIntent = hasContentIntent;
     57             this.vibrate = vibrate;
     58             this.backgroundIds = backgroundIds;
     59         }
     60     }
     61 
     62     /** Build a notification with this preset and the provided options */
     63     public abstract Notification[] buildNotifications(Context context, BuildOptions options);
     64 
     65     /** Whether actions are required to use this preset. */
     66     public boolean actionsRequired() {
     67         return false;
     68     }
     69 
     70     /** Number of background pickers required */
     71     public int countBackgroundPickersRequired() {
     72         return 0;
     73     }
     74 }
     75