Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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.controls.ui |
| 18 | |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 19 | import android.animation.Animator |
| 20 | import android.animation.AnimatorListenerAdapter |
| 21 | import android.animation.ValueAnimator |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 22 | import android.content.Context |
| 23 | import android.graphics.drawable.Drawable |
| 24 | import android.graphics.drawable.LayerDrawable |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 25 | import android.os.Bundle |
| 26 | import android.service.controls.Control |
| 27 | import android.service.controls.actions.FloatAction |
| 28 | import android.service.controls.templates.RangeTemplate |
| 29 | import android.service.controls.templates.ToggleRangeTemplate |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 30 | import android.util.Log |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 31 | import android.util.MathUtils |
| 32 | import android.util.TypedValue |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 33 | import android.view.GestureDetector |
| 34 | import android.view.GestureDetector.SimpleOnGestureListener |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 35 | import android.view.MotionEvent |
| 36 | import android.view.View |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 37 | import android.view.ViewGroup |
| 38 | import android.view.accessibility.AccessibilityEvent |
| 39 | import android.view.accessibility.AccessibilityNodeInfo |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 40 | import android.widget.TextView |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 41 | import com.android.systemui.Interpolators |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 42 | import com.android.systemui.R |
Matt Pietal | 677981d | 2020-04-24 14:38:32 -0400 | [diff] [blame] | 43 | import com.android.systemui.controls.ui.ControlViewHolder.Companion.MAX_LEVEL |
| 44 | import com.android.systemui.controls.ui.ControlViewHolder.Companion.MIN_LEVEL |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 45 | import java.util.IllegalFormatException |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 46 | |
| 47 | class ToggleRangeBehavior : Behavior { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 48 | private var rangeAnimator: ValueAnimator? = null |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 49 | lateinit var clipLayer: Drawable |
| 50 | lateinit var template: ToggleRangeTemplate |
| 51 | lateinit var control: Control |
| 52 | lateinit var cvh: ControlViewHolder |
| 53 | lateinit var rangeTemplate: RangeTemplate |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 54 | lateinit var status: TextView |
| 55 | lateinit var context: Context |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 56 | var currentStatusText: CharSequence = "" |
| 57 | var currentRangeValue: String = "" |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 58 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 59 | companion object { |
| 60 | private const val DEFAULT_FORMAT = "%.1f" |
| 61 | } |
| 62 | |
Matt Pietal | b582b69 | 2020-02-14 19:37:57 -0500 | [diff] [blame] | 63 | override fun initialize(cvh: ControlViewHolder) { |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 64 | this.cvh = cvh |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 65 | status = cvh.status |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 66 | context = status.getContext() |
| 67 | |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 68 | cvh.applyRenderInfo(false /* enabled */, 0 /* offset */, false /* animated */) |
Matt Pietal | b582b69 | 2020-02-14 19:37:57 -0500 | [diff] [blame] | 69 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 70 | val gestureListener = ToggleRangeGestureListener(cvh.layout) |
| 71 | val gestureDetector = GestureDetector(context, gestureListener) |
Matt Pietal | 1cbf78d | 2020-03-26 11:16:42 -0400 | [diff] [blame] | 72 | cvh.layout.setOnTouchListener { v: View, e: MotionEvent -> |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 73 | if (gestureDetector.onTouchEvent(e)) { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 74 | // Don't return true to let the state list change to "pressed" |
| 75 | return@setOnTouchListener false |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | if (e.getAction() == MotionEvent.ACTION_UP && gestureListener.isDragging) { |
Matt Pietal | 1cbf78d | 2020-03-26 11:16:42 -0400 | [diff] [blame] | 79 | v.getParent().requestDisallowInterceptTouchEvent(false) |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 80 | gestureListener.isDragging = false |
| 81 | endUpdateRange() |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 82 | return@setOnTouchListener false |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | return@setOnTouchListener false |
Fabian Kozynski | 6e51a705 | 2020-02-19 12:54:31 -0500 | [diff] [blame] | 86 | } |
Matt Pietal | b582b69 | 2020-02-14 19:37:57 -0500 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | override fun bind(cws: ControlWithState) { |
| 90 | this.control = cws.control!! |
| 91 | |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 92 | currentStatusText = control.getStatusText() |
| 93 | status.setText(currentStatusText) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 94 | |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 95 | // ControlViewHolder sets a long click listener, but we want to handle touch in |
| 96 | // here instead, otherwise we'll have state conflicts. |
| 97 | cvh.layout.setOnLongClickListener(null) |
| 98 | |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 99 | val ld = cvh.layout.getBackground() as LayerDrawable |
| 100 | clipLayer = ld.findDrawableByLayerId(R.id.clip_layer) |
| 101 | |
| 102 | template = control.getControlTemplate() as ToggleRangeTemplate |
| 103 | rangeTemplate = template.getRange() |
| 104 | |
| 105 | val checked = template.isChecked() |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 106 | updateRange(rangeToLevelValue(rangeTemplate.currentValue), checked, /* isDragging */ false) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 107 | |
Matt Pietal | 53a8bbd | 2020-03-05 16:10:34 -0500 | [diff] [blame] | 108 | cvh.applyRenderInfo(checked) |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 109 | |
| 110 | /* |
| 111 | * This is custom widget behavior, so add a new accessibility delegate to |
| 112 | * handle clicks and range events. Present as a seek bar control. |
| 113 | */ |
| 114 | cvh.layout.setAccessibilityDelegate(object : View.AccessibilityDelegate() { |
| 115 | override fun onInitializeAccessibilityNodeInfo( |
| 116 | host: View, |
| 117 | info: AccessibilityNodeInfo |
| 118 | ) { |
| 119 | super.onInitializeAccessibilityNodeInfo(host, info) |
| 120 | |
| 121 | val min = levelToRangeValue(MIN_LEVEL) |
| 122 | val current = levelToRangeValue(clipLayer.getLevel()) |
| 123 | val max = levelToRangeValue(MAX_LEVEL) |
| 124 | |
| 125 | val step = rangeTemplate.getStepValue().toDouble() |
| 126 | val type = if (step == Math.floor(step)) { |
| 127 | AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_INT |
| 128 | } else { |
| 129 | AccessibilityNodeInfo.RangeInfo.RANGE_TYPE_FLOAT |
| 130 | } |
| 131 | |
| 132 | val rangeInfo = AccessibilityNodeInfo.RangeInfo.obtain(type, min, max, current) |
| 133 | info.setRangeInfo(rangeInfo) |
| 134 | info.addAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS) |
| 135 | } |
| 136 | |
| 137 | override fun performAccessibilityAction( |
| 138 | host: View, |
| 139 | action: Int, |
| 140 | arguments: Bundle? |
| 141 | ): Boolean { |
| 142 | val handled = when (action) { |
| 143 | AccessibilityNodeInfo.ACTION_CLICK -> { |
Matt Pietal | 677981d | 2020-04-24 14:38:32 -0400 | [diff] [blame] | 144 | cvh.controlActionCoordinator.toggle(cvh, template.getTemplateId(), |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 145 | template.isChecked()) |
| 146 | true |
| 147 | } |
Matt Pietal | b2c7a44 | 2020-05-01 10:48:44 -0400 | [diff] [blame] | 148 | AccessibilityNodeInfo.ACTION_LONG_CLICK -> { |
| 149 | cvh.controlActionCoordinator.longPress(cvh) |
| 150 | true |
| 151 | } |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 152 | AccessibilityNodeInfo.AccessibilityAction.ACTION_SET_PROGRESS.getId() -> { |
| 153 | if (arguments == null || !arguments.containsKey( |
| 154 | AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE)) { |
| 155 | false |
| 156 | } else { |
| 157 | val value = arguments.getFloat( |
| 158 | AccessibilityNodeInfo.ACTION_ARGUMENT_PROGRESS_VALUE) |
Matt Pietal | b2c7a44 | 2020-05-01 10:48:44 -0400 | [diff] [blame] | 159 | val level = rangeToLevelValue(value) |
| 160 | updateRange(level, template.isChecked(), /* isDragging */ true) |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 161 | endUpdateRange() |
| 162 | true |
| 163 | } |
| 164 | } |
| 165 | else -> false |
| 166 | } |
| 167 | |
| 168 | return handled || super.performAccessibilityAction(host, action, arguments) |
| 169 | } |
| 170 | |
| 171 | override fun onRequestSendAccessibilityEvent( |
| 172 | host: ViewGroup, |
| 173 | child: View, |
| 174 | event: AccessibilityEvent |
Matt Pietal | b2c7a44 | 2020-05-01 10:48:44 -0400 | [diff] [blame] | 175 | ): Boolean = true |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 176 | }) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 177 | } |
| 178 | |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 179 | fun beginUpdateRange() { |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 180 | status.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources() |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 181 | .getDimensionPixelSize(R.dimen.control_status_expanded).toFloat()) |
| 182 | } |
| 183 | |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 184 | fun updateRange(level: Int, checked: Boolean, isDragging: Boolean) { |
| 185 | val newLevel = if (checked) Math.max(MIN_LEVEL, Math.min(MAX_LEVEL, level)) else MIN_LEVEL |
| 186 | |
| 187 | rangeAnimator?.cancel() |
| 188 | if (isDragging) { |
| 189 | clipLayer.level = newLevel |
Matt Pietal | b508084 | 2020-04-23 14:02:05 -0400 | [diff] [blame] | 190 | val isEdge = newLevel == MIN_LEVEL || newLevel == MAX_LEVEL |
Matt Pietal | 677981d | 2020-04-24 14:38:32 -0400 | [diff] [blame] | 191 | cvh.controlActionCoordinator.drag(isEdge) |
Matt Pietal | b2c7a44 | 2020-05-01 10:48:44 -0400 | [diff] [blame] | 192 | } else if (newLevel != clipLayer.level) { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 193 | rangeAnimator = ValueAnimator.ofInt(cvh.clipLayer.level, newLevel).apply { |
| 194 | addUpdateListener { |
| 195 | cvh.clipLayer.level = it.animatedValue as Int |
| 196 | } |
| 197 | addListener(object : AnimatorListenerAdapter() { |
| 198 | override fun onAnimationEnd(animation: Animator?) { |
| 199 | rangeAnimator = null |
| 200 | } |
| 201 | }) |
| 202 | duration = ControlViewHolder.STATE_ANIMATION_DURATION |
| 203 | interpolator = Interpolators.CONTROL_STATE |
| 204 | start() |
| 205 | } |
| 206 | } |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 207 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 208 | if (checked) { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 209 | val newValue = levelToRangeValue(newLevel) |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 210 | currentRangeValue = format(rangeTemplate.getFormatString().toString(), |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 211 | DEFAULT_FORMAT, newValue) |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 212 | val text = if (isDragging) { |
| 213 | currentRangeValue |
| 214 | } else { |
| 215 | "$currentStatusText $currentRangeValue" |
| 216 | } |
| 217 | status.setText(text) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 218 | } else { |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 219 | status.setText(currentStatusText) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 223 | private fun format(primaryFormat: String, backupFormat: String, value: Float): String { |
| 224 | return try { |
| 225 | String.format(primaryFormat, value) |
| 226 | } catch (e: IllegalFormatException) { |
| 227 | Log.w(ControlsUiController.TAG, "Illegal format in range template", e) |
| 228 | if (backupFormat == "") { |
| 229 | "" |
| 230 | } else { |
| 231 | format(backupFormat, "", value) |
| 232 | } |
| 233 | } |
| 234 | } |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 235 | |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 236 | private fun levelToRangeValue(i: Int): Float { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 237 | return MathUtils.constrainedMap(rangeTemplate.minValue, rangeTemplate.maxValue, |
| 238 | MIN_LEVEL.toFloat(), MAX_LEVEL.toFloat(), i.toFloat()) |
| 239 | } |
| 240 | |
| 241 | private fun rangeToLevelValue(i: Float): Int { |
| 242 | return MathUtils.constrainedMap(MIN_LEVEL.toFloat(), MAX_LEVEL.toFloat(), |
| 243 | rangeTemplate.minValue, rangeTemplate.maxValue, i).toInt() |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 244 | } |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 245 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 246 | fun endUpdateRange() { |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 247 | status.setTextSize(TypedValue.COMPLEX_UNIT_PX, context.getResources() |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 248 | .getDimensionPixelSize(R.dimen.control_status_normal).toFloat()) |
Matt Pietal | 5f478c7 | 2020-04-01 15:53:54 -0400 | [diff] [blame] | 249 | status.setText("$currentStatusText $currentRangeValue") |
Matt Pietal | 31ec9f2 | 2020-03-12 09:02:17 -0400 | [diff] [blame] | 250 | cvh.action(FloatAction(rangeTemplate.getTemplateId(), |
| 251 | findNearestStep(levelToRangeValue(clipLayer.getLevel())))) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | fun findNearestStep(value: Float): Float { |
| 255 | var minDiff = 1000f |
| 256 | |
| 257 | var f = rangeTemplate.getMinValue() |
| 258 | while (f <= rangeTemplate.getMaxValue()) { |
| 259 | val currentDiff = Math.abs(value - f) |
| 260 | if (currentDiff < minDiff) { |
| 261 | minDiff = currentDiff |
| 262 | } else { |
| 263 | return f - rangeTemplate.getStepValue() |
| 264 | } |
| 265 | |
| 266 | f += rangeTemplate.getStepValue() |
| 267 | } |
| 268 | |
| 269 | return rangeTemplate.getMaxValue() |
| 270 | } |
| 271 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 272 | inner class ToggleRangeGestureListener( |
| 273 | val v: View |
| 274 | ) : SimpleOnGestureListener() { |
| 275 | var isDragging: Boolean = false |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 276 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 277 | override fun onDown(e: MotionEvent): Boolean { |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 278 | return true |
| 279 | } |
| 280 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 281 | override fun onLongPress(e: MotionEvent) { |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 282 | if (isDragging) { |
| 283 | return |
| 284 | } |
Matt Pietal | 677981d | 2020-04-24 14:38:32 -0400 | [diff] [blame] | 285 | cvh.controlActionCoordinator.longPress(this@ToggleRangeBehavior.cvh) |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 286 | } |
| 287 | |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 288 | override fun onScroll( |
| 289 | e1: MotionEvent, |
| 290 | e2: MotionEvent, |
| 291 | xDiff: Float, |
| 292 | yDiff: Float |
| 293 | ): Boolean { |
Lucas Dupin | 3e18f22 | 2020-04-13 15:11:20 -0700 | [diff] [blame] | 294 | if (!template.isChecked) { |
| 295 | return false |
| 296 | } |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 297 | if (!isDragging) { |
Matt Pietal | 1cbf78d | 2020-03-26 11:16:42 -0400 | [diff] [blame] | 298 | v.getParent().requestDisallowInterceptTouchEvent(true) |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 299 | this@ToggleRangeBehavior.beginUpdateRange() |
| 300 | isDragging = true |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 301 | } |
| 302 | |
Lucas Dupin | 2ee4ec9 | 2020-04-13 19:51:14 -0700 | [diff] [blame] | 303 | val ratioDiff = -xDiff / v.width |
| 304 | val changeAmount = ((MAX_LEVEL - MIN_LEVEL) * ratioDiff).toInt() |
| 305 | this@ToggleRangeBehavior.updateRange(clipLayer.level + changeAmount, |
| 306 | checked = true, isDragging = true) |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 307 | return true |
| 308 | } |
| 309 | |
| 310 | override fun onSingleTapUp(e: MotionEvent): Boolean { |
| 311 | val th = this@ToggleRangeBehavior |
Matt Pietal | 677981d | 2020-04-24 14:38:32 -0400 | [diff] [blame] | 312 | cvh.controlActionCoordinator.toggle(th.cvh, th.template.getTemplateId(), |
Matt Pietal | 307b1ef | 2020-02-10 07:27:01 -0500 | [diff] [blame] | 313 | th.template.isChecked()) |
| 314 | return true |
Matt Pietal | a635bd1 | 2020-02-03 13:36:18 -0500 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | } |