diff --git a/android/app/src/main/java/com/happy/friendogly/data/mapper/MemberMapper.kt b/android/app/src/main/java/com/happy/friendogly/data/mapper/MemberMapper.kt index 6d97f80b4..f55ff3c3d 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/mapper/MemberMapper.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/mapper/MemberMapper.kt @@ -9,5 +9,6 @@ fun MemberDto.toDomain(): Member { name = name, tag = tag, email = email, + imageUrl = imageUrl, ) } diff --git a/android/app/src/main/java/com/happy/friendogly/data/model/MemberDto.kt b/android/app/src/main/java/com/happy/friendogly/data/model/MemberDto.kt index d0401af6d..819fdc5fa 100644 --- a/android/app/src/main/java/com/happy/friendogly/data/model/MemberDto.kt +++ b/android/app/src/main/java/com/happy/friendogly/data/model/MemberDto.kt @@ -5,4 +5,5 @@ data class MemberDto( val name: String, val tag: String, val email: String, + val imageUrl: String, ) diff --git a/android/app/src/main/java/com/happy/friendogly/domain/model/Member.kt b/android/app/src/main/java/com/happy/friendogly/domain/model/Member.kt index 043d2bf92..3e9fca4d4 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/model/Member.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/model/Member.kt @@ -5,4 +5,5 @@ data class Member( val name: String, val tag: String, val email: String, + val imageUrl: String, ) diff --git a/android/app/src/main/java/com/happy/friendogly/domain/model/Pet.kt b/android/app/src/main/java/com/happy/friendogly/domain/model/Pet.kt index 17807a3a5..f56d932bb 100644 --- a/android/app/src/main/java/com/happy/friendogly/domain/model/Pet.kt +++ b/android/app/src/main/java/com/happy/friendogly/domain/model/Pet.kt @@ -18,6 +18,7 @@ data class Pet( ) { val age: Int get() { + val currentDate = getCurrentDate() return if (isAtLeastOneYearOld) { currentDate.year - birthDate.year } else { @@ -26,11 +27,15 @@ data class Pet( } val isAtLeastOneYearOld: Boolean - get() = currentDate.year - birthDate.year > 0 + get() = getCurrentDate().year - birthDate.year > MINIMUM_AGE + + private fun getCurrentDate(): LocalDate { + val now: Instant = Clock.System.now() + val timeZone = TimeZone.currentSystemDefault() + return now.toLocalDateTime(timeZone).date + } companion object { - private val now: Instant = Clock.System.now() - private val timeZone = TimeZone.currentSystemDefault() - private val currentDate = now.toLocalDateTime(timeZone).date + const val MINIMUM_AGE = 0 } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivity.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivity.kt index de1817a32..a8b672035 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivity.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivity.kt @@ -18,6 +18,8 @@ import com.happy.friendogly.presentation.ui.mypage.MyPageFragment import com.happy.friendogly.presentation.ui.permission.MultiPermission import com.happy.friendogly.presentation.ui.petdetail.PetDetailActivity import com.happy.friendogly.presentation.ui.petdetail.PetsDetail +import com.happy.friendogly.presentation.ui.profilesetting.ProfileSettingActivity +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile import com.happy.friendogly.presentation.ui.registerdog.RegisterDogActivity import com.happy.friendogly.presentation.ui.setting.SettingActivity import com.happy.friendogly.presentation.ui.woof.WoofFragment @@ -102,6 +104,10 @@ class MainActivity : startActivity(RegisterDogActivity.getIntent(this)) } + override fun navigateToProfileSetting(profile: Profile?) { + startActivity(ProfileSettingActivity.getIntent(this, profile)) + } + override fun navigateToPetDetail( currentPage: Int, petsDetail: PetsDetail, diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivityActionHandler.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivityActionHandler.kt index e69f70d87..f5b23cf63 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivityActionHandler.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/MainActivityActionHandler.kt @@ -1,6 +1,7 @@ package com.happy.friendogly.presentation.ui import com.happy.friendogly.presentation.ui.petdetail.PetsDetail +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile interface MainActivityActionHandler { fun navigateToGroupDetailActivity(groupId: Long) @@ -9,6 +10,8 @@ interface MainActivityActionHandler { fun navigateToRegisterDog() + fun navigateToProfileSetting(profile: Profile?) + fun navigateToPetDetail( currentPage: Int, petsDetail: PetsDetail, diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageFragment.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageFragment.kt index beb8ae961..3df47aded 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageFragment.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageFragment.kt @@ -54,7 +54,9 @@ class MyPageFragment : BaseFragment(R.layout.fragment_my_ is MyPageNavigationAction.NavigateToDogRegister -> (activity as MainActivityActionHandler).navigateToRegisterDog() - is MyPageNavigationAction.NavigateToProfileEdit -> {} + is MyPageNavigationAction.NavigateToProfileEdit -> + (activity as MainActivityActionHandler).navigateToProfileSetting(profile = action.profile) + is MyPageNavigationAction.NavigateToMyClubManger -> {} is MyPageNavigationAction.NavigateToMyParticipation -> {} is MyPageNavigationAction.NavigateToPetEdit -> {} diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageNavigationAction.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageNavigationAction.kt index 99b40a10d..aa1794db9 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageNavigationAction.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageNavigationAction.kt @@ -1,9 +1,10 @@ package com.happy.friendogly.presentation.ui.mypage import com.happy.friendogly.presentation.ui.petdetail.PetsDetail +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile sealed interface MyPageNavigationAction { - data object NavigateToProfileEdit : MyPageNavigationAction + data class NavigateToProfileEdit(val profile: Profile?) : MyPageNavigationAction data object NavigateToSetting : MyPageNavigationAction diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageUiState.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageUiState.kt index ab885daf7..7074a38b6 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageUiState.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageUiState.kt @@ -7,16 +7,19 @@ import kotlinx.datetime.Clock import kotlinx.datetime.Instant import kotlinx.datetime.TimeZone import kotlinx.datetime.toLocalDateTime -import java.time.LocalDate data class MyPageUiState( - val id: Long = -1, + val id: Long = INVALID_ID, val nickname: String = "", val email: String = "", val tag: String = "", - val profilePath: String? = null, + val imageUrl: String? = null, val pets: List = emptyList(), -) +) { + companion object { + private const val INVALID_ID = -1L + } +} sealed interface PetViewType { val id: Long @@ -33,6 +36,7 @@ data class PetView( ) : PetViewType { val age: Int get() { + val currentDate = getCurrentDate() return if (isAtLeastOneYearOld) { currentDate.year - birthDate.year } else { @@ -41,12 +45,16 @@ data class PetView( } val isAtLeastOneYearOld: Boolean - get() = currentDate.year - birthDate.year > 0 + get() = getCurrentDate().year - birthDate.year > MINIMUM_AGE + + private fun getCurrentDate(): kotlinx.datetime.LocalDate { + val now: Instant = Clock.System.now() + val timeZone = TimeZone.currentSystemDefault() + return now.toLocalDateTime(timeZone).date + } companion object { - private val now: Instant = Clock.System.now() - private val timeZone = TimeZone.currentSystemDefault() - private val currentDate = now.toLocalDateTime(timeZone).date + const val MINIMUM_AGE = 0 fun from(pet: Pet): PetView { return PetView( @@ -70,14 +78,3 @@ data class PetAddView( private const val INVALID_ID = -1L } } - -// TODO 더미 데이터 모델 -data class Dog( - val name: String, - val description: String, - val birthDate: LocalDate, - val sizeType: String, - val gender: String, - val isNeutered: Boolean, - val image: String, -) diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageViewModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageViewModel.kt index c6fa5677e..e189ee308 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageViewModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/mypage/MyPageViewModel.kt @@ -12,6 +12,7 @@ import com.happy.friendogly.presentation.base.Event import com.happy.friendogly.presentation.base.emit import com.happy.friendogly.presentation.ui.petdetail.PetDetail import com.happy.friendogly.presentation.ui.petdetail.PetsDetail +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile import kotlinx.coroutines.launch class MyPageViewModel( @@ -44,6 +45,7 @@ class MyPageViewModel( nickname = member.name, email = member.email, tag = member.tag, + imageUrl = member.imageUrl, ) }.onFailure { // TODO 예외 처리 @@ -100,7 +102,13 @@ class MyPageViewModel( } override fun navigateToProfileEdit() { - _navigateAction.emit(MyPageNavigationAction.NavigateToProfileEdit) + val state = uiState.value ?: return + val profile = + Profile( + name = state.nickname, + imageUrl = state.imageUrl, + ) + _navigateAction.emit(MyPageNavigationAction.NavigateToProfileEdit(profile = profile)) } fun navigateToSetting() { diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailBindingAdapters.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailBindingAdapters.kt index 70a64b821..3faca584a 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailBindingAdapters.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailBindingAdapters.kt @@ -62,7 +62,7 @@ fun ImageView.bindGenderDrawable(gender: Gender) { fun TextView.bindNeuteredTitle(gender: Gender) { when (gender) { Gender.MALE_NEUTERED, Gender.FEMALE_NEUTERED -> { - text = "중성화를 했어요" + text = context.getString(R.string.neuterd_status) visibility = View.VISIBLE } @@ -74,9 +74,9 @@ fun TextView.bindNeuteredTitle(gender: Gender) { fun TextView.bindDogSize(sizeType: SizeType) { text = when (sizeType) { - SizeType.SMALL -> "소형견이에요" - SizeType.MEDIUM -> "중현견이에요" - SizeType.LARGE -> "대형견이에요" + SizeType.SMALL -> context.getString(R.string.small_pet_description) + SizeType.MEDIUM -> context.getString(R.string.medium_pet_description) + SizeType.LARGE -> context.getString(R.string.large_pet_description) } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailUiState.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailUiState.kt index 48bf0579a..08dd7ed7f 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailUiState.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/petdetail/PetDetailUiState.kt @@ -30,6 +30,7 @@ data class PetDetail( ) { val age: Int get() { + val currentDate = getCurrentDate() return if (isAtLeastOneYearOld) { currentDate.year - birthDate.year } else { @@ -38,11 +39,15 @@ data class PetDetail( } val isAtLeastOneYearOld: Boolean - get() = currentDate.year - birthDate.year > 0 + get() = getCurrentDate().year - birthDate.year > MINIMUM_AGE + + private fun getCurrentDate(): LocalDate { + val now: Instant = Clock.System.now() + val timeZone = TimeZone.currentSystemDefault() + return now.toLocalDateTime(timeZone).date + } companion object { - private val now: Instant = Clock.System.now() - private val timeZone = TimeZone.currentSystemDefault() - private val currentDate = now.toLocalDateTime(timeZone).date + const val MINIMUM_AGE = 0 } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfieSettingBindingAdapters.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfieSettingBindingAdapters.kt index 64c18e51c..e7ff05452 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfieSettingBindingAdapters.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfieSettingBindingAdapters.kt @@ -6,6 +6,16 @@ import androidx.core.content.ContextCompat import androidx.databinding.BindingAdapter import com.happy.friendogly.R +@BindingAdapter("profileSettingTitle") +fun TextView.bindProfileSettingTitle(isFirstTimeSetup: Boolean) { + text = + if (isFirstTimeSetup) { + context.getString(R.string.make_profile_title) + } else { + context.getString(R.string.make_profile_edit_title) + } +} + @SuppressLint("SetTextI18n") @BindingAdapter("editTextLength") fun TextView.bindEditTextLength(contents: String?) { @@ -19,17 +29,15 @@ fun TextView.bindEditTextLength(contents: String?) { } this.apply { - text = "$length/15" + text = context.getString(R.string.user_name_length, length) setTextColor(color) } } @SuppressLint("UseCompatLoadingForDrawables") @BindingAdapter("editBtnBackgroundTextColor") -fun TextView.bindEditBtnBackground(contents: String?) { - val length = contents?.length ?: 0 - - if (length > 0) { +fun TextView.bindEditBtnBackground(isButtonActive: Boolean) { + if (isButtonActive) { this.background = context.getDrawable(R.drawable.rect_coral04_fill_16) this.setTextColor(context.getColor(R.color.gray100)) } else { diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingActivity.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingActivity.kt index a58f566ff..b9429d41b 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingActivity.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingActivity.kt @@ -18,8 +18,10 @@ import com.happy.friendogly.presentation.base.BaseActivity import com.happy.friendogly.presentation.base.observeEvent import com.happy.friendogly.presentation.ui.MainActivity import com.happy.friendogly.presentation.ui.profilesetting.bottom.EditProfileImageBottomSheet +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile import com.happy.friendogly.presentation.utils.customOnFocusChangeListener import com.happy.friendogly.presentation.utils.hideKeyboard +import com.happy.friendogly.presentation.utils.putSerializable import com.happy.friendogly.presentation.utils.saveBitmapToFile import com.happy.friendogly.presentation.utils.toBitmap import com.happy.friendogly.presentation.utils.toMultipartBody @@ -122,8 +124,16 @@ class ProfileSettingActivity : } companion object { - fun getIntent(context: Context): Intent { - return Intent(context, ProfileSettingActivity::class.java) + const val PUT_EXTRA_PROFILE = "PUT_EXTRA_PROFILE" + + fun getIntent( + context: Context, + profile: Profile?, + ): Intent { + return Intent(context, ProfileSettingActivity::class.java).apply { + profile ?: return@apply + putSerializable(PUT_EXTRA_PROFILE, profile, Profile.serializer()) + } } } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingUiState.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingUiState.kt index 511319910..9434ecdc9 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingUiState.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingUiState.kt @@ -4,6 +4,10 @@ import android.graphics.Bitmap import okhttp3.MultipartBody data class ProfileSettingUiState( + val isFirstTimeSetup: Boolean = true, + val beforeName: String = "", + val beforeProfileImageUrl: String? = null, val profileImage: Bitmap? = null, + val profileImageUrl: String? = null, val profilePath: MultipartBody.Part? = null, ) diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingViewModel.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingViewModel.kt index 63f43479c..596fa3aa1 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingViewModel.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/ProfileSettingViewModel.kt @@ -2,8 +2,11 @@ package com.happy.friendogly.presentation.ui.profilesetting import android.graphics.Bitmap import androidx.lifecycle.LiveData +import androidx.lifecycle.MediatorLiveData import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.createSavedStateHandle import androidx.lifecycle.viewModelScope import com.happy.friendogly.domain.model.JwtToken import com.happy.friendogly.domain.usecase.PostMemberUseCase @@ -12,10 +15,14 @@ import com.happy.friendogly.presentation.base.BaseViewModel import com.happy.friendogly.presentation.base.BaseViewModelFactory import com.happy.friendogly.presentation.base.Event import com.happy.friendogly.presentation.base.emit +import com.happy.friendogly.presentation.ui.profilesetting.model.Profile +import com.happy.friendogly.presentation.utils.addSourceList +import com.happy.friendogly.presentation.utils.getSerializable import kotlinx.coroutines.launch import okhttp3.MultipartBody class ProfileSettingViewModel( + private val savedStateHandle: SavedStateHandle, private val postMemberUseCase: PostMemberUseCase, private val saveJwtTokenUseCase: SaveJwtTokenUseCase, ) : BaseViewModel() { @@ -25,10 +32,47 @@ class ProfileSettingViewModel( val nickname = MutableLiveData("") + val isButtonActive = + MediatorLiveData().apply { + addSourceList( + nickname, + uiState, + ) { + val state = uiState.value ?: return@addSourceList false + val nickname = nickname.value ?: return@addSourceList false + + !((nickname == state.beforeName || nickname.isBlank()) && state.profileImageUrl == state.beforeProfileImageUrl) + } + } + private val _navigateAction: MutableLiveData> = MutableLiveData(null) val navigateAction: LiveData> get() = _navigateAction + init { + fetchProfile() + } + + private fun fetchProfile() { + val profile = + savedStateHandle.getSerializable( + ProfileSettingActivity.PUT_EXTRA_PROFILE, + Profile.serializer(), + ) + profile ?: return + + val state = uiState.value ?: return + + nickname.value = profile.name + _uiState.value = + state.copy( + isFirstTimeSetup = false, + beforeName = profile.name, + profileImageUrl = profile.imageUrl, + beforeProfileImageUrl = profile.imageUrl, + ) + } + fun selectProfileImage() { _navigateAction.emit(ProfileSettingNavigationAction.NavigateToSetProfileImage) } @@ -38,21 +82,32 @@ class ProfileSettingViewModel( val nickname = nickname.value ?: return@launch if (nickname.isBlank()) return@launch if (regex.matches(nickname)) return@launch - val profilePath = _uiState.value?.profilePath - - // TODO email 필드는 임시로 넣어두었습니다. - postMemberUseCase( - name = nickname, - email = "test@banggapge.com", - file = _uiState.value?.profilePath, - ).onSuccess { member -> - saveJwaToken(member.id) - }.onFailure { - // TODO 예외처리 + val state = uiState.value ?: return@launch + + if (state.isFirstTimeSetup) { + postMember(nickname, state.profilePath) + } else { + patchMember(nickname, state.profilePath) } } } + private suspend fun postMember( + nickname: String, + profilePath: MultipartBody.Part?, + ) { + // TODO email 필드는 임시로 넣어두었습니다. + postMemberUseCase( + name = nickname, + email = "test@banggapge.com", + file = profilePath, + ).onSuccess { member -> + saveJwaToken(member.id) + }.onFailure { + // TODO 예외처리 + } + } + private suspend fun saveJwaToken(memberId: Long) { val jwtToken = JwtToken(accessToken = memberId.toString(), refreshToken = null) saveJwtTokenUseCase(jwtToken = jwtToken).onSuccess { @@ -62,14 +117,21 @@ class ProfileSettingViewModel( } } + private suspend fun patchMember( + nickname: String, + profilePath: MultipartBody.Part?, + ) { + // TODO patch use case 호출 예정 + } + fun updateProfileImage(bitmap: Bitmap) { val state = _uiState.value ?: return - _uiState.value = state.copy(profileImage = bitmap) + _uiState.value = state.copy(profileImage = bitmap, profileImageUrl = null) } fun resetProfileImage() { val state = _uiState.value ?: return - _uiState.value = state.copy(profileImage = null) + _uiState.value = state.copy(profileImage = null, profileImageUrl = null) } fun updateProfileFile(file: MultipartBody.Part) { @@ -84,8 +146,9 @@ class ProfileSettingViewModel( postMemberUseCase: PostMemberUseCase, saveJwtTokenUseCase: SaveJwtTokenUseCase, ): ViewModelProvider.Factory { - return BaseViewModelFactory { _ -> + return BaseViewModelFactory { creator -> ProfileSettingViewModel( + savedStateHandle = creator.createSavedStateHandle(), postMemberUseCase = postMemberUseCase, saveJwtTokenUseCase = saveJwtTokenUseCase, ) diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/model/Profile.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/model/Profile.kt new file mode 100644 index 000000000..3ab62ab8f --- /dev/null +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/profilesetting/model/Profile.kt @@ -0,0 +1,9 @@ +package com.happy.friendogly.presentation.ui.profilesetting.model + +import kotlinx.serialization.Serializable + +@Serializable +data class Profile( + val name: String, + val imageUrl: String?, +) diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/ui/register/RegisterActivity.kt b/android/app/src/main/java/com/happy/friendogly/presentation/ui/register/RegisterActivity.kt index 9af1467be..2f951d32f 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/ui/register/RegisterActivity.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/ui/register/RegisterActivity.kt @@ -72,7 +72,7 @@ class RegisterActivity : AppCompatActivity() { is RegisterNavigationAction.NavigateToProfileSetting -> startActivity( - ProfileSettingActivity.getIntent(this), + ProfileSettingActivity.getIntent(this, null), ) } } diff --git a/android/app/src/main/java/com/happy/friendogly/presentation/utils/GlideImageBindingAdapters.kt b/android/app/src/main/java/com/happy/friendogly/presentation/utils/GlideImageBindingAdapters.kt index 8e4dc98d3..4c6365ce0 100644 --- a/android/app/src/main/java/com/happy/friendogly/presentation/utils/GlideImageBindingAdapters.kt +++ b/android/app/src/main/java/com/happy/friendogly/presentation/utils/GlideImageBindingAdapters.kt @@ -42,7 +42,7 @@ fun ImageView.bindProfile1000(bitmap: Bitmap?) { @BindingAdapter("glideProfile1000") fun ImageView.bindProfile1000(profilePath: String?) { - if (profilePath == null) { + if (profilePath.isNullOrBlank()) { this.setImageResource(R.drawable.img_profile_normal) return } @@ -54,6 +54,32 @@ fun ImageView.bindProfile1000(profilePath: String?) { .into(this) } +@BindingAdapter("imageBitmap", "imageUrl") +fun ImageView.bindGlideProfileImage( + imageBitmap: Bitmap?, + imageUrl: String?, +) { + if (imageBitmap == null && imageUrl.isNullOrBlank()) { + this.setImageResource(R.drawable.img_profile_normal) + return + } + if (imageBitmap != null) { + val softwareBitmap = imageBitmap.toSoftwareBitmap() + + Glide.with(context) + .asBitmap() + .load(softwareBitmap) + .transform(CenterCrop(), RoundedCorners(1000)) + .into(this) + } else { + Glide.with(context) + .asBitmap() + .load(imageUrl) + .transform(CenterCrop(), RoundedCorners(1000)) + .into(this) + } +} + @BindingAdapter("dogProfile") fun ImageView.bindDogProfile(bitmap: Bitmap?) { if (bitmap == null) return diff --git a/android/app/src/main/java/com/happy/friendogly/remote/mapper/MemberDtoMapper.kt b/android/app/src/main/java/com/happy/friendogly/remote/mapper/MemberDtoMapper.kt index c181704cd..dd078ab57 100644 --- a/android/app/src/main/java/com/happy/friendogly/remote/mapper/MemberDtoMapper.kt +++ b/android/app/src/main/java/com/happy/friendogly/remote/mapper/MemberDtoMapper.kt @@ -9,5 +9,6 @@ fun MemberResponse.toData(): MemberDto { name = name, tag = tag, email = email, + imageUrl = imageUrl, ) } diff --git a/android/app/src/main/java/com/happy/friendogly/remote/model/response/MemberResponse.kt b/android/app/src/main/java/com/happy/friendogly/remote/model/response/MemberResponse.kt index 09943a4a6..7136cab66 100644 --- a/android/app/src/main/java/com/happy/friendogly/remote/model/response/MemberResponse.kt +++ b/android/app/src/main/java/com/happy/friendogly/remote/model/response/MemberResponse.kt @@ -8,4 +8,5 @@ data class MemberResponse( val name: String, val tag: String = "", val email: String, + val imageUrl: String, ) diff --git a/android/app/src/main/res/layout/activity_pet_detail.xml b/android/app/src/main/res/layout/activity_pet_detail.xml index ea9612645..4fb0275ad 100644 --- a/android/app/src/main/res/layout/activity_pet_detail.xml +++ b/android/app/src/main/res/layout/activity_pet_detail.xml @@ -17,26 +17,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - + + + + + + diff --git a/android/app/src/main/res/layout/activity_profile_setting.xml b/android/app/src/main/res/layout/activity_profile_setting.xml index d72a2ab0e..7b9befb66 100644 --- a/android/app/src/main/res/layout/activity_profile_setting.xml +++ b/android/app/src/main/res/layout/activity_profile_setting.xml @@ -25,13 +25,14 @@ + app:layout_constraintTop_toTopOf="parent" + tools:text="프로필 만들기" /> @@ -117,10 +119,10 @@ android:onClick="@{() -> vm.submitProfileSelection()}" android:padding="18dp" android:text="@string/make_profile_edit_btn_title" - app:editBtnBackgroundTextColor="@{vm.nickname}" + app:editBtnBackgroundTextColor="@{vm.isButtonActive}" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" - tools:background="@color/blue" /> + tools:background="@color/coral400" /> diff --git a/android/app/src/main/res/layout/fragment_my_page.xml b/android/app/src/main/res/layout/fragment_my_page.xml index 05c3d5052..5ae8cb816 100644 --- a/android/app/src/main/res/layout/fragment_my_page.xml +++ b/android/app/src/main/res/layout/fragment_my_page.xml @@ -35,10 +35,10 @@ @@ -196,11 +196,11 @@ 닉네임을 입력해주세요 프로필 사진 프로필 만들기 + 프로필 수정하기 선택 완료! + %d/15 뒤로가기 버튼을\n한번 더 누르면 종료됩니다. @@ -44,6 +46,12 @@ 함께하는 반려동물 강아지를 등록해주세요 + + 중성화를 했어요 + 소형견이에요 + 중현견이에요 + 대형견이에요 + 함께하는 반려동물이 없어요 취소