From 0dad5d565d1c78f4c696c477aa3108b97221b618 Mon Sep 17 00:00:00 2001 From: inseonyun Date: Tue, 8 Aug 2023 17:06:10 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20MyPage=EC=99=80=20Setting=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=20=EC=97=B0=EA=B2=B0=20=EB=B0=8F=20=ED=88=B4?= =?UTF-8?q?=EB=B0=94=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/myPage/MyPageFragment.kt | 2 ++ .../presentation/setting/SettingActivity.kt | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/android/app/src/main/java/com/created/team201/presentation/myPage/MyPageFragment.kt b/android/app/src/main/java/com/created/team201/presentation/myPage/MyPageFragment.kt index 929862792..765224cbb 100644 --- a/android/app/src/main/java/com/created/team201/presentation/myPage/MyPageFragment.kt +++ b/android/app/src/main/java/com/created/team201/presentation/myPage/MyPageFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.viewModels import com.created.team201.R import com.created.team201.databinding.FragmentMyPageBinding import com.created.team201.presentation.common.BindingFragment +import com.created.team201.presentation.setting.SettingActivity class MyPageFragment : BindingFragment(R.layout.fragment_my_page) { private val myPageViewModel: MyPageViewModel by viewModels { @@ -29,6 +30,7 @@ class MyPageFragment : BindingFragment(R.layout.fragment_ when (it.itemId) { R.id.menu_my_page_setting -> { // 설정 뷰 이동 + startActivity(SettingActivity.getIntent(requireContext())) true } diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt index 3ef442562..a0e855670 100644 --- a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt @@ -1,6 +1,9 @@ package com.created.team201.presentation.setting +import android.content.Context +import android.content.Intent import android.os.Bundle +import android.view.MenuItem import com.created.team201.R import com.created.team201.databinding.ActivitySettingBinding import com.created.team201.presentation.common.BindingActivity @@ -8,5 +11,28 @@ import com.created.team201.presentation.common.BindingActivity class SettingActivity : BindingActivity(R.layout.activity_setting) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + initActionBar() + } + + private fun initActionBar() { + setSupportActionBar(binding.tbSetting) + supportActionBar?.setHomeActionContentDescription(R.string.toolbar_back_text) + supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_back) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean = + when (item.itemId) { + android.R.id.home -> { + finish() + true + } + + else -> false + } + + companion object { + fun getIntent(context: Context): Intent = Intent(context, SettingActivity::class.java) } } From e84f6029f5909784abb2ded2add9b202a5e97b1e Mon Sep 17 00:00:00 2001 From: inseonyun Date: Tue, 8 Aug 2023 19:39:14 +0900 Subject: [PATCH 2/4] =?UTF-8?q?feat:=20Setting=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../accountSetting/AccountSettingActivity.kt | 29 +++++++++++++ .../presentation/setting/SettingActivity.kt | 42 ++++++++++++++++++- .../setting/SettingClickListener.kt | 5 +++ .../setting/adapter/SettingAdapter.kt | 42 +++++++++++++++++++ .../setting/adapter/SettingViewHolder.kt | 26 ++++++++++++ .../presentation/setting/model/SettingType.kt | 19 +++++++++ .../setting/model/SettingUiModel.kt | 6 +++ android/app/src/main/res/values/arrays.xml | 8 ++++ android/app/src/main/res/values/strings.xml | 4 ++ 9 files changed, 180 insertions(+), 1 deletion(-) create mode 100644 android/app/src/main/java/com/created/team201/presentation/setting/SettingClickListener.kt create mode 100644 android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingAdapter.kt create mode 100644 android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingViewHolder.kt create mode 100644 android/app/src/main/java/com/created/team201/presentation/setting/model/SettingType.kt create mode 100644 android/app/src/main/java/com/created/team201/presentation/setting/model/SettingUiModel.kt diff --git a/android/app/src/main/java/com/created/team201/presentation/accountSetting/AccountSettingActivity.kt b/android/app/src/main/java/com/created/team201/presentation/accountSetting/AccountSettingActivity.kt index f6e97db96..0a53dfcec 100644 --- a/android/app/src/main/java/com/created/team201/presentation/accountSetting/AccountSettingActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/accountSetting/AccountSettingActivity.kt @@ -1,6 +1,9 @@ package com.created.team201.presentation.accountSetting +import android.content.Context +import android.content.Intent import android.os.Bundle +import android.view.MenuItem import com.created.team201.R import com.created.team201.databinding.ActivityAccountSettingBinding import com.created.team201.presentation.common.BindingActivity @@ -9,5 +12,31 @@ class AccountSettingActivity : BindingActivity(R.layout.activity_account_setting) { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + initActionBar() + } + + private fun initActionBar() { + setSupportActionBar(binding.tbAccountSetting) + supportActionBar?.setHomeActionContentDescription(R.string.toolbar_back_text) + supportActionBar?.setHomeAsUpIndicator(R.drawable.ic_back) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean = + when (item.itemId) { + android.R.id.home -> { + finish() + true + } + + else -> false + } + + companion object { + fun getIntent(context: Context): Intent = + Intent(context, AccountSettingActivity::class.java).also { + it.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + } } } diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt index a0e855670..a86f4d3bf 100644 --- a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt @@ -6,13 +6,40 @@ import android.os.Bundle import android.view.MenuItem import com.created.team201.R import com.created.team201.databinding.ActivitySettingBinding +import com.created.team201.presentation.accountSetting.AccountSettingActivity import com.created.team201.presentation.common.BindingActivity +import com.created.team201.presentation.setting.adapter.SettingAdapter +import com.created.team201.presentation.setting.model.SettingType +import com.created.team201.presentation.setting.model.SettingUiModel class SettingActivity : BindingActivity(R.layout.activity_setting) { + private val settingItems: List by lazy { + resources.getStringArray(R.array.settingItems).mapIndexed { index, setting -> + SettingUiModel(index.toLong(), setting) + } + } + + private val onSettingItemClick: SettingClickListener by lazy { + object : SettingClickListener { + override fun onClick(itemId: Long) { + when (SettingType.valueOf(itemId)) { + SettingType.NOTIFICATION -> {} + SettingType.ACCOUNT -> { + navigateToAccountSetting() + } + + SettingType.POLICY -> {} + SettingType.LOGOUT -> {} + } + } + } + } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) initActionBar() + initSettingRecyclerView() } private fun initActionBar() { @@ -22,6 +49,16 @@ class SettingActivity : BindingActivity(R.layout.activit supportActionBar?.setDisplayHomeAsUpEnabled(true) } + private fun initSettingRecyclerView() { + binding.rvSetting.hasFixedSize() + binding.rvSetting.adapter = + SettingAdapter(onSettingItemClick).also { it.submitList(settingItems) } + } + + private fun navigateToAccountSetting() { + startActivity(AccountSettingActivity.getIntent(this)) + } + override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) { android.R.id.home -> { @@ -33,6 +70,9 @@ class SettingActivity : BindingActivity(R.layout.activit } companion object { - fun getIntent(context: Context): Intent = Intent(context, SettingActivity::class.java) + fun getIntent(context: Context): Intent = + Intent(context, SettingActivity::class.java).also { + it.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP + } } } diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/SettingClickListener.kt b/android/app/src/main/java/com/created/team201/presentation/setting/SettingClickListener.kt new file mode 100644 index 000000000..af951a3ec --- /dev/null +++ b/android/app/src/main/java/com/created/team201/presentation/setting/SettingClickListener.kt @@ -0,0 +1,5 @@ +package com.created.team201.presentation.setting + +interface SettingClickListener { + fun onClick(itemId: Long) +} diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingAdapter.kt b/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingAdapter.kt new file mode 100644 index 000000000..bfdc9ae6f --- /dev/null +++ b/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingAdapter.kt @@ -0,0 +1,42 @@ +package com.created.team201.presentation.setting.adapter + +import android.view.ViewGroup +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.ListAdapter +import com.created.team201.presentation.setting.SettingClickListener +import com.created.team201.presentation.setting.model.SettingUiModel + +class SettingAdapter( + private val settingClickListener: SettingClickListener +) : ListAdapter(SettingDiffUtil) { + + init { + setHasStableIds(true) + } + + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SettingViewHolder { + return SettingViewHolder(parent, settingClickListener) + } + + override fun onBindViewHolder(holder: SettingViewHolder, position: Int) { + holder.bind(getItem(position)) + } + + override fun getItemId(position: Int): Long = getItem(position).id + + companion object { + private val SettingDiffUtil = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame( + oldItem: SettingUiModel, + newItem: SettingUiModel, + ): Boolean = + oldItem.id == newItem.id + + override fun areContentsTheSame( + oldItem: SettingUiModel, + newItem: SettingUiModel, + ): Boolean = + oldItem == newItem + } + } +} diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingViewHolder.kt b/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingViewHolder.kt new file mode 100644 index 000000000..d6b4295b4 --- /dev/null +++ b/android/app/src/main/java/com/created/team201/presentation/setting/adapter/SettingViewHolder.kt @@ -0,0 +1,26 @@ +package com.created.team201.presentation.setting.adapter + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.created.team201.R +import com.created.team201.databinding.ItemSettingBinding +import com.created.team201.presentation.setting.SettingClickListener +import com.created.team201.presentation.setting.model.SettingUiModel + +class SettingViewHolder( + parent: ViewGroup, + settingClickListener: SettingClickListener +) : RecyclerView.ViewHolder( + LayoutInflater.from(parent.context).inflate(R.layout.item_setting, parent, false) +) { + private val binding = ItemSettingBinding.bind(itemView) + + init { + itemView.setOnClickListener { settingClickListener.onClick(itemId) } + } + + fun bind(setting: SettingUiModel) { + binding.tvSettingTitle.text = setting.title + } +} diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingType.kt b/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingType.kt new file mode 100644 index 000000000..54f533e44 --- /dev/null +++ b/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingType.kt @@ -0,0 +1,19 @@ +package com.created.team201.presentation.setting.model + +enum class SettingType(val itemId: Long) { + NOTIFICATION(0L), + ACCOUNT(1L), + POLICY(2L), + LOGOUT(3L); + + companion object { + fun valueOf(itemId: Long): SettingType = + when (itemId) { + 0L -> NOTIFICATION + 1L -> ACCOUNT + 2L -> POLICY + 3L -> LOGOUT + else -> throw IllegalArgumentException() + } + } +} diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingUiModel.kt b/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingUiModel.kt new file mode 100644 index 000000000..e29b84f1f --- /dev/null +++ b/android/app/src/main/java/com/created/team201/presentation/setting/model/SettingUiModel.kt @@ -0,0 +1,6 @@ +package com.created.team201.presentation.setting.model + +data class SettingUiModel( + val id: Long, + val title: String +) diff --git a/android/app/src/main/res/values/arrays.xml b/android/app/src/main/res/values/arrays.xml index 5ad67f228..37cac432c 100644 --- a/android/app/src/main/res/values/arrays.xml +++ b/android/app/src/main/res/values/arrays.xml @@ -34,4 +34,12 @@ @string/study_list_item_week_format + + + @string/setting_item_notification_title + @string/setting_item_account_title + @string/setting_item_policy + @string/setting_item_logout + + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index cb1dcb2db..b1145a12c 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -161,6 +161,10 @@ 설정 + 알림 설정 + 계정 관리 + 정책 및 약관 + 로그아웃 계정 관리 From f8fe17a8197a7a0e68671a51f9b0078d040a9c5c Mon Sep 17 00:00:00 2001 From: inseonyun Date: Wed, 9 Aug 2023 21:23:15 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=EB=A6=AC=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=ED=81=B4=EB=9F=AC=EB=B7=B0=20=EA=B5=AC=EB=B6=84=EC=84=A0=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team201/presentation/setting/SettingActivity.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt index a86f4d3bf..b0bcf8cc2 100644 --- a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt @@ -4,6 +4,8 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.MenuItem +import androidx.core.content.ContextCompat +import androidx.recyclerview.widget.DividerItemDecoration import com.created.team201.R import com.created.team201.databinding.ActivitySettingBinding import com.created.team201.presentation.accountSetting.AccountSettingActivity @@ -51,6 +53,13 @@ class SettingActivity : BindingActivity(R.layout.activit private fun initSettingRecyclerView() { binding.rvSetting.hasFixedSize() + + val decoration = DividerItemDecoration(this, DividerItemDecoration.VERTICAL) + ContextCompat.getDrawable(this, R.drawable.divider_study_list)?.let { + decoration.setDrawable(it) + } + + binding.rvSetting.addItemDecoration(decoration) binding.rvSetting.adapter = SettingAdapter(onSettingItemClick).also { it.submitList(settingItems) } } From ecfab20708e87c0be2794dcdf1eed6aad9ed6060 Mon Sep 17 00:00:00 2001 From: inseonyun Date: Wed, 9 Aug 2023 21:28:50 +0900 Subject: [PATCH 4/4] =?UTF-8?q?style:=20=EB=A6=AC=EC=82=AC=EC=9D=B4?= =?UTF-8?q?=ED=81=B4=EB=9F=AC=EB=B7=B0=20=EA=B5=AC=EB=B6=84=EC=84=A0=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/created/team201/presentation/profile/ProfileActivity.kt | 2 +- .../com/created/team201/presentation/setting/SettingActivity.kt | 2 +- .../created/team201/presentation/studyList/StudyListFragment.kt | 2 +- .../presentation/studyManage/adapter/StudyManageViewHolder.kt | 2 +- .../{divider_study_list.xml => divider_recyclerview_line.xml} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename android/app/src/main/res/drawable/{divider_study_list.xml => divider_recyclerview_line.xml} (100%) diff --git a/android/app/src/main/java/com/created/team201/presentation/profile/ProfileActivity.kt b/android/app/src/main/java/com/created/team201/presentation/profile/ProfileActivity.kt index fdd03ce5e..1c6aa3c66 100644 --- a/android/app/src/main/java/com/created/team201/presentation/profile/ProfileActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/profile/ProfileActivity.kt @@ -63,7 +63,7 @@ class ProfileActivity : BindingActivity(R.layout.activit private fun getDividerItemDecoration(): DividerItemDecoration { val dividerItemDecoration = DividerItemDecoration(this, LinearLayout.VERTICAL) - ContextCompat.getDrawable(this, R.drawable.divider_study_list)?.let { + ContextCompat.getDrawable(this, R.drawable.divider_recyclerview_line)?.let { dividerItemDecoration.setDrawable(it) } return dividerItemDecoration diff --git a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt index b0bcf8cc2..d696219f9 100644 --- a/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt +++ b/android/app/src/main/java/com/created/team201/presentation/setting/SettingActivity.kt @@ -55,7 +55,7 @@ class SettingActivity : BindingActivity(R.layout.activit binding.rvSetting.hasFixedSize() val decoration = DividerItemDecoration(this, DividerItemDecoration.VERTICAL) - ContextCompat.getDrawable(this, R.drawable.divider_study_list)?.let { + ContextCompat.getDrawable(this, R.drawable.divider_recyclerview_line)?.let { decoration.setDrawable(it) } diff --git a/android/app/src/main/java/com/created/team201/presentation/studyList/StudyListFragment.kt b/android/app/src/main/java/com/created/team201/presentation/studyList/StudyListFragment.kt index fb604c5be..5c5bb16eb 100644 --- a/android/app/src/main/java/com/created/team201/presentation/studyList/StudyListFragment.kt +++ b/android/app/src/main/java/com/created/team201/presentation/studyList/StudyListFragment.kt @@ -58,7 +58,7 @@ class StudyListFragment : BindingFragment(R.layout.fra private fun setUpStudyListSettings() { val dividerItemDecoration = DividerItemDecoration(context, VERTICAL) - getDrawable(requireContext(), R.drawable.divider_study_list)?.let { + getDrawable(requireContext(), R.drawable.divider_recyclerview_line)?.let { dividerItemDecoration.setDrawable(it) } diff --git a/android/app/src/main/java/com/created/team201/presentation/studyManage/adapter/StudyManageViewHolder.kt b/android/app/src/main/java/com/created/team201/presentation/studyManage/adapter/StudyManageViewHolder.kt index e8d956a1d..7e200f4e1 100644 --- a/android/app/src/main/java/com/created/team201/presentation/studyManage/adapter/StudyManageViewHolder.kt +++ b/android/app/src/main/java/com/created/team201/presentation/studyManage/adapter/StudyManageViewHolder.kt @@ -29,7 +29,7 @@ class StudyManageViewHolder( private fun setUpStudyManageList() { val dividerItemDecoration = DividerItemDecoration(parent.context, VERTICAL) - getDrawable(parent.context, R.drawable.divider_study_list)?.let { + getDrawable(parent.context, R.drawable.divider_recyclerview_line)?.let { dividerItemDecoration.setDrawable(it) } diff --git a/android/app/src/main/res/drawable/divider_study_list.xml b/android/app/src/main/res/drawable/divider_recyclerview_line.xml similarity index 100% rename from android/app/src/main/res/drawable/divider_study_list.xml rename to android/app/src/main/res/drawable/divider_recyclerview_line.xml