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