From c06dc528129bba9c42fcac6ca51879cb733123e8 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Thu, 22 Feb 2024 15:54:54 +0900 Subject: [PATCH 01/22] =?UTF-8?q?[add]=20#194=20String=20=EB=A6=AC?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aef04c5b..8b1fda68 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -191,4 +191,12 @@ \t\t\t\t\t\t\t예정된\t\t\t\t\t\t\t\t \t\t\t\t\t\t참여완료\t\t\t\t\t\t %d/%d명 + + + 나의 단체 + 개최된 핑글 수 + 참여자 수 + %s개 + %s명 + 새로운 단체 추가하러 가기 \ No newline at end of file From fc7ae00c2f6a14ef678d84a88b777d1956c11785 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Thu, 22 Feb 2024 15:55:24 +0900 Subject: [PATCH 02/22] =?UTF-8?q?[add]=20#194=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=A6=AC=EC=86=8C=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/drawable/ic_my_group_list_owner.xml | 23 ++++++++++++++++ .../main/res/drawable/ic_my_group_owner.xml | 26 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 app/src/main/res/drawable/ic_my_group_list_owner.xml create mode 100644 app/src/main/res/drawable/ic_my_group_owner.xml diff --git a/app/src/main/res/drawable/ic_my_group_list_owner.xml b/app/src/main/res/drawable/ic_my_group_list_owner.xml new file mode 100644 index 00000000..50897418 --- /dev/null +++ b/app/src/main/res/drawable/ic_my_group_list_owner.xml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/ic_my_group_owner.xml b/app/src/main/res/drawable/ic_my_group_owner.xml new file mode 100644 index 00000000..5b27886e --- /dev/null +++ b/app/src/main/res/drawable/ic_my_group_owner.xml @@ -0,0 +1,26 @@ + + + + + + + + + From 5d57c4886dcb6ad4f4734eb3fef6bb244053ea4b Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 20:27:05 +0900 Subject: [PATCH 03/22] =?UTF-8?q?[add]=20#194=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=A6=AC=EC=86=8C=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/drawable/ic_my_group_menu_copy.xml | 9 +++++++++ app/src/main/res/drawable/ic_my_group_menu_share.xml | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 app/src/main/res/drawable/ic_my_group_menu_copy.xml create mode 100644 app/src/main/res/drawable/ic_my_group_menu_share.xml diff --git a/app/src/main/res/drawable/ic_my_group_menu_copy.xml b/app/src/main/res/drawable/ic_my_group_menu_copy.xml new file mode 100644 index 00000000..ea409e6b --- /dev/null +++ b/app/src/main/res/drawable/ic_my_group_menu_copy.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_my_group_menu_share.xml b/app/src/main/res/drawable/ic_my_group_menu_share.xml new file mode 100644 index 00000000..a24ba62e --- /dev/null +++ b/app/src/main/res/drawable/ic_my_group_menu_share.xml @@ -0,0 +1,12 @@ + + + From edb4951d6467f796119faa8fd79f2e23b8c5ec47 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 20:27:21 +0900 Subject: [PATCH 04/22] =?UTF-8?q?[add]=20#194=20String=20=EB=A6=AC?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values/strings.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8b1fda68..9b9f3933 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -198,5 +198,12 @@ 참여자 수 %s개 %s명 - 새로운 단체 추가하러 가기 + 새로운 단체 추가하러 가기 + \'%s\'(으)로\n변경하시겠어요? + 변경하기 + 돌아가기 + 초대코드가 복사되었습니다! + 단체가 변경되었습니다! + 초대코드 복사하기 + 공유하기 \ No newline at end of file From 7ddaad936192d4e0dcd5ef2d03c5162c76ac8bc1 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 20:27:45 +0900 Subject: [PATCH 05/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20UI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../drawable/shape_border_white_radius_12.xml | 6 + app/src/main/res/layout/activity_my_group.xml | 288 ++++++++++++++++-- app/src/main/res/layout/item_my_group.xml | 80 +++++ .../main/res/layout/item_my_group_owner.xml | 87 ++++++ 4 files changed, 437 insertions(+), 24 deletions(-) create mode 100644 app/src/main/res/drawable/shape_border_white_radius_12.xml create mode 100644 app/src/main/res/layout/item_my_group.xml create mode 100644 app/src/main/res/layout/item_my_group_owner.xml diff --git a/app/src/main/res/drawable/shape_border_white_radius_12.xml b/app/src/main/res/drawable/shape_border_white_radius_12.xml new file mode 100644 index 00000000..f11e4623 --- /dev/null +++ b/app/src/main/res/drawable/shape_border_white_radius_12.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 71a403d7..a7cd8e39 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -5,6 +5,13 @@ + + + - + + + android:orientation="vertical" + app:layout_constraintGuide_begin="@dimen/spacing16" /> - + android:orientation="vertical" + app:layout_constraintGuide_end="@dimen/spacing16" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:layout_constraintTop_toBottomOf="@id/layout_my_group_now" /> + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_my_group.xml b/app/src/main/res/layout/item_my_group.xml new file mode 100644 index 00000000..1e931cca --- /dev/null +++ b/app/src/main/res/layout/item_my_group.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_my_group_owner.xml b/app/src/main/res/layout/item_my_group_owner.xml new file mode 100644 index 00000000..8b9f8666 --- /dev/null +++ b/app/src/main/res/layout/item_my_group_owner.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From d3642480122806da8bc4d5d1874fb0334905b51b Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 23:13:35 +0900 Subject: [PATCH 06/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20Dto,=20Entity=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=B0=8F=20pref=EC=97=90=20=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasource/local/PingleLocalDataSource.kt | 5 +++ .../local/PingleLocalDataSourceImpl.kt | 25 ++++++++++++++ .../remote/response/ResponseGroupListDto.kt | 33 +++++++++++++++++++ .../pingle/domain/model/GroupListEntity.kt | 11 +++++++ app/src/main/res/layout/activity_my_group.xml | 6 ++-- 5 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt create mode 100644 app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt diff --git a/app/src/main/java/org/sopt/pingle/data/datasource/local/PingleLocalDataSource.kt b/app/src/main/java/org/sopt/pingle/data/datasource/local/PingleLocalDataSource.kt index b83ed88f..3f91ccd0 100644 --- a/app/src/main/java/org/sopt/pingle/data/datasource/local/PingleLocalDataSource.kt +++ b/app/src/main/java/org/sopt/pingle/data/datasource/local/PingleLocalDataSource.kt @@ -7,5 +7,10 @@ interface PingleLocalDataSource { var refreshToken: String var groupId: Int var groupName: String + var meetingCount: String + var participantCount: String + var isOwner: Boolean + var groupKeyword: String + var code: String fun clear(): Unit } diff --git a/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt b/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt index 37b9e3bd..7c8991a2 100644 --- a/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt +++ b/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt @@ -55,6 +55,26 @@ class PingleLocalDataSourceImpl @Inject constructor( get() = pref.getString(GROUP_NAME, "") ?: "" set(value) = pref.edit { putString(GROUP_NAME, value) } + override var meetingCount: String + get() = pref.getString(MEETING_COUNT, "") ?: "" + set(value) = pref.edit { putString(MEETING_COUNT, value)} + + override var participantCount: String + get() = pref.getString(PARTICIPANTS_COUNT, "") ?: "" + set(value) = pref.edit { putString(PARTICIPANTS_COUNT, value) } + + override var groupKeyword: String + get() = pref.getString(GROUP_KEYWORD, "") ?: "" + set(value) = pref.edit{ putString(GROUP_KEYWORD, value)} + + override var isOwner: Boolean + get() = pref.getBoolean(IS_OWNER, false) + set(value) = pref.edit { putBoolean(IS_OWNER, value) } + + override var code: String + get() = pref.getString(GROUP_CODE, "") ?: "" + set(value) = pref.edit { putString(GROUP_CODE, value) } + override fun clear() { pref.edit { clear() @@ -69,5 +89,10 @@ class PingleLocalDataSourceImpl @Inject constructor( const val REFRESH_TOKEN = "RefreshToken" const val GROUP_ID = "GroupId" const val GROUP_NAME = "GroupName" + const val MEETING_COUNT = "MeetingCount" + const val PARTICIPANTS_COUNT = "ParticipantsCount" + const val GROUP_KEYWORD = "GroupKeyWord" + const val IS_OWNER = "IsOwner" + const val GROUP_CODE = "GroupCode" } } diff --git a/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt new file mode 100644 index 00000000..5e7c65e3 --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt @@ -0,0 +1,33 @@ +package org.sopt.pingle.data.model.remote.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import org.sopt.pingle.domain.model.GroupListEntity + +@Serializable +data class ResponseGroupListDto( + @SerialName("id") + val id: Int, + @SerialName("keyword") + val keyword: String, + @SerialName("name") + val name: String, + @SerialName("meetingCount") + val meetingCount: Int, + @SerialName("participantCount") + val participantCount: Int, + @SerialName("isOwner") + val isOwner: Boolean, + @SerialName("code") + val code: String, +) { + fun toResponseGroupListEntity() = GroupListEntity( + id = id, + keyword = keyword, + name = name, + meetingCount = meetingCount.toString(), + participantCount = participantCount.toString(), + isOwner = isOwner, + code = code + ) +} diff --git a/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt b/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt new file mode 100644 index 00000000..1fb630df --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt @@ -0,0 +1,11 @@ +package org.sopt.pingle.domain.model + +data class GroupListEntity( + val id: Int, + val keyword: String, + val name: String, + val meetingCount: String, + val participantCount: String, + val isOwner: Boolean, + val code: String +) diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index a7cd8e39..d56045ae 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -10,8 +10,8 @@ name="localStorage" type="org.sopt.pingle.data.datasource.local.PingleLocalDataSource" /> + name="myGroupMenuState" + type="org.sopt.pingle.presentation.ui.mygroup.MyGroupViewModel" /> Date: Sat, 24 Feb 2024 23:14:37 +0900 Subject: [PATCH 07/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=A6=AC=EC=82=AC=EC=9D=B4=ED=81=B4?= =?UTF-8?q?=EB=9F=AC=EB=B7=B0=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/joingroup/JoinViewModel.kt | 4 + .../ui/mygroup/MyGroupActivity.kt | 116 +++++++++++++++++ .../presentation/ui/mygroup/MyGroupAdapter.kt | 48 +++++++ .../ui/mygroup/MyGroupOwnerViewHolder.kt | 18 +++ .../ui/mygroup/MyGroupViewHolder.kt | 18 +++ .../ui/mygroup/MyGroupViewModel.kt | 122 ++++++++++++++++++ 6 files changed, 326 insertions(+) create mode 100644 app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt create mode 100644 app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt create mode 100644 app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt create mode 100644 app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt index e8b6a613..65f34723 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/joingroup/JoinViewModel.kt @@ -102,6 +102,10 @@ class JoinViewModel @Inject constructor( runCatching { getJoinGroupInfoUseCase(teamId = teamId).collect { joinGroupInfo -> _joinGroupInfoState.value = UiState.Success(joinGroupInfo) + with(localStorage) { + meetingCount = joinGroupInfo.meetingCount.toString() + participantCount = joinGroupInfo.participantCount.toString() + } } }.onFailure { _joinGroupInfoState.value = UiState.Error(it.message) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 949fb4b8..e9d06c1d 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -1,12 +1,128 @@ package org.sopt.pingle.presentation.ui.mygroup +import android.content.Intent import android.os.Bundle +import android.view.View +import androidx.activity.OnBackPressedCallback +import androidx.activity.viewModels +import dagger.hilt.android.AndroidEntryPoint import org.sopt.pingle.R import org.sopt.pingle.databinding.ActivityMyGroupBinding +import org.sopt.pingle.presentation.type.SnackbarType +import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity import org.sopt.pingle.util.base.BindingActivity +import org.sopt.pingle.util.component.AllModalDialogFragment +import org.sopt.pingle.util.component.PingleSnackbar +import org.sopt.pingle.util.context.stringOf +@AndroidEntryPoint class MyGroupActivity : BindingActivity(R.layout.activity_my_group) { + + private val viewModel by viewModels() + private lateinit var onBackPressed: OnBackPressedCallback + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + + initLayout() + addListeners() + onBackPressedBtn() + } + + override fun onDestroy() { + binding.rvMyGroupList.adapter = null + super.onDestroy() + } + + private fun initLayout() { + with(binding) { + toolbar.text = getString(R.string.my_group_title) + // TODO chip 머지되면 text에 localStorage에 저장된 keyword 가져오기 + tvMyGroupNowName.text = viewModel.getGroupName() + tvMyGroupNowMeetingCount.text = getString(R.string.my_group_meeting_count, viewModel.getGroupMeetingCount()) + tvMyGroupNowMemberCount.text = getString(R.string.my_group_member_count, viewModel.getGroupParticipantCount()) + + val adapter = MyGroupAdapter(::showChangeGroupModal) + rvMyGroupList.adapter = adapter + adapter.submitList(viewModel.dummyGroupList) + } + } + + private fun addListeners() { + with(binding) { + toolbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener { finish() } + tvMyGroupMoveNewGroup.setOnClickListener { navigateToNewGroupInfo() } + ivMyGroupNowMenu.setOnClickListener { showMyGroupMenu() } + root.setOnClickListener { layoutMyGroupMenu.visibility = View.INVISIBLE } + layoutMyGroupMenuCopy.setOnClickListener { copyGroupCode() } + layoutMyGroupMenuShare.setOnClickListener { shareGroupCode() } + } + } + + private fun showMyGroupMenu() { + with(binding) { + if (layoutMyGroupMenu.visibility == View.VISIBLE) { layoutMyGroupMenu.visibility = View.INVISIBLE } + else { + layoutMyGroupMenu.visibility = View.VISIBLE + } + } + } + + private fun showChangeGroupModal() { + AllModalDialogFragment( + // TODO viewModel에서 Entity의 특정 position에 해당하는 값 가져오는 함수 + title = getString(R.string.my_group_modal_move_question, viewModel.getGroupName()), + detail = null, + buttonText = getString(R.string.my_group_modal_change), + textButtonText = getString(R.string.my_group_modal_back), + clickBtn = { chageToNewGroup() }, + clickTextBtn = { }, + ).show(supportFragmentManager, CHANGE_MODAL) + } + + private fun chageToNewGroup() { + // TODO 서버통신으로 단체 get 해오고 현재 local에 저장된 것과 다른 경우만 리사이클러뷰 데이터로 업데이트 + + PingleSnackbar.makeSnackbar( + view = binding.root, + message = stringOf(R.string.my_group_snack_bar_chage_group_complete), + bottomMarin = SNACKBAR_BOTTOM_MARGIN, + snackbarType = SnackbarType.GUIDE, + ) + } + + private fun copyGroupCode() { + // TODO 초대코드 복사 로직 + + PingleSnackbar.makeSnackbar( + view = binding.root, + message = stringOf(R.string.my_group_snack_bar_code_copy_complete), + bottomMarin = SNACKBAR_BOTTOM_MARGIN, + snackbarType = SnackbarType.GUIDE, + ) + } + + private fun shareGroupCode() { + // TODO 초대코드 공유 로직 + } + + private fun navigateToNewGroupInfo() { + Intent(this, OnBoardingActivity::class.java).apply { + startActivity(this) + } + } + + private fun onBackPressedBtn() { + onBackPressed = object : OnBackPressedCallback(true) { + override fun handleOnBackPressed() { + finish() + } + } + onBackPressedDispatcher.addCallback(this, onBackPressed) + } + + companion object { + private const val CHANGE_MODAL = "changeGroupModal" + private const val SNACKBAR_BOTTOM_MARGIN = 57 } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt new file mode 100644 index 00000000..823e971b --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -0,0 +1,48 @@ +package org.sopt.pingle.presentation.ui.mygroup + +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.ListAdapter +import androidx.recyclerview.widget.RecyclerView +import org.sopt.pingle.databinding.ItemMyGroupBinding +import org.sopt.pingle.databinding.ItemMyGroupOwnerBinding +import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.util.view.ItemDiffCallback + +class MyGroupAdapter( + private val groupOnClick: () -> Unit, +) : ListAdapter( + ItemDiffCallback( + onContentsTheSame = { old, new -> old == new }, + onItemsTheSame = { old, new -> old.id == new.id }, + ), +) { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + return when (viewType) { + 1 -> MyGroupViewHolder( + ItemMyGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false), + groupOnClick, + ) + 2 -> MyGroupOwnerViewHolder( + ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), + groupOnClick, + ) + else -> throw RuntimeException() + } + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + when (holder) { + is MyGroupViewHolder -> holder.onBind(currentList[position]) + is MyGroupOwnerViewHolder -> holder.onBind(currentList[position]) + } + } + + override fun getItemViewType(position: Int): Int { + return if (currentList[position].isOwner) { + 2 + } else { + 1 + } + } +} diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt new file mode 100644 index 00000000..8421bc73 --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt @@ -0,0 +1,18 @@ +package org.sopt.pingle.presentation.ui.mygroup + +import androidx.recyclerview.widget.RecyclerView +import org.sopt.pingle.databinding.ItemMyGroupOwnerBinding +import org.sopt.pingle.domain.model.GroupListEntity + +class MyGroupOwnerViewHolder( + private val binding: ItemMyGroupOwnerBinding, + private val groupOnClick: () -> Unit, +) : + RecyclerView.ViewHolder(binding.root) { + fun onBind(groupListEntity: GroupListEntity) { + with(binding){ + this.groupListEntity = groupListEntity + layoutMyGroupListOwner.setOnClickListener { groupOnClick() } + } + } +} diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt new file mode 100644 index 00000000..bc2390ca --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -0,0 +1,18 @@ +package org.sopt.pingle.presentation.ui.mygroup + +import androidx.recyclerview.widget.RecyclerView +import org.sopt.pingle.databinding.ItemMyGroupBinding +import org.sopt.pingle.domain.model.GroupListEntity + +class MyGroupViewHolder( + private val binding: ItemMyGroupBinding, + private val groupOnClick: () -> Unit +) : + RecyclerView.ViewHolder(binding.root) { + fun onBind(groupListEntity: GroupListEntity) { + with(binding){ + this.groupListEntity = groupListEntity + layoutMyGroupListDefault.setOnClickListener { groupOnClick() } + } + } +} diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt new file mode 100644 index 00000000..f7c07cd4 --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -0,0 +1,122 @@ +package org.sopt.pingle.presentation.ui.mygroup + +import android.util.Log +import androidx.lifecycle.ViewModel +import dagger.hilt.android.lifecycle.HiltViewModel +import org.sopt.pingle.data.datasource.local.PingleLocalDataSource +import org.sopt.pingle.domain.model.GroupListEntity +import javax.inject.Inject + +@HiltViewModel +class MyGroupViewModel @Inject constructor( + private val localStorgae: PingleLocalDataSource, +) : ViewModel() { + + fun Logging() { + Log.e("localStorage", localStorgae.groupId.toString()) + Log.e("localStorage", localStorgae.groupName) + Log.e("localStorage", localStorgae.meetingCount) + Log.e("localStorage", localStorgae.participantCount) + Log.e("localStorage", localStorgae.isOwner.toString()) + Log.e("localStorage", localStorgae.groupKeyword) + Log.e("localStorage", localStorgae.code) + } + + fun getGroupList() { + /* TODO 서버통신으로 단체리스트를 받아온 뒤 현재 localStorgae의 groupId과 같은 단체 탐색, + * localStorage에 현재 단체를 저장하고 */ + val selectedGroup = dummyGroupList.find { + it.name == localStorgae.groupName + // it.id == localStorgae.groupId } + } + selectedGroup?.let { + with(localStorgae) { + // id랑 name은 joinGroupViewModel에서 저장되므로 생략 + groupKeyword = it.keyword + meetingCount = it.meetingCount + participantCount = it.participantCount + isOwner = it.isOwner + code = it.code + } + } + + val filteredGroupList = dummyGroupList.filterNot { it == selectedGroup } + // 데이터 업데이트 + } + + fun getGroupName(): String = localStorgae.groupName + + fun getGroupMeetingCount(): String = localStorgae.meetingCount + + fun getGroupParticipantCount(): String = localStorgae.participantCount + + fun getGroupCode(): String = localStorgae.code + + fun getGroupKeyword(): String = localStorgae.groupKeyword + + val dummyGroupList = listOf( + GroupListEntity( + id = 12341, + name = "SOPT", + meetingCount = "12", + participantCount = "76", + keyword = "연합동아리", + isOwner = true, + code = "soptcode", + ), + GroupListEntity( + id = 48103, + name = "UMC", + keyword = "연합동아리", + meetingCount = "3", + participantCount = "72", + isOwner = false, + code = "umccode", + ), + GroupListEntity( + id = 314927, + name = "SOPT MAKERS", + keyword = "자체기구", + meetingCount = "114", + participantCount = "3", + isOwner = false, + code = "makerscode", + ), + GroupListEntity( + id = 4915, + name = "소나무", + keyword = "교내동아리", + meetingCount = "98", + participantCount = "11", + isOwner = false, + code = "sonamucode", + ), + GroupListEntity( + id = 12792, + name = "불꽃컴공", + keyword = "학생회", + meetingCount = "35", + participantCount = "1123", + isOwner = true, + code = "donggukcode", + ), + GroupListEntity( + id = 852, + name = "TEAM PINGLE", + keyword = "동호회", + meetingCount = "254", + participantCount = "56", + isOwner = false, + code = "pinglecode", + ), + GroupListEntity( + id = 1, + name = "SERVER", + keyword = "사모임", + meetingCount = "2", + participantCount = "16", + isOwner = true, + code = "aaaaaaaaaaaa", + ), + ) +} From d3dce46e7060479ca3edd854504eeb774e83521d Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 23:28:06 +0900 Subject: [PATCH 08/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EC=B4=88=EB=8C=80?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=B3=B5=EC=82=AC=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 --- .../pingle/presentation/ui/mygroup/MyGroupActivity.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index e9d06c1d..4bcf2ee5 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -1,5 +1,8 @@ package org.sopt.pingle.presentation.ui.mygroup +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View @@ -92,7 +95,9 @@ class MyGroupActivity : BindingActivity(R.layout.activit } private fun copyGroupCode() { - // TODO 초대코드 복사 로직 + val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip: ClipData = ClipData.newPlainText(GROUP_CODE_COPY, viewModel.getGroupCode()) + clipboard.setPrimaryClip(clip) PingleSnackbar.makeSnackbar( view = binding.root, @@ -122,7 +127,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit } companion object { - private const val CHANGE_MODAL = "changeGroupModal" + private const val CHANGE_MODAL = "ChangeGroupModal" private const val SNACKBAR_BOTTOM_MARGIN = 57 + private const val GROUP_CODE_COPY = "CopyGroupCode" } } From 8cb22058cd5cd5f7da846e3c62e8c88f9bf7785c Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sat, 24 Feb 2024 23:41:06 +0900 Subject: [PATCH 09/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=8B=A8=EC=B2=B4=EC=9E=A5=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20visibility=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/mygroup/MyGroupActivity.kt | 13 ++++++++++++- .../presentation/ui/mygroup/MyGroupViewModel.kt | 2 ++ app/src/main/res/layout/activity_my_group.xml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 4bcf2ee5..eea985ac 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -38,6 +38,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit } private fun initLayout() { + checkMyGroupOwner() + with(binding) { toolbar.text = getString(R.string.my_group_title) // TODO chip 머지되면 text에 localStorage에 저장된 keyword 가져오기 @@ -61,7 +63,16 @@ class MyGroupActivity : BindingActivity(R.layout.activit layoutMyGroupMenuShare.setOnClickListener { shareGroupCode() } } } - + + private fun checkMyGroupOwner() { + with(binding) { + if (viewModel.getMyGroupIsOwner()) { ivMyGroupNowOwner.visibility = View.VISIBLE } + else { + ivMyGroupNowOwner.visibility = View.INVISIBLE + } + } + } + private fun showMyGroupMenu() { with(binding) { if (layoutMyGroupMenu.visibility == View.VISIBLE) { layoutMyGroupMenu.visibility = View.INVISIBLE } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index f7c07cd4..5a4ff7d1 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -44,6 +44,8 @@ class MyGroupViewModel @Inject constructor( // 데이터 업데이트 } + fun getMyGroupIsOwner(): Boolean = localStorgae.isOwner + fun getGroupName(): String = localStorgae.groupName fun getGroupMeetingCount(): String = localStorgae.meetingCount diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index d56045ae..1925198e 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -148,7 +148,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_my_group_owner" - android:visibility="@{localStorage.isOwner ? View.VISIBLE : View.INVISIBLE}" + android:visibility="invisible" app:layout_constraintBottom_toBottomOf="@id/layout_my_group_now" app:layout_constraintEnd_toStartOf="@id/gl_end" /> From c293513a40f249592a3e5d62f8f834c9cbb94388 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sun, 25 Feb 2024 00:01:45 +0900 Subject: [PATCH 10/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=ED=98=84=EC=9E=AC=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EA=B3=B5=EC=9C=A0=ED=95=98=EA=B8=B0=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 --- .../ui/mygroup/MyGroupActivity.kt | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index eea985ac..81c520fa 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -44,8 +44,10 @@ class MyGroupActivity : BindingActivity(R.layout.activit toolbar.text = getString(R.string.my_group_title) // TODO chip 머지되면 text에 localStorage에 저장된 keyword 가져오기 tvMyGroupNowName.text = viewModel.getGroupName() - tvMyGroupNowMeetingCount.text = getString(R.string.my_group_meeting_count, viewModel.getGroupMeetingCount()) - tvMyGroupNowMemberCount.text = getString(R.string.my_group_member_count, viewModel.getGroupParticipantCount()) + tvMyGroupNowMeetingCount.text = + getString(R.string.my_group_meeting_count, viewModel.getGroupMeetingCount()) + tvMyGroupNowMemberCount.text = + getString(R.string.my_group_member_count, viewModel.getGroupParticipantCount()) val adapter = MyGroupAdapter(::showChangeGroupModal) rvMyGroupList.adapter = adapter @@ -66,8 +68,9 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun checkMyGroupOwner() { with(binding) { - if (viewModel.getMyGroupIsOwner()) { ivMyGroupNowOwner.visibility = View.VISIBLE } - else { + if (viewModel.getMyGroupIsOwner()) { + ivMyGroupNowOwner.visibility = View.VISIBLE + } else { ivMyGroupNowOwner.visibility = View.INVISIBLE } } @@ -75,8 +78,9 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun showMyGroupMenu() { with(binding) { - if (layoutMyGroupMenu.visibility == View.VISIBLE) { layoutMyGroupMenu.visibility = View.INVISIBLE } - else { + if (layoutMyGroupMenu.visibility == View.VISIBLE) { + layoutMyGroupMenu.visibility = View.INVISIBLE + } else { layoutMyGroupMenu.visibility = View.VISIBLE } } @@ -119,7 +123,16 @@ class MyGroupActivity : BindingActivity(R.layout.activit } private fun shareGroupCode() { - // TODO 초대코드 공유 로직 + val intent = Intent(Intent.ACTION_SEND_MULTIPLE) + with(intent) { + type = "text/plain" + // TODO 기획에서 전달해준 템플릿 적용 + putExtra( + Intent.EXTRA_TEXT, + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", + ) + } + startActivity(Intent.createChooser(intent, null)) } private fun navigateToNewGroupInfo() { @@ -141,5 +154,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit private const val CHANGE_MODAL = "ChangeGroupModal" private const val SNACKBAR_BOTTOM_MARGIN = 57 private const val GROUP_CODE_COPY = "CopyGroupCode" + private const val PINGLE_PLAY_STORE_LINK = + "앱 링크 : https://play.google.com/store/apps/details?id=org.sopt.pingle&pcampaignid=web_share" + private const val PINGLE_SHARE_CODE = "초대코드 : " } } From acb6eb3a6441706becd55c78d9499dea9d1d2bf6 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sun, 25 Feb 2024 00:11:29 +0900 Subject: [PATCH 11/22] =?UTF-8?q?[chore]=20#194=20ktlintFormat=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../local/PingleLocalDataSourceImpl.kt | 4 ++-- .../remote/response/ResponseGroupListDto.kt | 2 +- .../ui/mygroup/MyGroupActivity.kt | 13 ++++++------ .../presentation/ui/mygroup/MyGroupAdapter.kt | 10 +++++----- .../ui/mygroup/MyGroupOwnerViewHolder.kt | 4 ++-- .../ui/mygroup/MyGroupViewHolder.kt | 2 +- .../ui/mygroup/MyGroupViewModel.kt | 20 +++++++++---------- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt b/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt index 7c8991a2..fa1beed1 100644 --- a/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt +++ b/app/src/main/java/org/sopt/pingle/data/datasourceimpl/local/PingleLocalDataSourceImpl.kt @@ -57,7 +57,7 @@ class PingleLocalDataSourceImpl @Inject constructor( override var meetingCount: String get() = pref.getString(MEETING_COUNT, "") ?: "" - set(value) = pref.edit { putString(MEETING_COUNT, value)} + set(value) = pref.edit { putString(MEETING_COUNT, value) } override var participantCount: String get() = pref.getString(PARTICIPANTS_COUNT, "") ?: "" @@ -65,7 +65,7 @@ class PingleLocalDataSourceImpl @Inject constructor( override var groupKeyword: String get() = pref.getString(GROUP_KEYWORD, "") ?: "" - set(value) = pref.edit{ putString(GROUP_KEYWORD, value)} + set(value) = pref.edit { putString(GROUP_KEYWORD, value) } override var isOwner: Boolean get() = pref.getBoolean(IS_OWNER, false) diff --git a/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt index 5e7c65e3..59f0fd12 100644 --- a/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt +++ b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt @@ -19,7 +19,7 @@ data class ResponseGroupListDto( @SerialName("isOwner") val isOwner: Boolean, @SerialName("code") - val code: String, + val code: String ) { fun toResponseGroupListEntity() = GroupListEntity( id = id, diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 81c520fa..c6c87b55 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -87,14 +87,14 @@ class MyGroupActivity : BindingActivity(R.layout.activit } private fun showChangeGroupModal() { + // TODO viewModel에서 Entity의 특정 position에 해당하는 값 가져와서 현재 단체랑 위치 바꾸기 AllModalDialogFragment( - // TODO viewModel에서 Entity의 특정 position에 해당하는 값 가져오는 함수 title = getString(R.string.my_group_modal_move_question, viewModel.getGroupName()), detail = null, buttonText = getString(R.string.my_group_modal_change), textButtonText = getString(R.string.my_group_modal_back), clickBtn = { chageToNewGroup() }, - clickTextBtn = { }, + clickTextBtn = { } ).show(supportFragmentManager, CHANGE_MODAL) } @@ -105,7 +105,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_chage_group_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) } @@ -118,18 +118,18 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_code_copy_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) } private fun shareGroupCode() { val intent = Intent(Intent.ACTION_SEND_MULTIPLE) with(intent) { - type = "text/plain" + type = SHARE_TYPE // TODO 기획에서 전달해준 템플릿 적용 putExtra( Intent.EXTRA_TEXT, - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" ) } startActivity(Intent.createChooser(intent, null)) @@ -157,5 +157,6 @@ class MyGroupActivity : BindingActivity(R.layout.activit private const val PINGLE_PLAY_STORE_LINK = "앱 링크 : https://play.google.com/store/apps/details?id=org.sopt.pingle&pcampaignid=web_share" private const val PINGLE_SHARE_CODE = "초대코드 : " + private const val SHARE_TYPE = "text/plain" } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index 823e971b..65b65267 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -10,22 +10,22 @@ import org.sopt.pingle.domain.model.GroupListEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: () -> Unit, + private val groupOnClick: () -> Unit ) : ListAdapter( ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, - onItemsTheSame = { old, new -> old.id == new.id }, - ), + onItemsTheSame = { old, new -> old.id == new.id } + ) ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { 1 -> MyGroupViewHolder( ItemMyGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick, + groupOnClick ) 2 -> MyGroupOwnerViewHolder( ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick, + groupOnClick ) else -> throw RuntimeException() } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt index 8421bc73..ae90456e 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt @@ -6,11 +6,11 @@ import org.sopt.pingle.domain.model.GroupListEntity class MyGroupOwnerViewHolder( private val binding: ItemMyGroupOwnerBinding, - private val groupOnClick: () -> Unit, + private val groupOnClick: () -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(groupListEntity: GroupListEntity) { - with(binding){ + with(binding) { this.groupListEntity = groupListEntity layoutMyGroupListOwner.setOnClickListener { groupOnClick() } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt index bc2390ca..357721f7 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -10,7 +10,7 @@ class MyGroupViewHolder( ) : RecyclerView.ViewHolder(binding.root) { fun onBind(groupListEntity: GroupListEntity) { - with(binding){ + with(binding) { this.groupListEntity = groupListEntity layoutMyGroupListDefault.setOnClickListener { groupOnClick() } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index 5a4ff7d1..de728303 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -3,13 +3,13 @@ package org.sopt.pingle.presentation.ui.mygroup import android.util.Log import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.domain.model.GroupListEntity -import javax.inject.Inject @HiltViewModel class MyGroupViewModel @Inject constructor( - private val localStorgae: PingleLocalDataSource, + private val localStorgae: PingleLocalDataSource ) : ViewModel() { fun Logging() { @@ -64,7 +64,7 @@ class MyGroupViewModel @Inject constructor( participantCount = "76", keyword = "연합동아리", isOwner = true, - code = "soptcode", + code = "soptcode" ), GroupListEntity( id = 48103, @@ -73,7 +73,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "3", participantCount = "72", isOwner = false, - code = "umccode", + code = "umccode" ), GroupListEntity( id = 314927, @@ -82,7 +82,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "114", participantCount = "3", isOwner = false, - code = "makerscode", + code = "makerscode" ), GroupListEntity( id = 4915, @@ -91,7 +91,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "98", participantCount = "11", isOwner = false, - code = "sonamucode", + code = "sonamucode" ), GroupListEntity( id = 12792, @@ -100,7 +100,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "35", participantCount = "1123", isOwner = true, - code = "donggukcode", + code = "donggukcode" ), GroupListEntity( id = 852, @@ -109,7 +109,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "254", participantCount = "56", isOwner = false, - code = "pinglecode", + code = "pinglecode" ), GroupListEntity( id = 1, @@ -118,7 +118,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "2", participantCount = "16", isOwner = true, - code = "aaaaaaaaaaaa", - ), + code = "aaaaaaaaaaaa" + ) ) } From fda97c8963f807e22be58c607f38e671e5fc1bac Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sun, 25 Feb 2024 13:29:17 +0900 Subject: [PATCH 12/22] =?UTF-8?q?[chore]=20#194=20activity=5Fmy=5Fgroup.xm?= =?UTF-8?q?l=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=B0=94=EC=9D=B8=EB=94=A9?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_my_group.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 1925198e..00986fa5 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -5,12 +5,14 @@ - + + + @@ -90,6 +92,7 @@ android:layout_marginTop="@dimen/spacing10" android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.20" android:textColor="@color/white" + android:text="@{myGroupviewModel.groupName}" app:layout_constraintEnd_toStartOf="@id/gl_now_end" app:layout_constraintStart_toEndOf="@id/gl_now_start" app:layout_constraintTop_toBottomOf="@id/badge_my_group_category" @@ -111,7 +114,7 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginStart="@dimen/spacing18" - android:text="@string/my_group_meeting_count" + android:text="@{@string/my_group_meeting_count(myGroupviewModel.groupMeetingCount)}" android:textAppearance="@style/TextAppearance.Pingle.Body.Med.14" android:textColor="@color/g_03" app:layout_constraintBottom_toBottomOf="@id/tv_my_group_now_meeting" @@ -123,7 +126,7 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginStart="45dp" - android:text="@string/my_group_meeting_count" + android:text="@{@string/my_group_meeting_count(myGroupviewModel.groupParticipantCount)}" android:textAppearance="@style/TextAppearance.Pingle.Body.Med.14" android:textColor="@color/g_03" app:layout_constraintBottom_toBottomOf="@id/tv_my_group_now_member" @@ -207,9 +210,9 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginEnd="7dp" - android:visibility="invisible" android:background="@color/g_10" android:foreground="@drawable/shape_line_g_09_radius_8" + android:visibility="invisible" app:layout_constraintEnd_toStartOf="@id/gl_end" app:layout_constraintTop_toBottomOf="@id/iv_my_group_now_menu"> @@ -227,11 +230,11 @@ android:id="@+id/tv_my_group_menu_chat" android:layout_width="wrap_content" android:layout_height="0dp" + android:layout_marginEnd="@dimen/spacing10" android:text="@string/my_group_menu_copy" android:textAppearance="@style/TextAppearance.Pingle.Body.Med.14" android:textColor="@color/g_03" app:layout_constraintBottom_toBottomOf="parent" - android:layout_marginEnd="@dimen/spacing10" app:layout_constraintEnd_toStartOf="@id/iv_my_group_menu_copy" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> From 1efd17ea49d81845ec42a5dd03308137ce944006 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sun, 25 Feb 2024 15:03:54 +0900 Subject: [PATCH 13/22] =?UTF-8?q?[feat]=20#194=20=EB=8B=A8=EC=B2=B4=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pingle/domain/model/GroupListEntity.kt | 2 +- .../ui/mygroup/MyGroupActivity.kt | 52 ++++++++++++------- .../presentation/ui/mygroup/MyGroupAdapter.kt | 25 +++++---- .../ui/mygroup/MyGroupOwnerViewHolder.kt | 5 +- .../ui/mygroup/MyGroupViewHolder.kt | 5 +- .../ui/mygroup/MyGroupViewModel.kt | 46 ++++++++++++---- app/src/main/res/layout/activity_my_group.xml | 6 +-- 7 files changed, 95 insertions(+), 46 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt b/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt index 1fb630df..cad4c3b8 100644 --- a/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt +++ b/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt @@ -1,7 +1,7 @@ package org.sopt.pingle.domain.model data class GroupListEntity( - val id: Int, + var id: Int, val keyword: String, val name: String, val meetingCount: String, diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index c6c87b55..3c2ab1d4 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -8,7 +8,11 @@ import android.os.Bundle import android.view.View import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels +import androidx.lifecycle.flowWithLifecycle +import androidx.lifecycle.lifecycleScope import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.onEach import org.sopt.pingle.R import org.sopt.pingle.databinding.ActivityMyGroupBinding import org.sopt.pingle.presentation.type.SnackbarType @@ -23,12 +27,18 @@ class MyGroupActivity : BindingActivity(R.layout.activit private val viewModel by viewModels() private lateinit var onBackPressed: OnBackPressedCallback + private lateinit var adapter: MyGroupAdapter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + binding.myGroupviewModel = viewModel + binding.lifecycleOwner = this + + viewModel.Logging() initLayout() addListeners() + collectData() onBackPressedBtn() } @@ -39,19 +49,15 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun initLayout() { checkMyGroupOwner() + viewModel.getGroupList() with(binding) { toolbar.text = getString(R.string.my_group_title) - // TODO chip 머지되면 text에 localStorage에 저장된 keyword 가져오기 - tvMyGroupNowName.text = viewModel.getGroupName() - tvMyGroupNowMeetingCount.text = - getString(R.string.my_group_meeting_count, viewModel.getGroupMeetingCount()) - tvMyGroupNowMemberCount.text = - getString(R.string.my_group_member_count, viewModel.getGroupParticipantCount()) - - val adapter = MyGroupAdapter(::showChangeGroupModal) + // TODO chip 머지되면 text에 localStorage에 저장된 keyword 데바 + + adapter = MyGroupAdapter(this@MyGroupActivity::showChangeGroupModal) rvMyGroupList.adapter = adapter - adapter.submitList(viewModel.dummyGroupList) + adapter.submitList(viewModel.filteredGroupList.value) } } @@ -66,6 +72,12 @@ class MyGroupActivity : BindingActivity(R.layout.activit } } + private fun collectData() { + viewModel.filteredGroupList.flowWithLifecycle(lifecycle).onEach { filteredList -> + adapter.submitList(filteredList) + }.launchIn(lifecycleScope) + } + private fun checkMyGroupOwner() { with(binding) { if (viewModel.getMyGroupIsOwner()) { @@ -86,27 +98,29 @@ class MyGroupActivity : BindingActivity(R.layout.activit } } - private fun showChangeGroupModal() { - // TODO viewModel에서 Entity의 특정 position에 해당하는 값 가져와서 현재 단체랑 위치 바꾸기 + private fun showChangeGroupModal(clickedPosition: Int) { + binding.layoutMyGroupMenu.visibility = View.INVISIBLE AllModalDialogFragment( - title = getString(R.string.my_group_modal_move_question, viewModel.getGroupName()), + title = getString(R.string.my_group_modal_move_question, viewModel.filteredGroupList.value[clickedPosition].name), detail = null, buttonText = getString(R.string.my_group_modal_change), textButtonText = getString(R.string.my_group_modal_back), - clickBtn = { chageToNewGroup() }, - clickTextBtn = { } + clickBtn = { chageToNewGroup(clickedPosition) }, + clickTextBtn = { }, ).show(supportFragmentManager, CHANGE_MODAL) } - private fun chageToNewGroup() { - // TODO 서버통신으로 단체 get 해오고 현재 local에 저장된 것과 다른 경우만 리사이클러뷰 데이터로 업데이트 + private fun chageToNewGroup(clickedPosition: Int) { + viewModel.changeGroupList(clickedPosition) PingleSnackbar.makeSnackbar( view = binding.root, message = stringOf(R.string.my_group_snack_bar_chage_group_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE + snackbarType = SnackbarType.GUIDE, ) + + viewModel.Logging() } private fun copyGroupCode() { @@ -118,7 +132,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_code_copy_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE + snackbarType = SnackbarType.GUIDE, ) } @@ -129,7 +143,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit // TODO 기획에서 전달해준 템플릿 적용 putExtra( Intent.EXTRA_TEXT, - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", ) } startActivity(Intent.createChooser(intent, null)) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index 65b65267..2a47b2b2 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -10,23 +10,25 @@ import org.sopt.pingle.domain.model.GroupListEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: () -> Unit + private val groupOnClick: (Int) -> Unit, ) : ListAdapter( ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, - onItemsTheSame = { old, new -> old.id == new.id } - ) + onItemsTheSame = { old, new -> old.id == new.id }, + ), ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { - 1 -> MyGroupViewHolder( + DEFAULT_GROUP -> MyGroupViewHolder( ItemMyGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick + groupOnClick, ) - 2 -> MyGroupOwnerViewHolder( + + OWNER_GROUP -> MyGroupOwnerViewHolder( ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick + groupOnClick, ) + else -> throw RuntimeException() } } @@ -40,9 +42,14 @@ class MyGroupAdapter( override fun getItemViewType(position: Int): Int { return if (currentList[position].isOwner) { - 2 + OWNER_GROUP } else { - 1 + DEFAULT_GROUP } } + + companion object { + private const val OWNER_GROUP = 2 + private const val DEFAULT_GROUP = 1 + } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt index ae90456e..5bc4879d 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt @@ -6,13 +6,14 @@ import org.sopt.pingle.domain.model.GroupListEntity class MyGroupOwnerViewHolder( private val binding: ItemMyGroupOwnerBinding, - private val groupOnClick: () -> Unit + private val groupOnClick: (Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(groupListEntity: GroupListEntity) { with(binding) { this.groupListEntity = groupListEntity - layoutMyGroupListOwner.setOnClickListener { groupOnClick() } + binding.tvMyGroupListOwnerName.text = groupListEntity.name + layoutMyGroupListOwner.setOnClickListener { groupOnClick(absoluteAdapterPosition) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt index 357721f7..d530cd4c 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -6,13 +6,14 @@ import org.sopt.pingle.domain.model.GroupListEntity class MyGroupViewHolder( private val binding: ItemMyGroupBinding, - private val groupOnClick: () -> Unit + private val groupOnClick: (Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(groupListEntity: GroupListEntity) { with(binding) { this.groupListEntity = groupListEntity - layoutMyGroupListDefault.setOnClickListener { groupOnClick() } + tvMyGroupListDefaultName.text = groupListEntity.name + layoutMyGroupListDefault.setOnClickListener { groupOnClick(absoluteAdapterPosition) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index de728303..84629c39 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -1,8 +1,10 @@ package org.sopt.pingle.presentation.ui.mygroup import android.util.Log +import androidx.constraintlayout.widget.Group import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow import javax.inject.Inject import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.domain.model.GroupListEntity @@ -22,16 +24,41 @@ class MyGroupViewModel @Inject constructor( Log.e("localStorage", localStorgae.code) } + private var _filteredGroupList = MutableStateFlow>(emptyList()) + val filteredGroupList get() = _filteredGroupList + + private var _selectedMyGroup = MutableStateFlow(null) + val selectedMyGroup get() = _selectedMyGroup + + // TODO 서버통신 List + fun getGroupList() { - /* TODO 서버통신으로 단체리스트를 받아온 뒤 현재 localStorgae의 groupId과 같은 단체 탐색, - * localStorage에 현재 단체를 저장하고 */ - val selectedGroup = dummyGroupList.find { - it.name == localStorgae.groupName - // it.id == localStorgae.groupId } + // TODO 서버통신 + selectedMyGroup.value = dummyGroupList.find { it.id == localStorgae.groupId } + selectedMyGroup.value.let { + with(localStorgae) { + groupId = it!!.id + groupName = it!!.name + groupKeyword = it!!.keyword + meetingCount = it!!.meetingCount + participantCount = it!!.participantCount + isOwner = it!!.isOwner + code = it!!.code + } } - selectedGroup?.let { + + _filteredGroupList.value = dummyGroupList.filterNot { it == selectedMyGroup.value } + } + + fun changeGroupList(clickedPosition: Int) { + // _filteredGroupList의 clickedPosition에 해당하는 값을 localStorage에 저장하고, + // _filteredGroupList의 clickedPosition에 selectedMyGroup를 저장 + // selectedMyGroup에는 localStorage에 저장된 값과 같은 GroupListEntity를 저장 + val clickedGroup = _filteredGroupList.value.getOrNull(clickedPosition) + clickedGroup?.let { with(localStorgae) { - // id랑 name은 joinGroupViewModel에서 저장되므로 생략 + groupId = it.id + groupName = it.name groupKeyword = it.keyword meetingCount = it.meetingCount participantCount = it.participantCount @@ -39,9 +66,8 @@ class MyGroupViewModel @Inject constructor( code = it.code } } - - val filteredGroupList = dummyGroupList.filterNot { it == selectedGroup } - // 데이터 업데이트 + _selectedMyGroup.value = clickedGroup + _filteredGroupList.value = dummyGroupList.filterNot { it == selectedMyGroup.value } } fun getMyGroupIsOwner(): Boolean = localStorgae.isOwner diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 00986fa5..33e49d7f 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -92,7 +92,7 @@ android:layout_marginTop="@dimen/spacing10" android:textAppearance="@style/TextAppearance.Pingle.Title.Semi.20" android:textColor="@color/white" - android:text="@{myGroupviewModel.groupName}" + android:text="@{myGroupviewModel.selectedMyGroup.name}" app:layout_constraintEnd_toStartOf="@id/gl_now_end" app:layout_constraintStart_toEndOf="@id/gl_now_start" app:layout_constraintTop_toBottomOf="@id/badge_my_group_category" @@ -114,7 +114,7 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginStart="@dimen/spacing18" - android:text="@{@string/my_group_meeting_count(myGroupviewModel.groupMeetingCount)}" + android:text="@{@string/my_group_meeting_count(myGroupviewModel.selectedMyGroup.meetingCount)}" android:textAppearance="@style/TextAppearance.Pingle.Body.Med.14" android:textColor="@color/g_03" app:layout_constraintBottom_toBottomOf="@id/tv_my_group_now_meeting" @@ -126,7 +126,7 @@ android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginStart="45dp" - android:text="@{@string/my_group_meeting_count(myGroupviewModel.groupParticipantCount)}" + android:text="@{@string/my_group_meeting_count(myGroupviewModel.selectedMyGroup.participantCount)}" android:textAppearance="@style/TextAppearance.Pingle.Body.Med.14" android:textColor="@color/g_03" app:layout_constraintBottom_toBottomOf="@id/tv_my_group_now_member" From 46574d2b129b57359923bad49b403943d4007f96 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Sun, 25 Feb 2024 15:09:26 +0900 Subject: [PATCH 14/22] =?UTF-8?q?[chore]=20#194=20conflict=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20=EB=B0=8F=20ktlintFormat=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pingle/presentation/ui/mygroup/MyGroupActivity.kt | 8 ++++---- .../pingle/presentation/ui/mygroup/MyGroupAdapter.kt | 10 +++++----- .../pingle/presentation/ui/mygroup/MyGroupViewModel.kt | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 3c2ab1d4..47ec98a2 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -106,7 +106,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit buttonText = getString(R.string.my_group_modal_change), textButtonText = getString(R.string.my_group_modal_back), clickBtn = { chageToNewGroup(clickedPosition) }, - clickTextBtn = { }, + clickTextBtn = { } ).show(supportFragmentManager, CHANGE_MODAL) } @@ -117,7 +117,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_chage_group_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) viewModel.Logging() @@ -132,7 +132,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_code_copy_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) } @@ -143,7 +143,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit // TODO 기획에서 전달해준 템플릿 적용 putExtra( Intent.EXTRA_TEXT, - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" ) } startActivity(Intent.createChooser(intent, null)) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index 2a47b2b2..aac5c345 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -10,23 +10,23 @@ import org.sopt.pingle.domain.model.GroupListEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: (Int) -> Unit, + private val groupOnClick: (Int) -> Unit ) : ListAdapter( ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, - onItemsTheSame = { old, new -> old.id == new.id }, - ), + onItemsTheSame = { old, new -> old.id == new.id } + ) ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { DEFAULT_GROUP -> MyGroupViewHolder( ItemMyGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick, + groupOnClick ) OWNER_GROUP -> MyGroupOwnerViewHolder( ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick, + groupOnClick ) else -> throw RuntimeException() diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index 84629c39..67a0fb34 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -1,11 +1,10 @@ package org.sopt.pingle.presentation.ui.mygroup import android.util.Log -import androidx.constraintlayout.widget.Group import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import kotlinx.coroutines.flow.MutableStateFlow import javax.inject.Inject +import kotlinx.coroutines.flow.MutableStateFlow import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.domain.model.GroupListEntity From 74cfc62bad9bf6f45cd617e1d6242d710313de71 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Mon, 26 Feb 2024 23:01:04 +0900 Subject: [PATCH 15/22] =?UTF-8?q?[chore]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20chip=20style=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/layout/activity_my_group.xml | 14 ++++++++------ app/src/main/res/layout/item_my_group.xml | 12 +++++++----- app/src/main/res/layout/item_my_group_owner.xml | 14 ++++++++------ app/src/main/res/values/themes.xml | 2 +- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 33e49d7f..92bc60fb 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -77,25 +77,27 @@ android:orientation="horizontal" app:layout_constraintGuide_end="@dimen/spacing20" /> - - + app:layout_constraintTop_toBottomOf="@id/gl_now_top" + tools:text="연합동아리" /> - - + app:layout_constraintTop_toBottomOf="@id/gl_top" + tools:text="연합동아리" /> diff --git a/app/src/main/res/layout/item_my_group_owner.xml b/app/src/main/res/layout/item_my_group_owner.xml index 8b9f8666..c22150d9 100644 --- a/app/src/main/res/layout/item_my_group_owner.xml +++ b/app/src/main/res/layout/item_my_group_owner.xml @@ -53,26 +53,28 @@ android:orientation="horizontal" app:layout_constraintGuide_end="@dimen/spacing20" /> - - + app:layout_constraintTop_toBottomOf="@id/gl_top" + tools:text="연합동아리" /> diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index c68d21df..789605ec 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -115,7 +115,7 @@ 10dp 4dp false - @color/g_10 + @color/g_07 @color/pingle_green @style/TextAppearance.Pingle.Cap.Semi.12 From 7d16745fc5d4b41ed46bd565d7a933934aafc306 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Wed, 28 Feb 2024 20:16:02 +0900 Subject: [PATCH 16/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EB=B3=B5=EC=82=AC?= =?UTF-8?q?=ED=95=98=EA=B8=B0,=20=EA=B3=B5=EC=9C=A0=ED=95=98=EA=B8=B0=20?= =?UTF-8?q?=ED=99=95=EC=9E=A5=ED=95=A8=EC=88=98=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/pingle/util/context/ContextExt.kt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt index ea4eaeb8..d0bd24bf 100644 --- a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt +++ b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt @@ -1,6 +1,8 @@ package org.sopt.pingle.util.context import android.app.Activity +import android.content.ClipData +import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.view.View @@ -10,6 +12,7 @@ import androidx.annotation.StringRes import androidx.core.content.ContextCompat import org.sopt.pingle.presentation.ui.common.WebViewActivity import org.sopt.pingle.presentation.ui.common.WebViewActivity.Companion.WEB_VIEW_LINK +import org.sopt.pingle.presentation.ui.mygroup.MyGroupActivity fun Context.hideKeyboard(view: View) { val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager @@ -24,3 +27,23 @@ fun Context.colorOf(@ColorRes resId: Int) = ContextCompat.getColor(this, resId) fun Context.navigateToWebView(link: String) = Intent(this, WebViewActivity::class.java).apply { putExtra(WEB_VIEW_LINK, link) } + +fun Context.setupShareIntent(shareContent: String) { + val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + type = SHARE_TYPE + putExtra(Intent.EXTRA_TEXT, shareContent) + } + startActivity(Intent.createChooser(intent, null)) +} + +fun Context.copyGroupCode(copyCode: String){ + val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip: ClipData = ClipData.newPlainText(GROUP_CODE_COPY, copyCode) + clipboard.setPrimaryClip(clip) +} + +const val PINGLE_PLAY_STORE_LINK = + "앱 링크 : https://play.google.com/store/apps/details?id=org.sopt.pingle&pcampaignid=web_share" +const val PINGLE_SHARE_CODE = "초대코드 : " +const val SHARE_TYPE = "text/plain" +const val GROUP_CODE_COPY = "CopyGroupCode" From 51dec5d53754d779f8e7a11ed78f7a038c1d336d Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Wed, 28 Feb 2024 20:17:50 +0900 Subject: [PATCH 17/22] =?UTF-8?q?[feat]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20=EB=AA=A8=EB=8B=AC=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/MyGroupModalDialogFragment.kt | 57 +++++++++++++ .../main/res/layout/dialog_my_group_modal.xml | 85 +++++++++++++++++++ app/src/main/res/values/dimens.xml | 1 + 3 files changed, 143 insertions(+) create mode 100644 app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt create mode 100644 app/src/main/res/layout/dialog_my_group_modal.xml diff --git a/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt b/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt new file mode 100644 index 00000000..6700b9b3 --- /dev/null +++ b/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt @@ -0,0 +1,57 @@ +package org.sopt.pingle.util.component + +import android.content.DialogInterface +import android.graphics.Paint +import android.os.Bundle +import android.view.View +import org.sopt.pingle.R +import org.sopt.pingle.databinding.DialogMyGroupModalBinding +import org.sopt.pingle.util.base.BindingDialogFragment + +class MyGroupModalDialogFragment( + private val title: String, + private val buttonText: String, + private val textButtonText: String, + private val clickBtn: () -> Unit, + private val clickTextBtn: () -> Unit, + private val onDialogClosed: () -> Unit = {} +) : BindingDialogFragment(R.layout.dialog_my_group_modal) { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + initLayout() + addListeners() + } + + override fun onDismiss(dialog: DialogInterface) { + super.onDismiss(dialog) + onDialogClosed() + } + + private fun initLayout() { + with(binding) { + tvMyGroupModalTitle.text = title + btnMyGroupModalButton.text = buttonText + tvMyGroupModalTextButton.apply { + text = textButtonText + paintFlags = Paint.UNDERLINE_TEXT_FLAG + } + } + } + + private fun addListeners() { + binding.btnMyGroupModalButton.setOnClickListener { + clickBtn() + dismiss() + } + + binding.tvMyGroupModalTextButton.setOnClickListener { + clickTextBtn() + dismiss() + } + + binding.layoutMyGroupModalBackground.setOnClickListener { + dismiss() + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_my_group_modal.xml b/app/src/main/res/layout/dialog_my_group_modal.xml new file mode 100644 index 00000000..66d8748b --- /dev/null +++ b/app/src/main/res/layout/dialog_my_group_modal.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 3df7c155..77108dc4 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -51,6 +51,7 @@ 24dp 34dp 24dp + 34dp 24dp From c36b0d9069589ccb073db37f0f3a5227364b4780 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Thu, 29 Feb 2024 15:55:57 +0900 Subject: [PATCH 18/22] =?UTF-8?q?[chore]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eGroupListDto.kt => ResponseMyGroupDto.kt} | 6 +- .../{GroupListEntity.kt => MyGroupEntity.kt} | 2 +- .../ui/mygroup/MyGroupActivity.kt | 117 +++++++--------- .../presentation/ui/mygroup/MyGroupAdapter.kt | 27 ++-- .../ui/mygroup/MyGroupOwnerViewHolder.kt | 10 +- .../ui/mygroup/MyGroupViewHolder.kt | 16 +-- .../ui/mygroup/MyGroupViewModel.kt | 65 ++++----- ...oup_owner.xml => ic_my_group_owner_58.xml} | 0 ....xml => ic_my_group_selected_owner_58.xml} | 0 .../drawable/shape_border_radius_12_13.xml | 4 + ..._12.xml => shape_line_white_radius_12.xml} | 3 +- app/src/main/res/layout/activity_my_group.xml | 126 +++++++++--------- ...my_group.xml => item_my_group_default.xml} | 10 +- .../main/res/layout/item_my_group_owner.xml | 18 +-- 14 files changed, 186 insertions(+), 218 deletions(-) rename app/src/main/java/org/sopt/pingle/data/model/remote/response/{ResponseGroupListDto.kt => ResponseMyGroupDto.kt} (84%) rename app/src/main/java/org/sopt/pingle/domain/model/{GroupListEntity.kt => MyGroupEntity.kt} (88%) rename app/src/main/res/drawable/{ic_my_group_owner.xml => ic_my_group_owner_58.xml} (100%) rename app/src/main/res/drawable/{ic_my_group_list_owner.xml => ic_my_group_selected_owner_58.xml} (100%) create mode 100644 app/src/main/res/drawable/shape_border_radius_12_13.xml rename app/src/main/res/drawable/{shape_border_white_radius_12.xml => shape_line_white_radius_12.xml} (69%) rename app/src/main/res/layout/{item_my_group.xml => item_my_group_default.xml} (92%) diff --git a/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseMyGroupDto.kt similarity index 84% rename from app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt rename to app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseMyGroupDto.kt index 59f0fd12..93bd4712 100644 --- a/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseGroupListDto.kt +++ b/app/src/main/java/org/sopt/pingle/data/model/remote/response/ResponseMyGroupDto.kt @@ -2,10 +2,10 @@ package org.sopt.pingle.data.model.remote.response import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.domain.model.MyGroupEntity @Serializable -data class ResponseGroupListDto( +data class ResponseMyGroupDto( @SerialName("id") val id: Int, @SerialName("keyword") @@ -21,7 +21,7 @@ data class ResponseGroupListDto( @SerialName("code") val code: String ) { - fun toResponseGroupListEntity() = GroupListEntity( + fun toResponseMyGroupEntity() = MyGroupEntity( id = id, keyword = keyword, name = name, diff --git a/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt b/app/src/main/java/org/sopt/pingle/domain/model/MyGroupEntity.kt similarity index 88% rename from app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt rename to app/src/main/java/org/sopt/pingle/domain/model/MyGroupEntity.kt index cad4c3b8..aa637268 100644 --- a/app/src/main/java/org/sopt/pingle/domain/model/GroupListEntity.kt +++ b/app/src/main/java/org/sopt/pingle/domain/model/MyGroupEntity.kt @@ -1,6 +1,6 @@ package org.sopt.pingle.domain.model -data class GroupListEntity( +data class MyGroupEntity( var id: Int, val keyword: String, val name: String, diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 47ec98a2..584140f8 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -1,12 +1,8 @@ package org.sopt.pingle.presentation.ui.mygroup -import android.content.ClipData -import android.content.ClipboardManager -import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View -import androidx.activity.OnBackPressedCallback import androidx.activity.viewModels import androidx.lifecycle.flowWithLifecycle import androidx.lifecycle.lifecycleScope @@ -18,15 +14,19 @@ import org.sopt.pingle.databinding.ActivityMyGroupBinding import org.sopt.pingle.presentation.type.SnackbarType import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity import org.sopt.pingle.util.base.BindingActivity -import org.sopt.pingle.util.component.AllModalDialogFragment +import org.sopt.pingle.util.component.MyGroupModalDialogFragment import org.sopt.pingle.util.component.PingleSnackbar +import org.sopt.pingle.util.context.PINGLE_PLAY_STORE_LINK +import org.sopt.pingle.util.context.PINGLE_SHARE_CODE +import org.sopt.pingle.util.context.copyGroupCode +import org.sopt.pingle.util.context.setupShareIntent import org.sopt.pingle.util.context.stringOf +import timber.log.Timber @AndroidEntryPoint class MyGroupActivity : BindingActivity(R.layout.activity_my_group) { private val viewModel by viewModels() - private lateinit var onBackPressed: OnBackPressedCallback private lateinit var adapter: MyGroupAdapter override fun onCreate(savedInstanceState: Bundle?) { @@ -35,40 +35,38 @@ class MyGroupActivity : BindingActivity(R.layout.activit binding.myGroupviewModel = viewModel binding.lifecycleOwner = this - viewModel.Logging() initLayout() + initAdapter() addListeners() collectData() - onBackPressedBtn() } override fun onDestroy() { - binding.rvMyGroupList.adapter = null + binding.rvMyGroupSelected.adapter = null super.onDestroy() } private fun initLayout() { - checkMyGroupOwner() viewModel.getGroupList() + binding.toolbarMyGroup.text = getString(R.string.my_group_title) + } - with(binding) { - toolbar.text = getString(R.string.my_group_title) - // TODO chip 머지되면 text에 localStorage에 저장된 keyword 데바 - + private fun initAdapter() { + runCatching { adapter = MyGroupAdapter(this@MyGroupActivity::showChangeGroupModal) - rvMyGroupList.adapter = adapter + binding.rvMyGroupSelected.adapter = adapter adapter.submitList(viewModel.filteredGroupList.value) - } + }.onFailure { throwable -> Timber.e(throwable.message) } } private fun addListeners() { with(binding) { - toolbar.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener { finish() } - tvMyGroupMoveNewGroup.setOnClickListener { navigateToNewGroupInfo() } - ivMyGroupNowMenu.setOnClickListener { showMyGroupMenu() } - root.setOnClickListener { layoutMyGroupMenu.visibility = View.INVISIBLE } - layoutMyGroupMenuCopy.setOnClickListener { copyGroupCode() } - layoutMyGroupMenuShare.setOnClickListener { shareGroupCode() } + toolbarMyGroup.ivAllTopbarArrowWithTitleArrowLeft.setOnClickListener { finish() } + tvMyGroupMoveSelectedGroup.setOnClickListener { navigateToNewGroupInfo() } + ivMyGroupSelectedMenu.setOnClickListener { showMyGroupMenu() } + root.setOnClickListener { layoutMyGroupSelectedMenu.visibility = View.INVISIBLE } + layoutMyGroupSelectedMenuCopy.setOnClickListener { copyGroupCode() } + layoutMyGroupSelectedMenuShare.setOnClickListener { shareGroupCode() } } } @@ -76,37 +74,39 @@ class MyGroupActivity : BindingActivity(R.layout.activit viewModel.filteredGroupList.flowWithLifecycle(lifecycle).onEach { filteredList -> adapter.submitList(filteredList) }.launchIn(lifecycleScope) - } - private fun checkMyGroupOwner() { - with(binding) { - if (viewModel.getMyGroupIsOwner()) { - ivMyGroupNowOwner.visibility = View.VISIBLE - } else { - ivMyGroupNowOwner.visibility = View.INVISIBLE + viewModel.selectedMyGroup.flowWithLifecycle(lifecycle).onEach { selectedMyGroup -> + with(binding) { + if (selectedMyGroup!!.isOwner) { + ivMyGroupSelectedOwner.visibility = View.VISIBLE + } else { + ivMyGroupSelectedOwner.visibility = View.INVISIBLE + } } - } + }.launchIn(lifecycleScope) } private fun showMyGroupMenu() { with(binding) { - if (layoutMyGroupMenu.visibility == View.VISIBLE) { - layoutMyGroupMenu.visibility = View.INVISIBLE + if (layoutMyGroupSelectedMenu.visibility == View.VISIBLE) { + layoutMyGroupSelectedMenu.visibility = View.INVISIBLE } else { - layoutMyGroupMenu.visibility = View.VISIBLE + layoutMyGroupSelectedMenu.visibility = View.VISIBLE } } } private fun showChangeGroupModal(clickedPosition: Int) { - binding.layoutMyGroupMenu.visibility = View.INVISIBLE - AllModalDialogFragment( - title = getString(R.string.my_group_modal_move_question, viewModel.filteredGroupList.value[clickedPosition].name), - detail = null, + binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE + MyGroupModalDialogFragment( + title = getString( + R.string.my_group_modal_move_question, + viewModel.filteredGroupList.value[clickedPosition].name, + ), buttonText = getString(R.string.my_group_modal_change), textButtonText = getString(R.string.my_group_modal_back), clickBtn = { chageToNewGroup(clickedPosition) }, - clickTextBtn = { } + clickTextBtn = { }, ).show(supportFragmentManager, CHANGE_MODAL) } @@ -117,36 +117,27 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_chage_group_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE + snackbarType = SnackbarType.GUIDE, ) - - viewModel.Logging() } private fun copyGroupCode() { - val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager - val clip: ClipData = ClipData.newPlainText(GROUP_CODE_COPY, viewModel.getGroupCode()) - clipboard.setPrimaryClip(clip) - + binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE + copyGroupCode(viewModel.getGroupCode()) PingleSnackbar.makeSnackbar( view = binding.root, message = stringOf(R.string.my_group_snack_bar_code_copy_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE + snackbarType = SnackbarType.GUIDE, ) } private fun shareGroupCode() { - val intent = Intent(Intent.ACTION_SEND_MULTIPLE) - with(intent) { - type = SHARE_TYPE - // TODO 기획에서 전달해준 템플릿 적용 - putExtra( - Intent.EXTRA_TEXT, - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" - ) - } - startActivity(Intent.createChooser(intent, null)) + // TODO 콘텐츠 내용 알려주면 ContextExt와 함께 수정 + binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE + this.setupShareIntent( + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", + ) } private fun navigateToNewGroupInfo() { @@ -155,22 +146,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit } } - private fun onBackPressedBtn() { - onBackPressed = object : OnBackPressedCallback(true) { - override fun handleOnBackPressed() { - finish() - } - } - onBackPressedDispatcher.addCallback(this, onBackPressed) - } - companion object { private const val CHANGE_MODAL = "ChangeGroupModal" private const val SNACKBAR_BOTTOM_MARGIN = 57 - private const val GROUP_CODE_COPY = "CopyGroupCode" - private const val PINGLE_PLAY_STORE_LINK = - "앱 링크 : https://play.google.com/store/apps/details?id=org.sopt.pingle&pcampaignid=web_share" - private const val PINGLE_SHARE_CODE = "초대코드 : " - private const val SHARE_TYPE = "text/plain" } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index aac5c345..b65d0a77 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -4,32 +4,36 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView -import org.sopt.pingle.databinding.ItemMyGroupBinding +import org.sopt.pingle.databinding.ItemMyGroupDefaultBinding import org.sopt.pingle.databinding.ItemMyGroupOwnerBinding -import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.domain.model.MyGroupEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: (Int) -> Unit -) : ListAdapter( - ItemDiffCallback( + private val groupOnClick: (Int) -> Unit, +) : ListAdapter( + ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, - onItemsTheSame = { old, new -> old.id == new.id } - ) + onItemsTheSame = { old, new -> old.id == new.id }, + ), ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { DEFAULT_GROUP -> MyGroupViewHolder( - ItemMyGroupBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick + ItemMyGroupDefaultBinding.inflate( + LayoutInflater.from(parent.context), + parent, + false, + ), + groupOnClick, ) OWNER_GROUP -> MyGroupOwnerViewHolder( ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick + groupOnClick, ) - else -> throw RuntimeException() + else -> throw IllegalArgumentException("$VIEWTYPE_EXCEPTION_MESSAGE $viewType") } } @@ -51,5 +55,6 @@ class MyGroupAdapter( companion object { private const val OWNER_GROUP = 2 private const val DEFAULT_GROUP = 1 + private const val VIEWTYPE_EXCEPTION_MESSAGE = "Invalid viewType: " } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt index 5bc4879d..376212e6 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt @@ -2,18 +2,18 @@ package org.sopt.pingle.presentation.ui.mygroup import androidx.recyclerview.widget.RecyclerView import org.sopt.pingle.databinding.ItemMyGroupOwnerBinding -import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.domain.model.MyGroupEntity class MyGroupOwnerViewHolder( private val binding: ItemMyGroupOwnerBinding, private val groupOnClick: (Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { - fun onBind(groupListEntity: GroupListEntity) { + fun onBind(myGroupEntity: MyGroupEntity) { with(binding) { - this.groupListEntity = groupListEntity - binding.tvMyGroupListOwnerName.text = groupListEntity.name - layoutMyGroupListOwner.setOnClickListener { groupOnClick(absoluteAdapterPosition) } + this.groupListEntity = myGroupEntity + tvMyGroupOwnerName.text = myGroupEntity.name + layoutMyGroupOwner.setOnClickListener { groupOnClick(absoluteAdapterPosition) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt index d530cd4c..2546b865 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -1,19 +1,19 @@ package org.sopt.pingle.presentation.ui.mygroup import androidx.recyclerview.widget.RecyclerView -import org.sopt.pingle.databinding.ItemMyGroupBinding -import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.databinding.ItemMyGroupDefaultBinding +import org.sopt.pingle.domain.model.MyGroupEntity class MyGroupViewHolder( - private val binding: ItemMyGroupBinding, - private val groupOnClick: (Int) -> Unit + private val binding: ItemMyGroupDefaultBinding, + private val groupOnClick: (Int) -> Unit, ) : RecyclerView.ViewHolder(binding.root) { - fun onBind(groupListEntity: GroupListEntity) { + fun onBind(myGroupEntity: MyGroupEntity) { with(binding) { - this.groupListEntity = groupListEntity - tvMyGroupListDefaultName.text = groupListEntity.name - layoutMyGroupListDefault.setOnClickListener { groupOnClick(absoluteAdapterPosition) } + this.groupListEntity = myGroupEntity + tvMyGroupDefaultName.text = myGroupEntity.name + layoutMyGroupDefault.setOnClickListener { groupOnClick(absoluteAdapterPosition) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index 67a0fb34..ed413fb6 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -1,32 +1,21 @@ package org.sopt.pingle.presentation.ui.mygroup -import android.util.Log import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel -import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import org.sopt.pingle.data.datasource.local.PingleLocalDataSource -import org.sopt.pingle.domain.model.GroupListEntity +import org.sopt.pingle.domain.model.MyGroupEntity +import javax.inject.Inject @HiltViewModel class MyGroupViewModel @Inject constructor( - private val localStorgae: PingleLocalDataSource + private val localStorgae: PingleLocalDataSource, ) : ViewModel() { - fun Logging() { - Log.e("localStorage", localStorgae.groupId.toString()) - Log.e("localStorage", localStorgae.groupName) - Log.e("localStorage", localStorgae.meetingCount) - Log.e("localStorage", localStorgae.participantCount) - Log.e("localStorage", localStorgae.isOwner.toString()) - Log.e("localStorage", localStorgae.groupKeyword) - Log.e("localStorage", localStorgae.code) - } - - private var _filteredGroupList = MutableStateFlow>(emptyList()) + private var _filteredGroupList = MutableStateFlow>(emptyList()) val filteredGroupList get() = _filteredGroupList - private var _selectedMyGroup = MutableStateFlow(null) + private var _selectedMyGroup = MutableStateFlow(null) val selectedMyGroup get() = _selectedMyGroup // TODO 서버통신 List @@ -69,81 +58,81 @@ class MyGroupViewModel @Inject constructor( _filteredGroupList.value = dummyGroupList.filterNot { it == selectedMyGroup.value } } - fun getMyGroupIsOwner(): Boolean = localStorgae.isOwner + fun getMyGroupIsOwner(): Boolean = _selectedMyGroup.value!!.isOwner - fun getGroupName(): String = localStorgae.groupName + fun getGroupName(): String = _selectedMyGroup.value!!.name - fun getGroupMeetingCount(): String = localStorgae.meetingCount + fun getGroupMeetingCount(): String = _selectedMyGroup.value!!.meetingCount - fun getGroupParticipantCount(): String = localStorgae.participantCount + fun getGroupParticipantCount(): String = _selectedMyGroup.value!!.participantCount - fun getGroupCode(): String = localStorgae.code + fun getGroupCode(): String = _selectedMyGroup.value!!.code - fun getGroupKeyword(): String = localStorgae.groupKeyword + fun getGroupKeyword(): String = _selectedMyGroup.value!!.keyword - val dummyGroupList = listOf( - GroupListEntity( + val dummyGroupList = listOf( + MyGroupEntity( id = 12341, name = "SOPT", meetingCount = "12", participantCount = "76", keyword = "연합동아리", isOwner = true, - code = "soptcode" + code = "soptcode", ), - GroupListEntity( + MyGroupEntity( id = 48103, name = "UMC", keyword = "연합동아리", meetingCount = "3", participantCount = "72", isOwner = false, - code = "umccode" + code = "umccode", ), - GroupListEntity( + MyGroupEntity( id = 314927, name = "SOPT MAKERS", keyword = "자체기구", meetingCount = "114", participantCount = "3", isOwner = false, - code = "makerscode" + code = "makerscode", ), - GroupListEntity( + MyGroupEntity( id = 4915, name = "소나무", keyword = "교내동아리", meetingCount = "98", participantCount = "11", isOwner = false, - code = "sonamucode" + code = "sonamucode", ), - GroupListEntity( + MyGroupEntity( id = 12792, name = "불꽃컴공", keyword = "학생회", meetingCount = "35", participantCount = "1123", isOwner = true, - code = "donggukcode" + code = "donggukcode", ), - GroupListEntity( + MyGroupEntity( id = 852, name = "TEAM PINGLE", keyword = "동호회", meetingCount = "254", participantCount = "56", isOwner = false, - code = "pinglecode" + code = "pinglecode", ), - GroupListEntity( + MyGroupEntity( id = 1, name = "SERVER", keyword = "사모임", meetingCount = "2", participantCount = "16", isOwner = true, - code = "aaaaaaaaaaaa" - ) + code = "aaaaaaaaaaaa", + ), ) } diff --git a/app/src/main/res/drawable/ic_my_group_owner.xml b/app/src/main/res/drawable/ic_my_group_owner_58.xml similarity index 100% rename from app/src/main/res/drawable/ic_my_group_owner.xml rename to app/src/main/res/drawable/ic_my_group_owner_58.xml diff --git a/app/src/main/res/drawable/ic_my_group_list_owner.xml b/app/src/main/res/drawable/ic_my_group_selected_owner_58.xml similarity index 100% rename from app/src/main/res/drawable/ic_my_group_list_owner.xml rename to app/src/main/res/drawable/ic_my_group_selected_owner_58.xml diff --git a/app/src/main/res/drawable/shape_border_radius_12_13.xml b/app/src/main/res/drawable/shape_border_radius_12_13.xml new file mode 100644 index 00000000..f7b4cfa7 --- /dev/null +++ b/app/src/main/res/drawable/shape_border_radius_12_13.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_border_white_radius_12.xml b/app/src/main/res/drawable/shape_line_white_radius_12.xml similarity index 69% rename from app/src/main/res/drawable/shape_border_white_radius_12.xml rename to app/src/main/res/drawable/shape_line_white_radius_12.xml index f11e4623..d2335bc4 100644 --- a/app/src/main/res/drawable/shape_border_white_radius_12.xml +++ b/app/src/main/res/drawable/shape_line_white_radius_12.xml @@ -1,6 +1,5 @@ - - + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 92bc60fb..62fca109 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -5,12 +5,6 @@ - - - - @@ -22,7 +16,7 @@ tools:context=".presentation.ui.mygroup.MyGroupActivity"> + app:layout_constraintTop_toBottomOf="@id/toolbar_my_group"> + app:layout_constraintStart_toEndOf="@id/gl_selected_start" + app:layout_constraintTop_toBottomOf="@id/tv_my_group_selected_name" /> + app:layout_constraintBottom_toBottomOf="@id/tv_my_group_selected_meeting" + app:layout_constraintStart_toEndOf="@id/tv_my_group_selected_meeting" + app:layout_constraintTop_toTopOf="@id/tv_my_group_selected_meeting" /> + app:layout_constraintBottom_toBottomOf="@id/tv_my_group_selected_member" + app:layout_constraintStart_toEndOf="@id/tv_my_group_selected_member" + app:layout_constraintTop_toTopOf="@id/tv_my_group_selected_member" /> + app:layout_constraintBottom_toBottomOf="@id/gl_selected_bottom" + app:layout_constraintStart_toEndOf="@id/gl_selected_start" + app:layout_constraintTop_toBottomOf="@id/tv_my_group_selected_meeting" /> + app:layout_constraintTop_toTopOf="@id/layout_my_group_selected" /> + app:layout_constraintTop_toBottomOf="@id/layout_my_group_selected" /> + app:layout_constraintTop_toBottomOf="@id/view_my_group_selected_divider" + tools:listitem="@layout/item_my_group_default" /> + app:layout_constraintTop_toBottomOf="@id/rv_my_group_selected" /> + app:layout_constraintTop_toBottomOf="@id/iv_my_group_selected_menu"> + app:layout_constraintTop_toBottomOf="@id/view_my_group_selected_menu_divider"> + app:layout_constraintTop_toBottomOf="@id/layout_my_group_selected_menu_copy" /> diff --git a/app/src/main/res/layout/item_my_group.xml b/app/src/main/res/layout/item_my_group_default.xml similarity index 92% rename from app/src/main/res/layout/item_my_group.xml rename to app/src/main/res/layout/item_my_group_default.xml index 3d9ccede..567bf9d8 100644 --- a/app/src/main/res/layout/item_my_group.xml +++ b/app/src/main/res/layout/item_my_group_default.xml @@ -7,7 +7,7 @@ + type="org.sopt.pingle.domain.model.MyGroupEntity" /> diff --git a/app/src/main/res/layout/item_my_group_owner.xml b/app/src/main/res/layout/item_my_group_owner.xml index c22150d9..a270a619 100644 --- a/app/src/main/res/layout/item_my_group_owner.xml +++ b/app/src/main/res/layout/item_my_group_owner.xml @@ -7,7 +7,7 @@ + type="org.sopt.pingle.domain.model.MyGroupEntity" /> + android:src="@drawable/ic_my_group_selected_owner_58" + app:layout_constraintBottom_toBottomOf="@id/layout_my_group_owner" + app:layout_constraintEnd_toEndOf="@id/layout_my_group_owner" /> \ No newline at end of file From 45319c245cbfa21bdbf3ad8acb3c33069ab3128f Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Thu, 29 Feb 2024 15:57:50 +0900 Subject: [PATCH 19/22] =?UTF-8?q?[chore]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20ktlintFormat=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/mygroup/MyGroupActivity.kt | 14 ++++++------- .../presentation/ui/mygroup/MyGroupAdapter.kt | 12 +++++------ .../ui/mygroup/MyGroupViewHolder.kt | 2 +- .../ui/mygroup/MyGroupViewModel.kt | 20 +++++++++---------- .../component/MyGroupModalDialogFragment.kt | 2 +- .../sopt/pingle/util/context/ContextExt.kt | 5 ++--- 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index 584140f8..c49a2363 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -19,7 +19,7 @@ import org.sopt.pingle.util.component.PingleSnackbar import org.sopt.pingle.util.context.PINGLE_PLAY_STORE_LINK import org.sopt.pingle.util.context.PINGLE_SHARE_CODE import org.sopt.pingle.util.context.copyGroupCode -import org.sopt.pingle.util.context.setupShareIntent +import org.sopt.pingle.util.context.sharePingle import org.sopt.pingle.util.context.stringOf import timber.log.Timber @@ -101,12 +101,12 @@ class MyGroupActivity : BindingActivity(R.layout.activit MyGroupModalDialogFragment( title = getString( R.string.my_group_modal_move_question, - viewModel.filteredGroupList.value[clickedPosition].name, + viewModel.filteredGroupList.value[clickedPosition].name ), buttonText = getString(R.string.my_group_modal_change), textButtonText = getString(R.string.my_group_modal_back), clickBtn = { chageToNewGroup(clickedPosition) }, - clickTextBtn = { }, + clickTextBtn = { } ).show(supportFragmentManager, CHANGE_MODAL) } @@ -117,7 +117,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_chage_group_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) } @@ -128,15 +128,15 @@ class MyGroupActivity : BindingActivity(R.layout.activit view = binding.root, message = stringOf(R.string.my_group_snack_bar_code_copy_complete), bottomMarin = SNACKBAR_BOTTOM_MARGIN, - snackbarType = SnackbarType.GUIDE, + snackbarType = SnackbarType.GUIDE ) } private fun shareGroupCode() { // TODO 콘텐츠 내용 알려주면 ContextExt와 함께 수정 binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE - this.setupShareIntent( - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK", + this.sharePingle( + "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" ) } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index b65d0a77..a2c6475e 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -10,12 +10,12 @@ import org.sopt.pingle.domain.model.MyGroupEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: (Int) -> Unit, + private val groupOnClick: (Int) -> Unit ) : ListAdapter( ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, - onItemsTheSame = { old, new -> old.id == new.id }, - ), + onItemsTheSame = { old, new -> old.id == new.id } + ) ) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { @@ -23,14 +23,14 @@ class MyGroupAdapter( ItemMyGroupDefaultBinding.inflate( LayoutInflater.from(parent.context), parent, - false, + false ), - groupOnClick, + groupOnClick ) OWNER_GROUP -> MyGroupOwnerViewHolder( ItemMyGroupOwnerBinding.inflate(LayoutInflater.from(parent.context), parent, false), - groupOnClick, + groupOnClick ) else -> throw IllegalArgumentException("$VIEWTYPE_EXCEPTION_MESSAGE $viewType") diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt index 2546b865..fd15b187 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -6,7 +6,7 @@ import org.sopt.pingle.domain.model.MyGroupEntity class MyGroupViewHolder( private val binding: ItemMyGroupDefaultBinding, - private val groupOnClick: (Int) -> Unit, + private val groupOnClick: (Int) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(myGroupEntity: MyGroupEntity) { diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index ed413fb6..86af2400 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -2,14 +2,14 @@ package org.sopt.pingle.presentation.ui.mygroup import androidx.lifecycle.ViewModel import dagger.hilt.android.lifecycle.HiltViewModel +import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import org.sopt.pingle.data.datasource.local.PingleLocalDataSource import org.sopt.pingle.domain.model.MyGroupEntity -import javax.inject.Inject @HiltViewModel class MyGroupViewModel @Inject constructor( - private val localStorgae: PingleLocalDataSource, + private val localStorgae: PingleLocalDataSource ) : ViewModel() { private var _filteredGroupList = MutableStateFlow>(emptyList()) @@ -78,7 +78,7 @@ class MyGroupViewModel @Inject constructor( participantCount = "76", keyword = "연합동아리", isOwner = true, - code = "soptcode", + code = "soptcode" ), MyGroupEntity( id = 48103, @@ -87,7 +87,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "3", participantCount = "72", isOwner = false, - code = "umccode", + code = "umccode" ), MyGroupEntity( id = 314927, @@ -96,7 +96,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "114", participantCount = "3", isOwner = false, - code = "makerscode", + code = "makerscode" ), MyGroupEntity( id = 4915, @@ -105,7 +105,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "98", participantCount = "11", isOwner = false, - code = "sonamucode", + code = "sonamucode" ), MyGroupEntity( id = 12792, @@ -114,7 +114,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "35", participantCount = "1123", isOwner = true, - code = "donggukcode", + code = "donggukcode" ), MyGroupEntity( id = 852, @@ -123,7 +123,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "254", participantCount = "56", isOwner = false, - code = "pinglecode", + code = "pinglecode" ), MyGroupEntity( id = 1, @@ -132,7 +132,7 @@ class MyGroupViewModel @Inject constructor( meetingCount = "2", participantCount = "16", isOwner = true, - code = "aaaaaaaaaaaa", - ), + code = "aaaaaaaaaaaa" + ) ) } diff --git a/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt b/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt index 6700b9b3..300b4e1b 100644 --- a/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt +++ b/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt @@ -54,4 +54,4 @@ class MyGroupModalDialogFragment( dismiss() } } -} \ No newline at end of file +} diff --git a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt index d0bd24bf..c8ca8671 100644 --- a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt +++ b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt @@ -12,7 +12,6 @@ import androidx.annotation.StringRes import androidx.core.content.ContextCompat import org.sopt.pingle.presentation.ui.common.WebViewActivity import org.sopt.pingle.presentation.ui.common.WebViewActivity.Companion.WEB_VIEW_LINK -import org.sopt.pingle.presentation.ui.mygroup.MyGroupActivity fun Context.hideKeyboard(view: View) { val inputMethodManager = getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager @@ -28,7 +27,7 @@ fun Context.navigateToWebView(link: String) = Intent(this, WebViewActivity::clas putExtra(WEB_VIEW_LINK, link) } -fun Context.setupShareIntent(shareContent: String) { +fun Context.sharePingle(shareContent: String) { val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { type = SHARE_TYPE putExtra(Intent.EXTRA_TEXT, shareContent) @@ -36,7 +35,7 @@ fun Context.setupShareIntent(shareContent: String) { startActivity(Intent.createChooser(intent, null)) } -fun Context.copyGroupCode(copyCode: String){ +fun Context.copyGroupCode(copyCode: String) { val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip: ClipData = ClipData.newPlainText(GROUP_CODE_COPY, copyCode) clipboard.setPrimaryClip(clip) From 62b6a15b7628cb68dd5a60d29d19bfe03f0aa1c6 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Mar 2024 14:47:59 +0900 Subject: [PATCH 20/22] =?UTF-8?q?[chore]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/mygroup/MyGroupActivity.kt | 26 +++++----- .../presentation/ui/mygroup/MyGroupAdapter.kt | 2 +- .../ui/mygroup/MyGroupOwnerViewHolder.kt | 4 +- .../ui/mygroup/MyGroupViewHolder.kt | 4 +- .../ui/mygroup/MyGroupViewModel.kt | 49 +++++++++---------- app/src/main/res/values/strings.xml | 1 + 6 files changed, 42 insertions(+), 44 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index c49a2363..accfebbc 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import org.sopt.pingle.R import org.sopt.pingle.databinding.ActivityMyGroupBinding +import org.sopt.pingle.domain.model.MyGroupEntity import org.sopt.pingle.presentation.type.SnackbarType import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity import org.sopt.pingle.util.base.BindingActivity @@ -33,10 +34,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit super.onCreate(savedInstanceState) binding.myGroupviewModel = viewModel - binding.lifecycleOwner = this initLayout() - initAdapter() addListeners() collectData() } @@ -48,7 +47,8 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun initLayout() { viewModel.getGroupList() - binding.toolbarMyGroup.text = getString(R.string.my_group_title) + binding.toolbarMyGroup.text = stringOf(R.string.my_group_title) + initAdapter() } private fun initAdapter() { @@ -77,7 +77,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit viewModel.selectedMyGroup.flowWithLifecycle(lifecycle).onEach { selectedMyGroup -> with(binding) { - if (selectedMyGroup!!.isOwner) { + if (selectedMyGroup?.isOwner == true) { ivMyGroupSelectedOwner.visibility = View.VISIBLE } else { ivMyGroupSelectedOwner.visibility = View.INVISIBLE @@ -96,22 +96,22 @@ class MyGroupActivity : BindingActivity(R.layout.activit } } - private fun showChangeGroupModal(clickedPosition: Int) { + private fun showChangeGroupModal(clickedEntity: MyGroupEntity) { binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE MyGroupModalDialogFragment( title = getString( R.string.my_group_modal_move_question, - viewModel.filteredGroupList.value[clickedPosition].name + clickedEntity.name ), - buttonText = getString(R.string.my_group_modal_change), - textButtonText = getString(R.string.my_group_modal_back), - clickBtn = { chageToNewGroup(clickedPosition) }, + buttonText = stringOf(R.string.my_group_modal_change), + textButtonText = stringOf(R.string.my_group_modal_back), + clickBtn = { chageToNewGroup(clickedEntity) }, clickTextBtn = { } ).show(supportFragmentManager, CHANGE_MODAL) } - private fun chageToNewGroup(clickedPosition: Int) { - viewModel.changeGroupList(clickedPosition) + private fun chageToNewGroup(clickedEntity: MyGroupEntity) { + viewModel.changeGroupList(clickedEntity) PingleSnackbar.makeSnackbar( view = binding.root, @@ -135,9 +135,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun shareGroupCode() { // TODO 콘텐츠 내용 알려주면 ContextExt와 함께 수정 binding.layoutMyGroupSelectedMenu.visibility = View.INVISIBLE - this.sharePingle( - "핑글 앱을 다운받고, ${viewModel.getGroupName()} 사람들을 만나보세요!\n\n$PINGLE_SHARE_CODE ${viewModel.getGroupCode()} \n\n $PINGLE_PLAY_STORE_LINK" - ) + this.sharePingle(getString(R.string.my_group_share_pingle, viewModel.getGroupName(), PINGLE_SHARE_CODE, viewModel.getGroupCode(), PINGLE_PLAY_STORE_LINK)) } private fun navigateToNewGroupInfo() { diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt index a2c6475e..1948e1ce 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupAdapter.kt @@ -10,7 +10,7 @@ import org.sopt.pingle.domain.model.MyGroupEntity import org.sopt.pingle.util.view.ItemDiffCallback class MyGroupAdapter( - private val groupOnClick: (Int) -> Unit + private val groupOnClick: (MyGroupEntity) -> Unit ) : ListAdapter( ItemDiffCallback( onContentsTheSame = { old, new -> old == new }, diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt index 376212e6..1640913f 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupOwnerViewHolder.kt @@ -6,14 +6,14 @@ import org.sopt.pingle.domain.model.MyGroupEntity class MyGroupOwnerViewHolder( private val binding: ItemMyGroupOwnerBinding, - private val groupOnClick: (Int) -> Unit + private val groupOnClick: (MyGroupEntity) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(myGroupEntity: MyGroupEntity) { with(binding) { this.groupListEntity = myGroupEntity tvMyGroupOwnerName.text = myGroupEntity.name - layoutMyGroupOwner.setOnClickListener { groupOnClick(absoluteAdapterPosition) } + layoutMyGroupOwner.setOnClickListener { groupOnClick(myGroupEntity) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt index fd15b187..9997481d 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewHolder.kt @@ -6,14 +6,14 @@ import org.sopt.pingle.domain.model.MyGroupEntity class MyGroupViewHolder( private val binding: ItemMyGroupDefaultBinding, - private val groupOnClick: (Int) -> Unit + private val groupOnClick: (MyGroupEntity) -> Unit ) : RecyclerView.ViewHolder(binding.root) { fun onBind(myGroupEntity: MyGroupEntity) { with(binding) { this.groupListEntity = myGroupEntity tvMyGroupDefaultName.text = myGroupEntity.name - layoutMyGroupDefault.setOnClickListener { groupOnClick(absoluteAdapterPosition) } + layoutMyGroupDefault.setOnClickListener { groupOnClick(myGroupEntity) } } } } diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt index 86af2400..2e6f8813 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupViewModel.kt @@ -23,52 +23,51 @@ class MyGroupViewModel @Inject constructor( fun getGroupList() { // TODO 서버통신 selectedMyGroup.value = dummyGroupList.find { it.id == localStorgae.groupId } - selectedMyGroup.value.let { + selectedMyGroup.value?.let { selectedMyGroup -> with(localStorgae) { - groupId = it!!.id - groupName = it!!.name - groupKeyword = it!!.keyword - meetingCount = it!!.meetingCount - participantCount = it!!.participantCount - isOwner = it!!.isOwner - code = it!!.code + groupId = selectedMyGroup.id + groupName = selectedMyGroup.name + groupKeyword = selectedMyGroup.keyword + meetingCount = selectedMyGroup.meetingCount + participantCount = selectedMyGroup.participantCount + isOwner = selectedMyGroup.isOwner + code = selectedMyGroup.code } } _filteredGroupList.value = dummyGroupList.filterNot { it == selectedMyGroup.value } } - fun changeGroupList(clickedPosition: Int) { + fun changeGroupList(clickedEntity: MyGroupEntity) { // _filteredGroupList의 clickedPosition에 해당하는 값을 localStorage에 저장하고, // _filteredGroupList의 clickedPosition에 selectedMyGroup를 저장 // selectedMyGroup에는 localStorage에 저장된 값과 같은 GroupListEntity를 저장 - val clickedGroup = _filteredGroupList.value.getOrNull(clickedPosition) - clickedGroup?.let { + clickedEntity?.let { clickedEntity -> with(localStorgae) { - groupId = it.id - groupName = it.name - groupKeyword = it.keyword - meetingCount = it.meetingCount - participantCount = it.participantCount - isOwner = it.isOwner - code = it.code + groupId = clickedEntity.id + groupName = clickedEntity.name + groupKeyword = clickedEntity.keyword + meetingCount = clickedEntity.meetingCount + participantCount = clickedEntity.participantCount + isOwner = clickedEntity.isOwner + code = clickedEntity.code } } - _selectedMyGroup.value = clickedGroup + _selectedMyGroup.value = clickedEntity _filteredGroupList.value = dummyGroupList.filterNot { it == selectedMyGroup.value } } - fun getMyGroupIsOwner(): Boolean = _selectedMyGroup.value!!.isOwner + fun getMyGroupIsOwner(): Boolean = _selectedMyGroup.value?.isOwner ?: false - fun getGroupName(): String = _selectedMyGroup.value!!.name + fun getGroupName(): String = _selectedMyGroup.value?.name.orEmpty() - fun getGroupMeetingCount(): String = _selectedMyGroup.value!!.meetingCount + fun getGroupMeetingCount(): String = _selectedMyGroup.value?.meetingCount.orEmpty() - fun getGroupParticipantCount(): String = _selectedMyGroup.value!!.participantCount + fun getGroupParticipantCount(): String = _selectedMyGroup.value?.participantCount.orEmpty() - fun getGroupCode(): String = _selectedMyGroup.value!!.code + fun getGroupCode(): String = _selectedMyGroup.value?.code.orEmpty() - fun getGroupKeyword(): String = _selectedMyGroup.value!!.keyword + fun getGroupKeyword(): String = _selectedMyGroup.value?.keyword.orEmpty() val dummyGroupList = listOf( MyGroupEntity( diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0fb73f55..7605751e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -225,4 +225,5 @@ 단체가 변경되었습니다! 초대코드 복사하기 공유하기 + 핑글 앱을 다운받고, %s 사람들을 만나보세요!\n\n%s %s\n\n %s \ No newline at end of file From 9924c7c45e5499a9e88a55fcb832c87f44c8e54c Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Mar 2024 15:28:11 +0900 Subject: [PATCH 21/22] =?UTF-8?q?[chore]=20#194=20=EB=82=98=EC=9D=98=20?= =?UTF-8?q?=EB=8B=A8=EC=B2=B4=20=EB=B7=B0=20:=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/mygroup/MyGroupActivity.kt | 12 +----------- .../ui/mygroup}/MyGroupModalDialogFragment.kt | 2 +- .../java/org/sopt/pingle/util/context/ContextExt.kt | 4 ++-- ...up_menu_copy.xml => ic_my_group_menu_copy_20.xml} | 0 ..._menu_share.xml => ic_my_group_menu_share_20.xml} | 0 app/src/main/res/layout/activity_my_group.xml | 4 ++-- 6 files changed, 6 insertions(+), 16 deletions(-) rename app/src/main/java/org/sopt/pingle/{util/component => presentation/ui/mygroup}/MyGroupModalDialogFragment.kt (97%) rename app/src/main/res/drawable/{ic_my_group_menu_copy.xml => ic_my_group_menu_copy_20.xml} (100%) rename app/src/main/res/drawable/{ic_my_group_menu_share.xml => ic_my_group_menu_share_20.xml} (100%) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt index accfebbc..908d8b8f 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupActivity.kt @@ -15,7 +15,6 @@ import org.sopt.pingle.domain.model.MyGroupEntity import org.sopt.pingle.presentation.type.SnackbarType import org.sopt.pingle.presentation.ui.onboarding.OnBoardingActivity import org.sopt.pingle.util.base.BindingActivity -import org.sopt.pingle.util.component.MyGroupModalDialogFragment import org.sopt.pingle.util.component.PingleSnackbar import org.sopt.pingle.util.context.PINGLE_PLAY_STORE_LINK import org.sopt.pingle.util.context.PINGLE_SHARE_CODE @@ -48,10 +47,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit private fun initLayout() { viewModel.getGroupList() binding.toolbarMyGroup.text = stringOf(R.string.my_group_title) - initAdapter() - } - private fun initAdapter() { runCatching { adapter = MyGroupAdapter(this@MyGroupActivity::showChangeGroupModal) binding.rvMyGroupSelected.adapter = adapter @@ -76,13 +72,7 @@ class MyGroupActivity : BindingActivity(R.layout.activit }.launchIn(lifecycleScope) viewModel.selectedMyGroup.flowWithLifecycle(lifecycle).onEach { selectedMyGroup -> - with(binding) { - if (selectedMyGroup?.isOwner == true) { - ivMyGroupSelectedOwner.visibility = View.VISIBLE - } else { - ivMyGroupSelectedOwner.visibility = View.INVISIBLE - } - } + binding.ivMyGroupSelectedOwner.visibility = if (selectedMyGroup?.isOwner == true) View.VISIBLE else View.INVISIBLE }.launchIn(lifecycleScope) } diff --git a/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupModalDialogFragment.kt similarity index 97% rename from app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt rename to app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupModalDialogFragment.kt index 300b4e1b..0f3c1dae 100644 --- a/app/src/main/java/org/sopt/pingle/util/component/MyGroupModalDialogFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/mygroup/MyGroupModalDialogFragment.kt @@ -1,4 +1,4 @@ -package org.sopt.pingle.util.component +package org.sopt.pingle.presentation.ui.mygroup import android.content.DialogInterface import android.graphics.Paint diff --git a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt index c8ca8671..44d61eb0 100644 --- a/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt +++ b/app/src/main/java/org/sopt/pingle/util/context/ContextExt.kt @@ -28,11 +28,11 @@ fun Context.navigateToWebView(link: String) = Intent(this, WebViewActivity::clas } fun Context.sharePingle(shareContent: String) { - val intent = Intent(Intent.ACTION_SEND_MULTIPLE).apply { + Intent(Intent.ACTION_SEND_MULTIPLE).apply { type = SHARE_TYPE putExtra(Intent.EXTRA_TEXT, shareContent) + startActivity(Intent.createChooser(this, null)) } - startActivity(Intent.createChooser(intent, null)) } fun Context.copyGroupCode(copyCode: String) { diff --git a/app/src/main/res/drawable/ic_my_group_menu_copy.xml b/app/src/main/res/drawable/ic_my_group_menu_copy_20.xml similarity index 100% rename from app/src/main/res/drawable/ic_my_group_menu_copy.xml rename to app/src/main/res/drawable/ic_my_group_menu_copy_20.xml diff --git a/app/src/main/res/drawable/ic_my_group_menu_share.xml b/app/src/main/res/drawable/ic_my_group_menu_share_20.xml similarity index 100% rename from app/src/main/res/drawable/ic_my_group_menu_share.xml rename to app/src/main/res/drawable/ic_my_group_menu_share_20.xml diff --git a/app/src/main/res/layout/activity_my_group.xml b/app/src/main/res/layout/activity_my_group.xml index 62fca109..486228ef 100644 --- a/app/src/main/res/layout/activity_my_group.xml +++ b/app/src/main/res/layout/activity_my_group.xml @@ -240,7 +240,7 @@ android:id="@+id/iv_my_group_selected_menu_copy" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_my_group_menu_copy" + android:src="@drawable/ic_my_group_menu_copy_20" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -271,7 +271,7 @@ android:id="@+id/iv_my_group_selected_menu_share" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:src="@drawable/ic_my_group_menu_share" + android:src="@drawable/ic_my_group_menu_share_20" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> From 46cd733252aca908c55bd723cb81909ca5e60c21 Mon Sep 17 00:00:00 2001 From: JIEUNI Date: Fri, 1 Mar 2024 15:34:06 +0900 Subject: [PATCH 22/22] =?UTF-8?q?[chore]=20#194=20=EB=8D=94=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=EB=B7=B0=20:=20=EB=8B=A8=EC=B2=B4=EB=AA=85=20?= =?UTF-8?q?=EA=B0=B1=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/ui/main/more/MoreFragment.kt | 86 ++++++++++--------- 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/org/sopt/pingle/presentation/ui/main/more/MoreFragment.kt b/app/src/main/java/org/sopt/pingle/presentation/ui/main/more/MoreFragment.kt index 3344c2e8..ec331c2b 100644 --- a/app/src/main/java/org/sopt/pingle/presentation/ui/main/more/MoreFragment.kt +++ b/app/src/main/java/org/sopt/pingle/presentation/ui/main/more/MoreFragment.kt @@ -39,6 +39,11 @@ class MoreFragment : BindingFragment(R.layout.fragment_more collectData() } + override fun onResume() { + super.onResume() + binding.tvMoreMyGroupContent.text = moreViewModel.getGroupName() + } + private fun initLayout() { with(binding) { tvMoreVersionDetail.text = BuildConfig.VERSION_NAME @@ -69,55 +74,58 @@ class MoreFragment : BindingFragment(R.layout.fragment_more } private fun collectData() { - moreViewModel.logoutState.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { logoutState -> - when (logoutState) { - is UiState.Success -> { - moveToSign() - } - - is UiState.Error -> { - Timber.d(FAILURE_LOGOUT) - } + moreViewModel.logoutState.flowWithLifecycle(viewLifecycleOwner.lifecycle) + .onEach { logoutState -> + when (logoutState) { + is UiState.Success -> { + moveToSign() + } - else -> {} - } - }.launchIn(viewLifecycleOwner.lifecycleScope) + is UiState.Error -> { + Timber.d(FAILURE_LOGOUT) + } - moreViewModel.withDrawState.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { withDrawState -> - when (withDrawState) { - is UiState.Success -> { - kakaoAuthService.withdrawKakao() - moveToSign() + else -> {} } + }.launchIn(viewLifecycleOwner.lifecycleScope) + + moreViewModel.withDrawState.flowWithLifecycle(viewLifecycleOwner.lifecycle) + .onEach { withDrawState -> + when (withDrawState) { + is UiState.Success -> { + kakaoAuthService.withdrawKakao() + moveToSign() + } - is UiState.Error -> { - when (withDrawState.message) { - FAILURE_OWNER -> { - PingleSnackbar.makeSnackbar( - requireView(), - stringOf(R.string.more_snackbar_failure), - SNACKBAR_BOTTOM_MARGIN, - SnackbarType.WARNING - ) + is UiState.Error -> { + when (withDrawState.message) { + FAILURE_OWNER -> { + PingleSnackbar.makeSnackbar( + requireView(), + stringOf(R.string.more_snackbar_failure), + SNACKBAR_BOTTOM_MARGIN, + SnackbarType.WARNING + ) + } + + else -> Timber.d("$FAILURE_LOGOUT : ${withDrawState.message}") } - - else -> Timber.d("$FAILURE_LOGOUT : ${withDrawState.message}") } + + else -> {} } + }.launchIn(viewLifecycleOwner.lifecycleScope) - else -> {} - } - }.launchIn(viewLifecycleOwner.lifecycleScope) + moreViewModel.userInfoState.flowWithLifecycle(viewLifecycleOwner.lifecycle) + .onEach { userInfoState -> + when (userInfoState) { + is UiState.Success -> { + binding.tvMoreNickname.text = userInfoState.data.name + } - moreViewModel.userInfoState.flowWithLifecycle(viewLifecycleOwner.lifecycle).onEach { userInfoState -> - when (userInfoState) { - is UiState.Success -> { - binding.tvMoreNickname.text = userInfoState.data.name + else -> Unit } - - else -> Unit - } - }.launchIn(viewLifecycleOwner.lifecycleScope) + }.launchIn(viewLifecycleOwner.lifecycleScope) } private fun moveToSign() {