Home | History | Annotate | Download | only in statusbar
      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 import com.android.internal.R;
     23 
     24 /**
     25  * Wraps the actual notification content view; used to implement behaviors which are different for
     26  * the individual templates and custom views.
     27  */
     28 public abstract class NotificationViewWrapper {
     29 
     30     protected final View mView;
     31 
     32     public static NotificationViewWrapper wrap(Context ctx, View v) {
     33 
     34         // TODO: Figure out a better way to find out which template the view is.
     35         if (v.findViewById(com.android.internal.R.id.media_actions) != null) {
     36             return new NotificationMediaViewWrapper(ctx, v);
     37         } else if (v.getId() == com.android.internal.R.id.status_bar_latest_event_content) {
     38             return new NotificationTemplateViewWrapper(ctx, v);
     39         } else {
     40             return new NotificationCustomViewWrapper(v);
     41         }
     42     }
     43 
     44     protected NotificationViewWrapper(View view) {
     45         mView = view;
     46     }
     47 
     48     /**
     49      * In dark mode, we draw as little as possible, assuming a black background.
     50      *
     51      * @param dark whether we should display ourselves in dark mode
     52      * @param fade whether to animate the transition if the mode changes
     53      * @param delay if fading, the delay of the animation
     54      */
     55     public abstract void setDark(boolean dark, boolean fade, long delay);
     56 
     57     /**
     58      * Notifies this wrapper that the content of the view might have changed.
     59      */
     60     public void notifyContentUpdated() {}
     61 }
     62