This commit is contained in:
lunaticbum
2024-09-04 18:29:53 +09:00
parent cb3062153f
commit c198294e12
3 changed files with 45 additions and 31 deletions
@@ -394,8 +394,8 @@ internal class LauncherHome : Fragment() {
// binding.time.textLocale = Locale.US
// binding.date.textLocale = Locale.US
// if (DateFormat.is24HourFormat(requireContext())) {
binding.time.format24Hour = timeFormat
binding.date.format24Hour = "yyyy년 M월 W주차, dd일 E요일"
// binding.time.format24Hour = timeFormat
// binding.date.format24Hour = "yyyy년 M월 W주차, dd일 E요일"
// } else {
// binding.time.format12Hour = timeFormat
// binding.date.format12Hour = dateFormat
@@ -9,6 +9,9 @@ import android.os.Handler
import android.os.Looper
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
@@ -46,8 +49,18 @@ class DateTimeView : AppCompatTextView {
val spannableBuilder = SpannableStringBuilder()
private fun setTime() {
spannableBuilder.clear()
val now = Date(System.currentTimeMillis())
val time = SpannableString(simpleTimeFormat.format(now))
val date = SpannableString(simpleDateFormat.format(now))
spannableBuilder.append(time)
spannableBuilder.setSpan(AbsoluteSizeSpan(48,true), 0, time.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
spannableBuilder.append("\n")
spannableBuilder.append(date)
var start = time.length + "\n".length
spannableBuilder.setSpan(AbsoluteSizeSpan(30,true), start , start+date.length , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
mHandler.removeCallbacks(runable)
setText(simpleDateFormat.format(Date(System.currentTimeMillis())))
setText(spannableBuilder)
mHandler.postDelayed(runable, DateTimeView.DALEY)
}