Skip to content

Commit

Permalink
Merge pull request #62 from Hyesung82/feature/write
Browse files Browse the repository at this point in the history
[develop] 일기 작성하기 기능 구현
  • Loading branch information
Hyesung82 authored Nov 15, 2023
2 parents 7db0b7e + 1a65c9f commit 9c4fe7c
Show file tree
Hide file tree
Showing 102 changed files with 2,436 additions and 148 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: set up JDK 11
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: gradle

Expand Down
1 change: 1 addition & 0 deletions MapZ-Android
Submodule MapZ-Android added at d201ed
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ plugins {
}

android {
compileSdk 33
namespace = "com.cheocharm.mapz"

compileSdk 34

defaultConfig {
applicationId "com.cheocharm.mapz"
minSdk 23
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

Expand All @@ -25,11 +27,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = jvmTarget
}

dataBinding {
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.cheocharm.mapz">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application
android:name=".MapZApplication"
Expand All @@ -21,6 +25,8 @@
android:name="com.cheocharm.presentation.ui.MainActivity"
android:exported="true" />

<activity android:name="com.cheocharm.presentation.ui.DiaryActivity" />

<activity
android:name="com.cheocharm.presentation.ui.login.SignActivity"
android:exported="true"
Expand All @@ -31,7 +37,6 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>

</manifest>
19 changes: 12 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
buildscript {
ext {
agp_version = '8.1.3'
}
}
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
id 'com.android.application' version '8.1.3' apply false
id 'com.android.library' version '8.1.3' apply false
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
id 'org.jetbrains.kotlin.jvm' version '1.9.20' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
id 'com.google.dagger.hilt.android' version '2.42' apply false
id 'com.google.dagger.hilt.android' version '2.48.1' apply false
id 'androidx.navigation.safeargs.kotlin' version "${navVersion}" apply false
}

task clean(type: Delete) {
delete rootProject.buildDir
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}
4 changes: 2 additions & 2 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
Expand Down
6 changes: 6 additions & 0 deletions data/src/main/java/com/cheocharm/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import com.cheocharm.data.repository.AuthRepositoryImpl
import com.cheocharm.data.repository.GroupRepositoryImpl
import com.cheocharm.data.repository.LoginRepositoryImpl
import com.cheocharm.data.repository.MyGroupsRepositoryImpl
import com.cheocharm.data.repository.WriteRepositoryImpl
import com.cheocharm.domain.repository.AuthRepository
import com.cheocharm.domain.repository.GroupRepository
import com.cheocharm.domain.repository.LoginRepository
import com.cheocharm.domain.repository.MyGroupsRepository
import com.cheocharm.domain.repository.WriteRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -33,4 +35,8 @@ internal abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindMyGroupsRepository(repo: MyGroupsRepositoryImpl): MyGroupsRepository

@Binds
@Singleton
abstract fun bindWriteRepository(repository: WriteRepositoryImpl): WriteRepository
}
3 changes: 3 additions & 0 deletions data/src/main/java/com/cheocharm/data/error/ErrorData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ sealed class ErrorData(
data class SearchGroupUnavailable(override val message: String) : ErrorData(message)
data class JoinGroupUnavailable(override val message: String) : ErrorData(message)
data class GetMyGroupsUnavailable(override val message: String) : ErrorData(message)

data class WriteImagesUnavailable(override val message: String) : ErrorData(message)
data class WriteDiaryUnavailable(override val message: String) : ErrorData(message)
}
2 changes: 2 additions & 0 deletions data/src/main/java/com/cheocharm/data/error/ErrorMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ internal fun ErrorData.toDomain(): Error = when (this) {
is ErrorData.SearchGroupUnavailable -> Error.SearchGroupUnavailable(message)
is ErrorData.JoinGroupUnavailable -> Error.JoinGroupUnavailable(message)
is ErrorData.GetMyGroupsUnavailable -> Error.GetMyGroupsUnavailable(message)
is ErrorData.WriteImagesUnavailable -> Error.WriteImagesUnavailable(message)
is ErrorData.WriteDiaryUnavailable -> Error.WriteDiaryUnavailable(message)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.cheocharm.data.repository

import com.cheocharm.data.error.ErrorData
import com.cheocharm.data.error.toDomain
import com.cheocharm.data.source.WriteRemoteDataSource
import com.cheocharm.domain.model.TempDiary
import com.cheocharm.domain.model.WriteDiaryRequest
import com.cheocharm.domain.model.WriteImageRequest
import com.cheocharm.domain.repository.WriteRepository
import javax.inject.Inject

class WriteRepositoryImpl @Inject constructor(
private val writeRemoteDataSource: WriteRemoteDataSource
) : WriteRepository {
override suspend fun requestWriteImages(request: WriteImageRequest): Result<TempDiary> {
val result = writeRemoteDataSource.requestWriteImages(request)

return when (val exception = result.exceptionOrNull()) {
is ErrorData -> Result.failure(exception.toDomain())
null -> result
else -> Result.failure(exception)
}
}

override suspend fun requestWriteDiary(request: WriteDiaryRequest): Result<Long> {
val result = writeRemoteDataSource.requestWriteDiary(request)

return when (val exception = result.exceptionOrNull()) {
is ErrorData -> Result.failure(exception.toDomain())
null -> result
else -> Result.failure(exception)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.cheocharm.data.source

import com.cheocharm.domain.model.TempDiary
import com.cheocharm.domain.model.WriteDiaryRequest
import com.cheocharm.domain.model.WriteImageRequest

interface WriteRemoteDataSource {
suspend fun requestWriteImages(request: WriteImageRequest): Result<TempDiary>

suspend fun requestWriteDiary(request: WriteDiaryRequest): Result<Long>
}
4 changes: 2 additions & 2 deletions domain/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ plugins {
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

dependencies {
Expand Down
3 changes: 3 additions & 0 deletions domain/src/main/java/com/cheocharm/domain/model/Error.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ sealed class Error(
data class SearchGroupUnavailable(override val message: String) : Error()
data class JoinGroupUnavailable(override val message: String) : Error()
data class GetMyGroupsUnavailable(override val message: String) : Error()

data class WriteImagesUnavailable(override val message: String) : Error()
data class WriteDiaryUnavailable(override val message: String) : Error()
}
3 changes: 3 additions & 0 deletions domain/src/main/java/com/cheocharm/domain/model/TempDiary.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.cheocharm.domain.model

data class TempDiary(val diaryId: Long, val imageUrls: List<String>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.cheocharm.domain.model

data class WriteDiaryRequest(
val id: Long,
val title: String,
val content: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.cheocharm.domain.model

import java.io.File

data class WriteImageRequest(
val groupId: Long,
val address: String,
val latitude: Double,
val longitude: Double,
val images: List<File>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.cheocharm.domain.repository

import com.cheocharm.domain.model.TempDiary
import com.cheocharm.domain.model.WriteDiaryRequest
import com.cheocharm.domain.model.WriteImageRequest

interface WriteRepository {
suspend fun requestWriteImages(request: WriteImageRequest): Result<TempDiary>

suspend fun requestWriteDiary(request: WriteDiaryRequest): Result<Long>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.cheocharm.domain.usecase.write

import com.cheocharm.domain.model.WriteDiaryRequest
import com.cheocharm.domain.repository.WriteRepository
import javax.inject.Inject

class RequestWriteDiaryUseCase @Inject constructor(
private val repository: WriteRepository
) {
suspend operator fun invoke(request: WriteDiaryRequest): Result<Long> =
repository.requestWriteDiary(request)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.cheocharm.domain.usecase.write

import com.cheocharm.domain.model.TempDiary
import com.cheocharm.domain.model.WriteImageRequest
import com.cheocharm.domain.repository.WriteRepository
import javax.inject.Inject

class RequestWriteImagesUseCase @Inject constructor(
private val repository: WriteRepository
) {
suspend operator fun invoke(request: WriteImageRequest): Result<TempDiary> =
repository.requestWriteImages(request)
}
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.defaults.buildfeatures.buildconfig=true

coreKtxVersion=1.9.0
coreKtxVersion=1.12.0
junitVersion=1.1.5
espressoCoreVersion=3.5.1
navVersion=2.5.3
hiltVersion=2.42
hiltVersion=2.48.1
coroutineVersion=1.6.3
glideVersion=4.12.0
pagingVersion=3.1.1
pagingVersion=3.2.1
jvmTarget=17
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon May 23 23:15:00 KST 2022
#Wed Nov 15 15:45:03 KST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 7 additions & 5 deletions local/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ plugins {
}

android {
compileSdk 33
namespace = "com.cheocharm.local"

compileSdk 34

defaultConfig {
minSdk 23
targetSdk 33
targetSdk 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -22,11 +24,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = jvmTarget
}
}

Expand Down
3 changes: 1 addition & 2 deletions local/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cheocharm.local">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
Loading

0 comments on commit 9c4fe7c

Please sign in to comment.