• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.android.systemui.statusbar;
18 
19 import android.content.Context;
20 import android.view.View;
21 
22 /**
23  * Wraps the actual notification content view; used to implement behaviors which are different for
24  * the individual templates and custom views.
25  */
26 public abstract class NotificationViewWrapper {
27 
28     private static final String TAG_BIG_MEDIA_NARROW = "bigMediaNarrow";
29     private static final String TAG_MEDIA = "media";
30     private static final String TAG_BIG_PICTURE = "bigPicture";
31 
32     protected final View mView;
33 
wrap(Context ctx, View v)34     public static NotificationViewWrapper wrap(Context ctx, View v) {
35         if (v.getId() == com.android.internal.R.id.status_bar_latest_event_content) {
36             if (TAG_BIG_MEDIA_NARROW.equals(v.getTag())) {
37                 return new NotificationBigMediaNarrowViewWrapper(ctx, v);
38             } else if (TAG_MEDIA.equals(v.getTag())) {
39                 return new NotificationMediaViewWrapper(ctx, v);
40             } else if (TAG_BIG_PICTURE.equals(v.getTag())) {
41                 return new NotificationBigMediaNarrowViewWrapper(ctx, v);
42             } else {
43                 return new NotificationTemplateViewWrapper(ctx, v);
44             }
45         } else {
46             return new NotificationCustomViewWrapper(v);
47         }
48     }
49 
NotificationViewWrapper(View view)50     protected NotificationViewWrapper(View view) {
51         mView = view;
52     }
53 
54     /**
55      * In dark mode, we draw as little as possible, assuming a black background.
56      *
57      * @param dark whether we should display ourselves in dark mode
58      * @param fade whether to animate the transition if the mode changes
59      * @param delay if fading, the delay of the animation
60      */
setDark(boolean dark, boolean fade, long delay)61     public abstract void setDark(boolean dark, boolean fade, long delay);
62 
63     /**
64      * Notifies this wrapper that the content of the view might have changed.
65      */
notifyContentUpdated()66     public void notifyContentUpdated() {}
67 
68     /**
69      * @return true if this template might need to be clipped with a round rect to make it look
70      *         nice, false otherwise
71      */
needsRoundRectClipping()72     public boolean needsRoundRectClipping() {
73         return false;
74     }
75 }
76