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