From c198294e1292f9766599c03029efbb7aa32f31a9 Mon Sep 17 00:00:00 2001 From: lunaticbum <> Date: Wed, 4 Sep 2024 18:29:53 +0900 Subject: [PATCH] //// --- .../rasel/lunar/launcher/home/LauncherHome.kt | 4 +- .../rasel/lunar/launcher/view/DateTimeView.kt | 15 ++++- app/src/main/res/layout/launcher_home.xml | 57 ++++++++++--------- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt index 5b7c1dbd..5fe6208d 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/home/LauncherHome.kt @@ -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 diff --git a/app/src/main/kotlin/rasel/lunar/launcher/view/DateTimeView.kt b/app/src/main/kotlin/rasel/lunar/launcher/view/DateTimeView.kt index 768aefe8..9f01bd5a 100644 --- a/app/src/main/kotlin/rasel/lunar/launcher/view/DateTimeView.kt +++ b/app/src/main/kotlin/rasel/lunar/launcher/view/DateTimeView.kt @@ -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) } diff --git a/app/src/main/res/layout/launcher_home.xml b/app/src/main/res/layout/launcher_home.xml index a37f89d9..9c7162f4 100644 --- a/app/src/main/res/layout/launcher_home.xml +++ b/app/src/main/res/layout/launcher_home.xml @@ -23,6 +23,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:text="this is init sentence" + android:id="@+id/time" android:gravity="center" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" @@ -30,34 +31,34 @@ android:textSize="16sp" tools:ignore="MissingConstraints" /> - + + + + + + + + + + + + + + - + + + + + + + + + + + + +