diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 20896b86..758a04ff 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -145,10 +145,16 @@ android:screenOrientation="portrait" /> + + + (R.layout.activity_profile_edit) { + private val viewModel by viewModels() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + setEtNameArguments() + setEtInfoArguments() + getUserInfo() + observeNameTextChanged() + observeInfoTextChanged() + observeIsValueChanged() + initBackBtnClickListener() + } + + private fun setEtNameArguments() { + with(binding.etProfileEditNickname) { + setMaxLen(viewModel.getMaxNameLen()) + overWarning = getString(R.string.name_over_error) + blankWarning = getString(R.string.name_blank_error) + } + } + + private fun setEtInfoArguments() { + with(binding.etProfileEditInfo) { + setMaxLen(viewModel.getMaxInfoLen()) + overWarning = getString(R.string.info_over_error) + } + } + + private fun observeNameTextChanged() { + binding.etProfileEditNickname.editText.doAfterTextChanged { name -> + viewModel.checkIsNameChanged(name.toString()) + } + } + + private fun observeInfoTextChanged() { + binding.etProfileEditInfo.editText.doAfterTextChanged { info -> + viewModel.checkIsInfoChanged(info.toString()) + } + } + + private fun getUserInfo() { + val name = intent.getStringExtra(NICKNAME) + val info = intent.getStringExtra(INFO) + + with(binding) { + etProfileEditNickname.editText.setText(name) + etProfileEditInfo.editText.setText(info) + } + viewModel.setDefaultValues(name.orEmpty(), info.orEmpty()) + } + + private fun observeIsValueChanged() { + viewModel.isValueChanged.flowWithLifecycle(lifecycle).onEach { state -> + binding.btnProfileEditFinish.isEnabled = state + }.launchIn(lifecycleScope) + } + + private fun initBackBtnClickListener() { + binding.btnProfileEditBack.setOnSingleClickListener { + finish() + } + } + + companion object { + private const val NICKNAME = "NICKNAME" + private const val INFO = "INFO" + + @JvmStatic + fun createIntent( + context: Context, + nickName: String, + info: String, + ): Intent = Intent(context, ProfileEditActivity::class.java).apply { + putExtra(NICKNAME, nickName) + putExtra(INFO, info) + } + } +} \ No newline at end of file diff --git a/presentation/src/main/java/com/going/presentation/profile/edit/ProfileEditViewModel.kt b/presentation/src/main/java/com/going/presentation/profile/edit/ProfileEditViewModel.kt new file mode 100644 index 00000000..42b5bee7 --- /dev/null +++ b/presentation/src/main/java/com/going/presentation/profile/edit/ProfileEditViewModel.kt @@ -0,0 +1,50 @@ +package com.going.presentation.profile.edit + +import androidx.lifecycle.ViewModel +import com.going.presentation.onboarding.signup.SignUpViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow + +class ProfileEditViewModel : ViewModel() { + private val _isValueChanged = MutableStateFlow(false) + val isValueChanged: StateFlow = _isValueChanged + + private var isNameChanged = false + private var isInfoChanged = false + + private lateinit var nowName: String + private lateinit var nowInfo: String + private lateinit var defaultName: String + private lateinit var defaultInfo: String + + fun setDefaultValues(name: String, info: String) { + nowName = name + nowInfo = info + + defaultName = name + defaultInfo = info + } + + fun checkIsNameChanged(name: String) { + nowName = name + isNameChanged = name != defaultName + + checkIsValueChanged() + } + + fun checkIsInfoChanged(info: String) { + nowInfo = info + isInfoChanged = info != defaultInfo + + checkIsValueChanged() + } + + private fun checkIsValueChanged() { + _isValueChanged.value = + nowName.length <= getMaxNameLen() && nowInfo.length <= getMaxInfoLen() && (isInfoChanged || isNameChanged) + } + + fun getMaxNameLen() = SignUpViewModel.MAX_NAME_LEN + + fun getMaxInfoLen() = SignUpViewModel.MAX_INFO_LEN +} diff --git a/presentation/src/main/java/com/going/presentation/profile/ProfileActivity.kt b/presentation/src/main/java/com/going/presentation/profile/my/ProfileActivity.kt similarity index 88% rename from presentation/src/main/java/com/going/presentation/profile/ProfileActivity.kt rename to presentation/src/main/java/com/going/presentation/profile/my/ProfileActivity.kt index a1900c3d..5d7e5b1e 100644 --- a/presentation/src/main/java/com/going/presentation/profile/ProfileActivity.kt +++ b/presentation/src/main/java/com/going/presentation/profile/my/ProfileActivity.kt @@ -1,7 +1,6 @@ -package com.going.presentation.profile +package com.going.presentation.profile.my import android.Manifest -import android.content.Intent import android.content.pm.PackageManager import android.os.Bundle import androidx.activity.viewModels @@ -13,17 +12,16 @@ import coil.transform.CircleCropTransformation import com.going.presentation.R import com.going.presentation.databinding.ActivityProfileBinding import com.going.presentation.designsystem.textview.ChartTextView +import com.going.presentation.profile.edit.ProfileEditActivity import com.going.presentation.tendency.result.TendencyResultActivity.Companion.PERMISSION_REQUEST_CODE import com.going.presentation.tendency.result.UserTendencyResultList import com.going.presentation.tendency.splash.TendencySplashActivity import com.going.presentation.util.downloadImage -import com.going.presentation.util.navigateToScreen import com.going.presentation.util.navigateToScreenClear import com.going.ui.base.BaseActivity -import com.going.ui.state.UiState -import com.going.ui.extension.setBulletPoint import com.going.ui.extension.setOnSingleClickListener import com.going.ui.extension.toast +import com.going.ui.state.UiState import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -38,9 +36,10 @@ class ProfileActivity : getUserInfo() observeUserInfoState() - initRestartBtnClickListener() initBackBtnClickListener() initSaveImgBtnClickListener() + initProfileEditBtnClickListener() + initRestartBtnClickListener() } private fun getUserInfo() { @@ -75,6 +74,8 @@ class ProfileActivity : tvProfileType.text = profileTitle tvProfileSubType.text = profileSubTitle + ivProfileBig.load(resultImage) + tvProfileTag1.text = getString(R.string.tag, tags[0]) tvProfileTag2.text = getString(R.string.tag, tags[1]) tvProfileTag3.text = getString(R.string.tag, tags[2]) @@ -108,9 +109,9 @@ class ProfileActivity : } } - private fun initRestartBtnClickListener() { - binding.tvProfileRestart.setOnSingleClickListener { - navigateToScreenClear() + private fun initBackBtnClickListener() { + binding.btnProfileBack.setOnSingleClickListener { + finish() } } @@ -120,9 +121,21 @@ class ProfileActivity : } } - private fun initBackBtnClickListener() { - binding.btnProfileBack.setOnSingleClickListener { - finish() + private fun initProfileEditBtnClickListener() { + binding.btnProfileEdit.setOnSingleClickListener { + ProfileEditActivity.createIntent( + this, + binding.tvProfileName.text.toString(), + binding.tvProfileOneLine.text.toString() + ).apply { + startActivity(this) + } + } + } + + private fun initRestartBtnClickListener() { + binding.btnProfileRestart.setOnSingleClickListener { + navigateToScreenClear() } } diff --git a/presentation/src/main/java/com/going/presentation/profile/ProfileViewModel.kt b/presentation/src/main/java/com/going/presentation/profile/my/ProfileViewModel.kt similarity index 96% rename from presentation/src/main/java/com/going/presentation/profile/ProfileViewModel.kt rename to presentation/src/main/java/com/going/presentation/profile/my/ProfileViewModel.kt index 37f00dd1..dd390654 100644 --- a/presentation/src/main/java/com/going/presentation/profile/ProfileViewModel.kt +++ b/presentation/src/main/java/com/going/presentation/profile/my/ProfileViewModel.kt @@ -1,4 +1,4 @@ -package com.going.presentation.profile +package com.going.presentation.profile.my import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope diff --git a/presentation/src/main/java/com/going/presentation/setting/SettingActivity.kt b/presentation/src/main/java/com/going/presentation/setting/SettingActivity.kt index e135d880..9db92953 100644 --- a/presentation/src/main/java/com/going/presentation/setting/SettingActivity.kt +++ b/presentation/src/main/java/com/going/presentation/setting/SettingActivity.kt @@ -3,21 +3,17 @@ package com.going.presentation.setting import android.content.Intent import android.net.Uri import android.os.Bundle -import androidx.activity.viewModels import com.going.presentation.R import com.going.presentation.databinding.ActivitySettingBinding -import com.going.presentation.profile.ProfileActivity -import com.going.presentation.profile.ProfileViewModel -import com.going.presentation.util.openWebView +import com.going.presentation.profile.my.ProfileActivity import com.going.presentation.util.navigateToScreen +import com.going.presentation.util.openWebView import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint class SettingActivity : BaseActivity(R.layout.activity_setting) { - private val profileViewModel by viewModels() - private var quitDialog: SettingQuitDialogFragment? = null private var logoutDialog: SettingLogoutDialogFragment? = null diff --git a/presentation/src/main/java/com/going/presentation/tendency/splash/TendencySplashActivity.kt b/presentation/src/main/java/com/going/presentation/tendency/splash/TendencySplashActivity.kt index 5ec81890..0be8bd4a 100644 --- a/presentation/src/main/java/com/going/presentation/tendency/splash/TendencySplashActivity.kt +++ b/presentation/src/main/java/com/going/presentation/tendency/splash/TendencySplashActivity.kt @@ -1,12 +1,12 @@ package com.going.presentation.tendency.splash -import android.content.Intent import android.os.Bundle import com.going.presentation.R +import com.going.presentation.dashboard.DashBoardActivity import com.going.presentation.databinding.ActivityTendencySplashBinding import com.going.presentation.tendency.ttest.TendencyTestActivity import com.going.presentation.util.initOnBackPressedListener -import com.going.presentation.util.navigateToScreen +import com.going.presentation.util.navigateToScreenClear import com.going.ui.base.BaseActivity import com.going.ui.extension.setOnSingleClickListener @@ -16,13 +16,18 @@ class TendencySplashActivity : override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + initSkipBtnClickListener() initStartBtnClickListener() initOnBackPressedListener(binding.root) } - private fun initStartBtnClickListener() { + private fun initSkipBtnClickListener() = + binding.btnTendencySplashSkip.setOnSingleClickListener { + navigateToScreenClear() + } + + private fun initStartBtnClickListener() = binding.btnTendencySplashStart.setOnSingleClickListener { - navigateToScreen(listOf(Intent.FLAG_ACTIVITY_CLEAR_TOP)) + navigateToScreenClear() } - } } diff --git a/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt b/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt index ebc35d16..51fb07e1 100644 --- a/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt +++ b/presentation/src/main/java/com/going/presentation/todo/mytodo/MyTodoFragment.kt @@ -16,7 +16,7 @@ import androidx.lifecycle.lifecycleScope import androidx.viewpager2.widget.ViewPager2 import com.going.presentation.R import com.going.presentation.databinding.FragmentMyTodoBinding -import com.going.presentation.profile.ProfileActivity +import com.going.presentation.profile.my.ProfileActivity import com.going.presentation.todo.TodoActivity.Companion.EXTRA_TRIP_ID import com.going.presentation.todo.create.TodoCreateActivity import com.going.presentation.todo.mytodo.todolist.MyTodoViewPagerAdapter diff --git a/presentation/src/main/res/drawable/ic_delete.xml b/presentation/src/main/res/drawable/ic_delete.xml new file mode 100644 index 00000000..f6db5bb4 --- /dev/null +++ b/presentation/src/main/res/drawable/ic_delete.xml @@ -0,0 +1,13 @@ + + + + diff --git a/presentation/src/main/res/drawable/shape_rect_4_gray50_fill_gray100_line.xml b/presentation/src/main/res/drawable/shape_rect_4_gray50_fill_gray100_line.xml new file mode 100644 index 00000000..49ff0b19 --- /dev/null +++ b/presentation/src/main/res/drawable/shape_rect_4_gray50_fill_gray100_line.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_profile.xml b/presentation/src/main/res/layout/activity_profile.xml index 297653d1..a67ea5d2 100644 --- a/presentation/src/main/res/layout/activity_profile.xml +++ b/presentation/src/main/res/layout/activity_profile.xml @@ -13,7 +13,7 @@ android:background="@color/white_000"> + app:layout_constraintTop_toBottomOf="@id/tb_profile"> - + + + app:layout_constraintTop_toBottomOf="@id/iv_profile" /> + + app:layout_constraintTop_toBottomOf="@id/iv_profile_big" /> @@ -250,7 +274,7 @@ android:layout_height="17dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tv_profile_restart" /> + app:layout_constraintTop_toBottomOf="@id/btn_profile_restart" /> diff --git a/presentation/src/main/res/layout/activity_profile_edit.xml b/presentation/src/main/res/layout/activity_profile_edit.xml new file mode 100644 index 00000000..b3a2a52f --- /dev/null +++ b/presentation/src/main/res/layout/activity_profile_edit.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/presentation/src/main/res/layout/activity_sign_up.xml b/presentation/src/main/res/layout/activity_sign_up.xml index e6d6d42e..39e1ef39 100644 --- a/presentation/src/main/res/layout/activity_sign_up.xml +++ b/presentation/src/main/res/layout/activity_sign_up.xml @@ -13,20 +13,39 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + app:layout_constraintTop_toTopOf="parent"> + + + + + + + + + + 여행을 할 때 우리는 어떤 모습일까? 9개의 질문으로\n나를 대신할 여행 캐릭터를 찾아보세요 테스트 시작하기 + 테스트 건너뛰기 나의 여행 캐릭터는? @@ -173,6 +174,7 @@ 나는 두릅이 좋다. 다시 해볼래요 존재하지 않는 여행입니다. + 프로필 수정 이미지가 저장되었어요\n친구들에게 공유해보세요! 이미지를 저장할 수 없습니다\n안드로이드 버전을 확인해주세요