feat(notification): 알림 수신 설정 화면을 추가한다

This commit is contained in:
2026-03-13 13:56:34 +09:00
parent 0f371ffd0e
commit 4a65902217
10 changed files with 661 additions and 0 deletions

View File

@@ -150,6 +150,7 @@
<activity android:name=".settings.event.EventActivity" />
<activity android:name=".settings.event.EventDetailActivity" />
<activity android:name=".settings.notification.NotificationSettingsActivity" />
<activity android:name=".settings.notification.NotificationReceiveSettingsActivity" />
<activity android:name=".settings.ContentSettingsActivity" />
<activity android:name=".live.reservation_status.LiveReservationStatusActivity" />
<activity android:name=".live.reservation_status.LiveReservationCancelActivity" />

View File

@@ -160,6 +160,7 @@ import kr.co.vividnext.sodalive.settings.event.EventViewModel
import kr.co.vividnext.sodalive.settings.notice.NoticeApi
import kr.co.vividnext.sodalive.settings.notice.NoticeRepository
import kr.co.vividnext.sodalive.settings.notice.NoticeViewModel
import kr.co.vividnext.sodalive.settings.notification.NotificationReceiveSettingsViewModel
import kr.co.vividnext.sodalive.settings.notification.NotificationSettingsViewModel
import kr.co.vividnext.sodalive.settings.signout.SignOutViewModel
import kr.co.vividnext.sodalive.settings.terms.TermsApi
@@ -329,6 +330,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
viewModel { NoticeViewModel(get()) }
viewModel { EventViewModel(get()) }
viewModel { NotificationSettingsViewModel(get()) }
viewModel { NotificationReceiveSettingsViewModel(get(), get()) }
viewModel { ContentSettingsViewModel() }
viewModel { SettingsViewModel(get(), get()) }
viewModel { SeriesDetailViewModel(get(), get()) }

View File

@@ -14,6 +14,7 @@ import kr.co.vividnext.sodalive.common.LoadingDialog
import kr.co.vividnext.sodalive.databinding.ActivityPushNotificationListBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.home.HomeContentThemeAdapter
import kr.co.vividnext.sodalive.settings.notification.NotificationReceiveSettingsActivity
import org.koin.android.ext.android.inject
class PushNotificationListActivity : BaseActivity<ActivityPushNotificationListBinding>(
@@ -37,6 +38,9 @@ class PushNotificationListActivity : BaseActivity<ActivityPushNotificationListBi
loadingDialog = LoadingDialog(this, layoutInflater)
binding.tvBack.text = getString(R.string.screen_push_notification_title)
binding.tvBack.setOnClickListener { finish() }
binding.ivSettings.setOnClickListener {
startActivity(Intent(this, NotificationReceiveSettingsActivity::class.java))
}
setupCategoryList()
setupNotificationList()

View File

@@ -0,0 +1,185 @@
package kr.co.vividnext.sodalive.settings.notification
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.common.LoadingDialog
import kr.co.vividnext.sodalive.databinding.ActivityNotificationReceiveSettingsBinding
import kr.co.vividnext.sodalive.explorer.profile.CreatorFollowNotifyFragment
import kr.co.vividnext.sodalive.explorer.profile.UserProfileActivity
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.following.FollowingCreatorAdapter
import org.koin.android.ext.android.inject
class NotificationReceiveSettingsActivity : BaseActivity<ActivityNotificationReceiveSettingsBinding>(
ActivityNotificationReceiveSettingsBinding::inflate
) {
private val viewModel: NotificationReceiveSettingsViewModel by inject()
private lateinit var loadingDialog: LoadingDialog
private lateinit var adapter: FollowingCreatorAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
bindData()
viewModel.getNotificationSettings()
viewModel.getFollowedCreatorAllList()
}
override fun setupView() {
loadingDialog = LoadingDialog(this, layoutInflater)
binding.toolbar.tvBack.text = getString(R.string.screen_notification_receive_settings_title)
binding.toolbar.tvBack.setOnClickListener { finish() }
binding.ivNotifiedLive.setOnClickListener {
viewModel.toggleFollowingChannelLiveNotice()
}
binding.ivNotifiedUploadContent.setOnClickListener {
viewModel.toggleFollowingChannelUploadContentNotice()
}
binding.ivMessage.setOnClickListener { viewModel.toggleMessage() }
setupFollowingChannels()
}
private fun setupFollowingChannels() {
adapter = FollowingCreatorAdapter(
onClickItem = { creatorId ->
startActivity(
Intent(applicationContext, UserProfileActivity::class.java).apply {
putExtra(Constants.EXTRA_USER_ID, creatorId)
}
)
},
onClickFollow = { creatorId, isFollow ->
if (isFollow) {
val notifyFragment = CreatorFollowNotifyFragment(
onClickNotifyAll = {
viewModel.follow(creatorId, follow = true, notify = true)
},
onClickNotifyNone = {
viewModel.follow(creatorId, follow = true, notify = false)
},
onClickUnFollow = {
viewModel.follow(creatorId, follow = false, notify = false)
}
)
if (notifyFragment.isAdded) return@FollowingCreatorAdapter
notifyFragment.show(supportFragmentManager, notifyFragment.tag)
} else {
viewModel.follow(creatorId)
}
}
)
binding.rvFollowingChannel.layoutManager = LinearLayoutManager(
applicationContext,
LinearLayoutManager.VERTICAL,
false
)
binding.rvFollowingChannel.addItemDecoration(object : RecyclerView.ItemDecoration() {
override fun getItemOffsets(
outRect: Rect,
view: View,
parent: RecyclerView,
state: RecyclerView.State
) {
super.getItemOffsets(outRect, view, parent, state)
outRect.left = 13.3f.dpToPx().toInt()
outRect.right = 13.3f.dpToPx().toInt()
}
})
binding.rvFollowingChannel.adapter = adapter
binding.nsvContent.setOnScrollChangeListener { _, _, scrollY, _, _ ->
val contentView = binding.nsvContent.getChildAt(0) ?: return@setOnScrollChangeListener
if (scrollY >= contentView.measuredHeight - binding.nsvContent.measuredHeight) {
viewModel.getFollowedCreatorAllList()
}
}
}
@SuppressLint("SetTextI18n")
private fun bindData() {
viewModel.followingChannelLiveNotice.observe(this) {
binding.ivNotifiedLive.setImageResource(
if (it) {
R.drawable.btn_toggle_on_big
} else {
R.drawable.btn_toggle_off_big
}
)
}
viewModel.followingChannelUploadContentNotice.observe(this) {
binding.ivNotifiedUploadContent.setImageResource(
if (it) {
R.drawable.btn_toggle_on_big
} else {
R.drawable.btn_toggle_off_big
}
)
}
viewModel.isMessage.observe(this) {
binding.ivMessage.setImageResource(
if (it) {
R.drawable.btn_toggle_on_big
} else {
R.drawable.btn_toggle_off_big
}
)
}
viewModel.creatorListLiveData.observe(this) {
if (viewModel.page == 2) adapter.clear()
adapter.addAll(it)
}
viewModel.creatorListTotalCountLiveData.observe(this) {
binding.tvTotalCount.text = " ${getString(
R.string.following_creator_total_count_value,
it
)} "
if (it > 0) {
binding.tvNone.visibility = View.GONE
binding.rvFollowingChannel.visibility = View.VISIBLE
} else {
binding.tvNone.visibility = View.VISIBLE
binding.rvFollowingChannel.visibility = View.GONE
}
}
viewModel.isLoading.observe(this) {
if (it) {
loadingDialog.show(screenWidth, "")
} else {
loadingDialog.dismiss()
}
}
viewModel.toastLiveData.observe(this) {
val text = it?.message ?: it?.resId?.let { resId -> getString(resId) }
text?.let { message ->
Toast.makeText(applicationContext, message, Toast.LENGTH_LONG).show()
}
}
}
}

View File

@@ -0,0 +1,218 @@
package kr.co.vividnext.sodalive.settings.notification
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.orhanobut.logger.Logger
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.schedulers.Schedulers
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseViewModel
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.common.ToastMessage
import kr.co.vividnext.sodalive.following.FollowingCreatorRepository
import kr.co.vividnext.sodalive.following.GetCreatorFollowingAllListItem
import kr.co.vividnext.sodalive.user.UserRepository
class NotificationReceiveSettingsViewModel(
private val userRepository: UserRepository,
private val followingCreatorRepository: FollowingCreatorRepository
) : BaseViewModel() {
private val _toastLiveData = MutableLiveData<ToastMessage?>()
val toastLiveData: LiveData<ToastMessage?>
get() = _toastLiveData
private val _isLoading = MutableLiveData(false)
val isLoading: LiveData<Boolean>
get() = _isLoading
private val _followingChannelLiveNotice = MutableLiveData(false)
val followingChannelLiveNotice: LiveData<Boolean>
get() = _followingChannelLiveNotice
private val _isMessage = MutableLiveData(false)
val isMessage: LiveData<Boolean>
get() = _isMessage
private val _followingChannelUploadContentNotice = MutableLiveData(false)
val followingChannelUploadContentNotice: LiveData<Boolean>
get() = _followingChannelUploadContentNotice
private val _creatorListLiveData = MutableLiveData<List<GetCreatorFollowingAllListItem>>()
val creatorListLiveData: LiveData<List<GetCreatorFollowingAllListItem>>
get() = _creatorListLiveData
private val _creatorListTotalCountLiveData = MutableLiveData(0)
val creatorListTotalCountLiveData: LiveData<Int>
get() = _creatorListTotalCountLiveData
private var _isFollowingListLoading = MutableLiveData(false)
var page = 1
var isLast = false
private var pageSize = PAGE_SIZE
fun getNotificationSettings() {
_isLoading.value = true
compositeDisposable.add(
userRepository.getMemberInfo(token = "Bearer ${SharedPreferenceManager.token}")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
_isLoading.value = false
if (it.success && it.data != null) {
val data = it.data
_isMessage.value = data.messageNotice ?: false
_followingChannelUploadContentNotice.value =
data.followingChannelUploadContentNotice ?: false
_followingChannelLiveNotice.value =
data.followingChannelLiveNotice ?: false
} else {
if (it.message != null) {
_toastLiveData.postValue(ToastMessage(message = it.message))
} else {
_toastLiveData.postValue(
ToastMessage(resId = R.string.common_error_unknown)
)
}
}
},
{
_isLoading.value = false
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue(ToastMessage(resId = R.string.retry))
}
)
)
}
fun toggleFollowingChannelLiveNotice() {
val nextValue = !(_followingChannelLiveNotice.value ?: false)
_followingChannelLiveNotice.value = nextValue
updateNotificationSettings(live = nextValue)
}
fun toggleFollowingChannelUploadContentNotice() {
val nextValue = !(_followingChannelUploadContentNotice.value ?: false)
_followingChannelUploadContentNotice.value = nextValue
updateNotificationSettings(uploadContent = nextValue)
}
fun toggleMessage() {
val nextValue = !(_isMessage.value ?: false)
_isMessage.value = nextValue
updateNotificationSettings(message = nextValue)
}
private fun updateNotificationSettings(
live: Boolean? = null,
uploadContent: Boolean? = null,
message: Boolean? = null
) {
if (live != null || uploadContent != null || message != null) {
compositeDisposable.add(
userRepository.updateNotificationSettings(
request = UpdateNotificationSettingRequest(
live = live,
uploadContent = uploadContent,
message = message
),
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({}, {})
)
}
}
fun getFollowedCreatorAllList() {
if (isLast || _isFollowingListLoading.value == true) {
return
}
_isFollowingListLoading.value = true
compositeDisposable.add(
followingCreatorRepository.getFollowedCreatorAllList(
page = page,
size = pageSize,
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
_isFollowingListLoading.value = false
pageSize = PAGE_SIZE
if (it.success && it.data != null) {
if (it.data.items.isEmpty()) {
isLast = true
} else {
page += 1
_creatorListTotalCountLiveData.value = it.data.totalCount
_creatorListLiveData.value = it.data.items
}
} else if (it.message != null) {
_toastLiveData.postValue(ToastMessage(message = it.message))
} else {
_toastLiveData.postValue(
ToastMessage(resId = R.string.common_error_unknown)
)
}
},
{
_isFollowingListLoading.value = false
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
}
)
)
}
fun follow(creatorId: Long, follow: Boolean = true, notify: Boolean = true) {
_isLoading.value = true
compositeDisposable.add(
userRepository.creatorFollow(
creatorId = creatorId,
follow = follow,
notify = notify,
token = "Bearer ${SharedPreferenceManager.token}"
)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
{
_isLoading.value = false
if (it.success && it.data != null) {
isLast = false
pageSize *= page
page = 1
getFollowedCreatorAllList()
} else if (it.message != null) {
_toastLiveData.postValue(ToastMessage(message = it.message))
} else {
_toastLiveData.postValue(
ToastMessage(resId = R.string.common_error_unknown)
)
}
},
{
_isLoading.value = false
it.message?.let { message -> Logger.e(message) }
_toastLiveData.postValue(ToastMessage(resId = R.string.common_error_unknown))
}
)
)
}
companion object {
private const val PAGE_SIZE = 20
}
}

View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/detail_toolbar" />
<androidx.core.widget.NestedScrollView
android:id="@+id/nsv_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="13.3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="13.3dp"
android:layout_marginTop="20dp"
android:fontFamily="@font/bold"
android:text="@string/screen_notification_receive_settings_service_section"
android:textColor="@color/color_eeeeee"
android:textSize="13.3sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="13.3dp"
android:layout_marginTop="8dp"
android:background="@drawable/bg_round_corner_6_7_222222"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="13.3dp"
android:paddingStart="16.7dp"
android:paddingEnd="13.3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/bold"
android:text="@string/notification_settings_live"
android:textColor="@color/color_eeeeee"
android:textSize="14.7sp" />
<ImageView
android:id="@+id/iv_notified_live"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:contentDescription="@null"
tools:src="@drawable/btn_toggle_off_big" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="13.3dp"
android:background="@color/color_88909090" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="13.3dp"
android:paddingStart="16.7dp"
android:paddingEnd="13.3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/bold"
android:text="@string/notification_settings_upload"
android:textColor="@color/color_eeeeee"
android:textSize="14.7sp" />
<ImageView
android:id="@+id/iv_notified_upload_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:contentDescription="@null"
tools:src="@drawable/btn_toggle_on_big" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="13.3dp"
android:background="@color/color_88909090" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="13.3dp"
android:paddingStart="16.7dp"
android:paddingEnd="13.3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:fontFamily="@font/bold"
android:text="@string/notification_settings_message"
android:textColor="@color/color_eeeeee"
android:textSize="14.7sp" />
<ImageView
android:id="@+id/iv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:contentDescription="@null"
tools:src="@drawable/btn_toggle_on_big" />
</RelativeLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="13.3dp"
android:layout_marginTop="26.7dp"
android:fontFamily="@font/bold"
android:text="@string/screen_notification_receive_settings_following_section"
android:textColor="@color/color_eeeeee"
android:textSize="13.3sp" />
<LinearLayout
android:id="@+id/ll_total_count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="13.3dp"
android:orientation="horizontal"
android:paddingHorizontal="13.3dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/medium"
android:text="@string/following_creator_total_prefix"
android:textColor="@color/color_eeeeee"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_total_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/medium"
android:textColor="@color/color_dd4500"
android:textSize="12sp"
tools:text=" 10" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/medium"
android:text="@string/following_creator_total_suffix"
android:textColor="@color/color_eeeeee"
android:textSize="12sp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_following_channel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="13.3dp"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingBottom="13.3dp"
android:visibility="gone" />
<TextView
android:id="@+id/tv_none"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="13.3dp"
android:fontFamily="@font/medium"
android:gravity="center"
android:paddingVertical="40dp"
android:text="@string/following_creator_empty"
android:textColor="@color/color_bbbbbb" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>

View File

@@ -988,6 +988,9 @@
<string name="screen_content_settings_male">Male-oriented</string>
<string name="screen_content_settings_female">Female-oriented</string>
<string name="screen_notification_settings_title">Notification settings</string>
<string name="screen_notification_receive_settings_title">Notification receive settings</string>
<string name="screen_notification_receive_settings_service_section">Service notifications</string>
<string name="screen_notification_receive_settings_following_section">Following channels</string>
<string name="notification_settings_live">Live notifications</string>
<string name="notification_settings_upload">Content upload notifications</string>
<string name="notification_settings_message">Message notifications</string>

View File

@@ -988,6 +988,9 @@
<string name="screen_content_settings_male">男性向け</string>
<string name="screen_content_settings_female">女性向け</string>
<string name="screen_notification_settings_title">通知設定</string>
<string name="screen_notification_receive_settings_title">通知受信設定</string>
<string name="screen_notification_receive_settings_service_section">サービス通知</string>
<string name="screen_notification_receive_settings_following_section">フォロー中のチャンネル</string>
<string name="notification_settings_live">ライブ通知</string>
<string name="notification_settings_upload">コンテンツ投稿通知</string>
<string name="notification_settings_message">メッセージ通知</string>

View File

@@ -987,6 +987,9 @@
<string name="screen_content_settings_male">남성향</string>
<string name="screen_content_settings_female">여성향</string>
<string name="screen_notification_settings_title">알림 설정</string>
<string name="screen_notification_receive_settings_title">알림 수신 설정</string>
<string name="screen_notification_receive_settings_service_section">서비스 알림</string>
<string name="screen_notification_receive_settings_following_section">팔로잉 채널</string>
<string name="notification_settings_live">라이브 알림</string>
<string name="notification_settings_upload">콘텐츠 업로드 알림</string>
<string name="notification_settings_message">메시지 알림</string>