From 5b89ea4fe5619393f5e238bf598e5bb31d2596d4 Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Thu, 20 Jan 2022 11:52:05 -0800 Subject: [PATCH] For You initial screen Change-Id: Ic1975802934e64b59ef151c0e2063ddeb9645690 --- app/build.gradle | 26 + app/proguard-rules.pro | 3 + .../apps/nowinandroid/ui/NavigationTest.kt | 20 +- .../ui/foryou/ForYouScreenTest.kt | 160 +++ .../samples/apps/nowinandroid/MainActivity.kt | 2 + .../apps/nowinandroid/data/NiaPreferences.kt | 49 + .../data/UserPreferencesSerializer.kt | 46 + ...esourceRepository.kt => NewsRepository.kt} | 11 +- .../nowinandroid/data/news/NewsResource.kt | 8 +- .../apps/nowinandroid/data/news/Topic.kt | 26 + .../data/news/TopicsRepository.kt | 36 + .../nowinandroid/data/news/fake/FakeData.kt | 1149 ++++++++++------- ...rceRepository.kt => FakeNewsRepository.kt} | 28 +- .../data/news/fake/FakeTopicsRepository.kt | 44 + .../samples/apps/nowinandroid/di/AppModule.kt | 49 +- .../apps/nowinandroid/di/NiaDispatchers.kt | 39 + .../apps/nowinandroid/ui/NiaNavGraph.kt | 4 +- .../ui/SavedStateHandleExtensions.kt | 229 ++++ .../nowinandroid/ui/foryou/ForYouScreen.kt | 203 +++ .../nowinandroid/ui/foryou/ForYouViewModel.kt | 199 +++ .../nowinandroid/data/user_preferences.proto | 24 + app/src/main/res/values/strings.xml | 2 + .../data/UserPreferencesSerializerTest.kt | 64 + ...itoryTest.kt => FakeNewsRepositoryTest.kt} | 22 +- .../testutil/TestDispatcherRule.kt | 46 + .../testutil/TestNewsRepository.kt | 49 + .../testutil/TestTopicsRepository.kt | 57 + .../ui/foryou/ForYouViewModelTest.kt | 266 ++++ gradle/libs.versions.toml | 18 +- 29 files changed, 2394 insertions(+), 485 deletions(-) create mode 100644 app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreenTest.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/data/NiaPreferences.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializer.kt rename app/src/main/java/com/google/samples/apps/nowinandroid/data/news/{NewsResourceRepository.kt => NewsRepository.kt} (71%) create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/data/news/Topic.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/data/news/TopicsRepository.kt rename app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/{FakeNewsResourceRepository.kt => FakeNewsRepository.kt} (56%) create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeTopicsRepository.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/di/NiaDispatchers.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/ui/SavedStateHandleExtensions.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreen.kt create mode 100644 app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModel.kt create mode 100644 app/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto create mode 100644 app/src/test/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializerTest.kt rename app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/{FakeNewsResourceRepositoryTest.kt => FakeNewsRepositoryTest.kt} (60%) create mode 100644 app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestDispatcherRule.kt create mode 100644 app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestNewsRepository.kt create mode 100644 app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestTopicsRepository.kt create mode 100644 app/src/test/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModelTest.kt diff --git a/app/build.gradle b/app/build.gradle index 72e25ba6f..8966e4a0d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,6 +20,7 @@ plugins { id 'kotlinx-serialization' id 'jacoco' id 'dagger.hilt.android.plugin' + alias(libs.plugins.protobuf) } def jacocoTestReport = tasks.create("jacocoTestReport") @@ -109,6 +110,25 @@ android { } } +// Setup protobuf configuration, generating lite Java and Kotlin classes +protobuf { + protoc { + artifact = libs.protobuf.protoc.get() + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { + option "lite" + } + kotlin { + option "lite" + } + } + } + } +} + dependencies { coreLibraryDesugaring libs.android.desugarJdkLibs @@ -118,11 +138,14 @@ dependencies { implementation libs.androidx.activity.compose implementation libs.androidx.core.ktx + implementation libs.androidx.dataStore implementation libs.androidx.appcompat + implementation libs.androidx.hilt.navigation.compose implementation libs.androidx.lifecycle.viewModelCompose implementation libs.androidx.navigation.compose implementation libs.material3 + implementation libs.accompanist.flowlayout implementation libs.accompanist.insets implementation libs.androidx.compose.foundation.layout @@ -138,12 +161,15 @@ dependencies { implementation libs.hilt.android kapt libs.hilt.compiler + implementation libs.protobuf.kotlin.lite + debugImplementation libs.androidx.compose.ui.testManifest testImplementation libs.junit4 testImplementation libs.mockk testImplementation libs.androidx.test.core testImplementation libs.kotlinx.coroutines.test + testImplementation libs.turbine androidTestImplementation libs.androidx.test.espresso.core androidTestImplementation libs.androidx.test.runner diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index a1f89277e..36260b8b4 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -60,3 +60,6 @@ #-keepnames class <1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept. # static <1>$$serializer INSTANCE; #} + +# Enable protobuf-related optimizations. +-shrinkunusedprotofields diff --git a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt index c7d47fe8a..e27093302 100644 --- a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt +++ b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/NavigationTest.kt @@ -16,15 +16,15 @@ package com.google.samples.apps.nowinandroid.ui -import androidx.activity.ComponentActivity import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithContentDescription +import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import androidx.test.espresso.Espresso import androidx.test.espresso.NoActivityResumedException -import org.junit.Before +import com.google.samples.apps.nowinandroid.MainActivity import org.junit.Rule import org.junit.Test @@ -34,18 +34,12 @@ import org.junit.Test class NavigationTest { /** - * Using an empty activity to have control of the content that is set. + * Use the primary activity to initialize the app normally. + * + * TODO: Bind fakes as needed to the Dagger graph to allow for easier testing */ @get:Rule - val composeTestRule = createAndroidComposeRule() - - @Before - fun setUp() { - // Using targetContext as the Context of the instrumentation code - composeTestRule.setContent { - NiaApp() - } - } + val composeTestRule = createAndroidComposeRule() @Test fun firstScreenIsForYou() { @@ -166,7 +160,7 @@ class NavigationTest { * Matches an element at the top of the For You destination. Should be updated when the * destination is implemented. */ - private fun ComposeTestRule.forYouDestinationTopMatcher() = onNodeWithText("FOR YOU") + private fun ComposeTestRule.forYouDestinationTopMatcher() = onNodeWithTag("FOR YOU") /* * Matches an element at the top of the Topics destination. Should be updated when the diff --git a/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreenTest.kt b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreenTest.kt new file mode 100644 index 000000000..3f67709e6 --- /dev/null +++ b/app/src/androidTest/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreenTest.kt @@ -0,0 +1,160 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.ui.foryou + +import androidx.activity.ComponentActivity +import androidx.compose.ui.test.assertHasClickAction +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsEnabled +import androidx.compose.ui.test.assertIsNotEnabled +import androidx.compose.ui.test.junit4.createAndroidComposeRule +import androidx.compose.ui.test.onNodeWithContentDescription +import androidx.compose.ui.test.onNodeWithText +import com.google.samples.apps.nowinandroid.R +import com.google.samples.apps.nowinandroid.data.news.Topic +import org.junit.Rule +import org.junit.Test + +class ForYouScreenTest { + @get:Rule + val composeTestRule = createAndroidComposeRule() + + @Test + fun circularProgressIndicator_whenScreenIsLoading_exists() { + composeTestRule.setContent { + ForYouScreen( + uiState = ForYouFeedUiState.Loading, + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) + } + + composeTestRule + .onNodeWithContentDescription( + composeTestRule.activity.resources.getString(R.string.for_you_loading) + ) + .assertExists() + } + + @Test + fun topicSelector_whenNoTopicsSelected_showsTopicChipsAndDisabledDoneButton() { + composeTestRule.setContent { + ForYouScreen( + uiState = ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to false, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) + } + + composeTestRule + .onNodeWithText("HEADLINES") + .assertIsDisplayed() + // .assertIsOff() + .assertHasClickAction() + + composeTestRule + .onNodeWithText("UI") + .assertIsDisplayed() + // .assertIsOff() + .assertHasClickAction() + + composeTestRule + .onNodeWithText("TOOLS") + .assertIsDisplayed() + // .assertIsOff() + .assertHasClickAction() + + composeTestRule + .onNodeWithText(composeTestRule.activity.resources.getString(R.string.done)) + .assertIsDisplayed() + .assertIsNotEnabled() + .assertHasClickAction() + } + + @Test + fun topicSelector_whenSomeTopicsSelected_showsTopicChipsAndEnabledDoneButton() { + composeTestRule.setContent { + ForYouScreen( + uiState = ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to true, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) + } + + composeTestRule + .onNodeWithText("HEADLINES") + .assertIsDisplayed() + // .assertIsOff() + .assertHasClickAction() + + composeTestRule + .onNodeWithText("UI") + .assertIsDisplayed() + // .assertIsOn() + .assertHasClickAction() + + composeTestRule + .onNodeWithText("TOOLS") + .assertIsDisplayed() + // .assertIsOff() + .assertHasClickAction() + + composeTestRule + .onNodeWithText(composeTestRule.activity.resources.getString(R.string.done)) + .assertIsDisplayed() + .assertIsEnabled() + .assertHasClickAction() + } +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt index 6b0771eb4..9746f5a1f 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/MainActivity.kt @@ -21,7 +21,9 @@ import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.core.view.WindowCompat import com.google.samples.apps.nowinandroid.ui.NiaApp +import dagger.hilt.android.AndroidEntryPoint +@AndroidEntryPoint class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/NiaPreferences.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/NiaPreferences.kt new file mode 100644 index 000000000..7a095c3cc --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/NiaPreferences.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data + +import android.util.Log +import androidx.datastore.core.DataStore +import java.io.IOException +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.retry + +class NiaPreferences @Inject constructor( + private val userPreferences: DataStore +) { + suspend fun setFollowedTopicIds(followedTopicIds: Set) { + try { + userPreferences.updateData { + it.copy { + this.followedTopicIds.clear() + this.followedTopicIds.addAll(followedTopicIds) + } + } + } catch (ioException: IOException) { + Log.e("NiaPreferences", "Failed to update user preferences", ioException) + } + } + + val followedTopicIds: Flow> = userPreferences.data + .retry { + Log.e("NiaPreferences", "Failed to read user preferences", it) + true + } + .map { it.followedTopicIdsList.toSet() } +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializer.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializer.kt new file mode 100644 index 000000000..94065332b --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializer.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data + +import androidx.datastore.core.CorruptionException +import androidx.datastore.core.Serializer +import com.google.protobuf.InvalidProtocolBufferException +import java.io.InputStream +import java.io.OutputStream +import javax.inject.Inject + +/** + * An [androidx.datastore.core.Serializer] for the [UserPreferences] proto. + */ +class UserPreferencesSerializer @Inject constructor() : Serializer { + override val defaultValue: UserPreferences = UserPreferences.getDefaultInstance() + + override suspend fun readFrom(input: InputStream): UserPreferences = + try { + // readFrom is already called on the data store background thread + @Suppress("BlockingMethodInNonBlockingContext") + UserPreferences.parseFrom(input) + } catch (exception: InvalidProtocolBufferException) { + throw CorruptionException("Cannot read proto.", exception) + } + + override suspend fun writeTo(t: UserPreferences, output: OutputStream) { + // writeTo is already called on the data store background thread + @Suppress("BlockingMethodInNonBlockingContext") + t.writeTo(output) + } +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResourceRepository.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsRepository.kt similarity index 71% rename from app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResourceRepository.kt rename to app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsRepository.kt index d6b1cdd22..44e8db2fc 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResourceRepository.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsRepository.kt @@ -21,9 +21,14 @@ import kotlinx.coroutines.flow.Flow /** * Data layer implementation for [NewsResource] */ -interface NewsResourceRepository { +interface NewsRepository { /** - * Fetches available news resources + * Returns available news resources as a stream. */ - fun monitor(): Flow> + fun getNewsResourcesStream(): Flow> + + /** + * Returns available news resources as a stream filtered by the topic. + */ + fun getNewsResourcesStream(filterTopicIds: Set): Flow> } diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResource.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResource.kt index 6ba7f8fd0..e3657abc2 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResource.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/NewsResource.kt @@ -32,16 +32,16 @@ import kotlinx.serialization.encoding.Encoder */ @Serializable data class NewsResource( - val episode: Int, + val id: Int, + val episodeId: Int, val title: String, val content: String, - @SerialName("URL") val url: String, - val authorName: String, + val authors: List, @Serializable(InstantSerializer::class) val publishDate: Instant, val type: String, - val topics: List, + val topics: List, val alternateVideo: VideoInfo? ) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/Topic.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/Topic.kt new file mode 100644 index 000000000..45dc13967 --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/Topic.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data.news + +import kotlinx.serialization.Serializable + +@Serializable +data class Topic( + val id: Int, + val name: String, + val description: String +) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/TopicsRepository.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/TopicsRepository.kt new file mode 100644 index 000000000..687a93df2 --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/TopicsRepository.kt @@ -0,0 +1,36 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data.news + +import kotlinx.coroutines.flow.Flow + +interface TopicsRepository { + /** + * Gets the available topics as a stream + */ + fun getTopicsStream(): Flow> + + /** + * Sets the user's currently followed topics + */ + suspend fun setFollowedTopicIds(followedTopicIds: Set) + + /** + * Returns the users currently followed topics + */ + fun getFollowedTopicIdsStream(): Flow> +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeData.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeData.kt index 1f35d5e01..664283435 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeData.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeData.kt @@ -21,14 +21,16 @@ import com.google.samples.apps.nowinandroid.data.news.VideoInfo import kotlinx.datetime.LocalDateTime import kotlinx.datetime.TimeZone import kotlinx.datetime.toInstant +import org.intellij.lang.annotations.Language object FakeDataSource { val sampleResource = NewsResource( - episode = 52, + id = 1, + episodeId = 52, title = "Thanks for helping us reach 1M YouTube Subscribers", content = "Thank you everyone for following the Now in Android series and everything the Android Developers YouTube channel has to offer. During the Android Developer Summit, our YouTube channel reached 1 million subscribers! Hereโ€™s a small video to thank you all.", url = "https://youtu.be/-fJ6poHQrjM", - authorName = "", + authors = emptyList(), publishDate = LocalDateTime( year = 2021, monthNumber = 11, @@ -39,9 +41,7 @@ object FakeDataSource { nanosecond = 0 ).toInstant(TimeZone.UTC), type = "Video \uD83D\uDCFA", - topics = listOf( - "Headlines", - ), + topics = listOf(0), alternateVideo = VideoInfo( url = "", startTimestamp = 0, @@ -49,20 +49,123 @@ object FakeDataSource { ) ) + @Language("JSON") + val topicsData = """ +[ + { + "id": 0, + "name": "Headlines", + "description": "" + }, + { + "id": 1, + "name": "UI", + "description": "" + }, + { + "id": 2, + "name": "Testing", + "description": "" + }, + { + "id": 3, + "name": "Performance", + "description": "" + }, + { + "id": 4, + "name": "Camera & Media", + "description": "" + }, + { + "id": 5, + "name": "Android Studio", + "description": "" + }, + { + "id": 6, + "name": "New APIs & Libraries", + "description": "" + }, + { + "id": 7, + "name": "Data Storage", + "description": "" + }, + { + "id": 8, + "name": "Kotlin", + "description": "" + }, + { + "id": 9, + "name": "Compose", + "description": "" + }, + { + "id": 10, + "name": "Privacy & Security", + "description": "" + }, + { + "id": 11, + "name": "Publishing & Distribution", + "description": "" + }, + { + "id": 12, + "name": "Tools", + "description": "" + }, + { + "id": 13, + "name": "Platform & Releases", + "description": "" + }, + { + "id": 14, + "name": "Architecture", + "description": "" + }, + { + "id": 15, + "name": "Accessibility", + "description": "" + }, + { + "id": 16, + "name": "Android Auto", + "description": "" + }, + { + "id": 17, + "name": "Games", + "description": "" + }, + { + "id": 18, + "name": "Wear OS", + "description": "" + } +] +""".trimIndent() + + @Language("JSON") val data = """ { "resources": [ { - "episode": 52, + "id": 1, + "episodeId": 52, "title": "Thanks for helping us reach 1M YouTube Subscribers", "content": "Thank you everyone for following the Now in Android series and everything the Android Developers YouTube channel has to offer. During the Android Developer Summit, our YouTube channel reached 1 million subscribers! Hereโ€™s a small video to thank you all.", - "URL": "https://youtu.be/-fJ6poHQrjM", - "authorName": "", + "url": "https://youtu.be/-fJ6poHQrjM", "publishDate": "2021-11-09T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Headlines" + 0 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -70,16 +173,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 2, + "episodeId": 52, "title": "Transformations and customisations in the Paging Library", "content": "A demonstration of different operations that can be performed with Paging. Transformations like inserting separators, when to create a new pager, and customisation options for consuming PagingData.", - "URL": "https://youtu.be/ZARz0pjm5YM", - "authorName": "TJ", + "url": "https://youtu.be/ZARz0pjm5YM", "publishDate": "2021-11-01T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Paging" + 1 + ], + "authors": [ + 0 ], "alternateVideo": { "URL": "", @@ -88,17 +193,17 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 3, + "episodeId": 52, "title": "Community tip on Paging", "content": "Tips for using the Paging library from the developer community", - "URL": "https://youtu.be/r5JgIyS3t3s", - "authorName": "", + "url": "https://youtu.be/r5JgIyS3t3s", "publishDate": "2021-11-08T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Paging" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -106,17 +211,17 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 4, + "episodeId": 52, "title": "Paging Q&A", "content": "In this live session, TJ and Dustin answered your questions in the usual live Q&A format.", - "URL": "https://youtu.be/8i6vrlbIVCc", - "authorName": "", + "url": "https://youtu.be/8i6vrlbIVCc", "publishDate": "2021-11-11T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Paging" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -124,16 +229,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 5, + "episodeId": 52, "title": "Gradle series kicks off", "content": "Murat introduces the Gradle series and everything you'll learn in it.", - "URL": "https://youtu.be/mk0XBWenod8", - "authorName": "Murat", + "url": "https://youtu.be/mk0XBWenod8", "publishDate": "2021-11-15T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Gradle" + 12 + ], + "authors": [ + 1 ], "alternateVideo": { "URL": "", @@ -142,16 +249,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 6, + "episodeId": 52, "title": "Intro to Gradle and AGP", "content": "In the first episode of the Gradle MAD Skills series, Murat explains how the Android build system works, and how to configure your build.", - "URL": "https://youtu.be/GjPS4xDMmQY", - "authorName": "Murat", + "url": "https://youtu.be/GjPS4xDMmQY", "publishDate": "2021-11-15T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Gradle" + 12 + ], + "authors": [ + 1 ], "alternateVideo": { "URL": "", @@ -160,16 +269,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 7, + "episodeId": 52, "title": "How to write a Gradle plugin", "content": "In this second episode of the Gradle MAD Skills series, Murat explains how to write your own custom Gradle plugin.", - "URL": "https://youtu.be/LPzBVtwGxlo", - "authorName": "Murat", + "url": "https://youtu.be/LPzBVtwGxlo", "publishDate": "2021-11-22T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Gradle" + 12 + ], + "authors": [ + 1 ], "alternateVideo": { "URL": "", @@ -178,16 +289,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 8, + "episodeId": 52, "title": "Take your Gradle plugin to the next step", "content": "This third and last episode of the Gradle MAD Skills series teaches you how to get access to various build artifacts using the new Artifact API.", - "URL": "https://youtu.be/SB4QlngQQW0", - "authorName": "Murat", + "url": "https://youtu.be/SB4QlngQQW0", "publishDate": "2021-11-29T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Gradle" + 12 + ], + "authors": [ + 1 ], "alternateVideo": { "URL": "", @@ -196,17 +309,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 9, + "episodeId": 52, "title": "AppCompat, Activity, and Fragment to support multiple back stacks", "content": "The 1.4.0 release of these libraries brings stable support for multiple back stacks.", - "URL": "https://developer.android.com/jetpack/androidx/releases/appcompat#1.4.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/appcompat#1.4.0", "publishDate": "2021-11-17T00:00:00.000Z", "type": "API change", "topics": [ - "AndroidX", - "Navigation" + 6, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -214,17 +328,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 10, + "episodeId": 52, "title": "Emoji2 adds support for modern emojis", "content": "The 1.0 stable release of Emoji2 allows you to use modern emojis in your app.", - "URL": "https://developer.android.com/jetpack/androidx/releases/emoji2#1.0.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/emoji2#1.0.0", "publishDate": "2021-11-17T00:00:00.000Z", "type": "API change", "topics": [ - "AndroidX", - "Text" + 6, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -232,17 +347,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 11, + "episodeId": 52, "title": "Lifecycle introduces lifecycle-aware coroutine APIs", "content": "The new 2.4 release of Lifecycle introduces repeatOnLifecycle and flowWithLifecycle.", - "URL": "https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/lifecycle#2.4.0", "publishDate": "2021-11-17T00:00:00.000Z", "type": "API change", "topics": [ - "AndroidX", - "Lifecycle" + 6, + 14 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -250,17 +366,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 12, + "episodeId": 52, "title": "Paging release brings changes to LoadState", "content": "The new 3.1 release of Paging changes the behavior of LoadState.", - "URL": "https://developer.android.com/jetpack/androidx/releases/paging#3.1.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/paging#3.1.0", "publishDate": "2021-11-17T00:00:00.000Z", "type": "API change", "topics": [ - "AndroidX", - "Paging" + 6, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -268,17 +385,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 13, + "episodeId": 52, "title": "Wear tiles released as 1.0 stable", "content": "The library that you use to build custom tiles for Wear OS devices is now stable.", - "URL": "https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0", "publishDate": "2021-11-17T00:00:00.000Z", "type": "API change", "topics": [ - "AndroidX", - "Wear" + 6, + 18 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -286,16 +404,19 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 14, + "episodeId": 52, "title": "Introducing Jetpack Media3", "content": "The first alpha version of this new library is now available. Media3 is a collection of support libraries for media playback, including ExoPlayer. The following article explains why the team created Media3, what it contains, and how it can simplify your app architecture.", - "URL": "https://developer.android.com/jetpack/androidx/releases/media3", - "authorName": "Don Turner", + "url": "https://developer.android.com/jetpack/androidx/releases/media3", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "AndroidX", - "Media" + 6, + 4 + ], + "authors": [ + 2 ], "alternateVideo": { "URL": "", @@ -304,16 +425,19 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 15, + "episodeId": 52, "title": "The problem with emojis and how emoji2 can help out", "content": "Meghan wrote about the new emoji2 library that just became stable.", - "URL": "https://medium.com/androiddevelopers/support-modern-emoji-99f6dea8e57f", - "authorName": "Meghan", + "url": "https://medium.com/androiddevelopers/support-modern-emoji-99f6dea8e57f", "publishDate": "2021-11-12T00:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "AndroidX", - "Text" + 6, + 1 + ], + "authors": [ + 3 ], "alternateVideo": { "URL": "", @@ -322,16 +446,19 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 16, + "episodeId": 52, "title": "Convert YUV to RGB for CameraX Image Analysis", "content": "Learn about a new feature in CameraX to convert YUV, the format that CameraX produces, to RGB used for image analysis capabilities available in TensorFlow Lite, for example. Read the blog post for more information about these formats and how to use the new conversion feature.", - "URL": "https://medium.com/androiddevelopers/convert-yuv-to-rgb-for-camerax-imageanalysis-6c627f3a0292", - "authorName": "Kailiang Chen", + "url": "https://medium.com/androiddevelopers/convert-yuv-to-rgb-for-camerax-imageanalysis-6c627f3a0292", "publishDate": "2021-11-19T00:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "AndroidX", - "Camera" + 6, + 4 + ], + "authors": [ + 4 ], "alternateVideo": { "URL": "", @@ -340,16 +467,17 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 17, + "episodeId": 52, "title": "Improving App Startup: Lessons from the Facebook App", "content": "Improving app startup time is not a trivial task and requires a deep understanding of things that affect it. This year, the Android team and the Facebook app team have been working together on metrics and sharing approaches to improve app startup. Read more about the findings in this blog post.", - "URL": "https://android-developers.googleblog.com/2021/11/improving-app-startup-facebook-app.html", - "authorName": "", + "url": "https://android-developers.googleblog.com/2021/11/improving-app-startup-facebook-app.html", "publishDate": "2021-11-16T00:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Performance" + 3 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -357,15 +485,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 18, + "episodeId": 52, "title": "About Custom Accessibility Actions", "content": "The accessibility series continues on with more information on how to create custom accessibility actions to make your apps more accessible. You can provide a custom action to the accessibility services and implement logic related to the action. For more information, check out the following episode!", - "URL": "https://youtu.be/wWDYIGk0Kdo", - "authorName": "Shailen Tuli", + "url": "https://youtu.be/wWDYIGk0Kdo", "publishDate": "2021-11-17T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Accessibility" + 1 + ], + "authors": [ + 5 ], "alternateVideo": { "URL": "", @@ -374,15 +505,18 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 19, + "episodeId": 52, "title": "Conveying state for Accessibility", "content": "In this episode of the Accessibility series, you can learn more about the StateDescription API, when to use stateDescription and contentDescription, and how to represent error states to the end user.", - "URL": "https://youtu.be/JvWM2PjLJls", - "authorName": "Shailen Tuli", + "url": "https://youtu.be/JvWM2PjLJls", "publishDate": "2021-11-30T00:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Accessibility" + 1 + ], + "authors": [ + 5 ], "alternateVideo": { "URL": "", @@ -391,16 +525,19 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 20, + "episodeId": 52, "title": "New Compose for Wear OS codelab", "content": "In this codelab, you can learn how Wear OS can work with Compose, what Wear OS specific composables are available, and more!", - "URL": "https://developer.android.com/codelabs/compose-for-wear-os", - "authorName": "Jeremy Walker", + "url": "https://developer.android.com/codelabs/compose-for-wear-os", "publishDate": "2021-10-27T23:00:00.000Z", "type": "Codelab", "topics": [ - "Compose", - "Wear OS" + 9, + 18 + ], + "authors": [ + 6 ], "alternateVideo": { "URL": "", @@ -409,18 +546,20 @@ object FakeDataSource { } }, { - "episode": 52, + "id": 21, + "episodeId": 52, "title": "ADB Podcast episode 179 Hosts 3, Guests 0", "content": "Chet, Romain and Tor sit down to chat about the Android Developer Summit, and in particular all the new features arriving in Android Studio, along with a few other topics like Chetโ€™s new jank stats library, the Android 12L release, and more.", - "URL": "https://adbackstage.libsyn.com/episode-178-hosts-3-guests-0", - "authorName": "Chet Haase", + "url": "https://adbackstage.libsyn.com/episode-178-hosts-3-guests-0", "publishDate": "2021-11-15T00:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Android Studio", - "ADS", - "Performance", - "Android 12" + 5, + 3, + 13 + ], + "authors": [ + 7 ], "alternateVideo": { "URL": "", @@ -429,17 +568,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 22, + "episodeId": 50, "title": "Building apps which are private by design", "content": "Sara N-Marandi, product manager, and Yacine Rezgui, developer relations engineer, provided guidelines and best practices on how to build apps that are private by design, covered new privacy features in Android 12 and previewed upcoming Android concepts.", - "URL": "https://youtu.be/hBVwr2ErQCw", - "authorName": "", + "url": "https://youtu.be/hBVwr2ErQCw", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Privacy", - "Security" + 10 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -447,18 +586,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 23, + "episodeId": 50, "title": "Memory Safety Tools", "content": "Serban Constantinescu, product manager, talked about the Memory Safety Tools that became available starting in Android 11 and have continued to evolve in Android 12. These tools can help address memory bugs and improve the quality and security of your application.", - "URL": "https://youtu.be/JqLcTFpXreg", - "authorName": "", + "url": "https://youtu.be/JqLcTFpXreg", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Security", - "Debugging", - "App quality" + 10 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -466,15 +604,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 24, + "episodeId": 50, "title": "Increasing User Transparency with Privacy Dashboard", "content": "Android is ever evolving in its quest to protect usersโ€™ privacy. In Android 12, the platform increases transparency by introducing Privacy Dashboard, which gives users a simple and clear timeline view of the apps that have accessed location, microphone and camera within the past 24 hours. ", - "URL": "https://medium.com/androiddevelopers/increasing-user-transparency-with-privacy-dashboard-23064f2d7ff6", - "authorName": "Meghan Mehta", + "url": "https://medium.com/androiddevelopers/increasing-user-transparency-with-privacy-dashboard-23064f2d7ff6", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Privacy" + 10 + ], + "authors": [ + 8 ], "alternateVideo": { "URL": "", @@ -483,15 +624,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 25, + "episodeId": 50, "title": "The most unusual and interesting security issues addressed last year", "content": "Lilian Young, software engineer, presented a selection of the most unusual, intricate, and interesting security issues addressed in the last year. Developers and researchers are able to contribute to the security of the Android platform by submitting to the Android Vulnerability Rewards Program.", - "URL": "https://medium.com/androiddevelopers/now-in-android-50-ads-special-9934422f8dd1", - "authorName": "Lilian Young", + "url": "https://medium.com/androiddevelopers/now-in-android-50-ads-special-9934422f8dd1", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Security" + 10 + ], + "authors": [ + 9 ], "alternateVideo": { "URL": "", @@ -500,18 +644,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 26, + "episodeId": 50, "title": "New Data Safety section in the Play Console", "content": "The new Data safety section will give you a simple way to showcase your appโ€™s overall safety. It gives you a place to give users deeper insight into your appโ€™s privacy and security practices, and explain the data your app may collect and why โ€” all before users install.", - "URL": "https://youtu.be/J7TM0Yy0aTQ", - "authorName": "", + "url": "https://youtu.be/J7TM0Yy0aTQ", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Play Console", - "Privacy", - "Security" + 10, + 11 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -519,16 +663,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 27, + "episodeId": 50, "title": "Building Android UIs for any screen size", "content": "Clara Bayarri, engineering manager and Daniel Jacobson, product manager, talked about the state of the ecosystem, focusing on new design guidance, APIs, and tools to help you make the most of your UI on different screen sizes.", - "URL": "https://youtu.be/ir3LztqbeRI", - "authorName": "", + "url": "https://youtu.be/ir3LztqbeRI", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Large Screens" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -536,19 +681,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 28, + "episodeId": 50, "title": "What's new for large screens & foldables", "content": "Emilie Roberts, Chrome OS developer advocate and Andrii Kulian, Android software engineer, introduced new features focused specifically on making apps look great on large screens, foldables, and Chrome OS. ", - "URL": "https://youtu.be/6-925K3hMHU", - "authorName": "", + "url": "https://youtu.be/6-925K3hMHU", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Large Screens", - "Foldables", - "Chrome OS", - "UI" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -556,16 +699,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 29, + "episodeId": 50, "title": "Enable great input support for all devices", "content": "Users expect seamless experiences when using keyboards, mice, and stylus. Emilie Roberts taught us how to handle common keyboard and mouse input events and how to get started with more advanced support like keyboard shortcuts, low-latency styluses, MIDI, and more.", - "URL": "https://youtu.be/piLEZYTc_4g", - "authorName": "", + "url": "https://youtu.be/piLEZYTc_4g", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "UI" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -573,19 +717,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 30, + "episodeId": 50, "title": "Best practices for video apps on foldable devices", "content": "Francesco Romano, developer advocate, and Will Chan, product manager at Zoom explored new user experiences made possible by the foldable form factor, focusing on video conferencing and media applications. ", - "URL": "https://youtu.be/DBAek_P0nEw", - "authorName": "", + "url": "https://youtu.be/DBAek_P0nEw", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "UI", - "Media", - "Foldables", - "Camera" + 1, + 4 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -593,19 +736,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 31, + "episodeId": 50, "title": "Design beautiful apps on foldables and large screens", "content": "Liam Spradlin, design advocate, and Jonathan Koren, developer relations engineer, talked about how to design and test Android applications that look and feel great across device types and screen sizes, from tablets to foldables to Chrome OS.", - "URL": "https://youtu.be/DJeJIJKOUbI", - "authorName": "", + "url": "https://youtu.be/DJeJIJKOUbI", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "UI", - "Material Design", - "Foldables", - "Large Screens" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -613,18 +754,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 32, + "episodeId": 50, "title": "12L and new Android APIs and tools for large screens", "content": "Dave Burke, vice president of engineering, wrote a post covering the developer preview of 12L, an upcoming feature drop that makes Android 12 even better on large screens. ", - "URL": "https://android-developers.googleblog.com/2021/10/12L-preview-large-screens.html", - "authorName": "", + "url": "https://android-developers.googleblog.com/2021/10/12L-preview-large-screens.html", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Platform", - "Large Screens", - "Android releases" + 1, + 13 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -632,16 +773,18 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 33, + "episodeId": 50, "title": "New features in ML Kit: Text Recognition V2 & Pose Detections", "content": "Zongmin Sun, software engineer, and Valentin Bazarevsky, MediaPipe Engineer, talked about Text Recognition V2 & Pose Detection, recently-released features in ML Kit. ", - "URL": "https://youtu.be/9EKQ0UC04S8", - "authorName": "", + "url": "https://youtu.be/9EKQ0UC04S8", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Machine learning" + 6, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -649,16 +792,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 34, + "episodeId": 50, "title": "How to retain users with Android backup and restore", "content": "In this talk, Martin Millmore, engineering manager, and Ruslan Tkhakokhov, software engineer, explored the benefits of transferring usersโ€™ data to a new device, using Backup and Restore to achieve that in a simple and secure way.", - "URL": "https://youtu.be/bg2drEhz1_s", - "authorName": "", + "url": "https://youtu.be/bg2drEhz1_s", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Platform" + 13 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -666,16 +810,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 35, + "episodeId": 50, "title": "Compatibility changes in Android 12", "content": "Developer relations engineers Kseniia Shumelchyk and Slava Panasenko talked about new Android 12 features and changes. They shared tools and techniques to ensure that apps are compatible with the next Android release and users can take advantage of new features, along with app developer success stories.", - "URL": "https://youtu.be/fCMJmV6nqGo", - "authorName": "", + "url": "https://youtu.be/fCMJmV6nqGo", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Platform" + 13 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -683,16 +828,17 @@ object FakeDataSource { } }, { - "episode": 50, + "id": 36, + "episodeId": 50, "title": "Building great experiences for Novice Internet Users", "content": "Learn the principles to help craft great experiences for the novice Internet user segment from Mrinal Sharma, UX manager, and Amrit Sanjeev, developer relations engineer. They highlight the gap between nascent and tech savvy user segments and suggest strategies in areas to improve the overall user experience. Factors like low functional literacy, being multilingual by default, being less digitally confident, and having no prior internet experience requires that we rethink the way we build apps for these users.", - "URL": "https://youtu.be/Sf_TauUY4LE", - "authorName": "", + "url": "https://youtu.be/Sf_TauUY4LE", "publishDate": "2021-10-26T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "UX" + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -700,16 +846,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 37, + "episodeId": 49, "title": "Android Basics in Kotlin course ๐Ÿง‘โ€๐Ÿ’ป", "content": "Android Basics in Kotlin teaches people with no programming experience how to build simple Android apps. Since the first learning units were released in 2020, over 100,000 beginners have completed it! Today, weโ€™re excited to share that the final unit has been released, and the full Android Basics in Kotlin course is now available.", - "URL": "https://android-developers.googleblog.com/2021/10/announcing-android-basics-in-kotlin.html", - "authorName": "Murat Yener", + "url": "https://android-developers.googleblog.com/2021/10/announcing-android-basics-in-kotlin.html", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Kotlin", - "Courses" + 8 + ], + "authors": [ + 10 ], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", @@ -718,16 +866,17 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 38, + "episodeId": 49, "title": "WorkManager 2.7 adds setExpedited API to help with Foreground Service restrictions", "content": "As the most outstanding release this time, WorkManager 2.7 was promoted to stable. This new version introduces a new setExpedited API to help with Foreground Service restrictions in Android 12.", - "URL": "https://developer.android.com/reference/android/app/job/JobInfo.Builder#setExpedited(boolean)", - "authorName": "", + "url": "https://developer.android.com/reference/android/app/job/JobInfo.Builder#setExpedited(boolean)", "publishDate": "2021-10-20T23:00:00.000Z", "type": "API change", "topics": [ - "WorkManager" + 14 ], + "authors": [], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", "startTimestamp": 97, @@ -735,16 +884,17 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 39, + "episodeId": 49, "title": "Updated Widget docs", "content": "Widgets can make a huge impact on your userโ€™s home screen! We updated the App Widgets documentation with the recent changes in the latest OS versions. New pages about how to create a simple widget, an advanced widget, and how to provide flexible widget layouts.", - "URL": "https://developer.android.com/guide/topics/appwidgets", - "authorName": "", + "url": "https://developer.android.com/guide/topics/appwidgets", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Widgets" + 1 ], + "authors": [], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", "startTimestamp": 193, @@ -752,17 +902,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 40, + "episodeId": 49, "title": "Extend AGP by creating your own plugins", "content": "The Android Gradle Plugin (AGP) contains extension points for plugins to control build inputs and extend its functionality. Starting in version 7.0, AGP has a set of official, stable APIs that you can rely on. We also have a new documentation page that walks you through this and explains how to create your own plugins.", - "URL": "https://developer.android.com/studio/build/extend-agp", - "authorName": "", + "url": "https://developer.android.com/studio/build/extend-agp", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Gradle", - "Android Studio" + 12, + 5 ], + "authors": [], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", "startTimestamp": 206, @@ -770,16 +921,17 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 41, + "episodeId": 49, "title": "Revamped Compose Basics Codelab", "content": "If youโ€™re planning to start learning Jetpack Compose, our modern toolkit for building native Android UI, itโ€™s your lucky day! We just revamped the Basics Jetpack Compose codelab to help you learn the core concepts of Compose, and only with this, youโ€™ll see how much it improves building Android UIs.", - "URL": "https://developer.android.com/codelabs/jetpack-compose-basics", - "authorName": "", + "url": "https://developer.android.com/codelabs/jetpack-compose-basics", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Codelab", "topics": [ - "Compose" + 9 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -787,16 +939,17 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 42, + "episodeId": 49, "title": "Start an activity for a result from a Composable", "content": "We expanded the Compose and other libraries page to cover how to start an activity for result, request runtime permissions, and handle the system back button directly from your composables.", - "URL": "https://developer.android.com/jetpack/compose/libraries", - "authorName": "", + "url": "https://developer.android.com/jetpack/compose/libraries", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Compose" + 9 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -804,17 +957,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 43, + "episodeId": 49, "title": "Material components in Compose", "content": "We added a new Material Components and layouts page that goes over the different Material components in Compose such as backdrop, app bars, modal drawers, etc.!", - "URL": "https://developer.android.com/jetpack/compose/layouts/material", - "authorName": "", + "url": "https://developer.android.com/jetpack/compose/layouts/material", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Compose", - "Material design" + 9, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -822,17 +976,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 44, + "episodeId": 49, "title": "How to implement a custom design system", "content": "How to implement a custom design system in Compose", - "URL": "https://developer.android.com/jetpack/compose/themes/custom", - "authorName": "", + "url": "https://developer.android.com/jetpack/compose/themes/custom", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Compose", - "Material design" + 9, + 1 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -840,17 +995,17 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 45, + "episodeId": 49, "title": "The anatomy of a theme", "content": "Understanding the anatomy of a Compose theme", - "URL": "https://developer.android.com/jetpack/compose/themes/anatomy", - "authorName": "", + "url": "https://developer.android.com/jetpack/compose/themes/anatomy", "publishDate": "2021-10-20T23:00:00.000Z", "type": "Docs ๐Ÿ“‘", "topics": [ - "Compose", - "Themes" + 9 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -858,17 +1013,19 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 46, + "episodeId": 49, "title": "Paging ๐Ÿ“‘ Displaying data and its loading state", "content": "In the third episode of the Paging video series, TJ adds a local cache to pull from and refresh only when necessary, making use of Room . The local cache acts as the single source of truth for paging data.", - "URL": "https://www.youtube.com/watch?v=OHH_FPbrjtA", - "authorName": "TJ Dahunsi", + "url": "https://www.youtube.com/watch?v=OHH_FPbrjtA", "publishDate": "2021-10-17T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Paging", - "Room", - "Data storage" + 7, + 1 + ], + "authors": [ + 0 ], "alternateVideo": { "URL": "", @@ -877,16 +1034,19 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 47, + "episodeId": 49, "title": "Data safety in the Play Console ๐Ÿ”’", "content": "Google Play is rolling out the Data safety form in the Google Play Console. With the new Data safety section, developers will now have a transparent way to show users if and how they collect, share, and protect user data, before users install an app.\nRead the blog post to learn more about how to submit your app information in Play Console, how to get prepared, and what your users will see in your appโ€™s store listing starting February.", - "URL": "https://android-developers.googleblog.com/2021/10/launching-data-safety-in-play-console.html", - "authorName": "Krish Vitaldevara", + "url": "https://android-developers.googleblog.com/2021/10/launching-data-safety-in-play-console.html", "publishDate": "2021-10-17T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Play", - "Privacy & Security" + 10, + 11 + ], + "authors": [ + 11 ], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", @@ -895,16 +1055,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 48, + "episodeId": 49, "title": "Honor every photo - How cameras capture images", "content": "Episode 177: Honor every photon. In this episode, Chet, Roman, and Tor have a chat with Bart Wronski from the Google Research team, discussing the camera pipeline that powers the Pixel phones. How cameras capture images, how the algorithms responsible for Pixelโ€™s beautiful images, HDR+ or Night Sight mode works, and more!", - "URL": "https://adbackstage.libsyn.com/episode-177-honor-every-photon", - "authorName": "Chet Haase", + "url": "https://adbackstage.libsyn.com/episode-177-honor-every-photon", "publishDate": "2021-10-17T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Camera", - "Graphics" + 4 + ], + "authors": [ + 7 ], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", @@ -913,15 +1075,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 49, + "episodeId": 49, "title": "Accessibility series ๐ŸŒ - Touch targets", "content": "The accessibility series continues on with more information on how to follow basic accessibility principles to make sure that your app can be used by as many users as possible.\nIn general, you should ensure that interactive elements have a width and height of at least 48dp! In the touch targets episode, youโ€™ll learn about a few ways in which you can make this happen.", - "URL": "https://www.youtube.com/watch?v=Dqqbe8IFBA4", - "authorName": "Shailen Tuli", + "url": "https://www.youtube.com/watch?v=Dqqbe8IFBA4", "publishDate": "2021-10-16T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Accessibility" + 15 + ], + "authors": [ + 5 ], "alternateVideo": { "URL": "https://storage.googleapis.com/now-in-android/NIA049.mp4", @@ -930,15 +1095,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 50, + "episodeId": 49, "title": "Using the CameraX Exposure Compensation API", "content": "This blog post by Wenhung Teng talks about how to use the CameraX Exposure Compensation that makes it much simpler to quickly take images with exceptional quality.", - "URL": "https://medium.com/androiddevelopers/using-camerax-exposure-compensation-api-11fd75785bf", - "authorName": "Wenhung Teng", + "url": "https://medium.com/androiddevelopers/using-camerax-exposure-compensation-api-11fd75785bf", "publishDate": "2021-10-12T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Camera" + 4 + ], + "authors": [ + 12 ], "alternateVideo": { "URL": "", @@ -947,16 +1115,19 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 51, + "episodeId": 49, "title": "Compose for Wear OS in Developer preview โŒš", "content": "Weโ€™re bringing the best of Compose to Wear OS as well, with built-in support for Material You to help you create beautiful apps with less code. Read the following article to review the main composables for Wear OS weโ€™ve built and point you towards resources to get started using them.", - "URL": "https://android-developers.googleblog.com/2021/10/compose-for-wear-os-now-in-developer.html", - "authorName": "Jeremy Walker", + "url": "https://android-developers.googleblog.com/2021/10/compose-for-wear-os-now-in-developer.html", "publishDate": "2021-10-11T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Wear", - "Compose" + 18, + 9 + ], + "authors": [ + 6 ], "alternateVideo": { "URL": "", @@ -965,15 +1136,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 52, + "episodeId": 49, "title": "Paging ๐Ÿ“‘ How to fetch data and bind the PagingData to the UI", "content": "The series on Paging continues on with more content! In the second episode, TJ shows how to fetch data and bind the PagingData to the UI, including headers and footers.", - "URL": "https://www.youtube.com/watch?v=C0H54K63Lww", - "authorName": "TJ Dahunsi", + "url": "https://www.youtube.com/watch?v=C0H54K63Lww", "publishDate": "2021-10-10T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Paging" + 1 + ], + "authors": [ + 0 ], "alternateVideo": { "URL": "", @@ -982,16 +1156,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 53, + "episodeId": 49, "title": "Room adds support for Kotlin Symbol Processing", "content": "Yigit Boyar wrote the story about how Room added support for Kotlin Symbol Processing (KSP). Spoiler: it wasnโ€™t easy, but it was definitely worth it.", - "URL": "https://medium.com/androiddevelopers/room-kotlin-symbol-processing-24808528a28e", - "authorName": "Yigit Boyar", + "url": "https://medium.com/androiddevelopers/room-kotlin-symbol-processing-24808528a28e", "publishDate": "2021-10-09T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Data Storage", - "Room" + 7 + ], + "authors": [ + 13 ], "alternateVideo": { "URL": "", @@ -1000,15 +1176,18 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 54, + "episodeId": 49, "title": "Apply special effects to images with the CameraX Extensions API", "content": "Have you ever wanted to apply special effects such as HDR or Night mode when taking pictures from your app? CameraX is here to help you! In this article by Charcoal Chen, learn how to do that using the new ExtensionsManager available in the camera-extensions Jetpack library. ", - "URL": "https://medium.com/androiddevelopers/apply-special-effects-to-images-with-the-camerax-extensions-api-d1a169b803d3", - "authorName": "Charcoal Chen", + "url": "https://medium.com/androiddevelopers/apply-special-effects-to-images-with-the-camerax-extensions-api-d1a169b803d3", "publishDate": "2021-10-06T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Camera" + 4 + ], + "authors": [ + 14 ], "alternateVideo": { "URL": "", @@ -1017,16 +1196,19 @@ object FakeDataSource { } }, { - "episode": 49, + "id": 55, + "episodeId": 49, "title": "Wear OS Jetpack libraries now in stable", "content": "The Wear OS Jetpack libraries are now in stable.", - "URL": "https://android-developers.googleblog.com/2021/09/wear-os-jetpack-libraries-now-in-stable.html", - "authorName": "Jeremy Walker", + "url": "https://android-developers.googleblog.com/2021/09/wear-os-jetpack-libraries-now-in-stable.html", "publishDate": "2021-09-14T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Jetpack", - "Wear" + 6, + 18 + ], + "authors": [ + 6 ], "alternateVideo": { "URL": "", @@ -1035,16 +1217,17 @@ object FakeDataSource { } }, { - "episode": 48, + "id": 56, + "episodeId": 48, "title": "Android Dev Summit returns on October 27-28, 2021! ๐Ÿ“†", "content": "Join us October 27โ€“28 for Android Dev Summit 2021! The show kicks off at 10 AM PST on October 27 with The Android Show: a technical keynote where youโ€™ll hear all the latest developer news and updates. From there, we have over 30 sessions on a range of technical Android development topics, and weโ€™ll be answering your #AskAndroid questions live.", - "URL": "https://developer.android.com/dev-summit", - "authorName": "", + "url": "https://developer.android.com/dev-summit", "publishDate": "2021-10-05T23:00:00.000Z", "type": "Event ๐Ÿ“†", "topics": [ - "Events" + 0 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -1052,15 +1235,18 @@ object FakeDataSource { } }, { - "episode": 48, + "id": 57, + "episodeId": 48, "title": "Android 12 is live in AOSP! ๐Ÿค–", "content": "We released Android 12 and pushed it to the Android Open Source Project (AOSP). It will be coming to devices later on this year. Thank you for your feedback during the beta.\nAndroid 12 introduces a new design language called Material You along with redesigned widgets, notification UI updates, stretch overscroll, and app launch splash screens. We reduced the CPU time used by core system services, added performance class device capabilities, made ML accelerator drivers updatable outside of platform releases, and prevented apps from launching foreground services from the background and using notification trampolines to improve performance. The new Privacy Dashboard, approximate location, microphone and camera indicators/toggles, and nearby device permissions give users more insight into and control over privacy. We improved the user experience with a unified API for rich content insertion, compatible media transcoding, easier blurs and effects, AVIF image support, enhanced haptics, new camera effects/capabilities, improved native crash debugging, support for rounded screen corners, Play as you download, and Game Mode APIs.", - "URL": "https://android-developers.googleblog.com/2021/10/android-12-is-live-in-aosp.html", - "authorName": "Dave Burke", + "url": "https://android-developers.googleblog.com/2021/10/android-12-is-live-in-aosp.html", "publishDate": "2021-10-03T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Android releases" + 13 + ], + "authors": [ + 15 ], "alternateVideo": { "URL": "", @@ -1069,15 +1255,18 @@ object FakeDataSource { } }, { - "episode": 48, + "id": 58, + "episodeId": 48, "title": "Improved Google Play Console user management ๐Ÿง‘โ€๐Ÿ’ผ", "content": "The user and permission tools in Play Console have a new, decluttered interface and new team management features, making it easier to make sure every team member has the right set of permissions to fulfill their responsibilities without overexposing unrelated business data.\nWeโ€™ve rewritten permission names and descriptions, clarified differentiation between account and app-level permissions, added new search, filtering, and batch-editing capabilities, and added the ability to export this information to a CSV file. In addition, Play Console users can request access to actions with a justification, and weโ€™ve introduced permission groups to make it easier to assign multiple permissions at once to users that share the same or similar roles.", - "URL": "https://android-developers.googleblog.com/2021/09/improved-google-play-console-user.html", - "authorName": "Mike Yerou", + "url": "https://android-developers.googleblog.com/2021/09/improved-google-play-console-user.html", "publishDate": "2021-09-20T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Play" + 11 + ], + "authors": [ + 16 ], "alternateVideo": { "URL": "", @@ -1086,15 +1275,18 @@ object FakeDataSource { } }, { - "episode": 48, + "id": 59, + "episodeId": 48, "title": "Making Permissions auto-reset available to billions more devices ๐Ÿ”", "content": "Android 11 introduced permission auto-reset, automatically resetting an appโ€™s runtime permissions when it isnโ€™t used for a few months. In December 2021, we are starting to roll this feature out to devices with Google Play services running Android 6.0 (API level 23) or higher for apps targeting Android 11 (API level 30) or higher. Users can manually enable permission auto-reset for apps targeting API levels 23 to 29.\nSome apps and permissions are automatically exempted from revocation, like active Device Administrator apps used by enterprises, and permissions fixed by enterprise policy. If your app is expected to work primarily in the background without user interaction, you can ask the user to prevent the system from resetting your appโ€™s permissions.", - "URL": "https://android-developers.googleblog.com/2021/09/making-permissions-auto-reset-available.html", - "authorName": "Peter Visontay", + "url": "https://android-developers.googleblog.com/2021/09/making-permissions-auto-reset-available.html", "publishDate": "2021-09-16T23:00:00.000Z", "type": "DAC - Android version features", "topics": [ - "Permissions" + 10 + ], + "authors": [ + 17 ], "alternateVideo": { "URL": "", @@ -1103,16 +1295,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 60, + "episodeId": 47, "title": "Hilt under the hood", "content": "This episode dives into how the Hilt annotation processors generate code, and how the Hilt Gradle plugin works behind the scenes to improve the overall experience when using Hilt with Gradle.", - "URL": "https://medium.com/androiddevelopers/mad-skills-series-hilt-under-the-hood-9d89ee227059", - "authorName": "Brad Corso", + "url": "https://medium.com/androiddevelopers/mad-skills-series-hilt-under-the-hood-9d89ee227059", "publishDate": "2021-09-07T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Hilt", - "MAD Skills" + 14 + ], + "authors": [ + 18 ], "alternateVideo": { "URL": "", @@ -1121,16 +1315,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 61, + "episodeId": 47, "title": "Hilt extensions", "content": "This episode explains how to write your own Hilt Extensions. Hilt Extensions allow you to extend Hilt support to new libraries. Extensions can be created for common patterns in projects, to support non-standard member injection, mirroring bindings, and more.", - "URL": "https://medium.com/androiddevelopers/hilt-extensions-in-the-mad-skills-series-f2ed6fcba5fe", - "authorName": "Daniel Santiago", + "url": "https://medium.com/androiddevelopers/hilt-extensions-in-the-mad-skills-series-f2ed6fcba5fe", "publishDate": "2021-09-12T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Hilt", - "MAD Skills" + 14 + ], + "authors": [ + 19 ], "alternateVideo": { "URL": "", @@ -1139,16 +1335,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 62, + "episodeId": 47, "title": "Migrating from Dagger to Hilt", "content": "While you will eventually want to migrate all your existing Dagger modules over to Hiltโ€™s built in components, you can start by migrating application-wide components to Hiltโ€™s singleton component. This episode explains how.", - "URL": "https://www.youtube.com/watch?v=Xt1_3Nq4lD0&t=15s", - "authorName": "Marcelo Hernandez", + "url": "https://www.youtube.com/watch?v=Xt1_3Nq4lD0&t=15s", "publishDate": "2021-09-19T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Hilt", - "MAD Skills" + 14 + ], + "authors": [ + 20 ], "alternateVideo": { "URL": "", @@ -1157,17 +1355,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 63, + "episodeId": 47, "title": "Trackr comes to the Big Screen", "content": "A blog post on Trackr, a sample task management app where we showcase Modern Android Development best practices. This post takes you through how applying Material Design and responsive patterns produced a more refined and intuitive user experience on large screen devices.", - "URL": "https://medium.com/androiddevelopers/trackr-comes-to-the-big-screen-9f13c6f927bf", - "authorName": "Jonathan Koren", + "url": "https://medium.com/androiddevelopers/trackr-comes-to-the-big-screen-9f13c6f927bf", "publishDate": "2021-09-06T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Large Screen", - "MAD Skills", - "Material Design" + 1 + ], + "authors": [ + 21 ], "alternateVideo": { "URL": "", @@ -1176,15 +1375,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 64, + "episodeId": 47, "title": "Accessibility services and the Android Accessibility model", "content": "This Accessibilities series episode covers accessibility services like TalkBack, Switch Access and Voice Access and how they help users interact with your apps. Androidโ€™s accessibility framework allows you to write one app and the framework takes care of providing the information needed by different accessibility services.", - "URL": "https://youtu.be/LxKat_m7mHk", - "authorName": "Shailen Tuli", + "url": "https://youtu.be/LxKat_m7mHk", "publishDate": "2021-09-02T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Accessibility" + 15 + ], + "authors": [ + 5 ], "alternateVideo": { "URL": "", @@ -1193,15 +1395,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 65, + "episodeId": 47, "title": "Labeling images for Accessibility", "content": "This Accessibilities series episode covers labeling images for accessibility, such as content descriptions for ImageViews and ImageButtons.", - "URL": "https://youtu.be/O2DeSITnzFk", - "authorName": "Caren Chang", + "url": "https://youtu.be/O2DeSITnzFk", "publishDate": "2021-09-09T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Accessibility" + 15 + ], + "authors": [ + 22 ], "alternateVideo": { "URL": "", @@ -1210,16 +1415,17 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 66, + "episodeId": 47, "title": "New Accessibility Pathway", "content": "Want even more accessibility? You are in luck, check out this entire new learning pathway aimed at teaching you how to make your app more accessible.", - "URL": "https://developer.android.com/courses/pathways/make-your-android-app-accessible", - "authorName": "", + "url": "https://developer.android.com/courses/pathways/make-your-android-app-accessible", "publishDate": "2021-08-31T23:00:00.000Z", "type": "", "topics": [ - "Accessibility" + 15 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -1227,16 +1433,17 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 67, + "episodeId": 47, "title": "AndroidX Activity Library 1.4.0-alpha01 released", "content": "The AndroidX ComponentActivity now implements the MenuHost interface which allows any component to add menu items to the ActionBar by adding a MenuProvider instance to the activity.", - "URL": "https://developer.android.com/jetpack/androidx/releases/activity#1.4.0-alpha01", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/activity#1.4.0-alpha01", "publishDate": "2021-08-31T23:00:00.000Z", "type": "API change", "topics": [ - "AndroidX" + 6 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -1244,16 +1451,19 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 68, + "episodeId": 47, "title": "ADB Podcast Episode 174: Compose in Android Studio", "content": "In this episode, Tor and Nick are joined by Chris Sinco, Diego Perez and Nicolas Roard to discuss the features added to Android Studio for Jetpack Compose. Tune in as they discuss the Compose preview, interactive preview, animation inspector, and additions to the Layout inspector along with their approach to creating tooling to support Composeโ€™s code-centric system.", - "URL": "", - "authorName": "Tor Norbye", + "url": "http://adbackstage.libsyn.com/episode-174-compose-tooling", "publishDate": "2021-09-08T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Android Studio", - "Compose" + 5, + 9 + ], + "authors": [ + 23 ], "alternateVideo": { "URL": "", @@ -1262,15 +1472,18 @@ object FakeDataSource { } }, { - "episode": 47, + "id": 69, + "episodeId": 47, "title": "ADB Podcast Episode 175: Creating delightful user experiences with Lottie animations", "content": "In this episode, Chet, Romain and Tor have a chat with Gabriel Peal from Tonal, well known for his contributions to the Android community on projects such as Mavericks and Lottie. They talked about Lottie and how it helps designers and developers deliver more delightful user experiences by taking complex animations designed in specialized authoring tools such as After Effects, and rendering them efficiently on mobile devices. They also explored the challenges of designing and implementing a rendering engine such as Lottie.", - "URL": "", - "authorName": "Chet Haase", + "url": "http://adbackstage.libsyn.com/episode-175-lottie", "publishDate": "2021-09-13T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Animations" + 1 + ], + "authors": [ + 7 ], "alternateVideo": { "URL": "", @@ -1279,17 +1492,17 @@ object FakeDataSource { } }, { - "episode": 45, + "id": 70, + "episodeId": 45, "title": "DataStore released into stable", "content": "Datastore was released, providing a data storage solution that allows you to store key-value pairs or typed objects with protocol buffers.", - "URL": "https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0", - "authorName": "", + "url": "https://developer.android.com/jetpack/androidx/releases/datastore#1.0.0", "publishDate": "2021-08-03T23:00:00.000Z", "type": "Jetpack release ๐Ÿš€", "topics": [ - "Data storage", - "DataStore" + 7 ], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -1297,15 +1510,18 @@ object FakeDataSource { } }, { - "episode": 44, + "id": 71, + "episodeId": 44, "title": "Jetpack Compose 1.0 stable is released", "content": "Jetpack Compose, Androidโ€™s modern, native UI toolkit is now stable and ready for you to adopt in production. It interoperates with your existing app, integrates with existing Jetpack libraries, implements Material Design with straightforward theming, supports lists with Lazy components using minimal boilerplate, and has a powerful, extensible animation system.", - "URL": "https://android-developers.googleblog.com/2021/07/jetpack-compose-announcement.html", - "authorName": "Anna-Chiara Bellini", + "url": "https://android-developers.googleblog.com/2021/07/jetpack-compose-announcement.html", "publishDate": "2021-07-27T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Compose" + 9 + ], + "authors": [ + 24 ], "alternateVideo": { "URL": "", @@ -1314,16 +1530,19 @@ object FakeDataSource { } }, { - "episode": 44, + "id": 72, + "episodeId": 44, "title": "Android Studio Artic Fox stable is released", "content": "Android Studio Arctic Fox is now available in the stable release channel. Arctic Fox brings Jetpack Compose to life with Compose Preview, Deploy Preview, Compose support in the Layout Inspector, and Live Editing of literals. Compose Preview works with the @Preview annotation to let you instantly see the impact of changes across multiple themes, screen sizes, font sizes, and more. Deploy Preview deploys snippets of your Compose code to a device or emulator for quick testing. Layout inspector now works with apps written fully in Compose as well as apps that have Compose alongside Views, allowing you to explore your layouts and troubleshoot. With Live Edit of literals, you can edit literals such as strings, numbers, booleans, etc. and see the immediate results change in previews, the emulator, or on a physical device โ€” all without having to compile.\n", - "URL": "https://android-developers.googleblog.com/2021/07/android-studio-arctic-fox-202031-stable.html", - "authorName": "Amanda Alexander", + "url": "https://android-developers.googleblog.com/2021/07/android-studio-arctic-fox-202031-stable.html", "publishDate": "2021-07-27T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Android Studio", - "Compose" + 5, + 9 + ], + "authors": [ + 25 ], "alternateVideo": { "URL": "", @@ -1332,15 +1551,18 @@ object FakeDataSource { } }, { - "episode": 44, + "id": 73, + "episodeId": 44, "title": "User control, privacy, security, and safety", "content": "Play announced new updates to bolster user control, privacy, and security. The post covered advertising ID updates, including zeroing out the advertising ID when users opt out of interest-based advertising or ads personalization, the developer preview of the app set ID, enhanced protection for kids, and policy updates around dormant accounts and users of the AccessibilityService API.", - "URL": "https://android-developers.googleblog.com/2021/07/announcing-policy-updates-to-bolster.html", - "authorName": "Krish Vitaldevara", + "url": "https://android-developers.googleblog.com/2021/07/announcing-policy-updates-to-bolster.html", "publishDate": "2021-07-27T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Play Console" + 11 + ], + "authors": [ + 11 ], "alternateVideo": { "URL": "", @@ -1349,16 +1571,19 @@ object FakeDataSource { } }, { - "episode": 44, + "id": 74, + "episodeId": 44, "title": "Identify performance bottlenecks using system trace", "content": "System trace profiling within Android Studio with a detailed walkthrough of app startup performance.", - "URL": "https://www.youtube.com/watch?v=aUrqx9AnDUg", - "authorName": "Carmen Jackson", + "url": "https://www.youtube.com/watch?v=aUrqx9AnDUg", "publishDate": "2021-07-25T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "MAD Skills", - "Performance" + 3, + 5 + ], + "authors": [ + 26 ], "alternateVideo": { "URL": "", @@ -1367,16 +1592,19 @@ object FakeDataSource { } }, { - "episode": 44, + "id": 75, + "episodeId": 44, "title": "Testing in Compose", "content": "ADB released episode #171, part of our continuing series on Jetpack Compose. In this episode, Nick and Romain are joined by Filip Pavlis, Jelle Fresen & Jose Alcรฉrreca to talk about Testing in Compose. They discuss how Composeโ€™s testing APIs were developed hand-in-hand with the UI toolkit, making them more deterministic and opening up new possibilities like manipulating time. They go on to discuss the semantics tree, interop testing, screenshot testing and the possibilities for host-side testing.", - "URL": "https://adbackstage.libsyn.com/episode-171-compose-testing", - "authorName": "Android Developers Backstage", - "publishDate": "2021-08-31T23:00:00.000Z", + "url": "https://adbackstage.libsyn.com/episode-171-compose-testing", + "publishDate": "2021-06-29T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Compose", - "Testing" + 9, + 2 + ], + "authors": [ + 27 ], "alternateVideo": { "URL": "", @@ -1385,16 +1613,15 @@ object FakeDataSource { } }, { - "episode": 42, + "id": 76, + "episodeId": 42, "title": "DataStore reached release candidate status", - "content": "Jetpack Compose and DataStore have now reached release candidate status meaning the 1.0 stable releases are right around the corner!", - "URL": "https://developer.android.com/topic/libraries/architecture/datastore", - "authorName": "", + "content": "DataStore has reached release candidate status meaning the 1.0 stable release is right around the corner!", + "url": "https://developer.android.com/topic/libraries/architecture/datastore", "publishDate": "2021-06-29T23:00:00.000Z", "type": "Jetpack release ๐Ÿš€", - "topics": [ - "" - ], + "topics": [], + "authors": [], "alternateVideo": { "URL": "", "startTimestamp": 0, @@ -1402,16 +1629,19 @@ object FakeDataSource { } }, { - "episode": 42, + "id": 77, + "episodeId": 42, "title": "Scope Storage Myths", "content": "Apps will be required to update their targetSdkVersion to API 30 in the second half of the year. That means your app will be required to work with Scoped Storage. In this blog post, Nicole Borrelli busts some Scope storage myths in a Q&A format.", - "URL": "https://medium.com/androiddevelopers/scope-storage-myths-ca6a97d7ff37", - "authorName": "Nicole Borrelli", + "url": "https://medium.com/androiddevelopers/scope-storage-myths-ca6a97d7ff37", "publishDate": "2021-06-27T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Data storage", - "Scoped Storage" + 7, + 10 + ], + "authors": [ + 28 ], "alternateVideo": { "URL": "", @@ -1420,15 +1650,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 78, + "episodeId": 41, "title": "Android 12 Beta 2 Update", "content": "The second Beta of Android 12 has just been released for you to try. Beta 2 adds new privacy features like the Privacy Dashboard and continues our work of refining the release.", - "URL": "https://android-developers.googleblog.com/2021/06/android-12-beta-2-update.html", - "authorName": "Dave Burke", + "url": "https://android-developers.googleblog.com/2021/06/android-12-beta-2-update.html", "publishDate": "2021-06-08T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Android releases" + 13 + ], + "authors": [ + 15 ], "alternateVideo": { "URL": "", @@ -1437,16 +1670,19 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 79, + "episodeId": 41, "title": "Grow Your Indie Game with Help From Google Play", "content": "Google Play is opening submissions for two of our annual developer programs - the Indie Games Accelerator and the Indie Games Festival. These programs are designed to help small games studios grow on Google Play, no matter what stage they are in", - "URL": "https://developers.googleblog.com/2021/06/grow-your-indie-game-with-help-from-google-play.html", - "authorName": "Patricia Correa", + "url": "https://developers.googleblog.com/2021/06/grow-your-indie-game-with-help-from-google-play.html", "publishDate": "2021-05-31T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Play", - "Games" + 11, + 17 + ], + "authors": [ + 29 ], "alternateVideo": { "URL": "", @@ -1455,16 +1691,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 80, + "episodeId": 41, "title": "Navigation with Multiple back stacks", - "content": "As part of the rercommended Material pattern for bottom-navigation, the Jetpack Navigation librar y makes it easy to implement navigation with multiple back-stacks", - "URL": "https://medium.com/androiddevelopers/navigation-multiple-back-stacks-6c67ba41952f", - "authorName": "Murat Yener", + "content": "As part of the rercommended Material pattern for bottom-navigation, the Jetpack Navigation library makes it easy to implement navigation with multiple back-stacks", + "url": "https://medium.com/androiddevelopers/navigation-multiple-back-stacks-6c67ba41952f", "publishDate": "2021-06-14T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Navigation", - "MAD Skills" + 1 + ], + "authors": [ + 10 ], "alternateVideo": { "URL": "", @@ -1473,16 +1711,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 81, + "episodeId": 41, "title": "Navigation in Feature Modules", "content": "Feature modules delivered with Play Feature delivery at not downloadedd at install time, but only when the app requestss them. Learn how to use the dynamic features navigation library to include the graph from the feature module.", - "URL": "https://medium.com/androiddevelopers/navigation-in-feature-modules-322ac3d79334", - "authorName": "Murat Yener", + "url": "https://medium.com/androiddevelopers/navigation-in-feature-modules-322ac3d79334", "publishDate": "2021-06-01T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Navigation", - "MAD Skills" + 1 + ], + "authors": [ + 10 ], "alternateVideo": { "URL": "", @@ -1491,16 +1731,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 82, + "episodeId": 41, "title": "Android @ Google I/O: 3 things to know in Modern Android Development", "content": "This yearโ€™s Google I/O brought lots of updates for Modern Android Development. Learn about the top 3 things you should know.", - "URL": "https://android-developers.googleblog.com/2021/05/mad-spotlight.html", - "authorName": "The Modern Android Development Team", + "url": "https://android-developers.googleblog.com/2021/05/mad-spotlight.html", "publishDate": "2021-05-24T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Android releases", - "MAD Skills" + 0 + ], + "authors": [ + 30 ], "alternateVideo": { "URL": "", @@ -1509,15 +1751,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 83, + "episodeId": 41, "title": "Top 3 things in Android 12 | Android @ Google I/O '21", "content": "Did you miss the latest in Android 12 at Google I/O 2021? Android Software Engineer Chet Haase will recap the top three themes in Android 12 from this yearโ€™s Google I/O!", - "URL": "https://www.youtube.com/watch?v=tvf1wmD5H0M", - "authorName": "Chet Haase", + "url": "https://www.youtube.com/watch?v=tvf1wmD5H0M", "publishDate": "2021-06-08T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Android Releases" + 13 + ], + "authors": [ + 7 ], "alternateVideo": { "URL": "", @@ -1526,15 +1771,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 84, + "episodeId": 41, "title": "Building across devices | Android @ Google I/O '21", "content": "Did you miss the latest in Building across screens at Google I/O 2021? Product Manager Diana Wong will recap the top three announcements from this yearโ€™s Google I/O!", - "URL": "https://www.youtube.com/watch?v=O5oRiIUk_F4", - "authorName": "Diana Wong", + "url": "https://www.youtube.com/watch?v=O5oRiIUk_F4", "publishDate": "2021-06-02T23:00:00.000Z", "type": "Video ๐Ÿ“บ", "topics": [ - "Form Factors" + 1 + ], + "authors": [ + 31 ], "alternateVideo": { "URL": "", @@ -1543,16 +1791,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 85, + "episodeId": 41, "title": "Multiple Back Stacks", "content": "A deep dive into multiple back stacks and some of the work it took to make this feature happen in Fragments and Navigation", - "URL": "https://medium.com/androiddevelopers/multiple-back-stacks-b714d974f134", - "authorName": "Ian Lake", + "url": "https://medium.com/androiddevelopers/multiple-back-stacks-b714d974f134", "publishDate": "2021-06-06T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Navigation", - "Fragments" + 1 + ], + "authors": [ + 32 ], "alternateVideo": { "URL": "", @@ -1561,15 +1811,19 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 86, + "episodeId": 41, "title": "Build sophisticated search features with AppSearch", "content": "AppSearch is an on-device search library which provides high performance and feature-rich full-text search functionality. Learn how to use the new Jetpack AppSearch library for doing high-performance on-device full text searches.", - "URL": "https://android-developers.googleblog.com/2021/06/sophisticated-search-with-appsearch-in-jetpack.html", - "authorName": "Dan Saadati", + "url": "https://android-developers.googleblog.com/2021/06/sophisticated-search-with-appsearch-in-jetpack.html", "publishDate": "2021-06-13T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "AppSearch" + 6, + 1 + ], + "authors": [ + 33 ], "alternateVideo": { "URL": "", @@ -1578,15 +1832,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 87, + "episodeId": 41, "title": "Untrusted Touch Events in Android", "content": "Android 12 prevents touch events from being deliverred if these touches first pass through a window from a different app to ensure users can see what they are interacting with. Learn about alternatives, to see if your app will be affected and how you can test to see if your app will be impacted.", - "URL": "https://medium.com/androiddevelopers/untrusted-touch-events-2c0e0b9c374c", - "authorName": "Meghan Mehta", + "url": "https://medium.com/androiddevelopers/untrusted-touch-events-2c0e0b9c374c", "publishDate": "2021-05-25T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Android releases" + 13 + ], + "authors": [ + 8 ], "alternateVideo": { "URL": "", @@ -1595,16 +1852,18 @@ object FakeDataSource { } }, { - "episode": 41, - "title": "Create an application CorouotineScope using Hilt", + "id": 88, + "episodeId": 41, + "title": "Create an application CoroutineScope using Hilt", "content": "Learn how to create an applicatioon-scoped CoroutineScope using Hilt, and how to inject it as a dependency.", - "URL": "https://medium.com/androiddevelopers/create-an-application-coroutinescope-using-hilt-dd444e721528", - "authorName": "Manuel Vivo", + "url": "https://medium.com/androiddevelopers/create-an-application-coroutinescope-using-hilt-dd444e721528", "publishDate": "2021-06-09T23:00:00.000Z", "type": "Article ๐Ÿ“š", "topics": [ - "Coroutines", - "Hilt" + 14 + ], + "authors": [ + 34 ], "alternateVideo": { "URL": "", @@ -1613,15 +1872,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 89, + "episodeId": 41, "title": "ADB Podcast Episode 165: Material Witnesses", "content": "In this episode, Chet and Romain chattedd with Hunter and Nick from the Material Design team about recent additions and improvements to the Material Design Component libraries: transitions, motion theming, Compose, large screens support and guidance, etc.", - "URL": "http://adbackstage.libsyn.com/episode-165-material-witnesses", - "authorName": "Chet Haase", + "url": "http://adbackstage.libsyn.com/episode-165-material-witnesses", "publishDate": "2021-06-01T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Material Design" + 1 + ], + "authors": [ + 7 ], "alternateVideo": { "URL": "", @@ -1630,15 +1892,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 90, + "episodeId": 41, "title": "ADB Podcast Episode 166: Security Deposit", "content": "In this episode, Chad and Jeff from the Android Security team join Tor and Romain to talk aboutโ€ฆ security. They explain what the platform does to help preserve user trust and device integrity, why it sometimes means restricting existing APIs, and touch on what apps can do or should worry about.", - "URL": "http://adbackstage.libsyn.com/episode-166-security-deposit", - "authorName": "Tor Norbye", + "url": "http://adbackstage.libsyn.com/episode-166-security-deposit", "publishDate": "2021-06-07T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Security" + 10 + ], + "authors": [ + 23 ], "alternateVideo": { "URL": "", @@ -1647,15 +1912,18 @@ object FakeDataSource { } }, { - "episode": 41, + "id": 91, + "episodeId": 41, "title": "ADB Podcast Episode 167: Jetpack Compose Layout", "content": "In this second episode of our mini-series on Jetpack Compose (AD/BC), Nick and Romain are joined by Anastasia Soboleva, George Mount and Mihai Popa to talk about Composeโ€™s layout system. They explain how the Compose layout model works and its benefits, introduce common layout composables, discuss how writing your own layout is far simpler than Views, and how you can even animate layout.", - "URL": "https://adbackstage.libsyn.com/episode-167-jetpack-compose-layout", - "authorName": "Nick Butcher", + "url": "https://adbackstage.libsyn.com/episode-167-jetpack-compose-layout", "publishDate": "2021-06-13T23:00:00.000Z", "type": "Podcast ๐ŸŽ™", "topics": [ - "Compose" + 9 + ], + "authors": [ + 35 ], "alternateVideo": { "URL": "", @@ -1665,5 +1933,6 @@ object FakeDataSource { } ] } -""".trimIndent() + + """.trimIndent() } diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepository.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepository.kt similarity index 56% rename from app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepository.kt rename to app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepository.kt index c7573d2a4..883231e8a 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepository.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepository.kt @@ -16,29 +16,35 @@ package com.google.samples.apps.nowinandroid.data.news.fake +import com.google.samples.apps.nowinandroid.data.news.NewsRepository import com.google.samples.apps.nowinandroid.data.news.NewsResource -import com.google.samples.apps.nowinandroid.data.news.NewsResourceRepository -import kotlinx.coroutines.CoroutineDispatcher +import com.google.samples.apps.nowinandroid.di.NiaDispatchers +import javax.inject.Inject import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn +import kotlinx.coroutines.flow.map import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json /** - * [NewsResourceRepository] implementation that provides static news resources to aid development + * [NewsRepository] implementation that provides static news resources to aid development */ -class FakeNewsResourceRepository( - private val ioDispatcher: CoroutineDispatcher -) : NewsResourceRepository { - private val deserializer = Json { ignoreUnknownKeys = true } - - override fun monitor(): Flow> = flow { - emit(deserializer.decodeFromString(FakeDataSource.data).resources) +class FakeNewsRepository @Inject constructor( + private val dispatchers: NiaDispatchers, + private val networkJson: Json +) : NewsRepository { + override fun getNewsResourcesStream(): Flow> = flow { + emit(networkJson.decodeFromString(FakeDataSource.data).resources) } - .flowOn(ioDispatcher) + .flowOn(dispatchers.IO) + + override fun getNewsResourcesStream(filterTopicIds: Set): Flow> = + getNewsResourcesStream().map { newsResources -> + newsResources.filter { it.topics.intersect(filterTopicIds.toSet()).isNotEmpty() } + } } /** diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeTopicsRepository.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeTopicsRepository.kt new file mode 100644 index 000000000..81217e3fc --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeTopicsRepository.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data.news.fake + +import com.google.samples.apps.nowinandroid.data.NiaPreferences +import com.google.samples.apps.nowinandroid.data.news.Topic +import com.google.samples.apps.nowinandroid.data.news.TopicsRepository +import com.google.samples.apps.nowinandroid.di.NiaDispatchers +import javax.inject.Inject +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.flowOn +import kotlinx.serialization.decodeFromString +import kotlinx.serialization.json.Json + +class FakeTopicsRepository @Inject constructor( + private val dispatchers: NiaDispatchers, + private val networkJson: Json, + private val niaPreferences: NiaPreferences +) : TopicsRepository { + override fun getTopicsStream(): Flow> = flow> { + emit(networkJson.decodeFromString(FakeDataSource.topicsData)) + } + .flowOn(dispatchers.IO) + + override suspend fun setFollowedTopicIds(followedTopicIds: Set) = + niaPreferences.setFollowedTopicIds(followedTopicIds) + + override fun getFollowedTopicIdsStream() = niaPreferences.followedTopicIds +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt index 6c88450a6..406d2bb19 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/di/AppModule.kt @@ -16,10 +16,57 @@ package com.google.samples.apps.nowinandroid.di +import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.core.DataStoreFactory +import androidx.datastore.dataStoreFile +import com.google.samples.apps.nowinandroid.data.UserPreferences +import com.google.samples.apps.nowinandroid.data.UserPreferencesSerializer +import com.google.samples.apps.nowinandroid.data.news.NewsRepository +import com.google.samples.apps.nowinandroid.data.news.TopicsRepository +import com.google.samples.apps.nowinandroid.data.news.fake.FakeNewsRepository +import com.google.samples.apps.nowinandroid.data.news.fake.FakeTopicsRepository +import dagger.Binds import dagger.Module +import dagger.Provides import dagger.hilt.InstallIn +import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton +import kotlinx.serialization.json.Json @Module @InstallIn(SingletonComponent::class) -class AppModule +interface AppModule { + + @Binds + fun bindsTopicRepository(fakeTopicsRepository: FakeTopicsRepository): TopicsRepository + + @Binds + fun bindsNewsResourceRepository( + fakeNewsRepository: FakeNewsRepository + ): NewsRepository + + @Binds + fun bindsNiaDispatchers(defaultNiaDispatchers: DefaultNiaDispatchers): NiaDispatchers + + companion object { + @Provides + @Singleton + fun providesUserPreferencesDataStore( + @ApplicationContext context: Context, + userPreferencesSerializer: UserPreferencesSerializer + ): DataStore = + DataStoreFactory.create( + serializer = userPreferencesSerializer + ) { + context.dataStoreFile("user_preferences.pb") + } + + @Provides + @Singleton + fun providesNetworkJson(): Json = Json { + ignoreUnknownKeys = true + } + } +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/di/NiaDispatchers.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/di/NiaDispatchers.kt new file mode 100644 index 000000000..7ca74b643 --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/di/NiaDispatchers.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.di + +import javax.inject.Inject +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.MainCoroutineDispatcher + +interface NiaDispatchers { + val IO: CoroutineDispatcher + + val Default: CoroutineDispatcher + + val Main: MainCoroutineDispatcher + + val Unconfined: CoroutineDispatcher +} + +class DefaultNiaDispatchers @Inject constructor() : NiaDispatchers { + override val IO: CoroutineDispatcher = Dispatchers.IO + override val Default: CoroutineDispatcher = Dispatchers.Default + override val Main: MainCoroutineDispatcher = Dispatchers.Main + override val Unconfined: CoroutineDispatcher = Dispatchers.Unconfined +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaNavGraph.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaNavGraph.kt index cf3a37ec3..ad6e93650 100644 --- a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaNavGraph.kt +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/NiaNavGraph.kt @@ -19,10 +19,12 @@ package com.google.samples.apps.nowinandroid.ui import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.testTag import androidx.navigation.NavHostController import androidx.navigation.compose.NavHost import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController +import com.google.samples.apps.nowinandroid.ui.foryou.ForYouRoute /** * Top-level navigation graph. Navigation is organized as explained at @@ -42,7 +44,7 @@ fun NiaNavGraph( startDestination = startDestination, ) { composable(NiaDestinations.FOR_YOU_ROUTE) { - Text("FOR YOU", modifier) + ForYouRoute(modifier = modifier.testTag("FOR YOU")) } composable(NiaDestinations.EPISODES_ROUTE) { Text("EPISODES", modifier) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/SavedStateHandleExtensions.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/SavedStateHandleExtensions.kt new file mode 100644 index 000000000..4e01da7eb --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/SavedStateHandleExtensions.kt @@ -0,0 +1,229 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.ui + +import android.os.Binder +import android.os.Bundle +import android.os.Parcelable +import android.util.Size +import android.util.SizeF +import android.util.SparseArray +import androidx.compose.runtime.MutableState +import androidx.compose.runtime.SnapshotMutationPolicy +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.neverEqualPolicy +import androidx.compose.runtime.referentialEqualityPolicy +import androidx.compose.runtime.saveable.Saver +import androidx.compose.runtime.saveable.SaverScope +import androidx.compose.runtime.saveable.autoSaver +import androidx.compose.runtime.saveable.rememberSaveable +import androidx.compose.runtime.setValue +import androidx.compose.runtime.snapshots.SnapshotMutableState +import androidx.compose.runtime.structuralEqualityPolicy +import androidx.core.os.bundleOf +import androidx.lifecycle.SavedStateHandle +import java.io.Serializable +import kotlin.properties.PropertyDelegateProvider +import kotlin.properties.ReadOnlyProperty +import kotlin.properties.ReadWriteProperty +import kotlin.reflect.KProperty + +// These are placeholder solutions for https://issuetracker.google.com/issues/195689777 +// With the following, it is possible to use the Compose Saver APIs to back values in the +// SavedStateHandle to persist through process death, in a similar form as rememberSaveable + +/** + * A [PropertyDelegateProvider] allowing the use of [saveable] with the key provided by the name + * of the property. + */ +fun SavedStateHandle.saveable( + saver: Saver = autoSaver(), + init: () -> T, +): PropertyDelegateProvider> = + PropertyDelegateProvider { _, property -> + val value = saveable( + key = property.name, + saver = saver, + init = init + ) + + ReadOnlyProperty { _, _ -> value } + } + +/** + * A nested [PropertyDelegateProvider] allowing the use of [saveable] with the key provided by the + * name, as well as direct access to the value contained with [MutableState]. + * + * This allows the main usage to look almost identical to + * `rememberSaveable { mutableStateOf(...) }`: + * + * ``` + * val value by savedStateHandle.saveable { mutableStateOf("initialValue") } + * ``` + */ +@JvmName("saveableMutableState") +fun SavedStateHandle.saveable( + stateSaver: Saver = autoSaver(), + init: () -> MutableState, +): PropertyDelegateProvider> = + PropertyDelegateProvider> { _, property -> + val mutableState = saveable( + key = property.name, + stateSaver = stateSaver, + init = init + ) + + object : ReadWriteProperty { + override fun getValue(thisRef: Any, property: KProperty<*>): T = + mutableState.getValue(thisRef, property) + + override fun setValue(thisRef: Any, property: KProperty<*>, value: T) = + mutableState.setValue(thisRef, property, value) + } + } + +/** + * A basic interop between [SavedStateHandle] and [Saver], so the latter can be used to save + * state holders into the [SavedStateHandle]. + * + * This implementation is based on [rememberSaveable], [SaveableStateRegistry] and + * [DisposableSaveableStateRegistry], with some simplifications since there will be exactly one + * state provider storing exactly one value. + * + * This implementation makes use of [SavedStateHandle.setSavedStateProvider], so this + * state will not be kept in sync with any other way to change the internal state + * of the [SavedStateHandle]. + */ +fun SavedStateHandle.saveable( + key: String, + saver: Saver = autoSaver(), + init: () -> T, +): T { + @Suppress("UNCHECKED_CAST") + saver as Saver + // value is restored using the SavedStateHandle or created via [init] lambda + val value = get(key)?.get("value")?.let(saver::restore) ?: init() + + // Hook up saving the state to the SavedStateHandle + setSavedStateProvider(key) { + bundleOf("value" to with(saver) { SaverScope(::canBeSavedToBundle).save(value) }) + } + return value +} + +/** + * A basic interop between [SavedStateHandle] and [Saver], so the latter can be used to save + * state holders into the [SavedStateHandle]. + * + * This implementation is based on [rememberSaveable], [SaveableStateRegistry] and + * [DisposableSaveableStateRegistry], with some simplifications since there will be exactly one + * state provider storing exactly one value. + * + * This implementation makes use of [SavedStateHandle.setSavedStateProvider], so this + * state will not be kept in sync with any other way to change the internal state + * of the [SavedStateHandle]. + * + * Use this overload if you remember a mutable state with a type which can't be stored in the + * Bundle so you have to provide a custom saver object. + */ +fun SavedStateHandle.saveable( + key: String, + stateSaver: Saver, + init: () -> MutableState +): MutableState = saveable( + saver = mutableStateSaver(stateSaver), + key = key, + init = init +) + +/** + * Copied from RememberSaveable.kt + */ +@Suppress("UNCHECKED_CAST") +private fun mutableStateSaver(inner: Saver) = with(inner as Saver) { + Saver, MutableState>( + save = { state -> + require(state is SnapshotMutableState) { + "If you use a custom MutableState implementation you have to write a custom " + + "Saver and pass it as a saver param to saveable()" + } + mutableStateOf(save(state.value), state.policy as SnapshotMutationPolicy) + }, + restore = @Suppress("UNCHECKED_CAST") { + require(it is SnapshotMutableState) + mutableStateOf( + if (it.value != null) restore(it.value!!) else null, + it.policy as SnapshotMutationPolicy + ) as MutableState + } + ) +} + +/** + * Checks that [value] can be stored inside [Bundle]. + * + * Copied from DisposableSaveableStateRegistry.android.kt + */ +private fun canBeSavedToBundle(value: Any): Boolean { + // SnapshotMutableStateImpl is Parcelable, but we do extra checks + if (value is SnapshotMutableState<*>) { + if (value.policy === neverEqualPolicy() || + value.policy === structuralEqualityPolicy() || + value.policy === referentialEqualityPolicy() + ) { + val stateValue = value.value + return if (stateValue == null) true else canBeSavedToBundle(stateValue) + } else { + return false + } + } + for (cl in AcceptableClasses) { + if (cl.isInstance(value)) { + return true + } + } + return false +} + +/** + * Contains Classes which can be stored inside [Bundle]. + * + * Some of the classes are not added separately because: + * + * This classes implement Serializable: + * - Arrays (DoubleArray, BooleanArray, IntArray, LongArray, ByteArray, FloatArray, ShortArray, + * CharArray, Array) + * - ArrayList + * - Primitives (Boolean, Int, Long, Double, Float, Byte, Short, Char) will be boxed when casted + * to Any, and all the boxed classes implements Serializable. + * This class implements Parcelable: + * - Bundle + * + * Note: it is simplified copy of the array from SavedStateHandle (lifecycle-viewmodel-savedstate). + * + * Copied from DisposableSaveableStateRegistry.android.kt + */ +private val AcceptableClasses = arrayOf( + Serializable::class.java, + Parcelable::class.java, + String::class.java, + SparseArray::class.java, + Binder::class.java, + Size::class.java, + SizeF::class.java +) diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreen.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreen.kt new file mode 100644 index 000000000..62782f8f8 --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouScreen.kt @@ -0,0 +1,203 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.ui.foryou + +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyListScope +import androidx.compose.foundation.lazy.items +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.CircularProgressIndicator +import androidx.compose.material3.Button +import androidx.compose.material3.ButtonDefaults +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.OutlinedButton +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.key +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.contentDescription +import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.hilt.navigation.compose.hiltViewModel +import com.google.accompanist.flowlayout.FlowRow +import com.google.samples.apps.nowinandroid.R +import com.google.samples.apps.nowinandroid.data.news.NewsResource +import com.google.samples.apps.nowinandroid.data.news.Topic + +@Composable +fun ForYouRoute( + modifier: Modifier = Modifier, + viewModel: ForYouViewModel = hiltViewModel() +) { + val uiState by viewModel.uiState.collectAsState() + + ForYouScreen( + modifier = modifier, + uiState = uiState, + onTopicCheckedChanged = viewModel::updateTopicSelection, + saveFollowedTopics = viewModel::saveFollowedTopics + ) +} + +@Composable +fun ForYouScreen( + uiState: ForYouFeedUiState, + onTopicCheckedChanged: (Int, Boolean) -> Unit, + saveFollowedTopics: () -> Unit, + modifier: Modifier = Modifier, +) { + Box(modifier = modifier.fillMaxSize()) { + when (uiState) { + ForYouFeedUiState.Loading -> { + val forYouLoading = stringResource(id = R.string.for_you_loading) + + CircularProgressIndicator( + modifier = Modifier + .align(Alignment.Center) + .semantics { + contentDescription = forYouLoading + }, + color = MaterialTheme.colorScheme.primary + ) + } + is ForYouFeedUiState.PopulatedFeed -> { + LazyColumn { + when (uiState) { + is ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection -> { + TopicSelection(uiState, onTopicCheckedChanged, saveFollowedTopics) + } + is ForYouFeedUiState.PopulatedFeed.FeedWithoutTopicSelection -> Unit + } + + items(uiState.feed) { _: NewsResource -> + // TODO: News item + } + } + } + } + } +} + +/** + * The topic selection items + */ +private fun LazyListScope.TopicSelection( + uiState: ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection, + onTopicCheckedChanged: (Int, Boolean) -> Unit, + saveFollowedTopics: () -> Unit +) { + item { + FlowRow( + mainAxisSpacing = 8.dp, + crossAxisSpacing = 8.dp, + modifier = Modifier.padding(horizontal = 40.dp) + ) { + uiState.selectedTopics.forEach { (topic, isSelected) -> + key(topic.id) { + // TODO: Add toggleable semantics + OutlinedButton( + onClick = { + onTopicCheckedChanged(topic.id, !isSelected) + }, + shape = RoundedCornerShape(50), + colors = if (isSelected) { + ButtonDefaults.buttonColors() + } else { + ButtonDefaults.outlinedButtonColors() + } + ) { + Text( + text = topic.name.uppercase(), + ) + } + } + } + } + } + + item { + Button( + onClick = saveFollowedTopics, + enabled = uiState.canSaveSelectedTopics, + modifier = Modifier + .padding(horizontal = 40.dp) + .fillMaxWidth() + ) { + Text(text = stringResource(R.string.done)) + } + } +} + +@Preview +@Composable +fun ForYouScreenLoading() { + ForYouScreen( + uiState = ForYouFeedUiState.Loading, + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) +} + +@Preview +@Composable +fun ForYouScreenTopicSelection() { + ForYouScreen( + uiState = ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to true, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) +} + +@Preview +@Composable +fun PopulatedFeed() { + ForYouScreen( + uiState = ForYouFeedUiState.PopulatedFeed.FeedWithoutTopicSelection( + feed = emptyList() + ), + onTopicCheckedChanged = { _, _ -> }, + saveFollowedTopics = {} + ) +} diff --git a/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModel.kt b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModel.kt new file mode 100644 index 000000000..d48362f7a --- /dev/null +++ b/app/src/main/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModel.kt @@ -0,0 +1,199 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.ui.foryou + +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.snapshotFlow +import androidx.compose.runtime.snapshots.Snapshot.Companion.withMutableSnapshot +import androidx.lifecycle.SavedStateHandle +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import com.google.samples.apps.nowinandroid.data.news.NewsRepository +import com.google.samples.apps.nowinandroid.data.news.NewsResource +import com.google.samples.apps.nowinandroid.data.news.Topic +import com.google.samples.apps.nowinandroid.data.news.TopicsRepository +import com.google.samples.apps.nowinandroid.ui.saveable +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject +import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.flatMapLatest +import kotlinx.coroutines.flow.flowOf +import kotlinx.coroutines.flow.map +import kotlinx.coroutines.flow.stateIn +import kotlinx.coroutines.launch + +@HiltViewModel +class ForYouViewModel @Inject constructor( + private val topicsRepository: TopicsRepository, + private val newsRepository: NewsRepository, + savedStateHandle: SavedStateHandle +) : ViewModel() { + + private val followedTopicsStateFlow = topicsRepository.getFollowedTopicIdsStream() + .map { followedTopics -> + if (followedTopics.isEmpty()) { + FollowedTopicsState.None + } else { + FollowedTopicsState.FollowedTopics( + topics = followedTopics + ) + } + } + .stateIn( + viewModelScope, + started = SharingStarted.WhileSubscribed(5_000), + initialValue = FollowedTopicsState.Unknown + ) + + /** + * The in-progress set of topics to be selected, persisted through process death with a + * [SavedStateHandle]. + */ + private var inProgressTopicSelection by savedStateHandle.saveable { + mutableStateOf>(emptySet()) + } + + val uiState: StateFlow = combine( + followedTopicsStateFlow, + topicsRepository.getTopicsStream(), + snapshotFlow { inProgressTopicSelection }, + ) { followedTopicsUserState, availableTopics, inProgressTopicSelection -> + when (followedTopicsUserState) { + // If we don't know the current selection state, just emit loading. + FollowedTopicsState.Unknown -> flowOf(ForYouFeedUiState.Loading) + // If the user has followed topics, use those followed topics to populate the feed + is FollowedTopicsState.FollowedTopics -> { + newsRepository.getNewsResourcesStream( + filterTopicIds = followedTopicsUserState.topics + ) + .map { feed -> + ForYouFeedUiState.PopulatedFeed.FeedWithoutTopicSelection( + feed = feed + ) + } + } + // If the user hasn't followed topics yet, show the topic selection, as well as a + // realtime populated feed based on those in-progress topic selections. + FollowedTopicsState.None -> { + newsRepository.getNewsResourcesStream( + filterTopicIds = inProgressTopicSelection + ) + .map { feed -> + ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = availableTopics.map { topic -> + topic to (topic.id in inProgressTopicSelection) + }, + feed = feed + ) + } + } + } + } + // Flatten the feed flows. + // As the selected topics and topic state changes, this will cancel the old feed monitoring + // and start the new one. + .flatMapLatest { it } + .stateIn( + scope = viewModelScope, + started = SharingStarted.Eagerly, + initialValue = ForYouFeedUiState.Loading + ) + + fun updateTopicSelection(topicId: Int, isChecked: Boolean) { + withMutableSnapshot { + inProgressTopicSelection = + // Update the in-progress selection based on whether the topic id was checked + if (isChecked) { + inProgressTopicSelection + topicId + } else { + inProgressTopicSelection - topicId + } + } + } + + fun saveFollowedTopics() { + if (inProgressTopicSelection.isEmpty()) return + + viewModelScope.launch { + topicsRepository.setFollowedTopicIds(inProgressTopicSelection) + } + } +} + +/** + * A sealed hierarchy for the user's current followed topics state. + */ +private sealed interface FollowedTopicsState { + + /** + * The current state is unknown (hasn't loaded yet) + */ + object Unknown : FollowedTopicsState + + /** + * The user hasn't followed any topics yet. + */ + object None : FollowedTopicsState + + /** + * The user has followed the given (non-empty) set of [topics]. + */ + data class FollowedTopics( + val topics: Set, + ) : FollowedTopicsState +} + +/** + * A sealed hierarchy describing the for you screen state. + */ +sealed interface ForYouFeedUiState { + + /** + * The screen is still loading. + */ + object Loading : ForYouFeedUiState + + /** + * Loaded with a populated [feed] of [NewsResource]s. + */ + sealed interface PopulatedFeed : ForYouFeedUiState { + + /** + * The list of news resources contained in this [PopulatedFeed]. + */ + val feed: List + + /** + * The feed, along with a list of topics that can be selected. + */ + data class FeedWithTopicSelection( + val selectedTopics: List>, + override val feed: List + ) : PopulatedFeed { + val canSaveSelectedTopics: Boolean = selectedTopics.any { it.second } + } + + /** + * Just the feed. + */ + data class FeedWithoutTopicSelection( + override val feed: List + ) : PopulatedFeed + } +} diff --git a/app/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto b/app/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto new file mode 100644 index 000000000..e776439c1 --- /dev/null +++ b/app/src/main/proto/com/google/samples/apps/nowinandroid/data/user_preferences.proto @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2022 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. + */ + +syntax = "proto3"; + +option java_package = "com.google.samples.apps.nowinandroid.data"; +option java_multiple_files = true; + +message UserPreferences { + repeated int32 followed_topic_ids = 1; +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 269c247b4..18d8565b2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,4 +19,6 @@ Episodes Saved Topics + Done + Loading for youโ€ฆ diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializerTest.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializerTest.kt new file mode 100644 index 000000000..45aafe036 --- /dev/null +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/data/UserPreferencesSerializerTest.kt @@ -0,0 +1,64 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.data + +import androidx.datastore.core.CorruptionException +import java.io.ByteArrayInputStream +import java.io.ByteArrayOutputStream +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Test + +class UserPreferencesSerializerTest { + private val userPreferencesSerializer = UserPreferencesSerializer() + + @Test + fun defaultUserPreferences_isEmpty() { + assertEquals( + userPreferences { + // Default value + }, + userPreferencesSerializer.defaultValue + ) + } + + @Test + fun writingAndReadingUserPreferences_outputsCorrectValue() = runTest { + val expectedUserPreferences = userPreferences { + followedTopicIds.add(0) + followedTopicIds.add(1) + } + + val outputStream = ByteArrayOutputStream() + + expectedUserPreferences.writeTo(outputStream) + + val inputStream = ByteArrayInputStream(outputStream.toByteArray()) + + val actualUserPreferences = userPreferencesSerializer.readFrom(inputStream) + + assertEquals( + expectedUserPreferences, + actualUserPreferences + ) + } + + @Test(expected = CorruptionException::class) + fun readingInvalidUserPreferences_throwsCorruptionException() = runTest { + userPreferencesSerializer.readFrom(ByteArrayInputStream(byteArrayOf(0))) + } +} diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepositoryTest.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepositoryTest.kt similarity index 60% rename from app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepositoryTest.kt rename to app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepositoryTest.kt index 824d89be9..e1ca56857 100644 --- a/app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsResourceRepositoryTest.kt +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/data/news/fake/FakeNewsRepositoryTest.kt @@ -16,28 +16,32 @@ package com.google.samples.apps.nowinandroid.data.news.fake +import com.google.samples.apps.nowinandroid.di.DefaultNiaDispatchers import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.test.TestCoroutineDispatcher +import kotlinx.coroutines.test.runTest +import kotlinx.serialization.json.Json import org.junit.Assert.assertEquals import org.junit.Before +import org.junit.Test -class FakeNewsResourceRepositoryTest { +class FakeNewsRepositoryTest { - private lateinit var subject: FakeNewsResourceRepository + private lateinit var subject: FakeNewsRepository @Before fun setup() { - subject = FakeNewsResourceRepository( - ioDispatcher = TestCoroutineDispatcher() + subject = FakeNewsRepository( + // TODO: Create test-specific NiaDispatchers + dispatchers = DefaultNiaDispatchers(), + networkJson = Json { ignoreUnknownKeys = true } ) } - @org.junit.Test - fun testDeserializationOfNewsResources() = runBlocking { + @Test + fun testDeserializationOfNewsResources() = runTest { assertEquals( FakeDataSource.sampleResource, - subject.monitor().first().first() + subject.getNewsResourcesStream().first().first() ) } } diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestDispatcherRule.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestDispatcherRule.kt new file mode 100644 index 000000000..f7baee782 --- /dev/null +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestDispatcherRule.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.testutil + +import kotlinx.coroutines.CoroutineDispatcher +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.test.StandardTestDispatcher +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.setMain +import org.junit.rules.TestRule +import org.junit.runner.Description +import org.junit.runners.model.Statement + +/** + * A [TestRule] that initializes the main dispatcher to [dispatcher], which defaults to a + * [StandardTestDispatcher]. + */ +class TestDispatcherRule( + private val dispatcher: CoroutineDispatcher = StandardTestDispatcher() +) : TestRule { + override fun apply(base: Statement, description: Description): Statement = + object : Statement() { + override fun evaluate() { + Dispatchers.setMain(dispatcher) + try { + base.evaluate() + } finally { + Dispatchers.resetMain() + } + } + } +} diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestNewsRepository.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestNewsRepository.kt new file mode 100644 index 000000000..e1908ecce --- /dev/null +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestNewsRepository.kt @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.testutil + +import com.google.samples.apps.nowinandroid.data.news.NewsRepository +import com.google.samples.apps.nowinandroid.data.news.NewsResource +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.map + +class TestNewsRepository : NewsRepository { + + /** + * The backing hot flow for the list of topics ids for testing. + */ + private val newsResourcesFlow: MutableSharedFlow> = + MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) + + override fun getNewsResourcesStream(): Flow> = newsResourcesFlow + + override fun getNewsResourcesStream( + filterTopicIds: Set + ): Flow> = + getNewsResourcesStream().map { newsResources -> + newsResources.filter { it.topics.intersect(filterTopicIds).isNotEmpty() } + } + + /** + * A test-only API to allow controlling the list of news resources from tests. + */ + fun sendNewsResources(newsResources: List) { + newsResourcesFlow.tryEmit(newsResources) + } +} diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestTopicsRepository.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestTopicsRepository.kt new file mode 100644 index 000000000..4150fe405 --- /dev/null +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/testutil/TestTopicsRepository.kt @@ -0,0 +1,57 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.testutil + +import com.google.samples.apps.nowinandroid.data.news.Topic +import com.google.samples.apps.nowinandroid.data.news.TopicsRepository +import kotlinx.coroutines.channels.BufferOverflow +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableSharedFlow + +class TestTopicsRepository : TopicsRepository { + /** + * The backing hot flow for the list of followed topic ids for testing. + */ + private val _followedTopicIds: MutableSharedFlow> = + MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) + + /** + * The backing hot flow for the list of topics ids for testing. + */ + private val topicsFlow: MutableSharedFlow> = + MutableSharedFlow(replay = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) + + override fun getTopicsStream(): Flow> = topicsFlow + + override suspend fun setFollowedTopicIds(followedTopicIds: Set) { + _followedTopicIds.tryEmit(followedTopicIds) + } + + override fun getFollowedTopicIdsStream(): Flow> = _followedTopicIds + + /** + * A test-only API to allow controlling the list of topics from tests. + */ + fun sendTopics(topics: List) { + topicsFlow.tryEmit(topics) + } + + /** + * A test-only API to allow querying the current followed topics. + */ + fun getCurrentFollowedTopics(): Set? = _followedTopicIds.replayCache.firstOrNull() +} diff --git a/app/src/test/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModelTest.kt b/app/src/test/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModelTest.kt new file mode 100644 index 000000000..2dc80c5b1 --- /dev/null +++ b/app/src/test/java/com/google/samples/apps/nowinandroid/ui/foryou/ForYouViewModelTest.kt @@ -0,0 +1,266 @@ +/* + * Copyright 2022 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 + * + * https://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 com.google.samples.apps.nowinandroid.ui.foryou + +import androidx.lifecycle.SavedStateHandle +import app.cash.turbine.test +import com.google.samples.apps.nowinandroid.data.news.Topic +import com.google.samples.apps.nowinandroid.testutil.TestDispatcherRule +import com.google.samples.apps.nowinandroid.testutil.TestNewsRepository +import com.google.samples.apps.nowinandroid.testutil.TestTopicsRepository +import kotlinx.coroutines.test.runTest +import org.junit.Assert.assertEquals +import org.junit.Before +import org.junit.Rule +import org.junit.Test + +class ForYouViewModelTest { + @get:Rule + val dispatcherRule = TestDispatcherRule() + + private val topicsRepository = TestTopicsRepository() + private val newsRepository = TestNewsRepository() + private lateinit var viewModel: ForYouViewModel + + @Before + fun setup() { + viewModel = ForYouViewModel( + topicsRepository = topicsRepository, + newsRepository = newsRepository, + savedStateHandle = SavedStateHandle() + ) + } + + @Test + fun stateIsInitiallyLoading() = runTest { + viewModel.uiState.test { + assertEquals(ForYouFeedUiState.Loading, awaitItem()) + cancel() + } + } + + @Test + fun stateIsLoadingWhenFollowedTopicsAreLoading() = runTest { + viewModel.uiState.test { + assertEquals(ForYouFeedUiState.Loading, awaitItem()) + topicsRepository.sendTopics(sampleTopics) + + cancel() + } + } + + @Test + fun stateIsLoadingWhenTopicsAreLoading() = runTest { + viewModel.uiState.test { + assertEquals(ForYouFeedUiState.Loading, awaitItem()) + topicsRepository.setFollowedTopicIds(emptySet()) + + cancel() + } + } + + @Test + fun stateIsLoadingWhenNewsResourcesAreLoading() = runTest { + viewModel.uiState.test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(emptySet()) + + cancel() + } + } + + @Test + fun stateIsTopicSelectionAfterLoadingEmptyFollowedTopics() = runTest { + viewModel.uiState + .test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(emptySet()) + newsRepository.sendNewsResources(emptyList()) + + assertEquals( + ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to false, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + awaitItem() + ) + cancel() + } + } + + @Test + fun stateIsWithoutTopicSelectionAfterLoadingFollowedTopics() = runTest { + viewModel.uiState + .test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(setOf(0, 1)) + newsRepository.sendNewsResources(emptyList()) + + assertEquals( + ForYouFeedUiState.PopulatedFeed.FeedWithoutTopicSelection( + feed = emptyList() + ), + awaitItem() + ) + cancel() + } + } + + @Test + fun topicSelectionUpdatesAfterSelectingTopic() = runTest { + viewModel.uiState + .test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(emptySet()) + newsRepository.sendNewsResources(emptyList()) + + awaitItem() + viewModel.updateTopicSelection(1, isChecked = true) + + assertEquals( + ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to true, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + awaitItem() + ) + cancel() + } + } + + @Test + fun topicSelectionUpdatesAfterUnselectingTopic() = runTest { + viewModel.uiState + .test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(emptySet()) + newsRepository.sendNewsResources(emptyList()) + + awaitItem() + viewModel.updateTopicSelection(1, isChecked = true) + + awaitItem() + viewModel.updateTopicSelection(1, isChecked = false) + + assertEquals( + ForYouFeedUiState.PopulatedFeed.FeedWithTopicSelection( + selectedTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ) to false, + Topic( + id = 1, + name = "UI", + description = "" + ) to false, + Topic( + id = 2, + name = "Tools", + description = "" + ) to false + ), + feed = emptyList() + ), + awaitItem() + ) + cancel() + } + } + + @Test + fun topicSelectionUpdatesAfterSavingTopics() = runTest { + viewModel.uiState + .test { + awaitItem() + topicsRepository.sendTopics(sampleTopics) + topicsRepository.setFollowedTopicIds(emptySet()) + newsRepository.sendNewsResources(emptyList()) + + awaitItem() + viewModel.updateTopicSelection(1, isChecked = true) + + awaitItem() + viewModel.saveFollowedTopics() + + assertEquals( + ForYouFeedUiState.PopulatedFeed.FeedWithoutTopicSelection( + feed = emptyList() + ), + awaitItem() + ) + assertEquals(setOf(1), topicsRepository.getCurrentFollowedTopics()) + cancel() + } + } +} + +private val sampleTopics = listOf( + Topic( + id = 0, + name = "Headlines", + description = "" + ), + Topic( + id = 1, + name = "UI", + description = "" + ), + Topic( + id = 2, + name = "Tools", + description = "" + ) +) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 02c977156..a85970c79 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,9 +5,11 @@ androidGradlePlugin = "7.0.3" androidxActivity = "1.4.0" androidxAppCompat = "1.3.0" androidxCompose = "1.1.0-beta04" -androidxComposeMaterial3 = "1.0.0-alpha01" +androidxComposeMaterial3 = "1.0.0-alpha03" androidxCore = "1.7.0" +androidxDataStore = "1.0.0" androidxEspresso = "3.3.0" +androidxHiltNavigationCompose = "1.0.0-rc01" androidxLifecycle = "2.4.0" androidxNavigation = "2.4.0-rc01" androidxTest = "1.4.0" @@ -16,16 +18,20 @@ hilt = "2.40.5" jacoco = "0.8.7" junit4 = "4.13" kotlin = "1.6.0" -kotlinxCoroutines = "1.5.2" -kotlinxCoroutinesTest = "1.5.2" +kotlinxCoroutines = "1.6.0" +kotlinxCoroutinesTest = "1.6.0" kotlinxDatetime = "0.3.1" kotlinxSerializationJson = "1.3.1" ktlint = "0.43.0" material3 = "1.5.0-alpha05" mockk = "1.12.1" +protobuf = "3.19.1" +protobufPlugin = "0.8.18" spotless = "6.0.0" +turbine = "0.7.0" [libraries] +accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" } accompanist-insets = { group = "com.google.accompanist", name = "accompanist-insets", version.ref = "accompanist" } android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" } android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } @@ -42,6 +48,8 @@ androidx-compose-ui-testManifest = { group = "androidx.compose.ui", name = "ui-t androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling", version.ref = "androidxCompose" } androidx-compose-ui-util = { group = "androidx.compose.ui", name = "ui-util", version.ref = "androidxCompose" } androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "androidxCore" } +androidx-dataStore = { group = "androidx.datastore", name = "datastore", version.ref = "androidxDataStore" } +androidx-hilt-navigation-compose = { group = "androidx.hilt", name = "hilt-navigation-compose", version.ref = "androidxHiltNavigationCompose" } androidx-lifecycle-viewModelCompose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "androidxLifecycle" } androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "androidxNavigation" } androidx-test-core = { group = "androidx.test", name = "core", version.ref = "androidxTest" } @@ -60,6 +68,10 @@ kotlinx-datetime = { group = "org.jetbrains.kotlinx", name = "kotlinx-datetime", kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" } material3 = { group = "com.google.android.material", name = "material", version.ref = "material3" } mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } +protobuf-protoc = { group = "com.google.protobuf", name = "protoc", version.ref = "protobuf" } +protobuf-kotlin-lite = { group = "com.google.protobuf", name = "protobuf-kotlin-lite", version.ref = "protobuf" } +turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } [plugins] spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } +protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }