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