1 /*
2  * Copyright (C) 2017 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.systemui.statusbar.policy;
18 
19 import android.view.View;
20 
21 import com.android.systemui.R;
22 
23 /**
24  * A class of utility static methods for heads up notifications.
25  */
26 public final class HeadsUpUtil {
27     private static final int TAG_CLICKED_NOTIFICATION = R.id.is_clicked_heads_up_tag;
28 
29     /**
30      * Set the given view as clicked or not-clicked.
31      * @param view The view to be set the flag to.
32      * @param clicked True to set as clicked. False to not-clicked.
33      */
setIsClickedHeadsUpNotification(View view, boolean clicked)34     public static void setIsClickedHeadsUpNotification(View view, boolean clicked) {
35         view.setTag(TAG_CLICKED_NOTIFICATION, clicked ? true : null);
36     }
37 
38     /**
39      * Check if the given view has the flag of "clicked notification"
40      * @param view The view to be checked.
41      * @return True if the view has clicked. False othrewise.
42      */
isClickedHeadsUpNotification(View view)43     public static boolean isClickedHeadsUpNotification(View view) {
44         Boolean clicked = (Boolean) view.getTag(TAG_CLICKED_NOTIFICATION);
45         return clicked != null && clicked;
46     }
47 }
48