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