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 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 17 | package com.android.systemui.statusbar.phone; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 18 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.AnimatorSet; |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 22 | import android.animation.ObjectAnimator; |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 23 | import android.animation.TimeInterpolator; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 24 | import android.app.ActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 25 | import android.app.ActivityManagerNative; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 26 | import android.app.Notification; |
| 27 | import android.app.PendingIntent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 28 | import android.app.StatusBarManager; |
| 29 | import android.content.BroadcastReceiver; |
| 30 | import android.content.Context; |
| 31 | import android.content.Intent; |
| 32 | import android.content.IntentFilter; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 33 | import android.content.SharedPreferences; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 34 | import android.content.res.Resources; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 35 | import android.database.ContentObserver; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 36 | import android.graphics.Canvas; |
| 37 | import android.graphics.ColorFilter; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 38 | import android.graphics.PixelFormat; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 39 | import android.graphics.Point; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 40 | import android.graphics.PorterDuff; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 41 | import android.graphics.Rect; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 42 | import android.graphics.drawable.Drawable; |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 43 | import android.graphics.drawable.NinePatchDrawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 44 | import android.inputmethodservice.InputMethodService; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 45 | import android.os.Handler; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 46 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 47 | import android.os.Message; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 48 | import android.os.RemoteException; |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 49 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 50 | import android.os.SystemClock; |
Dianne Hackborn | f02b60a | 2012-08-16 10:48:27 -0700 | [diff] [blame] | 51 | import android.os.UserHandle; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 52 | import android.provider.Settings; |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 53 | import android.service.dreams.DreamService; |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 54 | import android.service.dreams.IDreamManager; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 55 | import android.util.DisplayMetrics; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 56 | import android.util.Log; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 57 | import android.util.Slog; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 58 | import android.view.Display; |
| 59 | import android.view.Gravity; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 60 | import android.view.MotionEvent; |
| 61 | import android.view.VelocityTracker; |
| 62 | import android.view.View; |
| 63 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 64 | import android.view.ViewGroup.LayoutParams; |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 65 | import android.view.ViewPropertyAnimator; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 66 | import android.view.ViewStub; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 67 | import android.view.WindowManager; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 68 | import android.view.animation.AccelerateInterpolator; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 69 | import android.view.animation.Animation; |
| 70 | import android.view.animation.AnimationUtils; |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 71 | import android.view.animation.DecelerateInterpolator; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 72 | import android.widget.FrameLayout; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 73 | import android.widget.ImageView; |
| 74 | import android.widget.LinearLayout; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 75 | import android.widget.ScrollView; |
| 76 | import android.widget.TextView; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 77 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 78 | import com.android.internal.statusbar.StatusBarIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 79 | import com.android.internal.statusbar.StatusBarNotification; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 80 | import com.android.systemui.R; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 81 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 82 | import com.android.systemui.statusbar.CommandQueue; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 83 | import com.android.systemui.statusbar.GestureRecorder; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 84 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 85 | import com.android.systemui.statusbar.NotificationData.Entry; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 86 | import com.android.systemui.statusbar.SignalClusterView; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 87 | import com.android.systemui.statusbar.StatusBarIconView; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 88 | import com.android.systemui.statusbar.policy.BatteryController; |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 89 | import com.android.systemui.statusbar.policy.BluetoothController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 90 | import com.android.systemui.statusbar.policy.DateView; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 91 | import com.android.systemui.statusbar.policy.IntruderAlertView; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 92 | import com.android.systemui.statusbar.policy.LocationController; |
| 93 | import com.android.systemui.statusbar.policy.NetworkController; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 94 | import com.android.systemui.statusbar.policy.NotificationRowLayout; |
Michael Jurka | a600fd9 | 2012-06-25 15:57:05 -0700 | [diff] [blame] | 95 | import com.android.systemui.statusbar.policy.OnSizeChangedListener; |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 96 | import com.android.systemui.statusbar.policy.Prefs; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 97 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 98 | import java.io.FileDescriptor; |
| 99 | import java.io.PrintWriter; |
| 100 | import java.util.ArrayList; |
| 101 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 102 | public class PhoneStatusBar extends BaseStatusBar { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 103 | static final String TAG = "PhoneStatusBar"; |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 104 | public static final boolean DEBUG = BaseStatusBar.DEBUG; |
Daniel Sandler | c1ebee4 | 2012-03-26 19:39:46 -0400 | [diff] [blame] | 105 | public static final boolean SPEW = DEBUG; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 106 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 107 | public static final boolean DEBUG_GESTURES = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 108 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 109 | public static final boolean DEBUG_CLINGS = false; |
| 110 | |
Daniel Sandler | ace0bd7 | 2012-10-11 09:56:45 -0700 | [diff] [blame] | 111 | public static final boolean ENABLE_NOTIFICATION_PANEL_CLING = false; |
| 112 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 113 | public static final boolean SETTINGS_DRAG_SHORTCUT = true; |
| 114 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 115 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 116 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 117 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 118 | public static final String ACTION_STATUSBAR_START |
| 119 | = "com.android.internal.policy.statusbar.START"; |
| 120 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 121 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 122 | private static final int MSG_CLOSE_PANELS = 1001; |
| 123 | private static final int MSG_OPEN_SETTINGS_PANEL = 1002; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 124 | // 1020-1030 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 125 | |
| 126 | // will likely move to a resource or other tunable param at some point |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 127 | private static final int INTRUDER_ALERT_DECAY_MS = 0; // disabled, was 10000; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 128 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 129 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 130 | |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 131 | private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService |
| 132 | private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER; |
| 133 | |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 134 | // fling gesture tuning parameters, scaled to display density |
| 135 | private float mSelfExpandVelocityPx; // classic value: 2000px/s |
| 136 | private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up") |
| 137 | private float mFlingExpandMinVelocityPx; // classic value: 200px/s |
| 138 | private float mFlingCollapseMinVelocityPx; // classic value: 200px/s |
| 139 | private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1) |
| 140 | private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand) |
| 141 | private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s |
| 142 | |
| 143 | private float mExpandAccelPx; // classic value: 2000px/s/s |
| 144 | private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up") |
| 145 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 146 | private float mFlingGestureMaxOutputVelocityPx; // how fast can it really go? (should be a little |
| 147 | // faster than mSelfCollapseVelocityPx) |
| 148 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 149 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 150 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 151 | // These are no longer handled by the policy, because we need custom strategies for them |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 152 | BluetoothController mBluetoothController; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 153 | BatteryController mBatteryController; |
| 154 | LocationController mLocationController; |
| 155 | NetworkController mNetworkController; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 156 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 157 | int mNaturalBarHeight = -1; |
| 158 | int mIconSize = -1; |
| 159 | int mIconHPadding = -1; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 160 | Display mDisplay; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 161 | Point mCurrentDisplaySize = new Point(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 162 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 163 | IDreamManager mDreamManager; |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 164 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 165 | StatusBarWindowView mStatusBarWindow; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 166 | PhoneStatusBarView mStatusBarView; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 167 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 168 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 169 | Object mQueueLock = new Object(); |
| 170 | |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 171 | // viewgroup containing the normal contents of the statusbar |
| 172 | LinearLayout mStatusBarContents; |
| 173 | |
| 174 | // right-hand icons |
| 175 | LinearLayout mSystemIconArea; |
| 176 | |
| 177 | // left-hand icons |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 178 | LinearLayout mStatusIcons; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 179 | // the icons themselves |
| 180 | IconMerger mNotificationIcons; |
| 181 | // [+> |
| 182 | View mMoreIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 183 | |
| 184 | // expanded notifications |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 185 | NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 186 | ScrollView mScrollView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 187 | View mExpandedContents; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 188 | int mNotificationPanelGravity; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 189 | int mNotificationPanelMarginBottomPx, mNotificationPanelMarginPx; |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 190 | float mNotificationPanelMinHeightFrac; |
Daniel Sandler | 66d92f8 | 2012-06-13 13:36:52 -0400 | [diff] [blame] | 191 | boolean mNotificationPanelIsFullScreenWidth; |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 192 | TextView mNotificationPanelDebugText; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 193 | |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 194 | // settings |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 195 | QuickSettings mQS; |
| 196 | boolean mHasSettingsPanel, mHasFlipSettings; |
Daniel Sandler | 3ffdcc7 | 2012-09-23 14:31:48 -0400 | [diff] [blame] | 197 | SettingsPanelView mSettingsPanel; |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 198 | View mFlipSettingsView; |
| 199 | QuickSettingsContainerView mSettingsContainer; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 200 | int mSettingsPanelGravity; |
| 201 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 202 | // top bar |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 203 | View mNotificationPanelHeader; |
| 204 | View mDateTimeView; |
Daniel Sandler | 1347c30 | 2011-08-01 16:47:53 -0400 | [diff] [blame] | 205 | View mClearButton; |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 206 | ImageView mSettingsButton, mNotificationButton; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 207 | |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 208 | // carrier/wifi label |
| 209 | private TextView mCarrierLabel; |
| 210 | private boolean mCarrierLabelVisible = false; |
| 211 | private int mCarrierLabelHeight; |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 212 | private TextView mEmergencyCallLabel; |
Daniel Sandler | bf526d1 | 2012-09-04 22:56:44 -0400 | [diff] [blame] | 213 | private int mNotificationHeaderHeight; |
| 214 | |
| 215 | private boolean mShowCarrierInPanel = false; |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 216 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 217 | // position |
| 218 | int[] mPositionTmp = new int[2]; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 219 | boolean mExpandedVisible; |
| 220 | |
| 221 | // the date view |
| 222 | DateView mDateView; |
| 223 | |
| 224 | // for immersive activities |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 225 | private IntruderAlertView mIntruderAlertView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 226 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 227 | // on-screen navigation buttons |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 228 | private NavigationBarView mNavigationBarView = null; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 229 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 230 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 231 | int mTrackingPosition; // the position of the top of the tracking view. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 232 | |
| 233 | // ticker |
| 234 | private Ticker mTicker; |
| 235 | private View mTickerView; |
| 236 | private boolean mTicking; |
| 237 | |
| 238 | // Tracking finger for opening/closing. |
| 239 | int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore |
| 240 | boolean mTracking; |
| 241 | VelocityTracker mVelocityTracker; |
| 242 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 243 | // help screen |
| 244 | private boolean mClingShown; |
| 245 | private ViewGroup mCling; |
| 246 | private boolean mSuppressStatusBarDrags; // while a cling is up, briefly deaden the bar to give things time to settle |
| 247 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 248 | boolean mAnimating; |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 249 | boolean mClosing; // only valid when mAnimating; indicates the initial acceleration |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 250 | float mAnimY; |
| 251 | float mAnimVel; |
| 252 | float mAnimAccel; |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 253 | long mAnimLastTimeNanos; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 254 | boolean mAnimatingReveal = false; |
| 255 | int mViewDelta; |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 256 | float mFlingVelocity; |
| 257 | int mFlingY; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 258 | int[] mAbsPos = new int[2]; |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 259 | Runnable mPostCollapseCleanup = null; |
| 260 | |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 261 | private Animator mLightsOutAnimation; |
| 262 | private Animator mLightsOnAnimation; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 263 | |
| 264 | // for disabling the status bar |
| 265 | int mDisabled = 0; |
| 266 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 267 | // tracking calls to View.setSystemUiVisibility() |
| 268 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
| 269 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 270 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 271 | |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 272 | // XXX: gesture research |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 273 | private final GestureRecorder mGestureRec = DEBUG_GESTURES |
| 274 | ? new GestureRecorder("/sdcard/statusbar_gestures.dat") |
| 275 | : null; |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 276 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 277 | private int mNavigationIconHints = 0; |
Romain Guy | f7f16f7 | 2012-05-24 19:13:56 -0700 | [diff] [blame] | 278 | private final Animator.AnimatorListener mMakeIconsInvisible = new AnimatorListenerAdapter() { |
| 279 | @Override |
| 280 | public void onAnimationEnd(Animator animation) { |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 281 | // double-check to avoid races |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 282 | if (mStatusBarContents.getAlpha() == 0) { |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 283 | Slog.d(TAG, "makeIconsInvisible"); |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 284 | mStatusBarContents.setVisibility(View.INVISIBLE); |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 285 | } |
Romain Guy | f7f16f7 | 2012-05-24 19:13:56 -0700 | [diff] [blame] | 286 | } |
| 287 | }; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 288 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 289 | // ensure quick settings is disabled until the current user makes it through the setup wizard |
| 290 | private boolean mUserSetup = false; |
| 291 | private ContentObserver mUserSetupObserver = new ContentObserver(new Handler()) { |
| 292 | @Override |
| 293 | public void onChange(boolean selfChange) { |
| 294 | final boolean userSetup = 0 != Settings.Secure.getIntForUser( |
| 295 | mContext.getContentResolver(), |
| 296 | Settings.Secure.USER_SETUP_COMPLETE, |
| 297 | 0 /*default */, |
| 298 | mCurrentUserId); |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 299 | if (MULTIUSER_DEBUG) Slog.d(TAG, String.format("User setup changed: " + |
| 300 | "selfChange=%s userSetup=%s mUserSetup=%s", |
| 301 | selfChange, userSetup, mUserSetup)); |
Daniel Sandler | 91ffedd | 2012-10-17 01:09:27 -0400 | [diff] [blame] | 302 | if (mSettingsButton != null && !mHasSettingsPanel) { |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 303 | mSettingsButton.setVisibility(userSetup ? View.VISIBLE : View.INVISIBLE); |
| 304 | } |
| 305 | if (mSettingsPanel != null) { |
John Spurlock | e4e8c56 | 2012-10-04 09:55:01 -0400 | [diff] [blame] | 306 | mSettingsPanel.setEnabled(userSetup); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 307 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 308 | if (userSetup != mUserSetup) { |
| 309 | mUserSetup = userSetup; |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 310 | if (!mUserSetup && mStatusBarView != null) |
| 311 | animateCollapseQuickSettings(); |
| 312 | } |
| 313 | } |
| 314 | }; |
| 315 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 316 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 317 | public void start() { |
| 318 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 319 | .getDefaultDisplay(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 320 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 321 | mDreamManager = IDreamManager.Stub.asInterface( |
Dianne Hackborn | be87e2f | 2012-09-28 16:31:34 -0700 | [diff] [blame] | 322 | ServiceManager.checkService(DreamService.DREAM_SERVICE)); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 323 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 324 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 325 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 326 | addNavigationBar(); |
| 327 | |
Daniel Sandler | fc6fda3 | 2012-02-24 22:00:46 -0500 | [diff] [blame] | 328 | if (ENABLE_INTRUDERS) addIntruderView(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 329 | |
| 330 | // Lastly, call to the icon policy to install/update all the icons. |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 331 | mIconPolicy = new PhoneStatusBarPolicy(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | // ================================================================================ |
| 335 | // Constructing the view |
| 336 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 337 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 338 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 339 | |
| 340 | Resources res = context.getResources(); |
| 341 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 342 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 343 | loadDimens(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 344 | |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 345 | mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); |
| 346 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 347 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 348 | R.layout.super_status_bar, null); |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 349 | mStatusBarWindow.mService = this; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 350 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 351 | @Override |
| 352 | public boolean onTouch(View v, MotionEvent event) { |
| 353 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 354 | if (mExpandedVisible && !mAnimating) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 355 | animateCollapsePanels(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 356 | } |
| 357 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 358 | return mStatusBarWindow.onTouchEvent(event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 359 | }}); |
| 360 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 361 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 362 | mStatusBarView.setBar(this); |
Daniel Sandler | efb0faf | 2012-10-10 14:15:34 -0700 | [diff] [blame] | 363 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 364 | |
| 365 | PanelHolder holder = (PanelHolder) mStatusBarWindow.findViewById(R.id.panel_holder); |
| 366 | mStatusBarView.setPanelHolder(holder); |
| 367 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 368 | mNotificationPanel = (NotificationPanelView) mStatusBarWindow.findViewById(R.id.notification_panel); |
| 369 | mNotificationPanel.setStatusBar(this); |
Daniel Sandler | 66d92f8 | 2012-06-13 13:36:52 -0400 | [diff] [blame] | 370 | mNotificationPanelIsFullScreenWidth = |
| 371 | (mNotificationPanel.getLayoutParams().width == ViewGroup.LayoutParams.MATCH_PARENT); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 372 | |
Daniel Sandler | efb0faf | 2012-10-10 14:15:34 -0700 | [diff] [blame] | 373 | // make the header non-responsive to clicks |
| 374 | mNotificationPanel.findViewById(R.id.header).setOnTouchListener( |
| 375 | new View.OnTouchListener() { |
| 376 | @Override |
| 377 | public boolean onTouch(View v, MotionEvent event) { |
| 378 | return true; // e eats everything |
| 379 | } |
| 380 | }); |
| 381 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 382 | if (!ActivityManager.isHighEndGfx()) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 383 | mStatusBarWindow.setBackground(null); |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 384 | mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor( |
| 385 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 386 | } |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 387 | if (ENABLE_INTRUDERS) { |
| 388 | mIntruderAlertView = (IntruderAlertView) View.inflate(context, R.layout.intruder_alert, null); |
| 389 | mIntruderAlertView.setVisibility(View.GONE); |
| 390 | mIntruderAlertView.setBar(this); |
| 391 | } |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 392 | if (MULTIUSER_DEBUG) { |
| 393 | mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(R.id.header_debug_info); |
| 394 | mNotificationPanelDebugText.setVisibility(View.VISIBLE); |
| 395 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 396 | |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 397 | updateShowSearchHoldoff(); |
| 398 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 399 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 400 | boolean showNav = mWindowManagerService.hasNavigationBar(); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 401 | if (DEBUG) Slog.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 402 | if (showNav) { |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 403 | mNavigationBarView = |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 404 | (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 405 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 406 | mNavigationBarView.setDisabledFlags(mDisabled); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 407 | mNavigationBarView.setBar(this); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 408 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 409 | } catch (RemoteException ex) { |
| 410 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 411 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 412 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 413 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 414 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 415 | |
| 416 | mSystemIconArea = (LinearLayout) mStatusBarView.findViewById(R.id.system_icon_area); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 417 | mStatusIcons = (LinearLayout)mStatusBarView.findViewById(R.id.statusIcons); |
| 418 | mNotificationIcons = (IconMerger)mStatusBarView.findViewById(R.id.notificationIcons); |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 419 | mNotificationIcons.setOverflowIndicator(mMoreIcon); |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 420 | mStatusBarContents = (LinearLayout)mStatusBarView.findViewById(R.id.status_bar_contents); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 421 | mTickerView = mStatusBarView.findViewById(R.id.ticker); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 422 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 423 | mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems); |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 424 | mPile.setLayoutTransitionsEnabled(false); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 425 | mPile.setLongPressListener(getNotificationLongClicker()); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 426 | mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout); |
Daniel Sandler | d714148 | 2011-08-18 15:14:52 -0400 | [diff] [blame] | 427 | |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 428 | mNotificationPanelHeader = mStatusBarWindow.findViewById(R.id.header); |
| 429 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 430 | mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 431 | mClearButton.setOnClickListener(mClearButtonListener); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 432 | mClearButton.setAlpha(0f); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 433 | mClearButton.setVisibility(View.INVISIBLE); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 434 | mClearButton.setEnabled(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 435 | mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 436 | |
| 437 | mHasSettingsPanel = res.getBoolean(R.bool.config_hasSettingsPanel); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 438 | mHasFlipSettings = res.getBoolean(R.bool.config_hasFlipSettingsPanel); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 439 | |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 440 | mDateTimeView = mNotificationPanelHeader.findViewById(R.id.datetime); |
| 441 | if (mHasFlipSettings) { |
| 442 | mDateTimeView.setOnClickListener(mClockClickListener); |
| 443 | mDateTimeView.setEnabled(true); |
| 444 | } |
| 445 | |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 446 | mSettingsButton = (ImageView) mStatusBarWindow.findViewById(R.id.settings_button); |
Daniel Sandler | 6e5fe43 | 2012-09-16 15:34:36 -0400 | [diff] [blame] | 447 | if (mSettingsButton != null) { |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 448 | mSettingsButton.setOnClickListener(mSettingsButtonListener); |
| 449 | if (mHasSettingsPanel) { |
| 450 | if (mStatusBarView.hasFullWidthNotifications()) { |
| 451 | // the settings panel is hiding behind this button |
| 452 | mSettingsButton.setImageResource(R.drawable.ic_notify_quicksettings); |
| 453 | mSettingsButton.setVisibility(View.VISIBLE); |
| 454 | } else { |
| 455 | // there is a settings panel, but it's on the other side of the (large) screen |
| 456 | mSettingsButton.setVisibility(View.GONE); |
| 457 | } |
Daniel Sandler | efb0faf | 2012-10-10 14:15:34 -0700 | [diff] [blame] | 458 | } else { |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 459 | // no settings panel, go straight to settings |
| 460 | mSettingsButton.setVisibility(View.VISIBLE); |
| 461 | mSettingsButton.setImageResource(R.drawable.ic_notify_settings); |
Daniel Sandler | efb0faf | 2012-10-10 14:15:34 -0700 | [diff] [blame] | 462 | } |
Daniel Sandler | 6e5fe43 | 2012-09-16 15:34:36 -0400 | [diff] [blame] | 463 | } |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 464 | if (mHasFlipSettings) { |
| 465 | mNotificationButton = (ImageView) mStatusBarWindow.findViewById(R.id.notification_button); |
| 466 | if (mNotificationButton != null) { |
| 467 | mNotificationButton.setOnClickListener(mNotificationButtonListener); |
| 468 | } |
| 469 | } |
| 470 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 471 | mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll); |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 472 | mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 473 | if (!mNotificationPanelIsFullScreenWidth) { |
| 474 | mScrollView.setSystemUiVisibility( |
| 475 | View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER | |
| 476 | View.STATUS_BAR_DISABLE_NOTIFICATION_ICONS | |
| 477 | View.STATUS_BAR_DISABLE_CLOCK); |
| 478 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 479 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 480 | mTicker = new MyTicker(context, mStatusBarView); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 481 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 482 | TickerView tickerView = (TickerView)mStatusBarView.findViewById(R.id.tickerText); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 483 | tickerView.mTicker = mTicker; |
| 484 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 485 | mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); |
| 486 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 487 | // set the inital view visibility |
| 488 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 489 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 490 | // Other icons |
| 491 | mLocationController = new LocationController(mContext); // will post a notification |
| 492 | mBatteryController = new BatteryController(mContext); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 493 | mBatteryController.addIconView((ImageView)mStatusBarView.findViewById(R.id.battery)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 494 | mNetworkController = new NetworkController(mContext); |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 495 | mBluetoothController = new BluetoothController(mContext); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 496 | final SignalClusterView signalCluster = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 497 | (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster); |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 498 | |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 499 | |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 500 | mNetworkController.addSignalCluster(signalCluster); |
Daniel Sandler | 28f89d4 | 2011-08-15 14:04:15 -0400 | [diff] [blame] | 501 | signalCluster.setNetworkController(mNetworkController); |
Daniel Sandler | 18ac782 | 2012-06-11 16:07:18 -0400 | [diff] [blame] | 502 | |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 503 | mEmergencyCallLabel = (TextView)mStatusBarWindow.findViewById(R.id.emergency_calls_only); |
| 504 | if (mEmergencyCallLabel != null) { |
| 505 | mNetworkController.addEmergencyLabelView(mEmergencyCallLabel); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 506 | mEmergencyCallLabel.setOnClickListener(new View.OnClickListener() { |
| 507 | public void onClick(View v) { }}); |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 508 | mEmergencyCallLabel.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { |
| 509 | @Override |
| 510 | public void onLayoutChange(View v, int left, int top, int right, int bottom, |
| 511 | int oldLeft, int oldTop, int oldRight, int oldBottom) { |
| 512 | updateCarrierLabelVisibility(false); |
| 513 | }}); |
| 514 | } |
| 515 | |
Daniel Sandler | bf526d1 | 2012-09-04 22:56:44 -0400 | [diff] [blame] | 516 | mCarrierLabel = (TextView)mStatusBarWindow.findViewById(R.id.carrier_label); |
| 517 | mShowCarrierInPanel = (mCarrierLabel != null); |
| 518 | Slog.v(TAG, "carrierlabel=" + mCarrierLabel + " show=" + mShowCarrierInPanel); |
| 519 | if (mShowCarrierInPanel) { |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 520 | mCarrierLabel.setVisibility(mCarrierLabelVisible ? View.VISIBLE : View.INVISIBLE); |
| 521 | |
Daniel Sandler | 67234c4 | 2012-06-15 13:17:39 -0400 | [diff] [blame] | 522 | // for mobile devices, we always show mobile connection info here (SPN/PLMN) |
| 523 | // for other devices, we show whatever network is connected |
Daniel Sandler | 18ac782 | 2012-06-11 16:07:18 -0400 | [diff] [blame] | 524 | if (mNetworkController.hasMobileDataFeature()) { |
| 525 | mNetworkController.addMobileLabelView(mCarrierLabel); |
| 526 | } else { |
Daniel Sandler | 67234c4 | 2012-06-15 13:17:39 -0400 | [diff] [blame] | 527 | mNetworkController.addCombinedLabelView(mCarrierLabel); |
Daniel Sandler | 18ac782 | 2012-06-11 16:07:18 -0400 | [diff] [blame] | 528 | } |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 529 | |
| 530 | // set up the dynamic hide/show of the label |
| 531 | mPile.setOnSizeChangedListener(new OnSizeChangedListener() { |
| 532 | @Override |
| 533 | public void onSizeChanged(View view, int w, int h, int oldw, int oldh) { |
| 534 | updateCarrierLabelVisibility(false); |
| 535 | } |
| 536 | }); |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 537 | } |
| 538 | |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 539 | // Quick Settings (where available, some restrictions apply) |
| 540 | if (mHasSettingsPanel) { |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 541 | // first, figure out where quick settings should be inflated |
| 542 | final View settings_stub; |
| 543 | if (mHasFlipSettings) { |
| 544 | // a version of quick settings that flips around behind the notifications |
| 545 | settings_stub = mStatusBarWindow.findViewById(R.id.flip_settings_stub); |
| 546 | if (settings_stub != null) { |
| 547 | mFlipSettingsView = ((ViewStub)settings_stub).inflate(); |
| 548 | mFlipSettingsView.setVisibility(View.GONE); |
| 549 | mFlipSettingsView.setVerticalScrollBarEnabled(false); |
| 550 | } |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 551 | } else { |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 552 | // full quick settings panel |
| 553 | settings_stub = mStatusBarWindow.findViewById(R.id.quick_settings_stub); |
| 554 | if (settings_stub != null) { |
| 555 | mSettingsPanel = (SettingsPanelView) ((ViewStub)settings_stub).inflate(); |
| 556 | } else { |
| 557 | mSettingsPanel = (SettingsPanelView) mStatusBarWindow.findViewById(R.id.settings_panel); |
| 558 | } |
| 559 | |
| 560 | if (mSettingsPanel != null) { |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 561 | if (!ActivityManager.isHighEndGfx()) { |
| 562 | mSettingsPanel.setBackground(new FastColorDrawable(context.getResources().getColor( |
| 563 | R.color.notification_panel_solid_background))); |
| 564 | } |
| 565 | } |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 566 | } |
| 567 | |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 568 | // wherever you find it, Quick Settings needs a container to survive |
| 569 | mSettingsContainer = (QuickSettingsContainerView) |
| 570 | mStatusBarWindow.findViewById(R.id.quick_settings_container); |
| 571 | if (mSettingsContainer != null) { |
| 572 | mQS = new QuickSettings(mContext, mSettingsContainer); |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 573 | if (!mNotificationPanelIsFullScreenWidth) { |
| 574 | mSettingsContainer.setSystemUiVisibility( |
| 575 | View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER |
| 576 | | View.STATUS_BAR_DISABLE_SYSTEM_INFO); |
| 577 | } |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 578 | if (mSettingsPanel != null) { |
| 579 | mSettingsPanel.setQuickSettings(mQS); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 580 | } |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 581 | mQS.setService(this); |
Daniel Sandler | fe3376b | 2012-10-16 19:54:02 -0400 | [diff] [blame] | 582 | mQS.setBar(mStatusBarView); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 583 | mQS.setup(mNetworkController, mBluetoothController, mBatteryController, |
| 584 | mLocationController); |
| 585 | } else { |
| 586 | mQS = null; // fly away, be free |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 587 | } |
Siva Velusamy | 537421b | 2012-09-14 14:45:02 -0700 | [diff] [blame] | 588 | } |
| 589 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 590 | mClingShown = ! (DEBUG_CLINGS |
| 591 | || !Prefs.read(mContext).getBoolean(Prefs.SHOWN_QUICK_SETTINGS_HELP, false)); |
| 592 | |
Daniel Sandler | ace0bd7 | 2012-10-11 09:56:45 -0700 | [diff] [blame] | 593 | if (!ENABLE_NOTIFICATION_PANEL_CLING || ActivityManager.isRunningInTestHarness()) { |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 594 | mClingShown = true; |
| 595 | } |
| 596 | |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 597 | // final ImageView wimaxRSSI = |
Daniel Sandler | 633eabe | 2011-11-09 16:49:44 -0500 | [diff] [blame] | 598 | // (ImageView)sb.findViewById(R.id.wimax_signal); |
| 599 | // if (wimaxRSSI != null) { |
| 600 | // mNetworkController.addWimaxIconView(wimaxRSSI); |
| 601 | // } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 602 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 603 | // receive broadcasts |
| 604 | IntentFilter filter = new IntentFilter(); |
| 605 | filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); |
| 606 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 607 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 608 | filter.addAction(Intent.ACTION_SCREEN_ON); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 609 | context.registerReceiver(mBroadcastReceiver, filter); |
| 610 | |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 611 | // listen for USER_SETUP_COMPLETE setting (per-user) |
| 612 | resetUserSetupObserver(); |
| 613 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 614 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 615 | } |
| 616 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 617 | @Override |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 618 | protected View getStatusBarView() { |
| 619 | return mStatusBarView; |
| 620 | } |
| 621 | |
| 622 | @Override |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 623 | protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { |
Michael Jurka | 3cd0a59 | 2011-08-16 12:40:30 -0700 | [diff] [blame] | 624 | boolean opaque = false; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 625 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 626 | layoutParams.width, |
| 627 | layoutParams.height, |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 628 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 629 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 630 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 631 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Michael Jurka | 3cd0a59 | 2011-08-16 12:40:30 -0700 | [diff] [blame] | 632 | (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 633 | if (ActivityManager.isHighEndGfx()) { |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 634 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
Michael Jurka | f16fc51 | 2012-02-27 15:02:23 -0800 | [diff] [blame] | 635 | } else { |
| 636 | lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; |
Michael Jurka | f3abbad | 2012-06-04 14:00:32 -0700 | [diff] [blame] | 637 | lp.dimAmount = 0.75f; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 638 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 639 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 640 | lp.setTitle("RecentsPanel"); |
Michael Jurka | 99a9655 | 2012-01-27 17:23:38 -0800 | [diff] [blame] | 641 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 642 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 643 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 644 | return lp; |
| 645 | } |
| 646 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 647 | @Override |
| 648 | protected WindowManager.LayoutParams getSearchLayoutParams(LayoutParams layoutParams) { |
| 649 | boolean opaque = false; |
| 650 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 651 | LayoutParams.MATCH_PARENT, |
| 652 | LayoutParams.MATCH_PARENT, |
| 653 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 654 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 655 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 656 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 657 | (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 658 | if (ActivityManager.isHighEndGfx()) { |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 659 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 660 | } |
| 661 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 662 | lp.setTitle("SearchPanel"); |
| 663 | // TODO: Define custom animation for Search panel |
| 664 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
| 665 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 666 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 667 | return lp; |
| 668 | } |
| 669 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 670 | @Override |
| 671 | protected void updateSearchPanel() { |
| 672 | super.updateSearchPanel(); |
Jim Miller | 354619c | 2012-04-27 17:33:44 -0700 | [diff] [blame] | 673 | mSearchPanelView.setStatusBarView(mNavigationBarView); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 674 | mNavigationBarView.setDelegateView(mSearchPanelView); |
| 675 | } |
| 676 | |
| 677 | @Override |
| 678 | public void showSearchPanel() { |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 679 | super.showSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 680 | WindowManager.LayoutParams lp = |
| 681 | (android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams(); |
| 682 | lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 683 | mWindowManager.updateViewLayout(mNavigationBarView, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | @Override |
| 687 | public void hideSearchPanel() { |
| 688 | super.hideSearchPanel(); |
| 689 | WindowManager.LayoutParams lp = |
| 690 | (android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams(); |
| 691 | lp.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 692 | mWindowManager.updateViewLayout(mNavigationBarView, lp); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 695 | protected int getStatusBarGravity() { |
| 696 | return Gravity.TOP | Gravity.FILL_HORIZONTAL; |
| 697 | } |
| 698 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 699 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 700 | if (mNaturalBarHeight < 0) { |
| 701 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 702 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 703 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 704 | } |
| 705 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 706 | } |
| 707 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 708 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
| 709 | public void onClick(View v) { |
| 710 | toggleRecentApps(); |
| 711 | } |
| 712 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 713 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 714 | private int mShowSearchHoldoff = 0; |
| 715 | private Runnable mShowSearchPanel = new Runnable() { |
| 716 | public void run() { |
| 717 | showSearchPanel(); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 718 | awakenDreams(); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 719 | } |
| 720 | }; |
| 721 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 722 | View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() { |
| 723 | public boolean onTouch(View v, MotionEvent event) { |
| 724 | switch(event.getAction()) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 725 | case MotionEvent.ACTION_DOWN: |
John Spurlock | 67ad368 | 2012-06-26 17:42:00 -0400 | [diff] [blame] | 726 | if (!shouldDisableNavbarGestures() && !inKeyguardRestrictedInputMode()) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 727 | mHandler.removeCallbacks(mShowSearchPanel); |
| 728 | mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff); |
| 729 | } |
| 730 | break; |
| 731 | |
| 732 | case MotionEvent.ACTION_UP: |
| 733 | case MotionEvent.ACTION_CANCEL: |
| 734 | mHandler.removeCallbacks(mShowSearchPanel); |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 735 | awakenDreams(); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 736 | break; |
| 737 | } |
| 738 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 739 | } |
| 740 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 741 | |
Daniel Sandler | a2fbe53 | 2012-08-10 01:19:03 -0400 | [diff] [blame] | 742 | private void awakenDreams() { |
| 743 | if (mDreamManager != null) { |
| 744 | try { |
| 745 | mDreamManager.awaken(); |
| 746 | } catch (RemoteException e) { |
| 747 | // fine, stay asleep then |
| 748 | } |
| 749 | } |
| 750 | } |
| 751 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 752 | private void prepareNavigationBarView() { |
| 753 | mNavigationBarView.reorient(); |
| 754 | |
| 755 | mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); |
Michael Jurka | cb2522c | 2012-04-13 09:32:47 -0700 | [diff] [blame] | 756 | mNavigationBarView.getRecentsButton().setOnTouchListener(getRecentTasksLoader()); |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 757 | mNavigationBarView.getHomeButton().setOnTouchListener(mHomeSearchActionListener); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 758 | updateSearchPanel(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 759 | } |
| 760 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 761 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
| 762 | private void addNavigationBar() { |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 763 | if (DEBUG) Slog.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 764 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 765 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 766 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 767 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 768 | mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | private void repositionNavigationBar() { |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 772 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 773 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 774 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 775 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 776 | mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams()); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 780 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 781 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 782 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 783 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 784 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 785 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 786 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Daniel Sandler | c26185b | 2012-08-29 15:49:53 -0400 | [diff] [blame] | 787 | | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH |
Jim Miller | d99e7fd | 2012-05-08 16:30:42 -0700 | [diff] [blame] | 788 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Daniel Sandler | a388449 | 2011-08-16 15:55:44 -0400 | [diff] [blame] | 789 | PixelFormat.OPAQUE); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 790 | // this will allow the navbar to run in an overlay on devices that support this |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 791 | if (ActivityManager.isHighEndGfx()) { |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 792 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 793 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 794 | |
| 795 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 796 | lp.windowAnimations = 0; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 797 | return lp; |
| 798 | } |
| 799 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 800 | private void addIntruderView() { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 801 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 802 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 803 | ViewGroup.LayoutParams.WRAP_CONTENT, |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 804 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar! |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 805 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 806 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
| 807 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 808 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Jeff Brown | 46e7529 | 2010-11-10 16:53:45 -0800 | [diff] [blame] | 809 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 810 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 811 | PixelFormat.TRANSLUCENT); |
| 812 | lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 813 | //lp.y += height * 1.5; // FIXME |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 814 | lp.setTitle("IntruderAlert"); |
Dianne Hackborn | 59aed38 | 2011-08-02 17:31:44 -0700 | [diff] [blame] | 815 | lp.packageName = mContext.getPackageName(); |
| 816 | lp.windowAnimations = R.style.Animation_StatusBar_IntruderAlert; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 817 | |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 818 | mWindowManager.addView(mIntruderAlertView, lp); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 819 | } |
| 820 | |
| 821 | public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { |
| 822 | if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex |
| 823 | + " icon=" + icon); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 824 | StatusBarIconView view = new StatusBarIconView(mContext, slot, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 825 | view.set(icon); |
| 826 | mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); |
| 827 | } |
| 828 | |
| 829 | public void updateIcon(String slot, int index, int viewIndex, |
| 830 | StatusBarIcon old, StatusBarIcon icon) { |
| 831 | if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex |
| 832 | + " old=" + old + " icon=" + icon); |
| 833 | StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); |
| 834 | view.set(icon); |
| 835 | } |
| 836 | |
| 837 | public void removeIcon(String slot, int index, int viewIndex) { |
| 838 | if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); |
| 839 | mStatusIcons.removeViewAt(viewIndex); |
| 840 | } |
| 841 | |
| 842 | public void addNotification(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 843 | /* if (DEBUG) */ Slog.d(TAG, "addNotification score=" + notification.score); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 844 | StatusBarIconView iconView = addNotificationViews(key, notification); |
| 845 | if (iconView == null) return; |
| 846 | |
| 847 | boolean immersive = false; |
| 848 | try { |
| 849 | immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); |
Daniel Sandler | 8355e93 | 2011-08-11 00:27:45 -0400 | [diff] [blame] | 850 | if (DEBUG) { |
| 851 | Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); |
| 852 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 853 | } catch (RemoteException ex) { |
| 854 | } |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 855 | |
| 856 | /* |
| 857 | * DISABLED due to missing API |
Daniel Sandler | fc6fda3 | 2012-02-24 22:00:46 -0500 | [diff] [blame] | 858 | if (ENABLE_INTRUDERS && ( |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 859 | // TODO(dsandler): Only if the screen is on |
| 860 | notification.notification.intruderView != null)) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 861 | Slog.d(TAG, "Presenting high-priority notification"); |
| 862 | // special new transient ticker mode |
| 863 | // 1. Populate mIntruderAlertView |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 864 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 865 | if (notification.notification.intruderView == null) { |
| 866 | Slog.e(TAG, notification.notification.toString() + " wanted to intrude but intruderView was null"); |
| 867 | return; |
| 868 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 869 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 870 | // bind the click event to the content area |
| 871 | PendingIntent contentIntent = notification.notification.contentIntent; |
| 872 | final View.OnClickListener listener = (contentIntent != null) |
| 873 | ? new NotificationClicker(contentIntent, |
| 874 | notification.pkg, notification.tag, notification.id) |
| 875 | : null; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 876 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 877 | mIntruderAlertView.applyIntruderContent(notification.notification.intruderView, listener); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 878 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 879 | mCurrentlyIntrudingNotification = notification; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 880 | |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 881 | // 2. Animate mIntruderAlertView in |
| 882 | mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 883 | |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 884 | // 3. Set alarm to age the notification off (TODO) |
| 885 | mHandler.removeMessages(MSG_HIDE_INTRUDER); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 886 | if (INTRUDER_ALERT_DECAY_MS > 0) { |
| 887 | mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); |
| 888 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 889 | } else |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 890 | */ |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 891 | |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 892 | if (notification.notification.fullScreenIntent != null) { |
Daniel Sandler | c9ce0ab | 2012-09-04 13:27:09 -0400 | [diff] [blame] | 893 | // Stop screensaver if the notification has a full-screen intent. |
| 894 | // (like an incoming phone call) |
| 895 | awakenDreams(); |
| 896 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 897 | // not immersive & a full-screen alert should be shown |
Daniel Sandler | 8355e93 | 2011-08-11 00:27:45 -0400 | [diff] [blame] | 898 | Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 899 | try { |
| 900 | notification.notification.fullScreenIntent.send(); |
| 901 | } catch (PendingIntent.CanceledException e) { |
| 902 | } |
| 903 | } else { |
| 904 | // usual case: status bar visible & not immersive |
| 905 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 906 | // show the ticker if there isn't an intruder too |
| 907 | if (mCurrentlyIntrudingNotification == null) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 908 | tick(null, notification, true); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 909 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | // Recalculate the position of the sliding windows and the titles. |
| 913 | setAreThereNotifications(); |
| 914 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
| 915 | } |
| 916 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 917 | public void removeNotification(IBinder key) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 918 | StatusBarNotification old = removeNotificationViews(key); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 919 | if (SPEW) Slog.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 920 | |
| 921 | if (old != null) { |
| 922 | // Cancel the ticker if it's still running |
| 923 | mTicker.removeEntry(old); |
| 924 | |
| 925 | // Recalculate the position of the sliding windows and the titles. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 926 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 927 | |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 928 | if (ENABLE_INTRUDERS && old == mCurrentlyIntrudingNotification) { |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 929 | mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); |
| 930 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 931 | |
| 932 | if (CLOSE_PANEL_WHEN_EMPTIED && mNotificationData.size() == 0 && !mAnimating) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 933 | animateCollapsePanels(); |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 934 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 935 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 936 | |
| 937 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 938 | } |
| 939 | |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 940 | private void updateShowSearchHoldoff() { |
| 941 | mShowSearchHoldoff = mContext.getResources().getInteger( |
| 942 | R.integer.config_show_search_delay); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 943 | } |
| 944 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 945 | private void loadNotificationShade() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 946 | if (mPile == null) return; |
| 947 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 948 | int N = mNotificationData.size(); |
| 949 | |
| 950 | ArrayList<View> toShow = new ArrayList<View>(); |
| 951 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 952 | final boolean provisioned = isDeviceProvisioned(); |
| 953 | // If the device hasn't been through Setup, we only show system notifications |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 954 | for (int i=0; i<N; i++) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 955 | Entry ent = mNotificationData.get(N-i-1); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 956 | if (!(provisioned || showNotificationEvenIfUnprovisioned(ent.notification))) continue; |
| 957 | if (!notificationIsForCurrentUser(ent.notification)) continue; |
| 958 | toShow.add(ent.row); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 959 | } |
| 960 | |
| 961 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 962 | for (int i=0; i<mPile.getChildCount(); i++) { |
| 963 | View child = mPile.getChildAt(i); |
| 964 | if (!toShow.contains(child)) { |
| 965 | toRemove.add(child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 966 | } |
| 967 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 968 | |
| 969 | for (View remove : toRemove) { |
| 970 | mPile.removeView(remove); |
| 971 | } |
| 972 | |
| 973 | for (int i=0; i<toShow.size(); i++) { |
| 974 | View v = toShow.get(i); |
| 975 | if (v.getParent() == null) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 976 | mPile.addView(v, i); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 977 | } |
| 978 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 979 | |
Daniel Sandler | 6e5fe43 | 2012-09-16 15:34:36 -0400 | [diff] [blame] | 980 | if (mSettingsButton != null) { |
| 981 | mSettingsButton.setEnabled(isDeviceProvisioned()); |
| 982 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 983 | } |
| 984 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 985 | @Override |
| 986 | protected void updateNotificationIcons() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 987 | if (mNotificationIcons == null) return; |
| 988 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 989 | loadNotificationShade(); |
| 990 | |
| 991 | final LinearLayout.LayoutParams params |
| 992 | = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); |
| 993 | |
| 994 | int N = mNotificationData.size(); |
| 995 | |
| 996 | if (DEBUG) { |
| 997 | Slog.d(TAG, "refreshing icons: " + N + " notifications, mNotificationIcons=" + mNotificationIcons); |
| 998 | } |
| 999 | |
| 1000 | ArrayList<View> toShow = new ArrayList<View>(); |
| 1001 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1002 | final boolean provisioned = isDeviceProvisioned(); |
| 1003 | // If the device hasn't been through Setup, we only show system notifications |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1004 | for (int i=0; i<N; i++) { |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 1005 | Entry ent = mNotificationData.get(N-i-1); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 1006 | if (!((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE) |
| 1007 | || showNotificationEvenIfUnprovisioned(ent.notification))) continue; |
| 1008 | if (!notificationIsForCurrentUser(ent.notification)) continue; |
| 1009 | toShow.add(ent.icon); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1010 | } |
| 1011 | |
| 1012 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 1013 | for (int i=0; i<mNotificationIcons.getChildCount(); i++) { |
| 1014 | View child = mNotificationIcons.getChildAt(i); |
| 1015 | if (!toShow.contains(child)) { |
| 1016 | toRemove.add(child); |
| 1017 | } |
| 1018 | } |
| 1019 | |
| 1020 | for (View remove : toRemove) { |
| 1021 | mNotificationIcons.removeView(remove); |
| 1022 | } |
| 1023 | |
| 1024 | for (int i=0; i<toShow.size(); i++) { |
| 1025 | View v = toShow.get(i); |
| 1026 | if (v.getParent() == null) { |
| 1027 | mNotificationIcons.addView(v, i, params); |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1032 | protected void updateCarrierLabelVisibility(boolean force) { |
Daniel Sandler | bf526d1 | 2012-09-04 22:56:44 -0400 | [diff] [blame] | 1033 | if (!mShowCarrierInPanel) return; |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1034 | // The idea here is to only show the carrier label when there is enough room to see it, |
| 1035 | // i.e. when there aren't enough notifications to fill the panel. |
| 1036 | if (DEBUG) { |
| 1037 | Slog.d(TAG, String.format("pileh=%d scrollh=%d carrierh=%d", |
| 1038 | mPile.getHeight(), mScrollView.getHeight(), mCarrierLabelHeight)); |
| 1039 | } |
Daniel Sandler | dd4ef49 | 2012-07-27 11:19:52 -0400 | [diff] [blame] | 1040 | |
| 1041 | final boolean emergencyCallsShownElsewhere = mEmergencyCallLabel != null; |
| 1042 | final boolean makeVisible = |
| 1043 | !(emergencyCallsShownElsewhere && mNetworkController.isEmergencyOnly()) |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1044 | && mPile.getHeight() < (mNotificationPanel.getHeight() - mCarrierLabelHeight - mNotificationHeaderHeight) |
| 1045 | && mScrollView.getVisibility() == View.VISIBLE; |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1046 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1047 | if (force || mCarrierLabelVisible != makeVisible) { |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1048 | mCarrierLabelVisible = makeVisible; |
| 1049 | if (DEBUG) { |
| 1050 | Slog.d(TAG, "making carrier label " + (makeVisible?"visible":"invisible")); |
| 1051 | } |
| 1052 | mCarrierLabel.animate().cancel(); |
| 1053 | if (makeVisible) { |
| 1054 | mCarrierLabel.setVisibility(View.VISIBLE); |
| 1055 | } |
| 1056 | mCarrierLabel.animate() |
| 1057 | .alpha(makeVisible ? 1f : 0f) |
| 1058 | //.setStartDelay(makeVisible ? 500 : 0) |
| 1059 | //.setDuration(makeVisible ? 750 : 100) |
| 1060 | .setDuration(150) |
| 1061 | .setListener(makeVisible ? null : new AnimatorListenerAdapter() { |
| 1062 | @Override |
| 1063 | public void onAnimationEnd(Animator animation) { |
| 1064 | if (!mCarrierLabelVisible) { // race |
| 1065 | mCarrierLabel.setVisibility(View.INVISIBLE); |
| 1066 | mCarrierLabel.setAlpha(0f); |
| 1067 | } |
| 1068 | } |
| 1069 | }) |
| 1070 | .start(); |
| 1071 | } |
| 1072 | } |
| 1073 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1074 | @Override |
| 1075 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1076 | final boolean any = mNotificationData.size() > 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1077 | |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1078 | final boolean clearable = any && mNotificationData.hasClearableItems(); |
| 1079 | |
| 1080 | if (DEBUG) { |
| 1081 | Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size() |
| 1082 | + " any=" + any + " clearable=" + clearable); |
| 1083 | } |
| 1084 | |
Daniel Sandler | 6e2810b | 2012-10-17 09:40:09 -0400 | [diff] [blame] | 1085 | if (mHasFlipSettings |
| 1086 | && mFlipSettingsView != null |
Daniel Sandler | f249efc | 2012-10-17 16:42:36 -0400 | [diff] [blame] | 1087 | && mFlipSettingsView.getVisibility() == View.VISIBLE |
| 1088 | && mScrollView.getVisibility() != View.VISIBLE) { |
| 1089 | // the flip settings panel is unequivocally showing; we should not be shown |
Daniel Sandler | 6e2810b | 2012-10-17 09:40:09 -0400 | [diff] [blame] | 1090 | mClearButton.setVisibility(View.INVISIBLE); |
| 1091 | } else if (mClearButton.isShown()) { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1092 | if (clearable != (mClearButton.getAlpha() == 1.0f)) { |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 1093 | ObjectAnimator clearAnimation = ObjectAnimator.ofFloat( |
| 1094 | mClearButton, "alpha", clearable ? 1.0f : 0.0f).setDuration(250); |
| 1095 | clearAnimation.addListener(new AnimatorListenerAdapter() { |
| 1096 | @Override |
| 1097 | public void onAnimationEnd(Animator animation) { |
| 1098 | if (mClearButton.getAlpha() <= 0.0f) { |
| 1099 | mClearButton.setVisibility(View.INVISIBLE); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | @Override |
| 1104 | public void onAnimationStart(Animator animation) { |
| 1105 | if (mClearButton.getAlpha() <= 0.0f) { |
| 1106 | mClearButton.setVisibility(View.VISIBLE); |
| 1107 | } |
| 1108 | } |
| 1109 | }); |
| 1110 | clearAnimation.start(); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1111 | } |
| 1112 | } else { |
| 1113 | mClearButton.setAlpha(clearable ? 1.0f : 0.0f); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 1114 | mClearButton.setVisibility(clearable ? View.VISIBLE : View.INVISIBLE); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 1115 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1116 | mClearButton.setEnabled(clearable); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 1117 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1118 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
| 1119 | final boolean showDot = (any&&!areLightsOn()); |
| 1120 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 1121 | if (showDot) { |
| 1122 | nlo.setAlpha(0f); |
| 1123 | nlo.setVisibility(View.VISIBLE); |
| 1124 | } |
| 1125 | nlo.animate() |
| 1126 | .alpha(showDot?1:0) |
| 1127 | .setDuration(showDot?750:250) |
| 1128 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 1129 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 1130 | @Override |
| 1131 | public void onAnimationEnd(Animator _a) { |
| 1132 | nlo.setVisibility(View.GONE); |
| 1133 | } |
| 1134 | }) |
| 1135 | .start(); |
| 1136 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1137 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1138 | updateCarrierLabelVisibility(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1139 | } |
| 1140 | |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1141 | public void showClock(boolean show) { |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1142 | if (mStatusBarView == null) return; |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1143 | View clock = mStatusBarView.findViewById(R.id.clock); |
| 1144 | if (clock != null) { |
| 1145 | clock.setVisibility(show ? View.VISIBLE : View.GONE); |
| 1146 | } |
| 1147 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1148 | |
| 1149 | /** |
| 1150 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 1151 | */ |
| 1152 | public void disable(int state) { |
| 1153 | final int old = mDisabled; |
| 1154 | final int diff = state ^ old; |
| 1155 | mDisabled = state; |
| 1156 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 1157 | if (DEBUG) { |
| 1158 | Slog.d(TAG, String.format("disable: 0x%08x -> 0x%08x (diff: 0x%08x)", |
| 1159 | old, state, diff)); |
| 1160 | } |
| 1161 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1162 | StringBuilder flagdbg = new StringBuilder(); |
| 1163 | flagdbg.append("disable: < "); |
| 1164 | flagdbg.append(((state & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 1165 | flagdbg.append(((diff & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 1166 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 1167 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 1168 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 1169 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 1170 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "TICKER" : "ticker"); |
| 1171 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "* " : " "); |
| 1172 | flagdbg.append(((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 1173 | flagdbg.append(((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1174 | flagdbg.append(((state & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 1175 | flagdbg.append(((diff & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1176 | flagdbg.append(((state & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 1177 | flagdbg.append(((diff & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 1178 | flagdbg.append(((state & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 1179 | flagdbg.append(((diff & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1180 | flagdbg.append(((state & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 1181 | flagdbg.append(((diff & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 1182 | flagdbg.append(">"); |
| 1183 | Slog.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1184 | |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 1185 | if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1186 | mSystemIconArea.animate().cancel(); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 1187 | if ((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1188 | mSystemIconArea.animate() |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 1189 | .alpha(0f) |
| 1190 | .translationY(mNaturalBarHeight*0.5f) |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 1191 | .setDuration(175) |
| 1192 | .setInterpolator(new DecelerateInterpolator(1.5f)) |
| 1193 | .setListener(mMakeIconsInvisible) |
| 1194 | .start(); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 1195 | } else { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1196 | mSystemIconArea.setVisibility(View.VISIBLE); |
| 1197 | mSystemIconArea.animate() |
Daniel Sandler | 67e7d90 | 2012-06-06 16:32:21 -0400 | [diff] [blame] | 1198 | .alpha(1f) |
| 1199 | .translationY(0) |
| 1200 | .setStartDelay(0) |
| 1201 | .setInterpolator(new DecelerateInterpolator(1.5f)) |
| 1202 | .setDuration(175) |
| 1203 | .start(); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 1204 | } |
| 1205 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1206 | |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 1207 | if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 1208 | boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; |
| 1209 | showClock(show); |
| 1210 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1211 | if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1212 | if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1213 | animateCollapsePanels(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1214 | } |
| 1215 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 1216 | |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 1217 | if ((diff & (StatusBarManager.DISABLE_HOME |
| 1218 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1219 | | StatusBarManager.DISABLE_BACK)) != 0) { |
| 1220 | // the nav bar will take care of these |
Daniel Sandler | d9283b90 | 2011-09-14 21:42:00 -0400 | [diff] [blame] | 1221 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1222 | |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 1223 | if ((state & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 1224 | // close recents if it's visible |
| 1225 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 1226 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 1227 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 1228 | } |
| 1229 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1230 | if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 1231 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1232 | if (mTicking) { |
Daniel Sandler | f59a90c | 2012-09-28 15:33:14 -0400 | [diff] [blame] | 1233 | haltTicker(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1234 | } |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1235 | |
| 1236 | mNotificationIcons.animate() |
| 1237 | .alpha(0f) |
| 1238 | .translationY(mNaturalBarHeight*0.5f) |
| 1239 | .setDuration(175) |
| 1240 | .setInterpolator(new DecelerateInterpolator(1.5f)) |
| 1241 | .setListener(mMakeIconsInvisible) |
| 1242 | .start(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1243 | } else { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1244 | mNotificationIcons.setVisibility(View.VISIBLE); |
| 1245 | mNotificationIcons.animate() |
| 1246 | .alpha(1f) |
| 1247 | .translationY(0) |
| 1248 | .setStartDelay(0) |
| 1249 | .setInterpolator(new DecelerateInterpolator(1.5f)) |
| 1250 | .setDuration(175) |
| 1251 | .start(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1252 | } |
| 1253 | } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
| 1254 | if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Daniel Sandler | f59a90c | 2012-09-28 15:33:14 -0400 | [diff] [blame] | 1255 | haltTicker(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1256 | } |
| 1257 | } |
| 1258 | } |
| 1259 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1260 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 1261 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1262 | return new PhoneStatusBar.H(); |
| 1263 | } |
| 1264 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1265 | /** |
| 1266 | * All changes to the status bar and notifications funnel through here and are batched. |
| 1267 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1268 | private class H extends BaseStatusBar.H { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1269 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1270 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1271 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1272 | case MSG_OPEN_NOTIFICATION_PANEL: |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1273 | animateExpandNotificationsPanel(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1274 | break; |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1275 | case MSG_OPEN_SETTINGS_PANEL: |
| 1276 | animateExpandSettingsPanel(); |
| 1277 | break; |
| 1278 | case MSG_CLOSE_PANELS: |
| 1279 | animateCollapsePanels(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1280 | break; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1281 | case MSG_SHOW_INTRUDER: |
| 1282 | setIntruderAlertVisibility(true); |
| 1283 | break; |
| 1284 | case MSG_HIDE_INTRUDER: |
| 1285 | setIntruderAlertVisibility(false); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 1286 | mCurrentlyIntrudingNotification = null; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1287 | break; |
| 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1292 | public Handler getHandler() { |
| 1293 | return mHandler; |
| 1294 | } |
| 1295 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1296 | View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { |
| 1297 | public void onFocusChange(View v, boolean hasFocus) { |
| 1298 | // Because 'v' is a ViewGroup, all its children will be (un)selected |
| 1299 | // too, which allows marqueeing to work. |
| 1300 | v.setSelected(hasFocus); |
| 1301 | } |
| 1302 | }; |
| 1303 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1304 | void makeExpandedVisible(boolean revealAfterDraw) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1305 | if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
| 1306 | if (mExpandedVisible) { |
| 1307 | return; |
| 1308 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1309 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1310 | mExpandedVisible = true; |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1311 | mPile.setLayoutTransitionsEnabled(true); |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 1312 | if (mNavigationBarView != null) |
| 1313 | mNavigationBarView.setSlippery(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1314 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1315 | updateCarrierLabelVisibility(true); |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 1316 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1317 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1318 | |
| 1319 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 1320 | // This is only possible to do atomically because the status bar is at the top of the screen! |
| 1321 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams(); |
Daniel Sandler | 4391b0b | 2012-05-10 13:15:26 -0400 | [diff] [blame] | 1322 | lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 1323 | lp.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1324 | lp.height = ViewGroup.LayoutParams.MATCH_PARENT; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1325 | mWindowManager.updateViewLayout(mStatusBarWindow, lp); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1326 | |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 1327 | // Updating the window layout will force an expensive traversal/redraw. |
| 1328 | // Kick off the reveal animation after this is complete to avoid animation latency. |
| 1329 | if (revealAfterDraw) { |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1330 | // mHandler.post(mStartRevealAnimation); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 1331 | } |
| 1332 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1333 | visibilityChanged(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1334 | } |
| 1335 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1336 | public void animateCollapsePanels() { |
| 1337 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1340 | public void animateCollapsePanels(int flags) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1341 | if (SPEW) { |
Daniel Sandler | 198a030 | 2012-08-17 16:04:31 -0400 | [diff] [blame] | 1342 | Slog.d(TAG, "animateCollapse():" |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1343 | + " mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1344 | + " mAnimating=" + mAnimating |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 1345 | + " mAnimatingReveal=" + mAnimatingReveal |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1346 | + " mAnimY=" + mAnimY |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1347 | + " mAnimVel=" + mAnimVel |
| 1348 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1349 | } |
| 1350 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1351 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1352 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 1353 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 1354 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1355 | |
| 1356 | if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) { |
| 1357 | mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL); |
| 1358 | mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL); |
| 1359 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1360 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1361 | mStatusBarView.collapseAllPanels(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1362 | } |
| 1363 | |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1364 | public ViewPropertyAnimator setVisibilityWhenDone( |
| 1365 | final ViewPropertyAnimator a, final View v, final int vis) { |
| 1366 | a.setListener(new AnimatorListenerAdapter() { |
| 1367 | @Override |
| 1368 | public void onAnimationEnd(Animator animation) { |
| 1369 | v.setVisibility(vis); |
| 1370 | a.setListener(null); // oneshot |
| 1371 | } |
| 1372 | }); |
| 1373 | return a; |
| 1374 | } |
| 1375 | |
| 1376 | public Animator setVisibilityWhenDone( |
| 1377 | final Animator a, final View v, final int vis) { |
| 1378 | a.addListener(new AnimatorListenerAdapter() { |
| 1379 | @Override |
| 1380 | public void onAnimationEnd(Animator animation) { |
| 1381 | v.setVisibility(vis); |
| 1382 | } |
| 1383 | }); |
| 1384 | return a; |
| 1385 | } |
| 1386 | |
| 1387 | public Animator interpolator(TimeInterpolator ti, Animator a) { |
| 1388 | a.setInterpolator(ti); |
| 1389 | return a; |
| 1390 | } |
| 1391 | |
| 1392 | public Animator startDelay(int d, Animator a) { |
| 1393 | a.setStartDelay(d); |
| 1394 | return a; |
| 1395 | } |
| 1396 | |
| 1397 | public Animator start(Animator a) { |
| 1398 | a.start(); |
| 1399 | return a; |
| 1400 | } |
| 1401 | |
| 1402 | final TimeInterpolator mAccelerateInterpolator = new AccelerateInterpolator(); |
| 1403 | final TimeInterpolator mDecelerateInterpolator = new DecelerateInterpolator(); |
| 1404 | final int FLIP_DURATION_OUT = 125; |
| 1405 | final int FLIP_DURATION_IN = 225; |
| 1406 | final int FLIP_DURATION = (FLIP_DURATION_IN + FLIP_DURATION_OUT); |
| 1407 | |
| 1408 | Animator mScrollViewAnim, mFlipSettingsViewAnim, mNotificationButtonAnim, |
| 1409 | mSettingsButtonAnim, mClearButtonAnim; |
| 1410 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1411 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1412 | public void animateExpandNotificationsPanel() { |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 1413 | if (SPEW) Slog.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1414 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1415 | return ; |
| 1416 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1417 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1418 | mNotificationPanel.expand(); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1419 | if (mHasFlipSettings && mScrollView.getVisibility() != View.VISIBLE) { |
| 1420 | flipToNotifications(); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1421 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1422 | |
| 1423 | if (false) postStartTracing(); |
| 1424 | } |
| 1425 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1426 | public void flipToNotifications() { |
| 1427 | if (mFlipSettingsViewAnim != null) mFlipSettingsViewAnim.cancel(); |
| 1428 | if (mScrollViewAnim != null) mScrollViewAnim.cancel(); |
| 1429 | if (mSettingsButtonAnim != null) mSettingsButtonAnim.cancel(); |
| 1430 | if (mNotificationButtonAnim != null) mNotificationButtonAnim.cancel(); |
| 1431 | if (mClearButtonAnim != null) mClearButtonAnim.cancel(); |
| 1432 | |
| 1433 | mScrollView.setVisibility(View.VISIBLE); |
| 1434 | mScrollViewAnim = start( |
| 1435 | startDelay(FLIP_DURATION_OUT, |
| 1436 | interpolator(mDecelerateInterpolator, |
| 1437 | ObjectAnimator.ofFloat(mScrollView, View.SCALE_X, 0f, 1f) |
| 1438 | .setDuration(FLIP_DURATION_IN) |
| 1439 | ))); |
| 1440 | mFlipSettingsViewAnim = start( |
| 1441 | setVisibilityWhenDone( |
| 1442 | interpolator(mAccelerateInterpolator, |
| 1443 | ObjectAnimator.ofFloat(mFlipSettingsView, View.SCALE_X, 1f, 0f) |
| 1444 | ) |
| 1445 | .setDuration(FLIP_DURATION_OUT), |
| 1446 | mFlipSettingsView, View.INVISIBLE)); |
| 1447 | mNotificationButtonAnim = start( |
| 1448 | setVisibilityWhenDone( |
| 1449 | ObjectAnimator.ofFloat(mNotificationButton, View.ALPHA, 0f) |
| 1450 | .setDuration(FLIP_DURATION), |
| 1451 | mNotificationButton, View.INVISIBLE)); |
| 1452 | mSettingsButton.setVisibility(View.VISIBLE); |
| 1453 | mSettingsButtonAnim = start( |
| 1454 | ObjectAnimator.ofFloat(mSettingsButton, View.ALPHA, 1f) |
| 1455 | .setDuration(FLIP_DURATION)); |
| 1456 | mClearButton.setVisibility(View.VISIBLE); |
| 1457 | mClearButton.setAlpha(0f); |
| 1458 | setAreThereNotifications(); // this will show/hide the button as necessary |
| 1459 | mNotificationPanel.postDelayed(new Runnable() { |
| 1460 | public void run() { |
| 1461 | updateCarrierLabelVisibility(false); |
| 1462 | } |
| 1463 | }, FLIP_DURATION - 150); |
| 1464 | } |
| 1465 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 1466 | @Override |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1467 | public void animateExpandSettingsPanel() { |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 1468 | if (SPEW) Slog.d(TAG, "animateExpand: mExpandedVisible=" + mExpandedVisible); |
| 1469 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1470 | return; |
| 1471 | } |
| 1472 | |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1473 | if (mHasFlipSettings) { |
| 1474 | mNotificationPanel.expand(); |
| 1475 | if (mFlipSettingsView.getVisibility() != View.VISIBLE) { |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1476 | flipToSettings(); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1477 | } |
| 1478 | } else if (mSettingsPanel != null) { |
| 1479 | mSettingsPanel.expand(); |
| 1480 | } |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 1481 | |
| 1482 | if (false) postStartTracing(); |
| 1483 | } |
| 1484 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1485 | public void switchToSettings() { |
| 1486 | mFlipSettingsView.setScaleX(1f); |
| 1487 | mFlipSettingsView.setVisibility(View.VISIBLE); |
| 1488 | mSettingsButton.setVisibility(View.GONE); |
| 1489 | mScrollView.setVisibility(View.GONE); |
Daniel Sandler | 720a34d | 2012-10-18 11:44:04 -0400 | [diff] [blame^] | 1490 | mScrollView.setScaleX(0f); |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1491 | mNotificationButton.setVisibility(View.VISIBLE); |
| 1492 | mNotificationButton.setAlpha(1f); |
| 1493 | mClearButton.setVisibility(View.GONE); |
| 1494 | } |
| 1495 | |
| 1496 | public void flipToSettings() { |
| 1497 | if (mFlipSettingsViewAnim != null) mFlipSettingsViewAnim.cancel(); |
| 1498 | if (mScrollViewAnim != null) mScrollViewAnim.cancel(); |
| 1499 | if (mSettingsButtonAnim != null) mSettingsButtonAnim.cancel(); |
| 1500 | if (mNotificationButtonAnim != null) mNotificationButtonAnim.cancel(); |
| 1501 | if (mClearButtonAnim != null) mClearButtonAnim.cancel(); |
| 1502 | |
| 1503 | mFlipSettingsView.setVisibility(View.VISIBLE); |
| 1504 | mFlipSettingsView.setScaleX(0f); |
| 1505 | mFlipSettingsViewAnim = start( |
| 1506 | startDelay(FLIP_DURATION_OUT, |
| 1507 | interpolator(mDecelerateInterpolator, |
| 1508 | ObjectAnimator.ofFloat(mFlipSettingsView, View.SCALE_X, 0f, 1f) |
| 1509 | .setDuration(FLIP_DURATION_IN) |
| 1510 | ))); |
| 1511 | mScrollViewAnim = start( |
| 1512 | setVisibilityWhenDone( |
| 1513 | interpolator(mAccelerateInterpolator, |
| 1514 | ObjectAnimator.ofFloat(mScrollView, View.SCALE_X, 1f, 0f) |
| 1515 | ) |
| 1516 | .setDuration(FLIP_DURATION_OUT), |
| 1517 | mScrollView, View.INVISIBLE)); |
| 1518 | mSettingsButtonAnim = start( |
| 1519 | setVisibilityWhenDone( |
| 1520 | ObjectAnimator.ofFloat(mSettingsButton, View.ALPHA, 0f) |
| 1521 | .setDuration(FLIP_DURATION), |
| 1522 | mScrollView, View.INVISIBLE)); |
| 1523 | mNotificationButton.setVisibility(View.VISIBLE); |
| 1524 | mNotificationButtonAnim = start( |
| 1525 | ObjectAnimator.ofFloat(mNotificationButton, View.ALPHA, 1f) |
| 1526 | .setDuration(FLIP_DURATION)); |
| 1527 | mClearButtonAnim = start( |
| 1528 | setVisibilityWhenDone( |
| 1529 | ObjectAnimator.ofFloat(mClearButton, View.ALPHA, 0f) |
| 1530 | .setDuration(FLIP_DURATION), |
| 1531 | mClearButton, View.INVISIBLE)); |
| 1532 | mNotificationPanel.postDelayed(new Runnable() { |
| 1533 | public void run() { |
| 1534 | updateCarrierLabelVisibility(false); |
| 1535 | } |
| 1536 | }, FLIP_DURATION - 150); |
| 1537 | } |
| 1538 | |
| 1539 | public void flipPanels() { |
| 1540 | if (mHasFlipSettings) { |
| 1541 | if (mFlipSettingsView.getVisibility() != View.VISIBLE) { |
| 1542 | flipToSettings(); |
| 1543 | } else { |
| 1544 | flipToNotifications(); |
| 1545 | } |
| 1546 | } |
| 1547 | } |
| 1548 | |
Svetoslav Ganov | e20a177 | 2012-09-25 16:07:46 -0700 | [diff] [blame] | 1549 | public void animateCollapseQuickSettings() { |
| 1550 | mStatusBarView.collapseAllPanels(true); |
| 1551 | } |
| 1552 | |
Daniel Sandler | 6e2810b | 2012-10-17 09:40:09 -0400 | [diff] [blame] | 1553 | void makeExpandedInvisibleSoon() { |
| 1554 | mHandler.postDelayed(new Runnable() { public void run() { makeExpandedInvisible(); }}, 50); |
| 1555 | } |
| 1556 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1557 | void makeExpandedInvisible() { |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 1558 | if (SPEW) Slog.d(TAG, "makeExpandedInvisible: mExpandedVisible=" + mExpandedVisible |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1559 | + " mExpandedVisible=" + mExpandedVisible); |
| 1560 | |
| 1561 | if (!mExpandedVisible) { |
| 1562 | return; |
| 1563 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 1564 | |
Daniel Sandler | c38bbc3 | 2012-10-05 12:21:38 -0400 | [diff] [blame] | 1565 | // Ensure the panel is fully collapsed (just in case; bug 6765842, 7260868) |
| 1566 | mStatusBarView.collapseAllPanels(/*animate=*/ false); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 1567 | |
Daniel Sandler | 040c2e4 | 2012-10-17 00:56:33 -0400 | [diff] [blame] | 1568 | if (mHasFlipSettings) { |
| 1569 | // reset things to their proper state |
| 1570 | mScrollView.setScaleX(1f); |
| 1571 | mScrollView.setVisibility(View.VISIBLE); |
| 1572 | mSettingsButton.setAlpha(1f); |
| 1573 | mSettingsButton.setVisibility(View.VISIBLE); |
| 1574 | mNotificationPanel.setVisibility(View.GONE); |
| 1575 | mFlipSettingsView.setVisibility(View.GONE); |
| 1576 | mNotificationButton.setVisibility(View.GONE); |
| 1577 | setAreThereNotifications(); // show the clear button |
| 1578 | } |
| 1579 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1580 | mExpandedVisible = false; |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 1581 | mPile.setLayoutTransitionsEnabled(false); |
John Spurlock | d5ef546 | 2012-06-13 11:19:51 -0400 | [diff] [blame] | 1582 | if (mNavigationBarView != null) |
| 1583 | mNavigationBarView.setSlippery(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1584 | visibilityChanged(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1585 | |
| 1586 | // Shrink the window to the size of the status bar only |
| 1587 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams(); |
| 1588 | lp.height = getStatusBarHeight(); |
Daniel Sandler | 4391b0b | 2012-05-10 13:15:26 -0400 | [diff] [blame] | 1589 | lp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 1590 | lp.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1591 | mWindowManager.updateViewLayout(mStatusBarWindow, lp); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1592 | |
| 1593 | if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { |
| 1594 | setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); |
| 1595 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1596 | |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 1597 | // Close any "App info" popups that might have snuck on-screen |
| 1598 | dismissPopups(); |
| 1599 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1600 | if (mPostCollapseCleanup != null) { |
| 1601 | mPostCollapseCleanup.run(); |
| 1602 | mPostCollapseCleanup = null; |
| 1603 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1604 | } |
| 1605 | |
Romain Guy | 54ab347 | 2012-06-14 12:52:53 -0700 | [diff] [blame] | 1606 | /** |
| 1607 | * Enables or disables layers on the children of the notifications pile. |
| 1608 | * |
| 1609 | * When layers are enabled, this method attempts to enable layers for the minimal |
| 1610 | * number of children. Only children visible when the notification area is fully |
| 1611 | * expanded will receive a layer. The technique used in this method might cause |
| 1612 | * more children than necessary to get a layer (at most one extra child with the |
| 1613 | * current UI.) |
| 1614 | * |
| 1615 | * @param layerType {@link View#LAYER_TYPE_NONE} or {@link View#LAYER_TYPE_HARDWARE} |
| 1616 | */ |
| 1617 | private void setPileLayers(int layerType) { |
| 1618 | final int count = mPile.getChildCount(); |
| 1619 | |
| 1620 | switch (layerType) { |
| 1621 | case View.LAYER_TYPE_NONE: |
| 1622 | for (int i = 0; i < count; i++) { |
| 1623 | mPile.getChildAt(i).setLayerType(layerType, null); |
| 1624 | } |
| 1625 | break; |
| 1626 | case View.LAYER_TYPE_HARDWARE: |
| 1627 | final int[] location = new int[2]; |
| 1628 | mNotificationPanel.getLocationInWindow(location); |
| 1629 | |
| 1630 | final int left = location[0]; |
| 1631 | final int top = location[1]; |
| 1632 | final int right = left + mNotificationPanel.getWidth(); |
| 1633 | final int bottom = top + getExpandedViewMaxHeight(); |
| 1634 | |
| 1635 | final Rect childBounds = new Rect(); |
| 1636 | |
| 1637 | for (int i = 0; i < count; i++) { |
| 1638 | final View view = mPile.getChildAt(i); |
| 1639 | view.getLocationInWindow(location); |
| 1640 | |
| 1641 | childBounds.set(location[0], location[1], |
| 1642 | location[0] + view.getWidth(), location[1] + view.getHeight()); |
| 1643 | |
| 1644 | if (childBounds.intersects(left, top, right, bottom)) { |
| 1645 | view.setLayerType(layerType, null); |
| 1646 | } |
| 1647 | } |
| 1648 | |
| 1649 | break; |
| 1650 | } |
| 1651 | } |
| 1652 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 1653 | public boolean isClinging() { |
| 1654 | return mCling != null && mCling.getVisibility() == View.VISIBLE; |
| 1655 | } |
| 1656 | |
| 1657 | public void hideCling() { |
| 1658 | if (isClinging()) { |
| 1659 | mCling.animate().alpha(0f).setDuration(250).start(); |
| 1660 | mCling.setVisibility(View.GONE); |
| 1661 | mSuppressStatusBarDrags = false; |
| 1662 | } |
| 1663 | } |
| 1664 | |
| 1665 | public void showCling() { |
Daniel Sandler | 118f484 | 2012-10-07 20:38:39 -0400 | [diff] [blame] | 1666 | // lazily inflate this to accommodate orientation change |
| 1667 | final ViewStub stub = (ViewStub) mStatusBarWindow.findViewById(R.id.status_bar_cling_stub); |
| 1668 | if (stub == null) { |
| 1669 | mClingShown = true; |
| 1670 | return; // no clings on this device |
| 1671 | } |
| 1672 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 1673 | mSuppressStatusBarDrags = true; |
| 1674 | |
| 1675 | mHandler.postDelayed(new Runnable() { |
| 1676 | @Override |
| 1677 | public void run() { |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 1678 | mCling = (ViewGroup) stub.inflate(); |
Daniel Sandler | 118f484 | 2012-10-07 20:38:39 -0400 | [diff] [blame] | 1679 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 1680 | mCling.setOnTouchListener(new View.OnTouchListener() { |
| 1681 | @Override |
| 1682 | public boolean onTouch(View v, MotionEvent event) { |
| 1683 | return true; // e eats everything |
| 1684 | }}); |
| 1685 | mCling.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() { |
| 1686 | @Override |
| 1687 | public void onClick(View v) { |
| 1688 | hideCling(); |
| 1689 | }}); |
| 1690 | |
| 1691 | mCling.setAlpha(0f); |
| 1692 | mCling.setVisibility(View.VISIBLE); |
| 1693 | mCling.animate().alpha(1f); |
| 1694 | |
| 1695 | mClingShown = true; |
| 1696 | SharedPreferences.Editor editor = Prefs.edit(mContext); |
| 1697 | editor.putBoolean(Prefs.SHOWN_QUICK_SETTINGS_HELP, true); |
| 1698 | editor.apply(); |
| 1699 | |
| 1700 | makeExpandedVisible(true); // enforce visibility in case the shade is still animating closed |
| 1701 | animateExpandNotificationsPanel(); |
| 1702 | |
| 1703 | mSuppressStatusBarDrags = false; |
| 1704 | } |
| 1705 | }, 500); |
| 1706 | |
| 1707 | animateExpandNotificationsPanel(); |
| 1708 | } |
| 1709 | |
| 1710 | public boolean interceptTouchEvent(MotionEvent event) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1711 | if (SPEW) { |
| 1712 | Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 1713 | + mDisabled + " mTracking=" + mTracking); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1714 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1715 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1716 | Slog.d(TAG, String.format( |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1717 | "panel: %s at (%f, %f) mDisabled=0x%08x", |
| 1718 | MotionEvent.actionToString(event.getAction()), |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1719 | event.getRawX(), event.getRawY(), mDisabled)); |
| 1720 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1721 | } |
| 1722 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 1723 | if (DEBUG_GESTURES) { |
| 1724 | mGestureRec.add(event); |
| 1725 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 1726 | |
Daniel Sandler | b17a726 | 2012-10-05 14:32:50 -0400 | [diff] [blame] | 1727 | // Cling (first-run help) handling. |
| 1728 | // The cling is supposed to show the first time you drag, or even tap, the status bar. |
| 1729 | // It should show the notification panel, then fade in after half a second, giving you |
| 1730 | // an explanation of what just happened, as well as teach you how to access quick |
| 1731 | // settings (another drag). The user can dismiss the cling by clicking OK or by |
| 1732 | // dragging quick settings into view. |
| 1733 | final int act = event.getActionMasked(); |
| 1734 | if (mSuppressStatusBarDrags) { |
| 1735 | return true; |
| 1736 | } else if (act == MotionEvent.ACTION_UP && !mClingShown) { |
| 1737 | showCling(); |
| 1738 | } else { |
| 1739 | hideCling(); |
| 1740 | } |
| 1741 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1742 | return false; |
| 1743 | } |
| 1744 | |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 1745 | public GestureRecorder getGestureRecorder() { |
| 1746 | return mGestureRec; |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 1747 | } |
| 1748 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1749 | @Override // CommandQueue |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1750 | public void setNavigationIconHints(int hints) { |
| 1751 | if (hints == mNavigationIconHints) return; |
| 1752 | |
| 1753 | mNavigationIconHints = hints; |
| 1754 | |
| 1755 | if (mNavigationBarView != null) { |
| 1756 | mNavigationBarView.setNavigationIconHints(hints); |
| 1757 | } |
| 1758 | } |
| 1759 | |
| 1760 | @Override // CommandQueue |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1761 | public void setSystemUiVisibility(int vis, int mask) { |
| 1762 | final int oldVal = mSystemUiVisibility; |
| 1763 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 1764 | final int diff = newVal ^ oldVal; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1765 | |
| 1766 | if (diff != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1767 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1768 | |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1769 | if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { |
| 1770 | final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); |
| 1771 | if (lightsOut) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 1772 | animateCollapsePanels(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1773 | if (mTicking) { |
Daniel Sandler | f59a90c | 2012-09-28 15:33:14 -0400 | [diff] [blame] | 1774 | haltTicker(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1775 | } |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1776 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1777 | |
Daniel Sandler | 69314e7 | 2011-08-20 00:31:08 -0400 | [diff] [blame] | 1778 | if (mNavigationBarView != null) { |
| 1779 | mNavigationBarView.setLowProfile(lightsOut); |
| 1780 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1781 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1782 | setStatusBarLowProfile(lightsOut); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1783 | } |
| 1784 | |
| 1785 | notifyUiVisibilityChanged(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1786 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1787 | } |
| 1788 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1789 | private void setStatusBarLowProfile(boolean lightsOut) { |
| 1790 | if (mLightsOutAnimation == null) { |
Daniel Sandler | 825b330 | 2012-10-01 15:22:36 -0400 | [diff] [blame] | 1791 | final View notifications = mStatusBarView.findViewById(R.id.notification_icon_area); |
| 1792 | final View systemIcons = mStatusBarView.findViewById(R.id.statusIcons); |
| 1793 | final View signal = mStatusBarView.findViewById(R.id.signal_cluster); |
| 1794 | final View battery = mStatusBarView.findViewById(R.id.battery); |
| 1795 | final View clock = mStatusBarView.findViewById(R.id.clock); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1796 | |
Daniel Sandler | 825b330 | 2012-10-01 15:22:36 -0400 | [diff] [blame] | 1797 | final AnimatorSet lightsOutAnim = new AnimatorSet(); |
| 1798 | lightsOutAnim.playTogether( |
| 1799 | ObjectAnimator.ofFloat(notifications, View.ALPHA, 0), |
| 1800 | ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 0), |
| 1801 | ObjectAnimator.ofFloat(signal, View.ALPHA, 0), |
| 1802 | ObjectAnimator.ofFloat(battery, View.ALPHA, 0.5f), |
| 1803 | ObjectAnimator.ofFloat(clock, View.ALPHA, 0.5f) |
| 1804 | ); |
| 1805 | lightsOutAnim.setDuration(750); |
| 1806 | |
| 1807 | final AnimatorSet lightsOnAnim = new AnimatorSet(); |
| 1808 | lightsOnAnim.playTogether( |
| 1809 | ObjectAnimator.ofFloat(notifications, View.ALPHA, 1), |
| 1810 | ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 1), |
| 1811 | ObjectAnimator.ofFloat(signal, View.ALPHA, 1), |
| 1812 | ObjectAnimator.ofFloat(battery, View.ALPHA, 1), |
| 1813 | ObjectAnimator.ofFloat(clock, View.ALPHA, 1) |
| 1814 | ); |
| 1815 | lightsOnAnim.setDuration(250); |
| 1816 | |
| 1817 | mLightsOutAnimation = lightsOutAnim; |
| 1818 | mLightsOnAnimation = lightsOnAnim; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1819 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1820 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1821 | mLightsOutAnimation.cancel(); |
| 1822 | mLightsOnAnimation.cancel(); |
| 1823 | |
| 1824 | final Animator a = lightsOut ? mLightsOutAnimation : mLightsOnAnimation; |
| 1825 | a.start(); |
| 1826 | |
| 1827 | setAreThereNotifications(); |
| 1828 | } |
| 1829 | |
| 1830 | private boolean areLightsOn() { |
| 1831 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 1832 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1833 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1834 | public void setLightsOn(boolean on) { |
| 1835 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 1836 | if (on) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1837 | setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1838 | } else { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1839 | 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] | 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | private void notifyUiVisibilityChanged() { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1844 | try { |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 1845 | mWindowManagerService.statusBarVisibilityChanged(mSystemUiVisibility); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1846 | } catch (RemoteException ex) { |
| 1847 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1848 | } |
| 1849 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1850 | public void topAppWindowChanged(boolean showMenu) { |
| 1851 | if (DEBUG) { |
| 1852 | Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
| 1853 | } |
| 1854 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 1855 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1856 | } |
| 1857 | |
| 1858 | // See above re: lights-out policy for legacy apps. |
| 1859 | if (showMenu) setLightsOn(true); |
| 1860 | } |
| 1861 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1862 | @Override |
| 1863 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { |
| 1864 | boolean altBack = (backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) |
| 1865 | || ((vis & InputMethodService.IME_VISIBLE) != 0); |
| 1866 | |
| 1867 | mCommandQueue.setNavigationIconHints( |
| 1868 | altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) |
| 1869 | : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 1870 | if (mQS != null) mQS.setImeWindowStatus(vis > 0); |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1871 | } |
| 1872 | |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 1873 | @Override |
Winson Chung | 43229d7 | 2012-09-12 18:04:18 -0700 | [diff] [blame] | 1874 | public void setHardKeyboardStatus(boolean available, boolean enabled) {} |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 1875 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1876 | @Override |
| 1877 | protected void tick(IBinder key, StatusBarNotification n, boolean firstTime) { |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1878 | // no ticking in lights-out mode |
| 1879 | if (!areLightsOn()) return; |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1880 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1881 | // no ticking in Setup |
| 1882 | if (!isDeviceProvisioned()) return; |
| 1883 | |
John Spurlock | 61e3683 | 2012-09-10 09:43:27 -0400 | [diff] [blame] | 1884 | // not for you |
| 1885 | if (!notificationIsForCurrentUser(n)) return; |
| 1886 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1887 | // Show the ticker if one is requested. Also don't do this |
| 1888 | // until status bar window is attached to the window manager, |
| 1889 | // because... well, what's the point otherwise? And trying to |
| 1890 | // run a ticker without being attached will crash! |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1891 | if (n.notification.tickerText != null && mStatusBarWindow.getWindowToken() != null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1892 | if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS |
| 1893 | | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { |
| 1894 | mTicker.addEntry(n); |
| 1895 | } |
| 1896 | } |
| 1897 | } |
| 1898 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1899 | private class MyTicker extends Ticker { |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1900 | MyTicker(Context context, View sb) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1901 | super(context, sb); |
| 1902 | } |
| 1903 | |
| 1904 | @Override |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1905 | public void tickerStarting() { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1906 | mTicking = true; |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1907 | mStatusBarContents.setVisibility(View.GONE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1908 | mTickerView.setVisibility(View.VISIBLE); |
| 1909 | mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1910 | mStatusBarContents.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1911 | } |
| 1912 | |
| 1913 | @Override |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1914 | public void tickerDone() { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1915 | mStatusBarContents.setVisibility(View.VISIBLE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1916 | mTickerView.setVisibility(View.GONE); |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1917 | mStatusBarContents.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1918 | mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, |
| 1919 | mTickingDoneListener)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1920 | } |
| 1921 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1922 | public void tickerHalting() { |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1923 | mStatusBarContents.setVisibility(View.VISIBLE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1924 | mTickerView.setVisibility(View.GONE); |
Daniel Sandler | 173bae2 | 2012-09-25 14:37:42 -0400 | [diff] [blame] | 1925 | mStatusBarContents.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); |
Daniel Sandler | f59a90c | 2012-09-28 15:33:14 -0400 | [diff] [blame] | 1926 | // we do not animate the ticker away at this point, just get rid of it (b/6992707) |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1927 | } |
| 1928 | } |
| 1929 | |
| 1930 | Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; |
| 1931 | public void onAnimationEnd(Animation animation) { |
| 1932 | mTicking = false; |
| 1933 | } |
| 1934 | public void onAnimationRepeat(Animation animation) { |
| 1935 | } |
| 1936 | public void onAnimationStart(Animation animation) { |
| 1937 | } |
| 1938 | }; |
| 1939 | |
| 1940 | private Animation loadAnim(int id, Animation.AnimationListener listener) { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1941 | Animation anim = AnimationUtils.loadAnimation(mContext, id); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1942 | if (listener != null) { |
| 1943 | anim.setAnimationListener(listener); |
| 1944 | } |
| 1945 | return anim; |
| 1946 | } |
| 1947 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1948 | public static String viewInfo(View v) { |
| 1949 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 1950 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1951 | } |
| 1952 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1953 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1954 | synchronized (mQueueLock) { |
| 1955 | pw.println("Current Status Bar state:"); |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 1956 | pw.println(" mExpandedVisible=" + mExpandedVisible |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 1957 | + ", mTrackingPosition=" + mTrackingPosition); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1958 | pw.println(" mTicking=" + mTicking); |
| 1959 | pw.println(" mTracking=" + mTracking); |
Daniel Sandler | fdbac77 | 2012-07-03 14:30:10 -0400 | [diff] [blame] | 1960 | pw.println(" mNotificationPanel=" + |
| 1961 | ((mNotificationPanel == null) |
| 1962 | ? "null" |
| 1963 | : (mNotificationPanel + " params=" + mNotificationPanel.getLayoutParams().debug("")))); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1964 | pw.println(" mAnimating=" + mAnimating |
| 1965 | + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel |
| 1966 | + ", mAnimAccel=" + mAnimAccel); |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1967 | pw.println(" mAnimLastTimeNanos=" + mAnimLastTimeNanos); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1968 | pw.println(" mAnimatingReveal=" + mAnimatingReveal |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1969 | + " mViewDelta=" + mViewDelta); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1970 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1971 | pw.println(" mPile: " + viewInfo(mPile)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1972 | pw.println(" mTickerView: " + viewInfo(mTickerView)); |
| 1973 | pw.println(" mScrollView: " + viewInfo(mScrollView) |
| 1974 | + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1975 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1976 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1977 | pw.print(" mNavigationBarView="); |
| 1978 | if (mNavigationBarView == null) { |
| 1979 | pw.println("null"); |
| 1980 | } else { |
| 1981 | mNavigationBarView.dump(fd, pw, args); |
| 1982 | } |
| 1983 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 1984 | if (DUMPTRUCK) { |
| 1985 | synchronized (mNotificationData) { |
| 1986 | int N = mNotificationData.size(); |
| 1987 | pw.println(" notification icons: " + N); |
| 1988 | for (int i=0; i<N; i++) { |
| 1989 | NotificationData.Entry e = mNotificationData.get(i); |
| 1990 | pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); |
| 1991 | StatusBarNotification n = e.notification; |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 1992 | pw.println(" pkg=" + n.pkg + " id=" + n.id + " score=" + n.score); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 1993 | pw.println(" notification=" + n.notification); |
| 1994 | pw.println(" tickerText=\"" + n.notification.tickerText + "\""); |
| 1995 | } |
| 1996 | } |
| 1997 | |
| 1998 | int N = mStatusIcons.getChildCount(); |
| 1999 | pw.println(" system icons: " + N); |
| 2000 | for (int i=0; i<N; i++) { |
| 2001 | StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i); |
| 2002 | pw.println(" [" + i + "] icon=" + ic); |
| 2003 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2004 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2005 | if (false) { |
| 2006 | pw.println("see the logcat for a dump of the views we have created."); |
| 2007 | // must happen on ui thread |
| 2008 | mHandler.post(new Runnable() { |
| 2009 | public void run() { |
| 2010 | mStatusBarView.getLocationOnScreen(mAbsPos); |
| 2011 | Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
| 2012 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2013 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2014 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2015 | } |
| 2016 | }); |
| 2017 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2018 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2019 | |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2020 | if (DEBUG_GESTURES) { |
| 2021 | pw.print(" status bar gestures: "); |
| 2022 | mGestureRec.dump(fd, pw, args); |
| 2023 | } |
Daniel Sandler | 3380534 | 2012-07-23 15:45:12 -0400 | [diff] [blame] | 2024 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 2025 | mNetworkController.dump(fd, pw, args); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2026 | } |
| 2027 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2028 | @Override |
| 2029 | public void createAndAddWindows() { |
| 2030 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2031 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2032 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2033 | private void addStatusBarWindow() { |
| 2034 | // Put up the view |
| 2035 | final int height = getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2036 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2037 | // Now that the status bar window encompasses the sliding panel and its |
| 2038 | // translucent backdrop, the entire thing is made TRANSLUCENT and is |
| 2039 | // hardware-accelerated. |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2040 | final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 2041 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 2042 | height, |
| 2043 | WindowManager.LayoutParams.TYPE_STATUS_BAR, |
| 2044 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 2045 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 2046 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2047 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2048 | |
Romain Guy | 0901fda | 2012-05-22 21:10:57 -0700 | [diff] [blame] | 2049 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2050 | |
| 2051 | lp.gravity = getStatusBarGravity(); |
| 2052 | lp.setTitle("StatusBar"); |
| 2053 | lp.packageName = mContext.getPackageName(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2054 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 2055 | makeStatusBarView(); |
Jeff Brown | 98365d7 | 2012-08-19 20:30:52 -0700 | [diff] [blame] | 2056 | mWindowManager.addView(mStatusBarWindow, lp); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2057 | } |
| 2058 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2059 | void setNotificationIconVisibility(boolean visible, int anim) { |
| 2060 | int old = mNotificationIcons.getVisibility(); |
| 2061 | int v = visible ? View.VISIBLE : View.INVISIBLE; |
| 2062 | if (old != v) { |
| 2063 | mNotificationIcons.setVisibility(v); |
| 2064 | mNotificationIcons.startAnimation(loadAnim(anim, null)); |
| 2065 | } |
| 2066 | } |
| 2067 | |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2068 | void updateExpandedInvisiblePosition() { |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 2069 | mTrackingPosition = -mDisplayMetrics.heightPixels; |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2070 | } |
| 2071 | |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 2072 | static final float saturate(float a) { |
| 2073 | return a < 0f ? 0f : (a > 1f ? 1f : a); |
| 2074 | } |
| 2075 | |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 2076 | @Override |
| 2077 | protected int getExpandedViewMaxHeight() { |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2078 | return mDisplayMetrics.heightPixels - mNotificationPanelMarginBottomPx; |
| 2079 | } |
| 2080 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2081 | @Override |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2082 | public void updateExpandedViewPos(int thingy) { |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2083 | if (DEBUG) Slog.v(TAG, "updateExpandedViewPos"); |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 2084 | |
| 2085 | // on larger devices, the notification panel is propped open a bit |
| 2086 | mNotificationPanel.setMinimumHeight( |
| 2087 | (int)(mNotificationPanelMinHeightFrac * mCurrentDisplaySize.y)); |
| 2088 | |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2089 | FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mNotificationPanel.getLayoutParams(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2090 | lp.gravity = mNotificationPanelGravity; |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 2091 | lp.leftMargin = mNotificationPanelMarginPx; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2092 | mNotificationPanel.setLayoutParams(lp); |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 2093 | |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 2094 | if (mSettingsPanel != null) { |
| 2095 | lp = (FrameLayout.LayoutParams) mSettingsPanel.getLayoutParams(); |
| 2096 | lp.gravity = mSettingsPanelGravity; |
| 2097 | lp.rightMargin = mNotificationPanelMarginPx; |
| 2098 | mSettingsPanel.setLayoutParams(lp); |
| 2099 | } |
Daniel Sandler | bf526d1 | 2012-09-04 22:56:44 -0400 | [diff] [blame] | 2100 | |
| 2101 | updateCarrierLabelVisibility(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2102 | } |
| 2103 | |
Daniel Sandler | 747a9e9 | 2012-08-10 16:39:19 -0400 | [diff] [blame] | 2104 | // called by makeStatusbar and also by PhoneStatusBarView |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2105 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 2106 | mDisplay.getMetrics(mDisplayMetrics); |
Daniel Sandler | 151f00d | 2012-10-02 22:33:08 -0400 | [diff] [blame] | 2107 | if (DEBUG_GESTURES) { |
| 2108 | mGestureRec.tag("display", |
| 2109 | String.format("%dx%d", mDisplayMetrics.widthPixels, mDisplayMetrics.heightPixels)); |
| 2110 | } |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 2111 | } |
| 2112 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2113 | private View.OnClickListener mClearButtonListener = new View.OnClickListener() { |
| 2114 | public void onClick(View v) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2115 | synchronized (mNotificationData) { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2116 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 2117 | int numChildren = mPile.getChildCount(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2118 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2119 | int scrollTop = mScrollView.getScrollY(); |
| 2120 | int scrollBottom = scrollTop + mScrollView.getHeight(); |
| 2121 | final ArrayList<View> snapshot = new ArrayList<View>(numChildren); |
| 2122 | for (int i=0; i<numChildren; i++) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2123 | final View child = mPile.getChildAt(i); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2124 | if (mPile.canChildBeDismissed(child) && child.getBottom() > scrollTop && |
| 2125 | child.getTop() < scrollBottom) { |
| 2126 | snapshot.add(child); |
| 2127 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2128 | } |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2129 | if (snapshot.isEmpty()) { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2130 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2131 | return; |
| 2132 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2133 | new Thread(new Runnable() { |
| 2134 | @Override |
| 2135 | public void run() { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2136 | // Decrease the delay for every row we animate to give the sense of |
| 2137 | // accelerating the swipes |
| 2138 | final int ROW_DELAY_DECREMENT = 10; |
| 2139 | int currentDelay = 140; |
| 2140 | int totalDelay = 0; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2141 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2142 | // Set the shade-animating state to avoid doing other work during |
| 2143 | // all of these animations. In particular, avoid layout and |
| 2144 | // redrawing when collapsing the shade. |
| 2145 | mPile.setViewRemoval(false); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2146 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2147 | mPostCollapseCleanup = new Runnable() { |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2148 | @Override |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2149 | public void run() { |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 2150 | if (DEBUG) { |
| 2151 | Slog.v(TAG, "running post-collapse cleanup"); |
| 2152 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2153 | try { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2154 | mPile.setViewRemoval(true); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2155 | mBarService.onClearAllNotifications(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2156 | } catch (Exception ex) { } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2157 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2158 | }; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2159 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2160 | View sampleView = snapshot.get(0); |
| 2161 | int width = sampleView.getWidth(); |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2162 | final int velocity = width * 8; // 1000/8 = 125 ms duration |
| 2163 | for (final View _v : snapshot) { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2164 | mHandler.postDelayed(new Runnable() { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2165 | @Override |
| 2166 | public void run() { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2167 | mPile.dismissRowAnimated(_v, velocity); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2168 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2169 | }, totalDelay); |
| 2170 | currentDelay = Math.max(50, currentDelay - ROW_DELAY_DECREMENT); |
| 2171 | totalDelay += currentDelay; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2172 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2173 | // Delay the collapse animation until after all swipe animations have |
| 2174 | // finished. Provide some buffer because there may be some extra delay |
| 2175 | // before actually starting each swipe animation. Ideally, we'd |
| 2176 | // synchronize the end of those animations with the start of the collaps |
| 2177 | // exactly. |
| 2178 | mHandler.postDelayed(new Runnable() { |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2179 | @Override |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2180 | public void run() { |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2181 | animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2182 | } |
| 2183 | }, totalDelay + 225); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2184 | } |
| 2185 | }).start(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2186 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2187 | } |
| 2188 | }; |
| 2189 | |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 2190 | public void startActivityDismissingKeyguard(Intent intent, boolean onlyProvisioned) { |
| 2191 | if (onlyProvisioned && !isDeviceProvisioned()) return; |
| 2192 | try { |
| 2193 | // Dismiss the lock screen when Settings starts. |
| 2194 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 2195 | } catch (RemoteException e) { |
| 2196 | } |
| 2197 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 2198 | mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT)); |
| 2199 | animateCollapsePanels(); |
| 2200 | } |
| 2201 | |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 2202 | private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { |
| 2203 | public void onClick(View v) { |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 2204 | if (mHasSettingsPanel) { |
| 2205 | animateExpandSettingsPanel(); |
| 2206 | } else { |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 2207 | startActivityDismissingKeyguard( |
| 2208 | new Intent(android.provider.Settings.ACTION_SETTINGS), true); |
Daniel Sandler | e111ad3 | 2012-10-13 15:17:45 -0400 | [diff] [blame] | 2209 | } |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 2210 | } |
| 2211 | }; |
| 2212 | |
Daniel Sandler | 3679bf5 | 2012-10-16 21:30:28 -0400 | [diff] [blame] | 2213 | private View.OnClickListener mClockClickListener = new View.OnClickListener() { |
| 2214 | public void onClick(View v) { |
| 2215 | startActivityDismissingKeyguard( |
| 2216 | new Intent(Intent.ACTION_QUICK_CLOCK), true); // have fun, everyone |
| 2217 | } |
| 2218 | }; |
| 2219 | |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 2220 | private View.OnClickListener mNotificationButtonListener = new View.OnClickListener() { |
| 2221 | public void onClick(View v) { |
| 2222 | animateExpandNotificationsPanel(); |
| 2223 | } |
| 2224 | }; |
| 2225 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2226 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 2227 | public void onReceive(Context context, Intent intent) { |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 2228 | Slog.v(TAG, "onReceive: " + intent); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2229 | String action = intent.getAction(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2230 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2231 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2232 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Daniel Sandler | edbdd3a | 2011-06-21 12:57:08 -0400 | [diff] [blame] | 2233 | String reason = intent.getStringExtra("reason"); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2234 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 2235 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2236 | } |
| 2237 | } |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2238 | animateCollapsePanels(flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2239 | } |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2240 | else if (Intent.ACTION_SCREEN_OFF.equals(action)) { |
| 2241 | // no waiting! |
Daniel Sandler | 08d05e3 | 2012-08-08 16:39:54 -0400 | [diff] [blame] | 2242 | makeExpandedInvisible(); |
Daniel Sandler | ed930e5 | 2012-07-03 14:31:22 -0400 | [diff] [blame] | 2243 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2244 | else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 2245 | if (DEBUG) { |
| 2246 | Slog.v(TAG, "configuration changed: " + mContext.getResources().getConfiguration()); |
| 2247 | } |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 2248 | mDisplay.getSize(mCurrentDisplaySize); |
| 2249 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2250 | updateResources(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2251 | repositionNavigationBar(); |
| 2252 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Daniel Sandler | 7f3cf95 | 2012-08-31 14:57:09 -0400 | [diff] [blame] | 2253 | updateShowSearchHoldoff(); |
| 2254 | } |
| 2255 | else if (Intent.ACTION_SCREEN_ON.equals(action)) { |
| 2256 | // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018) |
| 2257 | repositionNavigationBar(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2258 | } |
| 2259 | } |
| 2260 | }; |
| 2261 | |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 2262 | @Override |
| 2263 | public void userSwitched(int newUserId) { |
| 2264 | if (MULTIUSER_DEBUG) mNotificationPanelDebugText.setText("USER " + newUserId); |
Daniel Sandler | 11cf178 | 2012-09-27 14:03:08 -0400 | [diff] [blame] | 2265 | animateCollapsePanels(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 2266 | updateNotificationIcons(); |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 2267 | resetUserSetupObserver(); |
Daniel Sandler | b9301c3 | 2012-08-14 15:08:24 -0400 | [diff] [blame] | 2268 | } |
John Spurlock | 919adac | 2012-10-02 16:41:12 -0400 | [diff] [blame] | 2269 | |
| 2270 | private void resetUserSetupObserver() { |
| 2271 | mContext.getContentResolver().unregisterContentObserver(mUserSetupObserver); |
| 2272 | mUserSetupObserver.onChange(false); |
| 2273 | mContext.getContentResolver().registerContentObserver( |
| 2274 | Settings.Secure.getUriFor(Settings.Secure.USER_SETUP_COMPLETE), true, |
| 2275 | mUserSetupObserver, |
| 2276 | mCurrentUserId); |
| 2277 | } |
| 2278 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2279 | private void setIntruderAlertVisibility(boolean vis) { |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 2280 | if (!ENABLE_INTRUDERS) return; |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2281 | if (DEBUG) { |
| 2282 | Slog.v(TAG, (vis ? "showing" : "hiding") + " intruder alert window"); |
| 2283 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2284 | mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); |
| 2285 | } |
| 2286 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2287 | public void dismissIntruder() { |
| 2288 | if (mCurrentlyIntrudingNotification == null) return; |
| 2289 | |
| 2290 | try { |
| 2291 | mBarService.onNotificationClear( |
| 2292 | mCurrentlyIntrudingNotification.pkg, |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2293 | mCurrentlyIntrudingNotification.tag, |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2294 | mCurrentlyIntrudingNotification.id); |
| 2295 | } catch (android.os.RemoteException ex) { |
| 2296 | // oh well |
| 2297 | } |
| 2298 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2299 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2300 | /** |
| 2301 | * Reload some of our resources when the configuration changes. |
| 2302 | * |
| 2303 | * We don't reload everything when the configuration changes -- we probably |
| 2304 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 2305 | * meantime, just update the things that we know change. |
| 2306 | */ |
| 2307 | void updateResources() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2308 | final Context context = mContext; |
| 2309 | final Resources res = context.getResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2310 | |
Daniel Sandler | 1347c30 | 2011-08-01 16:47:53 -0400 | [diff] [blame] | 2311 | if (mClearButton instanceof TextView) { |
| 2312 | ((TextView)mClearButton).setText(context.getText(R.string.status_bar_clear_all_button)); |
| 2313 | } |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 2314 | |
| 2315 | // Update the QuickSettings container |
Daniel Sandler | 101784e | 2012-10-15 13:39:38 -0400 | [diff] [blame] | 2316 | if (mQS != null) mQS.updateResources(); |
Winson Chung | d63c5978 | 2012-09-05 17:34:41 -0700 | [diff] [blame] | 2317 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 2318 | loadDimens(); |
| 2319 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2320 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 2321 | protected void loadDimens() { |
| 2322 | final Resources res = mContext.getResources(); |
| 2323 | |
| 2324 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 2325 | com.android.internal.R.dimen.status_bar_height); |
| 2326 | |
| 2327 | int newIconSize = res.getDimensionPixelSize( |
| 2328 | com.android.internal.R.dimen.status_bar_icon_size); |
| 2329 | int newIconHPadding = res.getDimensionPixelSize( |
| 2330 | R.dimen.status_bar_icon_padding); |
| 2331 | |
| 2332 | if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { |
| 2333 | // Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); |
| 2334 | mIconHPadding = newIconHPadding; |
| 2335 | mIconSize = newIconSize; |
| 2336 | //reloadAllNotificationIcons(); // reload the tray |
| 2337 | } |
| 2338 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2339 | mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); |
| 2340 | |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 2341 | mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity); |
| 2342 | mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity); |
| 2343 | mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity); |
| 2344 | mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity); |
| 2345 | |
| 2346 | mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1); |
| 2347 | mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1); |
| 2348 | |
| 2349 | mExpandAccelPx = res.getDimension(R.dimen.expand_accel); |
| 2350 | mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel); |
| 2351 | |
| 2352 | mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2353 | |
Daniel Sandler | e5011a3 | 2012-06-11 16:07:52 -0400 | [diff] [blame] | 2354 | mFlingGestureMaxOutputVelocityPx = res.getDimension(R.dimen.fling_gesture_max_output_velocity); |
| 2355 | |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2356 | mNotificationPanelMarginBottomPx |
| 2357 | = (int) res.getDimension(R.dimen.notification_panel_margin_bottom); |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 2358 | mNotificationPanelMarginPx |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2359 | = (int) res.getDimension(R.dimen.notification_panel_margin_left); |
| 2360 | mNotificationPanelGravity = res.getInteger(R.integer.notification_panel_layout_gravity); |
| 2361 | if (mNotificationPanelGravity <= 0) { |
Daniel Sandler | 8e72c9e | 2012-08-15 00:09:26 -0400 | [diff] [blame] | 2362 | mNotificationPanelGravity = Gravity.LEFT | Gravity.TOP; |
| 2363 | } |
| 2364 | mSettingsPanelGravity = res.getInteger(R.integer.settings_panel_layout_gravity); |
| 2365 | if (mSettingsPanelGravity <= 0) { |
| 2366 | mSettingsPanelGravity = Gravity.RIGHT | Gravity.TOP; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2367 | } |
Daniel Sandler | 3d32a24 | 2012-06-05 13:44:14 -0400 | [diff] [blame] | 2368 | |
| 2369 | mCarrierLabelHeight = res.getDimensionPixelSize(R.dimen.carrier_label_height); |
Daniel Sandler | bf526d1 | 2012-09-04 22:56:44 -0400 | [diff] [blame] | 2370 | mNotificationHeaderHeight = res.getDimensionPixelSize(R.dimen.notification_panel_header_height); |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 2371 | |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 2372 | mNotificationPanelMinHeightFrac = res.getFraction(R.dimen.notification_panel_min_height_frac, 1, 1); |
| 2373 | if (mNotificationPanelMinHeightFrac < 0f || mNotificationPanelMinHeightFrac > 1f) { |
| 2374 | mNotificationPanelMinHeightFrac = 0f; |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 2375 | } |
Daniel Sandler | e680f54 | 2012-09-28 12:22:27 -0400 | [diff] [blame] | 2376 | |
| 2377 | if (false) Slog.v(TAG, "updateResources"); |
John Spurlock | 804df70 | 2012-06-01 15:34:27 -0400 | [diff] [blame] | 2378 | } |
| 2379 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2380 | // |
| 2381 | // tracing |
| 2382 | // |
| 2383 | |
| 2384 | void postStartTracing() { |
| 2385 | mHandler.postDelayed(mStartTracing, 3000); |
| 2386 | } |
| 2387 | |
| 2388 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2389 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 2390 | Context.VIBRATOR_SERVICE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2391 | vib.vibrate(250); |
| 2392 | } |
| 2393 | |
| 2394 | Runnable mStartTracing = new Runnable() { |
| 2395 | public void run() { |
| 2396 | vibrate(); |
| 2397 | SystemClock.sleep(250); |
| 2398 | Slog.d(TAG, "startTracing"); |
| 2399 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 2400 | mHandler.postDelayed(mStopTracing, 10000); |
| 2401 | } |
| 2402 | }; |
| 2403 | |
| 2404 | Runnable mStopTracing = new Runnable() { |
| 2405 | public void run() { |
| 2406 | android.os.Debug.stopMethodTracing(); |
| 2407 | Slog.d(TAG, "stopTracing"); |
| 2408 | vibrate(); |
| 2409 | } |
| 2410 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2411 | |
| 2412 | @Override |
| 2413 | protected void haltTicker() { |
| 2414 | mTicker.halt(); |
| 2415 | } |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 2416 | |
| 2417 | @Override |
Jim Miller | b4238e0 | 2012-05-14 15:26:20 -0700 | [diff] [blame] | 2418 | protected boolean shouldDisableNavbarGestures() { |
Daniel Sandler | e7237fc | 2012-08-14 16:08:27 -0400 | [diff] [blame] | 2419 | return mExpandedVisible || (mDisabled & StatusBarManager.DISABLE_HOME) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 2420 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2421 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 2422 | private static class FastColorDrawable extends Drawable { |
| 2423 | private final int mColor; |
| 2424 | |
| 2425 | public FastColorDrawable(int color) { |
| 2426 | mColor = 0xff000000 | color; |
| 2427 | } |
| 2428 | |
| 2429 | @Override |
| 2430 | public void draw(Canvas canvas) { |
| 2431 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 2432 | } |
| 2433 | |
| 2434 | @Override |
| 2435 | public void setAlpha(int alpha) { |
| 2436 | } |
| 2437 | |
| 2438 | @Override |
| 2439 | public void setColorFilter(ColorFilter cf) { |
| 2440 | } |
| 2441 | |
| 2442 | @Override |
| 2443 | public int getOpacity() { |
| 2444 | return PixelFormat.OPAQUE; |
| 2445 | } |
| 2446 | |
| 2447 | @Override |
| 2448 | public void setBounds(int left, int top, int right, int bottom) { |
| 2449 | } |
| 2450 | |
| 2451 | @Override |
| 2452 | public void setBounds(Rect bounds) { |
| 2453 | } |
| 2454 | } |
| 2455 | } |