Home | History | Annotate | Download | only in tablet
      1 /*
      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 
     17 package com.android.systemui.statusbar.tablet;
     18 
     19 import android.content.Context;
     20 import android.util.AttributeSet;
     21 import android.view.MotionEvent;
     22 import android.widget.RelativeLayout;
     23 
     24 public class NotificationPeekPanel extends RelativeLayout implements StatusBarPanel {
     25     TabletStatusBar mBar;
     26 
     27     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 
     43     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     }
     54 
     55     @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 }
     68