1 /* 2 * Copyright (C) 2012 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.phone; 18 19 import android.content.Context; 20 import android.graphics.Canvas; 21 import android.graphics.Color; 22 import android.graphics.Paint; 23 import android.graphics.PorterDuff; 24 import android.graphics.PorterDuffXfermode; 25 import android.util.AttributeSet; 26 27 public class NotificationPanelView extends PanelView { 28 29 private static final boolean DEBUG = false; 30 31 /** 32 * Fling expanding QS. 33 */ 34 public static final int FLING_EXPAND = 0; 35 36 static final String COUNTER_PANEL_OPEN = "panel_open"; 37 static final String COUNTER_PANEL_OPEN_QS = "panel_open_qs"; 38 39 private int mCurrentPanelAlpha; 40 private final Paint mAlphaPaint = new Paint(); 41 private boolean mDozing; 42 private RtlChangeListener mRtlChangeListener; 43 NotificationPanelView(Context context, AttributeSet attrs)44 public NotificationPanelView(Context context, AttributeSet attrs) { 45 super(context, attrs); 46 setWillNotDraw(!DEBUG); 47 mAlphaPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY)); 48 49 setBackgroundColor(Color.TRANSPARENT); 50 } 51 52 @Override onRtlPropertiesChanged(int layoutDirection)53 public void onRtlPropertiesChanged(int layoutDirection) { 54 if (mRtlChangeListener != null) { 55 mRtlChangeListener.onRtlPropertielsChanged(layoutDirection); 56 } 57 } 58 59 @Override shouldDelayChildPressedState()60 public boolean shouldDelayChildPressedState() { 61 return true; 62 } 63 64 @Override dispatchDraw(Canvas canvas)65 protected void dispatchDraw(Canvas canvas) { 66 super.dispatchDraw(canvas); 67 if (mCurrentPanelAlpha != 255) { 68 canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mAlphaPaint); 69 } 70 } 71 getCurrentPanelAlpha()72 float getCurrentPanelAlpha() { 73 return mCurrentPanelAlpha; 74 } 75 setPanelAlphaInternal(float alpha)76 void setPanelAlphaInternal(float alpha) { 77 mCurrentPanelAlpha = (int) alpha; 78 mAlphaPaint.setARGB(mCurrentPanelAlpha, 255, 255, 255); 79 invalidate(); 80 } 81 setDozing(boolean dozing)82 public void setDozing(boolean dozing) { 83 mDozing = dozing; 84 } 85 86 @Override hasOverlappingRendering()87 public boolean hasOverlappingRendering() { 88 return !mDozing; 89 } 90 setRtlChangeListener(RtlChangeListener listener)91 void setRtlChangeListener(RtlChangeListener listener) { 92 mRtlChangeListener = listener; 93 } 94 95 interface RtlChangeListener { onRtlPropertielsChanged(int layoutDirection)96 void onRtlPropertielsChanged(int layoutDirection); 97 } 98 } 99