From 023cc3d61a072beed9bbbe2c366a53af1255749a Mon Sep 17 00:00:00 2001 From: Giwon Lee <2giwon@gmail.com> Date: Tue, 27 Oct 2026 10:12:58 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8F=B0=20=EC=BA=98=EB=A6=B0=EB=8D=94=20?= =?UTF-8?q?=EC=9D=BD=EA=B8=B0=20+=20EventRepository=20(=EB=B3=B4=EC=9D=B4?= =?UTF-8?q?=EB=8A=94=20=EC=BA=98=EB=A6=B0=EB=8D=94=20=EC=A0=80=EC=9E=A5,?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD=20=EA=B0=90=EC=A7=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/calendar/build.gradle.kts | 5 +- core/calendar/src/main/AndroidManifest.xml | 6 + .../aide/core/calendar/CalendarDataSource.kt | 14 ++ .../ContentResolverCalendarDataSource.kt | 140 ++++++++++++++++++ .../aide/core/calendar/di/CalendarModule.kt | 15 ++ core/data/build.gradle.kts | 5 +- .../aide/core/data/DefaultEventRepository.kt | 35 +++++ .../giwon/aide/core/data/EventRepository.kt | 14 ++ .../aide/core/data/VisibleCalendarStore.kt | 26 ++++ .../com/giwon/aide/core/data/di/DataModule.kt | 30 ++++ .../core/data/DefaultEventRepositoryTest.kt | 138 +++++++++++++++++ .../aide/core/data/FakeCalendarDataSource.kt | 37 +++++ .../giwon/aide/core/model/CalendarSource.kt | 11 ++ .../kotlin/com/giwon/aide/core/model/Event.kt | 14 ++ gradle/libs.versions.toml | 3 + 15 files changed, 491 insertions(+), 2 deletions(-) create mode 100644 core/calendar/src/main/AndroidManifest.xml create mode 100644 core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/CalendarDataSource.kt create mode 100644 core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/ContentResolverCalendarDataSource.kt create mode 100644 core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/di/CalendarModule.kt create mode 100644 core/data/src/main/kotlin/com/giwon/aide/core/data/DefaultEventRepository.kt create mode 100644 core/data/src/main/kotlin/com/giwon/aide/core/data/EventRepository.kt create mode 100644 core/data/src/main/kotlin/com/giwon/aide/core/data/VisibleCalendarStore.kt create mode 100644 core/data/src/main/kotlin/com/giwon/aide/core/data/di/DataModule.kt create mode 100644 core/data/src/test/kotlin/com/giwon/aide/core/data/DefaultEventRepositoryTest.kt create mode 100644 core/data/src/test/kotlin/com/giwon/aide/core/data/FakeCalendarDataSource.kt create mode 100644 core/model/src/main/kotlin/com/giwon/aide/core/model/CalendarSource.kt create mode 100644 core/model/src/main/kotlin/com/giwon/aide/core/model/Event.kt diff --git a/core/calendar/build.gradle.kts b/core/calendar/build.gradle.kts index 5e9fdda..e13863f 100644 --- a/core/calendar/build.gradle.kts +++ b/core/calendar/build.gradle.kts @@ -1,5 +1,6 @@ plugins { alias(libs.plugins.aide.android.library) + alias(libs.plugins.aide.android.hilt) } android { @@ -7,5 +8,7 @@ android { } dependencies { - implementation(project(":core:model")) + api(project(":core:model")) + api(libs.kotlinx.coroutines.core) + implementation(libs.timber) } diff --git a/core/calendar/src/main/AndroidManifest.xml b/core/calendar/src/main/AndroidManifest.xml new file mode 100644 index 0000000..09afa36 --- /dev/null +++ b/core/calendar/src/main/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/CalendarDataSource.kt b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/CalendarDataSource.kt new file mode 100644 index 0000000..5049329 --- /dev/null +++ b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/CalendarDataSource.kt @@ -0,0 +1,14 @@ +package com.giwon.aide.core.calendar + +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import kotlinx.coroutines.flow.Flow +import java.time.Instant + +interface CalendarDataSource { + /** 변경 감지를 등록한 직후 한 번, 이후 폰 캘린더가 바뀔 때마다 내보낸다 */ + fun observeChanges(): Flow + suspend fun queryCalendars(): List + suspend fun queryInstances(from: Instant, to: Instant, calendarIds: Set): List + suspend fun findInstance(eventId: Long, start: Instant): Event? +} diff --git a/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/ContentResolverCalendarDataSource.kt b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/ContentResolverCalendarDataSource.kt new file mode 100644 index 0000000..33a59bf --- /dev/null +++ b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/ContentResolverCalendarDataSource.kt @@ -0,0 +1,140 @@ +package com.giwon.aide.core.calendar + +import android.Manifest +import android.content.Context +import android.content.pm.PackageManager +import android.database.ContentObserver +import android.database.Cursor +import android.net.Uri +import android.provider.CalendarContract +import android.provider.CalendarContract.Calendars +import android.provider.CalendarContract.Instances +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import dagger.hilt.android.qualifiers.ApplicationContext +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.flow.conflate +import kotlinx.coroutines.withContext +import timber.log.Timber +import java.time.Duration +import java.time.Instant +import javax.inject.Inject + +internal class ContentResolverCalendarDataSource @Inject constructor( + @param:ApplicationContext private val context: Context, +) : CalendarDataSource { + + private val contentResolver = context.contentResolver + + override fun observeChanges(): Flow = callbackFlow { + val observer = object : ContentObserver(null) { + override fun onChange(selfChange: Boolean) { + trySend(Unit) + } + } + if (hasReadPermission()) { + contentResolver.registerContentObserver(CalendarContract.CONTENT_URI, true, observer) + } + trySend(Unit) + awaitClose { contentResolver.unregisterContentObserver(observer) } + }.conflate() + + override suspend fun queryCalendars(): List = + query(Calendars.CONTENT_URI, CALENDAR_PROJECTION) { it.toCalendarSource() } + + override suspend fun queryInstances(from: Instant, to: Instant, calendarIds: Set): List { + if (calendarIds.isEmpty()) return emptyList() + return query( + uri = instancesUri(from, to), + projection = INSTANCE_PROJECTION, + selection = "${Instances.CALENDAR_ID} IN (${calendarIds.joinToString { "?" }})", + selectionArgs = calendarIds.map(Long::toString).toTypedArray(), + sortOrder = "${Instances.BEGIN} ASC", + ) { it.toEvent() } + } + + // 종일 일정의 BEGIN 은 UTC 자정이라 범위를 하루씩 넓혀 찾는다 + override suspend fun findInstance(eventId: Long, start: Instant): Event? = + query( + uri = instancesUri(start - ONE_DAY, start + ONE_DAY), + projection = INSTANCE_PROJECTION, + selection = "${Instances.EVENT_ID} = ? AND ${Instances.BEGIN} = ?", + selectionArgs = arrayOf(eventId.toString(), start.toEpochMilli().toString()), + ) { it.toEvent() }.firstOrNull() + + private suspend fun query( + uri: Uri, + projection: Array, + selection: String? = null, + selectionArgs: Array? = null, + sortOrder: String? = null, + mapper: (Cursor) -> T, + ): List = withContext(Dispatchers.IO) { + if (!hasReadPermission()) { + Timber.w("READ_CALENDAR 권한이 없어 빈 목록을 돌려준다: %s", uri) + return@withContext emptyList() + } + contentResolver.query(uri, projection, selection, selectionArgs, sortOrder)?.use { cursor -> + buildList { while (cursor.moveToNext()) add(mapper(cursor)) } + }.orEmpty() + } + + private fun hasReadPermission() = + context.checkSelfPermission(Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_GRANTED + + private fun instancesUri(from: Instant, to: Instant): Uri = + Instances.CONTENT_URI.buildUpon() + .appendPath(from.toEpochMilli().toString()) + .appendPath(to.toEpochMilli().toString()) + .build() + + // 칸 순서는 아래 PROJECTION 배열 순서와 같다 + private fun Cursor.toCalendarSource() = CalendarSource( + id = getLong(0), + displayName = getString(1).orEmpty(), + accountName = getString(2).orEmpty(), + accountType = getString(3).orEmpty(), + ownerAccount = getString(4).orEmpty(), + color = getInt(5), + writable = getInt(6) >= Calendars.CAL_ACCESS_CONTRIBUTOR, + ) + + private fun Cursor.toEvent() = Event( + id = getLong(0), + calendarId = getLong(1), + title = getString(2).orEmpty(), + start = Instant.ofEpochMilli(getLong(3)), + end = Instant.ofEpochMilli(getLong(4)), + allDay = getInt(5) == 1, + color = getInt(6), + calendarName = getString(7).orEmpty(), + ) + + private companion object { + val ONE_DAY: Duration = Duration.ofDays(1) + + val CALENDAR_PROJECTION = arrayOf( + Calendars._ID, + Calendars.CALENDAR_DISPLAY_NAME, + Calendars.ACCOUNT_NAME, + Calendars.ACCOUNT_TYPE, + Calendars.OWNER_ACCOUNT, + Calendars.CALENDAR_COLOR, + Calendars.CALENDAR_ACCESS_LEVEL, + ) + + val INSTANCE_PROJECTION = arrayOf( + Instances.EVENT_ID, + Instances.CALENDAR_ID, + Instances.TITLE, + Instances.BEGIN, + Instances.END, + Instances.ALL_DAY, + Instances.DISPLAY_COLOR, + Instances.CALENDAR_DISPLAY_NAME, + ) + } +} diff --git a/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/di/CalendarModule.kt b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/di/CalendarModule.kt new file mode 100644 index 0000000..9ac072b --- /dev/null +++ b/core/calendar/src/main/kotlin/com/giwon/aide/core/calendar/di/CalendarModule.kt @@ -0,0 +1,15 @@ +package com.giwon.aide.core.calendar.di + +import com.giwon.aide.core.calendar.CalendarDataSource +import com.giwon.aide.core.calendar.ContentResolverCalendarDataSource +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent + +@Module +@InstallIn(SingletonComponent::class) +internal interface CalendarModule { + @Binds + fun bindsCalendarDataSource(dataSource: ContentResolverCalendarDataSource): CalendarDataSource +} diff --git a/core/data/build.gradle.kts b/core/data/build.gradle.kts index 37bf8fb..a5a9eeb 100644 --- a/core/data/build.gradle.kts +++ b/core/data/build.gradle.kts @@ -1,5 +1,7 @@ plugins { alias(libs.plugins.aide.android.library) + alias(libs.plugins.aide.android.hilt) + alias(libs.plugins.aide.android.junit) } android { @@ -7,7 +9,8 @@ android { } dependencies { - implementation(project(":core:model")) + api(project(":core:model")) implementation(project(":core:database")) implementation(project(":core:calendar")) + implementation(libs.androidx.datastore.preferences) } diff --git a/core/data/src/main/kotlin/com/giwon/aide/core/data/DefaultEventRepository.kt b/core/data/src/main/kotlin/com/giwon/aide/core/data/DefaultEventRepository.kt new file mode 100644 index 0000000..633a868 --- /dev/null +++ b/core/data/src/main/kotlin/com/giwon/aide/core/data/DefaultEventRepository.kt @@ -0,0 +1,35 @@ +package com.giwon.aide.core.data + +import com.giwon.aide.core.calendar.CalendarDataSource +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.map +import java.time.Instant +import javax.inject.Inject + +internal class DefaultEventRepository @Inject constructor( + private val calendarDataSource: CalendarDataSource, + private val visibleCalendarStore: VisibleCalendarStore, +) : EventRepository { + + override fun observeCalendars(): Flow> = + calendarDataSource.observeChanges().map { calendarDataSource.queryCalendars() } + + override fun observeVisibleCalendarIds(): Flow> = + combine(observeCalendars(), visibleCalendarStore.calendarIds) { calendars, savedIds -> + val allIds = calendars.map { it.id }.toSet() + savedIds.orEmpty().intersect(allIds).ifEmpty { allIds } + } + + override suspend fun setVisibleCalendarIds(ids: Set) { + visibleCalendarStore.setCalendarIds(ids) + } + + override fun observeEvents(from: Instant, to: Instant): Flow> = + observeVisibleCalendarIds().map { calendarDataSource.queryInstances(from, to, it) } + + override suspend fun findEvent(eventId: Long, start: Instant): Event? = + calendarDataSource.findInstance(eventId, start) +} diff --git a/core/data/src/main/kotlin/com/giwon/aide/core/data/EventRepository.kt b/core/data/src/main/kotlin/com/giwon/aide/core/data/EventRepository.kt new file mode 100644 index 0000000..6bb91ef --- /dev/null +++ b/core/data/src/main/kotlin/com/giwon/aide/core/data/EventRepository.kt @@ -0,0 +1,14 @@ +package com.giwon.aide.core.data + +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import kotlinx.coroutines.flow.Flow +import java.time.Instant + +interface EventRepository { + fun observeCalendars(): Flow> + fun observeVisibleCalendarIds(): Flow> + suspend fun setVisibleCalendarIds(ids: Set) + fun observeEvents(from: Instant, to: Instant): Flow> + suspend fun findEvent(eventId: Long, start: Instant): Event? +} diff --git a/core/data/src/main/kotlin/com/giwon/aide/core/data/VisibleCalendarStore.kt b/core/data/src/main/kotlin/com/giwon/aide/core/data/VisibleCalendarStore.kt new file mode 100644 index 0000000..07592d4 --- /dev/null +++ b/core/data/src/main/kotlin/com/giwon/aide/core/data/VisibleCalendarStore.kt @@ -0,0 +1,26 @@ +package com.giwon.aide.core.data + +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringSetPreferencesKey +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import javax.inject.Inject + +internal class VisibleCalendarStore @Inject constructor( + private val dataStore: DataStore, +) { + /** 한 번도 고르지 않았으면 null */ + val calendarIds: Flow?> = dataStore.data.map { preferences -> + preferences[VISIBLE_CALENDAR_IDS]?.map(String::toLong)?.toSet() + } + + suspend fun setCalendarIds(ids: Set) { + dataStore.edit { it[VISIBLE_CALENDAR_IDS] = ids.map(Long::toString).toSet() } + } + + private companion object { + val VISIBLE_CALENDAR_IDS = stringSetPreferencesKey("visible_calendar_ids") + } +} diff --git a/core/data/src/main/kotlin/com/giwon/aide/core/data/di/DataModule.kt b/core/data/src/main/kotlin/com/giwon/aide/core/data/di/DataModule.kt new file mode 100644 index 0000000..cc0a624 --- /dev/null +++ b/core/data/src/main/kotlin/com/giwon/aide/core/data/di/DataModule.kt @@ -0,0 +1,30 @@ +package com.giwon.aide.core.data.di + +import android.content.Context +import androidx.datastore.core.DataStore +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import androidx.datastore.preferences.core.Preferences +import androidx.datastore.preferences.preferencesDataStoreFile +import com.giwon.aide.core.data.DefaultEventRepository +import com.giwon.aide.core.data.EventRepository +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 + +@Module +@InstallIn(SingletonComponent::class) +internal abstract class DataModule { + @Binds + abstract fun bindsEventRepository(repository: DefaultEventRepository): EventRepository + + companion object { + @Provides + @Singleton + fun providesPreferencesDataStore(@ApplicationContext context: Context): DataStore = + PreferenceDataStoreFactory.create { context.preferencesDataStoreFile("settings") } + } +} diff --git a/core/data/src/test/kotlin/com/giwon/aide/core/data/DefaultEventRepositoryTest.kt b/core/data/src/test/kotlin/com/giwon/aide/core/data/DefaultEventRepositoryTest.kt new file mode 100644 index 0000000..2ef675d --- /dev/null +++ b/core/data/src/test/kotlin/com/giwon/aide/core/data/DefaultEventRepositoryTest.kt @@ -0,0 +1,138 @@ +package com.giwon.aide.core.data + +import androidx.datastore.preferences.core.PreferenceDataStoreFactory +import app.cash.turbine.test +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.test.TestScope +import kotlinx.coroutines.test.runTest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir +import java.io.File +import java.time.Duration +import java.time.Instant + +class DefaultEventRepositoryTest { + + @TempDir + lateinit var tempDir: File + + private val dataSource = FakeCalendarDataSource() + + private val from = Instant.parse("2026-10-01T00:00:00Z") + private val to = Instant.parse("2026-11-01T00:00:00Z") + + private fun TestScope.repository() = DefaultEventRepository( + calendarDataSource = dataSource, + visibleCalendarStore = VisibleCalendarStore( + PreferenceDataStoreFactory.create(scope = backgroundScope) { + File(tempDir, "test.preferences_pb") + }, + ), + ) + + @Test + fun `보이는 캘린더를 고른 적이 없으면 모든 캘린더가 보인다`() = runTest { + dataSource.calendars = listOf(calendar(1), calendar(2)) + + assertThat(repository().observeVisibleCalendarIds().first()).containsExactlyInAnyOrder(1L, 2L) + } + + @Test + fun `A 캘린더만 보이게 저장하면 A 의 일정만 나온다`() = runTest { + dataSource.calendars = listOf(calendar(1), calendar(2)) + dataSource.events = listOf(event(id = 10, calendarId = 1), event(id = 20, calendarId = 2)) + val repository = repository() + + repository.setVisibleCalendarIds(setOf(1L)) + + assertThat(repository.observeEvents(from, to).first()).extracting { it.id }.containsExactly(10L) + } + + @Test + fun `폰 캘린더가 바뀌었다는 신호가 오면 일정을 다시 읽어 내보낸다`() = runTest { + dataSource.calendars = listOf(calendar(1)) + dataSource.events = listOf(event(id = 10, calendarId = 1)) + + repository().observeEvents(from, to).test { + assertThat(awaitItem()).extracting { it.id }.containsExactly(10L) + + dataSource.events = listOf(event(id = 10, calendarId = 1), event(id = 11, calendarId = 1)) + dataSource.notifyChange() + + assertThat(awaitItem()).extracting { it.id }.containsExactly(10L, 11L) + } + } + + @Test + fun `변경 감지를 등록한 뒤에 첫 목록을 읽는다`() = runTest { + dataSource.calendars = listOf(calendar(1)) + + repository().observeCalendars().first() + + assertThat(dataSource.queriedBeforeObserving).isFalse() + } + + @Test + fun `반복 일정의 두 회차는 id 가 같고 start 가 다른 두 건으로 나온다`() = runTest { + val firstStart = Instant.parse("2026-10-05T01:00:00Z") + val secondStart = Instant.parse("2026-10-12T01:00:00Z") + dataSource.calendars = listOf(calendar(1)) + dataSource.events = listOf( + event(id = 10, calendarId = 1, start = firstStart), + event(id = 10, calendarId = 1, start = secondStart), + ) + + val events = repository().observeEvents(from, to).first() + + assertThat(events).extracting { it.id }.containsExactly(10L, 10L) + assertThat(events).extracting { it.start }.containsExactly(firstStart, secondStart) + } + + @Test + fun `저장한 캘린더 중 사라진 것은 무시하고 남은 것만 보인다`() = runTest { + dataSource.calendars = listOf(calendar(1), calendar(2)) + val repository = repository() + + repository.setVisibleCalendarIds(setOf(1L, 3L)) + + assertThat(repository.observeVisibleCalendarIds().first()).containsExactly(1L) + } + + @Test + fun `저장한 캘린더가 전부 사라지면 모든 캘린더로 되돌린다`() = runTest { + dataSource.calendars = listOf(calendar(1), calendar(2)) + val repository = repository() + + repository.setVisibleCalendarIds(setOf(3L)) + + assertThat(repository.observeVisibleCalendarIds().first()).containsExactlyInAnyOrder(1L, 2L) + } + + private fun calendar(id: Long) = CalendarSource( + id = id, + displayName = "캘린더 $id", + accountName = "me@example.com", + accountType = "com.google", + ownerAccount = "me@example.com", + color = 0, + writable = true, + ) + + private fun event( + id: Long, + calendarId: Long, + start: Instant = Instant.parse("2026-10-10T01:00:00Z"), + ) = Event( + id = id, + calendarId = calendarId, + title = "일정 $id", + start = start, + end = start + Duration.ofHours(1), + allDay = false, + color = 0, + calendarName = "캘린더 $calendarId", + ) +} diff --git a/core/data/src/test/kotlin/com/giwon/aide/core/data/FakeCalendarDataSource.kt b/core/data/src/test/kotlin/com/giwon/aide/core/data/FakeCalendarDataSource.kt new file mode 100644 index 0000000..ff162d9 --- /dev/null +++ b/core/data/src/test/kotlin/com/giwon/aide/core/data/FakeCalendarDataSource.kt @@ -0,0 +1,37 @@ +package com.giwon.aide.core.data + +import com.giwon.aide.core.calendar.CalendarDataSource +import com.giwon.aide.core.model.CalendarSource +import com.giwon.aide.core.model.Event +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.onSubscription +import java.time.Instant + +class FakeCalendarDataSource : CalendarDataSource { + var calendars: List = emptyList() + var events: List = emptyList() + var queriedBeforeObserving = false + private set + + private var observing = false + private val changes = MutableSharedFlow() + + suspend fun notifyChange() = changes.emit(Unit) + + override fun observeChanges(): Flow = changes.onSubscription { + observing = true + emit(Unit) + } + + override suspend fun queryCalendars(): List { + if (!observing) queriedBeforeObserving = true + return calendars + } + + override suspend fun queryInstances(from: Instant, to: Instant, calendarIds: Set): List = + events.filter { it.calendarId in calendarIds && it.start < to && it.end > from } + + override suspend fun findInstance(eventId: Long, start: Instant): Event? = + events.find { it.id == eventId && it.start == start } +} diff --git a/core/model/src/main/kotlin/com/giwon/aide/core/model/CalendarSource.kt b/core/model/src/main/kotlin/com/giwon/aide/core/model/CalendarSource.kt new file mode 100644 index 0000000..6f31f30 --- /dev/null +++ b/core/model/src/main/kotlin/com/giwon/aide/core/model/CalendarSource.kt @@ -0,0 +1,11 @@ +package com.giwon.aide.core.model + +data class CalendarSource( + val id: Long, + val displayName: String, + val accountName: String, + val accountType: String, + val ownerAccount: String, + val color: Int, + val writable: Boolean, +) diff --git a/core/model/src/main/kotlin/com/giwon/aide/core/model/Event.kt b/core/model/src/main/kotlin/com/giwon/aide/core/model/Event.kt new file mode 100644 index 0000000..1710ee3 --- /dev/null +++ b/core/model/src/main/kotlin/com/giwon/aide/core/model/Event.kt @@ -0,0 +1,14 @@ +package com.giwon.aide.core.model + +import java.time.Instant + +data class Event( + val id: Long, + val calendarId: Long, + val title: String, + val start: Instant, + val end: Instant, + val allDay: Boolean, + val color: Int, + val calendarName: String, +) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e9b5274..badad0e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,6 +19,7 @@ timber = "5.0.1" leakcanary = "2.14" composeBom = "2026.02.01" konsist = "0.18.1" +datastore = "1.3.0" [libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } @@ -50,7 +51,9 @@ junit-jupiter-launcher = { group = "org.junit.platform", name = "junit-platform- mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" } turbine = { group = "app.cash.turbine", name = "turbine", version.ref = "turbine" } assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" } +kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" } kotlinx-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" } +androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastore" } konsist = { group = "com.lemonappdev", name = "konsist", version.ref = "konsist" } androidx-navigation3-runtime = { group = "androidx.navigation3", name = "navigation3-runtime", version.ref = "navigation3" } androidx-navigation3-ui = { group = "androidx.navigation3", name = "navigation3-ui", version.ref = "navigation3" }