blob: ba2830605fcefde8192fe1181f1fc9747a73f9ec [file] [log] [blame]
Joe Onorato8a576712010-11-15 16:50:34 -08001/*
2 * Copyright (C) 2010 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.tablet;
18
19import android.content.Context;
20import android.util.AttributeSet;
Daniel Sandler663f0f22011-03-04 16:45:02 -050021import android.view.MotionEvent;
Joe Onorato8a576712010-11-15 16:50:34 -080022import android.widget.RelativeLayout;
23
Joe Onorato8a576712010-11-15 16:50:34 -080024public class NotificationPeekPanel extends RelativeLayout implements StatusBarPanel {
Daniel Sandler663f0f22011-03-04 16:45:02 -050025 TabletStatusBar mBar;
26
Joe Onorato8a576712010-11-15 16:50:34 -080027 public NotificationPeekPanel(Context context, AttributeSet attrs) {
28 this(context, attrs, 0);
29 }
30
31 public NotificationPeekPanel(Context context, AttributeSet attrs, int defStyle) {
32 super(context, attrs, defStyle);
33 }
34
35 public boolean isInContentArea(int x, int y) {
36 final int l = getPaddingLeft();
37 final int r = getWidth() - getPaddingRight();
38 final int t = getPaddingTop();
39 final int b = getHeight() - getPaddingBottom();
40 return x >= l && x < r && y >= t && y < b;
41 }
42
Daniel Sandler663f0f22011-03-04 16:45:02 -050043 public void setBar(TabletStatusBar bar) {
44 mBar = bar;
45 }
46
47 // We don't really want to intercept the touch event, but we *do* want to reset the fade timer
48 // in case the user is interacting with some custom controls or something.
49 @Override
50 public boolean onInterceptTouchEvent(MotionEvent ev) {
51 mBar.resetNotificationPeekFadeTimer();
52 return false;
53 }
Joe Onorato8a576712010-11-15 16:50:34 -080054
Svetoslav Ganov6179ea32011-06-28 01:12:41 -070055 @Override
56 public boolean dispatchHoverEvent(MotionEvent event) {
57 // Ignore hover events outside of this panel bounds since such events
58 // generate spurious accessibility events with the panel content when
59 // tapping outside of it, thus confusing the user.
60 final int x = (int) event.getX();
61 final int y = (int) event.getY();
62 if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) {
63 return super.dispatchHoverEvent(event);
64 }
65 return true;
66 }
67}