summaryrefslogtreecommitdiff
path: root/android/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/AndroidManifest.xml2
-rw-r--r--android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt27
-rw-r--r--android/app/src/test/java/org/terst/doot/widget/WidgetRepositoryTest.kt6
3 files changed, 18 insertions, 17 deletions
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index d4ec310..f6bf015 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -7,7 +7,7 @@
<application
android:label="Doot Widget"
- android:theme="@style/Theme.Material3.DayNight"
+ android:theme="@android:style/Theme.DeviceDefault.DayNight"
android:allowBackup="false">
<!-- Settings activity (also the widget config screen) -->
diff --git a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
index c7e48be..23a7019 100644
--- a/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
+++ b/android/app/src/main/java/org/terst/doot/widget/ui/DootWidget.kt
@@ -19,6 +19,7 @@ import androidx.glance.layout.*
import androidx.glance.text.FontWeight
import androidx.glance.text.Text
import androidx.glance.text.TextStyle
+import androidx.glance.unit.ColorProvider
import kotlinx.coroutines.flow.first
import kotlinx.serialization.json.Json
import org.terst.doot.widget.data.*
@@ -95,10 +96,10 @@ fun HourRow(
nowZoned: ZonedDateTime,
scheduled: List<WidgetItem>,
fragments: List<TaskFragment>,
- zone: ZoneId
+ @Suppress("UNUSED_PARAMETER") zone: ZoneId
) {
val hourStart = nowZoned.withHour(hour).withMinute(0).withSecond(0).withNano(0).toInstant()
- val hourEnd = nowZoned.withHour(hour + 1).withMinute(0).withSecond(0).withNano(0).toInstant()
+ val hourEnd = nowZoned.withHour(if (hour < 23) hour + 1 else 23).withMinute(59).withSecond(59).withNano(0).toInstant()
val isNowHour = nowZoned.hour == hour
val eventsHere = scheduled.filter { event ->
@@ -122,13 +123,10 @@ fun HourRow(
)
Column(modifier = GlanceModifier.defaultWeight()) {
- Box(
- modifier = GlanceModifier
- .fillMaxWidth()
- .height(1.dp)
- .background(Color(0x1AFFFFFF))
- )
+ // Hour divider line
+ Box(modifier = GlanceModifier.fillMaxWidth().height(1.dp).background(Color(0x1AFFFFFF))) {}
+ // NOW indicator
if (isNowHour) {
Box(
modifier = GlanceModifier
@@ -136,7 +134,7 @@ fun HourRow(
.height(1.dp)
.background(Color(0xBFFFFFFF.toInt()))
.padding(vertical = 2.dp)
- )
+ ) {}
}
eventsHere.forEach { event ->
@@ -159,7 +157,7 @@ fun EventBlock(event: WidgetItem, isPast: Boolean) {
modifier = GlanceModifier
.fillMaxWidth()
.padding(vertical = 2.dp)
- .clickable(actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(event.url)))),
+ .clickable(actionStartActivity(Intent(Intent.ACTION_VIEW, Uri.parse(event.url.ifEmpty { "https://calendar.google.com" })))),
verticalAlignment = Alignment.CenterVertically
) {
Box(
@@ -167,7 +165,7 @@ fun EventBlock(event: WidgetItem, isPast: Boolean) {
.width(3.dp)
.height(20.dp)
.background(color.copy(alpha = alpha))
- )
+ ) {}
Text(
text = event.title,
style = TextStyle(
@@ -186,7 +184,7 @@ fun TaskFragmentBlock(fragment: TaskFragment) {
modifier = GlanceModifier
.fillMaxWidth()
.padding(vertical = 2.dp)
- .background(Color(0xFF1E1E1E))
+ .background(Color(0xFF1E1E1E.toInt()))
) {
Text(
"TODAY",
@@ -197,7 +195,6 @@ fun TaskFragmentBlock(fragment: TaskFragment) {
),
modifier = GlanceModifier.padding(start = 8.dp, top = 3.dp, bottom = 1.dp)
)
-
fragment.slots.forEach { slot ->
TaskRow(slot.task)
}
@@ -231,13 +228,13 @@ fun TaskRow(task: WidgetItem) {
modifier = GlanceModifier
.size(8.dp)
.background(sourceColor(task.source).copy(alpha = 0.6f))
- )
+ ) {}
}
Text(
text = task.title,
style = TextStyle(
- color = ColorProvider(Color(0xFFDDDDDD)),
+ color = ColorProvider(Color(0xFFDDDDDD.toInt())),
fontSize = 10.sp
),
modifier = GlanceModifier.padding(start = 7.dp),
diff --git a/android/app/src/test/java/org/terst/doot/widget/WidgetRepositoryTest.kt b/android/app/src/test/java/org/terst/doot/widget/WidgetRepositoryTest.kt
index d4c2ce3..09fd467 100644
--- a/android/app/src/test/java/org/terst/doot/widget/WidgetRepositoryTest.kt
+++ b/android/app/src/test/java/org/terst/doot/widget/WidgetRepositoryTest.kt
@@ -2,8 +2,12 @@ package org.terst.doot.widget
import io.mockk.*
import kotlinx.coroutines.test.runTest
-import okhttp3.*
+import okhttp3.Call
import okhttp3.MediaType.Companion.toMediaType
+import okhttp3.OkHttpClient
+import okhttp3.Protocol
+import okhttp3.Request
+import okhttp3.Response
import okhttp3.ResponseBody.Companion.toResponseBody
import org.junit.Assert.*
import org.junit.Test