Skip to content

Commit

Permalink
remove obsolete api and logs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhirkevich committed Jan 29, 2025
1 parent 0dda8cf commit 3bbf88c
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 122 deletions.
4 changes: 0 additions & 4 deletions compottie/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@ kotlin {
desktopTest.dependencies {
implementation(compose.desktop.currentOs)
}

androidMain.dependencies {
implementation(libs.androidx.startup)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.createFontFamilyResolver


@OptIn(InternalCompottieApi::class)
internal actual fun makeFontFamilyResolver() : FontFamily.Resolver {
return createFontFamilyResolver(
checkNotNull(Compottie.context){
"Compottie failed to initialize"
}
)
}

internal actual fun mockFontFamilyResolver() : FontFamily.Resolver =
createFontFamilyResolver(Application())

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,4 @@ public object Compottie {
* You can set it to null for production
* */
public var logger : LottieLogger? = LottieLogger.Default

@InternalCompottieApi
public var context : LottieContext? = null
internal set
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,67 +208,6 @@ public fun rememberLottiePainter(
}


/**
* Factory method to create Lottie painter from non-composable context.
* This painter will not work with Android Studio preview.
* Use [rememberLottiePainter] to create it from the composition.
*
* [progress] lambda has to be derivable so that [derivedStateOf] can derive progress from it.
*
* Use [LottieCompositionSpec.load] to get [LottieComposition] instance from [LottieCompositionSpec].
* */
@OptIn(InternalCompottieApi::class)
public suspend fun LottiePainter(
composition : LottieComposition,
progress : () -> Float,
assetsManager: LottieAssetsManager? = null,
fontManager: LottieFontManager? = null,
dynamicProperties : LottieDynamicProperties? = null,
applyOpacityToLayers : Boolean = false,
clipToCompositionBounds : Boolean = true,
clipTextToBoundingBoxes: Boolean = false,
enableTextGrouping: Boolean = false,
enableMergePaths: Boolean = false,
enableExpressions: Boolean = true,
enableOffscreenBlending : Boolean = false
) : Painter = coroutineScope {

val dp = when (dynamicProperties) {
is DynamicCompositionProvider -> dynamicProperties
null -> null
}

val copy = dp != null

val assets = async(Compottie.ioDispatcher()) {
assetsManager?.let {
composition.loadAssets(it, copy)
}
}
val fonts = async(Compottie.ioDispatcher()) {
fontManager?.let {
composition.loadFonts(it)
}
}

LottiePainter(
composition = if (copy) composition.deepCopy() else composition,
progress = progress,
dynamicProperties = dp,
clipTextToBoundingBoxes = clipTextToBoundingBoxes,
enableTextGrouping = enableTextGrouping,
fontFamilyResolver = makeFontFamilyResolver(),
clipToCompositionBounds = clipToCompositionBounds,
enableMergePaths = enableMergePaths,
enableExpressions = enableExpressions,
applyOpacityToLayers = applyOpacityToLayers,
enableOffscreenBlending = enableOffscreenBlending,
assets = assets.await().orEmpty(),
fonts = fonts.await().orEmpty()
)
}

internal expect fun makeFontFamilyResolver() : FontFamily.Resolver
internal expect fun mockFontFamilyResolver() : FontFamily.Resolver

private class LateInitPainter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ private class ExpressionEvaluatorImpl(
ExpressionInterpreterImpl(expr, context).interpret()
}.getOrNull()

private val errors = mutableSetOf<String?>()

override fun RawProperty<*>.evaluate(state: AnimationState): Any {
if (!state.enableExpressions || expression == null)
Expand All @@ -39,19 +38,6 @@ private class ExpressionEvaluatorImpl(
expression.invoke(this, context, state)
context.result?.toListOrThis()
} catch (t: Throwable) {
if (catchErrors){
if (t.message !in errors) {
errors += t.message
Compottie.logger?.warn(
"Error occurred in a Lottie expression. Try to disable expressions for Painter using enableExpressions=false: ${t.message}"
)
if (EXPR_DEBUG_PRINT_ENABLED){
t.printStackTrace()
}
}
} else {
throw t
}
null
} finally {
context.reset()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ internal class OpCreatePath(
private val isClosed : Expression?,
) : OpPropertyContext(), Expression {

init {
Compottie.logger?.warn("Animation contains 'createPath' expression. It is supported but can cause significant performance drops. If you notice performance issues set enableExpressions=false for Painter")
}

override fun invoke(
property: RawProperty<Any>,
context: EvaluationContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ internal class Mask(
if (isClosedLegacy != null) {
shape?.setClosed(isClosedLegacy)
}

if (!mode.isSupported()){
Compottie.logger?.warn("Animation contains unsupported mask type: $mode. It will be treated as an 'Add' mask")
}
}

fun deepCopy() = Mask(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ internal class SolidColorLayer(
color = Color(red = r, green = g, blue = b, alpha = a)
} catch (t: Throwable) {
// TODO: sometimes colors are exported as #d9.0147ae147aedf.fdf3b645a1c8e6.028f5c28f5c8
Compottie.logger?.warn("Solid color layer (${name}) with unrecognized color: $colorHex")
color = Color.Transparent
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ package io.github.alexzhirkevich.compottie
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.createFontFamilyResolver

internal actual fun makeFontFamilyResolver() : FontFamily.Resolver {
return createFontFamilyResolver()
}

internal actual fun mockFontFamilyResolver() : FontFamily.Resolver =
createFontFamilyResolver()

0 comments on commit 3bbf88c

Please sign in to comment.