PhoneStatusBarView.java revision 1c1edaa5f127d814058271ee4827fc0fe4a8de44
1/*
2 * Copyright (C) 2008 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.app.ActivityManager;
20import android.content.Context;
21import android.content.res.Configuration;
22import android.content.res.Resources;
23import android.graphics.Canvas;
24import android.graphics.Color;
25import android.graphics.Rect;
26import android.os.SystemClock;
27import android.util.AttributeSet;
28import android.util.Log;
29import android.view.KeyEvent;
30import android.view.MotionEvent;
31import android.view.View;
32import android.view.ViewGroup;
33import android.view.ViewParent;
34import android.view.accessibility.AccessibilityEvent;
35import android.widget.FrameLayout;
36
37import com.android.systemui.R;
38import com.android.systemui.statusbar.BaseStatusBar;
39import com.android.systemui.statusbar.policy.FixedSizeDrawable;
40
41public class PhoneStatusBarView extends PanelBar {
42    private static final String TAG = "PhoneStatusBarView";
43    PhoneStatusBar mBar;
44    int mScrimColor;
45
46    public PhoneStatusBarView(Context context, AttributeSet attrs) {
47        super(context, attrs);
48    }
49
50    public void setBar(PhoneStatusBar bar) {
51        mBar = bar;
52    }
53
54    @Override
55    public void onAttachedToWindow() {
56        Resources res = getContext().getResources();
57        mScrimColor = res.getColor(R.color.notification_panel_scrim_color);
58    }
59
60    @Override
61    public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
62        if (super.onRequestSendAccessibilityEvent(child, event)) {
63            // The status bar is very small so augment the view that the user is touching
64            // with the content of the status bar a whole. This way an accessibility service
65            // may announce the current item as well as the entire content if appropriate.
66            AccessibilityEvent record = AccessibilityEvent.obtain();
67            onInitializeAccessibilityEvent(record);
68            dispatchPopulateAccessibilityEvent(record);
69            event.appendRecord(record);
70            return true;
71        }
72        return false;
73    }
74
75    @Override
76    public void onPanelPeeked() {
77        super.onPanelPeeked();
78        mBar.makeExpandedVisible(true);
79    }
80
81    @Override
82    public void onAllPanelsCollapsed() {
83        super.onAllPanelsCollapsed();
84        mBar.makeExpandedInvisible();
85    }
86
87    @Override
88    public boolean onTouchEvent(MotionEvent event) {
89        return mBar.interceptTouchEvent(event) || super.onTouchEvent(event);
90    }
91
92    @Override
93    public boolean onInterceptTouchEvent(MotionEvent event) {
94        return mBar.interceptTouchEvent(event) || super.onInterceptTouchEvent(event);
95    }
96
97    @Override
98    public void panelExpansionChanged(PanelView pv, float frac) {
99        super.panelExpansionChanged(pv, frac);
100
101        if (mScrimColor != 0 && ActivityManager.isHighEndGfx(mBar.mDisplay)) {
102            // woo, special effects
103            final float k = (float)(1f-0.5f*(1f-Math.cos(3.14159f * Math.pow(1f-frac, 2.2f))));
104            // attenuate background color alpha by k
105            final int color = (int) ((float)(mScrimColor >>> 24) * k) << 24 | (mScrimColor & 0xFFFFFF);
106            mBar.mStatusBarWindow.setBackgroundColor(color);
107        }
108
109        mBar.updateCarrierLabelVisibility(false);
110    }
111
112
113}
114