설정
- 19금 콘텐츠 보기 설정 UI 추가
This commit is contained in:
@@ -11,7 +11,9 @@ object Constants {
|
||||
const val PREF_NO_CHAT_ROOM = "pref_no_chat"
|
||||
const val PREF_PUSH_TOKEN = "pref_push_token"
|
||||
const val PREF_PROFILE_IMAGE = "pref_profile_image"
|
||||
const val PREF_CONTENT_PREFERENCE = "pref_content_preference"
|
||||
const val PREF_IS_CONTENT_PLAY_LOOP = "pref_is_content_play_loop"
|
||||
const val PREF_IS_ADULT_CONTENT_VISIBLE = "pref_is_adult_content_visible"
|
||||
const val PREF_IS_FOLLOWED_CREATOR_LIVE = "pref_is_followed_creator_live"
|
||||
const val PREF_NOT_SHOWING_EVENT_POPUP_ID = "pref_not_showing_event_popup_id"
|
||||
const val PREF_IS_VIEWED_ON_BOARDING_TUTORIAL = "pref_is_viewed_on_boarding_tutorial"
|
||||
|
||||
@@ -95,6 +95,18 @@ object SharedPreferenceManager {
|
||||
sharedPreferences[Constants.PREF_IS_ADULT] = value
|
||||
}
|
||||
|
||||
var isAdultContentVisible: Boolean
|
||||
get() = sharedPreferences[Constants.PREF_IS_ADULT_CONTENT_VISIBLE, true]
|
||||
set(value) {
|
||||
sharedPreferences[Constants.PREF_IS_ADULT_CONTENT_VISIBLE] = value
|
||||
}
|
||||
|
||||
var contentPreference: Int
|
||||
get() = sharedPreferences[Constants.PREF_CONTENT_PREFERENCE, 0]
|
||||
set(value) {
|
||||
sharedPreferences[Constants.PREF_CONTENT_PREFERENCE] = value
|
||||
}
|
||||
|
||||
var pushToken: String
|
||||
get() = sharedPreferences[Constants.PREF_PUSH_TOKEN, ""]
|
||||
set(value) {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package kr.co.vividnext.sodalive.settings
|
||||
|
||||
enum class ContentType {
|
||||
// 전체
|
||||
ALL,
|
||||
|
||||
// 남성향
|
||||
MALE,
|
||||
|
||||
// 여성향
|
||||
FEMALE
|
||||
}
|
||||
@@ -4,10 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Paint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
|
||||
import kr.co.vividnext.sodalive.BuildConfig
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.AudioContentPlayService
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
import kr.co.vividnext.sodalive.base.SodaDialog
|
||||
@@ -126,6 +128,42 @@ class SettingsActivity : BaseActivity<ActivitySettingsBinding>(ActivitySettingsB
|
||||
binding.tvSignOut.setOnClickListener {
|
||||
startActivity(Intent(applicationContext, SignOutActivity::class.java))
|
||||
}
|
||||
|
||||
setupAdultContentVisibleView()
|
||||
}
|
||||
|
||||
private fun setupAdultContentVisibleView() {
|
||||
// 본인 인증 체크
|
||||
if (SharedPreferenceManager.isAuth) {
|
||||
binding.llAdultContentVisible.visibility = View.VISIBLE
|
||||
|
||||
// 19금 콘텐츠 보기 체크
|
||||
if (SharedPreferenceManager.isAdultContentVisible) {
|
||||
binding.llAdultContentPreference.visibility = View.VISIBLE
|
||||
|
||||
} else {
|
||||
binding.llAdultContentPreference.visibility = View.GONE
|
||||
}
|
||||
|
||||
// 19금 콘텐츠 보기 스위치 액션
|
||||
binding.ivAdultContentVisible.setOnClickListener {
|
||||
viewModel.toggleAdultContentVisible()
|
||||
}
|
||||
|
||||
binding.tvContentAll.setOnClickListener {
|
||||
viewModel.setAdultContentPreference(ContentType.ALL)
|
||||
}
|
||||
|
||||
binding.tvContentMale.setOnClickListener {
|
||||
viewModel.setAdultContentPreference(ContentType.MALE)
|
||||
}
|
||||
|
||||
binding.tvContentFemale.setOnClickListener {
|
||||
viewModel.setAdultContentPreference(ContentType.FEMALE)
|
||||
}
|
||||
} else {
|
||||
binding.llAdultContentVisible.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
private fun bindData() {
|
||||
@@ -140,6 +178,29 @@ class SettingsActivity : BaseActivity<ActivitySettingsBinding>(ActivitySettingsB
|
||||
viewModel.toastLiveData.observe(this) {
|
||||
it?.let { Toast.makeText(applicationContext, it, Toast.LENGTH_LONG).show() }
|
||||
}
|
||||
|
||||
viewModel.isAdultContentVisible.observe(this) {
|
||||
if (it) {
|
||||
binding.ivAdultContentVisible.setImageResource(R.drawable.btn_toggle_on_big)
|
||||
binding.llAdultContentPreference.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.ivAdultContentVisible.setImageResource(R.drawable.btn_toggle_off_big)
|
||||
binding.llAdultContentPreference.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.adultContentPreference.observe(this) {
|
||||
binding.tvContentAll.isSelected = false
|
||||
binding.tvContentMale.isSelected = false
|
||||
binding.tvContentFemale.isSelected = false
|
||||
|
||||
when (it) {
|
||||
ContentType.ALL -> binding.tvContentAll.isSelected = true
|
||||
ContentType.MALE -> binding.tvContentMale.isSelected = true
|
||||
ContentType.FEMALE -> binding.tvContentFemale.isSelected = true
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun logout() {
|
||||
|
||||
@@ -18,6 +18,20 @@ class SettingsViewModel(private val userRepository: UserRepository) : BaseViewMo
|
||||
val isLoading: LiveData<Boolean>
|
||||
get() = _isLoading
|
||||
|
||||
private var _isAdultContentVisible = MutableLiveData(
|
||||
SharedPreferenceManager.isAdultContentVisible
|
||||
)
|
||||
val isAdultContentVisible: LiveData<Boolean>
|
||||
get() = _isAdultContentVisible
|
||||
|
||||
private var _adultContentPreference = MutableLiveData(
|
||||
ContentType.values()[SharedPreferenceManager.contentPreference]
|
||||
)
|
||||
val adultContentPreference: LiveData<ContentType>
|
||||
get() = _adultContentPreference
|
||||
|
||||
var isChangedAdultContentVisible = false
|
||||
|
||||
fun logout(onSuccess: () -> Unit) {
|
||||
compositeDisposable.add(
|
||||
userRepository.logout(token = "Bearer ${SharedPreferenceManager.token}")
|
||||
@@ -71,4 +85,17 @@ class SettingsViewModel(private val userRepository: UserRepository) : BaseViewMo
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun toggleAdultContentVisible() {
|
||||
val adultContentVisible = SharedPreferenceManager.isAdultContentVisible
|
||||
_isAdultContentVisible.value = !adultContentVisible
|
||||
SharedPreferenceManager.isAdultContentVisible = !adultContentVisible
|
||||
isChangedAdultContentVisible = true
|
||||
}
|
||||
|
||||
fun setAdultContentPreference(adultContentPreference: ContentType) {
|
||||
_adultContentPreference.value = adultContentPreference
|
||||
SharedPreferenceManager.contentPreference = adultContentPreference.ordinal
|
||||
isChangedAdultContentVisible = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user