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; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 23 | import android.app.ActivityManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 24 | import android.app.ActivityManagerNative; |
| 25 | import android.app.Dialog; |
Daniel Sandler | 92d3318 | 2011-09-11 16:29:05 -0400 | [diff] [blame] | 26 | import android.app.KeyguardManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 27 | import android.app.Notification; |
| 28 | import android.app.PendingIntent; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 29 | import android.app.StatusBarManager; |
| 30 | import android.content.BroadcastReceiver; |
| 31 | import android.content.Context; |
| 32 | import android.content.Intent; |
| 33 | import android.content.IntentFilter; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 34 | import android.content.res.Configuration; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 35 | import android.content.res.Resources; |
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; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 39 | import android.graphics.PorterDuff; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 40 | import android.graphics.Rect; |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 41 | import android.graphics.drawable.Drawable; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 42 | import android.inputmethodservice.InputMethodService; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 43 | import android.os.IBinder; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 44 | import android.os.Message; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 45 | import android.os.RemoteException; |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 46 | import android.os.ServiceManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 47 | import android.os.SystemClock; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 48 | import android.provider.Settings; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 49 | import android.util.DisplayMetrics; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 50 | import android.util.Log; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 51 | import android.util.Slog; |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 52 | import android.view.Choreographer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 53 | import android.view.Display; |
| 54 | import android.view.Gravity; |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 55 | import android.view.IWindowManager; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 56 | import android.view.KeyEvent; |
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; |
| 60 | import android.view.ViewGroup; |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 61 | import android.view.ViewGroup.LayoutParams; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 62 | import android.view.WindowManager; |
| 63 | import android.view.WindowManagerImpl; |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 64 | import android.view.animation.AccelerateInterpolator; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 65 | import android.view.animation.Animation; |
| 66 | import android.view.animation.AnimationUtils; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 67 | import android.widget.FrameLayout; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 68 | import android.widget.ImageView; |
| 69 | import android.widget.LinearLayout; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 70 | import android.widget.ScrollView; |
| 71 | import android.widget.TextView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 72 | import com.android.internal.statusbar.StatusBarIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 73 | import com.android.internal.statusbar.StatusBarNotification; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 74 | import com.android.systemui.R; |
Michael Jurka | ab48b68 | 2011-09-12 15:39:45 -0700 | [diff] [blame] | 75 | import com.android.systemui.recent.RecentTasksLoader; |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 76 | import com.android.systemui.statusbar.BaseStatusBar; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 77 | import com.android.systemui.statusbar.NotificationData; |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 78 | import com.android.systemui.statusbar.NotificationData.Entry; |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 79 | import com.android.systemui.statusbar.CommandQueue; |
Daniel Sandler | 9ff6378 | 2012-05-03 23:16:42 -0400 | [diff] [blame] | 80 | import com.android.systemui.statusbar.RotationToggle; |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 81 | import com.android.systemui.statusbar.SignalClusterView; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 82 | import com.android.systemui.statusbar.StatusBarIconView; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 83 | import com.android.systemui.statusbar.policy.BatteryController; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 84 | import com.android.systemui.statusbar.policy.DateView; |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 85 | import com.android.systemui.statusbar.policy.IntruderAlertView; |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 86 | import com.android.systemui.statusbar.policy.LocationController; |
| 87 | import com.android.systemui.statusbar.policy.NetworkController; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 88 | import com.android.systemui.statusbar.policy.NotificationRowLayout; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 89 | |
Daniel Sandler | 6a858c3 | 2012-03-12 14:38:58 -0400 | [diff] [blame] | 90 | import java.io.FileDescriptor; |
| 91 | import java.io.PrintWriter; |
| 92 | import java.util.ArrayList; |
| 93 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 94 | public class PhoneStatusBar extends BaseStatusBar { |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 95 | static final String TAG = "PhoneStatusBar"; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 96 | public static final boolean DEBUG = false; |
Daniel Sandler | c1ebee4 | 2012-03-26 19:39:46 -0400 | [diff] [blame] | 97 | public static final boolean SPEW = DEBUG; |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 98 | public static final boolean DUMPTRUCK = true; // extra dumpsys info |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 99 | |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 100 | // additional instrumentation for testing purposes; intended to be left on during development |
Daniel Sandler | 7c35174 | 2011-10-17 10:48:06 -0400 | [diff] [blame] | 101 | public static final boolean CHATTY = DEBUG; |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 102 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 103 | public static final String ACTION_STATUSBAR_START |
| 104 | = "com.android.internal.policy.statusbar.START"; |
| 105 | |
Daniel Sandler | fc753d2 | 2012-05-08 13:56:44 -0400 | [diff] [blame] | 106 | private static final boolean DIM_BEHIND_EXPANDED_PANEL = false; |
Daniel Sandler | fc6fda3 | 2012-02-24 22:00:46 -0500 | [diff] [blame] | 107 | |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 108 | private static final int MSG_OPEN_NOTIFICATION_PANEL = 1000; |
| 109 | private static final int MSG_CLOSE_NOTIFICATION_PANEL = 1001; |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 110 | // 1020-1030 reserved for BaseStatusBar |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 111 | |
| 112 | // will likely move to a resource or other tunable param at some point |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 113 | private static final int INTRUDER_ALERT_DECAY_MS = 0; // disabled, was 10000; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 114 | |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 115 | private static final boolean CLOSE_PANEL_WHEN_EMPTIED = true; |
| 116 | |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 117 | private static final int NOTIFICATION_PRIORITY_MULTIPLIER = 10; // see NotificationManagerService |
| 118 | private static final int HIDE_ICONS_BELOW_SCORE = Notification.PRIORITY_LOW * NOTIFICATION_PRIORITY_MULTIPLIER; |
| 119 | |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 120 | // fling gesture tuning parameters, scaled to display density |
| 121 | private float mSelfExpandVelocityPx; // classic value: 2000px/s |
| 122 | private float mSelfCollapseVelocityPx; // classic value: 2000px/s (will be negated to collapse "up") |
| 123 | private float mFlingExpandMinVelocityPx; // classic value: 200px/s |
| 124 | private float mFlingCollapseMinVelocityPx; // classic value: 200px/s |
| 125 | private float mCollapseMinDisplayFraction; // classic value: 0.08 (25px/min(320px,480px) on G1) |
| 126 | private float mExpandMinDisplayFraction; // classic value: 0.5 (drag open halfway to expand) |
| 127 | private float mFlingGestureMaxXVelocityPx; // classic value: 150px/s |
| 128 | |
| 129 | private float mExpandAccelPx; // classic value: 2000px/s/s |
| 130 | private float mCollapseAccelPx; // classic value: 2000px/s/s (will be negated to collapse "up") |
| 131 | |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 132 | PhoneStatusBarPolicy mIconPolicy; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 133 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 134 | // These are no longer handled by the policy, because we need custom strategies for them |
| 135 | BatteryController mBatteryController; |
| 136 | LocationController mLocationController; |
| 137 | NetworkController mNetworkController; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 138 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 139 | int mNaturalBarHeight = -1; |
| 140 | int mIconSize = -1; |
| 141 | int mIconHPadding = -1; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 142 | Display mDisplay; |
| 143 | |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 144 | IWindowManager mWindowManager; |
| 145 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 146 | StatusBarWindowView mStatusBarWindow; |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 147 | PhoneStatusBarView mStatusBarView; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 148 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 149 | int mPixelFormat; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 150 | Object mQueueLock = new Object(); |
| 151 | |
| 152 | // icons |
| 153 | LinearLayout mIcons; |
| 154 | IconMerger mNotificationIcons; |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 155 | View mMoreIcon; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 156 | LinearLayout mStatusIcons; |
| 157 | |
| 158 | // expanded notifications |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 159 | View mNotificationPanel; // the sliding/resizing panel within the notification window |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 160 | ScrollView mScrollView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 161 | View mExpandedContents; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 162 | int mNotificationPanelMarginBottomPx, mNotificationPanelMarginLeftPx; |
| 163 | int mNotificationPanelGravity; |
| 164 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 165 | // top bar |
Daniel Sandler | 1347c30 | 2011-08-01 16:47:53 -0400 | [diff] [blame] | 166 | View mClearButton; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 167 | View mSettingsButton; |
Daniel Sandler | 9ff6378 | 2012-05-03 23:16:42 -0400 | [diff] [blame] | 168 | RotationToggle mRotationButton; |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 169 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 170 | // drag bar |
| 171 | CloseDragHandle mCloseView; |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 172 | private int mCloseViewHeight; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 173 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 174 | // position |
| 175 | int[] mPositionTmp = new int[2]; |
| 176 | boolean mExpanded; |
| 177 | boolean mExpandedVisible; |
| 178 | |
| 179 | // the date view |
| 180 | DateView mDateView; |
| 181 | |
| 182 | // for immersive activities |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 183 | private IntruderAlertView mIntruderAlertView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 184 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 185 | // on-screen navigation buttons |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 186 | private NavigationBarView mNavigationBarView = null; |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 187 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 188 | // the tracker view |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 189 | int mTrackingPosition; // the position of the top of the tracking view. |
| 190 | private boolean mPanelSlightlyVisible; |
| 191 | |
| 192 | // ticker |
| 193 | private Ticker mTicker; |
| 194 | private View mTickerView; |
| 195 | private boolean mTicking; |
| 196 | |
| 197 | // Tracking finger for opening/closing. |
| 198 | int mEdgeBorder; // corresponds to R.dimen.status_bar_edge_ignore |
| 199 | boolean mTracking; |
| 200 | VelocityTracker mVelocityTracker; |
| 201 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 202 | Choreographer mChoreographer; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 203 | boolean mAnimating; |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 204 | boolean mClosing; // only valid when mAnimating; indicates the initial acceleration |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 205 | float mAnimY; |
| 206 | float mAnimVel; |
| 207 | float mAnimAccel; |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 208 | long mAnimLastTimeNanos; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 209 | boolean mAnimatingReveal = false; |
| 210 | int mViewDelta; |
| 211 | int[] mAbsPos = new int[2]; |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 212 | Runnable mPostCollapseCleanup = null; |
| 213 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 214 | private AnimatorSet mLightsOutAnimation; |
| 215 | private AnimatorSet mLightsOnAnimation; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 216 | |
| 217 | // for disabling the status bar |
| 218 | int mDisabled = 0; |
| 219 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 220 | // tracking calls to View.setSystemUiVisibility() |
| 221 | int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; |
| 222 | |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 223 | DisplayMetrics mDisplayMetrics = new DisplayMetrics(); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 224 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 225 | private int mNavigationIconHints = 0; |
Romain Guy | f7f16f7 | 2012-05-24 19:13:56 -0700 | [diff] [blame] | 226 | private final Animator.AnimatorListener mMakeIconsInvisible = new AnimatorListenerAdapter() { |
| 227 | @Override |
| 228 | public void onAnimationEnd(Animator animation) { |
| 229 | mIcons.setVisibility(View.INVISIBLE); |
| 230 | } |
| 231 | }; |
| 232 | private final Animator.AnimatorListener mMakeIconsVisible = new AnimatorListenerAdapter() { |
| 233 | @Override |
| 234 | public void onAnimationEnd(Animator animation) { |
| 235 | mIcons.setVisibility(View.VISIBLE); |
| 236 | } |
| 237 | }; |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 238 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 239 | private class ExpandedDialog extends Dialog { |
| 240 | ExpandedDialog(Context context) { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 241 | super(context, com.android.internal.R.style.Theme_Translucent_NoTitleBar); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 246 | boolean down = event.getAction() == KeyEvent.ACTION_DOWN; |
| 247 | switch (event.getKeyCode()) { |
| 248 | case KeyEvent.KEYCODE_BACK: |
| 249 | if (!down) { |
| 250 | animateCollapse(); |
| 251 | } |
| 252 | return true; |
| 253 | } |
| 254 | return super.dispatchKeyEvent(event); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | @Override |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 259 | public void start() { |
| 260 | mDisplay = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)) |
| 261 | .getDefaultDisplay(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 262 | |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 263 | mWindowManager = IWindowManager.Stub.asInterface( |
| 264 | ServiceManager.getService(Context.WINDOW_SERVICE)); |
| 265 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 266 | super.start(); // calls createAndAddWindows() |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 267 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 268 | addNavigationBar(); |
| 269 | |
Daniel Sandler | fc6fda3 | 2012-02-24 22:00:46 -0500 | [diff] [blame] | 270 | if (ENABLE_INTRUDERS) addIntruderView(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 271 | |
| 272 | // Lastly, call to the icon policy to install/update all the icons. |
Joe Onorato | fd52b18 | 2010-11-10 18:00:52 -0800 | [diff] [blame] | 273 | mIconPolicy = new PhoneStatusBarPolicy(mContext); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | // ================================================================================ |
| 277 | // Constructing the view |
| 278 | // ================================================================================ |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 279 | protected PhoneStatusBarView makeStatusBarView() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 280 | final Context context = mContext; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 281 | |
| 282 | Resources res = context.getResources(); |
| 283 | |
Daniel Sandler | 6e8db88 | 2011-10-26 15:40:51 -0400 | [diff] [blame] | 284 | updateDisplaySize(); // populates mDisplayMetrics |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 285 | loadDimens(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 286 | |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 287 | mIconSize = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_icon_size); |
| 288 | |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 289 | mStatusBarWindow = (StatusBarWindowView) View.inflate(context, |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 290 | R.layout.super_status_bar, null); |
Daniel Sandler | cf336e1 | 2011-08-09 15:48:18 -0400 | [diff] [blame] | 291 | if (DEBUG) { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 292 | mStatusBarWindow.setBackgroundColor(0x6000FF80); |
Daniel Sandler | cf336e1 | 2011-08-09 15:48:18 -0400 | [diff] [blame] | 293 | } |
Daniel Sandler | c4f2a56 | 2012-05-04 11:55:46 -0400 | [diff] [blame] | 294 | mStatusBarWindow.mService = this; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 295 | mStatusBarWindow.setOnTouchListener(new View.OnTouchListener() { |
| 296 | @Override |
| 297 | public boolean onTouch(View v, MotionEvent event) { |
| 298 | if (event.getAction() == MotionEvent.ACTION_DOWN) { |
| 299 | if (mExpanded && !mAnimating) { |
| 300 | animateCollapse(); |
| 301 | } |
| 302 | } |
Chris Wren | 5de6e94 | 2012-05-16 14:22:21 -0400 | [diff] [blame] | 303 | return mStatusBarWindow.onTouchEvent(event); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 304 | }}); |
| 305 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 306 | mStatusBarView = (PhoneStatusBarView) mStatusBarWindow.findViewById(R.id.status_bar); |
| 307 | mNotificationPanel = mStatusBarWindow.findViewById(R.id.notification_panel); |
Daniel Sandler | 9ff6378 | 2012-05-03 23:16:42 -0400 | [diff] [blame] | 308 | // don't allow clicks on the panel to pass through to the background where they will cause the panel to close |
| 309 | mNotificationPanel.setOnTouchListener(new View.OnTouchListener() { |
| 310 | @Override |
| 311 | public boolean onTouch(View v, MotionEvent event) { |
| 312 | return true; |
| 313 | } |
| 314 | }); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 315 | mNotificationPanel.setSystemUiVisibility( |
| 316 | View.STATUS_BAR_DISABLE_NOTIFICATION_TICKER |
| 317 | | View.STATUS_BAR_DISABLE_SYSTEM_INFO); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 318 | |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 319 | if (!ActivityManager.isHighEndGfx(mDisplay)) { |
| 320 | mStatusBarWindow.setBackground(null); |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 321 | mNotificationPanel.setBackground(new FastColorDrawable(context.getResources().getColor( |
| 322 | R.color.notification_panel_solid_background))); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 325 | if (ENABLE_INTRUDERS) { |
| 326 | mIntruderAlertView = (IntruderAlertView) View.inflate(context, R.layout.intruder_alert, null); |
| 327 | mIntruderAlertView.setVisibility(View.GONE); |
| 328 | mIntruderAlertView.setBar(this); |
| 329 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 330 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 331 | mStatusBarView.mService = this; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 332 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 333 | mChoreographer = Choreographer.getInstance(); |
| 334 | |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 335 | try { |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 336 | boolean showNav = mWindowManager.hasNavigationBar(); |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 337 | if (DEBUG) Slog.v(TAG, "hasNavigationBar=" + showNav); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 338 | if (showNav) { |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 339 | mNavigationBarView = |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 340 | (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 341 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 342 | mNavigationBarView.setDisabledFlags(mDisabled); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 343 | mNavigationBarView.setBar(this); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 344 | } |
Daniel Sandler | 0c4ccff | 2011-10-19 16:39:14 -0400 | [diff] [blame] | 345 | } catch (RemoteException ex) { |
| 346 | // no window manager? good luck with that |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 347 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 348 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 349 | // figure out which pixel-format to use for the status bar. |
Daniel Sandler | f733c2a | 2011-09-25 15:03:40 -0400 | [diff] [blame] | 350 | mPixelFormat = PixelFormat.OPAQUE; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 351 | mStatusIcons = (LinearLayout)mStatusBarView.findViewById(R.id.statusIcons); |
| 352 | mNotificationIcons = (IconMerger)mStatusBarView.findViewById(R.id.notificationIcons); |
Daniel Sandler | 05e2414 | 2011-11-10 11:56:49 -0500 | [diff] [blame] | 353 | mNotificationIcons.setOverflowIndicator(mMoreIcon); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 354 | mIcons = (LinearLayout)mStatusBarView.findViewById(R.id.icons); |
| 355 | mTickerView = mStatusBarView.findViewById(R.id.ticker); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 356 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 357 | mPile = (NotificationRowLayout)mStatusBarWindow.findViewById(R.id.latestItems); |
Daniel Sandler | f7a1956 | 2012-04-04 14:04:21 -0400 | [diff] [blame] | 358 | mPile.setLongPressListener(getNotificationLongClicker()); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 359 | mExpandedContents = mPile; // was: expanded.findViewById(R.id.notificationLinearLayout); |
Daniel Sandler | d714148 | 2011-08-18 15:14:52 -0400 | [diff] [blame] | 360 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 361 | mClearButton = mStatusBarWindow.findViewById(R.id.clear_all_button); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 362 | mClearButton.setOnClickListener(mClearButtonListener); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 363 | mClearButton.setAlpha(0f); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 364 | mClearButton.setVisibility(View.INVISIBLE); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 365 | mClearButton.setEnabled(false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 366 | mDateView = (DateView)mStatusBarWindow.findViewById(R.id.date); |
| 367 | mSettingsButton = mStatusBarWindow.findViewById(R.id.settings_button); |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 368 | mSettingsButton.setOnClickListener(mSettingsButtonListener); |
Daniel Sandler | 9ff6378 | 2012-05-03 23:16:42 -0400 | [diff] [blame] | 369 | mRotationButton = (RotationToggle) mStatusBarWindow.findViewById(R.id.rotation_lock_button); |
| 370 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 371 | mScrollView = (ScrollView)mStatusBarWindow.findViewById(R.id.scroll); |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 372 | mScrollView.setVerticalScrollBarEnabled(false); // less drawing during pulldowns |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 373 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 374 | mTicker = new MyTicker(context, mStatusBarView); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 375 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 376 | TickerView tickerView = (TickerView)mStatusBarView.findViewById(R.id.tickerText); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 377 | tickerView.mTicker = mTicker; |
| 378 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 379 | mCloseView = (CloseDragHandle)mStatusBarWindow.findViewById(R.id.close); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 380 | mCloseView.mService = this; |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 381 | mCloseViewHeight = res.getDimensionPixelSize(R.dimen.close_handle_height); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 382 | |
| 383 | mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); |
| 384 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 385 | // set the inital view visibility |
| 386 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 387 | |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 388 | // Other icons |
| 389 | mLocationController = new LocationController(mContext); // will post a notification |
| 390 | mBatteryController = new BatteryController(mContext); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 391 | mBatteryController.addIconView((ImageView)mStatusBarView.findViewById(R.id.battery)); |
Daniel Sandler | 2b69735 | 2011-07-22 16:23:09 -0400 | [diff] [blame] | 392 | mNetworkController = new NetworkController(mContext); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 393 | final SignalClusterView signalCluster = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 394 | (SignalClusterView)mStatusBarView.findViewById(R.id.signal_cluster); |
Christian Robertson | 2e34742 | 2011-08-11 14:01:04 -0700 | [diff] [blame] | 395 | mNetworkController.addSignalCluster(signalCluster); |
Daniel Sandler | 28f89d4 | 2011-08-15 14:04:15 -0400 | [diff] [blame] | 396 | signalCluster.setNetworkController(mNetworkController); |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 397 | // final ImageView wimaxRSSI = |
Daniel Sandler | 633eabe | 2011-11-09 16:49:44 -0500 | [diff] [blame] | 398 | // (ImageView)sb.findViewById(R.id.wimax_signal); |
| 399 | // if (wimaxRSSI != null) { |
| 400 | // mNetworkController.addWimaxIconView(wimaxRSSI); |
| 401 | // } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 402 | // Recents Panel |
Michael Jurka | ab48b68 | 2011-09-12 15:39:45 -0700 | [diff] [blame] | 403 | mRecentTasksLoader = new RecentTasksLoader(context); |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 404 | updateRecentsPanel(); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 405 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 406 | // receive broadcasts |
| 407 | IntentFilter filter = new IntentFilter(); |
| 408 | filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); |
| 409 | filter.addAction(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); |
| 410 | filter.addAction(Intent.ACTION_SCREEN_OFF); |
| 411 | context.registerReceiver(mBroadcastReceiver, filter); |
| 412 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 413 | return mStatusBarView; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 414 | } |
| 415 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 416 | @Override |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 417 | protected WindowManager.LayoutParams getRecentsLayoutParams(LayoutParams layoutParams) { |
Michael Jurka | 3cd0a59 | 2011-08-16 12:40:30 -0700 | [diff] [blame] | 418 | boolean opaque = false; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 419 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Jim Miller | f2a16b2 | 2011-07-06 17:32:48 -0700 | [diff] [blame] | 420 | layoutParams.width, |
| 421 | layoutParams.height, |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 422 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, |
| 423 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 424 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 425 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Michael Jurka | 3cd0a59 | 2011-08-16 12:40:30 -0700 | [diff] [blame] | 426 | (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 427 | if (ActivityManager.isHighEndGfx(mDisplay)) { |
| 428 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
Michael Jurka | f16fc51 | 2012-02-27 15:02:23 -0800 | [diff] [blame] | 429 | } else { |
| 430 | lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; |
Michael Jurka | f3abbad | 2012-06-04 14:00:32 -0700 | [diff] [blame^] | 431 | lp.dimAmount = 0.75f; |
Dianne Hackborn | fc8fa63 | 2011-08-17 16:20:47 -0700 | [diff] [blame] | 432 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 433 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 434 | lp.setTitle("RecentsPanel"); |
Michael Jurka | 99a9655 | 2012-01-27 17:23:38 -0800 | [diff] [blame] | 435 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 436 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 437 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 438 | return lp; |
| 439 | } |
| 440 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 441 | @Override |
| 442 | protected WindowManager.LayoutParams getSearchLayoutParams(LayoutParams layoutParams) { |
| 443 | boolean opaque = false; |
| 444 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 445 | LayoutParams.MATCH_PARENT, |
| 446 | LayoutParams.MATCH_PARENT, |
| 447 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR_PANEL, |
| 448 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 449 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 450 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
| 451 | (opaque ? PixelFormat.OPAQUE : PixelFormat.TRANSLUCENT)); |
| 452 | if (ActivityManager.isHighEndGfx(mDisplay)) { |
| 453 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 454 | } |
| 455 | lp.gravity = Gravity.BOTTOM | Gravity.LEFT; |
| 456 | lp.setTitle("SearchPanel"); |
| 457 | // TODO: Define custom animation for Search panel |
| 458 | lp.windowAnimations = com.android.internal.R.style.Animation_RecentApplications; |
| 459 | lp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_UNCHANGED |
| 460 | | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING; |
| 461 | return lp; |
| 462 | } |
| 463 | |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 464 | protected void updateRecentsPanel() { |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 465 | super.updateRecentsPanel(R.layout.status_bar_recent_panel); |
Michael Jurka | 4eaa983 | 2012-02-29 15:51:49 -0800 | [diff] [blame] | 466 | // Make .03 alpha the minimum so you always see the item a bit-- slightly below |
| 467 | // .03, the item disappears entirely (as if alpha = 0) and that discontinuity looks |
| 468 | // a bit jarring |
| 469 | mRecentsPanel.setMinSwipeAlpha(0.03f); |
Michael Jurka | 8b2e37e | 2012-05-08 20:06:13 -0700 | [diff] [blame] | 470 | if (mNavigationBarView != null) { |
| 471 | mNavigationBarView.getRecentsButton().setOnTouchListener(mRecentsPanel); |
| 472 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 473 | } |
| 474 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 475 | @Override |
| 476 | protected void updateSearchPanel() { |
| 477 | super.updateSearchPanel(); |
Jim Miller | 354619c | 2012-04-27 17:33:44 -0700 | [diff] [blame] | 478 | mSearchPanelView.setStatusBarView(mNavigationBarView); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 479 | mNavigationBarView.setDelegateView(mSearchPanelView); |
| 480 | } |
| 481 | |
| 482 | @Override |
| 483 | public void showSearchPanel() { |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 484 | super.showSearchPanel(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 485 | WindowManager.LayoutParams lp = |
| 486 | (android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams(); |
| 487 | lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 488 | WindowManagerImpl.getDefault().updateViewLayout(mNavigationBarView, lp); |
| 489 | } |
| 490 | |
| 491 | @Override |
| 492 | public void hideSearchPanel() { |
| 493 | super.hideSearchPanel(); |
| 494 | WindowManager.LayoutParams lp = |
| 495 | (android.view.WindowManager.LayoutParams) mNavigationBarView.getLayoutParams(); |
| 496 | lp.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 497 | WindowManagerImpl.getDefault().updateViewLayout(mNavigationBarView, lp); |
| 498 | } |
| 499 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 500 | protected int getStatusBarGravity() { |
| 501 | return Gravity.TOP | Gravity.FILL_HORIZONTAL; |
| 502 | } |
| 503 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 504 | public int getStatusBarHeight() { |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 505 | if (mNaturalBarHeight < 0) { |
| 506 | final Resources res = mContext.getResources(); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 507 | mNaturalBarHeight = |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 508 | res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height); |
| 509 | } |
| 510 | return mNaturalBarHeight; |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 511 | } |
| 512 | |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 513 | private int getCloseViewHeight() { |
| 514 | return mCloseViewHeight; |
| 515 | } |
| 516 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 517 | private View.OnClickListener mRecentsClickListener = new View.OnClickListener() { |
| 518 | public void onClick(View v) { |
| 519 | toggleRecentApps(); |
| 520 | } |
| 521 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 522 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 523 | private int mShowSearchHoldoff = 0; |
| 524 | private Runnable mShowSearchPanel = new Runnable() { |
| 525 | public void run() { |
| 526 | showSearchPanel(); |
| 527 | } |
| 528 | }; |
| 529 | |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 530 | View.OnTouchListener mHomeSearchActionListener = new View.OnTouchListener() { |
| 531 | public boolean onTouch(View v, MotionEvent event) { |
| 532 | switch(event.getAction()) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 533 | case MotionEvent.ACTION_DOWN: |
| 534 | if (!shouldDisableNavbarGestures()) { |
| 535 | mHandler.removeCallbacks(mShowSearchPanel); |
| 536 | mHandler.postDelayed(mShowSearchPanel, mShowSearchHoldoff); |
| 537 | } |
| 538 | break; |
| 539 | |
| 540 | case MotionEvent.ACTION_UP: |
| 541 | case MotionEvent.ACTION_CANCEL: |
| 542 | mHandler.removeCallbacks(mShowSearchPanel); |
| 543 | break; |
| 544 | } |
| 545 | return false; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 546 | } |
| 547 | }; |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 548 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 549 | private void prepareNavigationBarView() { |
| 550 | mNavigationBarView.reorient(); |
| 551 | |
| 552 | mNavigationBarView.getRecentsButton().setOnClickListener(mRecentsClickListener); |
| 553 | mNavigationBarView.getRecentsButton().setOnTouchListener(mRecentsPanel); |
Jim Miller | 998bb76 | 2012-05-21 13:37:27 -0700 | [diff] [blame] | 554 | mNavigationBarView.getHomeButton().setOnTouchListener(mHomeSearchActionListener); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 555 | updateSearchPanel(); |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 556 | } |
| 557 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 558 | // For small-screen devices (read: phones) that lack hardware navigation buttons |
| 559 | private void addNavigationBar() { |
Daniel Sandler | 4a066c5 | 2012-04-20 14:49:13 -0400 | [diff] [blame] | 560 | if (DEBUG) Slog.v(TAG, "addNavigationBar: about to add " + mNavigationBarView); |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 561 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 562 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 563 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 564 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 565 | WindowManagerImpl.getDefault().addView( |
| 566 | mNavigationBarView, getNavigationBarLayoutParams()); |
| 567 | } |
| 568 | |
| 569 | private void repositionNavigationBar() { |
Daniel Sandler | 0129b31 | 2011-05-11 11:54:11 -0400 | [diff] [blame] | 570 | if (mNavigationBarView == null) return; |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 571 | |
Michael Jurka | 412cba8 | 2011-10-17 09:05:00 -0700 | [diff] [blame] | 572 | prepareNavigationBarView(); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 573 | |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 574 | WindowManagerImpl.getDefault().updateViewLayout( |
| 575 | mNavigationBarView, getNavigationBarLayoutParams()); |
| 576 | } |
| 577 | |
| 578 | private WindowManager.LayoutParams getNavigationBarLayoutParams() { |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 579 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
Dianne Hackborn | 1f903c3 | 2011-09-13 19:18:06 -0700 | [diff] [blame] | 580 | LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 581 | WindowManager.LayoutParams.TYPE_NAVIGATION_BAR, |
| 582 | 0 |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 583 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 584 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Dianne Hackborn | df89e65 | 2011-10-06 22:35:11 -0700 | [diff] [blame] | 585 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
Jim Miller | d99e7fd | 2012-05-08 16:30:42 -0700 | [diff] [blame] | 586 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Daniel Sandler | a388449 | 2011-08-16 15:55:44 -0400 | [diff] [blame] | 587 | PixelFormat.OPAQUE); |
Daniel Sandler | c638c1e | 2011-08-24 16:19:23 -0700 | [diff] [blame] | 588 | // this will allow the navbar to run in an overlay on devices that support this |
| 589 | if (ActivityManager.isHighEndGfx(mDisplay)) { |
| 590 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 591 | } |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 592 | |
| 593 | lp.setTitle("NavigationBar"); |
Daniel Sandler | 8956dbb | 2011-04-22 07:55:02 -0400 | [diff] [blame] | 594 | lp.windowAnimations = 0; |
| 595 | |
| 596 | return lp; |
| 597 | } |
| 598 | |
Joe Onorato | dc10030 | 2011-01-11 17:07:41 -0800 | [diff] [blame] | 599 | private void addIntruderView() { |
| 600 | final int height = getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 601 | |
| 602 | WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 603 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 604 | ViewGroup.LayoutParams.WRAP_CONTENT, |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 605 | WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL, // above the status bar! |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 606 | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
| 607 | | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
| 608 | | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
| 609 | | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
Jeff Brown | 46e7529 | 2010-11-10 16:53:45 -0800 | [diff] [blame] | 610 | | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM |
| 611 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 612 | PixelFormat.TRANSLUCENT); |
| 613 | lp.gravity = Gravity.TOP | Gravity.FILL_HORIZONTAL; |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 614 | //lp.y += height * 1.5; // FIXME |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 615 | lp.setTitle("IntruderAlert"); |
Dianne Hackborn | 59aed38 | 2011-08-02 17:31:44 -0700 | [diff] [blame] | 616 | lp.packageName = mContext.getPackageName(); |
| 617 | lp.windowAnimations = R.style.Animation_StatusBar_IntruderAlert; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 618 | |
| 619 | WindowManagerImpl.getDefault().addView(mIntruderAlertView, lp); |
| 620 | } |
| 621 | |
| 622 | public void addIcon(String slot, int index, int viewIndex, StatusBarIcon icon) { |
| 623 | if (SPEW) Slog.d(TAG, "addIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex |
| 624 | + " icon=" + icon); |
Svetoslav Ganov | 6179ea3 | 2011-06-28 01:12:41 -0700 | [diff] [blame] | 625 | StatusBarIconView view = new StatusBarIconView(mContext, slot, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 626 | view.set(icon); |
| 627 | mStatusIcons.addView(view, viewIndex, new LinearLayout.LayoutParams(mIconSize, mIconSize)); |
| 628 | } |
| 629 | |
| 630 | public void updateIcon(String slot, int index, int viewIndex, |
| 631 | StatusBarIcon old, StatusBarIcon icon) { |
| 632 | if (SPEW) Slog.d(TAG, "updateIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex |
| 633 | + " old=" + old + " icon=" + icon); |
| 634 | StatusBarIconView view = (StatusBarIconView)mStatusIcons.getChildAt(viewIndex); |
| 635 | view.set(icon); |
| 636 | } |
| 637 | |
| 638 | public void removeIcon(String slot, int index, int viewIndex) { |
| 639 | if (SPEW) Slog.d(TAG, "removeIcon slot=" + slot + " index=" + index + " viewIndex=" + viewIndex); |
| 640 | mStatusIcons.removeViewAt(viewIndex); |
| 641 | } |
| 642 | |
| 643 | public void addNotification(IBinder key, StatusBarNotification notification) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 644 | /* if (DEBUG) */ Slog.d(TAG, "addNotification score=" + notification.score); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 645 | StatusBarIconView iconView = addNotificationViews(key, notification); |
| 646 | if (iconView == null) return; |
| 647 | |
| 648 | boolean immersive = false; |
| 649 | try { |
| 650 | immersive = ActivityManagerNative.getDefault().isTopActivityImmersive(); |
Daniel Sandler | 8355e93 | 2011-08-11 00:27:45 -0400 | [diff] [blame] | 651 | if (DEBUG) { |
| 652 | Slog.d(TAG, "Top activity is " + (immersive?"immersive":"not immersive")); |
| 653 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 654 | } catch (RemoteException ex) { |
| 655 | } |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 656 | |
| 657 | /* |
| 658 | * DISABLED due to missing API |
Daniel Sandler | fc6fda3 | 2012-02-24 22:00:46 -0500 | [diff] [blame] | 659 | if (ENABLE_INTRUDERS && ( |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 660 | // TODO(dsandler): Only if the screen is on |
| 661 | notification.notification.intruderView != null)) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 662 | Slog.d(TAG, "Presenting high-priority notification"); |
| 663 | // special new transient ticker mode |
| 664 | // 1. Populate mIntruderAlertView |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 665 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 666 | if (notification.notification.intruderView == null) { |
| 667 | Slog.e(TAG, notification.notification.toString() + " wanted to intrude but intruderView was null"); |
| 668 | return; |
| 669 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 670 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 671 | // bind the click event to the content area |
| 672 | PendingIntent contentIntent = notification.notification.contentIntent; |
| 673 | final View.OnClickListener listener = (contentIntent != null) |
| 674 | ? new NotificationClicker(contentIntent, |
| 675 | notification.pkg, notification.tag, notification.id) |
| 676 | : null; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 677 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 678 | mIntruderAlertView.applyIntruderContent(notification.notification.intruderView, listener); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 679 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 680 | mCurrentlyIntrudingNotification = notification; |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 681 | |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 682 | // 2. Animate mIntruderAlertView in |
| 683 | mHandler.sendEmptyMessage(MSG_SHOW_INTRUDER); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 684 | |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 685 | // 3. Set alarm to age the notification off (TODO) |
| 686 | mHandler.removeMessages(MSG_HIDE_INTRUDER); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 687 | if (INTRUDER_ALERT_DECAY_MS > 0) { |
| 688 | mHandler.sendEmptyMessageDelayed(MSG_HIDE_INTRUDER, INTRUDER_ALERT_DECAY_MS); |
| 689 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 690 | } else |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 691 | */ |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 692 | |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 693 | if (notification.notification.fullScreenIntent != null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 694 | // not immersive & a full-screen alert should be shown |
Daniel Sandler | 8355e93 | 2011-08-11 00:27:45 -0400 | [diff] [blame] | 695 | Slog.d(TAG, "Notification has fullScreenIntent; sending fullScreenIntent"); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 696 | try { |
| 697 | notification.notification.fullScreenIntent.send(); |
| 698 | } catch (PendingIntent.CanceledException e) { |
| 699 | } |
| 700 | } else { |
| 701 | // usual case: status bar visible & not immersive |
| 702 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 703 | // show the ticker if there isn't an intruder too |
| 704 | if (mCurrentlyIntrudingNotification == null) { |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 705 | tick(null, notification, true); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 706 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | // Recalculate the position of the sliding windows and the titles. |
| 710 | setAreThereNotifications(); |
| 711 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
| 712 | } |
| 713 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 714 | public void removeNotification(IBinder key) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 715 | StatusBarNotification old = removeNotificationViews(key); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 716 | if (SPEW) Slog.d(TAG, "removeNotification key=" + key + " old=" + old); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 717 | |
| 718 | if (old != null) { |
| 719 | // Cancel the ticker if it's still running |
| 720 | mTicker.removeEntry(old); |
| 721 | |
| 722 | // Recalculate the position of the sliding windows and the titles. |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 723 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 724 | |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 725 | if (ENABLE_INTRUDERS && old == mCurrentlyIntrudingNotification) { |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 726 | mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); |
| 727 | } |
Daniel Sandler | 8cc36e5 | 2011-10-17 14:18:46 -0400 | [diff] [blame] | 728 | |
| 729 | if (CLOSE_PANEL_WHEN_EMPTIED && mNotificationData.size() == 0 && !mAnimating) { |
| 730 | animateCollapse(); |
| 731 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 732 | } |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 733 | |
| 734 | setAreThereNotifications(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 735 | } |
| 736 | |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 737 | @Override |
| 738 | protected void onConfigurationChanged(Configuration newConfig) { |
Jim Miller | 17dfec7 | 2011-07-08 19:09:55 -0700 | [diff] [blame] | 739 | updateRecentsPanel(); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 740 | mShowSearchHoldoff = mContext.getResources().getInteger( |
| 741 | R.integer.config_show_search_delay); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 742 | } |
| 743 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 744 | private void loadNotificationShade() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 745 | if (mPile == null) return; |
| 746 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 747 | int N = mNotificationData.size(); |
| 748 | |
| 749 | ArrayList<View> toShow = new ArrayList<View>(); |
| 750 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 751 | final boolean provisioned = isDeviceProvisioned(); |
| 752 | // 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] | 753 | for (int i=0; i<N; i++) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 754 | Entry ent = mNotificationData.get(N-i-1); |
| 755 | if (provisioned || "android".equals(ent.notification.pkg)) { |
| 756 | toShow.add(ent.row); |
| 757 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 758 | } |
| 759 | |
| 760 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 761 | for (int i=0; i<mPile.getChildCount(); i++) { |
| 762 | View child = mPile.getChildAt(i); |
| 763 | if (!toShow.contains(child)) { |
| 764 | toRemove.add(child); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 765 | } |
| 766 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 767 | |
| 768 | for (View remove : toRemove) { |
| 769 | mPile.removeView(remove); |
| 770 | } |
| 771 | |
| 772 | for (int i=0; i<toShow.size(); i++) { |
| 773 | View v = toShow.get(i); |
| 774 | if (v.getParent() == null) { |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 775 | mPile.addView(v, i); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 776 | } |
| 777 | } |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 778 | |
| 779 | mSettingsButton.setEnabled(isDeviceProvisioned()); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 780 | } |
| 781 | |
| 782 | private void reloadAllNotificationIcons() { |
| 783 | if (mNotificationIcons == null) return; |
| 784 | mNotificationIcons.removeAllViews(); |
| 785 | updateNotificationIcons(); |
| 786 | } |
| 787 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 788 | @Override |
| 789 | protected void updateNotificationIcons() { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 790 | if (mNotificationIcons == null) return; |
| 791 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 792 | loadNotificationShade(); |
| 793 | |
| 794 | final LinearLayout.LayoutParams params |
| 795 | = new LinearLayout.LayoutParams(mIconSize + 2*mIconHPadding, mNaturalBarHeight); |
| 796 | |
| 797 | int N = mNotificationData.size(); |
| 798 | |
| 799 | if (DEBUG) { |
| 800 | Slog.d(TAG, "refreshing icons: " + N + " notifications, mNotificationIcons=" + mNotificationIcons); |
| 801 | } |
| 802 | |
| 803 | ArrayList<View> toShow = new ArrayList<View>(); |
| 804 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 805 | final boolean provisioned = isDeviceProvisioned(); |
| 806 | // 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] | 807 | for (int i=0; i<N; i++) { |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 808 | Entry ent = mNotificationData.get(N-i-1); |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 809 | if ((provisioned && ent.notification.score >= HIDE_ICONS_BELOW_SCORE) |
| 810 | || "android".equals(ent.notification.pkg)) { |
Daniel Sandler | 58b173b | 2012-05-03 11:25:29 -0400 | [diff] [blame] | 811 | toShow.add(ent.icon); |
| 812 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 813 | } |
| 814 | |
| 815 | ArrayList<View> toRemove = new ArrayList<View>(); |
| 816 | for (int i=0; i<mNotificationIcons.getChildCount(); i++) { |
| 817 | View child = mNotificationIcons.getChildAt(i); |
| 818 | if (!toShow.contains(child)) { |
| 819 | toRemove.add(child); |
| 820 | } |
| 821 | } |
| 822 | |
| 823 | for (View remove : toRemove) { |
| 824 | mNotificationIcons.removeView(remove); |
| 825 | } |
| 826 | |
| 827 | for (int i=0; i<toShow.size(); i++) { |
| 828 | View v = toShow.get(i); |
| 829 | if (v.getParent() == null) { |
| 830 | mNotificationIcons.addView(v, i, params); |
| 831 | } |
| 832 | } |
| 833 | } |
| 834 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 835 | @Override |
| 836 | protected void setAreThereNotifications() { |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 837 | final boolean any = mNotificationData.size() > 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 838 | |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 839 | final boolean clearable = any && mNotificationData.hasClearableItems(); |
| 840 | |
| 841 | if (DEBUG) { |
| 842 | Slog.d(TAG, "setAreThereNotifications: N=" + mNotificationData.size() |
| 843 | + " any=" + any + " clearable=" + clearable); |
| 844 | } |
| 845 | |
| 846 | if (mClearButton.isShown()) { |
| 847 | if (clearable != (mClearButton.getAlpha() == 1.0f)) { |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 848 | ObjectAnimator clearAnimation = ObjectAnimator.ofFloat( |
| 849 | mClearButton, "alpha", clearable ? 1.0f : 0.0f).setDuration(250); |
| 850 | clearAnimation.addListener(new AnimatorListenerAdapter() { |
| 851 | @Override |
| 852 | public void onAnimationEnd(Animator animation) { |
| 853 | if (mClearButton.getAlpha() <= 0.0f) { |
| 854 | mClearButton.setVisibility(View.INVISIBLE); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | @Override |
| 859 | public void onAnimationStart(Animator animation) { |
| 860 | if (mClearButton.getAlpha() <= 0.0f) { |
| 861 | mClearButton.setVisibility(View.VISIBLE); |
| 862 | } |
| 863 | } |
| 864 | }); |
| 865 | clearAnimation.start(); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 866 | } |
| 867 | } else { |
| 868 | mClearButton.setAlpha(clearable ? 1.0f : 0.0f); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 869 | mClearButton.setVisibility(clearable ? View.VISIBLE : View.INVISIBLE); |
Daniel Sandler | 0761e4c | 2011-08-11 00:19:49 -0400 | [diff] [blame] | 870 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 871 | mClearButton.setEnabled(clearable); |
Romain Guy | 8900e63 | 2012-05-25 12:08:39 -0700 | [diff] [blame] | 872 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 873 | final View nlo = mStatusBarView.findViewById(R.id.notification_lights_out); |
| 874 | final boolean showDot = (any&&!areLightsOn()); |
| 875 | if (showDot != (nlo.getAlpha() == 1.0f)) { |
| 876 | if (showDot) { |
| 877 | nlo.setAlpha(0f); |
| 878 | nlo.setVisibility(View.VISIBLE); |
| 879 | } |
| 880 | nlo.animate() |
| 881 | .alpha(showDot?1:0) |
| 882 | .setDuration(showDot?750:250) |
| 883 | .setInterpolator(new AccelerateInterpolator(2.0f)) |
| 884 | .setListener(showDot ? null : new AnimatorListenerAdapter() { |
| 885 | @Override |
| 886 | public void onAnimationEnd(Animator _a) { |
| 887 | nlo.setVisibility(View.GONE); |
| 888 | } |
| 889 | }) |
| 890 | .start(); |
| 891 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 892 | } |
| 893 | |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 894 | public void showClock(boolean show) { |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 895 | if (mStatusBarView == null) return; |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 896 | View clock = mStatusBarView.findViewById(R.id.clock); |
| 897 | if (clock != null) { |
| 898 | clock.setVisibility(show ? View.VISIBLE : View.GONE); |
| 899 | } |
| 900 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 901 | |
| 902 | /** |
| 903 | * State is one or more of the DISABLE constants from StatusBarManager. |
| 904 | */ |
| 905 | public void disable(int state) { |
| 906 | final int old = mDisabled; |
| 907 | final int diff = state ^ old; |
| 908 | mDisabled = state; |
| 909 | |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 910 | if (DEBUG) { |
| 911 | Slog.d(TAG, String.format("disable: 0x%08x -> 0x%08x (diff: 0x%08x)", |
| 912 | old, state, diff)); |
| 913 | } |
| 914 | |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 915 | StringBuilder flagdbg = new StringBuilder(); |
| 916 | flagdbg.append("disable: < "); |
| 917 | flagdbg.append(((state & StatusBarManager.DISABLE_EXPAND) != 0) ? "EXPAND" : "expand"); |
| 918 | flagdbg.append(((diff & StatusBarManager.DISABLE_EXPAND) != 0) ? "* " : " "); |
| 919 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "ICONS" : "icons"); |
| 920 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) ? "* " : " "); |
| 921 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "ALERTS" : "alerts"); |
| 922 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_ALERTS) != 0) ? "* " : " "); |
| 923 | flagdbg.append(((state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "TICKER" : "ticker"); |
| 924 | flagdbg.append(((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) ? "* " : " "); |
| 925 | flagdbg.append(((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "SYSTEM_INFO" : "system_info"); |
| 926 | flagdbg.append(((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 927 | flagdbg.append(((state & StatusBarManager.DISABLE_BACK) != 0) ? "BACK" : "back"); |
| 928 | flagdbg.append(((diff & StatusBarManager.DISABLE_BACK) != 0) ? "* " : " "); |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 929 | flagdbg.append(((state & StatusBarManager.DISABLE_HOME) != 0) ? "HOME" : "home"); |
| 930 | flagdbg.append(((diff & StatusBarManager.DISABLE_HOME) != 0) ? "* " : " "); |
| 931 | flagdbg.append(((state & StatusBarManager.DISABLE_RECENT) != 0) ? "RECENT" : "recent"); |
| 932 | flagdbg.append(((diff & StatusBarManager.DISABLE_RECENT) != 0) ? "* " : " "); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 933 | flagdbg.append(((state & StatusBarManager.DISABLE_CLOCK) != 0) ? "CLOCK" : "clock"); |
| 934 | flagdbg.append(((diff & StatusBarManager.DISABLE_CLOCK) != 0) ? "* " : " "); |
| 935 | flagdbg.append(">"); |
| 936 | Slog.d(TAG, flagdbg.toString()); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 937 | |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 938 | if ((diff & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
| 939 | mIcons.animate().cancel(); |
| 940 | if ((state & StatusBarManager.DISABLE_SYSTEM_INFO) != 0) { |
Romain Guy | f7f16f7 | 2012-05-24 19:13:56 -0700 | [diff] [blame] | 941 | mIcons.animate().alpha(0f).setStartDelay(100).setDuration(200). |
| 942 | setListener(mMakeIconsInvisible).start(); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 943 | } else { |
Romain Guy | f7f16f7 | 2012-05-24 19:13:56 -0700 | [diff] [blame] | 944 | mIcons.animate().alpha(1f).setStartDelay(0).setDuration(300). |
| 945 | setListener(mMakeIconsVisible).start(); |
Daniel Sandler | 8e18dc7 | 2012-05-17 00:44:59 -0400 | [diff] [blame] | 946 | } |
| 947 | } |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 948 | |
Jeff Sharkey | f52c70b | 2011-08-30 22:05:47 -0700 | [diff] [blame] | 949 | if ((diff & StatusBarManager.DISABLE_CLOCK) != 0) { |
| 950 | boolean show = (state & StatusBarManager.DISABLE_CLOCK) == 0; |
| 951 | showClock(show); |
| 952 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 953 | if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 954 | if ((state & StatusBarManager.DISABLE_EXPAND) != 0) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 955 | animateCollapse(); |
| 956 | } |
| 957 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 958 | |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 959 | if ((diff & (StatusBarManager.DISABLE_HOME |
| 960 | | StatusBarManager.DISABLE_RECENT |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 961 | | StatusBarManager.DISABLE_BACK)) != 0) { |
| 962 | // the nav bar will take care of these |
Daniel Sandler | d9283b90 | 2011-09-14 21:42:00 -0400 | [diff] [blame] | 963 | if (mNavigationBarView != null) mNavigationBarView.setDisabledFlags(state); |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 964 | |
Daniel Sandler | dba9356 | 2011-10-06 16:39:58 -0400 | [diff] [blame] | 965 | if ((state & StatusBarManager.DISABLE_RECENT) != 0) { |
Daniel Sandler | 6da2b76 | 2011-09-14 16:04:59 -0400 | [diff] [blame] | 966 | // close recents if it's visible |
| 967 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 968 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 969 | } |
Daniel Sandler | e21f288 | 2011-08-18 10:14:59 -0400 | [diff] [blame] | 970 | } |
| 971 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 972 | if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 973 | if ((state & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 974 | if (mTicking) { |
| 975 | mTicker.halt(); |
| 976 | } else { |
| 977 | setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); |
| 978 | } |
| 979 | } else { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 980 | if (!mExpandedVisible) { |
| 981 | setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); |
| 982 | } |
| 983 | } |
| 984 | } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
| 985 | if (mTicking && (state & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 986 | mTicker.halt(); |
| 987 | } |
| 988 | } |
| 989 | } |
| 990 | |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 991 | @Override |
Michael Jurka | ecc395a | 2012-03-30 05:31:46 -0700 | [diff] [blame] | 992 | protected BaseStatusBar.H createHandler() { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 993 | return new PhoneStatusBar.H(); |
| 994 | } |
| 995 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 996 | /** |
| 997 | * All changes to the status bar and notifications funnel through here and are batched. |
| 998 | */ |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 999 | private class H extends BaseStatusBar.H { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1000 | public void handleMessage(Message m) { |
Michael Jurka | 7f2668c | 2012-03-27 07:49:52 -0700 | [diff] [blame] | 1001 | super.handleMessage(m); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1002 | switch (m.what) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1003 | case MSG_OPEN_NOTIFICATION_PANEL: |
| 1004 | animateExpand(); |
| 1005 | break; |
| 1006 | case MSG_CLOSE_NOTIFICATION_PANEL: |
| 1007 | animateCollapse(); |
| 1008 | break; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1009 | case MSG_SHOW_INTRUDER: |
| 1010 | setIntruderAlertVisibility(true); |
| 1011 | break; |
| 1012 | case MSG_HIDE_INTRUDER: |
| 1013 | setIntruderAlertVisibility(false); |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 1014 | mCurrentlyIntrudingNotification = null; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1020 | final Runnable mAnimationCallback = new Runnable() { |
| 1021 | @Override |
| 1022 | public void run() { |
| 1023 | doAnimation(mChoreographer.getFrameTimeNanos()); |
| 1024 | } |
| 1025 | }; |
| 1026 | |
| 1027 | final Runnable mRevealAnimationCallback = new Runnable() { |
| 1028 | @Override |
| 1029 | public void run() { |
| 1030 | doRevealAnimation(mChoreographer.getFrameTimeNanos()); |
| 1031 | } |
| 1032 | }; |
| 1033 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1034 | View.OnFocusChangeListener mFocusChangeListener = new View.OnFocusChangeListener() { |
| 1035 | public void onFocusChange(View v, boolean hasFocus) { |
| 1036 | // Because 'v' is a ViewGroup, all its children will be (un)selected |
| 1037 | // too, which allows marqueeing to work. |
| 1038 | v.setSelected(hasFocus); |
| 1039 | } |
| 1040 | }; |
| 1041 | |
| 1042 | private void makeExpandedVisible() { |
| 1043 | if (SPEW) Slog.d(TAG, "Make expanded visible: expanded visible=" + mExpandedVisible); |
| 1044 | if (mExpandedVisible) { |
| 1045 | return; |
| 1046 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1047 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1048 | mExpandedVisible = true; |
Daniel Sandler | 3ac558b | 2012-05-17 13:38:11 -0400 | [diff] [blame] | 1049 | mNotificationPanel.setVisibility(View.VISIBLE); |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 1050 | makeSlippery(mNavigationBarView, true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1051 | |
| 1052 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1053 | |
| 1054 | // Expand the window to encompass the full screen in anticipation of the drag. |
| 1055 | // This is only possible to do atomically because the status bar is at the top of the screen! |
| 1056 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams(); |
Daniel Sandler | 4391b0b | 2012-05-10 13:15:26 -0400 | [diff] [blame] | 1057 | lp.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 1058 | lp.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1059 | lp.height = ViewGroup.LayoutParams.MATCH_PARENT; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1060 | final WindowManager wm = WindowManagerImpl.getDefault(); |
| 1061 | wm.updateViewLayout(mStatusBarWindow, lp); |
| 1062 | |
| 1063 | visibilityChanged(true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1064 | } |
| 1065 | |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 1066 | private static void makeSlippery(View view, boolean slippery) { |
Raph Levien | 311a961 | 2012-06-01 12:02:13 -0700 | [diff] [blame] | 1067 | if (view == null) { |
| 1068 | return; |
| 1069 | } |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 1070 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) view.getLayoutParams(); |
| 1071 | if (slippery) { |
| 1072 | lp.flags |= WindowManager.LayoutParams.FLAG_SLIPPERY; |
| 1073 | } else { |
| 1074 | lp.flags &= ~WindowManager.LayoutParams.FLAG_SLIPPERY; |
| 1075 | } |
| 1076 | WindowManagerImpl.getDefault().updateViewLayout(view, lp); |
| 1077 | } |
| 1078 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1079 | public void animateExpand() { |
| 1080 | if (SPEW) Slog.d(TAG, "Animate expand: expanded=" + mExpanded); |
| 1081 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1082 | return ; |
| 1083 | } |
| 1084 | if (mExpanded) { |
| 1085 | return; |
| 1086 | } |
| 1087 | |
| 1088 | prepareTracking(0, true); |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1089 | performFling(0, mSelfExpandVelocityPx, true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | public void animateCollapse() { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1093 | animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1094 | } |
| 1095 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1096 | public void animateCollapse(int flags) { |
| 1097 | animateCollapse(flags, 1.0f); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1098 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 1099 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1100 | public void animateCollapse(int flags, float velocityMultiplier) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1101 | if (SPEW) { |
| 1102 | Slog.d(TAG, "animateCollapse(): mExpanded=" + mExpanded |
| 1103 | + " mExpandedVisible=" + mExpandedVisible |
| 1104 | + " mExpanded=" + mExpanded |
| 1105 | + " mAnimating=" + mAnimating |
| 1106 | + " mAnimY=" + mAnimY |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1107 | + " mAnimVel=" + mAnimVel |
| 1108 | + " flags=" + flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1109 | } |
| 1110 | |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1111 | if ((flags & CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL) == 0) { |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1112 | mHandler.removeMessages(MSG_CLOSE_RECENTS_PANEL); |
| 1113 | mHandler.sendEmptyMessage(MSG_CLOSE_RECENTS_PANEL); |
| 1114 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1115 | |
| 1116 | if ((flags & CommandQueue.FLAG_EXCLUDE_SEARCH_PANEL) == 0) { |
| 1117 | mHandler.removeMessages(MSG_CLOSE_SEARCH_PANEL); |
| 1118 | mHandler.sendEmptyMessage(MSG_CLOSE_SEARCH_PANEL); |
| 1119 | } |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 1120 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1121 | if (!mExpandedVisible) { |
| 1122 | return; |
| 1123 | } |
| 1124 | |
| 1125 | int y; |
| 1126 | if (mAnimating) { |
| 1127 | y = (int)mAnimY; |
| 1128 | } else { |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1129 | y = getExpandedViewMaxHeight()-1; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1130 | } |
| 1131 | // Let the fling think that we're open so it goes in the right direction |
| 1132 | // and doesn't try to re-open the windowshade. |
| 1133 | mExpanded = true; |
| 1134 | prepareTracking(y, false); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1135 | performFling(y, -mSelfCollapseVelocityPx*velocityMultiplier, true); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1136 | } |
| 1137 | |
| 1138 | void performExpand() { |
| 1139 | if (SPEW) Slog.d(TAG, "performExpand: mExpanded=" + mExpanded); |
| 1140 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1141 | return ; |
| 1142 | } |
| 1143 | if (mExpanded) { |
| 1144 | return; |
| 1145 | } |
| 1146 | |
| 1147 | mExpanded = true; |
| 1148 | makeExpandedVisible(); |
| 1149 | updateExpandedViewPos(EXPANDED_FULL_OPEN); |
| 1150 | |
| 1151 | if (false) postStartTracing(); |
| 1152 | } |
| 1153 | |
| 1154 | void performCollapse() { |
| 1155 | if (SPEW) Slog.d(TAG, "performCollapse: mExpanded=" + mExpanded |
| 1156 | + " mExpandedVisible=" + mExpandedVisible); |
| 1157 | |
| 1158 | if (!mExpandedVisible) { |
| 1159 | return; |
| 1160 | } |
| 1161 | mExpandedVisible = false; |
| 1162 | visibilityChanged(false); |
Daniel Sandler | 3ac558b | 2012-05-17 13:38:11 -0400 | [diff] [blame] | 1163 | mNotificationPanel.setVisibility(View.INVISIBLE); |
Jim Miller | b490c3e | 2012-05-31 13:34:16 -0700 | [diff] [blame] | 1164 | makeSlippery(mNavigationBarView, false); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1165 | |
| 1166 | // Shrink the window to the size of the status bar only |
| 1167 | WindowManager.LayoutParams lp = (WindowManager.LayoutParams) mStatusBarWindow.getLayoutParams(); |
| 1168 | lp.height = getStatusBarHeight(); |
Daniel Sandler | 4391b0b | 2012-05-10 13:15:26 -0400 | [diff] [blame] | 1169 | lp.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; |
| 1170 | lp.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1171 | final WindowManager wm = WindowManagerImpl.getDefault(); |
| 1172 | wm.updateViewLayout(mStatusBarWindow, lp); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1173 | |
| 1174 | if ((mDisabled & StatusBarManager.DISABLE_NOTIFICATION_ICONS) == 0) { |
| 1175 | setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); |
| 1176 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1177 | |
| 1178 | if (!mExpanded) { |
| 1179 | return; |
| 1180 | } |
| 1181 | mExpanded = false; |
Daniel Sandler | 469e96e | 2012-05-04 15:56:19 -0400 | [diff] [blame] | 1182 | |
| 1183 | // Close any "App info" popups that might have snuck on-screen |
| 1184 | dismissPopups(); |
| 1185 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1186 | if (mPostCollapseCleanup != null) { |
| 1187 | mPostCollapseCleanup.run(); |
| 1188 | mPostCollapseCleanup = null; |
| 1189 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1190 | } |
| 1191 | |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1192 | void resetLastAnimTime() { |
| 1193 | mAnimLastTimeNanos = System.nanoTime(); |
| 1194 | if (SPEW) { |
| 1195 | Throwable t = new Throwable(); |
| 1196 | t.fillInStackTrace(); |
| 1197 | Slog.d(TAG, "resetting last anim time=" + mAnimLastTimeNanos, t); |
| 1198 | } |
| 1199 | } |
| 1200 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1201 | void doAnimation(long frameTimeNanos) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1202 | if (mAnimating) { |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1203 | if (SPEW) Slog.d(TAG, "doAnimation dt=" + (frameTimeNanos - mAnimLastTimeNanos)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1204 | if (SPEW) Slog.d(TAG, "doAnimation before mAnimY=" + mAnimY); |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1205 | incrementAnim(frameTimeNanos); |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1206 | if (SPEW) { |
| 1207 | Slog.d(TAG, "doAnimation after mAnimY=" + mAnimY); |
| 1208 | Slog.d(TAG, "doAnimation expandedViewMax=" + getExpandedViewMaxHeight()); |
| 1209 | } |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1210 | |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1211 | if (mAnimY >= getExpandedViewMaxHeight()-1 && !mClosing) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1212 | if (SPEW) Slog.d(TAG, "Animation completed to expanded state."); |
| 1213 | mAnimating = false; |
| 1214 | updateExpandedViewPos(EXPANDED_FULL_OPEN); |
| 1215 | performExpand(); |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1216 | return; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1217 | } |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1218 | |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1219 | if (mAnimY == 0 && mAnimAccel == 0 && mClosing) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1220 | if (SPEW) Slog.d(TAG, "Animation completed to collapsed state."); |
| 1221 | mAnimating = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1222 | performCollapse(); |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1223 | return; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1224 | } |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1225 | |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1226 | if (mAnimY < getStatusBarHeight() && mClosing) { |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1227 | // Draw one more frame with the bar positioned at the top of the screen |
| 1228 | // before ending the animation so that the user sees the bar in |
| 1229 | // its final position. The call to performCollapse() causes a window |
| 1230 | // relayout which takes time and might cause the animation to skip |
| 1231 | // on the very last frame before the bar disappears if we did it now. |
| 1232 | mAnimY = 0; |
| 1233 | mAnimAccel = 0; |
| 1234 | mAnimVel = 0; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1235 | } |
Jeff Brown | 6098c1f | 2012-05-03 16:56:20 -0700 | [diff] [blame] | 1236 | |
| 1237 | updateExpandedViewPos((int)mAnimY); |
| 1238 | mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, |
| 1239 | mAnimationCallback, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1240 | } |
| 1241 | } |
| 1242 | |
| 1243 | void stopTracking() { |
| 1244 | mTracking = false; |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1245 | mPile.setLayerType(View.LAYER_TYPE_NONE, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1246 | mVelocityTracker.recycle(); |
| 1247 | mVelocityTracker = null; |
Daniel Sandler | fc753d2 | 2012-05-08 13:56:44 -0400 | [diff] [blame] | 1248 | mCloseView.setPressed(false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1249 | } |
| 1250 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1251 | void incrementAnim(long frameTimeNanos) { |
| 1252 | final long deltaNanos = Math.max(frameTimeNanos - mAnimLastTimeNanos, 0); |
| 1253 | final float t = deltaNanos * 0.000000001f; // ns -> s |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1254 | final float y = mAnimY; |
| 1255 | final float v = mAnimVel; // px/s |
| 1256 | final float a = mAnimAccel; // px/s/s |
| 1257 | mAnimY = y + (v*t) + (0.5f*a*t*t); // px |
| 1258 | mAnimVel = v + (a*t); // px/s |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1259 | mAnimLastTimeNanos = frameTimeNanos; // ns |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1260 | //Slog.d(TAG, "y=" + y + " v=" + v + " a=" + a + " t=" + t + " mAnimY=" + mAnimY |
| 1261 | // + " mAnimAccel=" + mAnimAccel); |
| 1262 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1263 | |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1264 | void doRevealAnimation(long frameTimeNanos) { |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1265 | if (SPEW) { |
| 1266 | Slog.d(TAG, "doRevealAnimation: dt=" + (frameTimeNanos - mAnimLastTimeNanos)); |
| 1267 | } |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 1268 | final int h = getCloseViewHeight() + getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1269 | if (mAnimatingReveal && mAnimating && mAnimY < h) { |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1270 | incrementAnim(frameTimeNanos); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1271 | if (mAnimY >= h) { |
| 1272 | mAnimY = h; |
| 1273 | updateExpandedViewPos((int)mAnimY); |
| 1274 | } else { |
| 1275 | updateExpandedViewPos((int)mAnimY); |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1276 | mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, |
| 1277 | mRevealAnimationCallback, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1278 | } |
| 1279 | } |
| 1280 | } |
| 1281 | |
| 1282 | void prepareTracking(int y, boolean opening) { |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1283 | if (CHATTY) { |
| 1284 | Slog.d(TAG, "panel: beginning to track the user's touch, y=" + y + " opening=" + opening); |
| 1285 | } |
| 1286 | |
Daniel Sandler | fc753d2 | 2012-05-08 13:56:44 -0400 | [diff] [blame] | 1287 | mCloseView.setPressed(true); |
| 1288 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1289 | mTracking = true; |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1290 | mPile.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1291 | mVelocityTracker = VelocityTracker.obtain(); |
| 1292 | if (opening) { |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1293 | mAnimAccel = mExpandAccelPx; |
| 1294 | mAnimVel = mFlingExpandMinVelocityPx; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1295 | mAnimY = getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1296 | updateExpandedViewPos((int)mAnimY); |
| 1297 | mAnimating = true; |
| 1298 | mAnimatingReveal = true; |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1299 | resetLastAnimTime(); |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1300 | mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, |
| 1301 | mAnimationCallback, null); |
| 1302 | mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, |
| 1303 | mRevealAnimationCallback, null); |
| 1304 | mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, |
| 1305 | mRevealAnimationCallback, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1306 | makeExpandedVisible(); |
| 1307 | } else { |
| 1308 | // it's open, close it? |
| 1309 | if (mAnimating) { |
| 1310 | mAnimating = false; |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1311 | mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, |
| 1312 | mAnimationCallback, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1313 | } |
| 1314 | updateExpandedViewPos(y + mViewDelta); |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | void performFling(int y, float vel, boolean always) { |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1319 | if (CHATTY) { |
| 1320 | Slog.d(TAG, "panel: will fling, y=" + y + " vel=" + vel); |
| 1321 | } |
| 1322 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1323 | mAnimatingReveal = false; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1324 | |
| 1325 | mAnimY = y; |
| 1326 | mAnimVel = vel; |
| 1327 | |
| 1328 | //Slog.d(TAG, "starting with mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel); |
| 1329 | |
| 1330 | if (mExpanded) { |
| 1331 | if (!always && ( |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1332 | vel > mFlingCollapseMinVelocityPx |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1333 | || (y > (getExpandedViewMaxHeight()*(1f-mCollapseMinDisplayFraction)) && |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1334 | vel > -mFlingExpandMinVelocityPx))) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1335 | // We are expanded, but they didn't move sufficiently to cause |
| 1336 | // us to retract. Animate back to the expanded position. |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1337 | mAnimAccel = mExpandAccelPx; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1338 | if (vel < 0) { |
| 1339 | mAnimVel = 0; |
| 1340 | } |
| 1341 | } |
| 1342 | else { |
| 1343 | // We are expanded and are now going to animate away. |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1344 | mAnimAccel = -mCollapseAccelPx; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1345 | if (vel > 0) { |
| 1346 | mAnimVel = 0; |
| 1347 | } |
| 1348 | } |
| 1349 | } else { |
| 1350 | if (always || ( |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1351 | vel > mFlingExpandMinVelocityPx |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1352 | || (y > (getExpandedViewMaxHeight()*(1f-mExpandMinDisplayFraction)) && |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1353 | vel > -mFlingCollapseMinVelocityPx))) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1354 | // We are collapsed, and they moved enough to allow us to |
| 1355 | // expand. Animate in the notifications. |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1356 | mAnimAccel = mExpandAccelPx; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1357 | if (vel < 0) { |
| 1358 | mAnimVel = 0; |
| 1359 | } |
| 1360 | } |
| 1361 | else { |
| 1362 | // We are collapsed, but they didn't move sufficiently to cause |
| 1363 | // us to retract. Animate back to the collapsed position. |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1364 | mAnimAccel = -mCollapseAccelPx; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1365 | if (vel > 0) { |
| 1366 | mAnimVel = 0; |
| 1367 | } |
| 1368 | } |
| 1369 | } |
| 1370 | //Slog.d(TAG, "mAnimY=" + mAnimY + " mAnimVel=" + mAnimVel |
| 1371 | // + " mAnimAccel=" + mAnimAccel); |
| 1372 | |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1373 | resetLastAnimTime(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1374 | mAnimating = true; |
Daniel Sandler | fbab8ae | 2012-05-09 02:06:29 -0400 | [diff] [blame] | 1375 | mClosing = mAnimAccel < 0; |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1376 | |
| 1377 | mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, |
| 1378 | mAnimationCallback, null); |
| 1379 | mChoreographer.removeCallbacks(Choreographer.CALLBACK_ANIMATION, |
| 1380 | mRevealAnimationCallback, null); |
| 1381 | mChoreographer.postCallback(Choreographer.CALLBACK_ANIMATION, |
| 1382 | mAnimationCallback, null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1383 | stopTracking(); |
| 1384 | } |
| 1385 | |
| 1386 | boolean interceptTouchEvent(MotionEvent event) { |
| 1387 | if (SPEW) { |
| 1388 | Slog.d(TAG, "Touch: rawY=" + event.getRawY() + " event=" + event + " mDisabled=" |
| 1389 | + mDisabled); |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1390 | } else if (CHATTY) { |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1391 | if (event.getAction() != MotionEvent.ACTION_MOVE) { |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1392 | Slog.d(TAG, String.format( |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1393 | "panel: %s at (%f, %f) mDisabled=0x%08x", |
| 1394 | MotionEvent.actionToString(event.getAction()), |
Daniel Sandler | 96e61c3c8 | 2011-08-04 22:49:06 -0400 | [diff] [blame] | 1395 | event.getRawX(), event.getRawY(), mDisabled)); |
| 1396 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1397 | } |
| 1398 | |
| 1399 | if ((mDisabled & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1400 | return false; |
| 1401 | } |
| 1402 | |
Jeff Brown | 68ebcdf | 2011-09-12 14:12:17 -0700 | [diff] [blame] | 1403 | final int action = event.getAction(); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1404 | final int statusBarSize = getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1405 | final int hitSize = statusBarSize*2; |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1406 | final int y = (int)event.getRawY(); |
Jeff Brown | 68ebcdf | 2011-09-12 14:12:17 -0700 | [diff] [blame] | 1407 | if (action == MotionEvent.ACTION_DOWN) { |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1408 | if (!areLightsOn()) { |
| 1409 | setLightsOn(true); |
| 1410 | } |
| 1411 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1412 | if (!mExpanded) { |
| 1413 | mViewDelta = statusBarSize - y; |
| 1414 | } else { |
Daniel Sandler | fc753d2 | 2012-05-08 13:56:44 -0400 | [diff] [blame] | 1415 | mCloseView.getLocationOnScreen(mAbsPos); |
| 1416 | mViewDelta = mAbsPos[1] + statusBarSize + getCloseViewHeight() - y; // XXX: not closeViewHeight, but paddingBottom from the 9patch |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1417 | } |
| 1418 | if ((!mExpanded && y < hitSize) || |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1419 | // @@ add taps outside the panel if it's not full-screen |
| 1420 | (mExpanded && y > (getExpandedViewMaxHeight()-hitSize))) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1421 | |
| 1422 | // We drop events at the edge of the screen to make the windowshade come |
| 1423 | // down by accident less, especially when pushing open a device with a keyboard |
| 1424 | // that rotates (like g1 and droid) |
| 1425 | int x = (int)event.getRawX(); |
| 1426 | final int edgeBorder = mEdgeBorder; |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1427 | if (x >= edgeBorder && x < mDisplayMetrics.widthPixels - edgeBorder) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1428 | prepareTracking(y, !mExpanded);// opening if we're not already fully visible |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 1429 | trackMovement(event); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1430 | } |
| 1431 | } |
| 1432 | } else if (mTracking) { |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 1433 | trackMovement(event); |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 1434 | final int minY = statusBarSize + getCloseViewHeight(); |
Jeff Brown | 68ebcdf | 2011-09-12 14:12:17 -0700 | [diff] [blame] | 1435 | if (action == MotionEvent.ACTION_MOVE) { |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 1436 | if (mAnimatingReveal && (y + mViewDelta) < minY) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1437 | // nothing |
| 1438 | } else { |
| 1439 | mAnimatingReveal = false; |
| 1440 | updateExpandedViewPos(y + mViewDelta); |
| 1441 | } |
Jeff Brown | 68ebcdf | 2011-09-12 14:12:17 -0700 | [diff] [blame] | 1442 | } else if (action == MotionEvent.ACTION_UP |
| 1443 | || action == MotionEvent.ACTION_CANCEL) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1444 | mVelocityTracker.computeCurrentVelocity(1000); |
| 1445 | |
| 1446 | float yVel = mVelocityTracker.getYVelocity(); |
| 1447 | boolean negative = yVel < 0; |
| 1448 | |
| 1449 | float xVel = mVelocityTracker.getXVelocity(); |
| 1450 | if (xVel < 0) { |
| 1451 | xVel = -xVel; |
| 1452 | } |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1453 | if (xVel > mFlingGestureMaxXVelocityPx) { |
| 1454 | xVel = mFlingGestureMaxXVelocityPx; // limit how much we care about the x axis |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1455 | } |
| 1456 | |
| 1457 | float vel = (float)Math.hypot(yVel, xVel); |
| 1458 | if (negative) { |
| 1459 | vel = -vel; |
| 1460 | } |
| 1461 | |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1462 | if (CHATTY) { |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 1463 | Slog.d(TAG, String.format("gesture: vraw=(%f,%f) vnorm=(%f,%f) vlinear=%f", |
| 1464 | mVelocityTracker.getXVelocity(), |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 1465 | mVelocityTracker.getYVelocity(), |
| 1466 | xVel, yVel, |
| 1467 | vel)); |
| 1468 | } |
| 1469 | |
Daniel Sandler | fe172cc | 2011-09-12 13:47:25 -0400 | [diff] [blame] | 1470 | performFling(y + mViewDelta, vel, false); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1471 | } |
| 1472 | |
| 1473 | } |
| 1474 | return false; |
| 1475 | } |
| 1476 | |
Jeff Brown | 911fe30 | 2011-09-12 14:21:17 -0700 | [diff] [blame] | 1477 | private void trackMovement(MotionEvent event) { |
| 1478 | // Add movement to velocity tracker using raw screen X and Y coordinates instead |
| 1479 | // of window coordinates because the window frame may be moving at the same time. |
| 1480 | float deltaX = event.getRawX() - event.getX(); |
| 1481 | float deltaY = event.getRawY() - event.getY(); |
| 1482 | event.offsetLocation(deltaX, deltaY); |
| 1483 | mVelocityTracker.addMovement(event); |
| 1484 | event.offsetLocation(-deltaX, -deltaY); |
| 1485 | } |
| 1486 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1487 | @Override // CommandQueue |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1488 | public void setNavigationIconHints(int hints) { |
| 1489 | if (hints == mNavigationIconHints) return; |
| 1490 | |
| 1491 | mNavigationIconHints = hints; |
| 1492 | |
| 1493 | if (mNavigationBarView != null) { |
| 1494 | mNavigationBarView.setNavigationIconHints(hints); |
| 1495 | } |
| 1496 | } |
| 1497 | |
| 1498 | @Override // CommandQueue |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1499 | public void setSystemUiVisibility(int vis, int mask) { |
| 1500 | final int oldVal = mSystemUiVisibility; |
| 1501 | final int newVal = (oldVal&~mask) | (vis&mask); |
| 1502 | final int diff = newVal ^ oldVal; |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1503 | |
| 1504 | if (diff != 0) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1505 | mSystemUiVisibility = newVal; |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1506 | |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1507 | if (0 != (diff & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { |
| 1508 | final boolean lightsOut = (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)); |
| 1509 | if (lightsOut) { |
| 1510 | animateCollapse(); |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1511 | if (mTicking) { |
| 1512 | mTicker.halt(); |
| 1513 | } |
Daniel Sandler | e137a1e | 2011-08-17 16:47:19 -0400 | [diff] [blame] | 1514 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1515 | |
Daniel Sandler | 69314e7 | 2011-08-20 00:31:08 -0400 | [diff] [blame] | 1516 | if (mNavigationBarView != null) { |
| 1517 | mNavigationBarView.setLowProfile(lightsOut); |
| 1518 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1519 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1520 | setStatusBarLowProfile(lightsOut); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1521 | } |
| 1522 | |
| 1523 | notifyUiVisibilityChanged(); |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1524 | } |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1525 | } |
| 1526 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1527 | private void setStatusBarLowProfile(boolean lightsOut) { |
| 1528 | if (mLightsOutAnimation == null) { |
| 1529 | final View notifications = mStatusBarView.findViewById(R.id.notification_icon_area); |
| 1530 | final View systemIcons = mStatusBarView.findViewById(R.id.statusIcons); |
| 1531 | final View signal = mStatusBarView.findViewById(R.id.signal_cluster); |
| 1532 | final View battery = mStatusBarView.findViewById(R.id.battery); |
| 1533 | final View clock = mStatusBarView.findViewById(R.id.clock); |
| 1534 | |
| 1535 | mLightsOutAnimation = new AnimatorSet(); |
| 1536 | mLightsOutAnimation.playTogether( |
| 1537 | ObjectAnimator.ofFloat(notifications, View.ALPHA, 0), |
| 1538 | ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 0), |
| 1539 | ObjectAnimator.ofFloat(signal, View.ALPHA, 0), |
| 1540 | ObjectAnimator.ofFloat(battery, View.ALPHA, 0.5f), |
| 1541 | ObjectAnimator.ofFloat(clock, View.ALPHA, 0.5f) |
| 1542 | ); |
| 1543 | mLightsOutAnimation.setDuration(750); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1544 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1545 | mLightsOnAnimation = new AnimatorSet(); |
| 1546 | mLightsOnAnimation.playTogether( |
| 1547 | ObjectAnimator.ofFloat(notifications, View.ALPHA, 1), |
| 1548 | ObjectAnimator.ofFloat(systemIcons, View.ALPHA, 1), |
| 1549 | ObjectAnimator.ofFloat(signal, View.ALPHA, 1), |
| 1550 | ObjectAnimator.ofFloat(battery, View.ALPHA, 1), |
| 1551 | ObjectAnimator.ofFloat(clock, View.ALPHA, 1) |
| 1552 | ); |
| 1553 | mLightsOnAnimation.setDuration(250); |
| 1554 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1555 | |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1556 | mLightsOutAnimation.cancel(); |
| 1557 | mLightsOnAnimation.cancel(); |
| 1558 | |
| 1559 | final Animator a = lightsOut ? mLightsOutAnimation : mLightsOnAnimation; |
| 1560 | a.start(); |
| 1561 | |
| 1562 | setAreThereNotifications(); |
| 1563 | } |
| 1564 | |
| 1565 | private boolean areLightsOn() { |
| 1566 | return 0 == (mSystemUiVisibility & View.SYSTEM_UI_FLAG_LOW_PROFILE); |
| 1567 | } |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1568 | |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1569 | public void setLightsOn(boolean on) { |
| 1570 | Log.v(TAG, "setLightsOn(" + on + ")"); |
| 1571 | if (on) { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1572 | setSystemUiVisibility(0, View.SYSTEM_UI_FLAG_LOW_PROFILE); |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1573 | } else { |
Dianne Hackborn | 3a3a6cf | 2012-03-26 10:24:04 -0700 | [diff] [blame] | 1574 | 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] | 1575 | } |
| 1576 | } |
| 1577 | |
| 1578 | private void notifyUiVisibilityChanged() { |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1579 | try { |
Daniel Sandler | 60ee256 | 2011-07-22 12:34:33 -0400 | [diff] [blame] | 1580 | mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); |
Daniel Sandler | 1d4d30a | 2011-04-28 12:35:29 -0400 | [diff] [blame] | 1581 | } catch (RemoteException ex) { |
| 1582 | } |
Joe Onorato | 9305647 | 2010-09-10 10:30:46 -0400 | [diff] [blame] | 1583 | } |
| 1584 | |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1585 | public void topAppWindowChanged(boolean showMenu) { |
| 1586 | if (DEBUG) { |
| 1587 | Slog.d(TAG, (showMenu?"showing":"hiding") + " the MENU button"); |
| 1588 | } |
| 1589 | if (mNavigationBarView != null) { |
Daniel Sandler | f1ebcee | 2011-09-15 16:02:56 -0400 | [diff] [blame] | 1590 | mNavigationBarView.setMenuVisibility(showMenu); |
Daniel Sandler | 5c8da94 | 2011-06-28 00:29:04 -0400 | [diff] [blame] | 1591 | } |
| 1592 | |
| 1593 | // See above re: lights-out policy for legacy apps. |
| 1594 | if (showMenu) setLightsOn(true); |
| 1595 | } |
| 1596 | |
Daniel Sandler | 328310c | 2011-09-23 15:56:52 -0400 | [diff] [blame] | 1597 | @Override |
| 1598 | public void setImeWindowStatus(IBinder token, int vis, int backDisposition) { |
| 1599 | boolean altBack = (backDisposition == InputMethodService.BACK_DISPOSITION_WILL_DISMISS) |
| 1600 | || ((vis & InputMethodService.IME_VISIBLE) != 0); |
| 1601 | |
| 1602 | mCommandQueue.setNavigationIconHints( |
| 1603 | altBack ? (mNavigationIconHints | StatusBarManager.NAVIGATION_HINT_BACK_ALT) |
| 1604 | : (mNavigationIconHints & ~StatusBarManager.NAVIGATION_HINT_BACK_ALT)); |
| 1605 | } |
| 1606 | |
Jeff Brown | 2992ea7 | 2011-01-28 22:04:14 -0800 | [diff] [blame] | 1607 | @Override |
| 1608 | public void setHardKeyboardStatus(boolean available, boolean enabled) { } |
Daniel Sandler | e02d808 | 2010-10-08 15:13:22 -0400 | [diff] [blame] | 1609 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1610 | private class NotificationClicker implements View.OnClickListener { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1611 | private PendingIntent mIntent; |
| 1612 | private String mPkg; |
| 1613 | private String mTag; |
| 1614 | private int mId; |
| 1615 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1616 | NotificationClicker(PendingIntent intent, String pkg, String tag, int id) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1617 | mIntent = intent; |
| 1618 | mPkg = pkg; |
| 1619 | mTag = tag; |
| 1620 | mId = id; |
| 1621 | } |
| 1622 | |
| 1623 | public void onClick(View v) { |
| 1624 | try { |
| 1625 | // The intent we are sending is for the application, which |
| 1626 | // won't have permission to immediately start an activity after |
| 1627 | // the user switches to home. We know it is safe to do at this |
| 1628 | // point, so make sure new activity switches are now allowed. |
| 1629 | ActivityManagerNative.getDefault().resumeAppSwitches(); |
Dianne Hackborn | 90c52de | 2011-09-23 12:57:44 -0700 | [diff] [blame] | 1630 | // Also, notifications can be launched from the lock screen, |
| 1631 | // so dismiss the lock screen when the activity starts. |
| 1632 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1633 | } catch (RemoteException e) { |
| 1634 | } |
| 1635 | |
| 1636 | if (mIntent != null) { |
| 1637 | int[] pos = new int[2]; |
| 1638 | v.getLocationOnScreen(pos); |
| 1639 | Intent overlay = new Intent(); |
| 1640 | overlay.setSourceBounds( |
| 1641 | new Rect(pos[0], pos[1], pos[0]+v.getWidth(), pos[1]+v.getHeight())); |
| 1642 | try { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1643 | mIntent.send(mContext, 0, overlay); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1644 | } catch (PendingIntent.CanceledException e) { |
| 1645 | // the stack trace isn't very helpful here. Just log the exception message. |
| 1646 | Slog.w(TAG, "Sending contentIntent failed: " + e); |
| 1647 | } |
Daniel Sandler | 92d3318 | 2011-09-11 16:29:05 -0400 | [diff] [blame] | 1648 | |
| 1649 | KeyguardManager kgm = |
| 1650 | (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE); |
| 1651 | if (kgm != null) kgm.exitKeyguardSecurely(null); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1652 | } |
| 1653 | |
| 1654 | try { |
| 1655 | mBarService.onNotificationClick(mPkg, mTag, mId); |
| 1656 | } catch (RemoteException ex) { |
| 1657 | // system process is dead if we're here. |
| 1658 | } |
| 1659 | |
| 1660 | // close the shade if it was open |
| 1661 | animateCollapse(); |
| 1662 | |
| 1663 | // If this click was on the intruder alert, hide that instead |
| 1664 | mHandler.sendEmptyMessage(MSG_HIDE_INTRUDER); |
| 1665 | } |
| 1666 | } |
| 1667 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1668 | @Override |
| 1669 | protected void tick(IBinder key, StatusBarNotification n, boolean firstTime) { |
Daniel Sandler | d7e9686 | 2012-04-26 01:10:29 -0400 | [diff] [blame] | 1670 | // no ticking in lights-out mode |
| 1671 | if (!areLightsOn()) return; |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 1672 | |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 1673 | // no ticking in Setup |
| 1674 | if (!isDeviceProvisioned()) return; |
| 1675 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1676 | // Show the ticker if one is requested. Also don't do this |
| 1677 | // until status bar window is attached to the window manager, |
| 1678 | // because... well, what's the point otherwise? And trying to |
| 1679 | // run a ticker without being attached will crash! |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1680 | if (n.notification.tickerText != null && mStatusBarWindow.getWindowToken() != null) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1681 | if (0 == (mDisabled & (StatusBarManager.DISABLE_NOTIFICATION_ICONS |
| 1682 | | StatusBarManager.DISABLE_NOTIFICATION_TICKER))) { |
| 1683 | mTicker.addEntry(n); |
| 1684 | } |
| 1685 | } |
| 1686 | } |
| 1687 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1688 | private class MyTicker extends Ticker { |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1689 | MyTicker(Context context, View sb) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1690 | super(context, sb); |
| 1691 | } |
| 1692 | |
| 1693 | @Override |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1694 | public void tickerStarting() { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1695 | mTicking = true; |
| 1696 | mIcons.setVisibility(View.GONE); |
| 1697 | mTickerView.setVisibility(View.VISIBLE); |
| 1698 | mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_up_in, null)); |
| 1699 | mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_up_out, null)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1700 | } |
| 1701 | |
| 1702 | @Override |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1703 | public void tickerDone() { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1704 | mIcons.setVisibility(View.VISIBLE); |
| 1705 | mTickerView.setVisibility(View.GONE); |
| 1706 | mIcons.startAnimation(loadAnim(com.android.internal.R.anim.push_down_in, null)); |
| 1707 | mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.push_down_out, |
| 1708 | mTickingDoneListener)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1709 | } |
| 1710 | |
Daniel Sandler | dfa08db | 2010-08-05 16:18:42 -0400 | [diff] [blame] | 1711 | public void tickerHalting() { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1712 | mIcons.setVisibility(View.VISIBLE); |
| 1713 | mTickerView.setVisibility(View.GONE); |
| 1714 | mIcons.startAnimation(loadAnim(com.android.internal.R.anim.fade_in, null)); |
| 1715 | mTickerView.startAnimation(loadAnim(com.android.internal.R.anim.fade_out, |
| 1716 | mTickingDoneListener)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1717 | } |
| 1718 | } |
| 1719 | |
| 1720 | Animation.AnimationListener mTickingDoneListener = new Animation.AnimationListener() {; |
| 1721 | public void onAnimationEnd(Animation animation) { |
| 1722 | mTicking = false; |
| 1723 | } |
| 1724 | public void onAnimationRepeat(Animation animation) { |
| 1725 | } |
| 1726 | public void onAnimationStart(Animation animation) { |
| 1727 | } |
| 1728 | }; |
| 1729 | |
| 1730 | private Animation loadAnim(int id, Animation.AnimationListener listener) { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1731 | Animation anim = AnimationUtils.loadAnimation(mContext, id); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1732 | if (listener != null) { |
| 1733 | anim.setAnimationListener(listener); |
| 1734 | } |
| 1735 | return anim; |
| 1736 | } |
| 1737 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1738 | public static String viewInfo(View v) { |
| 1739 | return "[(" + v.getLeft() + "," + v.getTop() + ")(" + v.getRight() + "," + v.getBottom() |
| 1740 | + ") " + v.getWidth() + "x" + v.getHeight() + "]"; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1741 | } |
| 1742 | |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 1743 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1744 | synchronized (mQueueLock) { |
| 1745 | pw.println("Current Status Bar state:"); |
| 1746 | pw.println(" mExpanded=" + mExpanded |
| 1747 | + ", mExpandedVisible=" + mExpandedVisible); |
| 1748 | pw.println(" mTicking=" + mTicking); |
| 1749 | pw.println(" mTracking=" + mTracking); |
| 1750 | pw.println(" mAnimating=" + mAnimating |
| 1751 | + ", mAnimY=" + mAnimY + ", mAnimVel=" + mAnimVel |
| 1752 | + ", mAnimAccel=" + mAnimAccel); |
Jeff Brown | ed5f45a | 2012-05-03 15:53:47 -0700 | [diff] [blame] | 1753 | pw.println(" mAnimLastTimeNanos=" + mAnimLastTimeNanos); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1754 | pw.println(" mAnimatingReveal=" + mAnimatingReveal |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1755 | + " mViewDelta=" + mViewDelta); |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1756 | pw.println(" mDisplayMetrics=" + mDisplayMetrics); |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 1757 | pw.println(" mPile: " + viewInfo(mPile)); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1758 | pw.println(" mCloseView: " + viewInfo(mCloseView)); |
| 1759 | pw.println(" mTickerView: " + viewInfo(mTickerView)); |
| 1760 | pw.println(" mScrollView: " + viewInfo(mScrollView) |
| 1761 | + " scroll " + mScrollView.getScrollX() + "," + mScrollView.getScrollY()); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1762 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1763 | |
Daniel Sandler | 4885295 | 2011-12-01 14:34:23 -0500 | [diff] [blame] | 1764 | pw.print(" mNavigationBarView="); |
| 1765 | if (mNavigationBarView == null) { |
| 1766 | pw.println("null"); |
| 1767 | } else { |
| 1768 | mNavigationBarView.dump(fd, pw, args); |
| 1769 | } |
| 1770 | |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 1771 | if (DUMPTRUCK) { |
| 1772 | synchronized (mNotificationData) { |
| 1773 | int N = mNotificationData.size(); |
| 1774 | pw.println(" notification icons: " + N); |
| 1775 | for (int i=0; i<N; i++) { |
| 1776 | NotificationData.Entry e = mNotificationData.get(i); |
| 1777 | pw.println(" [" + i + "] key=" + e.key + " icon=" + e.icon); |
| 1778 | StatusBarNotification n = e.notification; |
Daniel Sandler | 2561b0b | 2012-02-13 21:04:12 -0500 | [diff] [blame] | 1779 | pw.println(" pkg=" + n.pkg + " id=" + n.id + " score=" + n.score); |
Daniel Sandler | 7579bca | 2011-08-18 15:47:26 -0400 | [diff] [blame] | 1780 | pw.println(" notification=" + n.notification); |
| 1781 | pw.println(" tickerText=\"" + n.notification.tickerText + "\""); |
| 1782 | } |
| 1783 | } |
| 1784 | |
| 1785 | int N = mStatusIcons.getChildCount(); |
| 1786 | pw.println(" system icons: " + N); |
| 1787 | for (int i=0; i<N; i++) { |
| 1788 | StatusBarIconView ic = (StatusBarIconView) mStatusIcons.getChildAt(i); |
| 1789 | pw.println(" [" + i + "] icon=" + ic); |
| 1790 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 1791 | |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 1792 | if (false) { |
| 1793 | pw.println("see the logcat for a dump of the views we have created."); |
| 1794 | // must happen on ui thread |
| 1795 | mHandler.post(new Runnable() { |
| 1796 | public void run() { |
| 1797 | mStatusBarView.getLocationOnScreen(mAbsPos); |
| 1798 | Slog.d(TAG, "mStatusBarView: ----- (" + mAbsPos[0] + "," + mAbsPos[1] |
| 1799 | + ") " + mStatusBarView.getWidth() + "x" |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1800 | + getStatusBarHeight()); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 1801 | mStatusBarView.debug(); |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 1802 | } |
| 1803 | }); |
| 1804 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1805 | } |
Daniel Sandler | 89d9713 | 2011-09-08 15:31:57 -0400 | [diff] [blame] | 1806 | |
| 1807 | mNetworkController.dump(fd, pw, args); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1808 | } |
| 1809 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1810 | @Override |
| 1811 | public void createAndAddWindows() { |
| 1812 | addStatusBarWindow(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1813 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1814 | |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1815 | private void addStatusBarWindow() { |
| 1816 | // Put up the view |
| 1817 | final int height = getStatusBarHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1818 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1819 | // Now that the status bar window encompasses the sliding panel and its |
| 1820 | // translucent backdrop, the entire thing is made TRANSLUCENT and is |
| 1821 | // hardware-accelerated. |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1822 | final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( |
| 1823 | ViewGroup.LayoutParams.MATCH_PARENT, |
| 1824 | height, |
| 1825 | WindowManager.LayoutParams.TYPE_STATUS_BAR, |
| 1826 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
| 1827 | | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING |
| 1828 | | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH, |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1829 | PixelFormat.TRANSLUCENT); |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1830 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1831 | if (ActivityManager.isHighEndGfx(mDisplay)) { |
| 1832 | lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; |
| 1833 | } |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1834 | |
| 1835 | lp.gravity = getStatusBarGravity(); |
| 1836 | lp.setTitle("StatusBar"); |
| 1837 | lp.packageName = mContext.getPackageName(); |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1838 | |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1839 | makeStatusBarView(); |
| 1840 | WindowManagerImpl.getDefault().addView(mStatusBarWindow, lp); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1841 | } |
| 1842 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1843 | void setNotificationIconVisibility(boolean visible, int anim) { |
| 1844 | int old = mNotificationIcons.getVisibility(); |
| 1845 | int v = visible ? View.VISIBLE : View.INVISIBLE; |
| 1846 | if (old != v) { |
| 1847 | mNotificationIcons.setVisibility(v); |
| 1848 | mNotificationIcons.startAnimation(loadAnim(anim, null)); |
| 1849 | } |
| 1850 | } |
| 1851 | |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1852 | void updateExpandedInvisiblePosition() { |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1853 | mTrackingPosition = -mDisplayMetrics.heightPixels; |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1854 | } |
| 1855 | |
Daniel Sandler | 1fac1fd | 2012-04-30 12:07:30 -0400 | [diff] [blame] | 1856 | static final float saturate(float a) { |
| 1857 | return a < 0f ? 0f : (a > 1f ? 1f : a); |
| 1858 | } |
| 1859 | |
Chris Wren | 8fd1265 | 2012-05-09 21:25:57 -0400 | [diff] [blame] | 1860 | @Override |
| 1861 | protected int getExpandedViewMaxHeight() { |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1862 | return mDisplayMetrics.heightPixels - mNotificationPanelMarginBottomPx; |
| 1863 | } |
| 1864 | |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 1865 | @Override |
| 1866 | protected void updateExpandedViewPos(int expandedPosition) { |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1867 | if (SPEW) { |
| 1868 | Slog.d(TAG, "updateExpandedViewPos before expandedPosition=" + expandedPosition |
Daniel Sandler | c6d29fc | 2012-02-25 00:33:12 -0500 | [diff] [blame] | 1869 | //+ " mTrackingParams.y=" + ((mTrackingParams == null) ? "?" : mTrackingParams.y) |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1870 | + " mTrackingPosition=" + mTrackingPosition |
| 1871 | + " gravity=" + mNotificationPanelGravity); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1872 | } |
| 1873 | |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1874 | int panelh = 0; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1875 | final int disph = getExpandedViewMaxHeight(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1876 | |
| 1877 | // If the expanded view is not visible, make sure they're still off screen. |
| 1878 | // Maybe the view was resized. |
| 1879 | if (!mExpandedVisible) { |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1880 | updateExpandedInvisiblePosition(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1881 | return; |
| 1882 | } |
| 1883 | |
| 1884 | // tracking view... |
| 1885 | int pos; |
| 1886 | if (expandedPosition == EXPANDED_FULL_OPEN) { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1887 | panelh = disph; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1888 | } |
| 1889 | else if (expandedPosition == EXPANDED_LEAVE_ALONE) { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1890 | panelh = mTrackingPosition; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1891 | } |
| 1892 | else { |
| 1893 | if (expandedPosition <= disph) { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1894 | panelh = expandedPosition; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1895 | } else { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1896 | panelh = disph; |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1897 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1898 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1899 | |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1900 | // catch orientation changes and other peculiar cases |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1901 | if (panelh > disph || (panelh < disph && !mTracking && !mAnimating)) { |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1902 | panelh = disph; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1903 | } else if (panelh < 0) { |
| 1904 | panelh = 0; |
| 1905 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 1906 | |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1907 | mTrackingPosition = panelh; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1908 | |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1909 | FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mNotificationPanel.getLayoutParams(); |
Daniel Sandler | 079b33d | 2012-03-02 16:29:41 -0500 | [diff] [blame] | 1910 | lp.height = panelh; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1911 | lp.gravity = mNotificationPanelGravity; |
| 1912 | lp.leftMargin = mNotificationPanelMarginLeftPx; |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1913 | if (SPEW) { |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1914 | Slog.v(TAG, "updated cropView height=" + panelh + " grav=" + lp.gravity); |
Daniel Sandler | a310af8 | 2012-04-24 01:20:13 -0400 | [diff] [blame] | 1915 | } |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 1916 | mNotificationPanel.setLayoutParams(lp); |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 1917 | |
Daniel Sandler | fc753d2 | 2012-05-08 13:56:44 -0400 | [diff] [blame] | 1918 | if (DIM_BEHIND_EXPANDED_PANEL && ActivityManager.isHighEndGfx(mDisplay)) { |
Romain Guy | 328b358 | 2012-05-08 15:30:57 -0700 | [diff] [blame] | 1919 | // woo, special effects |
| 1920 | final int barh = getCloseViewHeight() + getStatusBarHeight(); |
| 1921 | final float frac = saturate((float)(panelh - barh) / (disph - barh)); |
| 1922 | final int color = ((int)(0xB0 * Math.sin(frac * 1.57f))) << 24; |
| 1923 | mStatusBarWindow.setBackgroundColor(color); |
| 1924 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1925 | } |
| 1926 | |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1927 | void updateDisplaySize() { |
Daniel Sandler | 36412a7 | 2011-08-04 09:35:13 -0400 | [diff] [blame] | 1928 | mDisplay.getMetrics(mDisplayMetrics); |
Dianne Hackborn | 1dacf27 | 2011-08-02 15:01:22 -0700 | [diff] [blame] | 1929 | } |
| 1930 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1931 | void performDisableActions(int net) { |
| 1932 | int old = mDisabled; |
| 1933 | int diff = net ^ old; |
| 1934 | mDisabled = net; |
| 1935 | |
| 1936 | // act accordingly |
| 1937 | if ((diff & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1938 | if ((net & StatusBarManager.DISABLE_EXPAND) != 0) { |
| 1939 | Slog.d(TAG, "DISABLE_EXPAND: yes"); |
| 1940 | animateCollapse(); |
| 1941 | } |
| 1942 | } |
| 1943 | if ((diff & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 1944 | if ((net & StatusBarManager.DISABLE_NOTIFICATION_ICONS) != 0) { |
| 1945 | Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: yes"); |
| 1946 | if (mTicking) { |
| 1947 | mNotificationIcons.setVisibility(View.INVISIBLE); |
| 1948 | mTicker.halt(); |
| 1949 | } else { |
| 1950 | setNotificationIconVisibility(false, com.android.internal.R.anim.fade_out); |
| 1951 | } |
| 1952 | } else { |
| 1953 | Slog.d(TAG, "DISABLE_NOTIFICATION_ICONS: no"); |
| 1954 | if (!mExpandedVisible) { |
| 1955 | setNotificationIconVisibility(true, com.android.internal.R.anim.fade_in); |
| 1956 | } |
| 1957 | } |
| 1958 | } else if ((diff & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
| 1959 | if (mTicking && (net & StatusBarManager.DISABLE_NOTIFICATION_TICKER) != 0) { |
| 1960 | mTicker.halt(); |
| 1961 | } |
| 1962 | } |
| 1963 | } |
| 1964 | |
| 1965 | private View.OnClickListener mClearButtonListener = new View.OnClickListener() { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1966 | final int mini(int a, int b) { |
| 1967 | return (b>a?a:b); |
| 1968 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 1969 | public void onClick(View v) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1970 | synchronized (mNotificationData) { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1971 | // animate-swipe all dismissable notifications, then animate the shade closed |
| 1972 | int numChildren = mPile.getChildCount(); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1973 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1974 | int scrollTop = mScrollView.getScrollY(); |
| 1975 | int scrollBottom = scrollTop + mScrollView.getHeight(); |
| 1976 | final ArrayList<View> snapshot = new ArrayList<View>(numChildren); |
| 1977 | for (int i=0; i<numChildren; i++) { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1978 | final View child = mPile.getChildAt(i); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1979 | if (mPile.canChildBeDismissed(child) && child.getBottom() > scrollTop && |
| 1980 | child.getTop() < scrollBottom) { |
| 1981 | snapshot.add(child); |
| 1982 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1983 | } |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 1984 | if (snapshot.isEmpty()) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 1985 | animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 1986 | return; |
| 1987 | } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1988 | new Thread(new Runnable() { |
| 1989 | @Override |
| 1990 | public void run() { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1991 | // Decrease the delay for every row we animate to give the sense of |
| 1992 | // accelerating the swipes |
| 1993 | final int ROW_DELAY_DECREMENT = 10; |
| 1994 | int currentDelay = 140; |
| 1995 | int totalDelay = 0; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 1996 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 1997 | // Set the shade-animating state to avoid doing other work during |
| 1998 | // all of these animations. In particular, avoid layout and |
| 1999 | // redrawing when collapsing the shade. |
| 2000 | mPile.setViewRemoval(false); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2001 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2002 | mPostCollapseCleanup = new Runnable() { |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2003 | @Override |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2004 | public void run() { |
| 2005 | try { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2006 | mPile.setViewRemoval(true); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2007 | mBarService.onClearAllNotifications(); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2008 | } catch (Exception ex) { } |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2009 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2010 | }; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2011 | |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2012 | View sampleView = snapshot.get(0); |
| 2013 | int width = sampleView.getWidth(); |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2014 | final int velocity = width * 8; // 1000/8 = 125 ms duration |
| 2015 | for (final View _v : snapshot) { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2016 | mHandler.postDelayed(new Runnable() { |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2017 | @Override |
| 2018 | public void run() { |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2019 | mPile.dismissRowAnimated(_v, velocity); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2020 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2021 | }, totalDelay); |
| 2022 | currentDelay = Math.max(50, currentDelay - ROW_DELAY_DECREMENT); |
| 2023 | totalDelay += currentDelay; |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2024 | } |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2025 | // Delay the collapse animation until after all swipe animations have |
| 2026 | // finished. Provide some buffer because there may be some extra delay |
| 2027 | // before actually starting each swipe animation. Ideally, we'd |
| 2028 | // synchronize the end of those animations with the start of the collaps |
| 2029 | // exactly. |
| 2030 | mHandler.postDelayed(new Runnable() { |
Craig Mautner | 93a035c | 2012-04-09 15:23:59 -0700 | [diff] [blame] | 2031 | @Override |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2032 | public void run() { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2033 | animateCollapse(CommandQueue.FLAG_EXCLUDE_NONE); |
Chet Haase | 2f2022a | 2011-10-11 06:41:59 -0700 | [diff] [blame] | 2034 | } |
| 2035 | }, totalDelay + 225); |
Daniel Sandler | 8ba33c9 | 2011-10-04 21:49:30 -0400 | [diff] [blame] | 2036 | } |
| 2037 | }).start(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2038 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2039 | } |
| 2040 | }; |
| 2041 | |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 2042 | private View.OnClickListener mSettingsButtonListener = new View.OnClickListener() { |
| 2043 | public void onClick(View v) { |
Daniel Sandler | 26cda27 | 2012-05-22 15:44:08 -0400 | [diff] [blame] | 2044 | // We take this as a good indicator that Setup is running and we shouldn't |
| 2045 | // allow you to go somewhere else |
| 2046 | if (!isDeviceProvisioned()) return; |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2047 | try { |
| 2048 | // Dismiss the lock screen when Settings starts. |
| 2049 | ActivityManagerNative.getDefault().dismissKeyguardOnNextActivity(); |
| 2050 | } catch (RemoteException e) { |
| 2051 | } |
Daniel Sandler | d309056 | 2011-08-09 00:28:44 -0400 | [diff] [blame] | 2052 | v.getContext().startActivity(new Intent(Settings.ACTION_SETTINGS) |
| 2053 | .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); |
| 2054 | animateCollapse(); |
| 2055 | } |
| 2056 | }; |
| 2057 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2058 | private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 2059 | public void onReceive(Context context, Intent intent) { |
| 2060 | String action = intent.getAction(); |
| 2061 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action) |
| 2062 | || Intent.ACTION_SCREEN_OFF.equals(action)) { |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2063 | int flags = CommandQueue.FLAG_EXCLUDE_NONE; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2064 | if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(action)) { |
Daniel Sandler | edbdd3a | 2011-06-21 12:57:08 -0400 | [diff] [blame] | 2065 | String reason = intent.getStringExtra("reason"); |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2066 | if (reason != null && reason.equals(SYSTEM_DIALOG_REASON_RECENT_APPS)) { |
| 2067 | flags |= CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL; |
Michael Jurka | 3b1fc47 | 2011-06-13 10:54:40 -0700 | [diff] [blame] | 2068 | } |
| 2069 | } |
Jim Miller | 9a720f5 | 2012-05-30 03:19:43 -0700 | [diff] [blame] | 2070 | animateCollapse(flags); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2071 | } |
| 2072 | else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { |
| 2073 | updateResources(); |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2074 | repositionNavigationBar(); |
| 2075 | updateExpandedViewPos(EXPANDED_LEAVE_ALONE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2076 | } |
| 2077 | } |
| 2078 | }; |
| 2079 | |
| 2080 | private void setIntruderAlertVisibility(boolean vis) { |
Daniel Sandler | 6b31880 | 2012-04-13 14:05:19 -0400 | [diff] [blame] | 2081 | if (!ENABLE_INTRUDERS) return; |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2082 | if (DEBUG) { |
| 2083 | Slog.v(TAG, (vis ? "showing" : "hiding") + " intruder alert window"); |
| 2084 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2085 | mIntruderAlertView.setVisibility(vis ? View.VISIBLE : View.GONE); |
| 2086 | } |
| 2087 | |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2088 | public void dismissIntruder() { |
| 2089 | if (mCurrentlyIntrudingNotification == null) return; |
| 2090 | |
| 2091 | try { |
| 2092 | mBarService.onNotificationClear( |
| 2093 | mCurrentlyIntrudingNotification.pkg, |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2094 | mCurrentlyIntrudingNotification.tag, |
Daniel Sandler | fa7887b | 2012-03-26 09:43:31 -0400 | [diff] [blame] | 2095 | mCurrentlyIntrudingNotification.id); |
| 2096 | } catch (android.os.RemoteException ex) { |
| 2097 | // oh well |
| 2098 | } |
| 2099 | } |
Jim Miller | e898ac5 | 2012-04-06 17:10:57 -0700 | [diff] [blame] | 2100 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2101 | /** |
| 2102 | * Reload some of our resources when the configuration changes. |
| 2103 | * |
| 2104 | * We don't reload everything when the configuration changes -- we probably |
| 2105 | * should, but getting that smooth is tough. Someday we'll fix that. In the |
| 2106 | * meantime, just update the things that we know change. |
| 2107 | */ |
| 2108 | void updateResources() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2109 | final Context context = mContext; |
| 2110 | final Resources res = context.getResources(); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2111 | |
Daniel Sandler | 1347c30 | 2011-08-01 16:47:53 -0400 | [diff] [blame] | 2112 | if (mClearButton instanceof TextView) { |
| 2113 | ((TextView)mClearButton).setText(context.getText(R.string.status_bar_clear_all_button)); |
| 2114 | } |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 2115 | loadDimens(); |
| 2116 | } |
Jim Miller | 5e6af44 | 2011-12-02 18:24:26 -0800 | [diff] [blame] | 2117 | |
Daniel Sandler | 7c3e39d | 2011-07-29 16:30:49 -0400 | [diff] [blame] | 2118 | protected void loadDimens() { |
| 2119 | final Resources res = mContext.getResources(); |
| 2120 | |
| 2121 | mNaturalBarHeight = res.getDimensionPixelSize( |
| 2122 | com.android.internal.R.dimen.status_bar_height); |
| 2123 | |
| 2124 | int newIconSize = res.getDimensionPixelSize( |
| 2125 | com.android.internal.R.dimen.status_bar_icon_size); |
| 2126 | int newIconHPadding = res.getDimensionPixelSize( |
| 2127 | R.dimen.status_bar_icon_padding); |
| 2128 | |
| 2129 | if (newIconHPadding != mIconHPadding || newIconSize != mIconSize) { |
| 2130 | // Slog.d(TAG, "size=" + newIconSize + " padding=" + newIconHPadding); |
| 2131 | mIconHPadding = newIconHPadding; |
| 2132 | mIconSize = newIconSize; |
| 2133 | //reloadAllNotificationIcons(); // reload the tray |
| 2134 | } |
| 2135 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2136 | mEdgeBorder = res.getDimensionPixelSize(R.dimen.status_bar_edge_ignore); |
| 2137 | |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 2138 | mSelfExpandVelocityPx = res.getDimension(R.dimen.self_expand_velocity); |
| 2139 | mSelfCollapseVelocityPx = res.getDimension(R.dimen.self_collapse_velocity); |
| 2140 | mFlingExpandMinVelocityPx = res.getDimension(R.dimen.fling_expand_min_velocity); |
| 2141 | mFlingCollapseMinVelocityPx = res.getDimension(R.dimen.fling_collapse_min_velocity); |
| 2142 | |
| 2143 | mCollapseMinDisplayFraction = res.getFraction(R.dimen.collapse_min_display_fraction, 1, 1); |
| 2144 | mExpandMinDisplayFraction = res.getFraction(R.dimen.expand_min_display_fraction, 1, 1); |
| 2145 | |
| 2146 | mExpandAccelPx = res.getDimension(R.dimen.expand_accel); |
| 2147 | mCollapseAccelPx = res.getDimension(R.dimen.collapse_accel); |
| 2148 | |
| 2149 | mFlingGestureMaxXVelocityPx = res.getDimension(R.dimen.fling_gesture_max_x_velocity); |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2150 | |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2151 | mNotificationPanelMarginBottomPx |
| 2152 | = (int) res.getDimension(R.dimen.notification_panel_margin_bottom); |
| 2153 | mNotificationPanelMarginLeftPx |
| 2154 | = (int) res.getDimension(R.dimen.notification_panel_margin_left); |
| 2155 | mNotificationPanelGravity = res.getInteger(R.integer.notification_panel_layout_gravity); |
| 2156 | if (mNotificationPanelGravity <= 0) { |
Jim Miller | a073e57 | 2012-05-23 17:03:27 -0700 | [diff] [blame] | 2157 | mNotificationPanelGravity = Gravity.CENTER_VERTICAL | Gravity.TOP; |
Daniel Sandler | 21b274e | 2012-05-02 15:07:51 -0400 | [diff] [blame] | 2158 | } |
Daniel Sandler | dc940ea | 2011-08-25 14:35:53 -0700 | [diff] [blame] | 2159 | |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2160 | if (false) Slog.v(TAG, "updateResources"); |
| 2161 | } |
| 2162 | |
| 2163 | // |
| 2164 | // tracing |
| 2165 | // |
| 2166 | |
| 2167 | void postStartTracing() { |
| 2168 | mHandler.postDelayed(mStartTracing, 3000); |
| 2169 | } |
| 2170 | |
| 2171 | void vibrate() { |
Joe Onorato | f3c3c4f | 2010-10-21 11:09:02 -0400 | [diff] [blame] | 2172 | android.os.Vibrator vib = (android.os.Vibrator)mContext.getSystemService( |
| 2173 | Context.VIBRATOR_SERVICE); |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2174 | vib.vibrate(250); |
| 2175 | } |
| 2176 | |
| 2177 | Runnable mStartTracing = new Runnable() { |
| 2178 | public void run() { |
| 2179 | vibrate(); |
| 2180 | SystemClock.sleep(250); |
| 2181 | Slog.d(TAG, "startTracing"); |
| 2182 | android.os.Debug.startMethodTracing("/data/statusbar-traces/trace"); |
| 2183 | mHandler.postDelayed(mStopTracing, 10000); |
| 2184 | } |
| 2185 | }; |
| 2186 | |
| 2187 | Runnable mStopTracing = new Runnable() { |
| 2188 | public void run() { |
| 2189 | android.os.Debug.stopMethodTracing(); |
| 2190 | Slog.d(TAG, "stopTracing"); |
| 2191 | vibrate(); |
| 2192 | } |
| 2193 | }; |
Chris Wren | 0c8275b | 2012-05-08 13:36:48 -0400 | [diff] [blame] | 2194 | |
| 2195 | @Override |
| 2196 | protected void haltTicker() { |
| 2197 | mTicker.halt(); |
| 2198 | } |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 2199 | |
| 2200 | @Override |
Jim Miller | b4238e0 | 2012-05-14 15:26:20 -0700 | [diff] [blame] | 2201 | protected boolean shouldDisableNavbarGestures() { |
| 2202 | return mExpanded || (mDisabled & StatusBarManager.DISABLE_HOME) != 0; |
Jim Miller | 670d9dd | 2012-05-12 13:28:26 -0700 | [diff] [blame] | 2203 | } |
Joe Onorato | 808182d | 2010-07-09 18:52:06 -0400 | [diff] [blame] | 2204 | |
Romain Guy | 648342f | 2012-05-25 10:44:45 -0700 | [diff] [blame] | 2205 | private static class FastColorDrawable extends Drawable { |
| 2206 | private final int mColor; |
| 2207 | |
| 2208 | public FastColorDrawable(int color) { |
| 2209 | mColor = 0xff000000 | color; |
| 2210 | } |
| 2211 | |
| 2212 | @Override |
| 2213 | public void draw(Canvas canvas) { |
| 2214 | canvas.drawColor(mColor, PorterDuff.Mode.SRC); |
| 2215 | } |
| 2216 | |
| 2217 | @Override |
| 2218 | public void setAlpha(int alpha) { |
| 2219 | } |
| 2220 | |
| 2221 | @Override |
| 2222 | public void setColorFilter(ColorFilter cf) { |
| 2223 | } |
| 2224 | |
| 2225 | @Override |
| 2226 | public int getOpacity() { |
| 2227 | return PixelFormat.OPAQUE; |
| 2228 | } |
| 2229 | |
| 2230 | @Override |
| 2231 | public void setBounds(int left, int top, int right, int bottom) { |
| 2232 | } |
| 2233 | |
| 2234 | @Override |
| 2235 | public void setBounds(Rect bounds) { |
| 2236 | } |
| 2237 | } |
| 2238 | } |