Skip to content

Commit

Permalink
🔀 Merge remote-tracking branch 'origin/main' into fix/tests
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/src/androidTest/java/com/escodro/alkaa/TaskFlowTest.kt
  • Loading branch information
igorescodro committed Sep 27, 2022
2 parents 1f5d5c6 + 8806047 commit d9bcb01
Show file tree
Hide file tree
Showing 41 changed files with 557 additions and 389 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ One of the main goals of Alkaa is too use all the latest libraries and tools ava

- Application entirely written in [Kotlin](https://kotlinlang.org)
- Complete migrated to [Jetpack Compose](https://developer.android.com/jetpack/compose)
- Following the [Material You](https://m3.material.io/) guidelines and dynamic color
- Asynchronous processing using [Coroutines](https://kotlin.github.io/kotlinx.coroutines/)
- [Dynamic delivery](https://developer.android.com/guide/playcore/feature-delivery) for the _Task
Tracker_ feature
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ dependencies {

androidTestImplementation(projects.libraries.test)
androidTestImplementation(libs.koin.test)
androidTestImplementation(libs.test.hamcrest)
androidTestImplementation(libs.bundles.composetest) {
exclude(group = "androidx.core", module = "core-ktx")
exclude(group = "androidx.fragment", module = "fragment")
Expand Down
12 changes: 3 additions & 9 deletions app/src/androidTest/java/com/escodro/alkaa/TaskFlowTest.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.escodro.alkaa

import androidx.annotation.StringRes
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.assertIsSelected
import androidx.compose.ui.test.hasSetTextAction
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
Expand All @@ -19,10 +18,9 @@ import com.escodro.core.coroutines.CoroutineDebouncer
import com.escodro.designsystem.AlkaaTheme
import com.escodro.local.model.Category
import com.escodro.local.provider.DaoProvider
import com.escodro.task.presentation.category.ChipNameKey
import com.escodro.test.DisableAnimationsRule
import com.escodro.test.Events
import com.escodro.test.assertIsChecked
import com.escodro.test.onChip
import com.escodro.test.waitUntilExists
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runTest
Expand Down Expand Up @@ -123,7 +121,7 @@ internal class TaskFlowTest : KoinTest {

// Reopen the task and validate if the category is selected
onNodeWithText(text = taskName, useUnmergedTree = true).performClick()
onChip(category).assertIsChecked()
onChip(category).assertIsSelected()
}
}

Expand Down Expand Up @@ -197,8 +195,4 @@ internal class TaskFlowTest : KoinTest {
val taskTitle = context.getString(HomeSection.Tasks.title)
composeTestRule.waitUntilExists(hasText(taskTitle))
}

private fun ComposeTestRule.onChip(chipName: String) = onNode(
SemanticsMatcher.expectValue(ChipNameKey, chipName)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class MainActivity : ComponentActivity() {
val isDarkTheme = rememberIsDarkTheme()
updateTheme(isDarkTheme)

AlkaaTheme(darkTheme = isDarkTheme) {
AlkaaTheme(isDarkTheme = isDarkTheme) {
NavGraph()
}
}
Expand Down
48 changes: 23 additions & 25 deletions app/src/main/java/com/escodro/alkaa/presentation/home/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@ package com.escodro.alkaa.presentation.home

import androidx.compose.animation.Crossfade
import androidx.compose.animation.animateColorAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.padding
import androidx.compose.material.BottomAppBar
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.TopAppBar
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.escodro.alkaa.model.HomeSection
import com.escodro.category.presentation.list.CategoryListSection
import com.escodro.designsystem.AlkaaTheme
Expand All @@ -41,7 +40,6 @@ fun Home(
) {
val (currentSection, setCurrentSection) = rememberSaveable { mutableStateOf(HomeSection.Tasks) }
val navItems = HomeSection.values().toList()
val homeModifier = Modifier.padding(bottom = 56.dp)

val actions = HomeActions(
onTaskClick = onTaskClick,
Expand All @@ -55,26 +53,25 @@ fun Home(
Crossfade(currentSection) { homeSection ->
AlkaaHomeScaffold(
homeSection = homeSection,
modifier = homeModifier,
navItems = navItems,
actions = actions
)
}
}

@OptIn(ExperimentalMaterial3Api::class, ExperimentalLayoutApi::class)
@Composable
private fun AlkaaHomeScaffold(
homeSection: HomeSection,
modifier: Modifier,
navItems: List<HomeSection>,
actions: HomeActions
) {
Scaffold(
topBar = {
AlkaaTopBar(currentSection = homeSection)
},
content = {
AlkaaContent(homeSection, modifier, actions)
content = { paddingValues ->
AlkaaContent(homeSection, Modifier.padding(paddingValues), actions)
},
bottomBar = {
AlkaaBottomNav(
Expand Down Expand Up @@ -116,17 +113,18 @@ private fun AlkaaContent(
}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun AlkaaTopBar(currentSection: HomeSection) {
TopAppBar(backgroundColor = MaterialTheme.colors.background, elevation = 0.dp) {
Box(modifier = Modifier.fillMaxSize()) {
CenterAlignedTopAppBar(
title = {
Text(
modifier = Modifier.align(Alignment.Center),
style = MaterialTheme.typography.h5,
text = stringResource(currentSection.title)
style = MaterialTheme.typography.headlineMedium.copy(fontWeight = FontWeight.Light),
text = stringResource(currentSection.title),
color = MaterialTheme.colorScheme.tertiary
)
}
}
)
}

@Composable
Expand All @@ -135,14 +133,14 @@ private fun AlkaaBottomNav(
onSectionSelect: (HomeSection) -> Unit,
items: List<HomeSection>
) {
BottomAppBar(backgroundColor = MaterialTheme.colors.background) {
BottomAppBar(containerColor = MaterialTheme.colorScheme.background) {
items.forEach { section ->
val selected = section == currentSection
val colorState = animateColorAsState(
if (selected) {
MaterialTheme.colors.primary
MaterialTheme.colorScheme.primary
} else {
MaterialTheme.colors.onSecondary
MaterialTheme.colorScheme.outline
}
)
AlkaaBottomIcon(
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
<monochrome android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
7 changes: 4 additions & 3 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
<monochrome android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
2 changes: 2 additions & 0 deletions config/filters/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ comments:
active: false
CommentOverPrivateProperty:
active: false
UndocumentedPublicProperty:
excludes: ['**/designsystem/**']

style:
DataClassShouldBeImmutable:
Expand Down
1 change: 1 addition & 0 deletions data/local/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
implementation(libs.koin.android)
implementation(libs.androidx.room.runtime)
implementation(libs.androidx.room.ktx)
implementation(libs.test.junitext)
kapt(libs.androidx.room.compiler)

androidTestImplementation(libs.test.runner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import android.database.sqlite.SQLiteDatabase
import androidx.room.Room
import androidx.room.testing.MigrationTestHelper
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.escodro.core.extension.getIntFromColumn
import com.escodro.core.extension.getLongFromColumn
Expand All @@ -20,7 +20,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import java.io.IOException

@RunWith(AndroidJUnit4ClassRunner::class)
@RunWith(AndroidJUnit4::class)
class MigrationTest {

private val allMigrations = arrayOf(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import androidx.compose.foundation.lazy.LazyRow
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Button
import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
Expand Down Expand Up @@ -139,6 +139,7 @@ private fun CategorySheetContent(
modifier = Modifier
.fillMaxWidth()
.height(256.dp)
.background(MaterialTheme.colorScheme.surface) // Accompanist does not support M3 yet
.padding(16.dp),
verticalArrangement = Arrangement.SpaceAround
) {
Expand Down Expand Up @@ -244,14 +245,14 @@ private fun CategorySaveButton(currentColor: Color, onClick: () -> Unit) {
val colorState = animateColorAsState(targetValue = currentColor)
Button(
onClick = onClick,
colors = ButtonDefaults.buttonColors(backgroundColor = colorState.value),
colors = ButtonDefaults.buttonColors(containerColor = colorState.value),
modifier = Modifier
.fillMaxWidth()
.height(48.dp)
) {
Text(
text = stringResource(id = R.string.category_sheet_save),
color = MaterialTheme.colors.background
color = MaterialTheme.colorScheme.background
)
}
}
Expand Down Expand Up @@ -283,7 +284,7 @@ private fun CategoryColorItem(
modifier = Modifier
.size(16.dp)
.clip(CircleShape)
.background(MaterialTheme.colors.background)
.background(MaterialTheme.colorScheme.background)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material.Card
import androidx.compose.material.FabPosition
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Scaffold
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Bookmark
import androidx.compose.material.icons.outlined.ThumbUp
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FabPosition
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -91,6 +93,7 @@ private fun CategoryListLoader(
)
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun CategoryListScaffold(
modifier: Modifier,
Expand Down Expand Up @@ -144,8 +147,8 @@ private fun CategoryItem(
category: Category,
onItemClick: (Long) -> Unit
) {
Card(
elevation = 4.dp,
ElevatedCard(
elevation = CardDefaults.elevatedCardElevation(4.dp),
modifier = modifier
.fillMaxWidth()
.padding(all = 8.dp)
Expand Down Expand Up @@ -173,7 +176,7 @@ private fun CategoryItemIcon(color: Int) {
Icon(
imageVector = Icons.Default.Bookmark,
contentDescription = stringResource(id = R.string.category_icon_cd),
tint = MaterialTheme.colors.background
tint = MaterialTheme.colorScheme.background
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.escodro.glance.presentation

import android.content.Context
import android.content.Intent
import androidx.compose.material.MaterialTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -69,7 +69,7 @@ internal class TaskListGlanceWidget : GlanceAppWidget(), KoinComponent {
.fillMaxSize()
.cornerRadius(12.dp)
.appWidgetBackground()
.background(color = MaterialTheme.colors.background)
.background(color = MaterialTheme.colorScheme.background)
.padding(8.dp)
) {
Row(
Expand Down
Loading

0 comments on commit d9bcb01

Please sign in to comment.