diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 13505952..8659be37 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -150,6 +150,7 @@ + diff --git a/app/src/main/java/kr/co/vividnext/sodalive/di/AppDI.kt b/app/src/main/java/kr/co/vividnext/sodalive/di/AppDI.kt index 1fa19fa7..6c50f322 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/di/AppDI.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/di/AppDI.kt @@ -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()) } diff --git a/app/src/main/java/kr/co/vividnext/sodalive/home/pushnotification/PushNotificationListActivity.kt b/app/src/main/java/kr/co/vividnext/sodalive/home/pushnotification/PushNotificationListActivity.kt index d2adbd2a..aee60bd5 100644 --- a/app/src/main/java/kr/co/vividnext/sodalive/home/pushnotification/PushNotificationListActivity.kt +++ b/app/src/main/java/kr/co/vividnext/sodalive/home/pushnotification/PushNotificationListActivity.kt @@ -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( @@ -37,6 +38,9 @@ class PushNotificationListActivity : BaseActivity( + 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() + } + } + } +} diff --git a/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationReceiveSettingsViewModel.kt b/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationReceiveSettingsViewModel.kt new file mode 100644 index 00000000..8f98b93c --- /dev/null +++ b/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationReceiveSettingsViewModel.kt @@ -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() + val toastLiveData: LiveData + get() = _toastLiveData + + private val _isLoading = MutableLiveData(false) + val isLoading: LiveData + get() = _isLoading + + private val _followingChannelLiveNotice = MutableLiveData(false) + val followingChannelLiveNotice: LiveData + get() = _followingChannelLiveNotice + + private val _isMessage = MutableLiveData(false) + val isMessage: LiveData + get() = _isMessage + + private val _followingChannelUploadContentNotice = MutableLiveData(false) + val followingChannelUploadContentNotice: LiveData + get() = _followingChannelUploadContentNotice + + private val _creatorListLiveData = MutableLiveData>() + val creatorListLiveData: LiveData> + get() = _creatorListLiveData + + private val _creatorListTotalCountLiveData = MutableLiveData(0) + val creatorListTotalCountLiveData: LiveData + 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 + } +} diff --git a/app/src/main/res/layout/activity_notification_receive_settings.xml b/app/src/main/res/layout/activity_notification_receive_settings.xml new file mode 100644 index 00000000..2df35fe3 --- /dev/null +++ b/app/src/main/res/layout/activity_notification_receive_settings.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 8310fd16..0f421ca2 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -988,6 +988,9 @@ Male-oriented Female-oriented Notification settings + Notification receive settings + Service notifications + Following channels Live notifications Content upload notifications Message notifications diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index 3ef05213..26b9f7c9 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -988,6 +988,9 @@ 男性向け 女性向け 通知設定 + 通知受信設定 + サービス通知 + フォロー中のチャンネル ライブ通知 コンテンツ投稿通知 メッセージ通知 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 63a36a5f..9ad6bc22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -987,6 +987,9 @@ 남성향 여성향 알림 설정 + 알림 수신 설정 + 서비스 알림 + 팔로잉 채널 라이브 알림 콘텐츠 업로드 알림 메시지 알림 diff --git a/docs/20260313_알림수신설정페이지개발.md b/docs/20260313_알림수신설정페이지개발.md new file mode 100644 index 00000000..99efbbf8 --- /dev/null +++ b/docs/20260313_알림수신설정페이지개발.md @@ -0,0 +1,38 @@ +# 2026-03-13 알림 수신 설정 페이지 개발 + +## 완료 기준 +- [x] 알림 리스트 우측 상단 이미지(`iv_settings`) 터치 시 신규 알림 수신 설정 페이지로 이동한다. +- [x] 신규 페이지는 기존 알림 설정 페이지를 대체하지 않고 별도 Activity로 생성된다. +- [x] 페이지는 `서비스 알림` + `팔로잉 채널` 2개 섹션이며 전체가 하나의 스크롤로 동작한다. +- [x] `서비스 알림` 섹션 UI/토글 액션은 기존 `NotificationSettingsActivity`와 동일하게 동작한다. +- [x] `팔로잉 채널` 섹션 UI는 기존 팔로잉 리스트와 동일하며 무한 스크롤로 20개씩 로드한다. + +## 체크리스트 +- [x] 기존 진입/재사용 패턴 분석 +- [x] 신규 알림 수신 설정 Activity/ViewModel/Layout 구현 +- [x] 서비스 알림 토글 액션 기존 로직과 동일하게 연결 +- [x] 팔로잉 채널 리스트(20개 페이징/무한 스크롤) 연결 +- [x] 알림 리스트 우측 상단 이미지 진입 연결 +- [x] 검증(진단/테스트/빌드) 수행 및 기록 + +## 검증 기록 +- 2026-03-13 + - 무엇/왜/어떻게: 작업 시작 전 요구사항을 완료 기준으로 고정하고 구현 체크리스트를 문서화했다. + - 실행 명령: `glob(pattern="docs/*.md", path="/Users/klaus/Develop/sodalive/Android/SodaLive")`, `read(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/docs/20260312_알림리스트구현.md")` + - 결과: 기존 문서 형식을 확인하고 신규 계획 문서를 생성했다. +- 2026-03-13 + - 무엇/왜/어떻게: 알림 리스트 진입점과 재사용 가능한 알림/팔로잉 구현 패턴을 교차 확인해 신규 화면 구성 근거를 확보했다. + - 실행 명령: `background_output(task_id="bg_8f327a73")`, `background_output(task_id="bg_d549966d")`, `read(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/java/kr/co/vividnext/sodalive/home/pushnotification/PushNotificationListActivity.kt")`, `read(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationSettingsActivity.kt")`, `read(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/java/kr/co/vividnext/sodalive/following/FollowingCreatorActivity.kt")` + - 결과: `iv_settings` 클릭 미연결 상태를 확인했고, 토글/팔로잉 리스트 패턴 및 페이징 구조를 신규 화면에 반영했다. +- 2026-03-13 + - 무엇/왜/어떻게: 신규 화면/연결 코드의 정적 진단 가능 여부를 확인했다. + - 실행 명령: `lsp_diagnostics(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationReceiveSettingsActivity.kt")`, `lsp_diagnostics(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/java/kr/co/vividnext/sodalive/settings/notification/NotificationReceiveSettingsViewModel.kt")`, `lsp_diagnostics(filePath="/Users/klaus/Develop/sodalive/Android/SodaLive/app/src/main/res/layout/activity_notification_receive_settings.xml")` + - 결과: 현 환경은 `.kt`, `.xml` LSP 서버 미구성으로 진단 실행이 불가함을 확인했다. +- 2026-03-13 + - 무엇/왜/어떻게: 구현 변경분의 컴파일/테스트/코드스타일 상태를 검증해 배포 전 안정성을 확인했다. + - 실행 명령: `./gradlew :app:assembleDebug :app:testDebugUnitTest :app:ktlintCheck` + - 결과: `BUILD SUCCESSFUL`. +- 2026-03-13 + - 무엇/왜/어떻게: 연결된 단말에서 수동 실행 가능성을 점검했다. + - 실행 명령: `adb devices`, `./gradlew :app:installDebug`, `adb shell am start -W -n kr.co.vividnext.sodalive.debug/kr.co.vividnext.sodalive.settings.notification.NotificationReceiveSettingsActivity`, `adb shell run-as kr.co.vividnext.sodalive.debug am start --user 0 -n kr.co.vividnext.sodalive.debug/kr.co.vividnext.sodalive.settings.notification.NotificationReceiveSettingsActivity` + - 결과: APK 설치는 성공했고, 쉘 직접 실행은 non-exported Activity 정책으로 차단됨을 확인했다. 내부 네비게이션(`PushNotificationListActivity`의 `iv_settings`)을 통한 진입은 앱 내 수동 확인이 필요하다.