diff --git a/app/src/androidTest/kotlin/ru/pixnews/inject/initializer/TestStrictModeInitializer.kt b/app/src/androidTest/kotlin/ru/pixnews/inject/initializer/TestStrictModeInitializer.kt index 0aeecde8..36044103 100644 --- a/app/src/androidTest/kotlin/ru/pixnews/inject/initializer/TestStrictModeInitializer.kt +++ b/app/src/androidTest/kotlin/ru/pixnews/inject/initializer/TestStrictModeInitializer.kt @@ -17,6 +17,8 @@ import ru.pixnews.anvil.codegen.initializer.inject.ContributesInitializer import ru.pixnews.foundation.initializers.Initializer import ru.pixnews.inject.DebugStrictModeInitializerModule import ru.pixnews.util.strictmode.ViolationPolicy.FAIL +import ru.pixnews.util.strictmode.isFontRequestViolation +import ru.pixnews.util.strictmode.isGmsDiskReadViolation import ru.pixnews.util.strictmode.isInstanceCountViolation import ru.pixnews.util.strictmode.isInstrumentationDexMakerViolation import ru.pixnews.util.strictmode.isProfileSizeOfAppViolation @@ -71,11 +73,13 @@ class TestStrictModeInitializer @Inject constructor(logger: Logger) : Initialize private companion object { val ALLOWLIST = listOf( + isFontRequestViolation, + isGmsDiskReadViolation, + isInstanceCountViolation, isInstrumentationDexMakerViolation, isProfileSizeOfAppViolation, isTypefaceFullFlipFontViolation, isUntaggedSocketViolation, - isInstanceCountViolation, ) } } diff --git a/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationExt.kt b/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationExt.kt index 768d36e1..4c2be8d0 100644 --- a/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationExt.kt +++ b/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationExt.kt @@ -29,6 +29,13 @@ internal val isTypefaceFullFlipFontViolation: Violation.() -> Boolean = { } } +@SuppressLint("NewApi") +internal val isFontRequestViolation: Violation.() -> Boolean = { + this is DiskReadViolation && this.stackTrace.any { + it.className == "androidx.core.provider.FontRequestWorker" && it.fileName == "FontRequestWorker.java" + } +} + @SuppressLint("NewApi") internal val isProfileSizeOfAppViolation: Violation.() -> Boolean = { this is DiskReadViolation && this.stackTrace.any { @@ -46,3 +53,13 @@ internal val isUntaggedSocketViolation: Violation.() -> Boolean = { internal val isInstanceCountViolation: Violation.() -> Boolean = { this is InstanceCountViolation } + +/** + * Difficult to diagnose violation in GMS + */ +@SuppressLint("NewApi") +internal val isGmsDiskReadViolation: Violation.() -> Boolean = { + (this is DiskReadViolation) && this.stackTrace.any { + it.fileName?.contains(":com.google.android.gms") ?: false + } +} diff --git a/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationListener.kt b/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationListener.kt index d167bbc7..7da9473f 100644 --- a/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationListener.kt +++ b/app/src/main/kotlin/ru/pixnews/util/strictmode/ViolationListener.kt @@ -72,7 +72,10 @@ internal class ViolationListener( ) { if (violation.shouldSkip()) { if (logAllowListViolation) { - logger.e { "Skipping $type violation `$violation: ${violation.message}`" } + logger.e { + "Skipping $type violation `$violation: message: ${violation.message}`, " + + "stracktrace: ${violation.stackTraceToString()}" + } } return } diff --git a/feature/calendar/public/src/main/kotlin/ru/pixnews/feature/calendar/ui/header/DateSelectionHeader.kt b/feature/calendar/public/src/main/kotlin/ru/pixnews/feature/calendar/ui/header/DateSelectionHeader.kt index 76dcdade..ca2e7efa 100644 --- a/feature/calendar/public/src/main/kotlin/ru/pixnews/feature/calendar/ui/header/DateSelectionHeader.kt +++ b/feature/calendar/public/src/main/kotlin/ru/pixnews/feature/calendar/ui/header/DateSelectionHeader.kt @@ -28,7 +28,7 @@ import androidx.compose.material.icons.filled.ArrowDropDown import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon import androidx.compose.material3.LocalContentColor -import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement +import androidx.compose.material3.LocalMinimumInteractiveComponentSize import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface @@ -143,7 +143,7 @@ internal fun WeekDaysRow( } CompositionLocalProvider( LocalTextStyle provides textStyle, - LocalMinimumInteractiveComponentEnforcement provides false, + LocalMinimumInteractiveComponentSize provides 42.dp, ) { Surface( contentColor = contentColor, diff --git a/foundation/ui/design/src/main/kotlin/ru/pixnews/foundation/ui/design/navigation/BottomNavigationBar.kt b/foundation/ui/design/src/main/kotlin/ru/pixnews/foundation/ui/design/navigation/BottomNavigationBar.kt index ded6e4eb..102b302b 100644 --- a/foundation/ui/design/src/main/kotlin/ru/pixnews/foundation/ui/design/navigation/BottomNavigationBar.kt +++ b/foundation/ui/design/src/main/kotlin/ru/pixnews/foundation/ui/design/navigation/BottomNavigationBar.kt @@ -7,18 +7,18 @@ package ru.pixnews.foundation.ui.design.navigation import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.RowScope -import androidx.compose.material.ripple.LocalRippleTheme import androidx.compose.material.ripple.RippleAlpha -import androidx.compose.material.ripple.RippleTheme +import androidx.compose.material3.LocalRippleConfiguration import androidx.compose.material3.MaterialTheme import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.NavigationBarItemColors import androidx.compose.material3.NavigationBarItemDefaults +import androidx.compose.material3.RippleConfiguration import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider -import androidx.compose.runtime.Immutable import androidx.compose.runtime.NonRestartableComposable +import androidx.compose.runtime.ReadOnlyComposable import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -28,7 +28,7 @@ public fun PixnewsBottomNavigationBar( modifier: Modifier = Modifier, content: @Composable RowScope.() -> Unit, ) { - CompositionLocalProvider(LocalRippleTheme provides NavigationBarItemRippleTheme) { + CompositionLocalProvider(LocalRippleConfiguration provides BottomNavigationBarDefaults.rippleConfiguration()) { NavigationBar( modifier = modifier, content = content, @@ -66,26 +66,25 @@ public fun RowScope.PixnewsBottomNavigationBarItem( } public object BottomNavigationBarDefaults { + private val rippleAlpha = RippleAlpha( + draggedAlpha = 0.16f, + focusedAlpha = 0.12f, + hoveredAlpha = 0.08f, + pressedAlpha = 0.12f, + ) + @Composable + @ReadOnlyComposable public fun indicatorColor(): Color = MaterialTheme.colorScheme.secondaryContainer @Composable + @ReadOnlyComposable public fun selectedIconColor(): Color = MaterialTheme.colorScheme.onSecondaryContainer @Composable - public fun rippleDefaultColor(): Color = MaterialTheme.colorScheme.secondary -} - -@Immutable -private object NavigationBarItemRippleTheme : RippleTheme { - @Composable - override fun defaultColor(): Color = BottomNavigationBarDefaults.rippleDefaultColor() - - @Composable - override fun rippleAlpha(): RippleAlpha = RippleAlpha( - draggedAlpha = 0.16f, - focusedAlpha = 0.12f, - hoveredAlpha = 0.08f, - pressedAlpha = 0.12f, + @ReadOnlyComposable + public fun rippleConfiguration(): RippleConfiguration = RippleConfiguration( + color = MaterialTheme.colorScheme.secondary, + rippleAlpha = rippleAlpha, ) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4dab3eca..3bec79de 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -23,7 +23,7 @@ androidx-appcompat = "1.7.0-beta01" androidx-arch-core = "2.2.0" androidx-benchmark = "1.2.4" androidx-collection = "1.4.0" -androidx-compose-bom = "2024.05.00" +chrisbanes-compose-bom = "2024.05.00-alpha01" androidx-compose-compiler = "1.5.13" androidx-compose-material3 = "1.2.1" androidx-compose-runtime-tracing = "1.0.0-beta01" @@ -93,7 +93,6 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidx-annotation" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" } androidx-benchmark-macro = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "androidx-benchmark" } -androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidx-compose-bom" } androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidx-compose-material3" } androidx-compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class" } @@ -145,6 +144,7 @@ arrow-bom = { group = "io.arrow-kt", name = "arrow-stack", version.ref = "arrow" arrow-core = { group = "io.arrow-kt", name = "arrow-core" } assertk = { group = "com.willowtreeapps.assertk", name = "assertk-jvm", version.ref = "assertk" } asm-bom = { group = "org.ow2.asm", name = "asm-bom", version.ref = "asm" } +chrisbanes-compose-bom = { group = "dev.chrisbanes.compose", name = "compose-bom", version.ref = "chrisbanes-compose-bom" } coil-base = { group = "io.coil-kt", name = "coil-base" } coil-bom = { group = "io.coil-kt", name = "coil-bom", version.ref = "coil" } coil-compose-base = { group = "io.coil-kt", name = "coil-compose-base" } @@ -229,7 +229,7 @@ wire-plugin = { group = "com.squareup.wire", name = "wire-gradle-plugin", versio [bundles] coil = ["coil-compose-base"] boms = [ - "androidx-compose-bom", + "chrisbanes-compose-bom", "arrow-bom", "asm-bom", "coil-bom", diff --git a/gradle/plugin/project/android/convention/ru.pixnews.gradle.android.test-instrumented.gradle.kts b/gradle/plugin/project/android/convention/ru.pixnews.gradle.android.test-instrumented.gradle.kts index fda56747..ccb1559d 100644 --- a/gradle/plugin/project/android/convention/ru.pixnews.gradle.android.test-instrumented.gradle.kts +++ b/gradle/plugin/project/android/convention/ru.pixnews.gradle.android.test-instrumented.gradle.kts @@ -89,7 +89,7 @@ fun configureAndroidTestDependencies() { add("androidTestImplementation", project(":foundation:instrumented-test")) add("androidTestRuntimeOnly", versionCatalog.findLibrary("androidx-test-runner").orElseThrow()) if (pixnews.compose.get()) { - val composeBom = platform(versionCatalog.findLibrary("androidx.compose.bom").orElseThrow()) + val composeBom = platform(versionCatalog.findLibrary("chrisbanes.compose.bom").orElseThrow()) add("androidTestImplementation", composeBom) } } diff --git a/gradle/plugin/project/android/src/main/kotlin/ru/pixnews/gradle/android/AndroidCompose.kt b/gradle/plugin/project/android/src/main/kotlin/ru/pixnews/gradle/android/AndroidCompose.kt index e705e44d..efe5ceca 100644 --- a/gradle/plugin/project/android/src/main/kotlin/ru/pixnews/gradle/android/AndroidCompose.kt +++ b/gradle/plugin/project/android/src/main/kotlin/ru/pixnews/gradle/android/AndroidCompose.kt @@ -28,7 +28,7 @@ internal fun Project.configureCompose( } dependencies { - val composeBom = platform(versionCatalog.findLibrary("androidx.compose.bom").orElseThrow()) + val composeBom = platform(versionCatalog.findLibrary("chrisbanes.compose.bom").orElseThrow()) add("implementation", composeBom) } diff --git a/gradle/plugin/project/kotlin/convention/ru.pixnews.gradle.kotlin.compose-compiler.gradle.kts b/gradle/plugin/project/kotlin/convention/ru.pixnews.gradle.kotlin.compose-compiler.gradle.kts index 460804f9..e46b4d4c 100644 --- a/gradle/plugin/project/kotlin/convention/ru.pixnews.gradle.kotlin.compose-compiler.gradle.kts +++ b/gradle/plugin/project/kotlin/convention/ru.pixnews.gradle.kotlin.compose-compiler.gradle.kts @@ -70,7 +70,7 @@ fun createComposeRuntimeCompileClasspath(): FileCollection { dependencies { add( compileClasspathAarConfiguration.name, - platform(versionCatalog.findLibrary("androidx-compose-bom").get()), + platform(versionCatalog.findLibrary("chrisbanes-compose-bom").get()), ) add(compileClasspathAarConfiguration.name, versionCatalog.findLibrary("androidx-compose-runtime").get())