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