From 3838e1f99bffb013fcdf1cf99c23e25f14790dfe Mon Sep 17 00:00:00 2001 From: Hyesung82 Date: Wed, 15 Nov 2023 14:43:02 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20Gradle=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8,=20rebase?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 12 +-- build.gradle | 8 +- data/build.gradle | 4 +- .../com/cheocharm/data/di/RepositoryModule.kt | 6 ++ .../com/cheocharm/data/error/ErrorData.kt | 3 + .../com/cheocharm/data/error/ErrorMapper.kt | 2 + domain/build.gradle | 4 +- .../java/com/cheocharm/domain/model/Error.kt | 3 + gradle.properties | 9 ++- gradle/wrapper/gradle-wrapper.properties | 4 +- local/build.gradle | 12 +-- local/src/main/AndroidManifest.xml | 3 +- presentation/build.gradle | 32 +++++--- presentation/src/main/AndroidManifest.xml | 3 +- .../cheocharm/presentation/common/Event.kt | 4 +- .../presentation/common/TestValues.kt | 3 + .../cheocharm/presentation/ui/MainActivity.kt | 4 +- .../presentation/ui/home/HomeFragment.kt | 2 +- .../presentation/ui/login/SignActivity.kt | 2 +- .../presentation/ui/login/SignInFragment.kt | 2 +- .../ui/login/SignUpAgreeFragment.kt | 2 +- .../presentation/ui/login/SignUpFragment.kt | 2 +- .../ui/login/SignUpProfileFragment.kt | 4 +- .../presentation/ui/mypage/MyPageFragment.kt | 2 +- .../presentation/ui/search/SearchFragment.kt | 2 +- .../presentation/ui/write/GroupsFragment.kt | 2 + .../presentation/ui/write/GroupsViewModel.kt | 15 ++++ .../presentation/ui/write/MembersAdapter.kt | 6 +- .../presentation/ui/write/WriteViewModel.kt | 76 ++++++++++++++++++- .../src/main/res/layout/item_group.xml | 1 - .../res/layout/item_write_group_member.xml | 30 ++++++++ presentation/src/main/res/values/dimens.xml | 2 +- remote/build.gradle | 12 +-- remote/src/main/AndroidManifest.xml | 2 +- .../java/com/cheocharm/remote/api/DiaryApi.kt | 2 +- .../java/com/cheocharm/remote/api/WriteApi.kt | 21 ++++- .../cheocharm/remote/di/DataSourceModule.kt | 6 ++ .../com/cheocharm/remote/di/RemoteModule.kt | 1 - .../cheocharm/remote/mapper/WriteMapper.kt | 16 ++++ 39 files changed, 257 insertions(+), 69 deletions(-) create mode 100644 presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsViewModel.kt create mode 100644 presentation/src/main/res/layout/item_write_group_member.xml diff --git a/app/build.gradle b/app/build.gradle index 3f0c8550..6955fe41 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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" @@ -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 = '17' } dataBinding { diff --git a/build.gradle b/build.gradle index 99022649..234e6781 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ plugins { - id 'com.android.application' version '7.4.2' apply false - id 'com.android.library' version '7.4.2' 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.7.0' apply false id 'org.jetbrains.kotlin.jvm' version '1.5.30' 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) { +tasks.register('clean', Delete) { delete rootProject.buildDir } diff --git a/data/build.gradle b/data/build.gradle index b5bf6245..40c4d0aa 100644 --- a/data/build.gradle +++ b/data/build.gradle @@ -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 { diff --git a/data/src/main/java/com/cheocharm/data/di/RepositoryModule.kt b/data/src/main/java/com/cheocharm/data/di/RepositoryModule.kt index cab098c0..67182783 100644 --- a/data/src/main/java/com/cheocharm/data/di/RepositoryModule.kt +++ b/data/src/main/java/com/cheocharm/data/di/RepositoryModule.kt @@ -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 @@ -33,4 +35,8 @@ internal abstract class RepositoryModule { @Binds @Singleton abstract fun bindMyGroupsRepository(repo: MyGroupsRepositoryImpl): MyGroupsRepository + + @Binds + @Singleton + abstract fun bindWriteRepository(repository: WriteRepositoryImpl): WriteRepository } diff --git a/data/src/main/java/com/cheocharm/data/error/ErrorData.kt b/data/src/main/java/com/cheocharm/data/error/ErrorData.kt index 72cb1156..8c432c8a 100644 --- a/data/src/main/java/com/cheocharm/data/error/ErrorData.kt +++ b/data/src/main/java/com/cheocharm/data/error/ErrorData.kt @@ -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) } diff --git a/data/src/main/java/com/cheocharm/data/error/ErrorMapper.kt b/data/src/main/java/com/cheocharm/data/error/ErrorMapper.kt index 5ca281b4..a6d0ec8e 100644 --- a/data/src/main/java/com/cheocharm/data/error/ErrorMapper.kt +++ b/data/src/main/java/com/cheocharm/data/error/ErrorMapper.kt @@ -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) } diff --git a/domain/build.gradle b/domain/build.gradle index 6f6e1cda..41bb6374 100644 --- a/domain/build.gradle +++ b/domain/build.gradle @@ -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 { diff --git a/domain/src/main/java/com/cheocharm/domain/model/Error.kt b/domain/src/main/java/com/cheocharm/domain/model/Error.kt index 7b20d0bc..3ba776a6 100644 --- a/domain/src/main/java/com/cheocharm/domain/model/Error.kt +++ b/domain/src/main/java/com/cheocharm/domain/model/Error.kt @@ -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() } diff --git a/gradle.properties b/gradle.properties index a137433f..8fcfe15d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,12 +21,13 @@ 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 +navVersion=2.7.5 +hiltVersion=2.48.1 coroutineVersion=1.6.3 glideVersion=4.12.0 -pagingVersion=3.1.1 +pagingVersion=3.2.1 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 046060f6..6772f801 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon May 23 23:15:00 KST 2022 +#Wed Nov 15 11:07:58 KST 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/local/build.gradle b/local/build.gradle index 943436e9..6178c197 100644 --- a/local/build.gradle +++ b/local/build.gradle @@ -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" @@ -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 = '17' } } diff --git a/local/src/main/AndroidManifest.xml b/local/src/main/AndroidManifest.xml index 8dee0eed..a5918e68 100644 --- a/local/src/main/AndroidManifest.xml +++ b/local/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + \ No newline at end of file diff --git a/presentation/build.gradle b/presentation/build.gradle index 5d157033..f0d2bce5 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -11,11 +11,13 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) android { - compileSdk 33 + namespace = "com.cheocharm.presentation" + + compileSdk 34 defaultConfig { minSdk 23 - targetSdk 33 + targetSdk 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -30,15 +32,15 @@ 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 = '17' } - dataBinding { - enabled = true + buildFeatures { + dataBinding true } } @@ -47,7 +49,7 @@ dependencies { implementation "androidx.core:core-ktx:$coreKtxVersion" implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.8.0' + implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.exifinterface:exifinterface:1.3.6' testImplementation 'junit:junit:4.13.2' @@ -60,14 +62,14 @@ dependencies { // Hilt implementation "com.google.dagger:hilt-android:$hiltVersion" - implementation "androidx.hilt:hilt-navigation-fragment:1.0.0" + implementation "androidx.hilt:hilt-navigation-fragment:1.1.0" kapt "com.google.dagger:hilt-android-compiler:$hiltVersion" // Google Maps - implementation 'com.google.android.gms:play-services-maps:18.1.0' + implementation 'com.google.android.gms:play-services-maps:18.2.0' // google login - implementation 'com.google.android.gms:play-services-auth:20.4.1' + implementation 'com.google.android.gms:play-services-auth:20.7.0' // kotlin coroutine implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion" @@ -78,8 +80,14 @@ dependencies { kapt "com.github.bumptech.glide:compiler:$glideVersion" // paging - implementation "androidx.paging:paging-runtime:$pagingVersion" + implementation "androidx.paging:paging-runtime-ktx:$pagingVersion" // SwipeRefreshLayout implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" + + // 현재 위치 + implementation 'com.google.android.gms:play-services-location:21.0.1' + + // Text editor + implementation 'jp.wasabeef:richeditor-android:2.0.0' } diff --git a/presentation/src/main/AndroidManifest.xml b/presentation/src/main/AndroidManifest.xml index 5f211ade..6def8511 100644 --- a/presentation/src/main/AndroidManifest.xml +++ b/presentation/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + (private val content: T) { * [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. */ class EventObserver(private val onEventUnhandledContent: (T) -> Unit) : Observer> { - override fun onChanged(event: Event?) { - event?.getContentIfNotHandled()?.let { + override fun onChanged(value: Event) { + value.getContentIfNotHandled()?.let { onEventUnhandledContent(it) } } diff --git a/presentation/src/main/java/com/cheocharm/presentation/common/TestValues.kt b/presentation/src/main/java/com/cheocharm/presentation/common/TestValues.kt index 3ae49703..eaafd6af 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/common/TestValues.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/common/TestValues.kt @@ -7,6 +7,7 @@ import com.cheocharm.presentation.model.Sticker object TestValues { val testGroups = listOf( Group( + 0, "그룹제목 1", "맵지 고등학교 추억 교환일기!", "2022.02.23", @@ -22,6 +23,7 @@ object TestValues { ), 4 ), Group( + 1, "그룹제목 2", "맵지 고등학교 추억 교환일기!", "2022.02.23", listOf( @@ -29,6 +31,7 @@ object TestValues { ), 0 ), Group( + 2, "그룹제목 3", "맵지 고등학교 추억 교환일기!", "2022.02.23", listOf( diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/MainActivity.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/MainActivity.kt index fbda5a07..fc882bba 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/MainActivity.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/MainActivity.kt @@ -3,15 +3,15 @@ package com.cheocharm.presentation.ui import android.content.Context import android.graphics.Rect import android.os.Bundle -import androidx.core.view.isVisible import android.view.MotionEvent import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.EditText +import androidx.core.view.isVisible import androidx.navigation.fragment.NavHostFragment import androidx.navigation.ui.setupWithNavController -import com.cheocharm.presentation.base.BaseActivity import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseActivity import com.cheocharm.presentation.databinding.ActivityMainBinding import dagger.hilt.android.AndroidEntryPoint diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/home/HomeFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/home/HomeFragment.kt index 4b1c571d..54b4d5ba 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/home/HomeFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/home/HomeFragment.kt @@ -4,8 +4,8 @@ import android.os.Bundle import android.view.View import androidx.core.view.isVisible import androidx.fragment.app.viewModels -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.databinding.FragmentHomeBinding import com.cheocharm.presentation.ui.MainActivity import dagger.hilt.android.AndroidEntryPoint diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignActivity.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignActivity.kt index 2be63a7e..d3f6717e 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignActivity.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignActivity.kt @@ -7,8 +7,8 @@ import android.view.MotionEvent import android.view.inputmethod.InputMethodManager import android.widget.EditText import androidx.navigation.fragment.NavHostFragment -import com.cheocharm.presentation.base.BaseActivity import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseActivity import com.cheocharm.presentation.databinding.ActivitySignInBinding import dagger.hilt.android.AndroidEntryPoint diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignInFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignInFragment.kt index f0870a45..6e338c45 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignInFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignInFragment.kt @@ -12,9 +12,9 @@ import androidx.core.os.bundleOf import androidx.core.widget.doOnTextChanged import androidx.fragment.app.viewModels import androidx.navigation.fragment.findNavController -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.BuildConfig import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.common.EventObserver import com.cheocharm.presentation.common.GOOGLE_ID_TOKEN import com.cheocharm.presentation.common.SIGN_UP_TYPE diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpAgreeFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpAgreeFragment.kt index ce3200d2..8b466289 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpAgreeFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpAgreeFragment.kt @@ -5,8 +5,8 @@ import android.view.View import androidx.core.content.ContextCompat import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.common.GOOGLE_ID_TOKEN import com.cheocharm.presentation.common.SIGN_UP_TYPE import com.cheocharm.presentation.databinding.FragmentSignUpAgreeBinding diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpFragment.kt index 012d0959..804d013b 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpFragment.kt @@ -11,8 +11,8 @@ import androidx.core.view.isVisible import androidx.core.widget.doOnTextChanged import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.databinding.FragmentSignUpBinding import dagger.hilt.android.AndroidEntryPoint diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpProfileFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpProfileFragment.kt index b0fa5dc5..6ebfef6c 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpProfileFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/login/SignUpProfileFragment.kt @@ -16,10 +16,10 @@ import androidx.core.view.isVisible import androidx.core.widget.doOnTextChanged import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.R -import com.cheocharm.presentation.util.UriUtil +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.databinding.FragmentSignUpProfileBinding +import com.cheocharm.presentation.util.UriUtil import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/mypage/MyPageFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/mypage/MyPageFragment.kt index 9a687925..cebdda9f 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/mypage/MyPageFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/mypage/MyPageFragment.kt @@ -5,9 +5,9 @@ import android.os.Bundle import android.view.View import androidx.core.view.isVisible import androidx.fragment.app.viewModels -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.BuildConfig import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.databinding.FragmentMyPageBinding import com.cheocharm.presentation.ui.MainActivity import com.cheocharm.presentation.ui.login.SignActivity diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/search/SearchFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/search/SearchFragment.kt index 821c8623..5290305d 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/search/SearchFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/search/SearchFragment.kt @@ -6,8 +6,8 @@ import android.view.inputmethod.EditorInfo import androidx.core.view.isVisible import androidx.hilt.navigation.fragment.hiltNavGraphViewModels import androidx.navigation.fragment.findNavController -import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.R +import com.cheocharm.presentation.base.BaseFragment import com.cheocharm.presentation.databinding.ActivityMainBinding import com.cheocharm.presentation.databinding.FragmentSearchBinding import com.cheocharm.presentation.ui.MainActivity diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsFragment.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsFragment.kt index dbd8f34b..32f97929 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsFragment.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.util.Log import android.view.View import android.widget.Toast +import androidx.fragment.app.viewModels import androidx.hilt.navigation.fragment.hiltNavGraphViewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.DividerItemDecoration @@ -19,6 +20,7 @@ import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class GroupsFragment : BaseFragment(R.layout.fragment_groups) { private val writeViewModel by hiltNavGraphViewModels(R.id.write) + private val groupsViewModel: GroupsViewModel by viewModels() private lateinit var swipeRefreshLayout: SwipeRefreshLayout diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsViewModel.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsViewModel.kt new file mode 100644 index 00000000..7afc67d4 --- /dev/null +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/write/GroupsViewModel.kt @@ -0,0 +1,15 @@ +package com.cheocharm.presentation.ui.write + +import androidx.lifecycle.LiveData +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import com.cheocharm.domain.model.Group +import com.cheocharm.presentation.common.TestValues +import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject + +@HiltViewModel +class GroupsViewModel @Inject constructor() : ViewModel() { + private val _groups = MutableLiveData(TestValues.testGroups) + val groups: LiveData> = _groups +} diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/write/MembersAdapter.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/write/MembersAdapter.kt index 97a79156..dae2af05 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/write/MembersAdapter.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/write/MembersAdapter.kt @@ -6,11 +6,11 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.cheocharm.domain.model.GroupMember -import com.cheocharm.presentation.databinding.ItemGroupMemberBinding +import com.cheocharm.presentation.databinding.ItemWriteGroupMemberBinding class MembersAdapter : ListAdapter(MemberDiffCallback) { - class ViewHolder(private val binding: ItemGroupMemberBinding) : + class ViewHolder(private val binding: ItemWriteGroupMemberBinding) : RecyclerView.ViewHolder(binding.root) { fun bind(member: GroupMember) { @@ -20,7 +20,7 @@ class MembersAdapter : ListAdapter(Membe } override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ViewHolder { - val binding = ItemGroupMemberBinding.inflate( + val binding = ItemWriteGroupMemberBinding.inflate( LayoutInflater.from(viewGroup.context), viewGroup, false diff --git a/presentation/src/main/java/com/cheocharm/presentation/ui/write/WriteViewModel.kt b/presentation/src/main/java/com/cheocharm/presentation/ui/write/WriteViewModel.kt index eccee25a..848d0d05 100644 --- a/presentation/src/main/java/com/cheocharm/presentation/ui/write/WriteViewModel.kt +++ b/presentation/src/main/java/com/cheocharm/presentation/ui/write/WriteViewModel.kt @@ -5,24 +5,56 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.cheocharm.domain.model.Group +import com.cheocharm.domain.model.TempDiary +import com.cheocharm.domain.model.WriteDiaryRequest import com.cheocharm.domain.usecase.write.GetMyGroupsUseCase +import com.cheocharm.domain.usecase.write.RequestWriteDiaryUseCase import com.cheocharm.presentation.common.ErrorMessage import com.cheocharm.presentation.common.Event +import com.cheocharm.presentation.model.Sticker +import com.cheocharm.presentation.model.TextAlign +import com.cheocharm.presentation.model.TextColor +import com.cheocharm.presentation.model.TextEditTool +import com.cheocharm.presentation.model.ToolDetailPage import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch import javax.inject.Inject @HiltViewModel class WriteViewModel @Inject constructor( - private val getMyGroupsUseCase: GetMyGroupsUseCase + private val getMyGroupsUseCase: GetMyGroupsUseCase, + private val requestWriteDiaryUseCase: RequestWriteDiaryUseCase ) : ViewModel() { + lateinit var temp: TempDiary + lateinit var stickers: List private val _groups = MutableLiveData>() val groups: LiveData> = _groups + private val _openTool = MutableLiveData() + val openTool: LiveData = _openTool + + private val _textColor = MutableLiveData(TextColor.Default) + val textColor: LiveData = _textColor + + private val _page = MutableLiveData() + val page: LiveData = _page + + private val _textAlign = MutableLiveData(TextAlign.Left) + val textAlign: LiveData = _textAlign + + private val _bold = MutableLiveData() + val bold: LiveData = _bold + + private val _underline = MutableLiveData() + val underline: LiveData = _underline + private val _toastText = MutableLiveData>() val toastText: LiveData> = _toastText + private val _diaryWrittenEvent = MutableLiveData?>() + val diaryWrittenEvent: LiveData?> = _diaryWrittenEvent + init { fetchMyGroups() } @@ -41,4 +73,46 @@ class WriteViewModel @Inject constructor( } } } + + fun onClickTool(tool: TextEditTool?) { + _openTool.value = if (openTool.value == tool) null else tool + } + + fun changeTextColor(textColor: TextColor) { + if (this.textColor.value != textColor) { + _textColor.value = textColor + } else { + _textColor.value = TextColor.Default + } + } + + fun updatePage(page: ToolDetailPage) { + _page.value = page + } + + fun changeTextAlign(textAlign: TextAlign) { + _textAlign.value = textAlign + } + + fun setBold() { + val bold = bold.value ?: false + _bold.value = bold.not() + } + + fun setUnderline() { + val underline = underline.value ?: false + _underline.value = underline.not() + } + + fun writeDiary(diaryId: Long, title: String, content: String) { + viewModelScope.launch { + requestWriteDiaryUseCase.invoke(WriteDiaryRequest(diaryId, title, content)) + .onSuccess { + _diaryWrittenEvent.value = Event(it) + } + .onFailure { + _toastText.value = Event(it.message ?: "") + } + } + } } diff --git a/presentation/src/main/res/layout/item_group.xml b/presentation/src/main/res/layout/item_group.xml index 24b62b75..30edc5d3 100644 --- a/presentation/src/main/res/layout/item_group.xml +++ b/presentation/src/main/res/layout/item_group.xml @@ -21,7 +21,6 @@ android:layout_width="@dimen/groups_group_image_size" android:layout_height="@dimen/groups_group_image_size" android:background="@drawable/bg_round" - android:backgroundTint="@color/groups_group_image_empty_color" app:imageCircledLoad="@{group.groupImageUrl}" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/presentation/src/main/res/layout/item_write_group_member.xml b/presentation/src/main/res/layout/item_write_group_member.xml new file mode 100644 index 00000000..0be2c0fe --- /dev/null +++ b/presentation/src/main/res/layout/item_write_group_member.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + diff --git a/presentation/src/main/res/values/dimens.xml b/presentation/src/main/res/values/dimens.xml index bfd84745..ee6597ba 100644 --- a/presentation/src/main/res/values/dimens.xml +++ b/presentation/src/main/res/values/dimens.xml @@ -41,7 +41,7 @@ 14dp 1.5dp - 20sp + 20sp 9dp 45dp 10dp diff --git a/remote/build.gradle b/remote/build.gradle index 2ee9e622..5ce61f02 100644 --- a/remote/build.gradle +++ b/remote/build.gradle @@ -8,11 +8,13 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) android { - compileSdk 33 + namespace = "com.cheocharm.remote" + + compileSdk 34 defaultConfig { minSdk 23 - targetSdk 33 + targetSdk 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles "consumer-rules.pro" @@ -27,11 +29,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 = '17' } } diff --git a/remote/src/main/AndroidManifest.xml b/remote/src/main/AndroidManifest.xml index d0e2f7ea..8072ee00 100644 --- a/remote/src/main/AndroidManifest.xml +++ b/remote/src/main/AndroidManifest.xml @@ -1,2 +1,2 @@ - + diff --git a/remote/src/main/java/com/cheocharm/remote/api/DiaryApi.kt b/remote/src/main/java/com/cheocharm/remote/api/DiaryApi.kt index f1d00583..d05b7d12 100644 --- a/remote/src/main/java/com/cheocharm/remote/api/DiaryApi.kt +++ b/remote/src/main/java/com/cheocharm/remote/api/DiaryApi.kt @@ -3,7 +3,7 @@ package com.cheocharm.remote.api import com.cheocharm.remote.model.BaseResponse import com.cheocharm.remote.model.request.WriteDiaryDto import com.cheocharm.remote.model.request.WriteImageDto -import com.cheocharm.domain.model.WriteImageResponse +import com.cheocharm.remote.model.response.write.WriteImageResponse import okhttp3.MultipartBody import retrofit2.http.Body import retrofit2.http.Multipart diff --git a/remote/src/main/java/com/cheocharm/remote/api/WriteApi.kt b/remote/src/main/java/com/cheocharm/remote/api/WriteApi.kt index 26bae20d..db551478 100644 --- a/remote/src/main/java/com/cheocharm/remote/api/WriteApi.kt +++ b/remote/src/main/java/com/cheocharm/remote/api/WriteApi.kt @@ -1,12 +1,29 @@ package com.cheocharm.remote.api import com.cheocharm.remote.model.BaseResponse +import com.cheocharm.remote.model.request.WriteDiaryDto +import com.cheocharm.remote.model.request.WriteImageDto import com.cheocharm.remote.model.response.write.MyGroup +import com.cheocharm.remote.model.response.write.WriteDiaryResponse +import com.cheocharm.remote.model.response.write.WriteImageResponse +import okhttp3.MultipartBody +import retrofit2.http.Body import retrofit2.http.GET -import retrofit2.http.Query +import retrofit2.http.Multipart +import retrofit2.http.POST +import retrofit2.http.Part interface WriteApi { - @GET("group/mygroup") suspend fun fetchMyGroups(): BaseResponse> + + @Multipart + @POST("diary/image") + suspend fun writeImage( + @Part images: List, + @Part("dto") dto: WriteImageDto + ): BaseResponse + + @POST("diary/write") + suspend fun writeDiary(@Body diary: WriteDiaryDto): BaseResponse } diff --git a/remote/src/main/java/com/cheocharm/remote/di/DataSourceModule.kt b/remote/src/main/java/com/cheocharm/remote/di/DataSourceModule.kt index 998c50a8..9067511b 100644 --- a/remote/src/main/java/com/cheocharm/remote/di/DataSourceModule.kt +++ b/remote/src/main/java/com/cheocharm/remote/di/DataSourceModule.kt @@ -5,9 +5,11 @@ import com.cheocharm.remote.source.GroupRemoteDataSourceImpl import com.cheocharm.data.source.AuthRemoteDataSource import com.cheocharm.data.source.LoginRemoteDataSource import com.cheocharm.data.source.MyGroupsRemoteDataSource +import com.cheocharm.data.source.WriteRemoteDataSource import com.cheocharm.remote.source.AuthRemoteDataSourceImpl import com.cheocharm.remote.source.LoginRemoteDataSourceImpl import com.cheocharm.remote.source.MyGroupsRemoteDataSourceImpl +import com.cheocharm.remote.source.WriteRemoteDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -33,4 +35,8 @@ internal abstract class DataSourceModule { @Binds @Singleton abstract fun bindMyGroupsRemoteDataSource(dataSource: MyGroupsRemoteDataSourceImpl): MyGroupsRemoteDataSource + + @Binds + @Singleton + abstract fun bindWriteRemoteDataSource(dataSource: WriteRemoteDataSourceImpl): WriteRemoteDataSource } diff --git a/remote/src/main/java/com/cheocharm/remote/di/RemoteModule.kt b/remote/src/main/java/com/cheocharm/remote/di/RemoteModule.kt index 45b38c7c..9844c8da 100644 --- a/remote/src/main/java/com/cheocharm/remote/di/RemoteModule.kt +++ b/remote/src/main/java/com/cheocharm/remote/di/RemoteModule.kt @@ -4,7 +4,6 @@ import com.cheocharm.remote.api.WriteApi import com.cheocharm.remote.api.GroupApi import com.cheocharm.remote.api.LoginApi import com.cheocharm.remote.api.TokenApi -import com.cheocharm.remote.api.WriteApi import com.cheocharm.remote.network.AuthInterceptor import dagger.Module import dagger.Provides diff --git a/remote/src/main/java/com/cheocharm/remote/mapper/WriteMapper.kt b/remote/src/main/java/com/cheocharm/remote/mapper/WriteMapper.kt index 0fcc2ecf..67460133 100644 --- a/remote/src/main/java/com/cheocharm/remote/mapper/WriteMapper.kt +++ b/remote/src/main/java/com/cheocharm/remote/mapper/WriteMapper.kt @@ -1,8 +1,24 @@ package com.cheocharm.remote.mapper import com.cheocharm.data.model.GroupData +import com.cheocharm.domain.model.TempDiary +import com.cheocharm.domain.model.WriteDiaryRequest +import com.cheocharm.domain.model.WriteImageRequest +import com.cheocharm.remote.model.request.WriteDiaryDto +import com.cheocharm.remote.model.request.WriteImageDto import com.cheocharm.remote.model.response.write.MyGroup +import com.cheocharm.remote.model.response.write.WriteDiaryResponse +import com.cheocharm.remote.model.response.write.WriteImageResponse internal fun MyGroup.toData(): GroupData { return GroupData(groupName, groupImageUrl, count, listOf(chiefUserImage), groupId) } + +internal fun WriteImageRequest.toDto(): WriteImageDto = + WriteImageDto(groupId, address, latitude, longitude) + +internal fun WriteDiaryRequest.toDto(): WriteDiaryDto = WriteDiaryDto(id, title, content) + +internal fun WriteImageResponse.toDomain(): TempDiary = TempDiary(diaryId, imageURLs) + +internal fun WriteDiaryResponse.toDomain(): Long = diaryId