From 020460b610d8196cb820ba390300e3fefda82f30 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Wed, 19 Jan 2011 15:25:55 -0800 Subject: [PATCH] Cut a hole in the status bar for events when the IME is open. Bug: 3238092 Change-Id: I8af18c2ebada624fbf5baee09b4b7ef98a7c8205 --- .../SystemUI/res/layout-xlarge/status_bar.xml | 5 +- .../systemui/statusbar/policy/EventHole.java | 99 +++++++++++++++++++ 2 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/statusbar/policy/EventHole.java diff --git a/packages/SystemUI/res/layout-xlarge/status_bar.xml b/packages/SystemUI/res/layout-xlarge/status_bar.xml index 0533b6f5e66c1..852b72974f37c 100644 --- a/packages/SystemUI/res/layout-xlarge/status_bar.xml +++ b/packages/SystemUI/res/layout-xlarge/status_bar.xml @@ -78,15 +78,14 @@ - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/EventHole.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EventHole.java new file mode 100644 index 0000000000000..47e758c58fe60 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/EventHole.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.statusbar.policy; + +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Region; +import android.graphics.drawable.AnimationDrawable; +import android.graphics.drawable.Drawable; +import android.os.RemoteException; +import android.os.SystemClock; +import android.os.ServiceManager; +import android.util.AttributeSet; +import android.util.Slog; +import android.view.HapticFeedbackConstants; +import android.view.IWindowManager; +import android.view.InputDevice; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewConfiguration; +import android.view.ViewTreeObserver; +import android.widget.RemoteViews.RemoteView; + +import com.android.systemui.R; + +public class EventHole extends View implements ViewTreeObserver.OnComputeInternalInsetsListener { + private static final String TAG = "StatusBar.EventHole"; + + private boolean mWindowVis; + private int[] mLoc = new int[2]; + + public EventHole(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public EventHole(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs); + } + + @Override + protected void onWindowVisibilityChanged(int visibility) { + super.onWindowVisibilityChanged(visibility); + mWindowVis = visibility == View.VISIBLE; + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + getViewTreeObserver().addOnComputeInternalInsetsListener(this); + } + + @Override + protected void onDetachedFromWindow() { + super.onDetachedFromWindow(); + getViewTreeObserver().removeOnComputeInternalInsetsListener(this); + } + + public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo info) { + final boolean visible = isShown() && mWindowVis && getWidth() > 0 && getHeight() > 0; + final int[] loc = mLoc; + getLocationInWindow(loc); + final int l = loc[0]; + final int r = l + getWidth(); + final int t = loc[1]; + final int b = t + getHeight(); + + View top = this; + while (top.getParent() instanceof View) { + top = (View)top.getParent(); + } + + if (visible) { + info.setTouchableInsets( + ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION); + info.touchableRegion.set(0, 0, top.getWidth(), top.getHeight()); + info.touchableRegion.op(l, t, r, b, Region.Op.DIFFERENCE); + } else { + info.setTouchableInsets( + ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME); + } + } +} +