From bc3690360307a35bd41e9afcaadbf30d77ed9653 Mon Sep 17 00:00:00 2001 From: mueller-ma Date: Fri, 27 Dec 2024 16:54:57 +0100 Subject: [PATCH] Show date in DayDream Signed-off-by: mueller-ma --- .../main/java/org/openhab/habdroid/ui/DayDream.kt | 11 +++++++++++ mobile/src/main/res/layout/daydream.xml | 13 +++++++++++++ mobile/src/main/res/values/styles.xml | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/DayDream.kt b/mobile/src/main/java/org/openhab/habdroid/ui/DayDream.kt index 58d23e1670..40b3707351 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/DayDream.kt +++ b/mobile/src/main/java/org/openhab/habdroid/ui/DayDream.kt @@ -19,11 +19,14 @@ import android.graphics.Rect import android.os.Handler import android.os.Looper import android.service.dreams.DreamService +import android.text.format.DateFormat import android.util.Log import android.view.View import android.widget.FrameLayout import android.widget.LinearLayout +import android.widget.TextClock import android.widget.TextView +import java.util.Locale import kotlin.coroutines.CoroutineContext import kotlin.random.Random import kotlin.time.Duration.Companion.minutes @@ -65,12 +68,20 @@ class DayDream : DreamService(), CoroutineScope { textView = findViewById(R.id.text) wrapper = findViewById(R.id.wrapper) container = findViewById(R.id.container) + setupDateView() launch { item?.let { listenForTextItem(it) } } } + private fun setupDateView() { + val dateView: TextClock = findViewById(R.id.date) + val pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), "EEEE, MMMM d, yyyy") + dateView.format12Hour = pattern + dateView.format24Hour = pattern + } + override fun onConfigurationChanged(newConfig: Configuration) { super.onConfigurationChanged(newConfig) moveTextIfRequired() diff --git a/mobile/src/main/res/layout/daydream.xml b/mobile/src/main/res/layout/daydream.xml index 955661f926..b39d605678 100644 --- a/mobile/src/main/res/layout/daydream.xml +++ b/mobile/src/main/res/layout/daydream.xml @@ -16,14 +16,27 @@ android:id="@+id/clock" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="center_horizontal" + android:fontFamily="sans-serif-light" android:textAppearance="@style/TextAppearance.Material3.DisplayLarge" /> + + diff --git a/mobile/src/main/res/values/styles.xml b/mobile/src/main/res/values/styles.xml index 4b3ce7e4a3..549ed212c6 100644 --- a/mobile/src/main/res/values/styles.xml +++ b/mobile/src/main/res/values/styles.xml @@ -40,4 +40,8 @@ 8dp ?android:attr/textColorSecondary + +