Merge branch 'android:main' into datastore-exception

pull/1710/head
Nur Shuvo 9 months ago committed by GitHub
commit fe929ac879
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -5,3 +5,13 @@
ij_kotlin_allow_trailing_comma=true ij_kotlin_allow_trailing_comma=true
ij_kotlin_allow_trailing_comma_on_call_site=true ij_kotlin_allow_trailing_comma_on_call_site=true
ktlint_function_naming_ignore_when_annotated_with=Composable, Test ktlint_function_naming_ignore_when_annotated_with=Composable, Test
ktlint_standard_backing-property-naming = disabled
ktlint_standard_binary-expression-wrapping = disabled
ktlint_standard_chain-method-continuation = disabled
ktlint_standard_class-signature = disabled
ktlint_standard_condition-wrapping = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_function-literal = disabled
ktlint_standard_function-type-modifier-spacing = disabled
ktlint_standard_multiline-loop = disabled
ktlint_standard_function-signature = disabled

@ -166,7 +166,7 @@ jobs:
timeout-minutes: 55 timeout-minutes: 55
strategy: strategy:
matrix: matrix:
api-level: [26, 30] api-level: [26]
steps: steps:
- name: Delete unnecessary tools 🔧 - name: Delete unnecessary tools 🔧
@ -235,7 +235,7 @@ jobs:
- name: Display local test coverage (only API 30) - name: Display local test coverage (only API 30)
if: matrix.api-level == 30 if: matrix.api-level == 30
id: jacoco id: jacoco
uses: madrapps/jacoco-report@v1.7.0 uses: madrapps/jacoco-report@v1.7.1
with: with:
title: Combined test coverage report title: Combined test coverage report
min-coverage-overall: 40 min-coverage-overall: 40

@ -145,7 +145,7 @@ androidx.work:work-runtime-ktx:2.9.0
androidx.work:work-runtime:2.9.0 androidx.work:work-runtime:2.9.0
com.caverock:androidsvg-aar:1.4 com.caverock:androidsvg-aar:1.4
com.google.accompanist:accompanist-drawablepainter:0.32.0 com.google.accompanist:accompanist-drawablepainter:0.32.0
com.google.accompanist:accompanist-permissions:0.34.0 com.google.accompanist:accompanist-permissions:0.36.0
com.google.android.datatransport:transport-api:3.2.0 com.google.android.datatransport:transport-api:3.2.0
com.google.android.datatransport:transport-backend-cct:3.3.0 com.google.android.datatransport:transport-backend-cct:3.3.0
com.google.android.datatransport:transport-runtime:3.3.0 com.google.android.datatransport:transport-runtime:3.3.0

@ -30,6 +30,6 @@ import org.gradle.api.Project
internal fun LibraryAndroidComponentsExtension.disableUnnecessaryAndroidTests( internal fun LibraryAndroidComponentsExtension.disableUnnecessaryAndroidTests(
project: Project, project: Project,
) = beforeVariants { ) = beforeVariants {
it.enableAndroidTest = it.enableAndroidTest it.androidTest.enable = it.androidTest.enable
&& project.projectDir.resolve("src/androidTest").exists() && project.projectDir.resolve("src/androidTest").exists()
} }

@ -16,7 +16,13 @@
dependencyResolutionManagement { dependencyResolutionManagement {
repositories { repositories {
google() google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral() mavenCentral()
} }
versionCatalogs { versionCatalogs {

@ -16,7 +16,13 @@
buildscript { buildscript {
repositories { repositories {
google() google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral() mavenCentral()
// Android Build Server // Android Build Server

@ -522,6 +522,7 @@ private fun SearchTextField(
.focusRequester(focusRequester) .focusRequester(focusRequester)
.onKeyEvent { .onKeyEvent {
if (it.key == Key.Enter) { if (it.key == Key.Enter) {
if (searchQuery.isBlank()) return@onKeyEvent false
onSearchExplicitlyTriggered() onSearchExplicitlyTriggered()
true true
} else { } else {
@ -536,6 +537,7 @@ private fun SearchTextField(
), ),
keyboardActions = KeyboardActions( keyboardActions = KeyboardActions(
onSearch = { onSearch = {
if (searchQuery.isBlank()) return@KeyboardActions
onSearchExplicitlyTriggered() onSearchExplicitlyTriggered()
}, },
), ),

@ -59,7 +59,7 @@ class SearchViewModel @Inject constructor(
flowOf(SearchResultUiState.SearchNotReady) flowOf(SearchResultUiState.SearchNotReady)
} else { } else {
searchQuery.flatMapLatest { query -> searchQuery.flatMapLatest { query ->
if (query.length < SEARCH_QUERY_MIN_LENGTH) { if (query.trim().length < SEARCH_QUERY_MIN_LENGTH) {
flowOf(SearchResultUiState.EmptyQuery) flowOf(SearchResultUiState.EmptyQuery)
} else { } else {
getSearchContentsUseCase(query) getSearchContentsUseCase(query)
@ -102,6 +102,7 @@ class SearchViewModel @Inject constructor(
* search query in the search text field, defining this method. * search query in the search text field, defining this method.
*/ */
fun onSearchTriggered(query: String) { fun onSearchTriggered(query: String) {
if (query.isBlank()) return
viewModelScope.launch { viewModelScope.launch {
recentSearchRepository.insertOrReplaceRecentSearch(searchQuery = query) recentSearchRepository.insertOrReplaceRecentSearch(searchQuery = query)
} }

@ -41,6 +41,7 @@ import org.junit.Rule
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertIs import kotlin.test.assertIs
import kotlin.test.assertNull
/** /**
* To learn more about how this test handles Flows created with stateIn, see * To learn more about how this test handles Flows created with stateIn, see
@ -122,6 +123,43 @@ class SearchViewModelTest {
assertEquals(SearchNotReady, viewModel.searchResultUiState.value) assertEquals(SearchNotReady, viewModel.searchResultUiState.value)
} }
@Test
fun emptySearchText_isNotAddedToRecentSearches() = runTest {
viewModel.onSearchTriggered("")
val recentSearchQueriesStream = getRecentQueryUseCase()
val recentSearchQueries = recentSearchQueriesStream.first()
val recentSearchQuery = recentSearchQueries.firstOrNull()
assertNull(recentSearchQuery)
}
@Test
fun searchTextWithThreeSpaces_isEmptyQuery() = runTest {
searchContentsRepository.addNewsResources(newsResourcesTestData)
searchContentsRepository.addTopics(topicsTestData)
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.searchResultUiState.collect() }
viewModel.onSearchQueryChanged(" ")
assertIs<EmptyQuery>(viewModel.searchResultUiState.value)
collectJob.cancel()
}
@Test
fun searchTextWithThreeSpacesAndOneLetter_isEmptyQuery() = runTest {
searchContentsRepository.addNewsResources(newsResourcesTestData)
searchContentsRepository.addTopics(topicsTestData)
val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.searchResultUiState.collect() }
viewModel.onSearchQueryChanged(" a")
assertIs<EmptyQuery>(viewModel.searchResultUiState.value)
collectJob.cancel()
}
@Test @Test
fun whenToggleNewsResourceSavedIsCalled_bookmarkStateIsUpdated() = runTest { fun whenToggleNewsResourceSavedIsCalled_bookmarkStateIsUpdated() = runTest {
val newsResourceId = "123" val newsResourceId = "123"

@ -14,10 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
val ktlintVersion = "1.0.1" val ktlintVersion = "1.4.0"
initscript { initscript {
val spotlessVersion = "6.23.3" val spotlessVersion = "6.25.0"
repositories { repositories {
mavenCentral() mavenCentral()

@ -1,5 +1,5 @@
[versions] [versions]
accompanist = "0.34.0" accompanist = "0.36.0"
androidDesugarJdkLibs = "2.0.4" androidDesugarJdkLibs = "2.0.4"
# AGP and tools should be updated together # AGP and tools should be updated together
androidGradlePlugin = "8.6.1" androidGradlePlugin = "8.6.1"
@ -15,7 +15,7 @@ androidxDataStore = "1.1.1"
androidxEspresso = "3.6.1" androidxEspresso = "3.6.1"
androidxHiltNavigationCompose = "1.2.0" androidxHiltNavigationCompose = "1.2.0"
androidxLifecycle = "2.8.6" androidxLifecycle = "2.8.6"
androidxMacroBenchmark = "1.3.0" androidxMacroBenchmark = "1.3.1"
androidxMetrics = "1.0.0-beta01" androidxMetrics = "1.0.0-beta01"
androidxNavigation = "2.8.0" androidxNavigation = "2.8.0"
androidxProfileinstaller = "1.3.1" androidxProfileinstaller = "1.3.1"
@ -54,7 +54,7 @@ robolectric = "4.14"
roborazzi = "1.32.2" roborazzi = "1.32.2"
room = "2.6.1" room = "2.6.1"
secrets = "2.0.1" secrets = "2.0.1"
truth = "1.4.2" truth = "1.4.4"
turbine = "1.1.0" turbine = "1.1.0"
[bundles] [bundles]

@ -17,7 +17,13 @@
pluginManagement { pluginManagement {
includeBuild("build-logic") includeBuild("build-logic")
repositories { repositories {
google() google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral() mavenCentral()
gradlePluginPortal() gradlePluginPortal()
} }
@ -26,7 +32,13 @@ pluginManagement {
dependencyResolutionManagement { dependencyResolutionManagement {
repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS
repositories { repositories {
google() google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral() mavenCentral()
} }
} }

Loading…
Cancel
Save