Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 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 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 19 | import java.io.FileDescriptor; |
| 20 | import java.io.PrintWriter; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 21 | import java.util.ArrayList; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 22 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 23 | import android.animation.LayoutTransition; |
| 24 | import android.animation.ObjectAnimator; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 25 | import android.app.ActivityManagerNative; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 26 | import android.app.PendingIntent; |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 27 | import android.app.Notification; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 28 | import android.app.StatusBarManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 29 | import android.content.Context; |
| 30 | import android.content.Intent; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 31 | import android.content.SharedPreferences; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 32 | import android.content.res.Configuration; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 33 | import android.content.res.Resources; |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 34 | import android.inputmethodservice.InputMethodService; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 35 | import android.graphics.PixelFormat; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 36 | import android.graphics.Rect; |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 37 | import android.graphics.drawable.LayerDrawable; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 38 | import android.os.Handler; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 39 | import android.os.IBinder; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 40 | import android.os.Message; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 41 | import android.os.RemoteException; |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 42 | import android.os.ServiceManager; |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 43 | import android.text.TextUtils; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 44 | import android.util.Slog; |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 45 | import android.view.accessibility.AccessibilityEvent; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 46 | import android.view.Display; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 47 | import android.view.Gravity; |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 48 | import android.view.IWindowManager; |
| 49 | import android.view.KeyEvent; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 50 | import android.view.LayoutInflater; |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 51 | import android.view.MotionEvent; |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 52 | import android.view.SoundEffectConstants; |
Daniel Sandler | 8304da4 | 2010-10-25 15:53:25 -0400 | [diff] [blame] | 53 | import android.view.VelocityTracker; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 54 | import android.view.View; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 55 | import android.view.ViewConfiguration; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 56 | import android.view.ViewGroup; |
| 57 | import android.view.WindowManager; |
| 58 | import android.view.WindowManagerImpl; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 59 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 60 | import android.widget.LinearLayout; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 61 | import android.widget.RemoteViews; |
| 62 | import android.widget.ScrollView; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 63 | import android.widget.TextView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 64 | |
| 65 | import com.android.internal.statusbar.StatusBarIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 66 | import com.android.internal.statusbar.StatusBarNotification; |
| 67 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 68 | import com.android.systemui.R; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 69 | import com.android.systemui.statusbar.*; |
| 70 | import com.android.systemui.statusbar.policy.BatteryController; |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 71 | import com.android.systemui.statusbar.policy.BluetoothController; |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 72 | import com.android.systemui.statusbar.policy.LocationController; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 73 | import com.android.systemui.statusbar.policy.NetworkController; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 74 | import com.android.systemui.statusbar.policy.Prefs; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 75 | import com.android.systemui.recent.RecentApplicationsActivity; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 76 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 77 | public class TabletStatusBar extends StatusBar implements |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 78 | HeightReceiver.OnBarHeightChangedListener, |
| 79 | InputMethodsPanel.OnHardKeyboardEnabledChangeListener { |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 80 | public static final boolean DEBUG = false; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 81 | public static final String TAG = "TabletStatusBar"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 82 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 83 | public static final int MAX_NOTIFICATION_ICONS = 5; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 84 | // IME switcher icon is big and occupy width of two icons |
satok | 5113382 | 2011-01-25 15:01:48 +0900 | [diff] [blame] | 85 | public static final int MAX_NOTIFICATION_ICONS_IME_BUTTON_VISIBLE = MAX_NOTIFICATION_ICONS - 1; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 86 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 87 | public static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
| 88 | public static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 89 | public static final int MSG_OPEN_NOTIFICATION_PEEK = 1002; |
| 90 | public static final int MSG_CLOSE_NOTIFICATION_PEEK = 1003; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 91 | public static final int MSG_OPEN_RECENTS_PANEL = 1020; |
| 92 | public static final int MSG_CLOSE_RECENTS_PANEL = 1021; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 93 | public static final int MSG_SHOW_CHROME = 1030; |
| 94 | public static final int MSG_HIDE_CHROME = 1031; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 95 | public static final int MSG_OPEN_INPUT_METHODS_PANEL = 1040; |
| 96 | public static final int MSG_CLOSE_INPUT_METHODS_PANEL = 1041; |
Daniel Sandler | 2ed08d2 | 2011-01-30 16:07:28 -0500 | [diff] [blame] | 97 | public static final int MSG_STOP_TICKER = 2000; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 98 | |
Daniel Sandler | 3a2fded | 2011-02-23 11:19:59 -0500 | [diff] [blame] | 99 | // Fitts' Law assistance for LatinIME; see policy.EventHole |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 100 | private static final boolean FAKE_SPACE_BAR = true; |
| 101 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 102 | // The height of the bar, as definied by the build. It may be taller if we're plugged |
| 103 | // into hdmi. |
| 104 | int mNaturalBarHeight = -1; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 105 | int mIconSize = -1; |
| 106 | int mIconHPadding = -1; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 107 | |
| 108 | H mHandler = new H(); |
| 109 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 110 | IWindowManager mWindowManager; |
| 111 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 112 | // tracking all current notifications |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 113 | private NotificationData mNotificationData = new NotificationData(); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 114 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 115 | TabletStatusBarView mStatusBarView; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 116 | View mNotificationArea; |
| 117 | View mNotificationTrigger; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 118 | NotificationIconArea mNotificationIconArea; |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 119 | ViewGroup mNavigationArea; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 120 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 121 | boolean mNotificationDNDMode; |
| 122 | NotificationData.Entry mNotificationDNDDummyEntry; |
| 123 | |
Joe Onorato | 536c58f | 2010-11-28 17:52:28 -0800 | [diff] [blame] | 124 | ImageView mBackButton; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 125 | View mHomeButton; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 126 | View mMenuButton; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 127 | View mRecentButton; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 128 | |
Joe Onorato | ec51a82 | 2011-01-04 16:33:01 -0800 | [diff] [blame] | 129 | ViewGroup mNotificationAndImeArea; |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 130 | InputMethodButton mInputMethodSwitchButton; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 131 | |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 132 | NotificationPanel mNotificationPanel; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 133 | WindowManager.LayoutParams mNotificationPanelParams; |
Joe Onorato | 8a57671 | 2010-11-15 16:50:34 -0800 | [diff] [blame] | 134 | NotificationPeekPanel mNotificationPeekWindow; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 135 | ViewGroup mNotificationPeekRow; |
| 136 | int mNotificationPeekIndex; |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 137 | IBinder mNotificationPeekKey; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 138 | LayoutTransition mNotificationPeekScrubLeft, mNotificationPeekScrubRight; |
| 139 | |
| 140 | int mNotificationPeekTapDuration; |
| 141 | int mNotificationFlingVelocity; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 142 | |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 143 | ViewGroup mPile; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 144 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 145 | HeightReceiver mHeightReceiver; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 146 | BatteryController mBatteryController; |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 147 | BluetoothController mBluetoothController; |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 148 | LocationController mLocationController; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 149 | NetworkController mNetworkController; |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 150 | |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 151 | ViewGroup mBarContents; |
| 152 | LayoutTransition mBarContentsLayoutTransition; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 153 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 154 | // hide system chrome ("lights out") support |
| 155 | View mShadow; |
Daniel Sandler | ce70d91 | 2010-09-02 11:59:41 -0400 | [diff] [blame] | 156 | |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 157 | NotificationIconArea.IconLayout mIconLayout; |
| 158 | |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 159 | TabletTicker mTicker; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 160 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 161 | View mFakeSpaceBar; |
| 162 | KeyEvent mSpaceBarKeyEvent = null; |
| 163 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 164 | // for disabling the status bar |
| 165 | int mDisabled = 0; |
| 166 | |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 167 | private RecentAppsPanel mRecentsPanel; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 168 | private InputMethodsPanel mInputMethodsPanel; |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 169 | |
Daniel Sandler | c51451a | 2010-12-16 19:06:46 -0500 | [diff] [blame] | 170 | public Context getContext() { return mContext; } |
| 171 | |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 172 | protected void addPanelWindows() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 173 | final Context context = mContext; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 174 | final Resources res = mContext.getResources(); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 175 | |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 176 | // Notification Panel |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 177 | mNotificationPanel = (NotificationPanel)View.inflate(context, |
Joe Onorato | 755cc74 | 2010-11-27 15:45:35 -0800 | [diff] [blame] | 178 | R.layout.status_bar_notification_panel, null); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 179 | mNotificationPanel.show(false, false); |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 180 | mNotificationPanel.setOnTouchListener( |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 181 | new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PANEL, mNotificationPanel)); |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 182 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 183 | // the battery and network icons |
| 184 | mBatteryController.addIconView((ImageView)mNotificationPanel.findViewById(R.id.battery)); |
| 185 | mBatteryController.addLabelView( |
| 186 | (TextView)mNotificationPanel.findViewById(R.id.battery_text)); |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 187 | mBluetoothController.addIconView( |
| 188 | (ImageView)mNotificationPanel.findViewById(R.id.bluetooth)); |
Joe Onorato | ddbba42 | 2010-11-23 15:42:28 -0800 | [diff] [blame] | 189 | mNetworkController.addCombinedSignalIconView( |
Joe Onorato | 42f8e13 | 2010-11-29 15:52:43 -0800 | [diff] [blame] | 190 | (ImageView)mNotificationPanel.findViewById(R.id.network_signal)); |
| 191 | mNetworkController.addDataTypeIconView( |
| 192 | (ImageView)mNotificationPanel.findViewById(R.id.network_type)); |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 193 | mNetworkController.addDataDirectionOverlayIconView( |
| 194 | (ImageView)mNotificationPanel.findViewById(R.id.network_direction)); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 195 | mNetworkController.addLabelView( |
| 196 | (TextView)mNotificationPanel.findViewById(R.id.network_text)); |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 197 | mNetworkController.addLabelView( |
| 198 | (TextView)mBarContents.findViewById(R.id.network_text)); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 199 | |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 200 | mStatusBarView.setIgnoreChildren(0, mNotificationTrigger, mNotificationPanel); |
Daniel Sandler | d39e388 | 2010-08-31 14:16:13 -0400 | [diff] [blame] | 201 | |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 202 | WindowManager.LayoutParams lp = mNotificationPanelParams = new WindowManager.LayoutParams( |
| 203 | res.getDimensionPixelSize(R.dimen.notification_panel_width), |
| 204 | getNotificationPanelHeight(), |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 205 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 206 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 207 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
Jeff Brown | 46e7529 | 2010-11-10 16:53:45 -0800 | [diff] [blame] | 208 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 209 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 210 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 211 | PixelFormat.TRANSLUCENT); |
Joe Onorato | ea70e63 | 2010-09-27 17:59:37 -0700 | [diff] [blame] | 212 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 213 | lp.setTitle("NotificationPanel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 214 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 215 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 216 | lp.windowAnimations = com.android.internal.R.style.Animation; // == no animation |
Daniel Sandler | 7d9ea8c | 2011-01-11 10:28:58 -0500 | [diff] [blame] | 217 | // lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 218 | |
| 219 | WindowManagerImpl.getDefault().addView(mNotificationPanel, lp); |
| 220 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 221 | // Notification preview window |
Joe Onorato | 8a57671 | 2010-11-15 16:50:34 -0800 | [diff] [blame] | 222 | mNotificationPeekWindow = (NotificationPeekPanel) View.inflate(context, |
Joe Onorato | 755cc74 | 2010-11-27 15:45:35 -0800 | [diff] [blame] | 223 | R.layout.status_bar_notification_peek, null); |
Daniel Sandler | 663f0f2 | 2011-03-04 16:45:02 -0500 | [diff] [blame] | 224 | mNotificationPeekWindow.setBar(this); |
| 225 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 226 | mNotificationPeekRow = (ViewGroup) mNotificationPeekWindow.findViewById(R.id.content); |
| 227 | mNotificationPeekWindow.setVisibility(View.GONE); |
| 228 | mNotificationPeekWindow.setOnTouchListener( |
Joe Onorato | 5e75946 | 2010-11-28 17:43:50 -0800 | [diff] [blame] | 229 | new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PEEK, mNotificationPeekWindow)); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 230 | mNotificationPeekScrubRight = new LayoutTransition(); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 231 | mNotificationPeekScrubRight.setAnimator(LayoutTransition.APPEARING, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 232 | ObjectAnimator.ofInt(null, "left", -512, 0)); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 233 | mNotificationPeekScrubRight.setAnimator(LayoutTransition.DISAPPEARING, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 234 | ObjectAnimator.ofInt(null, "left", -512, 0)); |
| 235 | mNotificationPeekScrubRight.setDuration(500); |
| 236 | |
| 237 | mNotificationPeekScrubLeft = new LayoutTransition(); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 238 | mNotificationPeekScrubLeft.setAnimator(LayoutTransition.APPEARING, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 239 | ObjectAnimator.ofInt(null, "left", 512, 0)); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 240 | mNotificationPeekScrubLeft.setAnimator(LayoutTransition.DISAPPEARING, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 241 | ObjectAnimator.ofInt(null, "left", 512, 0)); |
| 242 | mNotificationPeekScrubLeft.setDuration(500); |
| 243 | |
| 244 | // XXX: setIgnoreChildren? |
| 245 | lp = new WindowManager.LayoutParams( |
| 246 | 512, // ViewGroup.LayoutParams.WRAP_CONTENT, |
| 247 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 248 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 249 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
Jeff Brown | 46e7529 | 2010-11-10 16:53:45 -0800 | [diff] [blame] | 250 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 251 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 252 | PixelFormat.TRANSLUCENT); |
| 253 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
| 254 | lp.setTitle("NotificationPeekWindow"); |
| 255 | lp.windowAnimations = com.android.internal.R.style.Animation_Toast; |
| 256 | |
| 257 | WindowManagerImpl.getDefault().addView(mNotificationPeekWindow, lp); |
| 258 | |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 259 | // Recents Panel |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 260 | mRecentsPanel = (RecentAppsPanel) View.inflate(context, |
| 261 | R.layout.status_bar_recent_panel, null); |
| 262 | mRecentsPanel.setVisibility(View.GONE); |
| 263 | mRecentsPanel.setOnTouchListener(new TouchOutsideListener(MSG_CLOSE_RECENTS_PANEL, |
| 264 | mRecentsPanel)); |
| 265 | mStatusBarView.setIgnoreChildren(2, mRecentButton, mRecentsPanel); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 266 | |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 267 | lp = new WindowManager.LayoutParams( |
| 268 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 269 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 270 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 271 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 272 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 273 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 274 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 275 | PixelFormat.TRANSLUCENT); |
| 276 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 277 | lp.setTitle("RecentsPanel"); |
| 278 | lp.windowAnimations = R.style.Animation_RecentPanel; |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 279 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 280 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 281 | |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 282 | WindowManagerImpl.getDefault().addView(mRecentsPanel, lp); |
| 283 | mRecentsPanel.setBar(this); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 284 | |
| 285 | // Input methods Panel |
| 286 | mInputMethodsPanel = (InputMethodsPanel) View.inflate(context, |
| 287 | R.layout.status_bar_input_methods_panel, null); |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 288 | mInputMethodsPanel.setHardKeyboardEnabledChangeListener(this); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 289 | mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener( |
| 290 | MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel)); |
satok | 913f42d | 2011-01-17 16:58:10 +0900 | [diff] [blame] | 291 | mInputMethodsPanel.setImeSwitchButton(mInputMethodSwitchButton); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 292 | mStatusBarView.setIgnoreChildren(3, mInputMethodSwitchButton, mInputMethodsPanel); |
| 293 | lp = new WindowManager.LayoutParams( |
| 294 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 295 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 296 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 297 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 298 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 299 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 300 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 301 | PixelFormat.TRANSLUCENT); |
| 302 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
| 303 | lp.setTitle("InputMethodsPanel"); |
| 304 | lp.windowAnimations = R.style.Animation_RecentPanel; |
| 305 | |
| 306 | WindowManagerImpl.getDefault().addView(mInputMethodsPanel, lp); |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 307 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 308 | |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 309 | private int getNotificationPanelHeight() { |
| 310 | final Resources res = mContext.getResources(); |
| 311 | final Display d = WindowManagerImpl.getDefault().getDefaultDisplay(); |
| 312 | return Math.max(res.getDimensionPixelSize(R.dimen.notification_panel_min_height), |
| 313 | d.getHeight()); |
| 314 | } |
| 315 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 316 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 317 | public void start() { |
| 318 | super.start(); // will add the main bar view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 319 | } |
| 320 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 321 | @Override |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 322 | protected void onConfigurationChanged(Configuration newConfig) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 323 | loadDimens(); |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 324 | mNotificationPanelParams.height = getNotificationPanelHeight(); |
| 325 | WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel, |
| 326 | mNotificationPanelParams); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | protected void loadDimens() { |
| 330 | final Resources res = mContext.getResources(); |
| 331 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 332 | mNaturalBarHeight = res.getDimensionPixelSize( |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame^] | 333 | com.android.internal.R.dimen.system_bar_height); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 334 | |
| 335 | int newIconSize = res.getDimensionPixelSize( |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame^] | 336 | com.android.internal.R.dimen.system_bar_icon_size); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 337 | int newIconHPadding = res.getDimensionPixelSize( |
| 338 | R.dimen.status_bar_icon_padding); |
| 339 | |
| 340 | if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { |
| 341 | // Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); |
| 342 | mIconHPadding = newIconHPadding; |
| 343 | mIconSize = newIconSize; |
| 344 | reloadAllNotificationIcons(); // reload the tray |
| 345 | } |
| 346 | } |
| 347 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 348 | protected View makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 349 | final Context context = mContext; |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 350 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 351 | mWindowManager = IWindowManager.Stub.asInterface( |
| 352 | ServiceManager.getService(Context.WINDOW_SERVICE)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 353 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 354 | // This guy will listen for HDMI plugged broadcasts so we can resize the |
| 355 | // status bar as appropriate. |
| 356 | mHeightReceiver = new HeightReceiver(mContext); |
| 357 | mHeightReceiver.registerReceiver(); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 358 | loadDimens(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 359 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 360 | final TabletStatusBarView sb = (TabletStatusBarView)View.inflate( |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 361 | context, R.layout.status_bar, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 362 | mStatusBarView = sb; |
| 363 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 364 | sb.setHandler(mHandler); |
| 365 | |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 366 | mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents); |
| 367 | // layout transitions for the status bar's contents |
| 368 | mBarContentsLayoutTransition = new LayoutTransition(); |
| 369 | // add/removal will fade as normal |
| 370 | mBarContentsLayoutTransition.setAnimator(LayoutTransition.APPEARING, |
| 371 | ObjectAnimator.ofFloat(null, "alpha", 0f, 1f)); |
| 372 | mBarContentsLayoutTransition.setAnimator(LayoutTransition.DISAPPEARING, |
| 373 | ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); |
| 374 | // no animations for siblings on change: just jump into place please |
| 375 | mBarContentsLayoutTransition.setAnimator(LayoutTransition.CHANGE_APPEARING, null); |
| 376 | mBarContentsLayoutTransition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING, null); |
| 377 | // quick like bunny |
| 378 | mBarContentsLayoutTransition.setDuration(250 * (DEBUG?10:1)); |
| 379 | mBarContents.setLayoutTransition(mBarContentsLayoutTransition); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 380 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 381 | // the whole right-hand side of the bar |
| 382 | mNotificationArea = sb.findViewById(R.id.notificationArea); |
| 383 | |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 384 | // the button to open the notification area |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 385 | mNotificationTrigger = sb.findViewById(R.id.notificationTrigger); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 386 | mNotificationTrigger.setOnTouchListener(new NotificationTriggerTouchListener()); |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 387 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 388 | // the more notifications icon |
| 389 | mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons); |
| 390 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 391 | // where the icons go |
| 392 | mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 393 | mIconLayout.setOnTouchListener(new NotificationIconTouchListener()); |
| 394 | |
| 395 | ViewConfiguration vc = ViewConfiguration.get(context); |
| 396 | mNotificationPeekTapDuration = vc.getTapTimeout(); |
| 397 | mNotificationFlingVelocity = 300; // px/s |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 398 | |
Daniel Sandler | c51451a | 2010-12-16 19:06:46 -0500 | [diff] [blame] | 399 | mTicker = new TabletTicker(this); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 400 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 401 | // The icons |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 402 | mLocationController = new LocationController(mContext); // will post a notification |
| 403 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 404 | mBatteryController = new BatteryController(mContext); |
| 405 | mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 406 | mBluetoothController = new BluetoothController(mContext); |
| 407 | mBluetoothController.addIconView((ImageView)sb.findViewById(R.id.bluetooth)); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 408 | mNetworkController = new NetworkController(mContext); |
Joe Onorato | 42f8e13 | 2010-11-29 15:52:43 -0800 | [diff] [blame] | 409 | mNetworkController.addCombinedSignalIconView( |
| 410 | (ImageView)sb.findViewById(R.id.network_signal)); |
| 411 | mNetworkController.addDataTypeIconView( |
| 412 | (ImageView)sb.findViewById(R.id.network_type)); |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 413 | mNetworkController.addDataDirectionOverlayIconView( |
| 414 | (ImageView)sb.findViewById(R.id.network_direction)); |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 415 | |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 416 | // The navigation buttons |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 417 | mBackButton = (ImageView)sb.findViewById(R.id.back); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 418 | mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 419 | mHomeButton = mNavigationArea.findViewById(R.id.home); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 420 | mMenuButton = mNavigationArea.findViewById(R.id.menu); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 421 | mRecentButton = mNavigationArea.findViewById(R.id.recent_apps); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 422 | mRecentButton.setOnClickListener(mOnClickListener); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 423 | mNavigationArea.setLayoutTransition(mBarContentsLayoutTransition); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 424 | |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 425 | // The bar contents buttons |
Joe Onorato | ec51a82 | 2011-01-04 16:33:01 -0800 | [diff] [blame] | 426 | mNotificationAndImeArea = (ViewGroup)sb.findViewById(R.id.notificationAndImeArea); |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 427 | mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 428 | // Overwrite the lister |
| 429 | mInputMethodSwitchButton.setOnClickListener(mOnClickListener); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 430 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 431 | // for redirecting errant bar taps to the IME |
| 432 | mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar); |
| 433 | |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 434 | // "shadows" of the status bar features, for lights-out mode |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 435 | mShadow = sb.findViewById(R.id.bar_shadow); |
| 436 | mShadow.setOnTouchListener( |
| 437 | new View.OnTouchListener() { |
| 438 | public boolean onTouch(View v, MotionEvent ev) { |
| 439 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | d720155 | 2011-01-28 09:58:02 -0500 | [diff] [blame] | 440 | // even though setting the systemUI visibility below will turn these views |
| 441 | // on, we need them to come up faster so that they can catch this motion |
| 442 | // event |
| 443 | mShadow.setVisibility(View.GONE); |
| 444 | mBarContents.setVisibility(View.VISIBLE); |
| 445 | |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 446 | try { |
| 447 | mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); |
| 448 | } catch (RemoteException ex) { |
| 449 | // system process dead |
| 450 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 451 | } |
| 452 | return false; |
| 453 | } |
| 454 | }); |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 455 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 456 | // tuning parameters |
| 457 | final int LIGHTS_GOING_OUT_SYSBAR_DURATION = 600; |
| 458 | final int LIGHTS_GOING_OUT_SHADOW_DURATION = 1000; |
| 459 | final int LIGHTS_GOING_OUT_SHADOW_DELAY = 500; |
| 460 | |
| 461 | final int LIGHTS_COMING_UP_SYSBAR_DURATION = 200; |
| 462 | // final int LIGHTS_COMING_UP_SYSBAR_DELAY = 50; |
| 463 | final int LIGHTS_COMING_UP_SHADOW_DURATION = 0; |
| 464 | |
| 465 | LayoutTransition xition = new LayoutTransition(); |
| 466 | xition.setAnimator(LayoutTransition.APPEARING, |
| 467 | ObjectAnimator.ofFloat(null, "alpha", 0.5f, 1f)); |
| 468 | xition.setDuration(LayoutTransition.APPEARING, LIGHTS_COMING_UP_SYSBAR_DURATION); |
| 469 | xition.setStartDelay(LayoutTransition.APPEARING, 0); |
| 470 | xition.setAnimator(LayoutTransition.DISAPPEARING, |
| 471 | ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); |
| 472 | xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_GOING_OUT_SYSBAR_DURATION); |
| 473 | xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); |
| 474 | ((ViewGroup)sb.findViewById(R.id.bar_contents_holder)).setLayoutTransition(xition); |
| 475 | |
| 476 | xition = new LayoutTransition(); |
| 477 | xition.setAnimator(LayoutTransition.APPEARING, |
| 478 | ObjectAnimator.ofFloat(null, "alpha", 0f, 1f)); |
| 479 | xition.setDuration(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DURATION); |
| 480 | xition.setStartDelay(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DELAY); |
| 481 | xition.setAnimator(LayoutTransition.DISAPPEARING, |
| 482 | ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); |
| 483 | xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_COMING_UP_SHADOW_DURATION); |
| 484 | xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); |
| 485 | ((ViewGroup)sb.findViewById(R.id.bar_shadow_holder)).setLayoutTransition(xition); |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 486 | |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 487 | // set the initial view visibility |
| 488 | setAreThereNotifications(); |
| 489 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 490 | // Add the windows |
| 491 | addPanelWindows(); |
| 492 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 493 | mPile = (ViewGroup)mNotificationPanel.findViewById(R.id.content); |
| 494 | mPile.removeAllViews(); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 495 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 496 | ScrollView scroller = (ScrollView)mPile.getParent(); |
| 497 | scroller.setFillViewport(true); |
| 498 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 499 | mHeightReceiver.addOnBarHeightChangedListener(this); |
| 500 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 501 | return sb; |
| 502 | } |
| 503 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 504 | public int getStatusBarHeight() { |
| 505 | return mHeightReceiver.getHeight(); |
| 506 | } |
| 507 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 508 | protected int getStatusBarGravity() { |
| 509 | return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; |
| 510 | } |
| 511 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 512 | public void onBarHeightChanged(int height) { |
| 513 | final WindowManager.LayoutParams lp |
| 514 | = (WindowManager.LayoutParams)mStatusBarView.getLayoutParams(); |
| 515 | if (lp == null) { |
| 516 | // haven't been added yet |
| 517 | return; |
| 518 | } |
| 519 | if (lp.height != height) { |
| 520 | lp.height = height; |
| 521 | final WindowManager wm = WindowManagerImpl.getDefault(); |
| 522 | wm.updateViewLayout(mStatusBarView, lp); |
| 523 | } |
| 524 | } |
| 525 | |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 526 | private class H extends Handler { |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 527 | public void handleMessage(Message m) { |
| 528 | switch (m.what) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 529 | case MSG_OPEN_NOTIFICATION_PEEK: |
| 530 | if (DEBUG) Slog.d(TAG, "opening notification peek window; arg=" + m.arg1); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 531 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 532 | if (m.arg1 >= 0) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 533 | final int N = mNotificationData.size(); |
| 534 | |
| 535 | if (!mNotificationDNDMode) { |
| 536 | if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { |
| 537 | NotificationData.Entry entry = mNotificationData.get(N-1-mNotificationPeekIndex); |
| 538 | entry.icon.setBackgroundColor(0); |
| 539 | mNotificationPeekIndex = -1; |
| 540 | mNotificationPeekKey = null; |
| 541 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | final int peekIndex = m.arg1; |
| 545 | if (peekIndex < N) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 546 | //Slog.d(TAG, "loading peek: " + peekIndex); |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 547 | NotificationData.Entry entry = |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 548 | mNotificationDNDMode |
| 549 | ? mNotificationDNDDummyEntry |
| 550 | : mNotificationData.get(N-1-peekIndex); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 551 | NotificationData.Entry copy = new NotificationData.Entry( |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 552 | entry.key, |
| 553 | entry.notification, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 554 | entry.icon); |
| 555 | inflateViews(copy, mNotificationPeekRow); |
| 556 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 557 | if (mNotificationDNDMode) { |
| 558 | copy.content.setOnClickListener(new View.OnClickListener() { |
| 559 | public void onClick(View v) { |
| 560 | SharedPreferences.Editor editor = Prefs.edit(mContext); |
| 561 | editor.putBoolean(Prefs.DO_NOT_DISTURB_PREF, false); |
| 562 | editor.apply(); |
| 563 | animateCollapse(); |
| 564 | } |
| 565 | }); |
| 566 | } |
| 567 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 568 | entry.icon.setBackgroundColor(0x20FFFFFF); |
| 569 | |
| 570 | // mNotificationPeekRow.setLayoutTransition( |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 571 | // peekIndex < mNotificationPeekIndex |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 572 | // ? mNotificationPeekScrubLeft |
| 573 | // : mNotificationPeekScrubRight); |
| 574 | |
| 575 | mNotificationPeekRow.removeAllViews(); |
| 576 | mNotificationPeekRow.addView(copy.row); |
| 577 | |
| 578 | mNotificationPeekWindow.setVisibility(View.VISIBLE); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 579 | mNotificationPanel.show(false, true); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 580 | |
| 581 | mNotificationPeekIndex = peekIndex; |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 582 | mNotificationPeekKey = entry.key; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 583 | } |
| 584 | } |
| 585 | break; |
| 586 | case MSG_CLOSE_NOTIFICATION_PEEK: |
| 587 | if (DEBUG) Slog.d(TAG, "closing notification peek window"); |
| 588 | mNotificationPeekWindow.setVisibility(View.GONE); |
| 589 | mNotificationPeekRow.removeAllViews(); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 590 | |
| 591 | final int N = mNotificationData.size(); |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 592 | if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 593 | NotificationData.Entry entry = |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 594 | mNotificationDNDMode |
| 595 | ? mNotificationDNDDummyEntry |
| 596 | : mNotificationData.get(N-1-mNotificationPeekIndex); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 597 | entry.icon.setBackgroundColor(0); |
| 598 | } |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 599 | |
| 600 | mNotificationPeekIndex = -1; |
| 601 | mNotificationPeekKey = null; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 602 | break; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 603 | case MSG_OPEN_NOTIFICATION_PANEL: |
| 604 | if (DEBUG) Slog.d(TAG, "opening notifications panel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 605 | if (!mNotificationPanel.isShowing()) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 606 | mNotificationPeekWindow.setVisibility(View.GONE); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 607 | mNotificationPanel.show(true, true); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 608 | mNotificationArea.setVisibility(View.INVISIBLE); |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 609 | mTicker.halt(); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 610 | } |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 611 | break; |
| 612 | case MSG_CLOSE_NOTIFICATION_PANEL: |
| 613 | if (DEBUG) Slog.d(TAG, "closing notifications panel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 614 | if (mNotificationPanel.isShowing()) { |
| 615 | mNotificationPanel.show(false, true); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 616 | mNotificationArea.setVisibility(View.VISIBLE); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 617 | } |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 618 | break; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 619 | case MSG_OPEN_RECENTS_PANEL: |
| 620 | if (DEBUG) Slog.d(TAG, "opening recents panel"); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 621 | if (mRecentsPanel != null) { |
Jim Miller | b5a2b29 | 2011-03-01 16:14:59 -0800 | [diff] [blame] | 622 | disable(StatusBarManager.DISABLE_BACK); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 623 | mRecentsPanel.setVisibility(View.VISIBLE); |
| 624 | mRecentsPanel.show(true, true); |
| 625 | } |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 626 | break; |
| 627 | case MSG_CLOSE_RECENTS_PANEL: |
| 628 | if (DEBUG) Slog.d(TAG, "closing recents panel"); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 629 | if (mRecentsPanel != null && mRecentsPanel.isShowing()) { |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 630 | disable(StatusBarManager.DISABLE_NONE); |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 631 | mRecentsPanel.show(false, true); |
| 632 | } |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 633 | break; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 634 | case MSG_OPEN_INPUT_METHODS_PANEL: |
| 635 | if (DEBUG) Slog.d(TAG, "opening input methods panel"); |
Tadashi G. Takaoka | e385f0c | 2011-02-01 02:57:44 +0900 | [diff] [blame] | 636 | if (mInputMethodsPanel != null) mInputMethodsPanel.openPanel(); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 637 | break; |
| 638 | case MSG_CLOSE_INPUT_METHODS_PANEL: |
| 639 | if (DEBUG) Slog.d(TAG, "closing input methods panel"); |
Tadashi G. Takaoka | e385f0c | 2011-02-01 02:57:44 +0900 | [diff] [blame] | 640 | if (mInputMethodsPanel != null) mInputMethodsPanel.closePanel(false); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 641 | break; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 642 | case MSG_SHOW_CHROME: |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 643 | if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)"); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 644 | mBarContents.setVisibility(View.VISIBLE); |
| 645 | mShadow.setVisibility(View.GONE); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 646 | notifyLightsChanged(true); |
Daniel Sandler | 06e6630 | 2010-11-05 15:00:06 -0400 | [diff] [blame] | 647 | break; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 648 | case MSG_HIDE_CHROME: |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 649 | if (DEBUG) Slog.d(TAG, "showing shadows (lights out)"); |
Daniel Sandler | 06e6630 | 2010-11-05 15:00:06 -0400 | [diff] [blame] | 650 | animateCollapse(); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 651 | mBarContents.setVisibility(View.GONE); |
| 652 | mShadow.setVisibility(View.VISIBLE); |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 653 | notifyLightsChanged(false); |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 654 | break; |
Daniel Sandler | 2ed08d2 | 2011-01-30 16:07:28 -0500 | [diff] [blame] | 655 | case MSG_STOP_TICKER: |
| 656 | mTicker.halt(); |
| 657 | break; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 658 | } |
| 659 | } |
| 660 | } |
Daniel Sandler | 271ea12 | 2010-10-22 14:06:10 -0400 | [diff] [blame] | 661 | |
Joe Onorato | 664644d | 2011-01-23 17:53:23 -0800 | [diff] [blame] | 662 | private void notifyLightsChanged(boolean shown) { |
| 663 | try { |
| 664 | Slog.d(TAG, "lights " + (shown?"on":"out")); |
| 665 | mWindowManager.statusBarVisibilityChanged( |
| 666 | shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN); |
| 667 | } catch (RemoteException ex) { |
| 668 | } |
| 669 | } |
| 670 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 671 | public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 672 | if (DEBUG) Slog.d(TAG, "addIcon(" + slot + ") -> " + icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | public void updateIcon(String slot, int index, int viewIndex, |
| 676 | StatusBarIcon old, StatusBarIcon icon) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 677 | if (DEBUG) Slog.d(TAG, "updateIcon(" + slot + ") -> " + icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | public void removeIcon(String slot, int index, int viewIndex) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 681 | if (DEBUG) Slog.d(TAG, "removeIcon(" + slot + ")"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | public void addNotification(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 685 | if (DEBUG) Slog.d(TAG, "addNotification(" + key + " -> " + notification + ")"); |
| 686 | addNotificationViews(key, notification); |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 687 | |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 688 | final boolean immersive = isImmersive(); |
Joe Onorato | cf2b199 | 2010-11-16 21:36:42 -0800 | [diff] [blame] | 689 | if (false && immersive) { |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 690 | // TODO: immersive mode popups for tablet |
| 691 | } else if (notification.notification.fullScreenIntent != null) { |
| 692 | // not immersive & a full-screen alert should be shown |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 693 | Slog.w(TAG, "Notification has fullScreenIntent and activity is not immersive;" |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 694 | + " sending fullScreenIntent"); |
| 695 | try { |
| 696 | notification.notification.fullScreenIntent.send(); |
| 697 | } catch (PendingIntent.CanceledException e) { |
| 698 | } |
| 699 | } else { |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 700 | tick(key, notification, true); |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 701 | } |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 702 | |
| 703 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | public void updateNotification(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 707 | if (DEBUG) Slog.d(TAG, "updateNotification(" + key + " -> " + notification + ")"); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 708 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 709 | final NotificationData.Entry oldEntry = mNotificationData.findByKey(key); |
Daniel Sandler | 379020a | 2010-07-29 16:20:06 -0400 | [diff] [blame] | 710 | if (oldEntry == null) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 711 | Slog.w(TAG, "updateNotification for unknown key: " + key); |
| 712 | return; |
| 713 | } |
| 714 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 715 | final StatusBarNotification oldNotification = oldEntry.notification; |
| 716 | final RemoteViews oldContentView = oldNotification.notification.contentView; |
| 717 | |
| 718 | final RemoteViews contentView = notification.notification.contentView; |
| 719 | |
Daniel Sandler | 373a998 | 2010-11-30 12:03:59 -0500 | [diff] [blame] | 720 | if (DEBUG) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 721 | Slog.d(TAG, "old notification: when=" + oldNotification.notification.when |
| 722 | + " ongoing=" + oldNotification.isOngoing() |
| 723 | + " expanded=" + oldEntry.expanded |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 724 | + " contentView=" + oldContentView |
| 725 | + " rowParent=" + oldEntry.row.getParent()); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 726 | Slog.d(TAG, "new notification: when=" + notification.notification.when |
| 727 | + " ongoing=" + oldNotification.isOngoing() |
| 728 | + " contentView=" + contentView); |
| 729 | } |
| 730 | |
| 731 | // Can we just reapply the RemoteViews in place? If when didn't change, the order |
| 732 | // didn't change. |
Joe Onorato | 80a4440 | 2011-01-15 16:22:24 -0800 | [diff] [blame] | 733 | boolean contentsUnchanged = oldEntry.expanded != null |
| 734 | && contentView != null && oldContentView != null |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 735 | && contentView.getPackage() != null |
| 736 | && oldContentView.getPackage() != null |
| 737 | && oldContentView.getPackage().equals(contentView.getPackage()) |
Joe Onorato | c9596d6 | 2011-01-12 17:03:11 -0800 | [diff] [blame] | 738 | && oldContentView.getLayoutId() == contentView.getLayoutId(); |
Daniel Sandler | 373a998 | 2010-11-30 12:03:59 -0500 | [diff] [blame] | 739 | ViewGroup rowParent = (ViewGroup) oldEntry.row.getParent(); |
Joe Onorato | 80a4440 | 2011-01-15 16:22:24 -0800 | [diff] [blame] | 740 | boolean orderUnchanged = notification.notification.when==oldNotification.notification.when |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 741 | && notification.priority == oldNotification.priority; |
Daniel Sandler | a31e419 | 2011-02-02 22:00:28 -0500 | [diff] [blame] | 742 | // priority now encompasses isOngoing() |
Joe Onorato | c9596d6 | 2011-01-12 17:03:11 -0800 | [diff] [blame] | 743 | boolean isLastAnyway = rowParent.indexOfChild(oldEntry.row) == rowParent.getChildCount()-1; |
| 744 | if (contentsUnchanged && (orderUnchanged || isLastAnyway)) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 745 | if (DEBUG) Slog.d(TAG, "reusing notification for key: " + key); |
| 746 | oldEntry.notification = notification; |
| 747 | try { |
| 748 | // Reapply the RemoteViews |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 749 | contentView.reapply(mContext, oldEntry.content); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 750 | // update the contentIntent |
| 751 | final PendingIntent contentIntent = notification.notification.contentIntent; |
| 752 | if (contentIntent != null) { |
| 753 | oldEntry.content.setOnClickListener(new NotificationClicker(contentIntent, |
| 754 | notification.pkg, notification.tag, notification.id)); |
Joe Onorato | 184498c | 2010-10-08 17:57:18 -0400 | [diff] [blame] | 755 | } else { |
| 756 | oldEntry.content.setOnClickListener(null); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 757 | } |
| 758 | // Update the icon. |
| 759 | final StatusBarIcon ic = new StatusBarIcon(notification.pkg, |
| 760 | notification.notification.icon, notification.notification.iconLevel, |
| 761 | notification.notification.number); |
| 762 | if (!oldEntry.icon.set(ic)) { |
| 763 | handleNotificationError(key, notification, "Couldn't update icon: " + ic); |
| 764 | return; |
| 765 | } |
Joe Onorato | 80a4440 | 2011-01-15 16:22:24 -0800 | [diff] [blame] | 766 | // Update the large icon |
| 767 | if (notification.notification.largeIcon != null) { |
| 768 | oldEntry.largeIcon.setImageBitmap(notification.notification.largeIcon); |
| 769 | } else { |
| 770 | oldEntry.largeIcon.getLayoutParams().width = 0; |
| 771 | oldEntry.largeIcon.setVisibility(View.INVISIBLE); |
| 772 | } |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 773 | |
Daniel Sandler | 7ef29b5 | 2010-12-16 17:29:50 -0500 | [diff] [blame] | 774 | if (key == mNotificationPeekKey) { |
| 775 | // must update the peek window |
| 776 | Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); |
| 777 | peekMsg.arg1 = mNotificationPeekIndex; |
| 778 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
| 779 | mHandler.sendMessage(peekMsg); |
| 780 | } |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 781 | } |
| 782 | catch (RuntimeException e) { |
| 783 | // It failed to add cleanly. Log, and remove the view from the panel. |
| 784 | Slog.w(TAG, "Couldn't reapply views for package " + contentView.getPackage(), e); |
| 785 | removeNotificationViews(key); |
| 786 | addNotificationViews(key, notification); |
| 787 | } |
| 788 | } else { |
| 789 | if (DEBUG) Slog.d(TAG, "not reusing notification for key: " + key); |
| 790 | removeNotificationViews(key); |
| 791 | addNotificationViews(key, notification); |
| 792 | } |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 793 | // fullScreenIntent doesn't happen on updates. You need to clear & repost a new |
| 794 | // notification. |
| 795 | final boolean immersive = isImmersive(); |
| 796 | if (false && immersive) { |
| 797 | // TODO: immersive mode |
| 798 | } else { |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 799 | tick(key, notification, false); |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 800 | } |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 801 | |
| 802 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 803 | } |
| 804 | |
| 805 | public void removeNotification(IBinder key) { |
Daniel Sandler | 3a2fded | 2011-02-23 11:19:59 -0500 | [diff] [blame] | 806 | if (DEBUG) Slog.d(TAG, "removeNotification(" + key + ")"); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 807 | removeNotificationViews(key); |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 808 | mTicker.remove(key); |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 809 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 810 | } |
| 811 | |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 812 | public void showClock(boolean show) { |
| 813 | View clock = mBarContents.findViewById(R.id.clock); |
| 814 | View network_text = mBarContents.findViewById(R.id.network_text); |
| 815 | if (clock != null) { |
| 816 | clock.setVisibility(show ? View.VISIBLE : View.GONE); |
| 817 | } |
| 818 | if (network_text != null) { |
| 819 | network_text.setVisibility((!show) ? View.VISIBLE : View.GONE); |
| 820 | } |
| 821 | } |
| 822 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 823 | public void disable(int state) { |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 824 | int old = mDisabled; |
| 825 | int diff = state ^ old; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 826 | mDisabled = state; |
| 827 | |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 828 | // act accordingly |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 829 | if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 830 | boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 831 | Slog.i(TAG, "DISABLE_CLOCK: " + (show ? "no" : "yes")); |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 832 | showClock(show); |
| 833 | } |
Daniel Sandler | 6f6cf3c | 2010-12-16 12:54:03 -0500 | [diff] [blame] | 834 | if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 835 | boolean show = (state & StatusBarManager.DISABLE_SYSTEM_INFO) == 0; |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 836 | Slog.i(TAG, "DISABLE_SYSTEM_INFO: " + (show ? "no" : "yes")); |
Daniel Sandler | 6f6cf3c | 2010-12-16 12:54:03 -0500 | [diff] [blame] | 837 | mNotificationTrigger.setVisibility(show ? View.VISIBLE : View.GONE); |
| 838 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 839 | if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 840 | if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 841 | Slog.i(TAG, "DISABLE_EXPAND: yes"); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 842 | animateCollapse(); |
| 843 | } |
| 844 | } |
| 845 | if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 846 | mNotificationDNDMode = Prefs.read(mContext) |
| 847 | .getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT); |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 848 | |
| 849 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 850 | Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes" + (mNotificationDNDMode?" (DND)":"")); |
| 851 | mTicker.halt(); |
| 852 | } else { |
| 853 | Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no" + (mNotificationDNDMode?" (DND)":"")); |
| 854 | } |
| 855 | |
| 856 | // refresh icons to show either notifications or the DND message |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 857 | reloadAllNotificationIcons(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 858 | } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 859 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 860 | mTicker.halt(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 861 | } |
| 862 | } |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 863 | if ((diff & StatusBarManager.DISABLE_NAVIGATION) != 0) { |
| 864 | if ((state & StatusBarManager.DISABLE_NAVIGATION) != 0) { |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 865 | Slog.i(TAG, "DISABLE_NAVIGATION: yes"); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 866 | mNavigationArea.setVisibility(View.INVISIBLE); |
satok | b70c82d | 2010-12-20 17:59:19 +0900 | [diff] [blame] | 867 | mInputMethodSwitchButton.setScreenLocked(true); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 868 | } else { |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 869 | Slog.i(TAG, "DISABLE_NAVIGATION: no"); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 870 | mNavigationArea.setVisibility(View.VISIBLE); |
satok | b70c82d | 2010-12-20 17:59:19 +0900 | [diff] [blame] | 871 | mInputMethodSwitchButton.setScreenLocked(false); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 872 | } |
| 873 | } |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 874 | if ((diff & StatusBarManager.DISABLE_BACK) != 0) { |
| 875 | if ((state & StatusBarManager.DISABLE_BACK) != 0) { |
| 876 | Slog.i(TAG, "DISABLE_BACK: yes"); |
| 877 | mBackButton.setVisibility(View.INVISIBLE); |
| 878 | mInputMethodSwitchButton.setScreenLocked(true); |
| 879 | } else { |
| 880 | Slog.i(TAG, "DISABLE_BACK: no"); |
| 881 | mBackButton.setVisibility(View.VISIBLE); |
| 882 | mInputMethodSwitchButton.setScreenLocked(false); |
| 883 | } |
| 884 | } |
| 885 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 886 | } |
| 887 | |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 888 | private boolean hasTicker(Notification n) { |
Joe Onorato | 46439ce | 2010-11-19 13:56:21 -0800 | [diff] [blame] | 889 | return n.tickerView != null || !TextUtils.isEmpty(n.tickerText); |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 890 | } |
| 891 | |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 892 | private void tick(IBinder key, StatusBarNotification n, boolean firstTime) { |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 893 | // Don't show the ticker when the windowshade is open. |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 894 | if (mNotificationPanel.isShowing()) { |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 895 | return; |
| 896 | } |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 897 | // If they asked for FLAG_ONLY_ALERT_ONCE, then only show this notification |
| 898 | // if it's a new notification. |
| 899 | if (!firstTime && (n.notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0) { |
| 900 | return; |
| 901 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 902 | // Show the ticker if one is requested. Also don't do this |
| 903 | // until status bar window is attached to the window manager, |
| 904 | // because... well, what's the point otherwise? And trying to |
| 905 | // run a ticker without being attached will crash! |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 906 | if (hasTicker(n.notification) && mStatusBarView.getWindowToken() != null) { |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 907 | if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS |
| 908 | | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 909 | mTicker.add(key, n); |
Joe Onorato | ec51a82 | 2011-01-04 16:33:01 -0800 | [diff] [blame] | 910 | mNotificationAndImeArea.setVisibility(View.GONE); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | } |
| 914 | |
Daniel Sandler | b8027d8 | 2010-12-16 19:35:54 -0500 | [diff] [blame] | 915 | // called by TabletTicker when it's done with all queued ticks |
| 916 | public void doneTicking() { |
Joe Onorato | ec51a82 | 2011-01-04 16:33:01 -0800 | [diff] [blame] | 917 | mNotificationAndImeArea.setVisibility(View.VISIBLE); |
Daniel Sandler | b8027d8 | 2010-12-16 19:35:54 -0500 | [diff] [blame] | 918 | } |
| 919 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 920 | public void animateExpand() { |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 921 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); |
| 922 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
| 923 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 924 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL); |
| 925 | mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 926 | } |
| 927 | |
| 928 | public void animateCollapse() { |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 929 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PANEL); |
| 930 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PANEL); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 931 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 932 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 933 | mHandler.removeMessages(MSG_CLOSE_INPUT_METHODS_PANEL); |
| 934 | mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 935 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); |
| 936 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 937 | } |
| 938 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 939 | // called by StatusBar |
Daniel Sandler | 06e6630 | 2010-11-05 15:00:06 -0400 | [diff] [blame] | 940 | @Override |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 941 | public void setLightsOn(boolean on) { |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 942 | // Policy note: if the frontmost activity needs the menu key, we assume it is a legacy app |
| 943 | // that can't handle lights-out mode. |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 944 | if (mMenuButton.getVisibility() == View.VISIBLE) { |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 945 | on = true; |
| 946 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 947 | mHandler.removeMessages(MSG_HIDE_CHROME); |
| 948 | mHandler.removeMessages(MSG_SHOW_CHROME); |
| 949 | mHandler.sendEmptyMessage(on ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 950 | } |
| 951 | |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 952 | public void setMenuKeyVisible(boolean visible) { |
| 953 | if (DEBUG) { |
| 954 | Slog.d(TAG, (visible?"showing":"hiding") + " the MENU button"); |
| 955 | } |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 956 | mMenuButton.setVisibility(visible ? View.VISIBLE : View.GONE); |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 957 | |
| 958 | // See above re: lights-out policy for legacy apps. |
| 959 | if (visible) setLightsOn(true); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 960 | } |
| 961 | |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 962 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { |
| 963 | mInputMethodSwitchButton.setImeWindowStatus(token, |
| 964 | (vis & InputMethodService.IME_ACTIVE) != 0); |
satok | 5113382 | 2011-01-25 15:01:48 +0900 | [diff] [blame] | 965 | updateNotificationIcons(); |
satok | 913f42d | 2011-01-17 16:58:10 +0900 | [diff] [blame] | 966 | mInputMethodsPanel.setImeToken(token); |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 967 | int res; |
| 968 | switch (backDisposition) { |
| 969 | case InputMethodService.BACK_DISPOSITION_WILL_NOT_DISMISS: |
| 970 | res = R.drawable.ic_sysbar_back; |
| 971 | break; |
| 972 | case InputMethodService.BACK_DISPOSITION_WILL_DISMISS: |
| 973 | res = R.drawable.ic_sysbar_back_ime; |
| 974 | break; |
| 975 | case InputMethodService.BACK_DISPOSITION_DEFAULT: |
| 976 | default: |
| 977 | if ((vis & InputMethodService.IME_VISIBLE) != 0) { |
| 978 | res = R.drawable.ic_sysbar_back_ime; |
| 979 | } else { |
| 980 | res = R.drawable.ic_sysbar_back; |
| 981 | } |
| 982 | break; |
| 983 | } |
| 984 | mBackButton.setImageResource(res); |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 985 | if (FAKE_SPACE_BAR) { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 986 | mFakeSpaceBar.setVisibility(((vis & InputMethodService.IME_VISIBLE) != 0) |
| 987 | ? View.VISIBLE : View.GONE); |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 988 | } |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 989 | } |
| 990 | |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 991 | @Override |
| 992 | public void setHardKeyboardStatus(boolean available, boolean enabled) { |
| 993 | if (DEBUG) { |
| 994 | Slog.d(TAG, "Set hard keyboard status: available=" + available |
| 995 | + ", enabled=" + enabled); |
| 996 | } |
| 997 | mInputMethodSwitchButton.setHardKeyboardStatus(available); |
| 998 | updateNotificationIcons(); |
| 999 | mInputMethodsPanel.setHardKeyboardStatus(available, enabled); |
| 1000 | } |
| 1001 | |
| 1002 | @Override |
| 1003 | public void onHardKeyboardEnabledChange(boolean enabled) { |
| 1004 | try { |
| 1005 | mBarService.setHardKeyboardEnabled(enabled); |
| 1006 | } catch (RemoteException ex) { |
| 1007 | } |
| 1008 | } |
| 1009 | |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 1010 | private boolean isImmersive() { |
| 1011 | try { |
| 1012 | return ActivityManagerNative.getDefault().isTopActivityImmersive(); |
| 1013 | //Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); |
| 1014 | } catch (RemoteException ex) { |
| 1015 | // the end is nigh |
| 1016 | return false; |
| 1017 | } |
| 1018 | } |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 1019 | |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 1020 | private void setAreThereNotifications() { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1021 | final boolean hasClearable = mNotificationData.hasClearableItems(); |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1024 | /** |
| 1025 | * Cancel this notification and tell the status bar service about the failure. Hold no locks. |
| 1026 | */ |
| 1027 | void handleNotificationError(IBinder key, StatusBarNotification n, String message) { |
| 1028 | removeNotification(key); |
| 1029 | try { |
| 1030 | mBarService.onNotificationError(n.pkg, n.tag, n.id, n.uid, n.initialPid, message); |
| 1031 | } catch (RemoteException ex) { |
| 1032 | // The end is nigh. |
| 1033 | } |
| 1034 | } |
| 1035 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 1036 | private void sendKey(KeyEvent key) { |
| 1037 | try { |
| 1038 | if (DEBUG) Slog.d(TAG, "injecting key event: " + key); |
| 1039 | mWindowManager.injectInputEventNoWait(key); |
| 1040 | } catch (RemoteException ex) { |
| 1041 | } |
| 1042 | } |
| 1043 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1044 | private View.OnClickListener mOnClickListener = new View.OnClickListener() { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1045 | public void onClick(View v) { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 1046 | if (v == mNotificationTrigger) { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1047 | onClickNotificationTrigger(); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1048 | } else if (v == mRecentButton) { |
| 1049 | onClickRecentButton(); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 1050 | } else if (v == mInputMethodSwitchButton) { |
| 1051 | onClickInputMethodSwitchButton(); |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1052 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1053 | } |
| 1054 | }; |
| 1055 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1056 | public void onClickNotificationTrigger() { |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 1057 | if (DEBUG) Slog.d(TAG, "clicked notification icons; disabled=" + mDisabled); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1058 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { |
Daniel Sandler | 3a2fded | 2011-02-23 11:19:59 -0500 | [diff] [blame] | 1059 | int msg = !mNotificationPanel.isShowing() |
| 1060 | ? MSG_OPEN_NOTIFICATION_PANEL |
| 1061 | : MSG_CLOSE_NOTIFICATION_PANEL; |
| 1062 | mHandler.removeMessages(msg); |
| 1063 | mHandler.sendEmptyMessage(msg); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1064 | } |
| 1065 | } |
| 1066 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1067 | public void onClickRecentButton() { |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 1068 | if (DEBUG) Slog.d(TAG, "clicked recent apps; disabled=" + mDisabled); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 1069 | if (mRecentsPanel == null) { |
| 1070 | Intent intent = new Intent(); |
| 1071 | intent.setClass(mContext, RecentApplicationsActivity.class); |
| 1072 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
| 1073 | | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); |
| 1074 | mContext.startActivity(intent); |
| 1075 | } else { |
| 1076 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { |
| 1077 | int msg = (mRecentsPanel.getVisibility() == View.GONE) |
| 1078 | ? MSG_OPEN_RECENTS_PANEL |
| 1079 | : MSG_CLOSE_RECENTS_PANEL; |
| 1080 | mHandler.removeMessages(msg); |
| 1081 | mHandler.sendEmptyMessage(msg); |
| 1082 | } |
| 1083 | } |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1084 | } |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 1085 | |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 1086 | public void onClickInputMethodSwitchButton() { |
| 1087 | if (DEBUG) Slog.d(TAG, "clicked input methods panel; disabled=" + mDisabled); |
| 1088 | int msg = (mInputMethodsPanel.getVisibility() == View.GONE) ? |
| 1089 | MSG_OPEN_INPUT_METHODS_PANEL : MSG_CLOSE_INPUT_METHODS_PANEL; |
| 1090 | mHandler.removeMessages(msg); |
| 1091 | mHandler.sendEmptyMessage(msg); |
| 1092 | } |
| 1093 | |
Daniel Sandler | c51451a | 2010-12-16 19:06:46 -0500 | [diff] [blame] | 1094 | public NotificationClicker makeClicker(PendingIntent intent, String pkg, String tag, int id) { |
| 1095 | return new NotificationClicker(intent, pkg, tag, id); |
| 1096 | } |
| 1097 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1098 | private class NotificationClicker implements View.OnClickListener { |
| 1099 | private PendingIntent mIntent; |
| 1100 | private String mPkg; |
| 1101 | private String mTag; |
| 1102 | private int mId; |
| 1103 | |
| 1104 | NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { |
| 1105 | mIntent = intent; |
| 1106 | mPkg = pkg; |
| 1107 | mTag = tag; |
| 1108 | mId = id; |
| 1109 | } |
| 1110 | |
| 1111 | public void onClick(View v) { |
| 1112 | try { |
| 1113 | // The intent we are sending is for the application, which |
| 1114 | // won't have permission to immediately start an activity after |
| 1115 | // the user switches to home. We know it is safe to do at this |
| 1116 | // point, so make sure new activity switches are now allowed. |
| 1117 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
| 1118 | } catch (RemoteException e) { |
| 1119 | } |
| 1120 | |
| 1121 | if (mIntent != null) { |
| 1122 | int[] pos = new int[2]; |
| 1123 | v.getLocationOnScreen(pos); |
| 1124 | Intent overlay = new Intent(); |
| 1125 | overlay.setSourceBounds( |
| 1126 | new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); |
| 1127 | try { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1128 | mIntent.send(mContext, 0, overlay); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1129 | } catch (PendingIntent.CanceledException e) { |
| 1130 | // the stack trace isn't very helpful here. Just log the exception message. |
| 1131 | Slog.w(TAG, "Sending contentIntent failed: " + e); |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | try { |
| 1136 | mBarService.onNotificationClick(mPkg, mTag, mId); |
| 1137 | } catch (RemoteException ex) { |
| 1138 | // system process is dead if we're here. |
| 1139 | } |
| 1140 | |
| 1141 | // close the shade if it was open |
| 1142 | animateCollapse(); |
| 1143 | |
| 1144 | // If this click was on the intruder alert, hide that instead |
| 1145 | // mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | StatusBarNotification removeNotificationViews(IBinder key) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1150 | NotificationData.Entry entry = mNotificationData.remove(key); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1151 | if (entry == null) { |
| 1152 | Slog.w(TAG, "removeNotification for unknown key: " + key); |
| 1153 | return null; |
| 1154 | } |
| 1155 | // Remove the expanded view. |
| 1156 | ViewGroup rowParent = (ViewGroup)entry.row.getParent(); |
| 1157 | if (rowParent != null) rowParent.removeView(entry.row); |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 1158 | |
| 1159 | if (key == mNotificationPeekKey) { |
| 1160 | // must close the peek as well, since it's gone |
| 1161 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); |
| 1162 | } |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1163 | // Remove the icon. |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1164 | // ViewGroup iconParent = (ViewGroup)entry.icon.getParent(); |
| 1165 | // if (iconParent != null) iconParent.removeView(entry.icon); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1166 | updateNotificationIcons(); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1167 | |
| 1168 | return entry.notification; |
| 1169 | } |
| 1170 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1171 | private class NotificationTriggerTouchListener implements View.OnTouchListener { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1172 | VelocityTracker mVT; |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1173 | float mInitialTouchX, mInitialTouchY; |
| 1174 | int mTouchSlop; |
| 1175 | |
| 1176 | public NotificationTriggerTouchListener() { |
| 1177 | mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); |
| 1178 | } |
| 1179 | |
| 1180 | public boolean onTouch(View v, MotionEvent event) { |
| 1181 | // Slog.d(TAG, String.format("touch: (%.1f, %.1f) initial: (%.1f, %.1f)", |
| 1182 | // event.getX(), |
| 1183 | // event.getY(), |
| 1184 | // mInitialTouchX, |
| 1185 | // mInitialTouchY)); |
| 1186 | final int action = event.getAction(); |
| 1187 | switch (action) { |
| 1188 | case MotionEvent.ACTION_DOWN: |
| 1189 | mVT = VelocityTracker.obtain(); |
| 1190 | mInitialTouchX = event.getX(); |
| 1191 | mInitialTouchY = event.getY(); |
| 1192 | // fall through |
| 1193 | case MotionEvent.ACTION_OUTSIDE: |
| 1194 | case MotionEvent.ACTION_MOVE: |
| 1195 | // check for fling |
| 1196 | if (mVT != null) { |
| 1197 | mVT.addMovement(event); |
| 1198 | mVT.computeCurrentVelocity(1000); // pixels per second |
| 1199 | // require a little more oomph once we're already in peekaboo mode |
| 1200 | if (mVT.getYVelocity() < -mNotificationFlingVelocity) { |
| 1201 | animateExpand(); |
| 1202 | mVT.recycle(); |
| 1203 | mVT = null; |
| 1204 | } |
| 1205 | } |
| 1206 | return true; |
| 1207 | case MotionEvent.ACTION_UP: |
| 1208 | case MotionEvent.ACTION_CANCEL: |
| 1209 | if (mVT != null) { |
| 1210 | if (action == MotionEvent.ACTION_UP |
| 1211 | // was this a sloppy tap? |
| 1212 | && Math.abs(event.getX() - mInitialTouchX) < mTouchSlop |
| 1213 | && Math.abs(event.getY() - mInitialTouchY) < (mTouchSlop / 3) |
| 1214 | // dragging off the bottom doesn't count |
| 1215 | && (int)event.getY() < v.getBottom()) { |
| 1216 | animateExpand(); |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 1217 | v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); |
| 1218 | v.playSoundEffect(SoundEffectConstants.CLICK); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1219 | } |
| 1220 | |
| 1221 | mVT.recycle(); |
| 1222 | mVT = null; |
| 1223 | return true; |
| 1224 | } |
| 1225 | } |
| 1226 | return false; |
| 1227 | } |
| 1228 | } |
| 1229 | |
Daniel Sandler | 663f0f2 | 2011-03-04 16:45:02 -0500 | [diff] [blame] | 1230 | final static int NOTIFICATION_PEEK_HOLD_THRESH = 200; // ms |
| 1231 | final static int NOTIFICATION_PEEK_FADE_DELAY = 3000; // ms |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1232 | |
Daniel Sandler | 663f0f2 | 2011-03-04 16:45:02 -0500 | [diff] [blame] | 1233 | public void resetNotificationPeekFadeTimer() { |
| 1234 | if (DEBUG) { |
| 1235 | Slog.d(TAG, "setting peek fade timer for " + NOTIFICATION_PEEK_FADE_DELAY |
| 1236 | + "ms from now"); |
| 1237 | } |
| 1238 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); |
| 1239 | mHandler.sendEmptyMessageDelayed(MSG_CLOSE_NOTIFICATION_PEEK, |
| 1240 | NOTIFICATION_PEEK_FADE_DELAY); |
| 1241 | } |
| 1242 | |
| 1243 | private class NotificationIconTouchListener implements View.OnTouchListener { |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1244 | VelocityTracker mVT; |
| 1245 | int mPeekIndex; |
| 1246 | float mInitialTouchX, mInitialTouchY; |
| 1247 | int mTouchSlop; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1248 | |
| 1249 | public NotificationIconTouchListener() { |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1250 | mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1251 | } |
| 1252 | |
| 1253 | public boolean onTouch(View v, MotionEvent event) { |
| 1254 | boolean peeking = mNotificationPeekWindow.getVisibility() != View.GONE; |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 1255 | boolean panelShowing = mNotificationPanel.isShowing(); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1256 | if (panelShowing) return false; |
| 1257 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1258 | int numIcons = mIconLayout.getChildCount(); |
| 1259 | int newPeekIndex = (int)(event.getX() * numIcons / mIconLayout.getWidth()); |
| 1260 | if (newPeekIndex > numIcons - 1) newPeekIndex = numIcons - 1; |
| 1261 | else if (newPeekIndex < 0) newPeekIndex = 0; |
| 1262 | |
| 1263 | final int action = event.getAction(); |
| 1264 | switch (action) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1265 | case MotionEvent.ACTION_DOWN: |
| 1266 | mVT = VelocityTracker.obtain(); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1267 | mInitialTouchX = event.getX(); |
| 1268 | mInitialTouchY = event.getY(); |
| 1269 | mPeekIndex = -1; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1270 | |
| 1271 | // fall through |
| 1272 | case MotionEvent.ACTION_OUTSIDE: |
| 1273 | case MotionEvent.ACTION_MOVE: |
| 1274 | // peek and switch icons if necessary |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1275 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1276 | if (newPeekIndex != mPeekIndex) { |
| 1277 | mPeekIndex = newPeekIndex; |
| 1278 | |
| 1279 | if (DEBUG) Slog.d(TAG, "will peek at notification #" + mPeekIndex); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1280 | Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1281 | peekMsg.arg1 = mPeekIndex; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1282 | |
| 1283 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
| 1284 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1285 | if (peeking) { |
| 1286 | // no delay if we're scrubbing left-right |
| 1287 | mHandler.sendMessage(peekMsg); |
| 1288 | } else { |
| 1289 | // wait for fling |
| 1290 | mHandler.sendMessageDelayed(peekMsg, NOTIFICATION_PEEK_HOLD_THRESH); |
| 1291 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | // check for fling |
| 1295 | if (mVT != null) { |
| 1296 | mVT.addMovement(event); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1297 | mVT.computeCurrentVelocity(1000); // pixels per second |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1298 | // require a little more oomph once we're already in peekaboo mode |
| 1299 | if (!panelShowing && ( |
| 1300 | (peeking && mVT.getYVelocity() < -mNotificationFlingVelocity*3) |
| 1301 | || (mVT.getYVelocity() < -mNotificationFlingVelocity))) { |
| 1302 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
| 1303 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL); |
| 1304 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); |
| 1305 | mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL); |
| 1306 | } |
| 1307 | } |
| 1308 | return true; |
| 1309 | case MotionEvent.ACTION_UP: |
| 1310 | case MotionEvent.ACTION_CANCEL: |
| 1311 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 1312 | if (!peeking) { |
| 1313 | if (action == MotionEvent.ACTION_UP |
| 1314 | // was this a sloppy tap? |
| 1315 | && Math.abs(event.getX() - mInitialTouchX) < mTouchSlop |
| 1316 | && Math.abs(event.getY() - mInitialTouchY) < (mTouchSlop / 3) |
| 1317 | // dragging off the bottom doesn't count |
| 1318 | && (int)event.getY() < v.getBottom()) { |
| 1319 | Message peekMsg = mHandler.obtainMessage(MSG_OPEN_NOTIFICATION_PEEK); |
| 1320 | peekMsg.arg1 = mPeekIndex; |
| 1321 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PEEK); |
| 1322 | mHandler.sendMessage(peekMsg); |
| 1323 | |
| 1324 | v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); |
| 1325 | v.playSoundEffect(SoundEffectConstants.CLICK); |
| 1326 | |
| 1327 | peeking = true; // not technically true yet, but the next line will run |
| 1328 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1329 | } |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1330 | |
| 1331 | if (peeking) { |
Daniel Sandler | 663f0f2 | 2011-03-04 16:45:02 -0500 | [diff] [blame] | 1332 | resetNotificationPeekFadeTimer(); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1333 | } |
| 1334 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1335 | mVT.recycle(); |
| 1336 | mVT = null; |
| 1337 | return true; |
| 1338 | } |
| 1339 | return false; |
| 1340 | } |
| 1341 | } |
| 1342 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1343 | StatusBarIconView addNotificationViews(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1344 | if (DEBUG) { |
| 1345 | Slog.d(TAG, "addNotificationViews(key=" + key + ", notification=" + notification); |
| 1346 | } |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1347 | // Construct the icon. |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1348 | final StatusBarIconView iconView = new StatusBarIconView(mContext, |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1349 | notification.pkg + "/0x" + Integer.toHexString(notification.id)); |
| 1350 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 1351 | |
| 1352 | final StatusBarIcon ic = new StatusBarIcon(notification.pkg, |
| 1353 | notification.notification.icon, |
| 1354 | notification.notification.iconLevel, |
| 1355 | notification.notification.number); |
| 1356 | if (!iconView.set(ic)) { |
| 1357 | handleNotificationError(key, notification, "Couldn't attach StatusBarIcon: " + ic); |
| 1358 | return null; |
| 1359 | } |
| 1360 | // Construct the expanded view. |
| 1361 | NotificationData.Entry entry = new NotificationData.Entry(key, notification, iconView); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1362 | if (!inflateViews(entry, mPile)) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1363 | handleNotificationError(key, notification, "Couldn't expand RemoteViews for: " |
| 1364 | + notification); |
| 1365 | return null; |
| 1366 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1367 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1368 | // Add the icon. |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1369 | int pos = mNotificationData.add(entry); |
Daniel Sandler | a31e419 | 2011-02-02 22:00:28 -0500 | [diff] [blame] | 1370 | if (DEBUG) { |
| 1371 | Slog.d(TAG, "addNotificationViews: added at " + pos); |
| 1372 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1373 | updateNotificationIcons(); |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1374 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1375 | return iconView; |
| 1376 | } |
| 1377 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1378 | private void reloadAllNotificationIcons() { |
| 1379 | if (mIconLayout == null) return; |
| 1380 | mIconLayout.removeAllViews(); |
| 1381 | updateNotificationIcons(); |
| 1382 | } |
| 1383 | |
| 1384 | private void updateNotificationIcons() { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1385 | // XXX: need to implement a new limited linear layout class |
| 1386 | // to avoid removing & readding everything |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1387 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1388 | if (mIconLayout == null) return; |
| 1389 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1390 | // first, populate the main notification panel |
| 1391 | loadNotificationPanel(); |
| 1392 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1393 | final LinearLayout.LayoutParams params |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1394 | = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1395 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1396 | // alternate behavior in DND mode |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1397 | if (mNotificationDNDMode) { |
| 1398 | if (mIconLayout.getChildCount() == 0) { |
| 1399 | final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd"); |
| 1400 | iconView.setImageResource(R.drawable.ic_notification_dnd); |
| 1401 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 1402 | iconView.setPadding(mIconHPadding, 0, mIconHPadding, 0); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1403 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1404 | final Notification dndNotification = new Notification.Builder(mContext) |
| 1405 | .setContentTitle(mContext.getText(R.string.notifications_off_title)) |
| 1406 | .setContentText(mContext.getText(R.string.notifications_off_text)) |
| 1407 | .setSmallIcon(R.drawable.ic_notification_dnd) |
| 1408 | .setOngoing(true) |
| 1409 | .getNotification(); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1410 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1411 | mNotificationDNDDummyEntry = new NotificationData.Entry( |
| 1412 | null, |
| 1413 | new StatusBarNotification("", 0, "", 0, 0, dndNotification), |
| 1414 | iconView); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1415 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1416 | mIconLayout.addView(iconView, params); |
| 1417 | } |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1418 | |
| 1419 | return; |
| 1420 | } |
| 1421 | |
| 1422 | int N = mNotificationData.size(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1423 | |
| 1424 | if (DEBUG) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1425 | Slog.d(TAG, "refreshing icons: " + N + " notifications, mIconLayout=" + mIconLayout); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1426 | } |
| 1427 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1428 | ArrayList<View> toShow = new ArrayList<View>(); |
| 1429 | |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 1430 | // When IME button is visible, the number of notification icons should be decremented |
| 1431 | // to fit the upper limit. |
| 1432 | final int maxNotificationIconsCount = |
| 1433 | (mInputMethodSwitchButton.getVisibility() != View.GONE) ? |
| 1434 | MAX_NOTIFICATION_ICONS_IME_BUTTON_VISIBLE : MAX_NOTIFICATION_ICONS; |
| 1435 | for (int i=0; i< maxNotificationIconsCount; i++) { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1436 | if (i>=N) break; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1437 | toShow.add(mNotificationData.get(N-i-1).icon); |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1438 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1439 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1440 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 1441 | for (int i=0; i<mIconLayout.getChildCount(); i++) { |
| 1442 | View child = mIconLayout.getChildAt(i); |
| 1443 | if (!toShow.contains(child)) { |
| 1444 | toRemove.add(child); |
| 1445 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1446 | } |
Daniel Sandler | 271ea12 | 2010-10-22 14:06:10 -0400 | [diff] [blame] | 1447 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1448 | for (View remove : toRemove) { |
| 1449 | mIconLayout.removeView(remove); |
| 1450 | } |
| 1451 | |
| 1452 | for (int i=0; i<toShow.size(); i++) { |
| 1453 | View v = toShow.get(i); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1454 | v.setPadding(mIconHPadding, 0, mIconHPadding, 0); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1455 | if (v.getParent() == null) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1456 | mIconLayout.addView(v, i, params); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1457 | } |
| 1458 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1459 | } |
| 1460 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1461 | private void loadNotificationPanel() { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1462 | int N = mNotificationData.size(); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1463 | |
| 1464 | ArrayList<View> toShow = new ArrayList<View>(); |
| 1465 | |
| 1466 | for (int i=0; i<N; i++) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1467 | View row = mNotificationData.get(N-i-1).row; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1468 | toShow.add(row); |
| 1469 | } |
| 1470 | |
| 1471 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 1472 | for (int i=0; i<mPile.getChildCount(); i++) { |
| 1473 | View child = mPile.getChildAt(i); |
| 1474 | if (!toShow.contains(child)) { |
| 1475 | toRemove.add(child); |
| 1476 | } |
| 1477 | } |
| 1478 | |
| 1479 | for (View remove : toRemove) { |
| 1480 | mPile.removeView(remove); |
| 1481 | } |
| 1482 | |
| 1483 | for (int i=0; i<toShow.size(); i++) { |
| 1484 | View v = toShow.get(i); |
| 1485 | if (v.getParent() == null) { |
Daniel Sandler | a31e419 | 2011-02-02 22:00:28 -0500 | [diff] [blame] | 1486 | mPile.addView(v, N-1-i); // the notification panel has newest at the bottom |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1487 | } |
| 1488 | } |
Daniel Sandler | 40c1545 | 2011-01-22 01:26:22 -0500 | [diff] [blame] | 1489 | |
| 1490 | mNotificationPanel.setNotificationCount(N); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1491 | } |
| 1492 | |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 1493 | void workAroundBadLayerDrawableOpacity(View v) { |
| 1494 | LayerDrawable d = (LayerDrawable)v.getBackground(); |
Daniel Sandler | f844dc4 | 2011-01-24 23:44:47 -0500 | [diff] [blame] | 1495 | if (d == null) return; |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 1496 | v.setBackgroundDrawable(null); |
| 1497 | d.setOpacity(PixelFormat.TRANSLUCENT); |
| 1498 | v.setBackgroundDrawable(d); |
| 1499 | } |
| 1500 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1501 | private boolean inflateViews(NotificationData.Entry entry, ViewGroup parent) { |
| 1502 | StatusBarNotification sbn = entry.notification; |
| 1503 | RemoteViews remoteViews = sbn.notification.contentView; |
| 1504 | if (remoteViews == null) { |
| 1505 | return false; |
| 1506 | } |
| 1507 | |
| 1508 | // create the row view |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1509 | LayoutInflater inflater = (LayoutInflater)mContext.getSystemService( |
| 1510 | Context.LAYOUT_INFLATER_SERVICE); |
Joe Onorato | 755cc74 | 2010-11-27 15:45:35 -0800 | [diff] [blame] | 1511 | View row = inflater.inflate(R.layout.status_bar_notification_row, parent, false); |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 1512 | workAroundBadLayerDrawableOpacity(row); |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1513 | View vetoButton = row.findViewById(R.id.veto); |
Joe Onorato | a4a6503 | 2010-09-27 15:53:44 -0700 | [diff] [blame] | 1514 | if (entry.notification.isClearable()) { |
| 1515 | final String _pkg = sbn.pkg; |
| 1516 | final String _tag = sbn.tag; |
| 1517 | final int _id = sbn.id; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 1518 | vetoButton.setOnClickListener(new View.OnClickListener() { |
Joe Onorato | a4a6503 | 2010-09-27 15:53:44 -0700 | [diff] [blame] | 1519 | public void onClick(View v) { |
| 1520 | try { |
| 1521 | mBarService.onNotificationClear(_pkg, _tag, _id); |
| 1522 | } catch (RemoteException ex) { |
| 1523 | // system process is dead if we're here. |
| 1524 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1525 | } |
Joe Onorato | a4a6503 | 2010-09-27 15:53:44 -0700 | [diff] [blame] | 1526 | }); |
| 1527 | } else { |
Joe Onorato | 100748e | 2011-01-07 11:03:54 -0800 | [diff] [blame] | 1528 | if ((sbn.notification.flags & Notification.FLAG_ONGOING_EVENT) == 0) { |
| 1529 | vetoButton.setVisibility(View.INVISIBLE); |
| 1530 | } else { |
| 1531 | vetoButton.setVisibility(View.GONE); |
| 1532 | } |
Joe Onorato | a4a6503 | 2010-09-27 15:53:44 -0700 | [diff] [blame] | 1533 | } |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1534 | |
Joe Onorato | 561d385 | 2010-11-20 18:09:34 -0800 | [diff] [blame] | 1535 | // the large icon |
| 1536 | ImageView largeIcon = (ImageView)row.findViewById(R.id.large_icon); |
| 1537 | if (sbn.notification.largeIcon != null) { |
| 1538 | largeIcon.setImageBitmap(sbn.notification.largeIcon); |
| 1539 | } else { |
| 1540 | largeIcon.getLayoutParams().width = 0; |
| 1541 | largeIcon.setVisibility(View.INVISIBLE); |
| 1542 | } |
| 1543 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1544 | // bind the click event to the content area |
| 1545 | ViewGroup content = (ViewGroup)row.findViewById(R.id.content); |
| 1546 | // XXX: update to allow controls within notification views |
| 1547 | content.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); |
| 1548 | // content.setOnFocusChangeListener(mFocusChangeListener); |
| 1549 | PendingIntent contentIntent = sbn.notification.contentIntent; |
| 1550 | if (contentIntent != null) { |
| 1551 | content.setOnClickListener(new NotificationClicker(contentIntent, |
| 1552 | sbn.pkg, sbn.tag, sbn.id)); |
Joe Onorato | 184498c | 2010-10-08 17:57:18 -0400 | [diff] [blame] | 1553 | } else { |
| 1554 | content.setOnClickListener(null); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1555 | } |
| 1556 | |
| 1557 | View expanded = null; |
| 1558 | Exception exception = null; |
| 1559 | try { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1560 | expanded = remoteViews.apply(mContext, content); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1561 | } |
| 1562 | catch (RuntimeException e) { |
| 1563 | exception = e; |
| 1564 | } |
| 1565 | if (expanded == null) { |
Joe Onorato | 46439ce | 2010-11-19 13:56:21 -0800 | [diff] [blame] | 1566 | final String ident = sbn.pkg + "/0x" + Integer.toHexString(sbn.id); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1567 | Slog.e(TAG, "couldn't inflate view for notification " + ident, exception); |
| 1568 | return false; |
| 1569 | } else { |
| 1570 | content.addView(expanded); |
| 1571 | row.setDrawingCacheEnabled(true); |
| 1572 | } |
| 1573 | |
| 1574 | entry.row = row; |
| 1575 | entry.content = content; |
| 1576 | entry.expanded = expanded; |
Joe Onorato | 80a4440 | 2011-01-15 16:22:24 -0800 | [diff] [blame] | 1577 | entry.largeIcon = largeIcon; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 1578 | |
| 1579 | return true; |
| 1580 | } |
Daniel Sandler | ce70d91 | 2010-09-02 11:59:41 -0400 | [diff] [blame] | 1581 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1582 | public class TouchOutsideListener implements View.OnTouchListener { |
| 1583 | private int mMsg; |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 1584 | private StatusBarPanel mPanel; |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1585 | |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 1586 | public TouchOutsideListener(int msg, StatusBarPanel panel) { |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1587 | mMsg = msg; |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 1588 | mPanel = panel; |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1589 | } |
| 1590 | |
| 1591 | public boolean onTouch(View v, MotionEvent ev) { |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 1592 | final int action = ev.getAction(); |
| 1593 | if (action == MotionEvent.ACTION_OUTSIDE |
| 1594 | || (action == MotionEvent.ACTION_DOWN |
| 1595 | && !mPanel.isInContentArea((int)ev.getX(), (int)ev.getY()))) { |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1596 | mHandler.removeMessages(mMsg); |
| 1597 | mHandler.sendEmptyMessage(mMsg); |
| 1598 | return true; |
| 1599 | } |
| 1600 | return false; |
| 1601 | } |
| 1602 | } |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 1603 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1604 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1605 | pw.print("mDisabled=0x"); |
| 1606 | pw.println(Integer.toHexString(mDisabled)); |
Joe Onorato | 933464d | 2011-01-05 15:53:36 -0800 | [diff] [blame] | 1607 | pw.println("mNetworkController:"); |
| 1608 | mNetworkController.dump(fd, pw, args); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1609 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1610 | } |
Daniel Sandler | d39e388 | 2010-08-31 14:16:13 -0400 | [diff] [blame] | 1611 | |
| 1612 | |