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 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 19 | import android.animation.LayoutTransition; |
| 20 | import android.animation.ObjectAnimator; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 21 | import android.app.ActivityManager; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 22 | import android.app.ActivityManagerNative; |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 23 | import android.app.Notification; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 24 | import android.app.PendingIntent; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 25 | import android.app.StatusBarManager; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 26 | import android.content.BroadcastReceiver; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 27 | import android.content.Context; |
| 28 | import android.content.Intent; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 29 | import android.content.IntentFilter; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 30 | import android.content.SharedPreferences; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 31 | import android.content.res.Configuration; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 32 | import android.content.res.Resources; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 33 | import android.graphics.PixelFormat; |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 34 | import android.graphics.Point; |
Adam Powell | 29ea525 | 2011-11-15 18:59:36 -0800 | [diff] [blame] | 35 | import android.graphics.drawable.Drawable; |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 36 | import android.graphics.drawable.LayerDrawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 37 | import android.inputmethodservice.InputMethodService; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 38 | import android.os.IBinder; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 39 | import android.os.Message; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 40 | import android.os.RemoteException; |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 41 | import android.os.ServiceManager; |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 42 | import android.text.TextUtils; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 43 | import android.util.Slog; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 44 | import android.view.Display; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 45 | import android.view.Gravity; |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 46 | import android.view.IWindowManager; |
| 47 | import android.view.KeyEvent; |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 48 | import android.view.MotionEvent; |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 49 | import android.view.SoundEffectConstants; |
Daniel Sandler | 8304da4 | 2010-10-25 15:53:25 -0400 | [diff] [blame] | 50 | import android.view.VelocityTracker; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 51 | import android.view.View; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 52 | import android.view.ViewConfiguration; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 53 | import android.view.ViewGroup; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 54 | import android.view.ViewGroup.LayoutParams; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 55 | import android.view.WindowManager; |
| 56 | import android.view.WindowManagerImpl; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 57 | import android.view.accessibility.AccessibilityEvent; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 58 | import android.widget.ImageView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 59 | import android.widget.LinearLayout; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 60 | import android.widget.ScrollView; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 61 | import android.widget.TextView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 62 | |
| 63 | import com.android.internal.statusbar.StatusBarIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 64 | import com.android.internal.statusbar.StatusBarNotification; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 65 | import com.android.systemui.R; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 66 | import com.android.systemui.recent.RecentTasksLoader; |
| 67 | import com.android.systemui.recent.RecentsPanelView; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 68 | import com.android.systemui.statusbar.BaseStatusBar; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 69 | import com.android.systemui.statusbar.CommandQueue; |
Daniel Sandler | d2217f0 | 2012-05-04 16:40:13 -0400 | [diff] [blame] | 70 | import com.android.systemui.statusbar.DoNotDisturb; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 71 | import com.android.systemui.statusbar.NotificationData; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 72 | import com.android.systemui.statusbar.NotificationData.Entry; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 73 | import com.android.systemui.statusbar.SignalClusterView; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 74 | import com.android.systemui.statusbar.StatusBarIconView; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 75 | import com.android.systemui.statusbar.policy.BatteryController; |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 76 | import com.android.systemui.statusbar.policy.BluetoothController; |
Daniel Sandler | 45c0401 | 2011-06-07 15:29:07 -0400 | [diff] [blame] | 77 | import com.android.systemui.statusbar.policy.CompatModeButton; |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 78 | import com.android.systemui.statusbar.policy.LocationController; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 79 | import com.android.systemui.statusbar.policy.NetworkController; |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 80 | import com.android.systemui.statusbar.policy.NotificationRowLayout; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 81 | import com.android.systemui.statusbar.policy.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 82 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 83 | import java.io.FileDescriptor; |
| 84 | import java.io.PrintWriter; |
| 85 | import java.util.ArrayList; |
| 86 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 87 | public class TabletStatusBar extends BaseStatusBar implements |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 88 | InputMethodsPanel.OnHardKeyboardEnabledChangeListener, |
| 89 | RecentsPanelView.OnRecentsPanelVisibilityChangedListener { |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 90 | public static final boolean DEBUG = false; |
Daniel Sandler | e25f833 | 2011-06-15 15:00:10 -0400 | [diff] [blame] | 91 | public static final boolean DEBUG_COMPAT_HELP = false; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 92 | public static final String TAG = "TabletStatusBar"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 93 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 94 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 95 | public static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
| 96 | public static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 97 | public static final int MSG_OPEN_NOTIFICATION_PEEK = 1002; |
| 98 | public static final int MSG_CLOSE_NOTIFICATION_PEEK = 1003; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 99 | // 1020-1029 reserved for BaseStatusBar |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 100 | public static final int MSG_SHOW_CHROME = 1030; |
| 101 | public static final int MSG_HIDE_CHROME = 1031; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 102 | public static final int MSG_OPEN_INPUT_METHODS_PANEL = 1040; |
| 103 | public static final int MSG_CLOSE_INPUT_METHODS_PANEL = 1041; |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 104 | public static final int MSG_OPEN_COMPAT_MODE_PANEL = 1050; |
| 105 | public static final int MSG_CLOSE_COMPAT_MODE_PANEL = 1051; |
Daniel Sandler | 2ed08d2 | 2011-01-30 16:07:28 -0500 | [diff] [blame] | 106 | public static final int MSG_STOP_TICKER = 2000; |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 107 | |
Daniel Sandler | 3a2fded | 2011-02-23 11:19:59 -0500 | [diff] [blame] | 108 | // Fitts' Law assistance for LatinIME; see policy.EventHole |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 109 | private static final boolean FAKE_SPACE_BAR = true; |
| 110 | |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 111 | // Notification "peeking" (flyover preview of individual notifications) |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 112 | final static int NOTIFICATION_PEEK_HOLD_THRESH = 200; // ms |
| 113 | final static int NOTIFICATION_PEEK_FADE_DELAY = 3000; // ms |
| 114 | |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 115 | private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService |
| 116 | private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER; |
| 117 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 118 | // The height of the bar, as definied by the build. It may be taller if we're plugged |
| 119 | // into hdmi. |
| 120 | int mNaturalBarHeight = -1; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 121 | int mIconSize = -1; |
| 122 | int mIconHPadding = -1; |
Andrew Flynn | 1d9af30 | 2012-03-07 15:48:51 -0800 | [diff] [blame] | 123 | int mNavIconWidth = -1; |
| 124 | int mMenuNavIconWidth = -1; |
satok | 5485ff6 | 2011-05-27 19:15:01 +0900 | [diff] [blame] | 125 | private int mMaxNotificationIcons = 5; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 126 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 127 | IWindowManager mWindowManager; |
| 128 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 129 | TabletStatusBarView mStatusBarView; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 130 | View mNotificationArea; |
| 131 | View mNotificationTrigger; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 132 | NotificationIconArea mNotificationIconArea; |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 133 | ViewGroup mNavigationArea; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 134 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 135 | boolean mNotificationDNDMode; |
| 136 | NotificationData.Entry mNotificationDNDDummyEntry; |
| 137 | |
Joe Onorato | 536c58f | 2010-11-28 17:52:28 -0800 | [diff] [blame] | 138 | ImageView mBackButton; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 139 | View mHomeButton; |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 140 | View mMenuButton; |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 141 | View mRecentButton; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 142 | private boolean mAltBackButtonEnabledForIme; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 143 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 144 | ViewGroup mFeedbackIconArea; // notification icons, IME icon, compat icon |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 145 | InputMethodButton mInputMethodSwitchButton; |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 146 | CompatModeButton mCompatModeButton; |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 147 | |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 148 | NotificationPanel mNotificationPanel; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 149 | WindowManager.LayoutParams mNotificationPanelParams; |
Joe Onorato | 8a57671 | 2010-11-15 16:50:34 -0800 | [diff] [blame] | 150 | NotificationPeekPanel mNotificationPeekWindow; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 151 | ViewGroup mNotificationPeekRow; |
| 152 | int mNotificationPeekIndex; |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 153 | IBinder mNotificationPeekKey; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 154 | LayoutTransition mNotificationPeekScrubLeft, mNotificationPeekScrubRight; |
| 155 | |
| 156 | int mNotificationPeekTapDuration; |
| 157 | int mNotificationFlingVelocity; |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 158 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 159 | BatteryController mBatteryController; |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 160 | BluetoothController mBluetoothController; |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 161 | LocationController mLocationController; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 162 | NetworkController mNetworkController; |
Daniel Sandler | d2217f0 | 2012-05-04 16:40:13 -0400 | [diff] [blame] | 163 | DoNotDisturb mDoNotDisturb; |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 164 | |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 165 | ViewGroup mBarContents; |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 166 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 167 | // hide system chrome ("lights out") support |
| 168 | View mShadow; |
Daniel Sandler | ce70d91 | 2010-09-02 11:59:41 -0400 | [diff] [blame] | 169 | |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 170 | NotificationIconArea.IconLayout mIconLayout; |
| 171 | |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 172 | TabletTicker mTicker; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 173 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 174 | View mFakeSpaceBar; |
| 175 | KeyEvent mSpaceBarKeyEvent = null; |
| 176 | |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 177 | View mCompatibilityHelpDialog = null; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 178 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 179 | // for disabling the status bar |
| 180 | int mDisabled = 0; |
| 181 | |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 182 | private InputMethodsPanel mInputMethodsPanel; |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 183 | private CompatModePanel mCompatModePanel; |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 184 | |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 185 | private int mSystemUiVisibility = 0; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 186 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 187 | private int mNavigationIconHints = 0; |
| 188 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 189 | private int mShowSearchHoldoff = 0; |
| 190 | |
Daniel Sandler | c51451a | 2010-12-16 19:06:46 -0500 | [diff] [blame] | 191 | public Context getContext() { return mContext; } |
| 192 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 193 | private Runnable mShowSearchPanel = new Runnable() { |
| 194 | public void run() { |
| 195 | showSearchPanel(); |
| 196 | } |
| 197 | }; |
| 198 | |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 199 | private View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() { |
| 200 | public boolean onTouch(View v, MotionEvent event) { |
| 201 | switch(event.getAction()) { |
| 202 | case MotionEvent.ACTION_DOWN: |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 203 | if (!shouldDisableNavbarGestures() && !inKeyguardRestrictedInputMode()) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 204 | mHandler.removeCallbacks(mShowSearchPanel); |
| 205 | mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 206 | } |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 207 | break; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 208 | |
| 209 | case MotionEvent.ACTION_UP: |
| 210 | case MotionEvent.ACTION_CANCEL: |
| 211 | mHandler.removeCallbacks(mShowSearchPanel); |
| 212 | break; |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 213 | } |
| 214 | return false; |
| 215 | } |
| 216 | }; |
| 217 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 218 | @Override |
| 219 | protected void createAndAddWindows() { |
| 220 | addStatusBarWindow(); |
| 221 | addPanelWindows(); |
| 222 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 223 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 224 | private void addStatusBarWindow() { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 225 | final View sb = makeStatusBarView(); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 226 | |
| 227 | final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 228 | ViewGroup.LayoutParams.MATCH_PARENT, |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 229 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 230 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 231 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 232 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 233 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Greg Hackmann | bb033ea | 2012-07-10 14:39:29 -0700 | [diff] [blame] | 234 | PixelFormat.OPAQUE); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 235 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 236 | // We explicitly leave FLAG_HARDWARE_ACCELERATED out of the flags. The status bar occupies |
| 237 | // very little screen real-estate and is updated fairly frequently. By using CPU rendering |
| 238 | // for the status bar, we prevent the GPU from having to wake up just to do these small |
| 239 | // updates, which should help keep power consumption down. |
| 240 | |
| 241 | lp.gravity = getStatusBarGravity(); |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 242 | lp.setTitle("SystemBar"); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 243 | lp.packageName = mContext.getPackageName(); |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 244 | WindowManagerImpl.getDefault().addView(sb, lp); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 245 | } |
| 246 | |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 247 | protected void addPanelWindows() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 248 | final Context context = mContext; |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 249 | final Resources res = mContext.getResources(); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 250 | |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 251 | // Notification Panel |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 252 | mNotificationPanel = (NotificationPanel)View.inflate(context, |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 253 | R.layout.system_bar_notification_panel, null); |
Daniel Sandler | 1347c30 | 2011-08-01 16:47:53 -0400 | [diff] [blame] | 254 | mNotificationPanel.setBar(this); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 255 | mNotificationPanel.show(false, false); |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 256 | mNotificationPanel.setOnTouchListener( |
Joe Onorato | ddf680b | 2010-09-26 13:59:40 -0700 | [diff] [blame] | 257 | new TouchOutsideListener(MSG_CLOSE_NOTIFICATION_PANEL, mNotificationPanel)); |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 258 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 259 | // the battery icon |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 260 | mBatteryController.addIconView((ImageView)mNotificationPanel.findViewById(R.id.battery)); |
| 261 | mBatteryController.addLabelView( |
| 262 | (TextView)mNotificationPanel.findViewById(R.id.battery_text)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 263 | |
| 264 | // Bt |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 265 | mBluetoothController.addIconView( |
| 266 | (ImageView)mNotificationPanel.findViewById(R.id.bluetooth)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 267 | |
| 268 | // network icons: either a combo icon that switches between mobile and data, or distinct |
| 269 | // mobile and data icons |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 270 | final ImageView mobileRSSI = |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 271 | (ImageView)mNotificationPanel.findViewById(R.id.mobile_signal); |
| 272 | if (mobileRSSI != null) { |
| 273 | mNetworkController.addPhoneSignalIconView(mobileRSSI); |
| 274 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 275 | final ImageView wifiRSSI = |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 276 | (ImageView)mNotificationPanel.findViewById(R.id.wifi_signal); |
| 277 | if (wifiRSSI != null) { |
| 278 | mNetworkController.addWifiIconView(wifiRSSI); |
| 279 | } |
Daniel Sandler | 5962fd5 | 2012-01-11 14:57:04 -0500 | [diff] [blame] | 280 | mNetworkController.addWifiLabelView( |
| 281 | (TextView)mNotificationPanel.findViewById(R.id.wifi_text)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 282 | |
Joe Onorato | 42f8e13 | 2010-11-29 15:52:43 -0800 | [diff] [blame] | 283 | mNetworkController.addDataTypeIconView( |
Daniel Sandler | 5962fd5 | 2012-01-11 14:57:04 -0500 | [diff] [blame] | 284 | (ImageView)mNotificationPanel.findViewById(R.id.mobile_type)); |
| 285 | mNetworkController.addMobileLabelView( |
| 286 | (TextView)mNotificationPanel.findViewById(R.id.mobile_text)); |
| 287 | mNetworkController.addCombinedLabelView( |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 288 | (TextView)mBarContents.findViewById(R.id.network_text)); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 289 | |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 290 | mStatusBarView.setIgnoreChildren(0, mNotificationTrigger, mNotificationPanel); |
Daniel Sandler | d39e388 | 2010-08-31 14:16:13 -0400 | [diff] [blame] | 291 | |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 292 | WindowManager.LayoutParams lp = mNotificationPanelParams = new WindowManager.LayoutParams( |
| 293 | res.getDimensionPixelSize(R.dimen.notification_panel_width), |
| 294 | getNotificationPanelHeight(), |
Daniel Sandler | 4ce64fb | 2012-05-03 10:53:10 -0400 | [diff] [blame] | 295 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 296 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 297 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
Jeff Brown | 46e7529 | 2010-11-10 16:53:45 -0800 | [diff] [blame] | 298 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 299 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 300 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 301 | PixelFormat.TRANSLUCENT); |
Joe Onorato | ea70e63 | 2010-09-27 17:59:37 -0700 | [diff] [blame] | 302 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 303 | lp.setTitle("NotificationPanel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 304 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 305 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 306 | lp.windowAnimations = com.android.internal.R.style.Animation; // == no animation |
Daniel Sandler | 7d9ea8c | 2011-01-11 10:28:58 -0500 | [diff] [blame] | 307 | // lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 308 | |
| 309 | WindowManagerImpl.getDefault().addView(mNotificationPanel, lp); |
| 310 | |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 311 | // Recents Panel |
Michael Jurka | ab48b68 | 2011-09-12 15:39:45 -0700 | [diff] [blame] | 312 | mRecentTasksLoader = new RecentTasksLoader(context); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 313 | updateRecentsPanel(); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 314 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 315 | // Search Panel |
| 316 | mStatusBarView.setBar(this); |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 317 | mHomeButton.setOnTouchListener(mHomeSearchActionListener); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 318 | updateSearchPanel(); |
| 319 | |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 320 | // Input methods Panel |
| 321 | mInputMethodsPanel = (InputMethodsPanel) View.inflate(context, |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 322 | R.layout.system_bar_input_methods_panel, null); |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 323 | mInputMethodsPanel.setHardKeyboardEnabledChangeListener(this); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 324 | mInputMethodsPanel.setOnTouchListener(new TouchOutsideListener( |
| 325 | MSG_CLOSE_INPUT_METHODS_PANEL, mInputMethodsPanel)); |
satok | 913f42d | 2011-01-17 16:58:10 +0900 | [diff] [blame] | 326 | mInputMethodsPanel.setImeSwitchButton(mInputMethodSwitchButton); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 327 | mStatusBarView.setIgnoreChildren(2, mInputMethodSwitchButton, mInputMethodsPanel); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 328 | lp = new WindowManager.LayoutParams( |
| 329 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 330 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 331 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 332 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 333 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 334 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 335 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 336 | PixelFormat.TRANSLUCENT); |
| 337 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
| 338 | lp.setTitle("InputMethodsPanel"); |
| 339 | lp.windowAnimations = R.style.Animation_RecentPanel; |
| 340 | |
| 341 | WindowManagerImpl.getDefault().addView(mInputMethodsPanel, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 342 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 343 | // Compatibility mode selector panel |
| 344 | mCompatModePanel = (CompatModePanel) View.inflate(context, |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 345 | R.layout.system_bar_compat_mode_panel, null); |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 346 | mCompatModePanel.setOnTouchListener(new TouchOutsideListener( |
| 347 | MSG_CLOSE_COMPAT_MODE_PANEL, mCompatModePanel)); |
| 348 | mCompatModePanel.setTrigger(mCompatModeButton); |
| 349 | mCompatModePanel.setVisibility(View.GONE); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 350 | mStatusBarView.setIgnoreChildren(3, mCompatModeButton, mCompatModePanel); |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 351 | lp = new WindowManager.LayoutParams( |
| 352 | 250, |
| 353 | ViewGroup.LayoutParams.WRAP_CONTENT, |
| 354 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 355 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 356 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 357 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 358 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 359 | PixelFormat.TRANSLUCENT); |
| 360 | lp.gravity = Gravity.BOTTOM | Gravity.RIGHT; |
| 361 | lp.setTitle("CompatModePanel"); |
| 362 | lp.windowAnimations = android.R.style.Animation_Dialog; |
| 363 | |
| 364 | WindowManagerImpl.getDefault().addView(mCompatModePanel, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 365 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 366 | mRecentButton.setOnTouchListener(mRecentsPanel); |
| 367 | |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 368 | mPile = (NotificationRowLayout)mNotificationPanel.findViewById(R.id.content); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 369 | mPile.removeAllViews(); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 370 | mPile.setLongPressListener(getNotificationLongClicker()); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 371 | |
| 372 | ScrollView scroller = (ScrollView)mPile.getParent(); |
| 373 | scroller.setFillViewport(true); |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 374 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 375 | |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 376 | @Override |
| 377 | protected int getExpandedViewMaxHeight() { |
| 378 | return getNotificationPanelHeight(); |
| 379 | } |
| 380 | |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 381 | private int getNotificationPanelHeight() { |
| 382 | final Resources res = mContext.getResources(); |
| 383 | final Display d = WindowManagerImpl.getDefault().getDefaultDisplay(); |
Jeff Brown | bc68a59 | 2011-07-25 12:58:12 -0700 | [diff] [blame] | 384 | final Point size = new Point(); |
| 385 | d.getRealSize(size); |
| 386 | 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] | 387 | } |
| 388 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 389 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 390 | public void start() { |
| 391 | super.start(); // will add the main bar view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 392 | } |
| 393 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 394 | @Override |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 395 | protected void onConfigurationChanged(Configuration newConfig) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 396 | loadDimens(); |
Joe Onorato | 07949e9 | 2011-05-25 17:35:35 -0700 | [diff] [blame] | 397 | mNotificationPanelParams.height = getNotificationPanelHeight(); |
| 398 | WindowManagerImpl.getDefault().updateViewLayout(mNotificationPanel, |
| 399 | mNotificationPanelParams); |
Michael Jurka | ab48b68 | 2011-09-12 15:39:45 -0700 | [diff] [blame] | 400 | mRecentsPanel.updateValuesFromResources(); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 401 | mShowSearchHoldoff = mContext.getResources().getInteger( |
| 402 | R.integer.config_show_search_delay); |
Jim Miller | 955a016 | 2012-06-11 21:06:13 -0700 | [diff] [blame] | 403 | updateSearchPanel(); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | protected void loadDimens() { |
| 407 | final Resources res = mContext.getResources(); |
| 408 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 409 | mNaturalBarHeight = res.getDimensionPixelSize( |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 410 | com.android.internal.R.dimen.navigation_bar_height); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 411 | |
| 412 | int newIconSize = res.getDimensionPixelSize( |
Dianne Hackborn | 81e56d5 | 2011-05-26 00:55:58 -0700 | [diff] [blame] | 413 | com.android.internal.R.dimen.system_bar_icon_size); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 414 | int newIconHPadding = res.getDimensionPixelSize( |
| 415 | R.dimen.status_bar_icon_padding); |
Andrew Flynn | 1d9af30 | 2012-03-07 15:48:51 -0800 | [diff] [blame] | 416 | int newNavIconWidth = res.getDimensionPixelSize(R.dimen.navigation_key_width); |
| 417 | int newMenuNavIconWidth = res.getDimensionPixelSize(R.dimen.navigation_menu_key_width); |
| 418 | |
| 419 | if (mNavigationArea != null && newNavIconWidth != mNavIconWidth) { |
| 420 | mNavIconWidth = newNavIconWidth; |
| 421 | |
| 422 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( |
| 423 | mNavIconWidth, ViewGroup.LayoutParams.MATCH_PARENT); |
| 424 | mBackButton.setLayoutParams(lp); |
| 425 | mHomeButton.setLayoutParams(lp); |
| 426 | mRecentButton.setLayoutParams(lp); |
| 427 | } |
| 428 | |
| 429 | if (mNavigationArea != null && newMenuNavIconWidth != mMenuNavIconWidth) { |
| 430 | mMenuNavIconWidth = newMenuNavIconWidth; |
| 431 | |
| 432 | LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams( |
| 433 | mMenuNavIconWidth, ViewGroup.LayoutParams.MATCH_PARENT); |
| 434 | mMenuButton.setLayoutParams(lp); |
| 435 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 436 | |
| 437 | if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { |
| 438 | // Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); |
| 439 | mIconHPadding = newIconHPadding; |
| 440 | mIconSize = newIconSize; |
| 441 | reloadAllNotificationIcons(); // reload the tray |
| 442 | } |
satok | 5485ff6 | 2011-05-27 19:15:01 +0900 | [diff] [blame] | 443 | |
| 444 | final int numIcons = res.getInteger(R.integer.config_maxNotificationIcons); |
| 445 | if (numIcons != mMaxNotificationIcons) { |
| 446 | mMaxNotificationIcons = numIcons; |
| 447 | if (DEBUG) Slog.d(TAG, "max notification icons: " + mMaxNotificationIcons); |
| 448 | reloadAllNotificationIcons(); |
| 449 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 450 | } |
| 451 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 452 | public View getStatusBarView() { |
| 453 | return mStatusBarView; |
| 454 | } |
| 455 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 456 | protected View makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 457 | final Context context = mContext; |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 458 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 459 | mWindowManager = IWindowManager.Stub.asInterface( |
| 460 | ServiceManager.getService(Context.WINDOW_SERVICE)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 461 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 462 | loadDimens(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 463 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 464 | final TabletStatusBarView sb = (TabletStatusBarView)View.inflate( |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 465 | context, R.layout.system_bar, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 466 | mStatusBarView = sb; |
| 467 | |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 468 | sb.setHandler(mHandler); |
| 469 | |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 470 | try { |
| 471 | // Sanity-check that someone hasn't set up the config wrong and asked for a navigation |
| 472 | // bar on a tablet that has only the system bar |
| 473 | if (mWindowManager.hasNavigationBar()) { |
Mike Lockwood | c33d576 | 2011-10-21 13:28:22 -0400 | [diff] [blame] | 474 | Slog.e(TAG, "Tablet device cannot show navigation bar and system bar"); |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 475 | } |
| 476 | } catch (RemoteException ex) { |
Chet Haase | bc0009d | 2011-09-08 16:19:50 -0700 | [diff] [blame] | 477 | } |
| 478 | |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 479 | mBarContents = (ViewGroup) sb.findViewById(R.id.bar_contents); |
Joe Onorato | f63b0f4 | 2010-09-12 17:03:19 -0400 | [diff] [blame] | 480 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 481 | // the whole right-hand side of the bar |
| 482 | mNotificationArea = sb.findViewById(R.id.notificationArea); |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 483 | mNotificationArea.setOnTouchListener(new NotificationTriggerTouchListener()); |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 484 | |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 485 | // the button to open the notification area |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 486 | mNotificationTrigger = sb.findViewById(R.id.notificationTrigger); |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 487 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 488 | // the more notifications icon |
| 489 | mNotificationIconArea = (NotificationIconArea)sb.findViewById(R.id.notificationIcons); |
| 490 | |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 491 | // where the icons go |
| 492 | mIconLayout = (NotificationIconArea.IconLayout) sb.findViewById(R.id.icons); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 493 | |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 494 | mNotificationPeekTapDuration = ViewConfiguration.getTapTimeout(); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 495 | mNotificationFlingVelocity = 300; // px/s |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 496 | |
Daniel Sandler | c51451a | 2010-12-16 19:06:46 -0500 | [diff] [blame] | 497 | mTicker = new TabletTicker(this); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 498 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 499 | // The icons |
Daniel Sandler | e40451a | 2011-02-03 14:51:35 -0500 | [diff] [blame] | 500 | mLocationController = new LocationController(mContext); // will post a notification |
| 501 | |
Daniel Sandler | d2217f0 | 2012-05-04 16:40:13 -0400 | [diff] [blame] | 502 | // watch the PREF_DO_NOT_DISTURB and convert to appropriate disable() calls |
| 503 | mDoNotDisturb = new DoNotDisturb(mContext); |
| 504 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 505 | mBatteryController = new BatteryController(mContext); |
| 506 | mBatteryController.addIconView((ImageView)sb.findViewById(R.id.battery)); |
Joe Onorato | fce2bf3 | 2011-02-01 17:00:29 -0800 | [diff] [blame] | 507 | mBluetoothController = new BluetoothController(mContext); |
| 508 | mBluetoothController.addIconView((ImageView)sb.findViewById(R.id.bluetooth)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 509 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 510 | mNetworkController = new NetworkController(mContext); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 511 | final SignalClusterView signalCluster = |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 512 | (SignalClusterView)sb.findViewById(R.id.signal_cluster); |
| 513 | mNetworkController.addSignalCluster(signalCluster); |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 514 | |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 515 | // The navigation buttons |
Joe Onorato | 6478adc | 2011-01-27 21:15:01 -0800 | [diff] [blame] | 516 | mBackButton = (ImageView)sb.findViewById(R.id.back); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 517 | mNavigationArea = (ViewGroup) sb.findViewById(R.id.navigationArea); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 518 | mHomeButton = mNavigationArea.findViewById(R.id.home); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 519 | mMenuButton = mNavigationArea.findViewById(R.id.menu); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 520 | mRecentButton = mNavigationArea.findViewById(R.id.recent_apps); |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 521 | mRecentButton.setOnClickListener(mOnClickListener); |
Daniel Sandler | 4f9986e | 2011-12-02 16:10:37 -0500 | [diff] [blame] | 522 | |
| 523 | LayoutTransition lt = new LayoutTransition(); |
| 524 | lt.setDuration(250); |
| 525 | // don't wait for these transitions; we just want icons to fade in/out, not move around |
| 526 | lt.setDuration(LayoutTransition.CHANGE_APPEARING, 0); |
| 527 | lt.setDuration(LayoutTransition.CHANGE_DISAPPEARING, 0); |
Daniel Sandler | 5a82660 | 2011-12-07 15:16:18 -0500 | [diff] [blame] | 528 | lt.addTransitionListener(new LayoutTransition.TransitionListener() { |
| 529 | public void endTransition(LayoutTransition transition, ViewGroup container, |
| 530 | View view, int transitionType) { |
| 531 | // ensure the menu button doesn't stick around on the status bar after it's been |
| 532 | // removed |
| 533 | mBarContents.invalidate(); |
| 534 | } |
| 535 | public void startTransition(LayoutTransition transition, ViewGroup container, |
| 536 | View view, int transitionType) {} |
| 537 | }); |
Daniel Sandler | 4f9986e | 2011-12-02 16:10:37 -0500 | [diff] [blame] | 538 | mNavigationArea.setLayoutTransition(lt); |
Daniel Sandler | 96f4818 | 2011-08-17 09:50:35 -0400 | [diff] [blame] | 539 | // no multi-touch on the nav buttons |
| 540 | mNavigationArea.setMotionEventSplittingEnabled(false); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 541 | |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 542 | // The bar contents buttons |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 543 | mFeedbackIconArea = (ViewGroup)sb.findViewById(R.id.feedbackIconArea); |
satok | cd7cd29 | 2010-11-20 15:46:23 +0900 | [diff] [blame] | 544 | mInputMethodSwitchButton = (InputMethodButton) sb.findViewById(R.id.imeSwitchButton); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 545 | // Overwrite the lister |
| 546 | mInputMethodSwitchButton.setOnClickListener(mOnClickListener); |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 547 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 548 | mCompatModeButton = (CompatModeButton) sb.findViewById(R.id.compatModeButton); |
| 549 | mCompatModeButton.setOnClickListener(mOnClickListener); |
Dianne Hackborn | e0f085d | 2011-11-30 18:41:15 -0800 | [diff] [blame] | 550 | mCompatModeButton.setVisibility(View.GONE); |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 551 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 552 | // for redirecting errant bar taps to the IME |
| 553 | mFakeSpaceBar = sb.findViewById(R.id.fake_space_bar); |
| 554 | |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 555 | // "shadows" of the status bar features, for lights-out mode |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 556 | mShadow = sb.findViewById(R.id.bar_shadow); |
| 557 | mShadow.setOnTouchListener( |
| 558 | new View.OnTouchListener() { |
| 559 | public boolean onTouch(View v, MotionEvent ev) { |
| 560 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | d720155 | 2011-01-28 09:58:02 -0500 | [diff] [blame] | 561 | // even though setting the systemUI visibility below will turn these views |
| 562 | // on, we need them to come up faster so that they can catch this motion |
| 563 | // event |
| 564 | mShadow.setVisibility(View.GONE); |
| 565 | mBarContents.setVisibility(View.VISIBLE); |
| 566 | |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 567 | try { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 568 | mBarService.setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE); |
Joe Onorato | 55bf380 | 2011-01-25 13:42:10 -0800 | [diff] [blame] | 569 | } catch (RemoteException ex) { |
| 570 | // system process dead |
| 571 | } |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 572 | } |
| 573 | return false; |
| 574 | } |
| 575 | }); |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 576 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 577 | // tuning parameters |
Daniel Sandler | 635fb49 | 2012-04-27 10:45:37 -0400 | [diff] [blame] | 578 | final int LIGHTS_GOING_OUT_SYSBAR_DURATION = 750; |
| 579 | final int LIGHTS_GOING_OUT_SHADOW_DURATION = 750; |
| 580 | final int LIGHTS_GOING_OUT_SHADOW_DELAY = 0; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 581 | |
| 582 | final int LIGHTS_COMING_UP_SYSBAR_DURATION = 200; |
| 583 | // final int LIGHTS_COMING_UP_SYSBAR_DELAY = 50; |
| 584 | final int LIGHTS_COMING_UP_SHADOW_DURATION = 0; |
| 585 | |
| 586 | LayoutTransition xition = new LayoutTransition(); |
| 587 | xition.setAnimator(LayoutTransition.APPEARING, |
| 588 | ObjectAnimator.ofFloat(null, "alpha", 0.5f, 1f)); |
| 589 | xition.setDuration(LayoutTransition.APPEARING, LIGHTS_COMING_UP_SYSBAR_DURATION); |
| 590 | xition.setStartDelay(LayoutTransition.APPEARING, 0); |
| 591 | xition.setAnimator(LayoutTransition.DISAPPEARING, |
| 592 | ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); |
| 593 | xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_GOING_OUT_SYSBAR_DURATION); |
| 594 | xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); |
| 595 | ((ViewGroup)sb.findViewById(R.id.bar_contents_holder)).setLayoutTransition(xition); |
| 596 | |
| 597 | xition = new LayoutTransition(); |
| 598 | xition.setAnimator(LayoutTransition.APPEARING, |
| 599 | ObjectAnimator.ofFloat(null, "alpha", 0f, 1f)); |
| 600 | xition.setDuration(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DURATION); |
| 601 | xition.setStartDelay(LayoutTransition.APPEARING, LIGHTS_GOING_OUT_SHADOW_DELAY); |
| 602 | xition.setAnimator(LayoutTransition.DISAPPEARING, |
| 603 | ObjectAnimator.ofFloat(null, "alpha", 1f, 0f)); |
| 604 | xition.setDuration(LayoutTransition.DISAPPEARING, LIGHTS_COMING_UP_SHADOW_DURATION); |
| 605 | xition.setStartDelay(LayoutTransition.DISAPPEARING, 0); |
| 606 | ((ViewGroup)sb.findViewById(R.id.bar_shadow_holder)).setLayoutTransition(xition); |
Daniel Sandler | b960699 | 2010-11-19 14:47:59 -0500 | [diff] [blame] | 607 | |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 608 | // set the initial view visibility |
| 609 | setAreThereNotifications(); |
| 610 | |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 611 | // receive broadcasts |
| 612 | IntentFilter filter = new IntentFilter(); |
| 613 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 614 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
| 615 | context.registerReceiver(mBroadcastReceiver, filter); |
| 616 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 617 | return sb; |
| 618 | } |
| 619 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 620 | @Override |
| 621 | protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { |
| 622 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 623 | (int) mContext.getResources().getDimension(R.dimen.status_bar_recents_width), |
| 624 | ViewGroup.LayoutParams.MATCH_PARENT, |
Daniel Sandler | 4ce64fb | 2012-05-03 10:53:10 -0400 | [diff] [blame] | 625 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 626 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 627 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 628 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH |
| 629 | | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, |
| 630 | PixelFormat.TRANSLUCENT); |
| 631 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 632 | lp.setTitle("RecentsPanel"); |
| 633 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
| 634 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 635 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 636 | |
| 637 | return lp; |
| 638 | } |
| 639 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 640 | @Override |
| 641 | protected WindowManager.LayoutParams getSearchLayoutParams(LayoutParams layoutParams) { |
| 642 | boolean opaque = false; |
| 643 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 644 | LayoutParams.MATCH_PARENT, |
| 645 | LayoutParams.MATCH_PARENT, |
| 646 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 647 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 648 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 649 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 650 | (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); |
| 651 | if (ActivityManager.isHighEndGfx(mDisplay)) { |
| 652 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 653 | } else { |
| 654 | lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; |
| 655 | lp.dimAmount = 0.7f; |
| 656 | } |
| 657 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 658 | lp.setTitle("SearchPanel"); |
| 659 | // TODO: Define custom animation for Search panel |
| 660 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
| 661 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 662 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 663 | return lp; |
| 664 | } |
| 665 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 666 | protected void updateRecentsPanel() { |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 667 | super.updateRecentsPanel(R.layout.system_bar_recent_panel); |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 668 | mRecentsPanel.setStatusBarView(mStatusBarView); |
| 669 | } |
| 670 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 671 | @Override |
| 672 | protected void updateSearchPanel() { |
| 673 | super.updateSearchPanel(); |
| 674 | mSearchPanelView.setStatusBarView(mStatusBarView); |
| 675 | mStatusBarView.setDelegateView(mSearchPanelView); |
| 676 | } |
| 677 | |
| 678 | @Override |
| 679 | public void showSearchPanel() { |
| 680 | super.showSearchPanel(); |
| 681 | WindowManager.LayoutParams lp = |
| 682 | (android.view.WindowManager.LayoutParams) mStatusBarView.getLayoutParams(); |
| 683 | lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 684 | WindowManagerImpl.getDefault().updateViewLayout(mStatusBarView, lp); |
| 685 | } |
| 686 | |
| 687 | @Override |
| 688 | public void hideSearchPanel() { |
| 689 | super.hideSearchPanel(); |
| 690 | WindowManager.LayoutParams lp = |
| 691 | (android.view.WindowManager.LayoutParams) mStatusBarView.getLayoutParams(); |
| 692 | lp.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 693 | WindowManagerImpl.getDefault().updateViewLayout(mStatusBarView, lp); |
| 694 | } |
| 695 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 696 | public int getStatusBarHeight() { |
Dianne Hackborn | f87d196 | 2012-04-04 12:48:24 -0700 | [diff] [blame] | 697 | return mStatusBarView != null ? mStatusBarView.getHeight() |
| 698 | : mContext.getResources().getDimensionPixelSize( |
| 699 | com.android.internal.R.dimen.navigation_bar_height); |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 700 | } |
| 701 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 702 | protected int getStatusBarGravity() { |
| 703 | return Gravity.BOTTOM | Gravity.FILL_HORIZONTAL; |
| 704 | } |
| 705 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 706 | public void onBarHeightChanged(int height) { |
| 707 | final WindowManager.LayoutParams lp |
| 708 | = (WindowManager.LayoutParams)mStatusBarView.getLayoutParams(); |
| 709 | if (lp == null) { |
| 710 | // haven't been added yet |
| 711 | return; |
| 712 | } |
| 713 | if (lp.height != height) { |
| 714 | lp.height = height; |
| 715 | final WindowManager wm = WindowManagerImpl.getDefault(); |
| 716 | wm.updateViewLayout(mStatusBarView, lp); |
| 717 | } |
| 718 | } |
| 719 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 720 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 721 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 722 | return new TabletStatusBar.H(); |
| 723 | } |
| 724 | |
| 725 | private class H extends BaseStatusBar.H { |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 726 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 727 | super.handleMessage(m); |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 728 | switch (m.what) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 729 | case MSG_OPEN_NOTIFICATION_PEEK: |
| 730 | if (DEBUG) Slog.d(TAG, "opening notification peek window; arg=" + m.arg1); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 731 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 732 | if (m.arg1 >= 0) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 733 | final int N = mNotificationData.size(); |
| 734 | |
| 735 | if (!mNotificationDNDMode) { |
| 736 | if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { |
| 737 | NotificationData.Entry entry = mNotificationData.get(N-1-mNotificationPeekIndex); |
| 738 | entry.icon.setBackgroundColor(0); |
| 739 | mNotificationPeekIndex = -1; |
| 740 | mNotificationPeekKey = null; |
| 741 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | final int peekIndex = m.arg1; |
| 745 | if (peekIndex < N) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 746 | //Slog.d(TAG, "loading peek: " + peekIndex); |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 747 | NotificationData.Entry entry = |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 748 | mNotificationDNDMode |
| 749 | ? mNotificationDNDDummyEntry |
| 750 | : mNotificationData.get(N-1-peekIndex); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 751 | NotificationData.Entry copy = new NotificationData.Entry( |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 752 | entry.key, |
| 753 | entry.notification, |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 754 | entry.icon); |
| 755 | inflateViews(copy, mNotificationPeekRow); |
| 756 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 757 | if (mNotificationDNDMode) { |
| 758 | copy.content.setOnClickListener(new View.OnClickListener() { |
| 759 | public void onClick(View v) { |
| 760 | SharedPreferences.Editor editor = Prefs.edit(mContext); |
| 761 | editor.putBoolean(Prefs.DO_NOT_DISTURB_PREF, false); |
| 762 | editor.apply(); |
| 763 | animateCollapse(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 764 | visibilityChanged(false); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 765 | } |
| 766 | }); |
| 767 | } |
| 768 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 769 | entry.icon.setBackgroundColor(0x20FFFFFF); |
| 770 | |
| 771 | // mNotificationPeekRow.setLayoutTransition( |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 772 | // peekIndex < mNotificationPeekIndex |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 773 | // ? mNotificationPeekScrubLeft |
| 774 | // : mNotificationPeekScrubRight); |
| 775 | |
| 776 | mNotificationPeekRow.removeAllViews(); |
| 777 | mNotificationPeekRow.addView(copy.row); |
| 778 | |
| 779 | mNotificationPeekWindow.setVisibility(View.VISIBLE); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 780 | mNotificationPanel.show(false, true); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 781 | |
| 782 | mNotificationPeekIndex = peekIndex; |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 783 | mNotificationPeekKey = entry.key; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 784 | } |
| 785 | } |
| 786 | break; |
| 787 | case MSG_CLOSE_NOTIFICATION_PEEK: |
| 788 | if (DEBUG) Slog.d(TAG, "closing notification peek window"); |
| 789 | mNotificationPeekWindow.setVisibility(View.GONE); |
| 790 | mNotificationPeekRow.removeAllViews(); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 791 | |
| 792 | final int N = mNotificationData.size(); |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 793 | if (mNotificationPeekIndex >= 0 && mNotificationPeekIndex < N) { |
Jim Miller | 5fda69c | 2011-02-16 15:17:11 -0800 | [diff] [blame] | 794 | NotificationData.Entry entry = |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 795 | mNotificationDNDMode |
| 796 | ? mNotificationDNDDummyEntry |
| 797 | : mNotificationData.get(N-1-mNotificationPeekIndex); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 798 | entry.icon.setBackgroundColor(0); |
| 799 | } |
Daniel Sandler | a8e5b06 | 2010-12-01 13:53:08 -0500 | [diff] [blame] | 800 | |
| 801 | mNotificationPeekIndex = -1; |
| 802 | mNotificationPeekKey = null; |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 803 | break; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 804 | case MSG_OPEN_NOTIFICATION_PANEL: |
| 805 | if (DEBUG) Slog.d(TAG, "opening notifications panel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 806 | if (!mNotificationPanel.isShowing()) { |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 807 | mNotificationPanel.show(true, true); |
Daniel Sandler | 21eb86a | 2011-03-02 11:52:58 -0500 | [diff] [blame] | 808 | mNotificationArea.setVisibility(View.INVISIBLE); |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 809 | mTicker.halt(); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 810 | } |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 811 | break; |
| 812 | case MSG_CLOSE_NOTIFICATION_PANEL: |
| 813 | if (DEBUG) Slog.d(TAG, "closing notifications panel"); |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 814 | if (mNotificationPanel.isShowing()) { |
| 815 | mNotificationPanel.show(false, true); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 816 | mNotificationArea.setVisibility(View.VISIBLE); |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 817 | } |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 818 | break; |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 819 | case MSG_OPEN_INPUT_METHODS_PANEL: |
| 820 | if (DEBUG) Slog.d(TAG, "opening input methods panel"); |
Tadashi G. Takaoka | e385f0c | 2011-02-01 02:57:44 +0900 | [diff] [blame] | 821 | if (mInputMethodsPanel != null) mInputMethodsPanel.openPanel(); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 822 | break; |
| 823 | case MSG_CLOSE_INPUT_METHODS_PANEL: |
| 824 | if (DEBUG) Slog.d(TAG, "closing input methods panel"); |
Tadashi G. Takaoka | e385f0c | 2011-02-01 02:57:44 +0900 | [diff] [blame] | 825 | if (mInputMethodsPanel != null) mInputMethodsPanel.closePanel(false); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 826 | break; |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 827 | case MSG_OPEN_COMPAT_MODE_PANEL: |
| 828 | if (DEBUG) Slog.d(TAG, "opening compat panel"); |
| 829 | if (mCompatModePanel != null) mCompatModePanel.openPanel(); |
| 830 | break; |
| 831 | case MSG_CLOSE_COMPAT_MODE_PANEL: |
| 832 | if (DEBUG) Slog.d(TAG, "closing compat panel"); |
| 833 | if (mCompatModePanel != null) mCompatModePanel.closePanel(); |
| 834 | break; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 835 | case MSG_SHOW_CHROME: |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 836 | if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)"); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 837 | mBarContents.setVisibility(View.VISIBLE); |
| 838 | mShadow.setVisibility(View.GONE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 839 | mSystemUiVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; |
| 840 | notifyUiVisibilityChanged(); |
Daniel Sandler | 06e6630 | 2010-11-05 15:00:06 -0400 | [diff] [blame] | 841 | break; |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 842 | case MSG_HIDE_CHROME: |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 843 | if (DEBUG) Slog.d(TAG, "showing shadows (lights out)"); |
Daniel Sandler | 06e6630 | 2010-11-05 15:00:06 -0400 | [diff] [blame] | 844 | animateCollapse(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 845 | visibilityChanged(false); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 846 | mBarContents.setVisibility(View.GONE); |
| 847 | mShadow.setVisibility(View.VISIBLE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 848 | mSystemUiVisibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE; |
| 849 | notifyUiVisibilityChanged(); |
Daniel Sandler | e03d1bc | 2010-11-17 21:36:40 -0500 | [diff] [blame] | 850 | break; |
Daniel Sandler | 2ed08d2 | 2011-01-30 16:07:28 -0500 | [diff] [blame] | 851 | case MSG_STOP_TICKER: |
| 852 | mTicker.halt(); |
| 853 | break; |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 854 | } |
| 855 | } |
| 856 | } |
Daniel Sandler | 271ea12 | 2010-10-22 14:06:10 -0400 | [diff] [blame] | 857 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 858 | public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 859 | if (DEBUG) Slog.d(TAG, "addIcon(" + slot + ") -> " + icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 860 | } |
| 861 | |
| 862 | public void updateIcon(String slot, int index, int viewIndex, |
| 863 | StatusBarIcon old, StatusBarIcon icon) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 864 | if (DEBUG) Slog.d(TAG, "updateIcon(" + slot + ") -> " + icon); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | public void removeIcon(String slot, int index, int viewIndex) { |
Daniel Sandler | 1e3ed8f | 2010-08-13 10:12:48 -0400 | [diff] [blame] | 868 | if (DEBUG) Slog.d(TAG, "removeIcon(" + slot + ")"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 869 | } |
| 870 | |
| 871 | public void addNotification(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 872 | if (DEBUG) Slog.d(TAG, "addNotification(" + key + " -> " + notification + ")"); |
| 873 | addNotificationViews(key, notification); |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 874 | |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 875 | final boolean immersive = isImmersive(); |
Joe Onorato | cf2b199 | 2010-11-16 21:36:42 -0800 | [diff] [blame] | 876 | if (false && immersive) { |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 877 | // TODO: immersive mode popups for tablet |
| 878 | } else if (notification.notification.fullScreenIntent != null) { |
| 879 | // not immersive & a full-screen alert should be shown |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 880 | Slog.w(TAG, "Notification has fullScreenIntent and activity is not immersive;" |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 881 | + " sending fullScreenIntent"); |
| 882 | try { |
| 883 | notification.notification.fullScreenIntent.send(); |
| 884 | } catch (PendingIntent.CanceledException e) { |
| 885 | } |
| 886 | } else { |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 887 | tick(key, notification, true); |
Daniel Sandler | fb970e9 | 2010-08-20 10:57:17 -0400 | [diff] [blame] | 888 | } |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 889 | |
| 890 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 891 | } |
| 892 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 893 | public void removeNotification(IBinder key) { |
Daniel Sandler | 3a2fded | 2011-02-23 11:19:59 -0500 | [diff] [blame] | 894 | if (DEBUG) Slog.d(TAG, "removeNotification(" + key + ")"); |
Daniel Sandler | 3eebd1f | 2010-07-27 08:39:33 -0400 | [diff] [blame] | 895 | removeNotificationViews(key); |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 896 | mTicker.remove(key); |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 897 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 898 | } |
| 899 | |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 900 | public void showClock(boolean show) { |
| 901 | View clock = mBarContents.findViewById(R.id.clock); |
| 902 | View network_text = mBarContents.findViewById(R.id.network_text); |
| 903 | if (clock != null) { |
| 904 | clock.setVisibility(show ? View.VISIBLE : View.GONE); |
| 905 | } |
| 906 | if (network_text != null) { |
| 907 | network_text.setVisibility((!show) ? View.VISIBLE : View.GONE); |
| 908 | } |
| 909 | } |
| 910 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 911 | public void disable(int state) { |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 912 | int old = mDisabled; |
| 913 | int diff = state ^ old; |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 914 | mDisabled = state; |
| 915 | |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 916 | // act accordingly |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 917 | if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 918 | boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 919 | Slog.i(TAG, "DISABLE_CLOCK: " + (show ? "no" : "yes")); |
Daniel Sandler | 3e8f5a2 | 2010-12-03 14:52:10 -0500 | [diff] [blame] | 920 | showClock(show); |
| 921 | } |
Daniel Sandler | 6f6cf3c | 2010-12-16 12:54:03 -0500 | [diff] [blame] | 922 | if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 923 | boolean show = (state & StatusBarManager.DISABLE_SYSTEM_INFO) == 0; |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 924 | Slog.i(TAG, "DISABLE_SYSTEM_INFO: " + (show ? "no" : "yes")); |
Daniel Sandler | 6f6cf3c | 2010-12-16 12:54:03 -0500 | [diff] [blame] | 925 | mNotificationTrigger.setVisibility(show ? View.VISIBLE : View.GONE); |
| 926 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 927 | if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 928 | if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { |
Joe Onorato | f68b500 | 2011-01-16 17:00:34 -0800 | [diff] [blame] | 929 | Slog.i(TAG, "DISABLE_EXPAND: yes"); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 930 | animateCollapse(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 931 | visibilityChanged(false); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 932 | } |
| 933 | } |
| 934 | if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 935 | mNotificationDNDMode = Prefs.read(mContext) |
| 936 | .getBoolean(Prefs.DO_NOT_DISTURB_PREF, Prefs.DO_NOT_DISTURB_DEFAULT); |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 937 | |
| 938 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 939 | Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: yes" + (mNotificationDNDMode?" (DND)":"")); |
| 940 | mTicker.halt(); |
| 941 | } else { |
| 942 | Slog.i(TAG, "DISABLE_NOTIFICATION_ICONS: no" + (mNotificationDNDMode?" (DND)":"")); |
| 943 | } |
| 944 | |
| 945 | // refresh icons to show either notifications or the DND message |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 946 | reloadAllNotificationIcons(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 947 | } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 948 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 949 | mTicker.halt(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 950 | } |
| 951 | } |
Jim Miller | 354619c | 2012-04-27 17:33:44 -0700 | [diff] [blame] | 952 | if ((diff & (StatusBarManager.DISABLE_RECENT |
| 953 | | StatusBarManager.DISABLE_BACK |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 954 | | StatusBarManager.DISABLE_HOME)) != 0) { |
| 955 | setNavigationVisibility(state); |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 956 | |
| 957 | if ((state & StatusBarManager.DISABLE_RECENT) != 0) { |
| 958 | // close recents if it's visible |
| 959 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 960 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 961 | } |
Joe Onorato | 091e1b8 | 2010-09-26 18:04:44 -0700 | [diff] [blame] | 962 | } |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | private void setNavigationVisibility(int visibility) { |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 966 | boolean disableHome = ((visibility & StatusBarManager.DISABLE_HOME) != 0); |
| 967 | boolean disableRecent = ((visibility & StatusBarManager.DISABLE_RECENT) != 0); |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 968 | boolean disableBack = ((visibility & StatusBarManager.DISABLE_BACK) != 0); |
| 969 | |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 970 | mBackButton.setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE); |
| 971 | mHomeButton.setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE); |
| 972 | mRecentButton.setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE); |
Mike Lockwood | e3646dd | 2011-09-01 12:46:28 -0400 | [diff] [blame] | 973 | |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 974 | mInputMethodSwitchButton.setScreenLocked( |
| 975 | (visibility & StatusBarManager.DISABLE_SYSTEM_INFO) != 0); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 976 | } |
| 977 | |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 978 | private boolean hasTicker(Notification n) { |
Joe Onorato | 46439ce | 2010-11-19 13:56:21 -0800 | [diff] [blame] | 979 | return n.tickerView != null || !TextUtils.isEmpty(n.tickerText); |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 980 | } |
| 981 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 982 | @Override |
| 983 | protected void tick(IBinder key, StatusBarNotification n, boolean firstTime) { |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 984 | // Don't show the ticker when the windowshade is open. |
Joe Onorato | 7c270fa | 2010-12-08 17:31:42 -0800 | [diff] [blame] | 985 | if (mNotificationPanel.isShowing()) { |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 986 | return; |
| 987 | } |
Joe Onorato | eeed994 | 2011-01-04 17:13:53 -0800 | [diff] [blame] | 988 | // If they asked for FLAG_ONLY_ALERT_ONCE, then only show this notification |
| 989 | // if it's a new notification. |
| 990 | if (!firstTime && (n.notification.flags & Notification.FLAG_ONLY_ALERT_ONCE) != 0) { |
| 991 | return; |
| 992 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 993 | // Show the ticker if one is requested. Also don't do this |
| 994 | // until status bar window is attached to the window manager, |
| 995 | // because... well, what's the point otherwise? And trying to |
| 996 | // run a ticker without being attached will crash! |
Joe Onorato | ef1e776 | 2010-09-17 18:38:38 -0400 | [diff] [blame] | 997 | if (hasTicker(n.notification) && mStatusBarView.getWindowToken() != null) { |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 998 | if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS |
| 999 | | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 1000 | mTicker.add(key, n); |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1001 | mFeedbackIconArea.setVisibility(View.GONE); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1002 | } |
| 1003 | } |
| 1004 | } |
| 1005 | |
Daniel Sandler | b8027d8 | 2010-12-16 19:35:54 -0500 | [diff] [blame] | 1006 | // called by TabletTicker when it's done with all queued ticks |
| 1007 | public void doneTicking() { |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1008 | mFeedbackIconArea.setVisibility(View.VISIBLE); |
Daniel Sandler | b8027d8 | 2010-12-16 19:35:54 -0500 | [diff] [blame] | 1009 | } |
| 1010 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1011 | public void animateExpand() { |
Joe Onorato | b62ac12 | 2010-09-20 16:16:32 -0400 | [diff] [blame] | 1012 | mHandler.removeMessages(MSG_OPEN_NOTIFICATION_PANEL); |
| 1013 | mHandler.sendEmptyMessage(MSG_OPEN_NOTIFICATION_PANEL); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | public void animateCollapse() { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1017 | animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1018 | } |
| 1019 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1020 | public void animateCollapse(int flags) { |
| 1021 | if ((flags & CommandQueue.FLAG_EXCLUDE_NOTIFICATION_PANEL) == 0) { |
| 1022 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PANEL); |
| 1023 | mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PANEL); |
| 1024 | } |
| 1025 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1026 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 1027 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 1028 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1029 | if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) { |
| 1030 | mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL); |
| 1031 | mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL); |
| 1032 | } |
| 1033 | if ((flags & CommandQueue.FLAG_EXCLUDE_INPUT_METHODS_PANEL) == 0) { |
| 1034 | mHandler.removeMessages(MSG_CLOSE_INPUT_METHODS_PANEL); |
| 1035 | mHandler.sendEmptyMessage(MSG_CLOSE_INPUT_METHODS_PANEL); |
| 1036 | } |
| 1037 | if ((flags & CommandQueue.FLAG_EXCLUDE_COMPAT_MODE_PANEL) == 0) { |
| 1038 | mHandler.removeMessages(MSG_CLOSE_COMPAT_MODE_PANEL); |
| 1039 | mHandler.sendEmptyMessage(MSG_CLOSE_COMPAT_MODE_PANEL); |
| 1040 | } |
| 1041 | |
Daniel Sandler | 9120d55 | 2010-07-23 09:11:14 -0400 | [diff] [blame] | 1042 | } |
| 1043 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1044 | @Override // CommandQueue |
| 1045 | public void setNavigationIconHints(int hints) { |
| 1046 | if (hints == mNavigationIconHints) return; |
| 1047 | |
| 1048 | if (DEBUG) { |
| 1049 | android.widget.Toast.makeText(mContext, |
| 1050 | "Navigation icon hints = " + hints, |
| 1051 | 500).show(); |
| 1052 | } |
| 1053 | |
| 1054 | mNavigationIconHints = hints; |
| 1055 | |
| 1056 | mBackButton.setAlpha( |
| 1057 | (0 != (hints & StatusBarManager.NAVIGATION_HINT_BACK_NOP)) ? 0.5f : 1.0f); |
| 1058 | mHomeButton.setAlpha( |
| 1059 | (0 != (hints & StatusBarManager.NAVIGATION_HINT_HOME_NOP)) ? 0.5f : 1.0f); |
| 1060 | mRecentButton.setAlpha( |
| 1061 | (0 != (hints & StatusBarManager.NAVIGATION_HINT_RECENT_NOP)) ? 0.5f : 1.0f); |
| 1062 | |
| 1063 | mBackButton.setImageResource( |
| 1064 | (0 != (hints & StatusBarManager.NAVIGATION_HINT_BACK_ALT)) |
| 1065 | ? R.drawable.ic_sysbar_back_ime |
| 1066 | : R.drawable.ic_sysbar_back); |
| 1067 | } |
| 1068 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1069 | private void notifyUiVisibilityChanged() { |
| 1070 | try { |
| 1071 | mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); |
| 1072 | } catch (RemoteException ex) { |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | @Override // CommandQueue |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1077 | public void setSystemUiVisibility(int vis, int mask) { |
| 1078 | final int oldVal = mSystemUiVisibility; |
| 1079 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 1080 | final int diff = newVal ^ oldVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1081 | |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1082 | if (diff != 0) { |
| 1083 | mSystemUiVisibility = newVal; |
| 1084 | |
| 1085 | if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { |
| 1086 | mHandler.removeMessages(MSG_HIDE_CHROME); |
| 1087 | mHandler.removeMessages(MSG_SHOW_CHROME); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1088 | mHandler.sendEmptyMessage(0 == (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1089 | ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); |
| 1090 | } |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1091 | |
| 1092 | notifyUiVisibilityChanged(); |
| 1093 | } |
| 1094 | } |
| 1095 | |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1096 | public void setLightsOn(boolean on) { |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 1097 | // Policy note: if the frontmost activity needs the menu key, we assume it is a legacy app |
| 1098 | // that can't handle lights-out mode. |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1099 | if (mMenuButton.getVisibility() == View.VISIBLE) { |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 1100 | on = true; |
| 1101 | } |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1102 | |
| 1103 | Slog.v(TAG, "setLightsOn(" + on + ")"); |
| 1104 | if (on) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1105 | setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1106 | } else { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1107 | setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE, View.SYSTEM_UI_FLAG_LOW_PROFILE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1108 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1109 | } |
| 1110 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1111 | public void topAppWindowChanged(boolean showMenu) { |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 1112 | if (DEBUG) { |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1113 | Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 1114 | } |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1115 | mMenuButton.setVisibility(showMenu ? View.VISIBLE : View.GONE); |
Daniel Sandler | 59485d74 | 2010-12-02 00:11:33 -0500 | [diff] [blame] | 1116 | |
| 1117 | // See above re: lights-out policy for legacy apps. |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1118 | if (showMenu) setLightsOn(true); |
Daniel Sandler | 45c0401 | 2011-06-07 15:29:07 -0400 | [diff] [blame] | 1119 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1120 | mCompatModeButton.refresh(); |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1121 | if (mCompatModeButton.getVisibility() == View.VISIBLE) { |
Daniel Sandler | 319d1e3 | 2011-08-05 11:34:06 -0400 | [diff] [blame] | 1122 | if (DEBUG_COMPAT_HELP |
| 1123 | || ! Prefs.read(mContext).getBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, false)) { |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1124 | showCompatibilityHelp(); |
Daniel Sandler | 319d1e3 | 2011-08-05 11:34:06 -0400 | [diff] [blame] | 1125 | } |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1126 | } else { |
| 1127 | hideCompatibilityHelp(); |
| 1128 | mCompatModePanel.closePanel(); |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1129 | } |
| 1130 | } |
| 1131 | |
| 1132 | private void showCompatibilityHelp() { |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1133 | if (mCompatibilityHelpDialog != null) { |
| 1134 | return; |
| 1135 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1136 | |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1137 | mCompatibilityHelpDialog = View.inflate(mContext, R.layout.compat_mode_help, null); |
| 1138 | View button = mCompatibilityHelpDialog.findViewById(R.id.button); |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1139 | |
| 1140 | button.setOnClickListener(new View.OnClickListener() { |
| 1141 | @Override |
| 1142 | public void onClick(View v) { |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1143 | hideCompatibilityHelp(); |
| 1144 | SharedPreferences.Editor editor = Prefs.edit(mContext); |
| 1145 | editor.putBoolean(Prefs.SHOWN_COMPAT_MODE_HELP, true); |
| 1146 | editor.apply(); |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1147 | } |
| 1148 | }); |
| 1149 | |
Daniel Sandler | f1dd26b | 2011-06-20 14:44:35 -0400 | [diff] [blame] | 1150 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Daniel Sandler | 552b1f0 | 2011-06-15 01:03:02 -0400 | [diff] [blame] | 1151 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 1152 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 1153 | WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG, |
| 1154 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 1155 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
| 1156 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, |
| 1157 | PixelFormat.TRANSLUCENT); |
| 1158 | lp.setTitle("CompatibilityModeDialog"); |
| 1159 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 1160 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 1161 | lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons; // simple fade |
| 1162 | |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1163 | WindowManagerImpl.getDefault().addView(mCompatibilityHelpDialog, lp); |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 1164 | } |
| 1165 | |
Dianne Hackborn | ed31bbf | 2011-06-15 11:16:06 -0700 | [diff] [blame] | 1166 | private void hideCompatibilityHelp() { |
| 1167 | if (mCompatibilityHelpDialog != null) { |
| 1168 | WindowManagerImpl.getDefault().removeView(mCompatibilityHelpDialog); |
| 1169 | mCompatibilityHelpDialog = null; |
| 1170 | } |
| 1171 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1172 | |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 1173 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { |
| 1174 | mInputMethodSwitchButton.setImeWindowStatus(token, |
| 1175 | (vis & InputMethodService.IME_ACTIVE) != 0); |
satok | 5113382 | 2011-01-25 15:01:48 +0900 | [diff] [blame] | 1176 | updateNotificationIcons(); |
satok | 913f42d | 2011-01-17 16:58:10 +0900 | [diff] [blame] | 1177 | mInputMethodsPanel.setImeToken(token); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1178 | |
| 1179 | boolean altBack = (backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) |
| 1180 | || ((vis & InputMethodService.IME_VISIBLE) != 0); |
| 1181 | mAltBackButtonEnabledForIme = altBack; |
| 1182 | |
| 1183 | mCommandQueue.setNavigationIconHints( |
| 1184 | altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) |
| 1185 | : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); |
| 1186 | |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 1187 | if (FAKE_SPACE_BAR) { |
Joe Onorato | 857fd9b | 2011-01-27 15:08:35 -0800 | [diff] [blame] | 1188 | mFakeSpaceBar.setVisibility(((vis & InputMethodService.IME_VISIBLE) != 0) |
| 1189 | ? View.VISIBLE : View.GONE); |
Daniel Sandler | 10163c6 | 2010-12-08 11:51:05 -0500 | [diff] [blame] | 1190 | } |
satok | 06487a5 | 2010-10-29 11:37:18 +0900 | [diff] [blame] | 1191 | } |
| 1192 | |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 1193 | @Override |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1194 | public void onRecentsPanelVisibilityChanged(boolean visible) { |
| 1195 | boolean altBack = visible || mAltBackButtonEnabledForIme; |
| 1196 | mCommandQueue.setNavigationIconHints( |
| 1197 | altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) |
| 1198 | : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); |
| 1199 | } |
| 1200 | |
| 1201 | @Override |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 1202 | public void setHardKeyboardStatus(boolean available, boolean enabled) { |
| 1203 | if (DEBUG) { |
| 1204 | Slog.d(TAG, "Set hard keyboard status: available=" + available |
| 1205 | + ", enabled=" + enabled); |
| 1206 | } |
| 1207 | mInputMethodSwitchButton.setHardKeyboardStatus(available); |
| 1208 | updateNotificationIcons(); |
| 1209 | mInputMethodsPanel.setHardKeyboardStatus(available, enabled); |
| 1210 | } |
| 1211 | |
| 1212 | @Override |
| 1213 | public void onHardKeyboardEnabledChange(boolean enabled) { |
| 1214 | try { |
| 1215 | mBarService.setHardKeyboardEnabled(enabled); |
| 1216 | } catch (RemoteException ex) { |
| 1217 | } |
| 1218 | } |
| 1219 | |
Joe Onorato | 50ec5ec | 2010-11-28 17:15:26 -0800 | [diff] [blame] | 1220 | private boolean isImmersive() { |
| 1221 | try { |
| 1222 | return ActivityManagerNative.getDefault().isTopActivityImmersive(); |
| 1223 | //Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); |
| 1224 | } catch (RemoteException ex) { |
| 1225 | // the end is nigh |
| 1226 | return false; |
| 1227 | } |
| 1228 | } |
Jim Miller | 85babff | 2011-01-11 14:26:03 -0800 | [diff] [blame] | 1229 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1230 | @Override |
| 1231 | protected void setAreThereNotifications() { |
Daniel Sandler | 06a0d4b | 2011-08-05 00:19:21 -0400 | [diff] [blame] | 1232 | if (mNotificationPanel != null) { |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1233 | mNotificationPanel.setClearable(isDeviceProvisioned() && mNotificationData.hasClearableItems()); |
Daniel Sandler | 06a0d4b | 2011-08-05 00:19:21 -0400 | [diff] [blame] | 1234 | } |
Joe Onorato | 5dd1169 | 2010-09-27 15:34:04 -0700 | [diff] [blame] | 1235 | } |
| 1236 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1237 | private View.OnClickListener mOnClickListener = new View.OnClickListener() { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1238 | public void onClick(View v) { |
Daniel Sandler | 130453c | 2011-08-18 09:41:01 -0400 | [diff] [blame] | 1239 | if (v == mRecentButton) { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1240 | onClickRecentButton(); |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 1241 | } else if (v == mInputMethodSwitchButton) { |
| 1242 | onClickInputMethodSwitchButton(); |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1243 | } else if (v == mCompatModeButton) { |
| 1244 | onClickCompatModeButton(); |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1245 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1246 | } |
| 1247 | }; |
| 1248 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1249 | public void onClickRecentButton() { |
Daniel Sandler | b6d3dc6 | 2010-11-17 16:51:26 -0500 | [diff] [blame] | 1250 | if (DEBUG) Slog.d(TAG, "clicked recent apps; disabled=" + mDisabled); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1251 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) == 0) { |
Michael Jurka | 5571ab2 | 2011-10-27 12:54:39 -0700 | [diff] [blame] | 1252 | int msg = (mRecentsPanel.getVisibility() == View.VISIBLE) |
| 1253 | ? MSG_CLOSE_RECENTS_PANEL : MSG_OPEN_RECENTS_PANEL; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1254 | mHandler.removeMessages(msg); |
| 1255 | mHandler.sendEmptyMessage(msg); |
Jim Miller | 44c66fe | 2010-10-20 18:32:52 -0700 | [diff] [blame] | 1256 | } |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1257 | } |
Joe Onorato | 55d2d76 | 2010-09-26 13:02:01 -0700 | [diff] [blame] | 1258 | |
satok | 82beadf | 2010-12-27 19:03:06 +0900 | [diff] [blame] | 1259 | public void onClickInputMethodSwitchButton() { |
| 1260 | if (DEBUG) Slog.d(TAG, "clicked input methods panel; disabled=" + mDisabled); |
| 1261 | int msg = (mInputMethodsPanel.getVisibility() == View.GONE) ? |
| 1262 | MSG_OPEN_INPUT_METHODS_PANEL : MSG_CLOSE_INPUT_METHODS_PANEL; |
| 1263 | mHandler.removeMessages(msg); |
| 1264 | mHandler.sendEmptyMessage(msg); |
| 1265 | } |
| 1266 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1267 | public void onClickCompatModeButton() { |
| 1268 | int msg = (mCompatModePanel.getVisibility() == View.GONE) ? |
| 1269 | MSG_OPEN_COMPAT_MODE_PANEL : MSG_CLOSE_COMPAT_MODE_PANEL; |
| 1270 | mHandler.removeMessages(msg); |
| 1271 | mHandler.sendEmptyMessage(msg); |
| 1272 | } |
| 1273 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1274 | private class NotificationTriggerTouchListener implements View.OnTouchListener { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1275 | VelocityTracker mVT; |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1276 | float mInitialTouchX, mInitialTouchY; |
| 1277 | int mTouchSlop; |
| 1278 | |
| 1279 | public NotificationTriggerTouchListener() { |
| 1280 | mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); |
| 1281 | } |
| 1282 | |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 1283 | private Runnable mHiliteOnR = new Runnable() { public void run() { |
| 1284 | mNotificationArea.setBackgroundResource( |
| 1285 | com.android.internal.R.drawable.list_selector_pressed_holo_dark); |
| 1286 | }}; |
| 1287 | public void hilite(final boolean on) { |
| 1288 | if (on) { |
| 1289 | mNotificationArea.postDelayed(mHiliteOnR, 100); |
| 1290 | } else { |
| 1291 | mNotificationArea.removeCallbacks(mHiliteOnR); |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 1292 | mNotificationArea.setBackground(null); |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 1293 | } |
| 1294 | } |
| 1295 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1296 | public boolean onTouch(View v, MotionEvent event) { |
| 1297 | // Slog.d(TAG, String.format("touch: (%.1f, %.1f) initial: (%.1f, %.1f)", |
| 1298 | // event.getX(), |
| 1299 | // event.getY(), |
| 1300 | // mInitialTouchX, |
| 1301 | // mInitialTouchY)); |
Daniel Sandler | 130453c | 2011-08-18 09:41:01 -0400 | [diff] [blame] | 1302 | |
| 1303 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1304 | return true; |
| 1305 | } |
| 1306 | |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1307 | final int action = event.getAction(); |
| 1308 | switch (action) { |
| 1309 | case MotionEvent.ACTION_DOWN: |
| 1310 | mVT = VelocityTracker.obtain(); |
| 1311 | mInitialTouchX = event.getX(); |
| 1312 | mInitialTouchY = event.getY(); |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 1313 | hilite(true); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1314 | // fall through |
| 1315 | case MotionEvent.ACTION_OUTSIDE: |
| 1316 | case MotionEvent.ACTION_MOVE: |
| 1317 | // check for fling |
| 1318 | if (mVT != null) { |
| 1319 | mVT.addMovement(event); |
| 1320 | mVT.computeCurrentVelocity(1000); // pixels per second |
| 1321 | // require a little more oomph once we're already in peekaboo mode |
| 1322 | if (mVT.getYVelocity() < -mNotificationFlingVelocity) { |
| 1323 | animateExpand(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 1324 | visibilityChanged(true); |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 1325 | hilite(false); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1326 | mVT.recycle(); |
| 1327 | mVT = null; |
| 1328 | } |
| 1329 | } |
| 1330 | return true; |
| 1331 | case MotionEvent.ACTION_UP: |
| 1332 | case MotionEvent.ACTION_CANCEL: |
Daniel Sandler | 298a2a8 | 2011-08-11 16:13:22 -0400 | [diff] [blame] | 1333 | hilite(false); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1334 | if (mVT != null) { |
| 1335 | if (action == MotionEvent.ACTION_UP |
| 1336 | // was this a sloppy tap? |
Jim Miller | 9f0f0e0 | 2011-05-17 20:06:29 -0700 | [diff] [blame] | 1337 | && Math.abs(event.getX() - mInitialTouchX) < mTouchSlop |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1338 | && Math.abs(event.getY() - mInitialTouchY) < (mTouchSlop / 3) |
| 1339 | // dragging off the bottom doesn't count |
| 1340 | && (int)event.getY() < v.getBottom()) { |
| 1341 | animateExpand(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 1342 | visibilityChanged(true); |
Daniel Sandler | aa051d6 | 2011-03-01 16:23:57 -0500 | [diff] [blame] | 1343 | v.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); |
| 1344 | v.playSoundEffect(SoundEffectConstants.CLICK); |
Daniel Sandler | 56a6d88 | 2011-02-23 16:40:33 -0500 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | mVT.recycle(); |
| 1348 | mVT = null; |
| 1349 | return true; |
| 1350 | } |
| 1351 | } |
| 1352 | return false; |
| 1353 | } |
| 1354 | } |
| 1355 | |
Daniel Sandler | 663f0f2 | 2011-03-04 16:45:02 -0500 | [diff] [blame] | 1356 | public void resetNotificationPeekFadeTimer() { |
| 1357 | if (DEBUG) { |
| 1358 | Slog.d(TAG, "setting peek fade timer for " + NOTIFICATION_PEEK_FADE_DELAY |
| 1359 | + "ms from now"); |
| 1360 | } |
| 1361 | mHandler.removeMessages(MSG_CLOSE_NOTIFICATION_PEEK); |
| 1362 | mHandler.sendEmptyMessageDelayed(MSG_CLOSE_NOTIFICATION_PEEK, |
| 1363 | NOTIFICATION_PEEK_FADE_DELAY); |
| 1364 | } |
| 1365 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1366 | private void reloadAllNotificationIcons() { |
| 1367 | if (mIconLayout == null) return; |
| 1368 | mIconLayout.removeAllViews(); |
| 1369 | updateNotificationIcons(); |
| 1370 | } |
| 1371 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1372 | @Override |
| 1373 | protected void updateNotificationIcons() { |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1374 | // XXX: need to implement a new limited linear layout class |
| 1375 | // to avoid removing & readding everything |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1376 | |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1377 | if (mIconLayout == null) return; |
| 1378 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1379 | // first, populate the main notification panel |
| 1380 | loadNotificationPanel(); |
| 1381 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1382 | final LinearLayout.LayoutParams params |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 1383 | = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1384 | |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1385 | // alternate behavior in DND mode |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1386 | if (mNotificationDNDMode) { |
| 1387 | if (mIconLayout.getChildCount() == 0) { |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1388 | final Notification dndNotification = new Notification.Builder(mContext) |
| 1389 | .setContentTitle(mContext.getText(R.string.notifications_off_title)) |
| 1390 | .setContentText(mContext.getText(R.string.notifications_off_text)) |
| 1391 | .setSmallIcon(R.drawable.ic_notification_dnd) |
| 1392 | .setOngoing(true) |
| 1393 | .getNotification(); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1394 | |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 1395 | final StatusBarIconView iconView = new StatusBarIconView(mContext, "_dnd", |
| 1396 | dndNotification); |
| 1397 | iconView.setImageResource(R.drawable.ic_notification_dnd); |
| 1398 | iconView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 1399 | iconView.setPadding(mIconHPadding, 0, mIconHPadding, 0); |
| 1400 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1401 | mNotificationDNDDummyEntry = new NotificationData.Entry( |
| 1402 | null, |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 1403 | new StatusBarNotification("", 0, "", 0, 0, Notification.PRIORITY_MAX, dndNotification), |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1404 | iconView); |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1405 | |
Daniel Sandler | 282ff9a | 2011-02-23 10:36:49 -0500 | [diff] [blame] | 1406 | mIconLayout.addView(iconView, params); |
| 1407 | } |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1408 | |
| 1409 | return; |
Daniel Sandler | 8e41f31 | 2011-08-03 14:05:07 -0400 | [diff] [blame] | 1410 | } else if (0 != (mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS)) { |
| 1411 | // if icons are disabled but we're not in DND mode, this is probably Setup and we should |
| 1412 | // just leave the area totally empty |
| 1413 | return; |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1414 | } |
| 1415 | |
| 1416 | int N = mNotificationData.size(); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1417 | |
| 1418 | if (DEBUG) { |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1419 | Slog.d(TAG, "refreshing icons: " + N + " notifications, mIconLayout=" + mIconLayout); |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1420 | } |
| 1421 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1422 | ArrayList<View> toShow = new ArrayList<View>(); |
| 1423 | |
Daniel Sandler | 3b0543a | 2011-06-14 11:30:28 -0400 | [diff] [blame] | 1424 | // Extra Special Icons |
| 1425 | // The IME switcher and compatibility mode icons take the place of notifications. You didn't |
| 1426 | // need to see all those new emails, did you? |
| 1427 | int maxNotificationIconsCount = mMaxNotificationIcons; |
| 1428 | if (mInputMethodSwitchButton.getVisibility() != View.GONE) maxNotificationIconsCount --; |
| 1429 | if (mCompatModeButton.getVisibility() != View.GONE) maxNotificationIconsCount --; |
| 1430 | |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1431 | final boolean provisioned = isDeviceProvisioned(); |
| 1432 | // If the device hasn't been through Setup, we only show system notifications |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 1433 | for (int i=0; toShow.size()< maxNotificationIconsCount; i++) { |
| 1434 | if (i >= N) break; |
| 1435 | Entry ent = mNotificationData.get(N-i-1); |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1436 | if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE) |
| 1437 | || showNotificationEvenIfUnprovisioned(ent.notification)) { |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 1438 | toShow.add(ent.icon); |
| 1439 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1440 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1441 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1442 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 1443 | for (int i=0; i<mIconLayout.getChildCount(); i++) { |
| 1444 | View child = mIconLayout.getChildAt(i); |
| 1445 | if (!toShow.contains(child)) { |
| 1446 | toRemove.add(child); |
| 1447 | } |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1448 | } |
Daniel Sandler | 271ea12 | 2010-10-22 14:06:10 -0400 | [diff] [blame] | 1449 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1450 | for (View remove : toRemove) { |
| 1451 | mIconLayout.removeView(remove); |
| 1452 | } |
| 1453 | |
| 1454 | for (int i=0; i<toShow.size(); i++) { |
| 1455 | View v = toShow.get(i); |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1456 | v.setPadding(mIconHPadding, 0, mIconHPadding, 0); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1457 | if (v.getParent() == null) { |
Daniel Sandler | 0ad460b | 2010-12-14 12:14:53 -0500 | [diff] [blame] | 1458 | mIconLayout.addView(v, i, params); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1459 | } |
| 1460 | } |
Daniel Sandler | 0f0b11c | 2010-08-04 15:54:58 -0400 | [diff] [blame] | 1461 | } |
| 1462 | |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1463 | private void loadNotificationPanel() { |
Daniel Sandler | ce6ff64 | 2011-02-18 12:51:08 -0500 | [diff] [blame] | 1464 | int N = mNotificationData.size(); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1465 | |
| 1466 | ArrayList<View> toShow = new ArrayList<View>(); |
| 1467 | |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1468 | final boolean provisioned = isDeviceProvisioned(); |
| 1469 | // If the device hasn't been through Setup, we only show system notifications |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1470 | for (int i=0; i<N; i++) { |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1471 | Entry ent = mNotificationData.get(N-i-1); |
| 1472 | if (provisioned || showNotificationEvenIfUnprovisioned(ent.notification)) { |
| 1473 | toShow.add(ent.row); |
| 1474 | } |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1475 | } |
| 1476 | |
| 1477 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 1478 | for (int i=0; i<mPile.getChildCount(); i++) { |
| 1479 | View child = mPile.getChildAt(i); |
| 1480 | if (!toShow.contains(child)) { |
| 1481 | toRemove.add(child); |
| 1482 | } |
| 1483 | } |
| 1484 | |
| 1485 | for (View remove : toRemove) { |
| 1486 | mPile.removeView(remove); |
| 1487 | } |
| 1488 | |
| 1489 | for (int i=0; i<toShow.size(); i++) { |
| 1490 | View v = toShow.get(i); |
| 1491 | if (v.getParent() == null) { |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 1492 | // the notification panel has the most important things at the bottom |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1493 | mPile.addView(v, Math.min(toShow.size()-1-i, mPile.getChildCount())); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1494 | } |
| 1495 | } |
Daniel Sandler | 40c1545 | 2011-01-22 01:26:22 -0500 | [diff] [blame] | 1496 | |
John Spurlock | 3623128 | 2012-06-23 17:11:27 -0400 | [diff] [blame] | 1497 | mNotificationPanel.setNotificationCount(toShow.size()); |
| 1498 | mNotificationPanel.setSettingsEnabled(isDeviceProvisioned()); |
Daniel Sandler | b0cc50d | 2010-10-26 16:55:56 -0400 | [diff] [blame] | 1499 | } |
| 1500 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 1501 | @Override |
| 1502 | protected void workAroundBadLayerDrawableOpacity(View v) { |
Adam Powell | 29ea525 | 2011-11-15 18:59:36 -0800 | [diff] [blame] | 1503 | Drawable bgd = v.getBackground(); |
| 1504 | if (!(bgd instanceof LayerDrawable)) return; |
| 1505 | |
| 1506 | LayerDrawable d = (LayerDrawable) bgd; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 1507 | v.setBackground(null); |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 1508 | d.setOpacity(PixelFormat.TRANSLUCENT); |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 1509 | v.setBackground(d); |
Joe Onorato | 4daaeaf | 2010-11-17 20:43:12 -0800 | [diff] [blame] | 1510 | } |
| 1511 | |
Daniel Sandler | 06a0d4b | 2011-08-05 00:19:21 -0400 | [diff] [blame] | 1512 | public void clearAll() { |
| 1513 | try { |
| 1514 | mBarService.onClearAllNotifications(); |
| 1515 | } catch (RemoteException ex) { |
| 1516 | // system process is dead if we're here. |
| 1517 | } |
| 1518 | animateCollapse(); |
Mike Lockwood | 066c891 | 2011-08-24 10:17:18 -0400 | [diff] [blame] | 1519 | visibilityChanged(false); |
Daniel Sandler | 06a0d4b | 2011-08-05 00:19:21 -0400 | [diff] [blame] | 1520 | } |
| 1521 | |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1522 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 1523 | public void onReceive(Context context, Intent intent) { |
| 1524 | String action = intent.getAction(); |
| 1525 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) |
| 1526 | || Intent.ACTION_SCREEN_OFF.equals(action)) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1527 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1528 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
| 1529 | String reason = intent.getStringExtra("reason"); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1530 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 1531 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1532 | } |
| 1533 | } |
| 1534 | if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
| 1535 | // If we're turning the screen off, we want to hide the |
| 1536 | // recents panel with no animation |
| 1537 | // TODO: hide other things, like the notification tray, |
| 1538 | // with no animation as well |
| 1539 | mRecentsPanel.show(false, false); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1540 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1541 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1542 | animateCollapse(flags); |
Michael Jurka | b7f4327 | 2011-10-27 15:06:38 -0700 | [diff] [blame] | 1543 | } |
| 1544 | } |
| 1545 | }; |
| 1546 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1547 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1548 | pw.print("mDisabled=0x"); |
| 1549 | pw.println(Integer.toHexString(mDisabled)); |
Joe Onorato | 933464d | 2011-01-05 15:53:36 -0800 | [diff] [blame] | 1550 | pw.println("mNetworkController:"); |
| 1551 | mNetworkController.dump(fd, pw, args); |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1552 | } |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1553 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1554 | @Override |
| 1555 | protected boolean isTopNotification(ViewGroup parent, NotificationData.Entry entry) { |
Daniel Sandler | 15986c6 | 2012-06-28 13:38:28 -0400 | [diff] [blame] | 1556 | if (parent == null || entry == null) return false; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1557 | return parent.indexOfChild(entry.row) == parent.getChildCount()-1; |
| 1558 | } |
| 1559 | |
| 1560 | @Override |
| 1561 | protected void haltTicker() { |
| 1562 | mTicker.halt(); |
| 1563 | } |
| 1564 | |
| 1565 | @Override |
| 1566 | protected void updateExpandedViewPos(int expandedPosition) { |
| 1567 | } |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 1568 | |
| 1569 | @Override |
Jim Miller | b4238e0 | 2012-05-14 15:26:20 -0700 | [diff] [blame] | 1570 | protected boolean shouldDisableNavbarGestures() { |
| 1571 | return mNotificationPanel.getVisibility() == View.VISIBLE |
| 1572 | || (mDisabled & StatusBarManager.DISABLE_HOME) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 1573 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1574 | } |
Daniel Sandler | d39e388 | 2010-08-31 14:16:13 -0400 | [diff] [blame] | 1575 | |
| 1576 | |