From 2a698ac0123ab47ce020862b8ad0c32dc63cfc98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20M=C4=9Bs=C3=AD=C4=8Dek?= Date: Thu, 16 May 2024 11:14:45 +0200 Subject: [PATCH 1/4] Update versions --- .editorconfig | 23 ++++++++++++++++++----- buildSrc/src/main/kotlin/Versions.kt | 4 ++-- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index f01f364..a8ea9af 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,22 @@ [*.{kt,kts}] -max_line_length=130 +max_line_length = 140 indent_style = space -indent_size=4 -continuation_indent_size=4 -ktlint_standard_import-ordering=disabled -ij_kotlin_allow_trailing_comma=true +indent_size = 4 + +insert_final_newline = true +trim_trailing_whitespace = true + +ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true + +continuation_indent_size = 4 +ktlint_standard_import-ordering = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_context-receiver-wrapping = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_no-blank-line-in-list = disabled +ktlint_standard_blank-line-before-declaration = disabled + + diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 2bacd6d..e3639a6 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -7,8 +7,8 @@ object Versions { // plugins const val detekt = "1.22.0" - const val ktlintGradle = "11.2.0" - const val ktlint = "0.48.2" + const val ktlintGradle = "12.1.1" + const val ktlint = "1.2.1" // kotlin const val kotlin = "1.9.23" From 09b62b63d2491f0eec9810e7e459f743aee479d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20M=C4=9Bs=C3=AD=C4=8Dek?= Date: Thu, 16 May 2024 11:38:32 +0200 Subject: [PATCH 2/4] Update detekt file --- .editorconfig | 1 + app/build.gradle.kts | 10 ++++--- .../injection/modules/ApplicationModule.kt | 8 ++++-- .../navigation/Destinations.kt | 27 +++++++++---------- .../tools/compose/Previews.kt | 2 ++ .../_templateScreen/_TEMPLATEScreen.kt | 4 +-- .../ui/screens/home/HomeScreen.kt | 3 +-- buildSrc/src/main/kotlin/Versions.kt | 2 +- 8 files changed, 32 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index a8ea9af..a81f2b3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,5 +18,6 @@ ktlint_standard_multiline-expression-wrapping = disabled ktlint_standard_no-empty-first-line-in-class-body = disabled ktlint_standard_no-blank-line-in-list = disabled ktlint_standard_blank-line-before-declaration = disabled +ktlint_standard_annotation = disabled diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 791aad7..41a4600 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,5 @@ +@file:Suppress("MagicNumber") + plugins { id("com.android.application") kotlin("android") @@ -46,12 +48,12 @@ android.apply { compileOptions { isCoreLibraryDesugaringEnabled = true - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions.apply { - jvmTarget = JavaVersion.VERSION_11.toString() + jvmTarget = JavaVersion.VERSION_17.toString() } composeOptions { @@ -137,7 +139,7 @@ android.apply { } kotlin { - jvmToolchain(11) + jvmToolchain(17) } dependencies { diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/injection/modules/ApplicationModule.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/injection/modules/ApplicationModule.kt index 2c4dfbb..7cb13e7 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/injection/modules/ApplicationModule.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/injection/modules/ApplicationModule.kt @@ -18,7 +18,9 @@ import kotlinx.serialization.modules.SerializersModule class ApplicationModule { @Provides - fun resources(@ApplicationContext context: Context): Resources = context.resources + fun resources( + @ApplicationContext context: Context, + ): Resources = context.resources @Provides fun json(): Json = Json(from = Json.Default) { @@ -31,6 +33,8 @@ class ApplicationModule { } @Provides - fun sharedPrefs(@ApplicationContext context: Context) = + fun sharedPrefs( + @ApplicationContext context: Context, + ) = PreferenceManager.getDefaultSharedPreferences(context) } diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/navigation/Destinations.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/navigation/Destinations.kt index 1ee95fa..4bd04bf 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/navigation/Destinations.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/navigation/Destinations.kt @@ -1,7 +1,6 @@ package app.futured.androidprojecttemplate.navigation import androidx.compose.animation.AnimatedContentScope -import androidx.compose.animation.AnimatedVisibilityScope import androidx.compose.runtime.Composable import androidx.compose.ui.window.DialogProperties import androidx.navigation.NamedNavArgument @@ -40,19 +39,19 @@ sealed class Destination( route = "detail/{title}?subtitle={subtitle}?value={value}", destinationScreen = { DetailScreen(navigation = it) }, arguments = - listOf( - navArgument("title") { - type = NavType.StringType - }, - navArgument("subtitle") { - type = NavType.StringType - defaultValue = "Default subtitle" - }, - navArgument("value") { - type = NavType.StringType - nullable = true - }, - ), + listOf( + navArgument("title") { + type = NavType.StringType + }, + navArgument("subtitle") { + type = NavType.StringType + defaultValue = "Default subtitle" + }, + navArgument("value") { + type = NavType.StringType + nullable = true + }, + ), ) { fun buildRoute(title: String, subtitle: String?, value: String?): String = route .withArgument("title", title) diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/tools/compose/Previews.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/tools/compose/Previews.kt index de58ba2..7f6c68f 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/tools/compose/Previews.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/tools/compose/Previews.kt @@ -1,3 +1,5 @@ +@file:Suppress("TopLevelPropertyNaming") + package app.futured.androidprojecttemplate.tools.compose import android.content.res.Configuration diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/_templateScreen/_TEMPLATEScreen.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/_templateScreen/_TEMPLATEScreen.kt index e3bdd1a..8be03f9 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/_templateScreen/_TEMPLATEScreen.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/_templateScreen/_TEMPLATEScreen.kt @@ -1,4 +1,5 @@ @file:OptIn(ExperimentalMaterial3Api::class) +@file:Suppress("PackageNaming") package app.futured.androidprojecttemplate.ui.screens._templateScreen @@ -99,8 +100,7 @@ object TEMPLATE { @Composable fun TEMPLATEContentPreview() = Showcase { TEMPLATE.Content( - actions = - object : TEMPLATE.Actions { + actions = object : TEMPLATE.Actions { override fun onNavigateBack() = Unit }, ) diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/home/HomeScreen.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/home/HomeScreen.kt index 134041c..3106b55 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/home/HomeScreen.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/screens/home/HomeScreen.kt @@ -93,8 +93,7 @@ object Home { fun HomeContentPreview() { Showcase { Home.Content( - actions = - object : Home.Actions { + actions = object : Home.Actions { override fun onNavigateToDetail() = Unit override fun onIncrementCounter() = Unit }, diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index e3639a6..0ec9804 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -6,7 +6,7 @@ object Versions { const val androidGradlePlugin = "8.4.0" // plugins - const val detekt = "1.22.0" + const val detekt = "1.23.6" const val ktlintGradle = "12.1.1" const val ktlint = "1.2.1" From 92176a91ad3a17f233f09f7d91f3bb662a20580f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20M=C4=9Bs=C3=AD=C4=8Dek?= Date: Thu, 16 May 2024 11:39:17 +0200 Subject: [PATCH 3/4] Update detekt file --- .../kotlin/app/futured/androidprojecttemplate/ui/NavGraph.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/NavGraph.kt b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/NavGraph.kt index 52c9542..51c58dc 100644 --- a/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/NavGraph.kt +++ b/app/src/main/kotlin/app/futured/androidprojecttemplate/ui/NavGraph.kt @@ -1,6 +1,5 @@ package app.futured.androidprojecttemplate.ui -import androidx.activity.compose.LocalOnBackPressedDispatcherOwner import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.navigation.NavHostController @@ -19,10 +18,6 @@ fun NavGraph( navController: NavHostController = rememberNavController(), navigation: NavRouter = remember { NavRouterImpl(navController) }, ) { - LocalOnBackPressedDispatcherOwner.current?.onBackPressedDispatcher?.let { - navController.navigateUp() - } - NavHost( navController = navController, startDestination = Destination.Home.route, From cc8e8496f8697ff57c097e60525be0527ff8ff7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20M=C4=9Bs=C3=AD=C4=8Dek?= Date: Thu, 16 May 2024 11:54:41 +0200 Subject: [PATCH 4/4] Delete magic number --- app/build.gradle.kts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 41a4600..10601ba 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,3 @@ -@file:Suppress("MagicNumber") - plugins { id("com.android.application") kotlin("android") @@ -139,7 +137,7 @@ android.apply { } kotlin { - jvmToolchain(17) + jvmToolchain(JavaVersion.VERSION_17.majorVersion.toInt()) } dependencies {