NotificationPanelView.java revision 13522a2e40730a0703fd7f185b7fb9be8ae37ab6
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 17package com.android.systemui.statusbar.phone; 18 19import android.content.Context; 20import android.content.res.Resources; 21import android.graphics.Canvas; 22import android.graphics.drawable.Drawable; 23import android.util.AttributeSet; 24import android.view.View; 25 26import com.android.systemui.R; 27 28public class NotificationPanelView extends PanelView { 29 30 Drawable mHandleBar; 31 float mHandleBarHeight; 32 View mHandleView; 33 34 public NotificationPanelView(Context context, AttributeSet attrs) { 35 super(context, attrs); 36 } 37 38 @Override 39 protected void onFinishInflate() { 40 super.onFinishInflate(); 41 42 Resources resources = getContext().getResources(); 43 mHandleBar = resources.getDrawable(R.drawable.status_bar_close); 44 mHandleBarHeight = resources.getDimension(R.dimen.close_handle_height); 45 mHandleView = findViewById(R.id.handle); 46 } 47 48 @Override 49 public void fling(float vel, boolean always) { 50 ((PhoneStatusBarView) mBar).mBar.getGestureRecorder().tag( 51 "fling " + ((vel > 0) ? "open" : "closed"), 52 "notifications,v=" + vel); 53 super.fling(vel, always); 54 } 55 56 // We draw the handle ourselves so that it's always glued to the bottom of the window. 57 @Override 58 protected void onLayout(boolean changed, int left, int top, int right, int bottom) { 59 super.onLayout(changed, left, top, right, bottom); 60 if (changed) { 61 final int pl = getPaddingLeft(); 62 final int pr = getPaddingRight(); 63 mHandleBar.setBounds(pl, 0, getWidth() - pr, (int) mHandleBarHeight); 64 } 65 } 66 67 @Override 68 public void draw(Canvas canvas) { 69 super.draw(canvas); 70 final int off = (int) (getHeight() - mHandleBarHeight - getPaddingBottom()); 71 canvas.translate(0, off); 72 mHandleBar.setState(mHandleView.getDrawableState()); 73 mHandleBar.draw(canvas); 74 canvas.translate(0, -off); 75 } 76} 77