Migrate input to use ktfmt

See go/why-ktfmt

BUG: 319663977
Change-Id: I75e9ea657931223a928206187aa32e056d496c65
diff --git a/gradle.properties b/gradle.properties
index 3af4a1c..799fb21 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -48,7 +48,7 @@
 androidx.unpinComposeCompiler=false
 
 # Prefix of projects that are opted-in to use ktfmt
-androidx.ktfmt.optin=:a,:b,:camera,:car,:collection,:concurrent,:constraintlayout,:core,:d,:e,:f,:g,:health,:hilt
+androidx.ktfmt.optin=:a,:b,:camera,:car,:collection,:concurrent,:constraintlayout,:core,:d,:e,:f,:g,:h,:input
 
 # Disable features we do not use
 android.defaults.buildfeatures.aidl=false
diff --git a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/MotionEventGenerator.kt b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/MotionEventGenerator.kt
index 574f246..7d4998b 100644
--- a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/MotionEventGenerator.kt
+++ b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/MotionEventGenerator.kt
@@ -28,9 +28,9 @@
     val secondPressureGenerator: ((Long) -> Float)?,
 ) {
     constructor(
-            firstXGenerator: (Long) -> Float,
-            firstYGenerator: (Long) -> Float,
-            firstPressureGenerator: ((Long) -> Float)?
+        firstXGenerator: (Long) -> Float,
+        firstYGenerator: (Long) -> Float,
+        firstPressureGenerator: ((Long) -> Float)?
     ) : this(firstXGenerator, firstYGenerator, firstPressureGenerator, null, null, null)
 
     private val downEventTime: Long = System.currentTimeMillis()
@@ -43,9 +43,10 @@
     private var sentSecondDown = false
 
     fun next(): MotionEvent {
-        val motionEventBuilder = MotionEventBuilder.newBuilder()
-            .setEventTime(currentEventTime)
-            .setDownTime(downEventTime)
+        val motionEventBuilder =
+            MotionEventBuilder.newBuilder()
+                .setEventTime(currentEventTime)
+                .setDownTime(downEventTime)
 
         if (!sentDown) {
             motionEventBuilder.setAction(MotionEvent.ACTION_DOWN)
@@ -83,15 +84,15 @@
             secondPointerProperties.toolType = MotionEvent.TOOL_TYPE_STYLUS
 
             val secondCoords = MotionEvent.PointerCoords()
-            secondCoords.x = secondStartX +
-                    secondXGenerator.invoke(currentEventTime - downEventTime)
-            secondCoords.y = secondStartY +
-                    secondYGenerator.invoke(currentEventTime - downEventTime)
+            secondCoords.x =
+                secondStartX + secondXGenerator.invoke(currentEventTime - downEventTime)
+            secondCoords.y =
+                secondStartY + secondYGenerator.invoke(currentEventTime - downEventTime)
             if (secondPressureGenerator == null) {
                 secondCoords.pressure = 1f
             } else {
                 secondCoords.pressure =
-                        secondPressureGenerator.invoke(currentEventTime - downEventTime)
+                    secondPressureGenerator.invoke(currentEventTime - downEventTime)
             }
 
             motionEventBuilder.setPointer(secondPointerProperties, secondCoords)
diff --git a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
index cec9bab..e8772fd 100644
--- a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
+++ b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/MultiPointerPredictorTest.kt
@@ -33,14 +33,15 @@
     @Test
     fun historicalTime() {
         val predictor = MultiPointerPredictor(Configuration.STRATEGY_BALANCED)
-        val generator = MotionEventGenerator(
+        val generator =
+            MotionEventGenerator(
                 { delta: Long -> delta.toFloat() },
                 { delta: Long -> delta.toFloat() },
                 null,
                 { delta: Long -> delta.toFloat() },
                 { delta: Long -> delta.toFloat() },
                 null,
-        )
+            )
         for (i in 1..INITIAL_FEED) {
             predictor.onTouchEvent(generator.next())
         }
@@ -49,7 +50,7 @@
         assertThat(predicted.getPointerCount()).isEqualTo(2)
         var historicalTime = predicted.getEventTime()
         for (i in (PREDICT_SAMPLE - 2) downTo 0) {
-            historicalTime -= generator.getRateMs().toInt();
+            historicalTime -= generator.getRateMs().toInt()
             assertThat(predicted.getHistoricalEventTime(i)).isEqualTo(historicalTime)
         }
     }
@@ -58,14 +59,15 @@
     @Test
     fun downTime() {
         val predictor = MultiPointerPredictor(Configuration.STRATEGY_BALANCED)
-        val generator = MotionEventGenerator(
+        val generator =
+            MotionEventGenerator(
                 { delta: Long -> delta.toFloat() },
                 { delta: Long -> delta.toFloat() },
                 null,
                 { delta: Long -> delta.toFloat() },
                 { delta: Long -> delta.toFloat() },
                 null,
-        )
+            )
         var firstEvent: MotionEvent? = null
         for (i in 1..INITIAL_FEED) {
             val nextEvent = generator.next()
@@ -80,5 +82,6 @@
     }
 }
 
-private const val PREDICT_SAMPLE = 5;
+private const val PREDICT_SAMPLE = 5
+
 private const val INITIAL_FEED = 20
diff --git a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/SinglePointerPredictorTest.kt b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/SinglePointerPredictorTest.kt
index 4200608..f675b70 100644
--- a/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/SinglePointerPredictorTest.kt
+++ b/input/input-motionprediction/src/test/kotlin/androidx/input/motionprediction/kalman/SinglePointerPredictorTest.kt
@@ -32,7 +32,8 @@
 
     @Test
     fun simplePrediction() {
-        val generators = arrayOf(
+        val generators =
+            arrayOf(
                 // Constant
                 { _: Long -> 0f },
                 // Velocity
@@ -46,7 +47,7 @@
                 // Acceleration & velocity
                 { delta: Long -> delta.toFloat() + delta.toFloat().pow(2) / 4 },
                 { delta: Long -> -delta.toFloat() - delta.toFloat().pow(2) / 4 }
-        )
+            )
         for ((xIndex, xGenerator) in generators.withIndex()) {
             for ((yIndex, yGenerator) in generators.withIndex()) {
                 if (xIndex == 0 && yIndex == 0) {
@@ -77,7 +78,7 @@
         val predictor = constructPredictor()
         val coordGenerator = { delta: Long -> delta.toFloat() }
         val motionGenerator = MotionEventGenerator(coordGenerator, coordGenerator, null)
-        var lastPredictedTime = 0L;
+        var lastPredictedTime = 0L
         for (i in 1..INITIAL_FEED) {
             predictor.onTouchEvent(motionGenerator.next())
             val predicted = predictor.predict(motionGenerator.getRateMs().toInt() * 10)
@@ -97,14 +98,15 @@
         val predictor = constructPredictor()
         val coordGenerator = { delta: Long -> delta.toFloat() }
         // Pressure will be 1 at the beginning and trend to zero while never getting there
-        val pressureGenerator = fun(delta: Long): Float {
-            if (delta > 500) {
-                return ((700 - delta) / 500).toFloat()
+        val pressureGenerator =
+            fun(delta: Long): Float {
+                if (delta > 500) {
+                    return ((700 - delta) / 500).toFloat()
+                }
+                return 1f
             }
-            return 1f
-        }
         val motionGenerator =
-                MotionEventGenerator(coordGenerator, coordGenerator, pressureGenerator)
+            MotionEventGenerator(coordGenerator, coordGenerator, pressureGenerator)
         var lastPredictedTime = 0L
         var lastPredictedEvent: MotionEvent? = null
         var predicted: MotionEvent?
@@ -115,7 +117,7 @@
                 assertThat(predicted.eventTime).isAtLeast(lastPredictedTime)
                 lastPredictedTime = predicted.eventTime
             } else if (lastPredictedEvent != null) {
-                assertThat(lastPredictedEvent.getHistorySize()).isEqualTo(0);
+                assertThat(lastPredictedEvent.getHistorySize()).isEqualTo(0)
             }
             lastPredictedEvent = predicted
             if (i > INITIAL_FEED) {
@@ -125,11 +127,8 @@
     }
 }
 
-private fun constructPredictor(): SinglePointerPredictor = SinglePointerPredictor(
-        Configuration.STRATEGY_BALANCED,
-        0,
-        MotionEvent.TOOL_TYPE_STYLUS
-)
+private fun constructPredictor(): SinglePointerPredictor =
+    SinglePointerPredictor(Configuration.STRATEGY_BALANCED, 0, MotionEvent.TOOL_TYPE_STYLUS)
 
 private const val INITIAL_FEED = 20
 private const val MAX_ITERATIONS = 10000