blob: 47e758c58fe60c37827f56dbb1f8e5ddce434cf3 [file] [log] [blame]
Joe Onorato020460b2011-01-19 15:25:55 -08001/*
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.policy;
18
19import android.content.Context;
20import android.content.res.TypedArray;
21import android.graphics.Region;
22import android.graphics.drawable.AnimationDrawable;
23import android.graphics.drawable.Drawable;
24import android.os.RemoteException;
25import android.os.SystemClock;
26import android.os.ServiceManager;
27import android.util.AttributeSet;
28import android.util.Slog;
29import android.view.HapticFeedbackConstants;
30import android.view.IWindowManager;
31import android.view.InputDevice;
32import android.view.KeyCharacterMap;
33import android.view.KeyEvent;
34import android.view.MotionEvent;
35import android.view.View;
36import android.view.ViewConfiguration;
37import android.view.ViewTreeObserver;
38import android.widget.RemoteViews.RemoteView;
39
40import com.android.systemui.R;
41
42public class EventHole extends View implements ViewTreeObserver.OnComputeInternalInsetsListener {
43 private static final String TAG = "StatusBar.EventHole";
44
45 private boolean mWindowVis;
46 private int[] mLoc = new int[2];
47
48 public EventHole(Context context, AttributeSet attrs) {
49 this(context, attrs, 0);
50 }
51
52 public EventHole(Context context, AttributeSet attrs, int defStyle) {
53 super(context, attrs);
54 }
55
56 @Override
57 protected void onWindowVisibilityChanged(int visibility) {
58 super.onWindowVisibilityChanged(visibility);
59 mWindowVis = visibility == View.VISIBLE;
60 }
61
62 @Override
63 protected void onAttachedToWindow() {
64 super.onAttachedToWindow();
65 getViewTreeObserver().addOnComputeInternalInsetsListener(this);
66 }
67
68 @Override
69 protected void onDetachedFromWindow() {
70 super.onDetachedFromWindow();
71 getViewTreeObserver().removeOnComputeInternalInsetsListener(this);
72 }
73
74 public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) {
75 final boolean visible = isShown() && mWindowVis && getWidth() > 0 && getHeight() > 0;
76 final int[] loc = mLoc;
77 getLocationInWindow(loc);
78 final int l = loc[0];
79 final int r = l + getWidth();
80 final int t = loc[1];
81 final int b = t + getHeight();
82
83 View top = this;
84 while (top.getParent() instanceof View) {
85 top = (View)top.getParent();
86 }
87
88 if (visible) {
89 info.setTouchableInsets(
90 ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
91 info.touchableRegion.set(0, 0, top.getWidth(), top.getHeight());
92 info.touchableRegion.op(l, t, r, b, Region.Op.DIFFERENCE);
93 } else {
94 info.setTouchableInsets(
95 ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME);
96 }
97 }
98}
99