Skip to content

Commit ebef59e

Browse files
Jetcaster Material Expressive update (#1565)
Adding Material Expressive to Jetcaster and merging gerrit code
2 parents e4e6f0f + 8f39bce commit ebef59e

File tree

140 files changed

+2343
-2274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2343
-2274
lines changed

Jetcaster/.editorconfig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# When authoring changes in .editorconfig, run ./gradlew spotlessApply --no-daemon
2+
# Reference: https://github.com/diffplug/spotless/issues/1924
3+
[*.{kt,kts}]
4+
ktlint_code_style = android_studio
5+
ij_kotlin_allow_trailing_comma = true
6+
ij_kotlin_allow_trailing_comma_on_call_site = true
7+
max_line_length = 140 # ktlint official
8+
ktlint_function_naming_ignore_when_annotated_with = Composable, Test
9+
ktlint_standard_filename = disabled
10+
ktlint_standard_package-name = disabled
11+
ktlint_standard_property-naming = disabled
12+
ktlint_standard_backing-property-naming = disabled
13+
ktlint_standard_argument-list-wrapping = disabled
14+
ktlint_standard_parameter-list-wrapping = disabled
15+
ktlint_standard_double-colon-spacing = disabled
16+
ktlint_standard_enum-entry-name-case = disabled
17+
ktlint_standard_multiline-if-else = disabled
18+
ktlint_standard_no-empty-first-line-in-method-block = disabled
19+
ktlint_standard_package-name = disabled
20+
ktlint_standard_trailing-comma = disabled
21+
ktlint_standard_spacing-around-angle-brackets = disabled
22+
ktlint_standard_spacing-between-declarations-with-annotations = disabled
23+
ktlint_standard_spacing-between-declarations-with-comments = disabled
24+
ktlint_standard_unary-op-spacing = disabled
25+
ktlint_standard_function-expression-body = disabled
26+
ktlint_standard_value-parameter-comment = disabled

Jetcaster/build.gradle.kts

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,45 +32,18 @@ apply("${project.rootDir}/buildscripts/toml-updater-config.gradle")
3232
subprojects {
3333
apply(plugin = "com.diffplug.spotless")
3434
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
35-
ratchetFrom = "origin/main"
3635
kotlin {
3736
target("**/*.kt")
38-
targetExclude("**/build/**/*.kt")
39-
ktlint().editorConfigOverride(
40-
mapOf(
41-
"ktlint_code_style" to "android_studio",
42-
"ij_kotlin_allow_trailing_comma" to true,
43-
"ktlint_function_naming_ignore_when_annotated_with" to "Composable",
44-
// These rules were introduced in ktlint 0.46.0 and should not be
45-
// enabled without further discussion. They are disabled for now.
46-
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0
47-
"disabled_rules" to
48-
"filename," +
49-
"annotation,annotation-spacing," +
50-
"argument-list-wrapping," +
51-
"double-colon-spacing," +
52-
"enum-entry-name-case," +
53-
"multiline-if-else," +
54-
"no-empty-first-line-in-method-block," +
55-
"package-name," +
56-
"trailing-comma," +
57-
"spacing-around-angle-brackets," +
58-
"spacing-between-declarations-with-annotations," +
59-
"spacing-between-declarations-with-comments," +
60-
"unary-op-spacing"
61-
)
62-
)
37+
targetExclude("${layout.buildDirectory}/**/*.kt")
38+
ktlint()
6339
licenseHeaderFile(rootProject.file("spotless/copyright.kt"))
6440
}
65-
format("kts") {
66-
target("**/*.kts")
67-
targetExclude("**/build/**/*.kts")
68-
// Look for the first line that doesn't have a block comment (assumed to be the license)
69-
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)")
70-
}
7141
kotlinGradle {
7242
target("*.gradle.kts")
43+
targetExclude("${layout.buildDirectory}/**/*.kt")
7344
ktlint()
45+
// Look for the first line that doesn't have a block comment (assumed to be the license)
46+
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)")
7447
}
7548
}
7649
}

Jetcaster/core/data-testing/build.gradle.kts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
/*
2+
* Copyright 2025 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
118
plugins {
219
alias(libs.plugins.android.library)
320
alias(libs.plugins.kotlin.android)
421
}
522

623
android {
724
namespace = "com.example.jetcaster.core.data.testing"
8-
compileSdk = libs.versions.compileSdk.get().toInt()
25+
compileSdk =
26+
libs.versions.compileSdk
27+
.get()
28+
.toInt()
929

1030
defaultConfig {
11-
minSdk = libs.versions.minSdk.get().toInt()
31+
minSdk =
32+
libs.versions.minSdk
33+
.get()
34+
.toInt()
1235

1336
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1437
consumerProguardFiles("consumer-rules.pro")
@@ -19,7 +42,7 @@ android {
1942
isMinifyEnabled = false
2043
proguardFiles(
2144
getDefaultProguardFile("proguard-android-optimize.txt"),
22-
"proguard-rules.pro"
45+
"proguard-rules.pro",
2346
)
2447
}
2548
}

Jetcaster/core/data-testing/src/main/java/com/example/jetcaster/core/data/testing/repository/TestCategoryStore.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,14 @@ class TestCategoryStore : CategoryStore {
3939
private val episodesFromPodcasts =
4040
MutableStateFlow<Map<Long, List<EpisodeToPodcast>>>(emptyMap())
4141

42-
override fun categoriesSortedByPodcastCount(limit: Int): Flow<List<Category>> =
43-
categoryFlow
42+
override fun categoriesSortedByPodcastCount(limit: Int): Flow<List<Category>> = categoryFlow
4443

45-
override fun podcastsInCategorySortedByPodcastCount(
46-
categoryId: Long,
47-
limit: Int
48-
): Flow<List<PodcastWithExtraInfo>> = podcastsInCategoryFlow.map {
49-
it[categoryId]?.take(limit) ?: emptyList()
50-
}
44+
override fun podcastsInCategorySortedByPodcastCount(categoryId: Long, limit: Int): Flow<List<PodcastWithExtraInfo>> =
45+
podcastsInCategoryFlow.map {
46+
it[categoryId]?.take(limit) ?: emptyList()
47+
}
5148

52-
override fun episodesFromPodcastsInCategory(
53-
categoryId: Long,
54-
limit: Int
55-
): Flow<List<EpisodeToPodcast>> = episodesFromPodcasts.map {
49+
override fun episodesFromPodcastsInCategory(categoryId: Long, limit: Int): Flow<List<EpisodeToPodcast>> = episodesFromPodcasts.map {
5650
it[categoryId]?.take(limit) ?: emptyList()
5751
}
5852

Jetcaster/core/data-testing/src/main/java/com/example/jetcaster/core/data/testing/repository/TestEpisodeStore.kt

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,47 @@ import kotlinx.coroutines.flow.update
2929
class TestEpisodeStore : EpisodeStore {
3030

3131
private val episodesFlow = MutableStateFlow<List<Episode>>(listOf())
32-
override fun episodeWithUri(episodeUri: String): Flow<Episode> =
33-
episodesFlow.map { episodes ->
34-
episodes.first { it.uri == episodeUri }
32+
override fun episodeWithUri(episodeUri: String): Flow<Episode> = episodesFlow.map { episodes ->
33+
episodes.first { it.uri == episodeUri }
34+
}
35+
36+
override fun episodeAndPodcastWithUri(episodeUri: String): Flow<EpisodeToPodcast> = episodesFlow.map { episodes ->
37+
val e = episodes.first {
38+
it.uri == episodeUri
39+
}
40+
EpisodeToPodcast().apply {
41+
episode = e
42+
_podcasts = emptyList()
3543
}
44+
}
3645

37-
override fun episodeAndPodcastWithUri(episodeUri: String): Flow<EpisodeToPodcast> =
38-
episodesFlow.map { episodes ->
39-
val e = episodes.first {
40-
it.uri == episodeUri
41-
}
46+
override fun episodesInPodcast(podcastUri: String, limit: Int): Flow<List<EpisodeToPodcast>> = episodesFlow.map { episodes ->
47+
episodes.filter {
48+
it.podcastUri == podcastUri
49+
}.map { e ->
4250
EpisodeToPodcast().apply {
4351
episode = e
44-
_podcasts = emptyList()
4552
}
4653
}
54+
}
4755

48-
override fun episodesInPodcast(podcastUri: String, limit: Int): Flow<List<EpisodeToPodcast>> =
49-
episodesFlow.map { episodes ->
50-
episodes.filter {
51-
it.podcastUri == podcastUri
52-
}.map { e ->
53-
EpisodeToPodcast().apply {
54-
episode = e
55-
}
56+
override fun episodesInPodcasts(podcastUris: List<String>, limit: Int): Flow<List<EpisodeToPodcast>> = episodesFlow.map { episodes ->
57+
episodes.filter {
58+
podcastUris.contains(it.podcastUri)
59+
}.map { ep ->
60+
EpisodeToPodcast().apply {
61+
episode = ep
5662
}
5763
}
64+
}
5865

59-
override fun episodesInPodcasts(
60-
podcastUris: List<String>,
61-
limit: Int
62-
): Flow<List<EpisodeToPodcast>> =
63-
episodesFlow.map { episodes ->
64-
episodes.filter {
65-
podcastUris.contains(it.podcastUri)
66-
}.map { ep ->
67-
EpisodeToPodcast().apply {
68-
episode = ep
69-
}
70-
}
71-
}
66+
override suspend fun addEpisodes(episodes: Collection<Episode>) = episodesFlow.update {
67+
it + episodes
68+
}
7269

73-
override suspend fun addEpisodes(episodes: Collection<Episode>) =
74-
episodesFlow.update {
75-
it + episodes
76-
}
70+
override suspend fun deleteEpisode(episode: Episode) = episodesFlow.update {
71+
it - episode
72+
}
7773

78-
override suspend fun isEmpty(): Boolean =
79-
episodesFlow.first().isEmpty()
74+
override suspend fun isEmpty(): Boolean = episodesFlow.first().isEmpty()
8075
}

Jetcaster/core/data-testing/src/main/java/com/example/jetcaster/core/data/testing/repository/TestPodcastStore.kt

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,71 +31,62 @@ class TestPodcastStore : PodcastStore {
3131

3232
private val podcastFlow = MutableStateFlow<List<Podcast>>(listOf())
3333
private val followedPodcasts = mutableSetOf<String>()
34-
override fun podcastWithUri(uri: String): Flow<Podcast> =
35-
podcastFlow.map { podcasts ->
36-
podcasts.first { it.uri == uri }
37-
}
34+
override fun podcastWithUri(uri: String): Flow<Podcast> = podcastFlow.map { podcasts ->
35+
podcasts.first { it.uri == uri }
36+
}
3837

39-
override fun podcastWithExtraInfo(podcastUri: String): Flow<PodcastWithExtraInfo> =
40-
podcastFlow.map { podcasts ->
41-
val podcast = podcasts.first { it.uri == podcastUri }
42-
PodcastWithExtraInfo().apply {
43-
this.podcast = podcast
44-
}
38+
override fun podcastWithExtraInfo(podcastUri: String): Flow<PodcastWithExtraInfo> = podcastFlow.map { podcasts ->
39+
val podcast = podcasts.first { it.uri == podcastUri }
40+
PodcastWithExtraInfo().apply {
41+
this.podcast = podcast
4542
}
43+
}
4644

47-
override fun podcastsSortedByLastEpisode(limit: Int): Flow<List<PodcastWithExtraInfo>> =
48-
podcastFlow.map { podcasts ->
49-
podcasts.map { p ->
50-
PodcastWithExtraInfo().apply {
51-
podcast = p
52-
isFollowed = followedPodcasts.contains(p.uri)
53-
}
45+
override fun podcastsSortedByLastEpisode(limit: Int): Flow<List<PodcastWithExtraInfo>> = podcastFlow.map { podcasts ->
46+
podcasts.map { p ->
47+
PodcastWithExtraInfo().apply {
48+
podcast = p
49+
isFollowed = followedPodcasts.contains(p.uri)
5450
}
5551
}
52+
}
5653

57-
override fun followedPodcastsSortedByLastEpisode(limit: Int): Flow<List<PodcastWithExtraInfo>> =
58-
podcastFlow.map { podcasts ->
59-
podcasts.filter {
60-
followedPodcasts.contains(it.uri)
61-
}.map { p ->
62-
PodcastWithExtraInfo().apply {
63-
podcast = p
64-
isFollowed = true
65-
}
54+
override fun followedPodcastsSortedByLastEpisode(limit: Int): Flow<List<PodcastWithExtraInfo>> = podcastFlow.map { podcasts ->
55+
podcasts.filter {
56+
followedPodcasts.contains(it.uri)
57+
}.map { p ->
58+
PodcastWithExtraInfo().apply {
59+
podcast = p
60+
isFollowed = true
6661
}
6762
}
63+
}
6864

69-
override fun searchPodcastByTitle(
70-
keyword: String,
71-
limit: Int
72-
): Flow<List<PodcastWithExtraInfo>> =
73-
podcastFlow.map { podcastList ->
74-
podcastList.filter {
75-
it.title.contains(keyword)
76-
}.map { p ->
77-
PodcastWithExtraInfo().apply {
78-
podcast = p
79-
isFollowed = true
80-
}
65+
override fun searchPodcastByTitle(keyword: String, limit: Int): Flow<List<PodcastWithExtraInfo>> = podcastFlow.map { podcastList ->
66+
podcastList.filter {
67+
it.title.contains(keyword)
68+
}.map { p ->
69+
PodcastWithExtraInfo().apply {
70+
podcast = p
71+
isFollowed = true
8172
}
8273
}
74+
}
8375

8476
override fun searchPodcastByTitleAndCategories(
8577
keyword: String,
8678
categories: List<Category>,
87-
limit: Int
88-
): Flow<List<PodcastWithExtraInfo>> =
89-
podcastFlow.map { podcastList ->
90-
podcastList.filter {
91-
it.title.contains(keyword)
92-
}.map { p ->
93-
PodcastWithExtraInfo().apply {
94-
podcast = p
95-
isFollowed = true
96-
}
79+
limit: Int,
80+
): Flow<List<PodcastWithExtraInfo>> = podcastFlow.map { podcastList ->
81+
podcastList.filter {
82+
it.title.contains(keyword)
83+
}.map { p ->
84+
PodcastWithExtraInfo().apply {
85+
podcast = p
86+
isFollowed = true
9787
}
9888
}
89+
}
9990

10091
override suspend fun togglePodcastFollowed(podcastUri: String) {
10192
if (podcastUri in followedPodcasts) {
@@ -113,9 +104,7 @@ class TestPodcastStore : PodcastStore {
113104
followedPodcasts.remove(podcastUri)
114105
}
115106

116-
override suspend fun addPodcast(podcast: Podcast) =
117-
podcastFlow.update { it + podcast }
107+
override suspend fun addPodcast(podcast: Podcast) = podcastFlow.update { it + podcast }
118108

119-
override suspend fun isEmpty(): Boolean =
120-
podcastFlow.first().isEmpty()
109+
override suspend fun isEmpty(): Boolean = podcastFlow.first().isEmpty()
121110
}

0 commit comments

Comments
 (0)