Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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.phone; |
| 18 | |
| 19 | import android.content.Context; |
| 20 | import android.util.AttributeSet; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 21 | import android.util.Log; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 22 | import android.view.KeyEvent; |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 23 | import android.view.MotionEvent; |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 24 | import android.widget.FrameLayout; |
| 25 | import android.widget.TextSwitcher; |
| 26 | |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 27 | import com.android.systemui.ExpandHelper; |
| 28 | import com.android.systemui.R; |
| 29 | import com.android.systemui.statusbar.policy.NotificationRowLayout; |
| 30 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 31 | |
| 32 | public class StatusBarWindowView extends FrameLayout |
| 33 | { |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 34 | private static final String TAG = "StatusBarWindowView"; |
| 35 | |
| 36 | private ExpandHelper mExpandHelper; |
| 37 | private NotificationRowLayout latestItems; |
| 38 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 39 | PhoneStatusBar mService; |
| 40 | |
| 41 | public StatusBarWindowView(Context context, AttributeSet attrs) { |
| 42 | super(context, attrs); |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 43 | setMotionEventSplittingEnabled(false); |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | protected void onAttachedToWindow () { |
| 48 | super.onAttachedToWindow(); |
| 49 | latestItems = (NotificationRowLayout) findViewById(R.id.latestItems); |
| 50 | int minHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_min_height); |
| 51 | int maxHeight = getResources().getDimensionPixelSize(R.dimen.notification_row_max_height); |
| 52 | mExpandHelper = new ExpandHelper(mContext, latestItems, minHeight, maxHeight); |
| 53 | mExpandHelper.setEventSource(this); |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 58 | boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 59 | switch (event.getKeyCode()) { |
| 60 | case KeyEvent.KEYCODE_BACK: |
| 61 | if (!down) { |
| 62 | mService.animateCollapse(); |
| 63 | } |
| 64 | return true; |
| 65 | } |
| 66 | return super.dispatchKeyEvent(event); |
| 67 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame^] | 68 | |
| 69 | @Override |
| 70 | public boolean onInterceptTouchEvent(MotionEvent ev) { |
| 71 | MotionEvent cancellation = MotionEvent.obtain(ev); |
| 72 | cancellation.setAction(MotionEvent.ACTION_CANCEL); |
| 73 | |
| 74 | boolean intercept = mExpandHelper.onInterceptTouchEvent(ev) || |
| 75 | super.onInterceptTouchEvent(ev); |
| 76 | if (intercept) { |
| 77 | latestItems.onInterceptTouchEvent(cancellation); |
| 78 | } |
| 79 | return intercept; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public boolean onTouchEvent(MotionEvent ev) { |
| 84 | boolean handled = mExpandHelper.onTouchEvent(ev) || |
| 85 | super.onTouchEvent(ev); |
| 86 | return handled; |
| 87 | } |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 88 | } |
| 89 | |