blob: ed1b2f5c7fafd710f2d57356358da2738ef527c1 [file] [log] [blame]
Daniel Sandlerc4f2a562012-05-04 11:55:46 -04001/*
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
17package com.android.systemui.statusbar.phone;
18
19import android.content.Context;
20import android.util.AttributeSet;
Chris Wren5de6e942012-05-16 14:22:21 -040021import android.util.Log;
Daniel Sandlerc4f2a562012-05-04 11:55:46 -040022import android.view.KeyEvent;
Chris Wren5de6e942012-05-16 14:22:21 -040023import android.view.MotionEvent;
Daniel Sandlerc4f2a562012-05-04 11:55:46 -040024import android.widget.FrameLayout;
25import android.widget.TextSwitcher;
26
Chris Wren5de6e942012-05-16 14:22:21 -040027import com.android.systemui.ExpandHelper;
28import com.android.systemui.R;
29import com.android.systemui.statusbar.policy.NotificationRowLayout;
30
Daniel Sandlerc4f2a562012-05-04 11:55:46 -040031
32public class StatusBarWindowView extends FrameLayout
33{
Chris Wren5de6e942012-05-16 14:22:21 -040034 private static final String TAG = "StatusBarWindowView";
35
36 private ExpandHelper mExpandHelper;
37 private NotificationRowLayout latestItems;
38
Daniel Sandlerc4f2a562012-05-04 11:55:46 -040039 PhoneStatusBar mService;
40
41 public StatusBarWindowView(Context context, AttributeSet attrs) {
42 super(context, attrs);
Chris Wren5de6e942012-05-16 14:22:21 -040043 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 Sandlerc4f2a562012-05-04 11:55:46 -040054 }
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 Wren5de6e942012-05-16 14:22:21 -040068
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 Sandlerc4f2a562012-05-04 11:55:46 -040088}
89