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