Skip to content

Commit bcb4d7d

Browse files
committed
Replace global variables with PreviewParameterProvider
1 parent 20c29a6 commit bcb4d7d

File tree

23 files changed

+598
-411
lines changed

23 files changed

+598
-411
lines changed

core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/FollowableTopic.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.samples.apps.nowinandroid.core.domain.model
1818

1919
import com.google.samples.apps.nowinandroid.core.model.data.Topic
20-
import com.google.samples.apps.nowinandroid.core.model.data.previewTopics
2120

2221
/**
2322
* A [topic] with the additional information for whether or not it is followed.
@@ -26,18 +25,3 @@ data class FollowableTopic( // TODO consider changing to UserTopic and flattenin
2625
val topic: Topic,
2726
val isFollowed: Boolean,
2827
)
29-
30-
val previewFollowableTopics = listOf(
31-
FollowableTopic(
32-
previewTopics[0],
33-
isFollowed = false,
34-
),
35-
FollowableTopic(
36-
previewTopics[1],
37-
isFollowed = true,
38-
),
39-
FollowableTopic(
40-
previewTopics[2],
41-
isFollowed = false,
42-
),
43-
)

core/domain/src/main/java/com/google/samples/apps/nowinandroid/core/domain/model/UserNewsResource.kt

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ package com.google.samples.apps.nowinandroid.core.domain.model
1818

1919
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
2020
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType
21-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Codelab
22-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Unknown
23-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
2421
import com.google.samples.apps.nowinandroid.core.model.data.UserData
2522
import kotlinx.datetime.Instant
26-
import kotlinx.datetime.LocalDateTime
27-
import kotlinx.datetime.TimeZone
28-
import kotlinx.datetime.toInstant
29-
30-
/* ktlint-disable max-line-length */
3123

3224
/**
3325
* A [NewsResource] with additional user information such as whether the user is following the
@@ -65,65 +57,3 @@ data class UserNewsResource internal constructor(
6557
fun List<NewsResource>.mapToUserNewsResources(userData: UserData): List<UserNewsResource> {
6658
return map { UserNewsResource(it, userData) }
6759
}
68-
69-
val previewUserNewsResources = listOf(
70-
UserNewsResource(
71-
id = "1",
72-
title = "Android Basics with Compose",
73-
content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey",
74-
url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html",
75-
headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg",
76-
publishDate = LocalDateTime(
77-
year = 2022,
78-
monthNumber = 5,
79-
dayOfMonth = 4,
80-
hour = 23,
81-
minute = 0,
82-
second = 0,
83-
nanosecond = 0,
84-
).toInstant(TimeZone.UTC),
85-
type = Codelab,
86-
followableTopics = listOf(previewFollowableTopics[1]),
87-
isSaved = true,
88-
),
89-
UserNewsResource(
90-
id = "2",
91-
title = "Thanks for helping us reach 1M YouTube Subscribers",
92-
content = "Thank you everyone for following the Now in Android series and everything the " +
93-
"Android Developers YouTube channel has to offer. During the Android Developer " +
94-
"Summit, our YouTube channel reached 1 million subscribers! Here’s a small video to " +
95-
"thank you all.",
96-
url = "https://youtu.be/-fJ6poHQrjM",
97-
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
98-
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
99-
type = Video,
100-
followableTopics = listOf(previewFollowableTopics[0], previewFollowableTopics[1]),
101-
isSaved = false,
102-
),
103-
UserNewsResource(
104-
id = "3",
105-
title = "Transformations and customisations in the Paging Library",
106-
content = "A demonstration of different operations that can be performed " +
107-
"with Paging. Transformations like inserting separators, when to " +
108-
"create a new pager, and customisation options for consuming " +
109-
"PagingData.",
110-
url = "https://youtu.be/ZARz0pjm5YM",
111-
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
112-
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
113-
type = Video,
114-
followableTopics = listOf(previewFollowableTopics[2]),
115-
isSaved = false,
116-
),
117-
UserNewsResource(
118-
id = "4",
119-
title = "New Jetpack Release",
120-
content = "New Jetpack release includes updates to libraries such as CameraX, Benchmark, and" +
121-
"more!",
122-
url = "https://developer.android.com/jetpack/androidx/versions/all-channel",
123-
headerImageUrl = "",
124-
publishDate = Instant.parse("2022-10-01T00:00:00.000Z"),
125-
type = Unknown,
126-
followableTopics = listOf(previewFollowableTopics[2]),
127-
isSaved = true,
128-
),
129-
)

core/model/src/main/java/com/google/samples/apps/nowinandroid/core/model/data/NewsResource.kt

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,7 @@
1616

1717
package com.google.samples.apps.nowinandroid.core.model.data
1818

19-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Codelab
20-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Unknown
21-
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
2219
import kotlinx.datetime.Instant
23-
import kotlinx.datetime.LocalDateTime
24-
import kotlinx.datetime.TimeZone
25-
import kotlinx.datetime.toInstant
26-
27-
/* ktlint-disable max-line-length */
2820

2921
/**
3022
* External data layer representation of a fully populated NiA news resource
@@ -39,61 +31,3 @@ data class NewsResource(
3931
val type: NewsResourceType,
4032
val topics: List<Topic>,
4133
)
42-
43-
val previewNewsResources = listOf(
44-
NewsResource(
45-
id = "1",
46-
title = "Android Basics with Compose",
47-
content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey",
48-
url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html",
49-
headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg",
50-
publishDate = LocalDateTime(
51-
year = 2022,
52-
monthNumber = 5,
53-
dayOfMonth = 4,
54-
hour = 23,
55-
minute = 0,
56-
second = 0,
57-
nanosecond = 0,
58-
).toInstant(TimeZone.UTC),
59-
type = Codelab,
60-
topics = listOf(previewTopics[1]),
61-
),
62-
NewsResource(
63-
id = "2",
64-
title = "Thanks for helping us reach 1M YouTube Subscribers",
65-
content = "Thank you everyone for following the Now in Android series and everything the " +
66-
"Android Developers YouTube channel has to offer. During the Android Developer " +
67-
"Summit, our YouTube channel reached 1 million subscribers! Here’s a small video to " +
68-
"thank you all.",
69-
url = "https://youtu.be/-fJ6poHQrjM",
70-
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
71-
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
72-
type = Video,
73-
topics = listOf(previewTopics[0], previewTopics[1]),
74-
),
75-
NewsResource(
76-
id = "3",
77-
title = "Transformations and customisations in the Paging Library",
78-
content = "A demonstration of different operations that can be performed " +
79-
"with Paging. Transformations like inserting separators, when to " +
80-
"create a new pager, and customisation options for consuming " +
81-
"PagingData.",
82-
url = "https://youtu.be/ZARz0pjm5YM",
83-
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
84-
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
85-
type = Video,
86-
topics = listOf(previewTopics[2]),
87-
),
88-
NewsResource(
89-
id = "4",
90-
title = "New Jetpack Release",
91-
content = "New Jetpack release includes updates to libraries such as CameraX, Benchmark, and" +
92-
"more!",
93-
url = "https://developer.android.com/jetpack/androidx/versions/all-channel",
94-
headerImageUrl = "",
95-
publishDate = Instant.parse("2022-10-01T00:00:00.000Z"),
96-
type = Unknown,
97-
topics = listOf(previewTopics[2]),
98-
),
99-
)

core/model/src/main/java/com/google/samples/apps/nowinandroid/core/model/data/Topic.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package com.google.samples.apps.nowinandroid.core.model.data
1818

19-
/* ktlint-disable max-line-length */
20-
2119
/**
2220
* External data layer representation of a NiA Topic
2321
*/
@@ -29,30 +27,3 @@ data class Topic(
2927
val url: String,
3028
val imageUrl: String,
3129
)
32-
33-
val previewTopics = listOf(
34-
Topic(
35-
id = "2",
36-
name = "Headlines",
37-
shortDescription = "News we want everyone to see",
38-
longDescription = "Stay up to date with the latest events and announcements from Android!",
39-
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f",
40-
url = "",
41-
),
42-
Topic(
43-
id = "3",
44-
name = "UI",
45-
shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets",
46-
longDescription = "Learn how to optimize your app's user interface - everything that users can see and interact with. Stay up to date on tocpis such as Material Design, Navigation, Text, Paging, Compose, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets, and many more!",
47-
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_UI.svg?alt=media&token=0ee1842b-12e8-435f-87ba-a5bb02c47594",
48-
url = "",
49-
),
50-
Topic(
51-
id = "4",
52-
name = "Testing",
53-
shortDescription = "CI, Espresso, TestLab, etc",
54-
longDescription = "Testing is an integral part of the app development process. By running tests against your app consistently, you can verify your app's correctness, functional behavior, and usability before you release it publicly. Stay up to date on the latest tricks in CI, Espresso, and Firebase TestLab.",
55-
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Testing.svg?alt=media&token=a11533c4-7cc8-4b11-91a3-806158ebf428",
56-
url = "",
57-
),
58-
)

core/testing/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ android {
2626
dependencies {
2727
implementation(project(":core:common"))
2828
implementation(project(":core:data"))
29+
implementation(project(":core:domain"))
2930
implementation(project(":core:model"))
3031

32+
implementation(libs.kotlinx.datetime)
33+
3134
api(libs.junit4)
3235
api(libs.androidx.test.core)
3336
api(libs.kotlinx.coroutines.test)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2023 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.samples.apps.nowinandroid.core.testing.data
18+
19+
import com.google.samples.apps.nowinandroid.core.domain.model.FollowableTopic
20+
import com.google.samples.apps.nowinandroid.core.model.data.Topic
21+
22+
/* ktlint-disable max-line-length */
23+
val followableTopicTestData: List<FollowableTopic> = listOf(
24+
FollowableTopic(
25+
topic = Topic(
26+
id = "2",
27+
name = "Headlines",
28+
shortDescription = "News we want everyone to see",
29+
longDescription = "Stay up to date with the latest events and announcements from Android!",
30+
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Headlines.svg?alt=media&token=506faab0-617a-4668-9e63-4a2fb996603f",
31+
url = "",
32+
),
33+
isFollowed = false,
34+
),
35+
FollowableTopic(
36+
topic = Topic(
37+
id = "3",
38+
name = "UI",
39+
shortDescription = "Material Design, Navigation, Text, Paging, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets",
40+
longDescription = "Learn how to optimize your app's user interface - everything that users can see and interact with. Stay up to date on tocpis such as Material Design, Navigation, Text, Paging, Compose, Accessibility (a11y), Internationalization (i18n), Localization (l10n), Animations, Large Screens, Widgets, and many more!",
41+
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_UI.svg?alt=media&token=0ee1842b-12e8-435f-87ba-a5bb02c47594",
42+
url = "",
43+
),
44+
isFollowed = true,
45+
),
46+
FollowableTopic(
47+
topic = Topic(
48+
id = "4",
49+
name = "Testing",
50+
shortDescription = "CI, Espresso, TestLab, etc",
51+
longDescription = "Testing is an integral part of the app development process. By running tests against your app consistently, you can verify your app's correctness, functional behavior, and usability before you release it publicly. Stay up to date on the latest tricks in CI, Espresso, and Firebase TestLab.",
52+
imageUrl = "https://firebasestorage.googleapis.com/v0/b/now-in-android.appspot.com/o/img%2Fic_topic_Testing.svg?alt=media&token=a11533c4-7cc8-4b11-91a3-806158ebf428",
53+
url = "",
54+
),
55+
isFollowed = false,
56+
),
57+
)
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright 2022 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.samples.apps.nowinandroid.core.testing.data
18+
19+
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
20+
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Codelab
21+
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Unknown
22+
import com.google.samples.apps.nowinandroid.core.model.data.NewsResourceType.Video
23+
import kotlinx.datetime.Instant
24+
25+
/* ktlint-disable max-line-length */
26+
val newsResourcesTestData: List<NewsResource> = listOf(
27+
NewsResource(
28+
id = "1",
29+
title = "Android Basics with Compose",
30+
content = "We released the first two units of Android Basics with Compose, our first free course that teaches Android Development with Jetpack Compose to anyone; you do not need any prior programming experience other than basic computer literacy to get started. You’ll learn the fundamentals of programming in Kotlin while building Android apps using Jetpack Compose, Android’s modern toolkit that simplifies and accelerates native UI development. These two units are just the beginning; more will be coming soon. Check out Android Basics with Compose to get started on your Android development journey",
31+
url = "https://android-developers.googleblog.com/2022/05/new-android-basics-with-compose-course.html",
32+
headerImageUrl = "https://developer.android.com/images/hero-assets/android-basics-compose.svg",
33+
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
34+
type = Codelab,
35+
topics = listOf(topicsTestData[1]),
36+
),
37+
NewsResource(
38+
id = "2",
39+
title = "Thanks for helping us reach 1M YouTube Subscribers",
40+
content = "Thank you everyone for following the Now in Android series and everything the " +
41+
"Android Developers YouTube channel has to offer. During the Android Developer " +
42+
"Summit, our YouTube channel reached 1 million subscribers! Here’s a small video to " +
43+
"thank you all.",
44+
url = "https://youtu.be/-fJ6poHQrjM",
45+
headerImageUrl = "https://i.ytimg.com/vi/-fJ6poHQrjM/maxresdefault.jpg",
46+
publishDate = Instant.parse("2021-11-09T00:00:00.000Z"),
47+
type = Video,
48+
topics = listOf(topicsTestData[0], topicsTestData[1]),
49+
),
50+
NewsResource(
51+
id = "3",
52+
title = "Transformations and customisations in the Paging Library",
53+
content = "A demonstration of different operations that can be performed " +
54+
"with Paging. Transformations like inserting separators, when to " +
55+
"create a new pager, and customisation options for consuming " +
56+
"PagingData.",
57+
url = "https://youtu.be/ZARz0pjm5YM",
58+
headerImageUrl = "https://i.ytimg.com/vi/ZARz0pjm5YM/maxresdefault.jpg",
59+
publishDate = Instant.parse("2021-11-01T00:00:00.000Z"),
60+
type = Video,
61+
topics = listOf(topicsTestData[2]),
62+
),
63+
NewsResource(
64+
id = "4",
65+
title = "New Jetpack Release",
66+
content = "New Jetpack release includes updates to libraries such as CameraX, Benchmark, and" +
67+
"more!",
68+
url = "https://developer.android.com/jetpack/androidx/versions/all-channel",
69+
headerImageUrl = "",
70+
publishDate = Instant.parse("2022-10-01T00:00:00.000Z"),
71+
type = Unknown,
72+
topics = listOf(topicsTestData[2]),
73+
),
74+
)

0 commit comments

Comments
 (0)