Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | |
| 17 | package com.android.systemui.statusbar |
| 18 | |
| 19 | import android.animation.Animator |
| 20 | import android.animation.AnimatorListenerAdapter |
| 21 | import android.animation.ObjectAnimator |
| 22 | import android.animation.ValueAnimator |
| 23 | import android.content.Context |
| 24 | import android.os.PowerManager |
| 25 | import android.os.PowerManager.WAKE_REASON_GESTURE |
| 26 | import android.os.SystemClock |
| 27 | import android.view.MotionEvent |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 28 | import android.view.VelocityTracker |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 29 | import android.view.ViewConfiguration |
| 30 | |
| 31 | import com.android.systemui.Gefingerpoken |
| 32 | import com.android.systemui.Interpolators |
| 33 | import com.android.systemui.R |
Dave Mankoff | 468d4f6 | 2019-05-08 14:56:29 -0400 | [diff] [blame] | 34 | import com.android.systemui.plugins.FalsingManager |
Lucas Dupin | e7ff7be | 2019-09-17 11:19:53 -0400 | [diff] [blame] | 35 | import com.android.systemui.plugins.statusbar.StatusBarStateController |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 36 | import com.android.systemui.statusbar.notification.NotificationWakeUpCoordinator |
| 37 | import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow |
| 38 | import com.android.systemui.statusbar.notification.row.ExpandableView |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 39 | import com.android.systemui.statusbar.notification.stack.NotificationRoundnessManager |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 40 | import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout |
Selim Cinek | d21232e | 2019-06-20 14:15:59 -0700 | [diff] [blame] | 41 | import com.android.systemui.statusbar.phone.HeadsUpManagerPhone |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 42 | import com.android.systemui.statusbar.phone.KeyguardBypassController |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 43 | import com.android.systemui.statusbar.phone.ShadeController |
| 44 | |
| 45 | import javax.inject.Inject |
| 46 | import javax.inject.Singleton |
| 47 | import kotlin.math.max |
| 48 | |
| 49 | /** |
| 50 | * A utility class to enable the downward swipe on when pulsing. |
| 51 | */ |
| 52 | @Singleton |
| 53 | class PulseExpansionHandler @Inject |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 54 | constructor( |
| 55 | context: Context, |
| 56 | private val wakeUpCoordinator: NotificationWakeUpCoordinator, |
| 57 | private val bypassController: KeyguardBypassController, |
| 58 | private val headsUpManager: HeadsUpManagerPhone, |
Lucas Dupin | e7ff7be | 2019-09-17 11:19:53 -0400 | [diff] [blame] | 59 | private val roundnessManager: NotificationRoundnessManager, |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 60 | private val statusBarStateController: StatusBarStateController, |
| 61 | private val falsingManager: FalsingManager |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 62 | ) : Gefingerpoken { |
Selim Cinek | 34518f6 | 2019-02-28 19:41:18 -0800 | [diff] [blame] | 63 | companion object { |
| 64 | private val RUBBERBAND_FACTOR_STATIC = 0.25f |
| 65 | private val SPRING_BACK_ANIMATION_LENGTH_MS = 375 |
| 66 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 67 | private val mPowerManager: PowerManager? |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 68 | private lateinit var shadeController: ShadeController |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 69 | |
| 70 | private val mMinDragDistance: Int |
| 71 | private var mInitialTouchX: Float = 0.0f |
| 72 | private var mInitialTouchY: Float = 0.0f |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 73 | var isExpanding: Boolean = false |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 74 | private set(value) { |
| 75 | val changed = field != value |
| 76 | field = value |
| 77 | bypassController.isPulseExpanding = value |
Selim Cinek | d21232e | 2019-06-20 14:15:59 -0700 | [diff] [blame] | 78 | if (changed) { |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 79 | if (value) { |
| 80 | val topEntry = headsUpManager.topEntry |
| 81 | topEntry?.let { |
| 82 | roundnessManager.setTrackingHeadsUp(it.row) |
| 83 | } |
| 84 | } else { |
| 85 | roundnessManager.setTrackingHeadsUp(null) |
| 86 | if (!leavingLockscreen) { |
| 87 | bypassController.maybePerformPendingUnlock() |
| 88 | pulseExpandAbortListener?.run() |
| 89 | } |
Selim Cinek | d21232e | 2019-06-20 14:15:59 -0700 | [diff] [blame] | 90 | } |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 91 | headsUpManager.unpinAll(true /* userUnPinned */) |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 92 | } |
| 93 | } |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 94 | var leavingLockscreen: Boolean = false |
| 95 | private set |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 96 | private val mTouchSlop: Float |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 97 | private lateinit var expansionCallback: ExpansionCallback |
| 98 | private lateinit var stackScroller: NotificationStackScrollLayout |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 99 | private val mTemp2 = IntArray(2) |
| 100 | private var mDraggedFarEnough: Boolean = false |
| 101 | private var mStartingChild: ExpandableView? = null |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 102 | private var mPulsing: Boolean = false |
| 103 | var isWakingToShadeLocked: Boolean = false |
| 104 | private set |
| 105 | private var mEmptyDragAmount: Float = 0.0f |
| 106 | private var mWakeUpHeight: Float = 0.0f |
| 107 | private var mReachedWakeUpHeight: Boolean = false |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 108 | private var velocityTracker: VelocityTracker? = null |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 109 | |
| 110 | private val isFalseTouch: Boolean |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 111 | get() = falsingManager.isFalseTouch |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 112 | var qsExpanded: Boolean = false |
| 113 | var pulseExpandAbortListener: Runnable? = null |
Selim Cinek | 820ba2d | 2019-06-18 18:59:09 -0700 | [diff] [blame] | 114 | var bouncerShowing: Boolean = false |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 115 | |
| 116 | init { |
| 117 | mMinDragDistance = context.resources.getDimensionPixelSize( |
| 118 | R.dimen.keyguard_drag_down_min_distance) |
| 119 | mTouchSlop = ViewConfiguration.get(context).scaledTouchSlop.toFloat() |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 120 | mPowerManager = context.getSystemService(PowerManager::class.java) |
| 121 | } |
| 122 | |
| 123 | override fun onInterceptTouchEvent(event: MotionEvent): Boolean { |
Dave Mankoff | 49b3335 | 2020-05-12 20:23:16 +0000 | [diff] [blame] | 124 | return maybeStartExpansion(event) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 125 | } |
| 126 | |
Dave Mankoff | 49b3335 | 2020-05-12 20:23:16 +0000 | [diff] [blame] | 127 | private fun maybeStartExpansion(event: MotionEvent): Boolean { |
| 128 | if (!wakeUpCoordinator.canShowPulsingHuns || qsExpanded || |
| 129 | bouncerShowing) { |
| 130 | return false |
| 131 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 132 | if (velocityTracker == null) { |
| 133 | velocityTracker = VelocityTracker.obtain() |
| 134 | } |
| 135 | velocityTracker!!.addMovement(event) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 136 | val x = event.x |
| 137 | val y = event.y |
| 138 | |
| 139 | when (event.actionMasked) { |
| 140 | MotionEvent.ACTION_DOWN -> { |
| 141 | mDraggedFarEnough = false |
| 142 | isExpanding = false |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 143 | leavingLockscreen = false |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 144 | mStartingChild = null |
| 145 | mInitialTouchY = y |
| 146 | mInitialTouchX = x |
| 147 | } |
| 148 | |
| 149 | MotionEvent.ACTION_MOVE -> { |
| 150 | val h = y - mInitialTouchY |
| 151 | if (h > mTouchSlop && h > Math.abs(x - mInitialTouchX)) { |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 152 | falsingManager.onStartExpandingFromPulse() |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 153 | isExpanding = true |
| 154 | captureStartingChild(mInitialTouchX, mInitialTouchY) |
| 155 | mInitialTouchY = y |
| 156 | mInitialTouchX = x |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 157 | mWakeUpHeight = wakeUpCoordinator.getWakeUpHeight() |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 158 | mReachedWakeUpHeight = false |
| 159 | return true |
| 160 | } |
| 161 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 162 | |
| 163 | MotionEvent.ACTION_UP -> { |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 164 | recycleVelocityTracker() |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | MotionEvent.ACTION_CANCEL -> { |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 168 | recycleVelocityTracker() |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 169 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 170 | } |
| 171 | return false |
| 172 | } |
| 173 | |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 174 | private fun recycleVelocityTracker() { |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 175 | velocityTracker?.recycle() |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 176 | velocityTracker = null |
| 177 | } |
| 178 | |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 179 | override fun onTouchEvent(event: MotionEvent): Boolean { |
Dave Mankoff | 49b3335 | 2020-05-12 20:23:16 +0000 | [diff] [blame] | 180 | if (!isExpanding) { |
| 181 | return maybeStartExpansion(event) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 182 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 183 | velocityTracker!!.addMovement(event) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 184 | val y = event.y |
| 185 | |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 186 | val moveDistance = y - mInitialTouchY |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 187 | when (event.actionMasked) { |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 188 | MotionEvent.ACTION_MOVE -> updateExpansionHeight(moveDistance) |
| 189 | MotionEvent.ACTION_UP -> { |
| 190 | velocityTracker!!.computeCurrentVelocity(1000 /* units */) |
Lucas Dupin | e7ff7be | 2019-09-17 11:19:53 -0400 | [diff] [blame] | 191 | val canExpand = moveDistance > 0 && velocityTracker!!.getYVelocity() > -1000 && |
| 192 | statusBarStateController.state != StatusBarState.SHADE |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 193 | if (!falsingManager.isUnlockingDisabled && !isFalseTouch && canExpand) { |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 194 | finishExpansion() |
| 195 | } else { |
| 196 | cancelExpansion() |
| 197 | } |
| 198 | recycleVelocityTracker() |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 199 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 200 | MotionEvent.ACTION_CANCEL -> { |
| 201 | cancelExpansion() |
| 202 | recycleVelocityTracker() |
| 203 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 204 | } |
| 205 | return isExpanding |
| 206 | } |
| 207 | |
| 208 | private fun finishExpansion() { |
| 209 | resetClock() |
| 210 | if (mStartingChild != null) { |
| 211 | setUserLocked(mStartingChild!!, false) |
| 212 | mStartingChild = null |
| 213 | } |
Heemin Seog | e9f4e96 | 2019-12-05 11:55:27 -0800 | [diff] [blame] | 214 | if (statusBarStateController.isDozing) { |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 215 | isWakingToShadeLocked = true |
| 216 | wakeUpCoordinator.willWakeUp = true |
| 217 | mPowerManager!!.wakeUp(SystemClock.uptimeMillis(), WAKE_REASON_GESTURE, |
| 218 | "com.android.systemui:PULSEDRAG") |
| 219 | } |
| 220 | shadeController.goToLockedShade(mStartingChild) |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 221 | leavingLockscreen = true |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 222 | isExpanding = false |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 223 | if (mStartingChild is ExpandableNotificationRow) { |
| 224 | val row = mStartingChild as ExpandableNotificationRow? |
| 225 | row!!.onExpandedByGesture(true /* userExpanded */) |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | private fun updateExpansionHeight(height: Float) { |
| 230 | var expansionHeight = max(height, 0.0f) |
| 231 | if (!mReachedWakeUpHeight && height > mWakeUpHeight) { |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 232 | mReachedWakeUpHeight = true |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 233 | } |
| 234 | if (mStartingChild != null) { |
| 235 | val child = mStartingChild!! |
| 236 | val newHeight = Math.min((child.collapsedHeight + expansionHeight).toInt(), |
| 237 | child.maxContentHeight) |
| 238 | child.actualHeight = newHeight |
| 239 | expansionHeight = max(newHeight.toFloat(), expansionHeight) |
| 240 | } else { |
Selim Cinek | 624d6ca | 2019-02-19 15:39:08 -0800 | [diff] [blame] | 241 | val target = if (mReachedWakeUpHeight) mWakeUpHeight else 0.0f |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 242 | wakeUpCoordinator.setNotificationsVisibleForExpansion(height > target, |
Selim Cinek | 624d6ca | 2019-02-19 15:39:08 -0800 | [diff] [blame] | 243 | true /* animate */, |
| 244 | true /* increaseSpeed */) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 245 | expansionHeight = max(mWakeUpHeight, expansionHeight) |
| 246 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 247 | val emptyDragAmount = wakeUpCoordinator.setPulseHeight(expansionHeight) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 248 | setEmptyDragAmount(emptyDragAmount * RUBBERBAND_FACTOR_STATIC) |
| 249 | } |
| 250 | |
| 251 | private fun captureStartingChild(x: Float, y: Float) { |
Selim Cinek | c7e4cb5 | 2019-06-20 15:41:45 -0700 | [diff] [blame] | 252 | if (mStartingChild == null && !bypassController.bypassEnabled) { |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 253 | mStartingChild = findView(x, y) |
| 254 | if (mStartingChild != null) { |
| 255 | setUserLocked(mStartingChild!!, true) |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | private fun setEmptyDragAmount(amount: Float) { |
| 261 | mEmptyDragAmount = amount |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 262 | expansionCallback.setEmptyDragAmount(amount) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | private fun reset(child: ExpandableView) { |
| 266 | if (child.actualHeight == child.collapsedHeight) { |
| 267 | setUserLocked(child, false) |
| 268 | return |
| 269 | } |
| 270 | val anim = ObjectAnimator.ofInt(child, "actualHeight", |
| 271 | child.actualHeight, child.collapsedHeight) |
| 272 | anim.interpolator = Interpolators.FAST_OUT_SLOW_IN |
| 273 | anim.duration = SPRING_BACK_ANIMATION_LENGTH_MS.toLong() |
| 274 | anim.addListener(object : AnimatorListenerAdapter() { |
| 275 | override fun onAnimationEnd(animation: Animator) { |
| 276 | setUserLocked(child, false) |
| 277 | } |
| 278 | }) |
| 279 | anim.start() |
| 280 | } |
| 281 | |
| 282 | private fun setUserLocked(child: ExpandableView, userLocked: Boolean) { |
| 283 | if (child is ExpandableNotificationRow) { |
| 284 | child.isUserLocked = userLocked |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | private fun resetClock() { |
| 289 | val anim = ValueAnimator.ofFloat(mEmptyDragAmount, 0f) |
| 290 | anim.interpolator = Interpolators.FAST_OUT_SLOW_IN |
| 291 | anim.duration = SPRING_BACK_ANIMATION_LENGTH_MS.toLong() |
| 292 | anim.addUpdateListener { animation -> setEmptyDragAmount(animation.animatedValue as Float) } |
| 293 | anim.start() |
| 294 | } |
| 295 | |
| 296 | private fun cancelExpansion() { |
Selim Cinek | b0fada6 | 2019-06-17 19:03:59 -0700 | [diff] [blame] | 297 | isExpanding = false |
Dave Mankoff | 898e1bb | 2019-09-25 17:54:19 -0400 | [diff] [blame] | 298 | falsingManager.onExpansionFromPulseStopped() |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 299 | if (mStartingChild != null) { |
| 300 | reset(mStartingChild!!) |
| 301 | mStartingChild = null |
| 302 | } else { |
| 303 | resetClock() |
| 304 | } |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 305 | wakeUpCoordinator.setNotificationsVisibleForExpansion(false /* visible */, |
Selim Cinek | 624d6ca | 2019-02-19 15:39:08 -0800 | [diff] [blame] | 306 | true /* animate */, |
| 307 | false /* increaseSpeed */) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | private fun findView(x: Float, y: Float): ExpandableView? { |
| 311 | var totalX = x |
| 312 | var totalY = y |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 313 | stackScroller.getLocationOnScreen(mTemp2) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 314 | totalX += mTemp2[0].toFloat() |
| 315 | totalY += mTemp2[1].toFloat() |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 316 | val childAtRawPosition = stackScroller.getChildAtRawPosition(totalX, totalY) |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 317 | return if (childAtRawPosition != null && childAtRawPosition.isContentExpandable) { |
| 318 | childAtRawPosition |
| 319 | } else null |
| 320 | } |
| 321 | |
Dan Sandler | da6e179 | 2019-08-14 13:52:54 -0400 | [diff] [blame] | 322 | fun setUp( |
| 323 | stackScroller: NotificationStackScrollLayout, |
| 324 | expansionCallback: ExpansionCallback, |
| 325 | shadeController: ShadeController |
| 326 | ) { |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 327 | this.expansionCallback = expansionCallback |
| 328 | this.shadeController = shadeController |
| 329 | this.stackScroller = stackScroller |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | fun setPulsing(pulsing: Boolean) { |
| 333 | mPulsing = pulsing |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | fun onStartedWakingUp() { |
| 337 | isWakingToShadeLocked = false |
| 338 | } |
| 339 | |
| 340 | interface ExpansionCallback { |
| 341 | fun setEmptyDragAmount(amount: Float) |
| 342 | } |
Selim Cinek | 3d6ae23 | 2019-01-04 14:14:33 -0800 | [diff] [blame] | 343 | } |