feat(auth): 콘텐츠 보기 설정 시트를 추가한다

This commit is contained in:
2026-10-13 11:29:42 +09:00
parent de220019cc
commit 31861721f4
10 changed files with 465 additions and 0 deletions
@@ -0,0 +1,86 @@
package kr.co.vividnext.sodalive.v2.auth
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.widget.Switch
import androidx.core.view.AccessibilityDelegateCompat
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.databinding.V2BottomSheetContentPreferenceBinding
import kr.co.vividnext.sodalive.settings.ContentType
class ContentPreferenceBottomSheet(
activity: Activity,
onToggle: () -> Unit,
onSelect: (ContentType) -> Unit,
onConfirm: () -> Unit
) : BottomSheetDialog(activity, R.style.V2ContentPreferenceBottomSheetTheme) {
private val binding = V2BottomSheetContentPreferenceBinding.inflate(LayoutInflater.from(context))
private var isConfirmClicked = false
init {
setContentView(binding.root)
setCancelable(false)
setCanceledOnTouchOutside(false)
behavior.isDraggable = false
behavior.isHideable = false
behavior.skipCollapsed = true
behavior.state = BottomSheetBehavior.STATE_EXPANDED
ViewCompat.setAccessibilityHeading(binding.tvTitle, true)
ViewCompat.setAccessibilityHeading(binding.tvPreferenceLabel, true)
ViewCompat.setAccessibilityPaneTitle(binding.root, context.getString(R.string.screen_content_settings_title))
ViewCompat.setAccessibilityDelegate(
binding.toggleAdultContent,
object : AccessibilityDelegateCompat() {
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(host, info)
info.className = Switch::class.java.name
info.isCheckable = true
info.isChecked = binding.toggleAdultContent.isChecked
}
}
)
binding.toggleAdultContent.setOnClickListener { onToggle() }
binding.radioAll.setOnClickListener { onSelect(ContentType.ALL) }
binding.radioMale.setOnClickListener { onSelect(ContentType.MALE) }
binding.radioFemale.setOnClickListener { onSelect(ContentType.FEMALE) }
binding.btnConfirm.setOnClickListener {
if (isConfirmClicked) return@setOnClickListener
isConfirmClicked = true
binding.btnConfirm.isEnabled = false
dismiss()
onConfirm()
}
}
fun render(isAdultContentVisible: Boolean, contentType: ContentType, selectionEnabled: Boolean) {
binding.toggleAdultContent.isChecked = isAdultContentVisible
binding.tvAdultDescription.setText(
if (isAdultContentVisible) {
R.string.v2_content_preference_adult_on_description
} else {
R.string.v2_content_preference_adult_off_description
}
)
binding.layoutPreference.visibility = if (isAdultContentVisible) View.VISIBLE else View.GONE
binding.radioContentType.check(
when (contentType) {
ContentType.ALL -> R.id.radio_all
ContentType.MALE -> R.id.radio_male
ContentType.FEMALE -> R.id.radio_female
}
)
binding.toggleAdultContent.isEnabled = selectionEnabled
binding.radioAll.isEnabled = selectionEnabled && isAdultContentVisible
binding.radioMale.isEnabled = selectionEnabled && isAdultContentVisible
binding.radioFemale.isEnabled = selectionEnabled && isAdultContentVisible
binding.btnConfirm.isEnabled = !isConfirmClicked
}
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/gray_900" />
<corners
android:topLeftRadius="@dimen/radius_14"
android:topRightRadius="@dimen/radius_14" />
</shape>
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<layer-list>
<item>
<shape android:shape="oval">
<size
android:width="@dimen/v2_content_preference_radio_size"
android:height="@dimen/v2_content_preference_radio_size" />
<stroke android:width="@dimen/v2_content_preference_divider_height" android:color="@color/gray_700" />
</shape>
</item>
<item
android:left="@dimen/v2_content_preference_radio_dot_inset"
android:top="@dimen/v2_content_preference_radio_dot_inset"
android:right="@dimen/v2_content_preference_radio_dot_inset"
android:bottom="@dimen/v2_content_preference_radio_dot_inset">
<shape android:shape="oval">
<solid android:color="@color/soda_400" />
</shape>
</item>
</layer-list>
</item>
<item>
<shape android:shape="oval">
<size
android:width="@dimen/v2_content_preference_radio_size"
android:height="@dimen/v2_content_preference_radio_size" />
<stroke android:width="@dimen/v2_content_preference_divider_height" android:color="@color/gray_700" />
</shape>
</item>
</selector>
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<vector
android:width="@dimen/v2_content_preference_switch_width"
android:height="@dimen/spacing_24"
android:viewportWidth="44"
android:viewportHeight="24">
<path
android:fillColor="@color/soda_400"
android:pathData="M12,0H32A12,12 0,0 1,32 24H12A12,12 0,0 1,12 0Z" />
<path
android:fillColor="@color/white"
android:pathData="M32,2A10,10 0,1 1,32 22A10,10 0,1 1,32 2Z" />
</vector>
</item>
<item>
<vector
android:width="@dimen/v2_content_preference_switch_width"
android:height="@dimen/spacing_24"
android:viewportWidth="44"
android:viewportHeight="24">
<path
android:fillColor="@color/gray_500"
android:pathData="M12,0H32A12,12 0,0 1,32 24H12A12,12 0,0 1,12 0Z" />
<path
android:fillColor="@color/white"
android:pathData="M12,2A10,10 0,1 1,12 22A10,10 0,1 1,12 2Z" />
</vector>
</item>
</selector>
@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:overScrollMode="never">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="@dimen/spacing_14"
android:paddingTop="@dimen/v2_content_preference_top_space"
android:paddingBottom="@dimen/spacing_8">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_title"
style="@style/V2ContentPreferenceTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:minHeight="@dimen/v2_content_preference_title_height"
android:text="@string/screen_content_settings_title" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_8"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/spacing_12"
android:layout_weight="1"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
style="@style/V2ContentPreferenceBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/bold"
android:text="@string/screen_content_settings_adult_toggle" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_adult_description"
style="@style/V2ContentPreferenceCaption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_4"
android:text="@string/v2_content_preference_adult_on_description" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatCheckedTextView
android:id="@+id/toggle_adult_content"
android:layout_width="@dimen/v2_content_preference_switch_width"
android:layout_height="@dimen/v2_content_preference_switch_width"
android:background="@null"
android:checkMark="@drawable/v2_content_preference_switch"
android:checked="true"
android:clickable="true"
android:contentDescription="@string/screen_content_settings_adult_toggle"
android:focusable="true"
android:gravity="center_vertical"
android:padding="0dp"
app:checkMarkTint="@null" />
</LinearLayout>
<LinearLayout
android:id="@+id/layout_preference"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/spacing_6">
<View
android:layout_width="match_parent"
android:layout_height="@dimen/v2_content_preference_divider_height"
android:layout_marginTop="@dimen/spacing_14"
android:background="@color/gray_800"
android:importantForAccessibility="no" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_preference_label"
style="@style/V2ContentPreferenceCaptionLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_12"
android:text="@string/v2_content_preference_label" />
<RadioGroup
android:id="@+id/radio_content_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_12"
android:checkedButton="@id/radio_all"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/radio_all"
style="@style/V2ContentPreferenceRadio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/screen_content_settings_all" />
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/radio_male"
style="@style/V2ContentPreferenceRadio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/screen_content_settings_male" />
<androidx.appcompat.widget.AppCompatRadioButton
android:id="@+id/radio_female"
style="@style/V2ContentPreferenceRadio"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/screen_content_settings_female" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_14"
android:gravity="top"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="@dimen/spacing_16"
android:layout_height="@dimen/spacing_16"
android:layout_marginEnd="@dimen/spacing_6"
android:contentDescription="@null"
android:importantForAccessibility="no"
app:srcCompat="@drawable/ic_gift_info"
app:tint="@color/gray_400" />
<androidx.appcompat.widget.AppCompatTextView
style="@style/V2ContentPreferenceCaption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/v2_content_preference_settings_note" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btn_confirm"
style="@style/V2ContentPreferenceBody"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_28"
android:background="@drawable/bg_creator_channel_donation_empty_button"
android:gravity="center"
android:minHeight="@dimen/v2_content_preference_button_height"
android:minWidth="0dp"
android:paddingHorizontal="@dimen/spacing_14"
android:paddingVertical="@dimen/spacing_14"
android:stateListAnimator="@null"
android:text="@string/v2_content_preference_confirm"
android:textAllCaps="false"
app:backgroundTint="@null" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="v2_content_preference_adult_on_description">You can view adult content after completing age verification</string>
<string name="v2_content_preference_adult_off_description">Adult content will not appear in lists or search results</string>
<string name="v2_content_preference_label">Preferred content</string>
<string name="v2_content_preference_settings_note">You can change this anytime in My &gt; Settings &gt; Content viewing settings</string>
<string name="v2_content_preference_confirm">Save settings</string>
</resources>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="v2_content_preference_adult_on_description">年齢認証完了後、成人向けコンテンツを表示できます</string>
<string name="v2_content_preference_adult_off_description">成人向けコンテンツは一覧や検索に表示されません</string>
<string name="v2_content_preference_label">好みのコンテンツ</string>
<string name="v2_content_preference_settings_note">マイ &gt; 設定 &gt; コンテンツ表示設定でいつでも変更できます</string>
<string name="v2_content_preference_confirm">設定完了</string>
</resources>
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="v2_content_preference_top_space">26dp</dimen>
<dimen name="v2_content_preference_title_height">54dp</dimen>
<dimen name="v2_content_preference_switch_width">44dp</dimen>
<dimen name="v2_content_preference_divider_height">1dp</dimen>
<dimen name="v2_content_preference_button_height">52dp</dimen>
<dimen name="v2_content_preference_radio_size">22dp</dimen>
<dimen name="v2_content_preference_radio_dot_inset">5dp</dimen>
<dimen name="v2_content_preference_title_line_height">26.1sp</dimen>
<dimen name="v2_content_preference_body_line_height">23.2sp</dimen>
<dimen name="v2_content_preference_caption_line_height">17.4sp</dimen>
<style name="V2ContentPreferenceBottomSheetTheme" parent="Theme.MaterialComponents.BottomSheetDialog">
<item name="bottomSheetStyle">@style/V2ContentPreferenceBottomSheetStyle</item>
<item name="android:navigationBarColor">@color/gray_900</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
</style>
<style name="V2ContentPreferenceBottomSheetStyle" parent="Widget.MaterialComponents.BottomSheet.Modal">
<item name="android:background">@drawable/v2_content_preference_background</item>
<item name="backgroundTint">@null</item>
<item name="shapeAppearance">@null</item>
<item name="paddingBottomSystemWindowInsets">true</item>
<item name="paddingLeftSystemWindowInsets">true</item>
<item name="paddingRightSystemWindowInsets">true</item>
</style>
<style name="V2ContentPreferenceTitle" parent="Typography.Heading4">
<item name="android:fontFamily">@font/medium</item>
<item name="android:includeFontPadding">false</item>
<item name="android:textColor">@color/white</item>
<item name="lineHeight">@dimen/v2_content_preference_title_line_height</item>
</style>
<style name="V2ContentPreferenceBody" parent="Typography.Body2">
<item name="android:includeFontPadding">false</item>
<item name="android:minHeight">@dimen/v2_content_preference_body_line_height</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textColor">@color/white</item>
<item name="lineHeight">@dimen/v2_content_preference_body_line_height</item>
</style>
<style name="V2ContentPreferenceCaption" parent="Typography.Caption3">
<item name="android:includeFontPadding">false</item>
<item name="android:minHeight">@dimen/v2_content_preference_caption_line_height</item>
<item name="android:gravity">center_vertical</item>
<item name="android:textColor">@color/gray_400</item>
<item name="lineHeight">@dimen/v2_content_preference_caption_line_height</item>
</style>
<style name="V2ContentPreferenceCaptionLabel" parent="V2ContentPreferenceCaption">
<item name="android:fontFamily">@font/medium</item>
<item name="android:textColor">@color/gray_300</item>
</style>
<style name="V2ContentPreferenceRadio" parent="V2ContentPreferenceBody">
<item name="android:background">@null</item>
<item name="android:button">@drawable/v2_content_preference_radio</item>
<item name="buttonTint">@null</item>
<item name="android:minWidth">0dp</item>
<item name="android:minHeight">@dimen/v2_content_preference_body_line_height</item>
<item name="android:paddingStart">@dimen/spacing_6</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:paddingTop">0dp</item>
<item name="android:paddingBottom">0dp</item>
<item name="android:gravity">center_vertical</item>
</style>
</resources>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="v2_content_preference_adult_on_description">성인인증 완료 후 성인 콘텐츠를 볼 수 있어요</string>
<string name="v2_content_preference_adult_off_description">성인 콘텐츠가 목록과 검색에 노출되지 않아요</string>
<string name="v2_content_preference_label">선호 콘텐츠</string>
<string name="v2_content_preference_settings_note">마이 &gt; 설정 &gt; 콘텐츠 보기 설정에서 언제든 바꿀 수 있어요</string>
<string name="v2_content_preference_confirm">설정 완료</string>
</resources>
@@ -0,0 +1,48 @@
package kr.co.vividnext.sodalive.v2.auth
import android.app.Application
import android.os.Looper
import android.view.MotionEvent
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.settings.ContentType
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], application = Application::class)
class ContentPreferenceBottomSheetTest {
@Test
fun `선택이 잠긴 GET 재시도도 완료 터치로 닫힌 뒤 확인을 한 번 전달한다`() {
val controller = Robolectric.buildActivity(AppCompatActivity::class.java)
controller.get().setTheme(R.style.Theme_SodaLive)
controller.setup()
var confirmations = 0
lateinit var sheet: ContentPreferenceBottomSheet
sheet = ContentPreferenceBottomSheet(controller.get(), {}, {}, {
assertFalse(sheet.isShowing)
confirmations += 1
})
sheet.render(true, ContentType.FEMALE, selectionEnabled = false)
sheet.show()
val confirm = sheet.findViewById<View>(R.id.btn_confirm)!!
repeat(2) {
listOf(MotionEvent.ACTION_DOWN, MotionEvent.ACTION_UP).forEach { action ->
val event = MotionEvent.obtain(0, 10, action, 1f, 1f, 0)
confirm.dispatchTouchEvent(event)
event.recycle()
}
shadowOf(Looper.getMainLooper()).idle()
}
assertEquals(1, confirmations)
sheet.dismiss()
controller.pause().stop().destroy()
}
}