1 /* 2 * Copyright (C) 2019 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.car.notification; 18 19 import android.os.Handler; 20 import android.service.notification.StatusBarNotification; 21 import android.view.View; 22 23 import com.android.car.notification.template.CarNotificationBaseViewHolder; 24 25 /** 26 * Class to store the state for Heads Up Notifications. Each notification will have its own post 27 * time, handler, and Layout. This class ensures to store it as a separate state so that each Heads 28 * up notification can be controlled independently. 29 */ 30 public class HeadsUpEntry extends AlertEntry { 31 32 private final Handler mHandler; 33 private View mNotificationView; 34 private CarNotificationBaseViewHolder mCarNotificationBaseViewHolder; 35 36 // Signifies that this notification was NOT flagged with Notification.FLAG_ONLY_ALERT_ONCE 37 boolean mIsAlertAgain; 38 39 // Signifies that this notification is to be shown as Heads Up Notification for the first time 40 boolean mIsNewHeadsUp; 41 HeadsUpEntry(StatusBarNotification statusBarNotification)42 HeadsUpEntry(StatusBarNotification statusBarNotification) { 43 super(statusBarNotification); 44 mHandler = new Handler(); 45 } 46 47 /** 48 * Handler will use the method {@link Handler#postDelayed(Runnable, long)} which will control 49 * the dismiss time for the Heads Up notification. All the notifications should have their own 50 * handler to control this time individually. 51 */ getHandler()52 Handler getHandler() { 53 return mHandler; 54 } 55 56 /** 57 * View that holds the actual card for heads up notification. 58 */ setNotificationView(View notificationView)59 void setNotificationView(View notificationView) { 60 mNotificationView = notificationView; 61 } 62 getNotificationView()63 View getNotificationView() { 64 return mNotificationView; 65 } 66 setViewHolder(CarNotificationBaseViewHolder viewHolder)67 void setViewHolder(CarNotificationBaseViewHolder viewHolder) { 68 mCarNotificationBaseViewHolder = viewHolder; 69 } 70 getViewHolder()71 CarNotificationBaseViewHolder getViewHolder() { 72 return mCarNotificationBaseViewHolder; 73 } 74 } 75