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