-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/Team-Shaka/Briefing-Android
into feat/#4-feature-module
- Loading branch information
Showing
40 changed files
with
833 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
build-logic/convention/src/main/kotlin/store/newsbriefing/app/buildlogic/extension/Secret.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package store.newsbriefing.app.buildlogic.extension | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import com.google.android.libraries.mapsplatform.secrets_gradle_plugin.SecretsPluginExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
internal fun Project.configureSecret() { | ||
extensions.configure<SecretsPluginExtension> { | ||
defaultPropertiesFileName = "secrets.properties" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
core/common/src/main/java/store/newsbriefing/app/core/common/DateTimeUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package store.newsbriefing.app.core.common | ||
|
||
import java.time.Instant | ||
import java.time.ZoneId | ||
import java.time.ZonedDateTime | ||
|
||
|
||
fun String.toZoneDateTime(): ZonedDateTime { | ||
val instant = Instant.parse(this) | ||
return instant.atZone(ZoneId.systemDefault()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
plugins { | ||
alias(libs.plugins.briefing.android.library) | ||
alias(libs.plugins.briefing.android.hilt) | ||
} | ||
|
||
android { | ||
namespace = "store.newsbriefing.app.core.data" | ||
} | ||
|
||
dependencies { | ||
api(projects.core.model) | ||
api(projects.core.network) | ||
api(projects.core.common) | ||
|
||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0") | ||
} |
18 changes: 18 additions & 0 deletions
18
core/data/src/main/java/store/newsbriefing/app/core/data/repository/BriefingRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import store.newsbriefing.app.core.model.BriefingArticle | ||
import store.newsbriefing.app.core.model.BriefingArticleCategory | ||
import store.newsbriefing.app.core.model.BriefingArticleSummary | ||
import store.newsbriefing.app.core.model.TimeOfDay | ||
import java.time.LocalDate | ||
|
||
interface BriefingRepository { | ||
suspend fun getBriefingArticleSummaries( | ||
briefingArticleCategory: BriefingArticleCategory, | ||
dateLocalDate: LocalDate?, | ||
timeOfDay: TimeOfDay? | ||
): Flow<List<BriefingArticleSummary>> | ||
|
||
suspend fun getBriefingArticle(articleId: Long): Flow<BriefingArticle> | ||
} |
36 changes: 36 additions & 0 deletions
36
...ta/src/main/java/store/newsbriefing/app/core/data/repository/DefaultBriefingRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import store.newsbriefing.app.core.model.BriefingArticle | ||
import store.newsbriefing.app.core.model.BriefingArticleCategory | ||
import store.newsbriefing.app.core.model.BriefingArticleSummary | ||
import store.newsbriefing.app.core.model.TimeOfDay | ||
import store.newsbriefing.app.core.network.datasource.BriefingNetworkDataSource | ||
import store.newsbriefing.app.core.network.model.asExternalModel | ||
import java.time.LocalDate | ||
|
||
internal class DefaultBriefingRepository( | ||
private val briefingNetworkDataSource: BriefingNetworkDataSource | ||
) : BriefingRepository { | ||
override suspend fun getBriefingArticleSummaries( | ||
briefingArticleCategory: BriefingArticleCategory, | ||
dateLocalDate: LocalDate?, | ||
timeOfDay: TimeOfDay? | ||
): Flow<List<BriefingArticleSummary>> = flow { | ||
val summaries = briefingNetworkDataSource.getBriefingArticleSummaries( | ||
briefingArticleCategory, | ||
dateLocalDate, | ||
timeOfDay | ||
) | ||
emit(summaries.map { | ||
it.asExternalModel() | ||
}) | ||
} | ||
|
||
override suspend fun getBriefingArticle(articleId: Long): Flow<BriefingArticle> { | ||
return flow { | ||
emit(briefingNetworkDataSource.getBriefingArticle(articleId).asExternalModel()) | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...data/src/main/java/store/newsbriefing/app/core/data/repository/DefaultMemberRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import store.newsbriefing.app.core.model.MemberDeleteResult | ||
import store.newsbriefing.app.core.model.MemberToken | ||
import store.newsbriefing.app.core.network.datasource.MemberNetworkDataSource | ||
import store.newsbriefing.app.core.network.model.asExternalModel | ||
|
||
internal class DefaultMemberRepository(val memberNetworkDataSource: MemberNetworkDataSource) : | ||
MemberRepository { | ||
override suspend fun deleteMember(memberId: Long): Flow<MemberDeleteResult> = flow { | ||
emit(memberNetworkDataSource.deleteMember(memberId).asExternalModel()) | ||
} | ||
|
||
override suspend fun getTokenWithSocialProvider( | ||
provider: String, | ||
identityToken: String | ||
): Flow<MemberToken> = flow { | ||
emit( | ||
memberNetworkDataSource.getTokenWithSocialProvider(provider, identityToken) | ||
.asExternalModel() | ||
) | ||
} | ||
|
||
override suspend fun getRefreshedAccessToken(refreshToken: String): Flow<MemberToken> = flow { | ||
emit(memberNetworkDataSource.getRefreshedAccessToken(refreshToken).asExternalModel()) | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
.../data/src/main/java/store/newsbriefing/app/core/data/repository/DefaultScrapRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import store.newsbriefing.app.core.model.Scrap | ||
import store.newsbriefing.app.core.model.ScrapCreateResult | ||
import store.newsbriefing.app.core.model.ScrapDeleteResult | ||
import store.newsbriefing.app.core.network.datasource.ScrapNetworkDataSource | ||
import store.newsbriefing.app.core.network.model.asExternalModel | ||
|
||
internal class DefaultScrapRepository(private val scrapNetworkDataSource: ScrapNetworkDataSource) : ScrapRepository { | ||
override fun getScrap(memberId: Long): Flow<List<Scrap>> = flow { | ||
val scraps = scrapNetworkDataSource.getScrap(memberId).map { it.asExternalModel() } | ||
emit(scraps) | ||
} | ||
|
||
override fun setScrap(memberId: Long, articleId: Long): Flow<ScrapCreateResult> = flow { | ||
val result = scrapNetworkDataSource.setScrap(memberId, articleId).asExternalModel() | ||
emit(result) | ||
} | ||
|
||
override fun unScrap(memberId: Long, articleId: Long): Flow<ScrapDeleteResult> = flow { | ||
val result = scrapNetworkDataSource.unScrap(memberId, articleId).asExternalModel() | ||
emit(result) | ||
} | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
core/data/src/main/java/store/newsbriefing/app/core/data/repository/MemberRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import store.newsbriefing.app.core.model.MemberDeleteResult | ||
import store.newsbriefing.app.core.model.MemberToken | ||
|
||
interface MemberRepository { | ||
|
||
suspend fun deleteMember(memberId: Long): Flow<MemberDeleteResult> | ||
suspend fun getTokenWithSocialProvider(provider: String, identityToken: String): Flow<MemberToken> | ||
suspend fun getRefreshedAccessToken(refreshToken: String): Flow<MemberToken> | ||
} |
12 changes: 12 additions & 0 deletions
12
core/data/src/main/java/store/newsbriefing/app/core/data/repository/ScrapRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package store.newsbriefing.app.core.data.repository | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
import store.newsbriefing.app.core.model.Scrap | ||
import store.newsbriefing.app.core.model.ScrapCreateResult | ||
import store.newsbriefing.app.core.model.ScrapDeleteResult | ||
|
||
interface ScrapRepository { | ||
fun getScrap(memberId: Long): Flow<List<Scrap>> | ||
fun setScrap(memberId: Long, articleId: Long): Flow<ScrapCreateResult> | ||
fun unScrap(memberId: Long, articleId: Long): Flow<ScrapDeleteResult> | ||
} |
31 changes: 31 additions & 0 deletions
31
core/data/src/main/java/store/newsbriefing/app/core/data/repository/di/DataModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package store.newsbriefing.app.core.data.repository.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import store.newsbriefing.app.core.data.repository.BriefingRepository | ||
import store.newsbriefing.app.core.data.repository.DefaultBriefingRepository | ||
import store.newsbriefing.app.core.data.repository.DefaultMemberRepository | ||
import store.newsbriefing.app.core.data.repository.DefaultScrapRepository | ||
import store.newsbriefing.app.core.data.repository.MemberRepository | ||
import store.newsbriefing.app.core.data.repository.ScrapRepository | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
abstract class DataModule { | ||
@Binds | ||
internal abstract fun bindBriefingRepository( | ||
repository: DefaultBriefingRepository | ||
): BriefingRepository | ||
|
||
@Binds | ||
internal abstract fun bindMemberRepository( | ||
repository: DefaultMemberRepository | ||
): MemberRepository | ||
|
||
@Binds | ||
internal abstract fun bindScrapRepository( | ||
repository: DefaultScrapRepository | ||
): ScrapRepository | ||
} |
20 changes: 20 additions & 0 deletions
20
core/model/src/main/java/store/newsbriefing/app/core/model/BriefingArticle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package store.newsbriefing.app.core.model | ||
|
||
import java.time.ZonedDateTime | ||
|
||
data class BriefingArticle( | ||
val id: Long, | ||
val ranks: Int, | ||
val title: String, | ||
val subtitle: String, | ||
val content: String, | ||
val date: ZonedDateTime, | ||
val articles: List<BriefingArticleRelated>, | ||
val isScrap: Boolean, | ||
val isBriefingOpen: Boolean, | ||
val isWarning: Boolean, | ||
val scrapCount: Int, | ||
val gptModel: String, | ||
val timeOfDay: String, | ||
val type: String | ||
) |
15 changes: 15 additions & 0 deletions
15
core/model/src/main/java/store/newsbriefing/app/core/model/BriefingArticleCategory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package store.newsbriefing.app.core.model | ||
enum class BriefingArticleCategory(val typeId: String) { | ||
KOREA("KOREA"), | ||
GLOBAL("GLOBAL"), | ||
SOCIAL("SOCIAL"), | ||
SCIENCE("SCIENCE"), | ||
ECONOMY("ECONOMY"); | ||
|
||
companion object { | ||
fun fromTypeName(typeName: String): BriefingArticleCategory { | ||
return values().firstOrNull { it.typeId.equals(typeName, ignoreCase = true) } | ||
?: throw IllegalArgumentException("Invalid typeName for ArticleType: $typeName") | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
core/model/src/main/java/store/newsbriefing/app/core/model/BriefingArticleRelated.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package store.newsbriefing.app.core.model | ||
|
||
data class BriefingArticleRelated( | ||
val id: Int, | ||
val press: String, | ||
val title: String, | ||
val url: String | ||
) |
9 changes: 9 additions & 0 deletions
9
core/model/src/main/java/store/newsbriefing/app/core/model/BriefingArticleSummary.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package store.newsbriefing.app.core.model | ||
|
||
data class BriefingArticleSummary( | ||
val id: Int, | ||
val ranks: Int, | ||
val title: String, | ||
val subtitle: String, | ||
val scrapCount: Int | ||
) |
7 changes: 7 additions & 0 deletions
7
core/model/src/main/java/store/newsbriefing/app/core/model/MemberDeleteResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package store.newsbriefing.app.core.model | ||
|
||
import java.time.ZonedDateTime | ||
|
||
data class MemberDeleteResult( | ||
val quitAt: ZonedDateTime | ||
) |
7 changes: 7 additions & 0 deletions
7
core/model/src/main/java/store/newsbriefing/app/core/model/MemberToken.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package store.newsbriefing.app.core.model | ||
|
||
data class MemberToken( | ||
val memberId: Long, | ||
val accessToken: String, | ||
val refreshToken: String | ||
) |
Oops, something went wrong.