Skip to content

Commit

Permalink
refactor: Use explicit API for core/model module
Browse files Browse the repository at this point in the history
Avoid unintentionally exposing declarations to the public API by using the `explicitAPI` mode.

Fixes DroidKaigi#1220
  • Loading branch information
sanao1006 committed Nov 13, 2023
1 parent 70064bf commit eb536af
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 41 deletions.
1 change: 1 addition & 0 deletions core/model/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ android.namespace = "io.github.droidkaigi.confsched2023.core.model"

@Suppress("UnusedPrivateProperty")
kotlin {
explicitApi()
sourceSets {
commonMain {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.github.droidkaigi.confsched2023.data.contributors

import kotlinx.coroutines.flow.Flow

interface StampRepository {
public interface StampRepository {

fun getStampEnabledStream(): Flow<Boolean>
public fun getStampEnabledStream(): Flow<Boolean>
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package io.github.droidkaigi.confsched2023.model

sealed class AboutItem {
data object Sponsors : AboutItem()
data object Contributors : AboutItem()
data object Staff : AboutItem()
data object CodeOfConduct : AboutItem()
data object License : AboutItem()
data object PrivacyPolicy : AboutItem()
data object YouTube : AboutItem()
data object X : AboutItem()
data object Medium : AboutItem()
public sealed class AboutItem {
public data object Sponsors : AboutItem()
public data object Contributors : AboutItem()
public data object Staff : AboutItem()
public data object CodeOfConduct : AboutItem()
public data object License : AboutItem()
public data object PrivacyPolicy : AboutItem()
public data object YouTube : AboutItem()
public data object X : AboutItem()
public data object Medium : AboutItem()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package io.github.droidkaigi.confsched2023.model
import kotlinx.collections.immutable.PersistentList
import kotlinx.coroutines.flow.Flow

interface ContributorsRepository {
public interface ContributorsRepository {

fun contributors(): Flow<PersistentList<Contributor>>
suspend fun refresh()
public fun contributors(): Flow<PersistentList<Contributor>>
public suspend fun refresh()
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public enum class DroidKaigi2023Day(
),
;

fun getDropDownText(language: String): String {
public fun getDropDownText(language: String): String {
val japanese = "ja"

val date = this.start.toLocalDateTime(TimeZone.currentSystemDefault())
Expand Down Expand Up @@ -85,7 +85,7 @@ public enum class DroidKaigi2023Day(
/**
* @return appropriate initial day for now
*/
fun initialSelectedDay(): DroidKaigi2023Day {
public fun initialSelectedDay(): DroidKaigi2023Day {
val reversedEntries = entries.sortedByDescending { it.day }
var selectedDay = reversedEntries.last()
for (entry in reversedEntries) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.droidkaigi.confsched2023.model

public enum class FloorLevel(
val floorName: String,
public val floorName: String,
) {
Basement("B1F"),
Ground("1F"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.github.droidkaigi.confsched2023.model
/**
* Please use [TimetableRoom] to get room information.
*/
enum class RoomType {
public enum class RoomType {
RoomA,
RoomB,
RoomC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package io.github.droidkaigi.confsched2023.model

import kotlinx.coroutines.flow.Flow

interface SessionsRepository {
fun getTimetableStream(): Flow<Timetable>
fun getTimetableItemWithBookmarkStream(id: TimetableItemId): Flow<Pair<TimetableItem, Boolean>>
suspend fun toggleBookmark(id: TimetableItemId)
public interface SessionsRepository {
public fun getTimetableStream(): Flow<Timetable>
public fun getTimetableItemWithBookmarkStream(id: TimetableItemId): Flow<Pair<TimetableItem, Boolean>>
public suspend fun toggleBookmark(id: TimetableItemId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import io.github.droidkaigi.confsched2023.model.FloorLevel.Basement
import io.github.droidkaigi.confsched2023.model.FloorLevel.Ground
import io.github.droidkaigi.confsched2023.model.SideEvent.Mark.Favorite
import io.github.droidkaigi.confsched2023.model.SideEvent.MarkColor.Pink
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf

public data class SideEvent(
Expand All @@ -16,18 +17,18 @@ public data class SideEvent(
val imageLink: String?,
) {

enum class Mark(val color: MarkColor) {
public enum class Mark(public val color: MarkColor) {
Favorite(Pink),
}

enum class MarkColor {
public enum class MarkColor {
Pink, Orange, Blue, Red, Purple
}

public companion object
}

val SideEvents = persistentListOf(
public val SideEvents: PersistentList<SideEvent> = persistentListOf(
SideEvent(
title = MultiLangText(
jaTitle = "アプリFiresideチャット(これは仮で後で消えます)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public data class Staff(
val profileUrl: String,
val iconUrl: String,
) {
companion object
public companion object
}

// create fakes
fun Staff.Companion.fakes(): PersistentList<Staff> {
public fun Staff.Companion.fakes(): PersistentList<Staff> {
return (1..20).map {
Staff(
id = it.toLong(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.collections.immutable.PersistentList
import kotlinx.coroutines.flow.Flow
import kotlin.coroutines.cancellation.CancellationException

interface StaffRepository {
public interface StaffRepository {

public fun staffs(): Flow<PersistentList<Staff>>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.github.droidkaigi.confsched2023.model

data class Stamp(
public data class Stamp(
val hasDrawableResId: Int,
val lottieRawId: Int,
val notHasDrawableResId: Int,
val hasStamp: Boolean = false,
val contentDescription: String,
) {
fun getDrawableResId() = if (hasStamp) hasDrawableResId else notHasDrawableResId
public fun getDrawableResId(): Int = if (hasStamp) hasDrawableResId else notHasDrawableResId
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public data class TimetableCategory(
public companion object
}

fun TimetableCategory.Companion.fakes(): List<TimetableCategory> {
public fun TimetableCategory.Companion.fakes(): List<TimetableCategory> {
return listOf(
TimetableCategory(
id = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public sealed class TimetableItem {
speakers.joinToString(", ") { it.name }
}

fun getSupportedLangString(isJapaneseLocale: Boolean): String {
public fun getSupportedLangString(isJapaneseLocale: Boolean): String {
val japanese = if (isJapaneseLocale) "日本語" else "Japanese"
val english = if (isJapaneseLocale) "英語" else "English"
val japaneseWithInterpretation =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ public data class TimetableLanguage(
val langOfSpeaker: String,
val isInterpretationTarget: Boolean,
) {
val labels = if (langOfSpeaker == Lang.MIXED.tagName) {
val labels: List<String> = if (langOfSpeaker == Lang.MIXED.tagName) {
listOf(Lang.MIXED.tagName)
} else if (isInterpretationTarget) {
listOf(Lang.ENGLISH.tagName, Lang.JAPANESE.tagName)
} else {
listOf(langOfSpeaker.take(2))
}

fun toLang() = if (isInterpretationTarget) {
public fun toLang(): Lang = if (isInterpretationTarget) {
Lang.MIXED
} else {
Lang.values().firstOrNull { it.tagName == langOfSpeaker.take(2) } ?: Lang.MIXED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public data class TimetableRoom(
val type: RoomType,
)

val TimetableRoom.nameAndFloor: String
public val TimetableRoom.nameAndFloor: String
get() {
val basementFloorString = MultiLangText(jaTitle = "地下1階", enTitle = "B1F")
val floor = when (type) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.github.droidkaigi.confsched2023.model

enum class TimetableSessionType(
val key: String,
val label: MultiLangText,
public enum class TimetableSessionType(
public val key: String,
public val label: MultiLangText,
) {
WELCOME_TALK(
key = "WELCOME_TALK",
Expand Down Expand Up @@ -34,8 +34,8 @@ enum class TimetableSessionType(
),
;

companion object {
fun ofOrNull(key: String): TimetableSessionType? {
public companion object {
public fun ofOrNull(key: String): TimetableSessionType? {
return values().firstOrNull {
it.key == key
}
Expand Down

0 comments on commit eb536af

Please sign in to comment.