Skip to content

Commit 0bfe3aa

Browse files
authored
Merge pull request #236 from SWM-KAWAI-MANS/develop
Release/v1.3.0
2 parents 3acd13e + ee71b64 commit 0bfe3aa

File tree

86 files changed

+1846
-327
lines changed

Some content is hidden

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

86 files changed

+1846
-327
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import java.io.File
22
import java.io.FileInputStream
3-
import java.util.*
3+
import java.util.Properties
44

55
plugins {
66
id("nohjunh.android.application")
77
id("nohjunh.android.application.compose")
8+
id("nohjunh.android.hilt")
89
id("com.google.gms.google-services")
910
id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
10-
id("nohjunh.android.hilt")
1111
}
1212

1313
val keystoreProperties = Properties()
@@ -79,21 +79,10 @@ android {
7979
)
8080
}
8181
}
82-
83-
compileOptions {
84-
sourceCompatibility = JavaVersion.VERSION_17
85-
targetCompatibility = JavaVersion.VERSION_17
86-
}
87-
kotlinOptions {
88-
jvmTarget = JavaVersion.VERSION_17.toString()
89-
}
9082
buildFeatures {
9183
compose = true
9284
buildConfig = true
9385
}
94-
composeOptions {
95-
kotlinCompilerExtensionVersion = Configurations.COMPOSE
96-
}
9786
kapt {
9887
correctErrorTypes = true
9988
}

app/src/main/java/online/partyrun/partyrunapplication/navigation/MainNavHost.kt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ fun SetUpMainNavGraph(
9696
)
9797

9898
myPageRoute(
99-
onSignOut = onSignOut,
10099
navigateToSettings = {
101100
navController.navigate(MainNavRoutes.Settings.route)
102101
},
@@ -110,6 +109,20 @@ fun SetUpMainNavGraph(
110109
navigateToProfile = {
111110
navController.navigate(MainNavRoutes.Profile.route)
112111
},
112+
navigateToSingleResult = { isFromMyPage ->
113+
navController.navigate("${MainNavRoutes.SingleResult.route}?isFromMyPage=$isFromMyPage") {
114+
popUpTo(MainNavRoutes.MyPage.route) {
115+
inclusive = false
116+
}
117+
}
118+
},
119+
navigateToBattleResult = { isFromMyPage ->
120+
navController.navigate("${MainNavRoutes.BattleResult.route}?isFromMyPage=$isFromMyPage") {
121+
popUpTo(MainNavRoutes.MyPage.route) {
122+
inclusive = false
123+
}
124+
}
125+
},
113126
onShowSnackbar = onShowSnackbar
114127
)
115128

@@ -124,7 +137,7 @@ fun SetUpMainNavGraph(
124137
navigateToBattleResult = {
125138
navController.navigate(MainNavRoutes.BattleResult.route) {
126139
popUpTo(MainNavRoutes.Battle.route) {
127-
inclusive = false
140+
inclusive = true
128141
}
129142
}
130143
},
@@ -135,7 +148,7 @@ fun SetUpMainNavGraph(
135148
navigateToSingleResult = {
136149
navController.navigate(MainNavRoutes.SingleResult.route) {
137150
popUpTo(MainNavRoutes.Single.route) {
138-
inclusive = false
151+
inclusive = true
139152
}
140153
}
141154
},
@@ -145,10 +158,13 @@ fun SetUpMainNavGraph(
145158
runningResultRoute(
146159
navigateToTopLevel = {
147160
navController.navigate(MainNavRoutes.Battle.route) {
148-
popUpTo(MainNavRoutes.Battle.route) {
161+
popUpTo(navController.graph.findStartDestination().id) {
149162
inclusive = true
150163
}
151164
}
165+
},
166+
navigateToBack = {
167+
navController.popBackStack()
152168
}
153169
)
154170

build-logic/convention/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ gradlePlugin {
4242
id = "nohjunh.android.library"
4343
implementationClass = "AndroidLibraryConventionPlugin"
4444
}
45+
register("androidRoom") {
46+
id = "nohjunh.android.room"
47+
implementationClass = "AndroidRoomConventionPlugin"
48+
}
4549
register("androidFeature") {
4650
id = "nohjunh.android.feature"
4751
implementationClass = "AndroidFeatureConventionPlugin"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import com.google.devtools.ksp.gradle.KspExtension
2+
import online.partyrun.partyrunapplication.libs
3+
import org.gradle.api.Plugin
4+
import org.gradle.api.Project
5+
import org.gradle.kotlin.dsl.configure
6+
import org.gradle.kotlin.dsl.dependencies
7+
8+
class AndroidRoomConventionPlugin : Plugin<Project> {
9+
10+
override fun apply(target: Project) {
11+
with(target) {
12+
pluginManager.apply("com.google.devtools.ksp")
13+
14+
extensions.configure<KspExtension> {
15+
}
16+
17+
dependencies {
18+
add("implementation", libs.findLibrary("room.runtime").get())
19+
add("implementation", libs.findLibrary("room.ktx").get())
20+
add("ksp", libs.findLibrary("room.compiler").get())
21+
}
22+
}
23+
}
24+
}

buildSrc/src/main/java/Configurations.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ object Configurations {
33
const val MIN_SDK_VERSION = 26
44
const val TARGET_SDK_VERSION = 33
55
private const val MAJOR_VERSION = 1
6-
private const val MINOR_VERSION = 2
6+
private const val MINOR_VERSION = 3
77
private const val PATCH_VERSION = 0
88
const val VERSION_NAME = "$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
9-
const val VERSION_CODE = 22
10-
// kotlinCompilerExtensionVersion
11-
const val COMPOSE = "1.4.5"
9+
const val VERSION_CODE = 23
1210
}

core/common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.io.File
22
import java.io.FileInputStream
3-
import java.util.*
3+
import java.util.Properties
44

55
plugins {
66
id("nohjunh.android.library")

core/data/build.gradle.kts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,12 @@ dependencies {
2020
implementation(project(":core:datastore"))
2121
implementation(project(":core:model"))
2222
implementation(project(":core:network"))
23+
implementation(project(":core:database"))
2324

2425
implementation(libs.androidx.core.ktx)
2526
implementation(libs.kotlinx.coroutines.android)
2627
implementation(libs.kotlinx.serialization.json)
2728

28-
implementation(libs.hilt.android)
29-
implementation(libs.androidx.hilt.navigation.compose)
30-
kapt(libs.hilt.compiler)
31-
3229
implementation(libs.google.location)
3330

3431
testImplementation(project(":core:testing"))

core/data/src/main/java/online/partyrun/partyrunapplication/core/data/repository/ResultRepository.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@ package online.partyrun.partyrunapplication.core.data.repository
33
import kotlinx.coroutines.flow.Flow
44
import online.partyrun.partyrunapplication.core.model.running_result.battle.BattleResult
55
import online.partyrun.partyrunapplication.core.common.result.Result
6+
import online.partyrun.partyrunapplication.core.model.my_page.BattleRunningHistory
7+
import online.partyrun.partyrunapplication.core.model.my_page.ComprehensiveRunRecord
8+
import online.partyrun.partyrunapplication.core.model.my_page.SingleRunningHistory
69
import online.partyrun.partyrunapplication.core.model.running_result.single.SingleResult
710

811
interface ResultRepository {
912
suspend fun getBattleResults(): Flow<Result<BattleResult>>
1013
suspend fun getSingleResults(): Flow<Result<SingleResult>>
14+
suspend fun getComprehensiveRunRecord(): Flow<Result<ComprehensiveRunRecord>>
15+
suspend fun updateSingleHistory(): Flow<Result<Unit>>
16+
suspend fun updateBattleHistory(): Flow<Result<Unit>>
17+
suspend fun getSingleHistory(): Flow<Result<SingleRunningHistory>>
18+
suspend fun getBattleHistory(): Flow<Result<BattleRunningHistory>>
19+
suspend fun deleteAllHistories(): Flow<Result<Unit>>
20+
1121
}

core/data/src/main/java/online/partyrun/partyrunapplication/core/data/repository/ResultRepositoryImpl.kt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,38 @@ package online.partyrun.partyrunapplication.core.data.repository
22

33
import kotlinx.coroutines.flow.Flow
44
import kotlinx.coroutines.flow.first
5+
import kotlinx.coroutines.flow.flow
6+
import kotlinx.coroutines.flow.map
57
import online.partyrun.partyrunapplication.core.common.network.apiRequestFlow
8+
import online.partyrun.partyrunapplication.core.common.network.onException
9+
import online.partyrun.partyrunapplication.core.common.network.onSuccess
610
import online.partyrun.partyrunapplication.core.datastore.datasource.BattlePreferencesDataSource
711
import online.partyrun.partyrunapplication.core.model.running_result.battle.BattleResult
812
import online.partyrun.partyrunapplication.core.network.datasource.ResultDataSource
913
import online.partyrun.partyrunapplication.core.network.model.response.toDomainModel
1014
import online.partyrun.partyrunapplication.core.common.result.Result
1115
import online.partyrun.partyrunapplication.core.common.result.mapResultModel
16+
import online.partyrun.partyrunapplication.core.database.dao.BattleRunningHistoryDao
17+
import online.partyrun.partyrunapplication.core.database.dao.SingleRunningHistoryDao
18+
import online.partyrun.partyrunapplication.core.database.model.toDomainModel
1219
import online.partyrun.partyrunapplication.core.datastore.datasource.SinglePreferencesDataSource
20+
import online.partyrun.partyrunapplication.core.model.my_page.BattleRunningHistory
21+
import online.partyrun.partyrunapplication.core.model.my_page.ComprehensiveRunRecord
22+
import online.partyrun.partyrunapplication.core.model.my_page.SingleRunningHistory
1323
import online.partyrun.partyrunapplication.core.model.running_result.single.SingleResult
24+
import online.partyrun.partyrunapplication.core.network.model.response.toEntity
1425
import javax.inject.Inject
1526

1627
class ResultRepositoryImpl @Inject constructor(
1728
private val resultDataSource: ResultDataSource,
29+
private val singleRunningHistoryDao: SingleRunningHistoryDao,
30+
private val battleRunningHistoryDao: BattleRunningHistoryDao,
1831
private val battlePreferencesDataSource: BattlePreferencesDataSource,
1932
private val singlePreferencesDataSource: SinglePreferencesDataSource
2033
) : ResultRepository {
34+
companion object {
35+
const val UNKNOWN_ERROR = "Unknown Error"
36+
}
2137

2238
override suspend fun getBattleResults(): Flow<Result<BattleResult>> {
2339
return apiRequestFlow {
@@ -33,4 +49,65 @@ class ResultRepositoryImpl @Inject constructor(
3349
}.mapResultModel { it.toDomainModel() }
3450
}
3551

52+
override suspend fun getComprehensiveRunRecord(): Flow<Result<ComprehensiveRunRecord>> {
53+
return apiRequestFlow {
54+
resultDataSource.getComprehensiveRunRecord()
55+
}.mapResultModel { it.toDomainModel() }
56+
}
57+
58+
override suspend fun updateSingleHistory(): Flow<Result<Unit>> = flow {
59+
emit(Result.Loading)
60+
val response = resultDataSource.getSingleHistory()
61+
response.onSuccess { result ->
62+
singleRunningHistoryDao.insertAllSingleRunningHistory(result.toEntity())
63+
emit(Result.Success(Unit))
64+
}.onException { e ->
65+
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
66+
}
67+
}
68+
69+
override suspend fun updateBattleHistory(): Flow<Result<Unit>> = flow {
70+
emit(Result.Loading)
71+
val response = resultDataSource.getBattleHistory()
72+
response.onSuccess { result ->
73+
battleRunningHistoryDao.insertAllBattleRunningHistory(result.toEntity())
74+
emit(Result.Success(Unit))
75+
}.onException { e ->
76+
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
77+
}
78+
}
79+
80+
override suspend fun getSingleHistory(): Flow<Result<SingleRunningHistory>> {
81+
return singleRunningHistoryDao.getAllSingleRunningHistories()
82+
.map { entityList ->
83+
try {
84+
Result.Success(SingleRunningHistory(entityList.map { it.toDomainModel() }))
85+
} catch (e: Exception) {
86+
Result.Failure(e.message ?: UNKNOWN_ERROR, -1)
87+
}
88+
}
89+
}
90+
91+
override suspend fun getBattleHistory(): Flow<Result<BattleRunningHistory>> {
92+
return battleRunningHistoryDao.getAllBattleRunningHistories()
93+
.map { entityList ->
94+
try {
95+
Result.Success(BattleRunningHistory(entityList.map { it.toDomainModel() }))
96+
} catch (e: Exception) {
97+
Result.Failure(e.message ?: UNKNOWN_ERROR, -1)
98+
}
99+
}
100+
}
101+
102+
override suspend fun deleteAllHistories(): Flow<Result<Unit>> = flow {
103+
emit(Result.Loading)
104+
try {
105+
singleRunningHistoryDao.deleteAllSingleRunningHistories()
106+
battleRunningHistoryDao.deleteAllBattleRunningHistories()
107+
emit(Result.Success(Unit))
108+
} catch (e: Exception) {
109+
emit(Result.Failure(e.message ?: UNKNOWN_ERROR, -1))
110+
}
111+
}
112+
36113
}

core/database/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

core/database/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
plugins {
2+
id("nohjunh.android.library")
3+
id("nohjunh.android.hilt")
4+
id("nohjunh.android.room")
5+
}
6+
7+
android {
8+
namespace = "online.partyrun.partyrunapplication.core.database"
9+
}
10+
11+
dependencies {
12+
implementation(project(":core:model"))
13+
14+
implementation(libs.kotlinx.coroutines.android)
15+
implementation(libs.kotlinx.datetime)
16+
17+
androidTestImplementation(project(":core:testing"))
18+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package online.partyrun.partyrunapplication.core.database
2+
3+
import androidx.room.Database
4+
import androidx.room.RoomDatabase
5+
import online.partyrun.partyrunapplication.core.database.dao.BattleRunningHistoryDao
6+
import online.partyrun.partyrunapplication.core.database.dao.SingleRunningHistoryDao
7+
import online.partyrun.partyrunapplication.core.database.model.BattleRunningHistoryEntity
8+
import online.partyrun.partyrunapplication.core.database.model.SingleRunningHistoryEntity
9+
10+
@Database(
11+
entities = [SingleRunningHistoryEntity::class, BattleRunningHistoryEntity::class],
12+
version = 1
13+
)
14+
abstract class PartyRunDatabase : RoomDatabase() {
15+
16+
abstract fun singleRunningHistoryDao(): SingleRunningHistoryDao
17+
18+
abstract fun battleRunningHistoryDao(): BattleRunningHistoryDao
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package online.partyrun.partyrunapplication.core.database.dao
2+
3+
import androidx.room.Dao
4+
import androidx.room.Insert
5+
import androidx.room.OnConflictStrategy
6+
import androidx.room.Query
7+
import kotlinx.coroutines.flow.Flow
8+
import online.partyrun.partyrunapplication.core.database.model.BattleRunningHistoryEntity
9+
10+
@Dao
11+
interface BattleRunningHistoryDao {
12+
13+
@Insert(onConflict = OnConflictStrategy.REPLACE)
14+
suspend fun insertAllBattleRunningHistory(historyEntities: List<BattleRunningHistoryEntity>)
15+
16+
@Query("SELECT * FROM battle_running_history_resource")
17+
fun getAllBattleRunningHistories(): Flow<List<BattleRunningHistoryEntity>>
18+
19+
@Query("DELETE FROM battle_running_history_resource")
20+
suspend fun deleteAllBattleRunningHistories()
21+
22+
}

0 commit comments

Comments
 (0)