diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8b27d42..c3a3fde 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,10 +15,10 @@ android { applicationId = "com.shahin.bookmine" minSdk = libs.versions.minSdkVersion.get().toInt() targetSdk = libs.versions.targetSdkVersion.get().toInt() - versionCode = 1 - versionName = "1.0" + versionCode = 2 + versionName = "1.1" - buildConfigField ("String", "MOCKY_IDENTIFIER", "\"c7738499-6a6d-49f4-a747-e293c7ee0fea\"") + buildConfigField ("String", "MOCKY_IDENTIFIER", "\"c23ee969-4e7c-40c3-9721-9c59b56346e0\"") testInstrumentationRunner = "com.shahin.bookmine.HiltTestRunner" vectorDrawables { diff --git a/app/release/baselineProfiles/0/app-release.dm b/app/release/baselineProfiles/0/app-release.dm new file mode 100644 index 0000000..929147d Binary files /dev/null and b/app/release/baselineProfiles/0/app-release.dm differ diff --git a/app/release/baselineProfiles/1/app-release.dm b/app/release/baselineProfiles/1/app-release.dm new file mode 100644 index 0000000..3c6dc60 Binary files /dev/null and b/app/release/baselineProfiles/1/app-release.dm differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..1ef0856 --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,37 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.shahin.bookmine", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0", + "outputFile": "app-release.apk" + } + ], + "elementType": "File", + "baselineProfiles": [ + { + "minApi": 28, + "maxApi": 30, + "baselineProfiles": [ + "baselineProfiles/1/app-release.dm" + ] + }, + { + "minApi": 31, + "maxApi": 2147483647, + "baselineProfiles": [ + "baselineProfiles/0/app-release.dm" + ] + } + ], + "minSdkVersionForDexing": 23 +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/shahin/bookmine/presentation/navigation/AppNavHostKtTest.kt b/app/src/androidTest/java/com/shahin/bookmine/presentation/navigation/AppNavHostKtTest.kt index a723782..632be89 100644 --- a/app/src/androidTest/java/com/shahin/bookmine/presentation/navigation/AppNavHostKtTest.kt +++ b/app/src/androidTest/java/com/shahin/bookmine/presentation/navigation/AppNavHostKtTest.kt @@ -56,11 +56,13 @@ class AppNavHostTest { @Test fun navigateToBookDetailsScreen() = runTest { - Thread.sleep(5000) // wait for some items to load + Thread.sleep(6000) // wait for some items to load composeTestRule.onAllNodesWithTag("books-screen")[0] // first item - whatever it is .performClick() // click on the first item + Thread.sleep(1000) // wait a second for the details screen to show up + composeTestRule.onNodeWithTag("book-details-screen") .assertIsDisplayed() diff --git a/core/database/src/androidTest/java/com/shahin/core/database/books/sources/BookDaoTest.kt b/core/database/src/androidTest/java/com/shahin/core/database/books/sources/BookDaoTest.kt index c112f2a..b7921fb 100644 --- a/core/database/src/androidTest/java/com/shahin/core/database/books/sources/BookDaoTest.kt +++ b/core/database/src/androidTest/java/com/shahin/core/database/books/sources/BookDaoTest.kt @@ -93,9 +93,21 @@ class BooksDaoTest { placeholdersEnabled = false ) ) + + // sizes should be the same since we have 3 items with "Book" in their title assertEquals( - listOf(dummyBooks[0], dummyBooks[1], dummyBooks[2]), - (result as PagingSource.LoadResult.Page).data + dummyBooks.size, + (result as PagingSource.LoadResult.Page).data.size + ) + + // and the first item should the BookEntity with id = 3 + assertEquals( + 3, // expected id the 3 + (result as PagingSource.LoadResult.Page).data[0].id + ) + assertEquals( + dummyBooks[2].id, + (result as PagingSource.LoadResult.Page).data[0].id ) } @@ -132,9 +144,18 @@ class BooksDaoTest { placeholdersEnabled = false ) ) + + // since a new reordering is added to the dao we'll have a slightly different expected list + // Reordering is from oldest to newest, so the first item should be [id = 3] + assertEquals( + dummyBooks[2].id, + (allBooksResult as PagingSource.LoadResult.Page).data[0].id + ) + + // now for checking if we're getting all the results we should just check the size assertEquals( - dummyBooks, - (allBooksResult as PagingSource.LoadResult.Page).data + dummyBooks.size, + (allBooksResult as PagingSource.LoadResult.Page).data.size ) } diff --git a/core/database/src/main/java/com/shahin/core/database/books/sources/BooksDao.kt b/core/database/src/main/java/com/shahin/core/database/books/sources/BooksDao.kt index 13522a1..eb2b9c3 100644 --- a/core/database/src/main/java/com/shahin/core/database/books/sources/BooksDao.kt +++ b/core/database/src/main/java/com/shahin/core/database/books/sources/BooksDao.kt @@ -30,7 +30,20 @@ interface BooksDao { * [getBooksByTitle] returns all [BookEntity]s when [title] is empty and not blank */ @Transaction - @Query(" SELECT * FROM books WHERE title LIKE '%' || :title || '%' ") + @Query(""" + SELECT * FROM books + WHERE title LIKE '%' || :title || '%' + ORDER BY + CASE + WHEN release_date LIKE '% BC' THEN -CAST(SUBSTR(release_date, 1, LENGTH(release_date) - 3) AS INT) + ELSE CAST(SUBSTR(release_date, -4) AS INT) + END DESC, + CASE + WHEN release_date LIKE '%/%/%' THEN STRFTIME('%Y-%m-%d', release_date) + ELSE STRFTIME('%Y-01-01', release_date || '-01-01') + END DESC, + id ASC + """) fun getBooksByTitle(title: String): PagingSource /** diff --git a/feature/book_details/src/main/java/com/shahin/feature/book_details/presentation/BookDetailsScreen.kt b/feature/book_details/src/main/java/com/shahin/feature/book_details/presentation/BookDetailsScreen.kt index 895d6d2..984a633 100644 --- a/feature/book_details/src/main/java/com/shahin/feature/book_details/presentation/BookDetailsScreen.kt +++ b/feature/book_details/src/main/java/com/shahin/feature/book_details/presentation/BookDetailsScreen.kt @@ -46,6 +46,7 @@ import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource +import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.text.font.FontWeight @@ -322,7 +323,7 @@ private fun DetailsScreenContent( modifier = Modifier.testTag("details-author"), text = buildAnnotatedString { withStyle(SpanStyle(fontWeight = FontWeight.Bold)) { - append("Author:") + append(stringResource(R.string.author)) } append(" ") append(bookDetails?.author.orEmpty()) diff --git a/feature/book_details/src/main/res/values/strings.xml b/feature/book_details/src/main/res/values/strings.xml new file mode 100644 index 0000000..62f1f94 --- /dev/null +++ b/feature/book_details/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Author: + \ No newline at end of file