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