Skip to content

Commit

Permalink
Merge pull request #182 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
WrapPinTextField Improvements, Kotlin 2, new Compose, Dependency Updates, Clean up code
  • Loading branch information
stzouvaras authored Sep 12, 2024
2 parents a7a2219 + 9087819 commit 96bc4fa
Show file tree
Hide file tree
Showing 29 changed files with 216 additions and 167 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ sign
#fastlane
.env.demo
.env.dev
fastlane/report.xml
fastlane/report.xml

# Kotlin
.kotlin/*
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import project.convention.logic.configureAndroidCompose
class AndroidApplicationComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.application")

with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.plugin.compose")
}
val extension = extensions.getByType<ApplicationExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import project.convention.logic.configureFlavors
import project.convention.logic.getProperty

class AndroidApplicationFlavorsConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {

val storedVersion = getProperty<String>(
"VERSION_NAME",
"version.properties"
).orEmpty()

extensions.configure<ApplicationExtension> {
configureFlavors(this, storedVersion)
configureFlavors(this)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,12 @@ import org.gradle.kotlin.dsl.dependencies
import project.convention.logic.configureFlavors
import project.convention.logic.configureGradleManagedDevices
import project.convention.logic.configureKotlinAndroid
import project.convention.logic.getProperty
import project.convention.logic.libs

@Suppress("UnstableApiUsage")
class AndroidBaseLineProfilePlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {

val storedVersion = getProperty<String>(
"VERSION_NAME",
"version.properties"
).orEmpty()

with(pluginManager) {
apply("com.android.test")
apply("org.jetbrains.kotlin.android")
Expand All @@ -47,7 +40,7 @@ class AndroidBaseLineProfilePlugin : Plugin<Project> {
with(defaultConfig) {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
configureFlavors(this, storedVersion)
configureFlavors(this)
configureGradleManagedDevices(this)
targetProjectPath = ":app"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import project.convention.logic.configureAndroidCompose
class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("com.android.library")

with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.plugin.compose")
}
val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import project.convention.logic.configureGradleManagedDevices
import project.convention.logic.configureKotlinAndroid
import project.convention.logic.configurePrintApksTask
import project.convention.logic.disableUnnecessaryAndroidTests
import project.convention.logic.getProperty
import project.convention.logic.libs

class AndroidLibraryConventionPlugin : Plugin<Project> {
Expand Down Expand Up @@ -59,11 +58,6 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
val openId4VciAuthorizationScheme = "eu.europa.ec.euidi"
val openId4VciAuthorizationHost = "authorization"

val storedVersion = getProperty<String>(
"VERSION_NAME",
"version.properties"
).orEmpty()

with(pluginManager) {
apply("com.android.library")
apply("project.android.library.kover")
Expand Down Expand Up @@ -116,7 +110,7 @@ class AndroidLibraryConventionPlugin : Plugin<Project> {
manifestPlaceholders["openId4VciAuthorizationHost"] =
openId4VciAuthorizationHost
}
configureFlavors(this, storedVersion)
configureFlavors(this)
configureGradleManagedDevices(this)
}
extensions.configure<LibraryAndroidComponentsExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ internal fun Project.configureAndroidCompose(
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion =
libs.findVersion("androidxComposeCompiler").get().toString()
}

dependencies {

val bom = libs.findLibrary("androidx-compose-bom").get()
Expand Down Expand Up @@ -74,8 +69,8 @@ internal fun Project.configureAndroidCompose(
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
compilerOptions {
freeCompilerArgs.addAll(buildComposeMetricsParameters())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.ApplicationProductFlavor
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.ProductFlavor
import org.gradle.api.Project

@Suppress("EnumEntryName")
enum class FlavorDimension {
Expand All @@ -35,11 +36,16 @@ enum class AppFlavor(
Demo(FlavorDimension.contentType)
}

fun configureFlavors(
fun Project.configureFlavors(
commonExtension: CommonExtension<*, *, *, *, *, *>,
version: String,
flavorConfigurationBlock: ProductFlavor.(flavor: AppFlavor) -> Unit = {}
) {

val version = getProperty<String>(
"VERSION_NAME",
"version.properties"
).orEmpty()

commonExtension.apply {
flavorDimensions += FlavorDimension.contentType.name
productFlavors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

/**
Expand Down Expand Up @@ -84,12 +85,12 @@ internal fun Project.configureKotlinJvm() {
*/
private fun Project.configureKotlin() {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
// Treat all Kotlin warnings as errors (disabled by default)
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)

val warningsAsErrors: String? by project
allWarningsAsErrors = warningsAsErrors.toBoolean()
freeCompilerArgs = freeCompilerArgs + listOf(
allWarningsAsErrors.set(warningsAsErrors.toBoolean())
freeCompilerArgs.addAll(
"-opt-in=kotlin.RequiresOptIn",
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-opt-in=kotlinx.coroutines.FlowPreview",
Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ plugins {
alias(libs.plugins.sonar) apply false
alias(libs.plugins.android.test) apply false
alias(libs.plugins.baselineprofile) apply false
alias(libs.plugins.compose.compiler) apply false
}
true
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import eu.europa.ec.uilogic.component.content.ScreenNavigateAction
import eu.europa.ec.uilogic.component.preview.PreviewTheme
import eu.europa.ec.uilogic.component.preview.ThemeModePreviews
import eu.europa.ec.uilogic.component.utils.OneTimeLaunchedEffect
import eu.europa.ec.uilogic.component.utils.SIZE_MEDIUM
import eu.europa.ec.uilogic.component.wrap.WrapIconButton
import eu.europa.ec.uilogic.component.wrap.WrapPinTextField
import eu.europa.ec.uilogic.config.ConfigNavigation
Expand Down Expand Up @@ -281,7 +282,7 @@ private fun PreviewBiometricScreen() {
effectFlow = Channel<Effect>().receiveAsFlow(),
onEventSent = {},
onNavigationRequested = {},
padding = PaddingValues(16.dp)
padding = PaddingValues(SIZE_MEDIUM.dp)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.content.ContextCompat
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.navigation.NavController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.isGranted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,15 @@ class QrScanViewModel(
val urlIsValid = validateForm(
form = Form(
inputs = mapOf(
listOf(Rule.ValidateUrl(
errorMessage = "",
shouldValidateSchema = true,
shouldValidateHost = false,
shouldValidatePath = false,
shouldValidateQuery = true,
)) to scannedQr
listOf(
Rule.ValidateUrl(
errorMessage = "",
shouldValidateSchema = true,
shouldValidateHost = false,
shouldValidatePath = false,
shouldValidateQuery = true,
)
) to scannedQr
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import eu.europa.ec.uilogic.component.content.ContentTitle
import eu.europa.ec.uilogic.component.content.ScreenNavigateAction
import eu.europa.ec.uilogic.component.preview.PreviewTheme
import eu.europa.ec.uilogic.component.preview.ThemeModePreviews
import eu.europa.ec.uilogic.component.utils.SIZE_MEDIUM
import eu.europa.ec.uilogic.component.wrap.WrapPrimaryButton
import eu.europa.ec.uilogic.component.wrap.WrapSecondaryButton
import eu.europa.ec.uilogic.config.ConfigNavigation
Expand Down Expand Up @@ -260,7 +261,7 @@ private fun SuccessDefaultPreview() {
effectFlow = Channel<Effect>().receiveAsFlow(),
onEventSent = {},
onNavigationRequested = {},
paddingValues = PaddingValues(16.dp)
paddingValues = PaddingValues(SIZE_MEDIUM.dp)
)
}
}
Expand Down Expand Up @@ -300,7 +301,7 @@ private fun SuccessDrawablePreview() {
effectFlow = Channel<Effect>().receiveAsFlow(),
onEventSent = {},
onNavigationRequested = {},
paddingValues = PaddingValues(16.dp)
paddingValues = PaddingValues(SIZE_MEDIUM.dp)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.buildAnnotatedString
Expand All @@ -60,6 +59,7 @@ import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.navigation.NavController
import com.google.accompanist.permissions.ExperimentalPermissionsApi
import com.google.accompanist.permissions.rememberMultiplePermissionsState
Expand Down
24 changes: 11 additions & 13 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
[versions]
accompanist = "0.34.0"
androidDesugarJdkLibs = "2.1.1"
androidDesugarJdkLibs = "2.1.2"
androidGradlePlugin = "8.6.0"
androidxActivity = "1.9.1"
androidxActivity = "1.9.2"
androidxAppCompat = "1.7.0"
androidxBrowser = "1.8.0"
androidxComposeBom = "2024.08.00"
androidxComposeCompiler = "1.5.11"
androidxComposeBom = "2024.09.01"
androidxComposeRuntimeTracing = "1.0.0-beta01"
androidxCore = "1.13.1"
androidxCoreSplashscreen = "1.0.1"
androidxDataStore = "1.1.1"
androidxEspresso = "3.6.1"
androidxLifecycle = "2.8.4"
androidxLifecycle = "2.8.5"
androidxMacroBenchmark = "1.3.0"
androidxMetrics = "1.0.0-beta01"
androidxNavigation = "2.7.7"
androidxNavigation = "2.8.0"
androidxProfileinstaller = "1.3.1"
androidxTestCore = "1.6.1"
androidxTestExt = "1.2.1"
Expand All @@ -33,11 +32,11 @@ coil = "2.6.0"
constraintlayoutVersion = "1.0.1"
gmsPlugin = "4.4.2"
junit4 = "4.13.2"
kotlin = "1.9.23"
kotlin = "2.0.10"
kotlinxCoroutines = "1.8.1"
kotlinxDatetime = "0.4.1"
kotlinxSerializationJson = "1.6.1"
ksp = "1.9.23-1.0.20"
kotlinxSerializationJson = "1.6.3"
ksp = "2.0.10-1.0.24"
lint = "31.6.0"
okhttp = "4.12.0"
protobuf = "3.24.0"
Expand All @@ -48,7 +47,6 @@ secrets = "2.0.1"
turbine = "1.1.0"
koin = "3.5.0"
koinAnnotations = "1.3.0"
org-jetbrains-kotlin-android = "1.9.23"
material = "1.12.0"
mockito = "5.12.0"
mockitoKotlin = "5.3.1"
Expand All @@ -62,8 +60,7 @@ eudiWalletCore = "0.11.1-SNAPSHOT"
cborTree = "0.01.02"
cameraCore = "1.3.4"
owaspDependencyCheck = "10.0.3"
material3 = "1.2.1"
workTesting = "2.9.0"
material3 = "1.3.0"
appCenter = "5.0.4"
kover = "0.7.5"
sonar = "5.0.0.4638"
Expand Down Expand Up @@ -182,7 +179,8 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "org-jetbrains-kotlin-android" }
org-jetbrains-kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
owasp-dependencycheck = { id = "org.owasp.dependencycheck", version.ref = "owaspDependencyCheck" }
kotlinx-kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
sonar = { id = "org.sonarqube", version.ref = "sonar" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.navigation.NavController
import eu.europa.ec.commonfeature.model.DocumentOptionItemUi
import eu.europa.ec.corelogic.controller.IssuanceMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ private fun CodeFieldLayout(
visualTransformation = PasswordVisualTransformation(),
pinWidth = 46.dp,
focusOnCreate = true,
shouldHideKeyboardOnCompletion = true
)
}

Expand Down
Loading

0 comments on commit 96bc4fa

Please sign in to comment.