다국어 설정 시 날짜 포맷이 섞이는 버그 수정

앱 내 설정 언어와 디바이스 언어가 다를 때 날짜 포맷에 여러 언어가
섞여서 표시되는 문제를 해결하기 위해 앱 설정 언어를 명시적으로
적용하도록 수정. 래핑된 컨텍스트를 사용하여 리소스를 가져오고
날짜 변환 시에도 해당 로케일을 전달하도록 개선.
This commit is contained in:
2026-01-21 16:52:39 +09:00
parent 5adfecf689
commit b1075eee16
10 changed files with 96 additions and 42 deletions

View File

@@ -60,6 +60,8 @@ import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.loadUrl
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.live.LiveViewModel
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import kr.co.vividnext.sodalive.live.reservation.complete.LiveReservationCompleteActivity
import kr.co.vividnext.sodalive.live.room.LiveRoomActivity
import kr.co.vividnext.sodalive.live.room.dialog.LivePaymentDialog
@@ -1094,12 +1096,15 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
liveViewModel.enterRoom(roomId, onEnterRoomSuccess)
}
} else {
val locale = Locale(LanguageManager.getEffectiveLanguage(this))
val wrappedContext = LocaleHelper.wrap(this)
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
val now = Date()
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", locale)
val diffTime: Long = now.time - beginDate.time
val hours = (diffTime / (1000 * 60 * 60)).toInt()
val mins = (diffTime / (1000 * 60)).toInt() % 60
@@ -1121,7 +1126,7 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
LivePaymentDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.live_paid_title),
title = wrappedContext.getString(R.string.live_paid_title),
startDateTime = if (hours >= 1) {
dateFormat.format(beginDate)
} else {
@@ -1132,17 +1137,17 @@ class UserProfileActivity : BaseActivity<ActivityUserProfileBinding>(
} else {
null
},
desc = getString(R.string.live_paid_desc, it.price),
desc = wrappedContext.getString(R.string.live_paid_desc, it.price),
desc2 = if (hours >= 1) {
getString(R.string.live_paid_warning, hours, mins)
wrappedContext.getString(R.string.live_paid_warning, hours, mins)
} else {
null
},
confirmButtonTitle = getString(R.string.live_paid_confirm),
confirmButtonTitle = wrappedContext.getString(R.string.live_paid_confirm),
confirmButtonClick = {
liveViewModel.enterRoom(roomId, onEnterRoomSuccess)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonTitle = wrappedContext.getString(R.string.cancel),
cancelButtonClick = {}
).show(screenWidth)
}

View File

@@ -14,6 +14,9 @@ import kr.co.vividnext.sodalive.databinding.ItemCreatorProfileLiveCardBinding
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.extensions.parseUtcIsoLocalDateTime
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import java.util.Locale
class UserProfileLiveAdapter(
private val onClickParticipant: (LiveRoomResponse) -> Unit,
@@ -27,6 +30,9 @@ class UserProfileLiveAdapter(
private val binding: ItemCreatorProfileLiveCardBinding
) : RecyclerView.ViewHolder(binding.root) {
fun bind(item: LiveRoomResponse) {
val locale = Locale(LanguageManager.getEffectiveLanguage(context))
val wrappedContext = LocaleHelper.wrap(context)
Glide.with(context)
.load(item.coverImageUrl)
.placeholder(R.drawable.ic_place_holder)
@@ -41,7 +47,7 @@ class UserProfileLiveAdapter(
binding.tvTitle.text = item.title
binding.tvNickname.text = item.managerNickname
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime()
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime(locale)
binding.tvDayOfWeek.text = dateMap["dayOfWeek"]
binding.ivLock.visibility = if (item.isPrivateRoom) {
@@ -55,7 +61,7 @@ class UserProfileLiveAdapter(
binding.tvOnAir.visibility = View.VISIBLE
binding.llDate.visibility = View.GONE
binding.tvTime.text = context.getString(R.string.screen_user_profile_on_air)
binding.tvTime.text = wrappedContext.getString(R.string.screen_user_profile_on_air)
binding.tvCompleteReservation.visibility = View.GONE
if (item.price <= 0) {
@@ -75,7 +81,7 @@ class UserProfileLiveAdapter(
binding.llDate.visibility = View.VISIBLE
binding.tvTime.text = dateMap["time"]
binding.tvMonth.text = context.getString(
binding.tvMonth.text = wrappedContext.getString(
R.string.screen_user_profile_month_format,
dateMap["month"]
)

View File

@@ -73,25 +73,25 @@ fun String.formatMoney(currencyCode: String, locale: Locale = Locale.getDefault(
return nf.format(bd)
}
fun String.parseUtcIsoLocalDateTime(): Map<String, String> {
fun String.parseUtcIsoLocalDateTime(locale: Locale = Locale.getDefault()): Map<String, String> {
// 1. 서버가 내려준 포맷: "yyyy-MM-dd'T'HH:mm:ss"
val utcFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault())
val utcFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", locale)
utcFormat.timeZone = TimeZone.getTimeZone("UTC") // 서버가 UTC 기준으로 보낸 것
// 2. Date 객체 생성
val date = utcFormat.parse(this)!!
// 3. 월 (1~12)
val month = SimpleDateFormat("M", Locale.getDefault()).format(date)
val month = SimpleDateFormat("M", locale).format(date)
// 4. 일 (1~31)
val day = SimpleDateFormat("d", Locale.getDefault()).format(date)
val day = SimpleDateFormat("d", locale).format(date)
// 5. 요일 (예: "Mon", "목")
val dayOfWeek = SimpleDateFormat("E", Locale.getDefault()).format(date)
val dayOfWeek = SimpleDateFormat("E", locale).format(date)
// 6. 시간 (예: "AM 05:00")
val time = SimpleDateFormat("a hh:mm", Locale.getDefault()).format(date)
val time = SimpleDateFormat("a hh:mm", locale).format(date)
return mapOf(
"month" to month,

View File

@@ -59,6 +59,8 @@ import kr.co.vividnext.sodalive.mypage.auth.BootpayResponse
import kr.co.vividnext.sodalive.mypage.can.charge.CanChargeActivity
import kr.co.vividnext.sodalive.search.SearchActivity
import kr.co.vividnext.sodalive.settings.event.EventDetailActivity
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import kr.co.vividnext.sodalive.settings.notification.MemberRole
import kr.co.vividnext.sodalive.splash.SplashActivity
import org.koin.android.ext.android.inject
@@ -1255,12 +1257,15 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
}, 300)
}
} else {
val locale = Locale(LanguageManager.getEffectiveLanguage(requireContext()))
val wrappedContext = LocaleHelper.wrap(requireContext())
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
val now = Date()
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", locale)
val diffTime: Long = now.time - beginDate.time
val hours = (diffTime / (1000 * 60 * 60)).toInt()
val mins = (diffTime / (1000 * 60)).toInt() % 60
@@ -1284,7 +1289,7 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
LivePaymentDialog(
activity = requireActivity(),
layoutInflater = layoutInflater,
title = getString(R.string.live_paid_title),
title = wrappedContext.getString(R.string.live_paid_title),
startDateTime = if (hours >= 1) {
dateFormat.format(beginDate)
} else {
@@ -1295,19 +1300,19 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(FragmentHomeBinding::infl
} else {
null
},
desc = getString(R.string.live_paid_desc, it.price),
desc = wrappedContext.getString(R.string.live_paid_desc, it.price),
desc2 = if (hours >= 1) {
getString(R.string.live_paid_warning, hours, mins)
wrappedContext.getString(R.string.live_paid_warning, hours, mins)
} else {
null
},
confirmButtonTitle = getString(R.string.live_paid_confirm),
confirmButtonTitle = wrappedContext.getString(R.string.live_paid_confirm),
confirmButtonClick = {
handler.postDelayed({
liveViewModel.enterRoom(roomId, onEnterRoomSuccess)
}, 300)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonTitle = wrappedContext.getString(R.string.cancel),
cancelButtonClick = {}
).show(screenWidth)
}

View File

@@ -56,6 +56,8 @@ import kr.co.vividnext.sodalive.main.MainActivity
import kr.co.vividnext.sodalive.message.MessageActivity
import kr.co.vividnext.sodalive.mypage.can.charge.CanChargeActivity
import kr.co.vividnext.sodalive.search.SearchActivity
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import kr.co.vividnext.sodalive.settings.notification.MemberRole
import org.koin.android.ext.android.inject
import java.text.SimpleDateFormat
@@ -903,12 +905,15 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
}, 300)
}
} else {
val locale = Locale(LanguageManager.getEffectiveLanguage(requireContext()))
val wrappedContext = LocaleHelper.wrap(requireContext())
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
val now = Date()
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", locale)
val diffTime: Long = now.time - beginDate.time
val hours = (diffTime / (1000 * 60 * 60)).toInt()
val mins = (diffTime / (1000 * 60)).toInt() % 60
@@ -932,7 +937,7 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
LivePaymentDialog(
activity = requireActivity(),
layoutInflater = layoutInflater,
title = getString(R.string.live_paid_title),
title = wrappedContext.getString(R.string.live_paid_title),
startDateTime = if (hours >= 1) {
dateFormat.format(beginDate)
} else {
@@ -943,19 +948,19 @@ class LiveFragment : BaseFragment<FragmentLiveBinding>(FragmentLiveBinding::infl
} else {
null
},
desc = getString(R.string.live_paid_desc, it.price),
desc = wrappedContext.getString(R.string.live_paid_desc, it.price),
desc2 = if (hours >= 1) {
getString(R.string.live_paid_warning, hours, mins)
wrappedContext.getString(R.string.live_paid_warning, hours, mins)
} else {
null
},
confirmButtonTitle = getString(R.string.live_paid_confirm),
confirmButtonTitle = wrappedContext.getString(R.string.live_paid_confirm),
confirmButtonClick = {
handler.postDelayed({
viewModel.enterRoom(roomId, onEnterRoomSuccess)
}, 300)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonTitle = wrappedContext.getString(R.string.cancel),
cancelButtonClick = {}
).show(screenWidth)
}

View File

@@ -23,6 +23,8 @@ import kr.co.vividnext.sodalive.live.room.LiveRoomActivity
import kr.co.vividnext.sodalive.live.room.detail.LiveRoomDetailFragment
import kr.co.vividnext.sodalive.live.room.dialog.LivePaymentDialog
import kr.co.vividnext.sodalive.live.room.dialog.LiveRoomPasswordDialog
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import org.koin.android.ext.android.inject
import java.text.SimpleDateFormat
import java.util.Date
@@ -141,12 +143,15 @@ class LiveNowAllActivity : BaseActivity<ActivityLiveNowAllBinding>(
viewModel.enterRoom(roomId, onEnterRoomSuccess)
}
} else {
val locale = Locale(LanguageManager.getEffectiveLanguage(this))
val wrappedContext = LocaleHelper.wrap(this)
val beginDateFormat = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH)
beginDateFormat.timeZone = TimeZone.getTimeZone("UTC")
val beginDate = beginDateFormat.parse(it.beginDateTimeUtc)!!
val now = Date()
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", Locale.getDefault())
val dateFormat = SimpleDateFormat("yyyy-MM-dd, HH:mm", locale)
val diffTime: Long = now.time - beginDate.time
val hours = (diffTime / (1000 * 60 * 60)).toInt()
val mins = (diffTime / (1000 * 60)).toInt() % 60
@@ -168,7 +173,7 @@ class LiveNowAllActivity : BaseActivity<ActivityLiveNowAllBinding>(
LivePaymentDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.live_paid_title),
title = wrappedContext.getString(R.string.live_paid_title),
startDateTime = if (hours >= 1) {
dateFormat.format(beginDate)
} else {
@@ -179,17 +184,17 @@ class LiveNowAllActivity : BaseActivity<ActivityLiveNowAllBinding>(
} else {
null
},
desc = getString(R.string.live_paid_desc, it.price),
desc = wrappedContext.getString(R.string.live_paid_desc, it.price),
desc2 = if (hours >= 1) {
getString(R.string.live_paid_warning, hours, mins)
wrappedContext.getString(R.string.live_paid_warning, hours, mins)
} else {
null
},
confirmButtonTitle = getString(R.string.live_paid_confirm),
confirmButtonTitle = wrappedContext.getString(R.string.live_paid_confirm),
confirmButtonClick = {
viewModel.enterRoom(roomId, onEnterRoomSuccess)
},
cancelButtonTitle = getString(R.string.cancel),
cancelButtonTitle = wrappedContext.getString(R.string.cancel),
cancelButtonClick = {}
).show(screenWidth)
}

View File

@@ -17,6 +17,9 @@ import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.extensions.moneyFormat
import kr.co.vividnext.sodalive.extensions.parseUtcIsoLocalDateTime
import kr.co.vividnext.sodalive.live.GetRoomListResponse
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import java.util.Locale
class LiveReservationAdapter(
private val isMain: Boolean = false,
@@ -81,7 +84,9 @@ class LiveReservationAdapter(
@SuppressLint("SetTextI18n")
fun bind(item: GetRoomListResponse) {
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime()
val locale = Locale(LanguageManager.getEffectiveLanguage(context))
val wrappedContext = LocaleHelper.wrap(context)
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime(locale)
Glide
.with(context)
@@ -96,7 +101,7 @@ class LiveReservationAdapter(
binding.tvTime.text = dateMap["time"]
binding.tvMonth.text =
context.getString(R.string.live_reservation_month_label, dateMap["month"])
wrappedContext.getString(R.string.live_reservation_month_label, dateMap["month"])
binding.tvDay.text = dateMap["day"]
if (item.isReservation) {
@@ -137,7 +142,9 @@ class LiveReservationAdapter(
View.GONE
}
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime()
val locale = Locale(LanguageManager.getEffectiveLanguage(context))
val wrappedContext = LocaleHelper.wrap(context)
val dateMap = item.beginDateTimeUtc.parseUtcIsoLocalDateTime(locale)
Glide
.with(context)
@@ -152,7 +159,7 @@ class LiveReservationAdapter(
binding.tvTime.text = dateMap["time"]
binding.tvMonth.text =
context.getString(R.string.live_reservation_month_label, dateMap["month"])
wrappedContext.getString(R.string.live_reservation_month_label, dateMap["month"])
binding.tvDay.text = dateMap["day"]
if (item.price <= 0) {

View File

@@ -20,7 +20,10 @@ import kr.co.vividnext.sodalive.extensions.convertDateFormat
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.main.MainActivity
import kr.co.vividnext.sodalive.mypage.can.status.CanStatusActivity
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import org.koin.android.ext.android.inject
import java.util.Locale
import java.util.TimeZone
class LiveReservationCancelActivity : BaseActivity<ActivityLiveReservationCancelBinding>(
@@ -148,9 +151,13 @@ class LiveReservationCancelActivity : BaseActivity<ActivityLiveReservationCancel
@SuppressLint("SetTextI18n")
private fun setReservation(response: GetLiveReservationResponse) {
val locale = Locale(LanguageManager.getEffectiveLanguage(this))
val wrappedContext = LocaleHelper.wrap(this)
binding.tvDate.text = response.beginDateTimeUtc.convertDateFormat(
from = "yyyy-MM-dd'T'HH:mm:ss",
to = "yyyy.MM.dd EEE hh:mm a",
outputLocale = locale,
inputTimeZone = TimeZone.getTimeZone("UTC")
)
binding.tvNickname.text = response.masterNickname
@@ -167,8 +174,7 @@ class LiveReservationCancelActivity : BaseActivity<ActivityLiveReservationCancel
} else {
binding.tvCheckCanStatus.visibility = View.GONE
binding.tvPrice.text =
SodaLiveApplicationHolder.get()
.getString(R.string.live_reservation_free)
wrappedContext.getString(R.string.live_reservation_free)
}
}
}

View File

@@ -10,6 +10,9 @@ import kr.co.vividnext.sodalive.databinding.ItemLiveReservationStatusBinding
import kr.co.vividnext.sodalive.extensions.convertDateFormat
import kr.co.vividnext.sodalive.extensions.dpToPx
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import java.util.Locale
import java.util.TimeZone
class LiveReservationStatusAdapter(
@@ -24,9 +27,13 @@ class LiveReservationStatusAdapter(
fun bind(item: GetLiveReservationResponse) {
val context = binding.root.context
val locale = Locale(LanguageManager.getEffectiveLanguage(context))
val wrappedContext = LocaleHelper.wrap(context)
binding.tvDate.text = item.beginDateTimeUtc.convertDateFormat(
from = "yyyy-MM-dd'T'HH:mm:ss",
to = "yyyy.MM.dd EEE hh:mm a",
outputLocale = locale,
inputTimeZone = TimeZone.getTimeZone("UTC")
)
binding.tvNickname.text = item.masterNickname
@@ -38,9 +45,9 @@ class LiveReservationStatusAdapter(
}
binding.tvPrice.text = if (item.price > 0) {
context.getString(R.string.live_reservation_status_price, item.price)
wrappedContext.getString(R.string.live_reservation_status_price, item.price)
} else {
context.getString(R.string.live_reservation_free)
wrappedContext.getString(R.string.live_reservation_free)
}
if (item.cancelable) {
@@ -49,7 +56,7 @@ class LiveReservationStatusAdapter(
} else {
binding.tvCancel.visibility = View.GONE
binding.tvNonCancellable.apply {
text = context.getString(R.string.live_reservation_status_not_cancelable)
text = wrappedContext.getString(R.string.live_reservation_status_not_cancelable)
visibility = View.VISIBLE
}
}

View File

@@ -15,6 +15,9 @@ import kr.co.vividnext.sodalive.extensions.convertDateFormat
import kr.co.vividnext.sodalive.live.LiveRepository
import kr.co.vividnext.sodalive.live.room.detail.GetRoomDetailResponse
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.settings.language.LanguageManager
import kr.co.vividnext.sodalive.settings.language.LocaleHelper
import kr.co.vividnext.sodalive.common.SodaLiveApplicationHolder
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody
import java.util.Locale
@@ -136,15 +139,20 @@ class LiveRoomEditViewModel(
fun setRoomDetail(roomDetail: GetRoomDetailResponse) {
this.roomDetail = roomDetail
val context = SodaLiveApplicationHolder.get()
val locale = Locale(LanguageManager.getEffectiveLanguage(context))
val date = roomDetail.beginDateTimeUtc.convertDateFormat(
from = "yyyy-MM-dd'T'HH:mm:ss",
to = "yyyy.MM.dd",
outputLocale = locale,
inputTimeZone = TimeZone.getTimeZone("UTC")
)
val time = roomDetail.beginDateTimeUtc.convertDateFormat(
from = "yyyy-MM-dd'T'HH:mm:ss",
to = "a hh:mm",
outputLocale = locale,
inputTimeZone = TimeZone.getTimeZone("UTC")
)