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