Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ ktlint_standard_property-naming = disabled
# This doesn't appear to have an impact at the moment, so we may still need to use suppress
# annotations for it.
ktlint_standard_parameter-wrapping = disabled
ktlint_standard_kdoc = disabled

# Some rules from the Compose ruleset are not working. These are being overridden here for now.
ktlint_function_naming_ignore_when_annotated_with = Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
with(target) {
with(pluginManager) {
apply(libs.plugin("agp-application").pluginId)
apply(libs.plugin("kgp").pluginId)
apply(libs.plugin("kotlin-serialization").pluginId)
}
Comment thread
Falah-Zaidan marked this conversation as resolved.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.theguardian.convention

import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.gradle.LibraryExtension
import com.theguardian.convention.shared.configureAndroidModule
import com.theguardian.convention.shared.configureAndroidTests
import com.theguardian.convention.shared.dokkaConfig
Expand Down Expand Up @@ -32,7 +32,6 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {

with(pluginManager) {
apply(libs.plugin("agp-library").pluginId)
apply(libs.plugin("kgp").pluginId)
apply(libs.plugin("dokka").pluginId)
}
Comment thread
Falah-Zaidan marked this conversation as resolved.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.theguardian.convention

import com.android.build.gradle.TestExtension
import com.android.build.api.dsl.TestExtension
import com.theguardian.convention.shared.configureAndroidModule
import com.theguardian.convention.shared.configureAndroidTests
import com.theguardian.convention.shared.libs
Expand All @@ -27,7 +27,6 @@ class AndroidTestConventionPlugin : Plugin<Project> {
with(target) {
with(pluginManager) {
apply(libs.plugin("agp-test").pluginId)
apply(libs.plugin("kgp").pluginId)
}

Comment thread
Falah-Zaidan marked this conversation as resolved.
setupDetekt()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.theguardian.convention

import com.android.build.gradle.LibraryExtension
import com.android.build.api.dsl.LibraryExtension
import com.theguardian.convention.shared.configureAndroidCompose
import com.theguardian.convention.shared.libs
import com.theguardian.convention.shared.plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,25 @@ package com.theguardian.convention.shared
import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension

/**
* This extension function applies the correct flags and dependencies to the module represented by
* the [Project].
*/
internal fun Project.configureAndroidCompose(
extension: CommonExtension<*, *, *, *, *, *>,
extension: CommonExtension,
) {
with(pluginManager) {
apply(libs.findPlugin("compose-compiler").get().get().pluginId)
}

extension.apply {
buildFeatures {
compose = true
}

extensions.configure(ComposeCompilerGradlePluginExtension::class.java) {
reportsDestination.set(layout.buildDirectory.dir("compose_compiler"))
Comment thread
Falah-Zaidan marked this conversation as resolved.
}
buildFeatures.compose = true

dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
add("implementation", platform(bom))

// View inter-op
add("implementation", "androidx.compose.ui:ui-viewbinding")
// Animations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@ import org.gradle.kotlin.dsl.invoke
* Provides AndroidTest dependencies, and sets up Gradle Managed devices to run tests on CI.
*/
internal fun Project.configureAndroidTests(
extension: CommonExtension<*, *, *, *, *, *>,
extension: CommonExtension,
isTestModule: Boolean = false,
) {
with(extension) {

extension.apply {
if (!isTestModule) {
configureGradleManagedDevices()
}

defaultConfig {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

dependencies {
Expand All @@ -36,20 +35,16 @@ internal fun Project.configureAndroidTests(
/**
* This extension function creates a gradle managed device for the receiver project.
*/
private fun CommonExtension<*, *, *, *, *, *>.configureGradleManagedDevices() {
testOptions {
managedDevices {
allDevices {
maybeCreate("ciDevice", ManagedVirtualDevice::class.java).apply {
// Use device profiles you typically see in Android Studio.
device = "Pixel 8"
// Use only API levels 27 and higher.
apiLevel = 36
// To include Google services, use the "google"/"google-atd" variants
// "aosp-atd"/"google-atd"/"aosp"/"google"
systemImageSource = "aosp-atd"
}
}
private fun CommonExtension.configureGradleManagedDevices() {
testOptions.managedDevices.allDevices {
maybeCreate("ciDevice", ManagedVirtualDevice::class.java).apply {
// Use device profiles you typically see in Android Studio.
device = "Pixel 8"
// Use only API levels 27 and higher.
apiLevel = 36
// To include Google services, use the "google"/"google-atd" variants
// "aosp-atd"/"google-atd"/"aosp"/"google"
systemImageSource = "aosp-atd"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ internal fun VersionCatalog.plugin(alias: String): PluginDependency = findPlugin
* Sets up core config for all Android modules - application and library.
*/
internal inline fun <reified T : KotlinBaseExtension> Project.configureAndroidModule(
extension: CommonExtension<*, *, *, *, *, *>,
extension: CommonExtension,
) {
extension.apply {
defaultConfig {
defaultConfig.apply {
minSdk = libs.findVersion("minsdk").get().toString().toInt()
compileSdk = libs.findVersion("compilesdk").get().toString().toInt()
}
Expand Down
1 change: 0 additions & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import org.jmailen.gradle.kotlinter.tasks.FormatTask

plugins {
alias(libs.plugins.agp.application) apply false
alias(libs.plugins.kgp) apply false
alias(libs.plugins.agp.library) apply false
alias(libs.plugins.kotlinter) apply false
alias(libs.plugins.detekt) apply false
Expand Down
6 changes: 2 additions & 4 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ targetsdk = "36"
# it up
java = "21"

agp = "8.13.2"
agp = "9.0.1"
kotlin = "2.4.0"
# Kotlinter version is tied closely to min & max Kotlin and Gradle versions. Update Kotlinter
# when updating Kotlin. Check compatible versions here:
# https://github.com/jeremymailen/kotlinter-gradle/blob/master/README.md#compatibility
kotlinter = "5.0.1"
kotlinter = "5.5.0"

activity = "1.13.0"
adaptive-navigation3 = "1.3.0-alpha09"
Expand Down Expand Up @@ -102,7 +102,6 @@ agp-test = { id = "com.android.test", version.ref = "agp" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
licensee = { id = "app.cash.licensee", version.ref = "licensee" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
kgp = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
Expand All @@ -113,6 +112,5 @@ metalava = { id = "me.tylerbwong.gradle.metalava", version.ref = "metalava" }
guardian-application = { id = "com.theguardian.application", version.ref = "guardian-convention-plugins" }
guardian-library-android = { id = "com.theguardian.library.android", version.ref = "guardian-convention-plugins" }
guardian-test-android = { id = "com.theguardian.test.android", version.ref = "guardian-convention-plugins" }
guardian-library-kotlin = { id = "com.theguardian.library.kotlin", version.ref = "guardian-convention-plugins" }
guardian-compose-library = { id = "com.theguardian.compose.library", version.ref = "guardian-convention-plugins" }
guardian-compose-application = { id = "com.theguardian.compose.application", version.ref = "guardian-convention-plugins" }
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ data class ButtonColours(
/**
* Maps a [SourceButton.Priority] to a set of colours based on the theme.
*/
internal fun SourceButton.Priority.toColours(theme: Source.Theme) = when (theme) {
internal fun SourceButton.Priority.toColours(
theme: Source.Theme,
) = when (theme) {
Core -> when (this) {
PrimaryOnWhite -> {
ButtonColours(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ private fun getSpacing(
}

is ChipDecoration.Image -> if (hasText) 8.dp else 0.dp

ChipDecoration.None -> 0.dp
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private suspend fun animateScrollToNext(
) {
val page = when (direction) {
ProgressDirection.Previous -> (pagerState.currentPage - 1).coerceAtLeast(0)

ProgressDirection.Next -> (pagerState.currentPage + 1)
.coerceAtMost(pagerState.pageCount - 1)
}
Expand Down
Loading