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
31 changes: 20 additions & 11 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt.gradle)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.compose.compiler)
}

Expand All @@ -37,14 +34,11 @@ android {
versionCode = 1
versionName = "1.0"

testInstrumentationRunner = "android.template.core.testing.HiltTestRunner"

vectorDrawables {
useSupportLibrary = true
}

// Enable room auto-migrations
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

buildTypes {
Expand All @@ -63,17 +57,21 @@ android {
compose = true
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

packagingOptions {
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

// Enable room auto-migrations
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

// Migrate from kotlinOptions to compilerOptions
kotlin {
compilerOptions {
Expand All @@ -86,14 +84,17 @@ dependencies {
implementation(project(":feature-mymodel"))
implementation(project(":feature-mymodel-navigation"))


// Core Android dependencies
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.activity.compose)

// Hilt Dependency Injection
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)
kspAndroidTest(libs.hilt.compiler)
kspTest(libs.hilt.compiler)

// Arch Components
implementation(libs.androidx.lifecycle.runtime.compose)
Expand All @@ -112,4 +113,12 @@ dependencies {
// Navigation
implementation(libs.androidx.navigation3.ui)
implementation(libs.androidx.lifecycle.viewmodel.navigation3)

// Instrumented tests
androidTestImplementation(composeBom)
androidTestImplementation(project(":core-testing"))
androidTestImplementation(libs.androidx.test.runner)
androidTestImplementation(libs.hilt.android.testing)
androidTestImplementation(libs.androidx.test.ext.junit)
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
}
44 changes: 44 additions & 0 deletions app/src/androidTest/java/android/template/ui/NavigationTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.template.ui

import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import dagger.hilt.android.testing.HiltAndroidRule
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@HiltAndroidTest
class NavigationTest {

@get:Rule(order = 0)
var hiltRule = HiltAndroidRule(this)

@get:Rule(order = 1)
val composeTestRule = createAndroidComposeRule<MainActivity>()

@Test
fun mainActivity_showsMainScreen() {
// Here we just verify that something from the main screen is displayed.
composeTestRule.onNodeWithText("Save").assertExists()

// TODO: Add actions and assertions to test navigation
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/android/template/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package android.template.ui

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.SystemBarStyle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
Expand All @@ -30,6 +32,12 @@ import android.template.core.ui.MyApplicationTheme
class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge(
statusBarStyle = SystemBarStyle.auto(
lightScrim = android.graphics.Color.TRANSPARENT,
darkScrim = android.graphics.Color.TRANSPARENT
)
)
super.onCreate(savedInstanceState)
setContent {
MyApplicationTheme {
Expand Down
8 changes: 2 additions & 6 deletions core-data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.ksp)
}

android {
Expand All @@ -29,15 +27,13 @@ android {

defaultConfig {
minSdk = 23

testInstrumentationRunner = "android.template.core.testing.HiltTestRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildFeatures {
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

Expand All @@ -58,7 +54,7 @@ dependencies {

// Arch Components
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)

implementation(libs.kotlinx.coroutines.android)

Expand Down
Empty file added core-data/consumer-rules.pro
Empty file.
18 changes: 6 additions & 12 deletions core-database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.ksp)
alias(libs.plugins.kotlin.kapt)

}

android {
Expand All @@ -30,16 +28,8 @@ android {

defaultConfig {
minSdk = 23

testInstrumentationRunner = "android.template.core.testing.HiltTestRunner"
consumerProguardFiles("consumer-rules.pro")

// The schemas directory contains a schema file for each version of the Room database.
// This is required to enable Room auto migrations.
// See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration.
ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}
}

buildFeatures {
Expand All @@ -55,6 +45,10 @@ android {
}
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

kotlin {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
Expand All @@ -67,5 +61,5 @@ dependencies {
implementation(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)
}
Empty file.
7 changes: 1 addition & 6 deletions core-testing/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.ksp)
}

android {
Expand All @@ -29,15 +27,13 @@ android {

defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildFeatures {
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

Expand All @@ -54,7 +50,6 @@ kotlin {
}

dependencies {

implementation(libs.androidx.test.runner)
implementation(libs.hilt.android.testing)
}
Empty file added core-testing/consumer-rules.pro
Empty file.
3 changes: 0 additions & 3 deletions core-ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
}

Expand All @@ -29,7 +27,6 @@ android {

defaultConfig {
minSdk = 23

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
Expand Down
Empty file added core-ui/consumer-rules.pro
Empty file.
8 changes: 1 addition & 7 deletions core-ui/src/main/java/android/template/core/ui/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,11 @@ fun MyApplicationTheme(
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
val view = LocalView.current
if (!view.isInEditMode) {
SideEffect {
(view.context as Activity).window.statusBarColor = colorScheme.primary.toArgb()
ViewCompat.getWindowInsetsController(view)?.isAppearanceLightStatusBars = darkTheme
}
}

MaterialTheme(
colorScheme = colorScheme,
typography = Typography,
content = content
)
}

2 changes: 1 addition & 1 deletion customizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ do
echo "Moving files to $n/java/$SUBDIR"
mv $n/java/android/template/* $n/java/$SUBDIR
echo "Removing old $n/java/android/template"
rm -rf mv $n/java/android
rm -rf $n/java/android
done

# Rename package and imports
Expand Down
3 changes: 0 additions & 3 deletions feature-mymodel-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.serialization)
}
Expand All @@ -35,7 +33,6 @@ android {
compose = true
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

Expand Down
Empty file.
14 changes: 7 additions & 7 deletions feature-mymodel/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

import org.jetbrains.kotlin.gradle.dsl.JvmTarget

@Suppress("DSL_SCOPE_VIOLATION") // Remove when fixed https://youtrack.jetbrains.com/issue/KTIJ-19369
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
alias(libs.plugins.ksp)
alias(libs.plugins.compose.compiler)
}

Expand All @@ -39,7 +37,6 @@ android {
compose = true
aidl = false
buildConfig = false
renderScript = false
shaders = false
}

Expand All @@ -58,6 +55,9 @@ kotlin {
dependencies {
implementation(project(":core-data"))
implementation(project(":core-ui"))
val composeBom = platform(libs.androidx.compose.bom)
implementation(composeBom)
androidTestImplementation(composeBom)
implementation(project(":feature-mymodel-navigation"))

androidTestImplementation(project(":core-testing"))
Expand Down Expand Up @@ -87,13 +87,13 @@ dependencies {

// Hilt Dependency Injection
implementation(libs.hilt.android)
kapt(libs.hilt.compiler)
ksp(libs.hilt.compiler)
// Hilt and instrumented tests.
androidTestImplementation(libs.hilt.android.testing)
kaptAndroidTest(libs.hilt.android.compiler)
kspAndroidTest(libs.hilt.compiler)
// Hilt and Robolectric tests.
testImplementation(libs.hilt.android.testing)
kaptTest(libs.hilt.android.compiler)
kspTest(libs.hilt.compiler)

// Local tests: jUnit, coroutines, Android runner
testImplementation(libs.junit)
Expand Down
Empty file.
Loading
Loading