Skip to content

Commit

Permalink
Merge branch 'integration-copy/compose/ce39fdf8982/to-jb-main' into j…
Browse files Browse the repository at this point in the history
…b-main
  • Loading branch information
MatkovIvan committed Dec 9, 2024
2 parents a1f0b94 + 950f761 commit f8ef71b
Show file tree
Hide file tree
Showing 812 changed files with 37,693 additions and 12,494 deletions.
5 changes: 2 additions & 3 deletions compose/OWNERS
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Bug component: 612128
chuckj@google.com
jsproch@google.com
lelandr@google.com
malkov@google.com
clarabayarri@google.com
alanv@google.com
adamp@google.com
12 changes: 4 additions & 8 deletions compose/animation/animation-core/api/current.ignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Baseline format: 1.0
ChangedType: androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig#at(T, int):
Method androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig.at has changed return type from androidx.compose.animation.core.KeyframesSpec.KeyframeEntity to androidx.compose.animation.core.KeyframesSpec.KeyframeEntity<T>
ChangedType: androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig#atFraction(T, float):
Method androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig.atFraction has changed return type from androidx.compose.animation.core.KeyframesSpec.KeyframeEntity to androidx.compose.animation.core.KeyframesSpec.KeyframeEntity<T>


RemovedClass: androidx.compose.animation.core.SpringEstimationKt:
Removed class androidx.compose.animation.core.SpringEstimationKt
RemovedMethod: androidx.compose.animation.core.StartOffset#getOffsetMillis():
Removed method androidx.compose.animation.core.StartOffset.getOffsetMillis()
RemovedMethod: androidx.compose.animation.core.StartOffset#getOffsetType():
Removed method androidx.compose.animation.core.StartOffset.getOffsetType()
14 changes: 12 additions & 2 deletions compose/animation/animation-core/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ package androidx.compose.animation.core {
}

public final class AnimationConstants {
property public static final int DefaultDurationMillis;
property public static final long UnspecifiedTime;
field public static final int DefaultDurationMillis = 300; // 0x12c
field public static final androidx.compose.animation.core.AnimationConstants INSTANCE;
field public static final long UnspecifiedTime = -9223372036854775808L; // 0x8000000000000000L
Expand Down Expand Up @@ -585,6 +587,16 @@ package androidx.compose.animation.core {
}

public final class Spring {
property public static final float DampingRatioHighBouncy;
property public static final float DampingRatioLowBouncy;
property public static final float DampingRatioMediumBouncy;
property public static final float DampingRatioNoBouncy;
property public static final float DefaultDisplacementThreshold;
property public static final float StiffnessHigh;
property public static final float StiffnessLow;
property public static final float StiffnessMedium;
property public static final float StiffnessMediumLow;
property public static final float StiffnessVeryLow;
field public static final float DampingRatioHighBouncy = 0.2f;
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
Expand Down Expand Up @@ -612,8 +624,6 @@ package androidx.compose.animation.core {

@kotlin.jvm.JvmInline public final value class StartOffset {
ctor public StartOffset(int offsetMillis, optional int offsetType);
method public int getOffsetMillis();
method public int getOffsetType();
property public final int offsetMillis;
property public final int offsetType;
}
Expand Down
12 changes: 4 additions & 8 deletions compose/animation/animation-core/api/restricted_current.ignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// Baseline format: 1.0
ChangedType: androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig#at(T, int):
Method androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig.at has changed return type from androidx.compose.animation.core.KeyframesSpec.KeyframeEntity to androidx.compose.animation.core.KeyframesSpec.KeyframeEntity<T>
ChangedType: androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig#atFraction(T, float):
Method androidx.compose.animation.core.KeyframesSpec.KeyframesSpecConfig.atFraction has changed return type from androidx.compose.animation.core.KeyframesSpec.KeyframeEntity to androidx.compose.animation.core.KeyframesSpec.KeyframeEntity<T>


RemovedClass: androidx.compose.animation.core.SpringEstimationKt:
Removed class androidx.compose.animation.core.SpringEstimationKt
RemovedMethod: androidx.compose.animation.core.StartOffset#getOffsetMillis():
Removed method androidx.compose.animation.core.StartOffset.getOffsetMillis()
RemovedMethod: androidx.compose.animation.core.StartOffset#getOffsetType():
Removed method androidx.compose.animation.core.StartOffset.getOffsetType()
14 changes: 12 additions & 2 deletions compose/animation/animation-core/api/restricted_current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ package androidx.compose.animation.core {
}

public final class AnimationConstants {
property public static final int DefaultDurationMillis;
property public static final long UnspecifiedTime;
field public static final int DefaultDurationMillis = 300; // 0x12c
field public static final androidx.compose.animation.core.AnimationConstants INSTANCE;
field public static final long UnspecifiedTime = -9223372036854775808L; // 0x8000000000000000L
Expand Down Expand Up @@ -585,6 +587,16 @@ package androidx.compose.animation.core {
}

public final class Spring {
property public static final float DampingRatioHighBouncy;
property public static final float DampingRatioLowBouncy;
property public static final float DampingRatioMediumBouncy;
property public static final float DampingRatioNoBouncy;
property public static final float DefaultDisplacementThreshold;
property public static final float StiffnessHigh;
property public static final float StiffnessLow;
property public static final float StiffnessMedium;
property public static final float StiffnessMediumLow;
property public static final float StiffnessVeryLow;
field public static final float DampingRatioHighBouncy = 0.2f;
field public static final float DampingRatioLowBouncy = 0.75f;
field public static final float DampingRatioMediumBouncy = 0.5f;
Expand Down Expand Up @@ -612,8 +624,6 @@ package androidx.compose.animation.core {

@kotlin.jvm.JvmInline public final value class StartOffset {
ctor public StartOffset(int offsetMillis, optional int offsetType);
method public int getOffsetMillis();
method public int getOffsetType();
property public final int offsetMillis;
property public final int offsetType;
}
Expand Down
24 changes: 24 additions & 0 deletions compose/animation/animation-core/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (C) 2020 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.

# Keep all the functions created to throw an exception. We don't want these functions to be
# inlined in any way, which R8 will do by default. The whole point of these functions is to
# reduce the amount of code generated at the call site.
-keep,allowshrinking,allowobfuscation class androidx.compose.**.* {
static void throw*Exception(...);
static void throw*ExceptionForNullCheck(...);
# For methods returning Nothing
static java.lang.Void throw*Exception(...);
static java.lang.Void throw*ExceptionForNullCheck(...);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@
package androidx.compose.animation.core

import androidx.compose.ui.util.floatFromBits
import kotlin.math.max
import kotlin.math.ulp
import kotlin.test.Test
import kotlin.test.assertTrue

// This test can't be in commonTest because
// Float.ulp is jvm only: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/ulp.html
class EasingTestAndroid {
private val ZeroEpsilon = -(1.0f.ulp * 2.0f)
private val ZeroEpsilon = 1.0f.ulp * 2.0f
private val OneEpsilon = 1.0f + 1.0f.ulp * 2.0f

@Test
fun canSolveCubicForFractionsCloseToOne() {
fun canSolveCubicForFractionsCloseToZeroOrOne() {
// Only test curves defined in [0..1]
// For instance, EaseInOutBack is defined in a larger domain, so exclude it from the list
val curves =
Expand All @@ -53,6 +54,9 @@ class EasingTestAndroid {
EaseInOutQuint,
EaseInSine,
EaseOut,
// Not included because it overshoots 1.0f on purpose, so it can't be tested the
// same way as the other curves. See canSolveOvershootingCurve()
// EaseOutBack,
EaseOutCirc,
EaseOutCubic,
EaseOutExpo,
Expand All @@ -63,15 +67,42 @@ class EasingTestAndroid {
)

for (curve in curves) {
// Test the last 16 ulps until 1.0f
for (i in 0x3f7ffff0..0x3f7fffff) {
for (i in 0x3f7f9d99..0x3f7fffff) {
val fraction = floatFromBits(i)
val t = curve.transform(fraction)
assertTrue(
t in -ZeroEpsilon..OneEpsilon,
"f($fraction) = $t out of range for $curve | ${-ZeroEpsilon}..${OneEpsilon}"
)
}

for (i in 0x0..0x6266) {
val fraction = floatFromBits(i)
val t = curve.transform(fraction)
assertTrue(
t in -ZeroEpsilon..OneEpsilon,
"f($fraction) = $t out of range for $curve | ${-ZeroEpsilon}..${OneEpsilon}"
)
}

// Test at 1.5058824E-7, small value but not too close to 0.0 either
val fraction = floatFromBits(0x3421b161)
val t = curve.transform(fraction)
assertTrue(
t in -ZeroEpsilon..OneEpsilon,
"f($fraction) = $t out of range for $curve | ${-ZeroEpsilon}..${OneEpsilon}"
)
}
}

@Test
fun canSolveOvershootingCurve() {
// We only really care that we don't throw an exception
var t = Float.MIN_VALUE
for (i in 0x3f7f9d99..0x3f7fffff) {
val fraction = floatFromBits(i)
t = max(t, EaseOutBack.transform(fraction))
}
assertTrue(t > Float.MIN_VALUE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.graphics.computeCubicVerticalBounds
import androidx.compose.ui.graphics.evaluateCubic
import androidx.compose.ui.graphics.findFirstCubicRoot
import androidx.compose.ui.util.fastCoerceIn
import kotlin.math.max

/**
* Easing is a way to adjust an animation’s fraction. Easing allows transitioning elements to speed
Expand Down Expand Up @@ -70,6 +71,10 @@ public val FastOutLinearInEasing: Easing = CubicBezierEasing(0.4f, 0.0f, 1.0f, 1
*/
public val LinearEasing: Easing = Easing { fraction -> fraction }

// This is equal to 1f.ulp or 1f.nextUp() - 1f, but neither ulp nor nextUp() are part of all KMP
// targets, only JVM and native
private const val OneUlpAt1 = 1.1920929e-7f

/**
* A cubic polynomial easing.
*
Expand Down Expand Up @@ -125,12 +130,16 @@ public class CubicBezierEasing(
*/
override fun transform(fraction: Float): Float {
return if (fraction > 0f && fraction < 1f) {
// We translate the coordinates by the fraction when calling findFirstCubicRoot,
// but we need to make sure the translation can be done at 1.0f so we take at
// least 1 ulp at 1.0f
val f = max(fraction, OneUlpAt1)
val t =
findFirstCubicRoot(
0.0f - fraction,
a - fraction,
c - fraction,
1.0f - fraction,
0.0f - f,
a - f,
c - f,
1.0f - f,
)

// No root, the cubic curve has no solution
Expand Down
6 changes: 3 additions & 3 deletions compose/animation/animation-graphics/api/current.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ package androidx.compose.animation.graphics {
package androidx.compose.animation.graphics.res {

public final class AnimatedVectorPainterResources_androidKt {
method @SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.painter.Painter rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector animatedImageVector, boolean atEnd);
method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.painter.Painter rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector animatedImageVector, boolean atEnd);
}

public final class AnimatedVectorResources_androidKt {
method @SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Composable public static androidx.compose.animation.graphics.vector.AnimatedImageVector animatedVectorResource(androidx.compose.animation.graphics.vector.AnimatedImageVector.Companion, @DrawableRes int id);
method @androidx.compose.runtime.Composable public static androidx.compose.animation.graphics.vector.AnimatedImageVector animatedVectorResource(androidx.compose.animation.graphics.vector.AnimatedImageVector.Companion, @DrawableRes int id);
}

}

package androidx.compose.animation.graphics.vector {

@SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Immutable public final class AnimatedImageVector {
@androidx.compose.runtime.Immutable public final class AnimatedImageVector {
method public androidx.compose.ui.graphics.vector.ImageVector getImageVector();
method public int getTotalDuration();
property public final androidx.compose.ui.graphics.vector.ImageVector imageVector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ package androidx.compose.animation.graphics {
package androidx.compose.animation.graphics.res {

public final class AnimatedVectorPainterResources_androidKt {
method @SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.painter.Painter rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector animatedImageVector, boolean atEnd);
method @androidx.compose.runtime.Composable public static androidx.compose.ui.graphics.painter.Painter rememberAnimatedVectorPainter(androidx.compose.animation.graphics.vector.AnimatedImageVector animatedImageVector, boolean atEnd);
}

public final class AnimatedVectorResources_androidKt {
method @SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Composable public static androidx.compose.animation.graphics.vector.AnimatedImageVector animatedVectorResource(androidx.compose.animation.graphics.vector.AnimatedImageVector.Companion, @DrawableRes int id);
method @androidx.compose.runtime.Composable public static androidx.compose.animation.graphics.vector.AnimatedImageVector animatedVectorResource(androidx.compose.animation.graphics.vector.AnimatedImageVector.Companion, @DrawableRes int id);
}

}

package androidx.compose.animation.graphics.vector {

@SuppressCompatibility @androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi @androidx.compose.runtime.Immutable public final class AnimatedImageVector {
@androidx.compose.runtime.Immutable public final class AnimatedImageVector {
method public androidx.compose.ui.graphics.vector.ImageVector getImageVector();
method public int getTotalDuration();
property public final androidx.compose.ui.graphics.vector.ImageVector imageVector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package androidx.compose.animation.graphics.res

import androidx.annotation.VisibleForTesting
import androidx.compose.animation.core.updateTransition
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.animation.graphics.vector.StateVectorConfig
import androidx.compose.runtime.Composable
Expand All @@ -38,7 +37,6 @@ import androidx.compose.ui.util.fastForEach
* @param atEnd Whether the animated vector should be rendered at the end of all its animations.
* @sample androidx.compose.animation.graphics.samples.AnimatedVectorSample
*/
@ExperimentalAnimationGraphicsApi
@Composable
public fun rememberAnimatedVectorPainter(
animatedImageVector: AnimatedImageVector,
Expand All @@ -49,7 +47,6 @@ public fun rememberAnimatedVectorPainter(
}
}

@ExperimentalAnimationGraphicsApi
@VisibleForTesting
@Composable
internal fun rememberAnimatedVectorPainter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package androidx.compose.animation.graphics.res
import android.content.res.Resources
import android.util.Xml
import androidx.annotation.DrawableRes
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.animation.graphics.vector.compat.parseAnimatedImageVector
import androidx.compose.animation.graphics.vector.compat.seekToStartTag
Expand All @@ -35,7 +34,6 @@ import org.xmlpull.v1.XmlPullParserException
* @return an animated vector drawable resource.
* @sample androidx.compose.animation.graphics.samples.AnimatedVectorSample
*/
@ExperimentalAnimationGraphicsApi
@Composable
public fun AnimatedImageVector.Companion.animatedVectorResource(
@DrawableRes id: Int
Expand All @@ -46,7 +44,6 @@ public fun AnimatedImageVector.Companion.animatedVectorResource(
return remember(id) { loadAnimatedVectorResource(theme, res, id) }
}

@ExperimentalAnimationGraphicsApi
@Throws(XmlPullParserException::class)
internal fun loadAnimatedVectorResource(
theme: Resources.Theme? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package androidx.compose.animation.graphics.vector.compat

import android.content.res.Resources
import android.util.AttributeSet
import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.animation.graphics.res.loadAnimatorResource
import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.animation.graphics.vector.AnimatedVectorTarget
Expand Down Expand Up @@ -54,7 +53,6 @@ private fun parseAnimatedVectorTarget(
}
}

@ExperimentalAnimationGraphicsApi
internal fun XmlPullParser.parseAnimatedImageVector(
res: Resources,
theme: Resources.Theme?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package androidx.compose.animation.graphics.vector

import androidx.compose.animation.graphics.ExperimentalAnimationGraphicsApi
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.util.fastMaxBy
Expand All @@ -29,7 +28,6 @@ import androidx.compose.ui.util.fastMaxBy
* @param imageVector The [ImageVector] to be animated. This is represented with the
* `android:drawable` parameter of an `<animated-vector>` element.
*/
@ExperimentalAnimationGraphicsApi
@Immutable
public class AnimatedImageVector
internal constructor(
Expand Down
Loading

0 comments on commit f8ef71b

Please sign in to comment.