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