Skip to content

Commit 022bdc0

Browse files
committed
feature: new maps renderer based on native PdfRenderer
chore: fix formatting for ktlint
1 parent 59233b5 commit 022bdc0

189 files changed

Lines changed: 3063 additions & 2431 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ insert_final_newline = true
1010
end_of_line = lf
1111

1212
[*.{kt,kts}]
13-
ktlint_function_naming_ignore_when_annotated_with=Composable
13+
# Jetpack Compose uses PascalCase for @Composable functions.
14+
ktlint_function_naming_ignore_when_annotated_with = Composable

app/src/main/java/com/advice/schedule/data/repositories/ContentRepository.kt

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,32 @@ class ContentRepository(
2121
private val notificationHelper: NotificationHelper,
2222
private val storage: Storage,
2323
) {
24-
val content: Flow<ConferenceContent> = contentDataSource
25-
.get()
26-
.onEach {
27-
updateBookmarkedContent(it)
28-
}
29-
.shareIn(
30-
scope = CoroutineScope(Dispatchers.IO),
31-
started = SharingStarted.Eagerly,
32-
replay = 1,
33-
)
24+
val content: Flow<ConferenceContent> =
25+
contentDataSource
26+
.get()
27+
.onEach {
28+
updateBookmarkedContent(it)
29+
}.shareIn(
30+
scope = CoroutineScope(Dispatchers.IO),
31+
started = SharingStarted.Eagerly,
32+
replay = 1,
33+
)
3434

3535
/**
3636
* On each sync update any reminders on Bookmarked Content that has been updated since last sync.
3737
*/
3838
private fun updateBookmarkedContent(conferenceContent: ConferenceContent) {
39-
val updatedBookmarks = conferenceContent.content
40-
.filter { it -> it.isBookmarked || it.sessions.any { it.isBookmarked } }
41-
.also {
42-
// Handling edge case for users that have bookmarked items before this update.
43-
it.forEach { content ->
44-
if (storage.getContentUpdatedTimestamp(content.id) == 0L) {
45-
storage.setContentUpdatedTimestamp(content.id, content.updated.toEpochMilli())
39+
val updatedBookmarks =
40+
conferenceContent.content
41+
.filter { it -> it.isBookmarked || it.sessions.any { it.isBookmarked } }
42+
.also {
43+
// Handling edge case for users that have bookmarked items before this update.
44+
it.forEach { content ->
45+
if (storage.getContentUpdatedTimestamp(content.id) == 0L) {
46+
storage.setContentUpdatedTimestamp(content.id, content.updated.toEpochMilli())
47+
}
4648
}
47-
}
48-
}
49-
.filter { storage.getContentUpdatedTimestamp(it.id) < it.updated.toEpochMilli() }
49+
}.filter { storage.getContentUpdatedTimestamp(it.id) < it.updated.toEpochMilli() }
5050
for (bookmark in updatedBookmarks) {
5151
val sessions = bookmark.sessions.filter { it.isBookmarked }
5252

@@ -67,16 +67,15 @@ class ContentRepository(
6767
contentDataSource.bookmark(content)
6868
}
6969

70-
suspend fun bookmark(content: Content, session: Session) {
70+
suspend fun bookmark(
71+
content: Content,
72+
session: Session,
73+
) {
7174
contentDataSource.bookmark(session)
7275
storage.setContentUpdatedTimestamp(content.id, content.updated.toEpochMilli())
7376
}
7477

75-
suspend fun isBookmarked(content: Content): Boolean {
76-
return contentDataSource.isBookmarked(content)
77-
}
78+
suspend fun isBookmarked(content: Content): Boolean = contentDataSource.isBookmarked(content)
7879

79-
suspend fun isBookmarked(session: Session): Boolean {
80-
return contentDataSource.isBookmarked(session)
81-
}
80+
suspend fun isBookmarked(session: Session): Boolean = contentDataSource.isBookmarked(session)
8281
}

app/src/main/java/com/advice/schedule/data/repositories/HomeRepository.kt

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,47 @@ class HomeRepository(
2222
private val storage: Storage,
2323
private val analyticsProvider: AnalyticsProvider,
2424
) {
25-
val contents = combine(
26-
userSession.getConference(),
27-
conferencesDataSource.get(),
28-
menuRepository.get(),
29-
newsRepository.get(),
30-
networkRepository.get(),
31-
) { conference, conferences, menu, news, wifi ->
32-
val latest = news.firstOrNull().takeUnless {
33-
it == null || storage.hasReadNews(conference.code, it.id)
34-
}
35-
val list = when (conferences) {
36-
is FlowResult.Failure -> return@combine HomeState.Error(conferences.error)
37-
FlowResult.Loading -> return@combine HomeState.Loading
38-
is FlowResult.Success -> conferences.value
39-
}
25+
val contents =
26+
combine(
27+
userSession.getConference(),
28+
conferencesDataSource.get(),
29+
menuRepository.get(),
30+
newsRepository.get(),
31+
networkRepository.get(),
32+
) { conference, conferences, menu, news, wifi ->
33+
val latest =
34+
news.firstOrNull().takeUnless {
35+
it == null || storage.hasReadNews(conference.code, it.id)
36+
}
37+
val list =
38+
when (conferences) {
39+
is FlowResult.Failure -> return@combine HomeState.Error(conferences.error)
40+
FlowResult.Loading -> return@combine HomeState.Loading
41+
is FlowResult.Success -> conferences.value
42+
}
4043

41-
HomeState.Loaded(
42-
conferences = list,
43-
conference = conference,
44-
menu = getMenu(menu, conference, wifi),
45-
news = latest,
46-
hasChicken = hasChicken(conference),
47-
)
48-
}
44+
HomeState.Loaded(
45+
conferences = list,
46+
conference = conference,
47+
menu = getMenu(menu, conference, wifi),
48+
news = latest,
49+
hasChicken = hasChicken(conference),
50+
)
51+
}
4952

50-
private fun hasChicken(conference: Conference): Boolean {
51-
return conference.code == "DEFCON33" && storage.easterEggs && analyticsProvider.isChickenEnabled()
52-
}
53+
private fun hasChicken(conference: Conference): Boolean =
54+
conference.code == "DEFCON33" && storage.easterEggs && analyticsProvider.isChickenEnabled()
5355

5456
private fun getMenu(
5557
menu: FlowResult<List<Menu>>,
5658
conference: Conference,
5759
wifi: List<WirelessNetwork>,
58-
): Menu {
59-
return when (menu) {
60+
): Menu =
61+
when (menu) {
6062
is FlowResult.Failure -> Menu.ERROR
6163
FlowResult.Loading -> Menu.LOADING
6264
is FlowResult.Success -> menu(menu, conference, wifi)
6365
}
64-
}
6566

6667
private fun menu(
6768
result: FlowResult.Success<List<Menu>>,
@@ -73,13 +74,14 @@ class HomeRepository(
7374
if (!analyticsProvider.isWifiEnabled() || wifi.isEmpty()) {
7475
return menu
7576
}
76-
val wifiItems = wifi.map { network ->
77-
MenuItem.Wifi(
78-
label = "WiFi",
79-
description = "Connect to the ${network.titleText}",
80-
id = network.id,
81-
)
82-
}
77+
val wifiItems =
78+
wifi.map { network ->
79+
MenuItem.Wifi(
80+
label = "WiFi",
81+
description = "Connect to the ${network.titleText}",
82+
id = network.id,
83+
)
84+
}
8385
return menu.copy(items = menu.items + wifiItems)
8486
}
8587

app/src/main/java/com/advice/schedule/data/repositories/OrganizationsRepository.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import kotlinx.coroutines.flow.shareIn
1111
class OrganizationsRepository(
1212
private val organizationsDataSource: OrganizationsDataSource,
1313
) {
14-
1514
val organizations: Flow<List<Organization>> =
1615
organizationsDataSource.get().shareIn(
1716
scope = CoroutineScope(Dispatchers.Default),

app/src/main/java/com/advice/schedule/data/repositories/ScheduleRepository.kt

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ import timber.log.Timber
1515

1616
sealed class ScheduleResult {
1717
data object Loading : ScheduleResult()
18-
data class Empty(val message: String) : ScheduleResult()
19-
data class Success(val events: List<Event>) : ScheduleResult()
18+
19+
data class Empty(
20+
val message: String,
21+
) : ScheduleResult()
22+
23+
data class Success(
24+
val events: List<Event>,
25+
) : ScheduleResult()
2026
}
2127

2228
class ScheduleRepository(
@@ -25,7 +31,6 @@ class ScheduleRepository(
2531
private val reminderManager: ReminderManager,
2632
private val bookmarksDataSource: BookmarkedElementDataSource,
2733
) {
28-
2934
fun getSchedule(filter: ScheduleFilter): Flow<ScheduleResult> {
3035
return combine(
3136
contentRepository.content,
@@ -36,11 +41,12 @@ class ScheduleRepository(
3641
return@combine ScheduleResult.Loading
3742
}
3843

39-
val events: List<Event> = content.content.flatMap { content ->
40-
content.sessions.map { session ->
41-
Event(content, session)
44+
val events: List<Event> =
45+
content.content.flatMap { content ->
46+
content.sessions.map { session ->
47+
Event(content, session)
48+
}
4249
}
43-
}
4450

4551
val sortedEvents = events.sortedBy { it.session.start }
4652
val selected = tags.filter { it.tags.any { it -> it.isSelected } }
@@ -49,33 +55,34 @@ class ScheduleRepository(
4955
.filterIsInstance<Bookmark.TagBookmark>()
5056
.any { it.id == Tag.bookmark.id.toString() && it.value }
5157

52-
val filteredEvents = when (filter) {
53-
ScheduleFilter.Default -> {
54-
filter(sortedEvents, selected, isBookmarkFilterSelected)
55-
}
58+
val filteredEvents =
59+
when (filter) {
60+
ScheduleFilter.Default -> {
61+
filter(sortedEvents, selected, isBookmarkFilterSelected)
62+
}
5663

57-
is ScheduleFilter.Location -> {
58-
sortedEvents.filter { it.session.location.id == filter.id }
59-
}
64+
is ScheduleFilter.Location -> {
65+
sortedEvents.filter { it.session.location.id == filter.id }
66+
}
6067

61-
is ScheduleFilter.Tag -> {
62-
if (filter.id == Tag.bookmark.id) {
63-
sortedEvents.filter { it.session.isBookmarked }
64-
} else {
65-
sortedEvents.filter { it.types.any { it -> it.id == filter.id } }
68+
is ScheduleFilter.Tag -> {
69+
if (filter.id == Tag.bookmark.id) {
70+
sortedEvents.filter { it.session.isBookmarked }
71+
} else {
72+
sortedEvents.filter { it.types.any { it -> it.id == filter.id } }
73+
}
6674
}
67-
}
6875

69-
is ScheduleFilter.Tags -> {
70-
val ids = filter.ids ?: emptyList()
71-
if (ids == listOf(Tag.bookmark.id)) {
72-
sortedEvents.filter { it.session.isBookmarked }
73-
} else {
74-
// Any content that have any of the selected tags
75-
sortedEvents.filter { it.types.any { it -> it.id in ids } }
76+
is ScheduleFilter.Tags -> {
77+
val ids = filter.ids ?: emptyList()
78+
if (ids == listOf(Tag.bookmark.id)) {
79+
sortedEvents.filter { it.session.isBookmarked }
80+
} else {
81+
// Any content that have any of the selected tags
82+
sortedEvents.filter { it.types.any { it -> it.id in ids } }
83+
}
7684
}
7785
}
78-
}
7986

8087
if (filteredEvents.isEmpty()) {
8188
val defaultFilter = filter is ScheduleFilter.Default && isBookmarkFilterSelected
@@ -84,25 +91,26 @@ class ScheduleRepository(
8491
(filter as? ScheduleFilter.Tag)?.id == Tag.bookmark.id ||
8592
(filter as? ScheduleFilter.Tags)?.ids == listOf(Tag.bookmark.id)
8693
val isDisplayingBookmarks = defaultFilter || onlyBookmarks || filterByBookmarks
87-
val message = when {
88-
// Bookmarks
89-
isDisplayingBookmarks -> {
90-
"Bookmark events to see them here"
94+
val message =
95+
when {
96+
// Bookmarks
97+
isDisplayingBookmarks -> {
98+
"Bookmark events to see them here"
99+
}
100+
101+
filter is ScheduleFilter.Location -> {
102+
"No events found in this location"
103+
}
104+
105+
filter is ScheduleFilter.Tag -> {
106+
"No events found for ${filter.label}"
107+
}
108+
109+
else -> {
110+
"No events found with selected tags"
111+
}
91112
}
92113

93-
filter is ScheduleFilter.Location -> {
94-
"No events found in this location"
95-
}
96-
97-
filter is ScheduleFilter.Tag -> {
98-
"No events found for ${filter.label}"
99-
}
100-
101-
else -> {
102-
"No events found with selected tags"
103-
}
104-
}
105-
106114
return@combine ScheduleResult.Empty(message)
107115
}
108116

@@ -122,9 +130,10 @@ class ScheduleRepository(
122130
return events
123131
}
124132

125-
val groups = filter.map {
126-
it.tags.filter { it -> it.isSelected }.map { it -> it.id }
127-
}
133+
val groups =
134+
filter.map {
135+
it.tags.filter { it -> it.isSelected }.map { it -> it.id }
136+
}
128137

129138
return events
130139
.filter {
@@ -151,7 +160,7 @@ class ScheduleRepository(
151160
*/
152161
private suspend fun bookmarkContent(
153162
content: Content,
154-
isBookmarked: Boolean
163+
isBookmarked: Boolean,
155164
) {
156165
// Bookmarking content that has sessions
157166
if (content.sessions.isNotEmpty()) {

0 commit comments

Comments
 (0)