summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Gallmann <gallmann@google.com>2023-07-20 16:14:10 +0200
committerJohannes Gallmann <gallmann@google.com>2023-07-20 17:11:57 +0200
commit41fbd3ae4a06fa3c6c61e2afdc466c5c20f7cbea (patch)
tree7eb1e7d5e470411466037c97cda6c67f30248d51
parentc1b65450ee1f718c4452bd186d5356c5f20eb7e4 (diff)
downloadsystemui-41fbd3ae4a06fa3c6c61e2afdc466c5c20f7cbea.tar.gz
Add most important Interpolators as resource interpolators to AnimationLib
Bug: 292080029 Test: atest InterpolatorResourcesTest Change-Id: I236a35126965156089c23eb6e3169e2c76a2ce03
-rw-r--r--animationlib/Android.bp3
-rw-r--r--animationlib/build.gradle1
-rw-r--r--animationlib/res/interpolator/emphasized_accelerate_interpolator.xml22
-rw-r--r--animationlib/res/interpolator/emphasized_decelerate_interpolator.xml22
-rw-r--r--animationlib/res/interpolator/emphasized_interpolator.xml19
-rw-r--r--animationlib/res/interpolator/standard_accelerate_interpolator.xml22
-rw-r--r--animationlib/res/interpolator/standard_decelerate_interpolator.xml22
-rw-r--r--animationlib/res/interpolator/standard_interpolator.xml22
-rw-r--r--animationlib/tests/src/com/android/app/animation/InterpolatorResourcesTest.kt64
9 files changed, 197 insertions, 0 deletions
diff --git a/animationlib/Android.bp b/animationlib/Android.bp
index d67a5de..5417001 100644
--- a/animationlib/Android.bp
+++ b/animationlib/Android.bp
@@ -31,6 +31,9 @@ android_library {
"src/**/*.java",
"src/**/*.kt"
],
+ resource_dirs: [
+ "res"
+ ],
kotlincflags: ["-Xjvm-default=all"],
// This library is meant to access only public APIs
// do not flip this flag to true
diff --git a/animationlib/build.gradle b/animationlib/build.gradle
index 645484a..d32fdb4 100644
--- a/animationlib/build.gradle
+++ b/animationlib/build.gradle
@@ -11,6 +11,7 @@ android {
sourceSets {
main {
java.srcDirs = ['src']
+ res.srcDirs = ['res']
manifest.srcFile 'AndroidManifest.xml'
}
androidTest {
diff --git a/animationlib/res/interpolator/emphasized_accelerate_interpolator.xml b/animationlib/res/interpolator/emphasized_accelerate_interpolator.xml
new file mode 100644
index 0000000..b9e3783
--- /dev/null
+++ b/animationlib/res/interpolator/emphasized_accelerate_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0.3"
+ android:controlY1="0"
+ android:controlX2="0.8"
+ android:controlY2="0.15"/>
diff --git a/animationlib/res/interpolator/emphasized_decelerate_interpolator.xml b/animationlib/res/interpolator/emphasized_decelerate_interpolator.xml
new file mode 100644
index 0000000..990bcff
--- /dev/null
+++ b/animationlib/res/interpolator/emphasized_decelerate_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0.05"
+ android:controlY1="0.7"
+ android:controlX2="0.1"
+ android:controlY2="1"/>
diff --git a/animationlib/res/interpolator/emphasized_interpolator.xml b/animationlib/res/interpolator/emphasized_interpolator.xml
new file mode 100644
index 0000000..5a48611
--- /dev/null
+++ b/animationlib/res/interpolator/emphasized_interpolator.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:pathData="M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1"/> \ No newline at end of file
diff --git a/animationlib/res/interpolator/standard_accelerate_interpolator.xml b/animationlib/res/interpolator/standard_accelerate_interpolator.xml
new file mode 100644
index 0000000..351862f
--- /dev/null
+++ b/animationlib/res/interpolator/standard_accelerate_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0.3"
+ android:controlY1="0"
+ android:controlX2="1"
+ android:controlY2="1"/> \ No newline at end of file
diff --git a/animationlib/res/interpolator/standard_decelerate_interpolator.xml b/animationlib/res/interpolator/standard_decelerate_interpolator.xml
new file mode 100644
index 0000000..1aee540
--- /dev/null
+++ b/animationlib/res/interpolator/standard_decelerate_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0"
+ android:controlY1="0"
+ android:controlX2="0"
+ android:controlY2="1"/> \ No newline at end of file
diff --git a/animationlib/res/interpolator/standard_interpolator.xml b/animationlib/res/interpolator/standard_interpolator.xml
new file mode 100644
index 0000000..8cc2a65
--- /dev/null
+++ b/animationlib/res/interpolator/standard_interpolator.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2023 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License
+ -->
+
+<pathInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
+ android:controlX1="0.2"
+ android:controlY1="0"
+ android:controlX2="0"
+ android:controlY2="1"/>
diff --git a/animationlib/tests/src/com/android/app/animation/InterpolatorResourcesTest.kt b/animationlib/tests/src/com/android/app/animation/InterpolatorResourcesTest.kt
new file mode 100644
index 0000000..ed4670e
--- /dev/null
+++ b/animationlib/tests/src/com/android/app/animation/InterpolatorResourcesTest.kt
@@ -0,0 +1,64 @@
+package com.android.app.animation
+
+import android.annotation.InterpolatorRes
+import android.content.Context
+import android.view.animation.AnimationUtils
+import androidx.test.filters.SmallTest
+import androidx.test.platform.app.InstrumentationRegistry
+import junit.framework.Assert.assertEquals
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@SmallTest
+@RunWith(JUnit4::class)
+class InterpolatorResourcesTest {
+
+ private lateinit var context: Context
+
+ @Before
+ fun setup() {
+ context = InstrumentationRegistry.getInstrumentation().context
+ }
+
+ @Test
+ fun testResourceInterpolatorsMatchCodeInterpolators() {
+ var progress = 0f
+ while (progress < +1f) {
+ assertEquals(
+ InterpolatorsAndroidX.EMPHASIZED.getInterpolation(progress),
+ loadInterpolator(R.interpolator.emphasized_interpolator).getInterpolation(progress)
+ )
+ assertEquals(
+ InterpolatorsAndroidX.EMPHASIZED_ACCELERATE.getInterpolation(progress),
+ loadInterpolator(R.interpolator.emphasized_accelerate_interpolator)
+ .getInterpolation(progress)
+ )
+ assertEquals(
+ InterpolatorsAndroidX.EMPHASIZED_DECELERATE.getInterpolation(progress),
+ loadInterpolator(R.interpolator.emphasized_decelerate_interpolator)
+ .getInterpolation(progress)
+ )
+ assertEquals(
+ InterpolatorsAndroidX.STANDARD.getInterpolation(progress),
+ loadInterpolator(R.interpolator.standard_interpolator).getInterpolation(progress)
+ )
+ assertEquals(
+ InterpolatorsAndroidX.STANDARD_ACCELERATE.getInterpolation(progress),
+ loadInterpolator(R.interpolator.standard_accelerate_interpolator)
+ .getInterpolation(progress)
+ )
+ assertEquals(
+ InterpolatorsAndroidX.STANDARD_DECELERATE.getInterpolation(progress),
+ loadInterpolator(R.interpolator.standard_decelerate_interpolator)
+ .getInterpolation(progress)
+ )
+ progress += 0.1f
+ }
+ }
+
+ private fun loadInterpolator(@InterpolatorRes resourceInt: Int) =
+ AnimationUtils.loadInterpolator(context, resourceInt)
+
+}