재생목록 생성 화면 문자열 리소스화
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package kr.co.vividnext.sodalive.audio_content.playlist.create
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Service
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
@@ -11,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.jakewharton.rxbinding4.widget.textChanges
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.create.add_content.PlaylistAddContentDialogFragment
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
@@ -70,7 +70,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
}
|
||||
|
||||
override fun setupView() {
|
||||
binding.tvBack.text = "새 재생목록 만들기"
|
||||
binding.tvBack.text = getString(R.string.audio_content_playlist_create_title)
|
||||
binding.tvSave.text = getString(R.string.audio_content_playlist_create_save)
|
||||
binding.tvBack.setOnClickListener { finish() }
|
||||
|
||||
loadingDialog = LoadingDialog(this, layoutInflater)
|
||||
@@ -153,8 +154,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 30) {
|
||||
val truncated = it.take(30)
|
||||
if (it.length > PLAYLIST_TITLE_MAX_LENGTH) {
|
||||
val truncated = it.take(PLAYLIST_TITLE_MAX_LENGTH)
|
||||
binding.etTitle.setText(truncated)
|
||||
binding.etTitle.setSelection(truncated.length)
|
||||
setTitle(truncated)
|
||||
@@ -171,8 +172,8 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if (it.length > 40) {
|
||||
val truncated = it.take(40)
|
||||
if (it.length > PLAYLIST_DESC_MAX_LENGTH) {
|
||||
val truncated = it.take(PLAYLIST_DESC_MAX_LENGTH)
|
||||
binding.etDesc.setText(truncated)
|
||||
binding.etDesc.setSelection(truncated.length)
|
||||
setDesc(truncated)
|
||||
@@ -183,15 +184,26 @@ class AudioContentPlaylistCreateActivity : BaseActivity<ActivityAudioContentPlay
|
||||
)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setTitle(title: String) {
|
||||
binding.tvTitleLength.text = "${title.length}/30"
|
||||
binding.tvTitleLength.text = getString(
|
||||
R.string.audio_content_playlist_create_length_format,
|
||||
title.length,
|
||||
PLAYLIST_TITLE_MAX_LENGTH
|
||||
)
|
||||
viewModel.title = title
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun setDesc(desc: String) {
|
||||
binding.tvDescLength.text = "${desc.length}/40"
|
||||
binding.tvDescLength.text = getString(
|
||||
R.string.audio_content_playlist_create_length_format,
|
||||
desc.length,
|
||||
PLAYLIST_DESC_MAX_LENGTH
|
||||
)
|
||||
viewModel.desc = desc
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val PLAYLIST_TITLE_MAX_LENGTH = 30
|
||||
private const val PLAYLIST_DESC_MAX_LENGTH = 40
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.AudioContentPlaylistRepository
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
|
||||
|
||||
class AudioContentPlaylistCreateViewModel(
|
||||
private val repository: AudioContentPlaylistRepository
|
||||
@@ -41,6 +43,8 @@ class AudioContentPlaylistCreateViewModel(
|
||||
|
||||
fun savePlaylist(onSuccess: () -> Unit) {
|
||||
if (validate()) {
|
||||
val unknownError =
|
||||
SodaLiveApplicationHolder.get().getString(R.string.common_error_unknown)
|
||||
_isLoading.value = true
|
||||
val contentIdAndOrderList = contentList.mapIndexed { index, item ->
|
||||
PlaylistContentIdAndOrder(item.id, index + 1)
|
||||
@@ -66,7 +70,7 @@ class AudioContentPlaylistCreateViewModel(
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
_toastLiveData.value = unknownError
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -75,7 +79,7 @@ class AudioContentPlaylistCreateViewModel(
|
||||
if (it.message != null) {
|
||||
_toastLiveData.value = it.message
|
||||
} else {
|
||||
_toastLiveData.value = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||
_toastLiveData.value = unknownError
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -84,16 +88,27 @@ class AudioContentPlaylistCreateViewModel(
|
||||
}
|
||||
|
||||
private fun validate(): Boolean {
|
||||
if (title.isBlank() || title.length < 3) {
|
||||
_toastLiveData.value = "제목을 3자 이상 입력하세요"
|
||||
if (title.isBlank() || title.length < MIN_TITLE_LENGTH) {
|
||||
_toastLiveData.value = SodaLiveApplicationHolder.get().getString(
|
||||
R.string.audio_content_playlist_create_title_min_length_error,
|
||||
MIN_TITLE_LENGTH
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (contentList.isEmpty()) {
|
||||
_toastLiveData.value = "콘텐츠를 1개 이상 추가하세요"
|
||||
_toastLiveData.value = SodaLiveApplicationHolder.get().getString(
|
||||
R.string.audio_content_playlist_create_content_min_count_error,
|
||||
MIN_CONTENT_COUNT
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private companion object {
|
||||
private const val MIN_TITLE_LENGTH = 3
|
||||
private const val MIN_CONTENT_COUNT = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.audio_content.order.AudioContentOrderListViewModel
|
||||
import kr.co.vividnext.sodalive.audio_content.order.GetAudioContentOrderListItem
|
||||
import kr.co.vividnext.sodalive.audio_content.playlist.detail.AudioContentPlaylistContent
|
||||
@@ -148,7 +149,7 @@ class PlaylistAddContentDialogFragment(
|
||||
recyclerView.adapter = adapter
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n", "NotifyDataSetChanged")
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun bindData() {
|
||||
viewModel.toastLiveData.observe(viewLifecycleOwner) {
|
||||
Toast.makeText(requireActivity(), it, Toast.LENGTH_LONG).show()
|
||||
@@ -175,7 +176,10 @@ class PlaylistAddContentDialogFragment(
|
||||
}
|
||||
|
||||
viewModel.totalCount.observe(viewLifecycleOwner) {
|
||||
binding.tvContentCount.text = "${it}개"
|
||||
binding.tvContentCount.text = getString(
|
||||
R.string.audio_content_playlist_total_count,
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="48dp"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:text="새 재생목록 만들기"
|
||||
android:text="@string/audio_content_playlist_create_title"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18.3sp"
|
||||
app:drawableStartCompat="@drawable/ic_back"
|
||||
@@ -43,7 +43,7 @@
|
||||
android:gravity="center"
|
||||
android:minHeight="48dp"
|
||||
android:paddingHorizontal="13.3dp"
|
||||
android:text="저장"
|
||||
android:text="@string/audio_content_playlist_create_save"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="14.7sp" />
|
||||
</RelativeLayout>
|
||||
@@ -55,7 +55,7 @@
|
||||
android:layout_marginStart="13.3dp"
|
||||
android:layout_marginTop="26.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="재생목록 제목"
|
||||
android:text="@string/audio_content_playlist_create_title_label"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="16.7sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
@@ -67,7 +67,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="13.3dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="0/30"
|
||||
android:text="@string/audio_content_playlist_create_title_length_initial"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_title"
|
||||
@@ -92,7 +92,8 @@
|
||||
app:layout_constraintEnd_toEndOf="@+id/tv_title_length"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tv_title"
|
||||
tools:text="사랑하는게 어때서?" />
|
||||
tools:text="사랑하는게 어때서?"
|
||||
tools:ignore="LabelFor" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_desc"
|
||||
@@ -100,7 +101,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="26.7dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="재생목록 설명을 입력해주세요."
|
||||
android:text="@string/audio_content_playlist_create_desc_label"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="16.7sp"
|
||||
app:layout_constraintStart_toStartOf="@+id/et_title"
|
||||
@@ -111,7 +112,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="0/40"
|
||||
android:text="@string/audio_content_playlist_create_desc_length_initial"
|
||||
android:textColor="@color/color_777777"
|
||||
android:textSize="13.3sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/tv_desc"
|
||||
@@ -146,7 +147,7 @@
|
||||
android:drawablePadding="8dp"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:gravity="center_vertical"
|
||||
android:text="새로운 콘텐츠 추가/제거"
|
||||
android:text="@string/audio_content_playlist_create_add_content"
|
||||
android:textColor="@color/color_3bb9f1"
|
||||
app:drawableStartCompat="@drawable/btn_plus_round"
|
||||
app:layout_constraintStart_toStartOf="@+id/et_desc"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:fontFamily="@font/gmarket_sans_bold"
|
||||
android:text="새로운 콘텐츠 추가/제거"
|
||||
android:text="@string/audio_content_playlist_create_add_content"
|
||||
android:textColor="@color/color_eeeeee"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -32,7 +32,7 @@
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="13dp"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="닫기"
|
||||
android:text="@string/dialog_close"
|
||||
android:textColor="@color/color_eeeeee" />
|
||||
</RelativeLayout>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:fontFamily="@font/gmarket_sans_medium"
|
||||
android:text="전체"
|
||||
android:text="@string/audio_content_label_all"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14.7sp" />
|
||||
|
||||
|
||||
@@ -865,6 +865,16 @@
|
||||
<string name="audio_content_badge_rented">Rented</string>
|
||||
<string name="audio_content_badge_sold_out">Sold Out</string>
|
||||
<string name="audio_content_playlist_create">+ Create new playlist</string>
|
||||
<string name="audio_content_playlist_create_title">Create new playlist</string>
|
||||
<string name="audio_content_playlist_create_save">Save</string>
|
||||
<string name="audio_content_playlist_create_title_label">Title</string>
|
||||
<string name="audio_content_playlist_create_title_length_initial">0/30</string>
|
||||
<string name="audio_content_playlist_create_desc_label">Description.</string>
|
||||
<string name="audio_content_playlist_create_desc_length_initial">0/40</string>
|
||||
<string name="audio_content_playlist_create_add_content">Add/Remove content</string>
|
||||
<string name="audio_content_playlist_create_length_format">%1$d/%2$d</string>
|
||||
<string name="audio_content_playlist_create_title_min_length_error">Enter at least %1$d characters for the title.</string>
|
||||
<string name="audio_content_playlist_create_content_min_count_error">Add at least %1$d content item.</string>
|
||||
<string name="audio_content_playlist_total_count">%1$d items</string>
|
||||
<string name="audio_content_playlist_content_count">Total %1$d items</string>
|
||||
<string name="audio_content_playlist_empty_title">No playlists yet.</string>
|
||||
|
||||
@@ -865,6 +865,16 @@
|
||||
<string name="audio_content_badge_rented">レンタル中</string>
|
||||
<string name="audio_content_badge_sold_out">売り切れ</string>
|
||||
<string name="audio_content_playlist_create">+ 新しいプレイリストを作成</string>
|
||||
<string name="audio_content_playlist_create_title">新しいプレイリストを作成</string>
|
||||
<string name="audio_content_playlist_create_save">保存</string>
|
||||
<string name="audio_content_playlist_create_title_label">タイトル</string>
|
||||
<string name="audio_content_playlist_create_title_length_initial">0/30</string>
|
||||
<string name="audio_content_playlist_create_desc_label">説明を入力してください。</string>
|
||||
<string name="audio_content_playlist_create_desc_length_initial">0/40</string>
|
||||
<string name="audio_content_playlist_create_add_content">コンテンツを追加/削除</string>
|
||||
<string name="audio_content_playlist_create_length_format">%1$d/%2$d</string>
|
||||
<string name="audio_content_playlist_create_title_min_length_error">タイトルを%1$d文字以上入力してください</string>
|
||||
<string name="audio_content_playlist_create_content_min_count_error">コンテンツを%1$d件以上追加してください</string>
|
||||
<string name="audio_content_playlist_total_count">%1$d件</string>
|
||||
<string name="audio_content_playlist_content_count">合計 %1$d件</string>
|
||||
<string name="audio_content_playlist_empty_title">プレイリストが空です。</string>
|
||||
|
||||
@@ -864,6 +864,16 @@
|
||||
<string name="audio_content_badge_rented">대여중</string>
|
||||
<string name="audio_content_badge_sold_out">Sold Out</string>
|
||||
<string name="audio_content_playlist_create">+ 새 재생목록 만들기</string>
|
||||
<string name="audio_content_playlist_create_title">새 재생목록 만들기</string>
|
||||
<string name="audio_content_playlist_create_save">저장</string>
|
||||
<string name="audio_content_playlist_create_title_label">제목</string>
|
||||
<string name="audio_content_playlist_create_title_length_initial">0/30</string>
|
||||
<string name="audio_content_playlist_create_desc_label">설명을 입력해주세요.</string>
|
||||
<string name="audio_content_playlist_create_desc_length_initial">0/40</string>
|
||||
<string name="audio_content_playlist_create_add_content">새로운 콘텐츠 추가/제거</string>
|
||||
<string name="audio_content_playlist_create_length_format">%1$d/%2$d</string>
|
||||
<string name="audio_content_playlist_create_title_min_length_error">제목을 %1$d자 이상 입력하세요</string>
|
||||
<string name="audio_content_playlist_create_content_min_count_error">콘텐츠를 %1$d개 이상 추가하세요</string>
|
||||
<string name="audio_content_playlist_total_count">%1$d개</string>
|
||||
<string name="audio_content_playlist_content_count">총 %1$d개</string>
|
||||
<string name="audio_content_playlist_empty_title">재생목록이 비어있습니다.</string>
|
||||
|
||||
Reference in New Issue
Block a user