From c8461fb17eb381524101e7894fe0840a5a211f9a Mon Sep 17 00:00:00 2001 From: Tim Kluge Date: Sat, 6 Sep 2025 20:22:02 +0200 Subject: [PATCH] Also open notepad editing activity when clicking on the text datafield --- app/build.gradle.kts | 2 +- .../timklge/karoonotepad/NotepadDataType.kt | 26 +++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f8f3b33..544f9a0 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -73,7 +73,7 @@ tasks.register("generateManifest") { "latestVersionCode" to android.defaultConfig.versionCode, "developer" to "github.com/timklge", "description" to "Open-source extension that provides a simple notepad", - "releaseNotes" to "* Fix notepad description", + "releaseNotes" to "* Also open notepad editing activity when clicking on the text datafield", "screenshotUrls" to listOf( "$baseUrl/menu.png", "$baseUrl/profile.png", diff --git a/app/src/main/kotlin/de/timklge/karoonotepad/NotepadDataType.kt b/app/src/main/kotlin/de/timklge/karoonotepad/NotepadDataType.kt index cdd91c8..3de24fb 100644 --- a/app/src/main/kotlin/de/timklge/karoonotepad/NotepadDataType.kt +++ b/app/src/main/kotlin/de/timklge/karoonotepad/NotepadDataType.kt @@ -7,9 +7,12 @@ import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.glance.GlanceModifier +import androidx.glance.action.actionStartActivity +import androidx.glance.action.clickable import androidx.glance.appwidget.ExperimentalGlanceRemoteViewsApi import androidx.glance.appwidget.GlanceRemoteViews import androidx.glance.color.ColorProvider +import androidx.glance.layout.Box import androidx.glance.layout.fillMaxSize import androidx.glance.layout.padding import androidx.glance.text.Text @@ -24,7 +27,6 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.awaitCancellation -import kotlinx.coroutines.flow.sample import kotlinx.coroutines.launch @OptIn(ExperimentalGlanceRemoteViewsApi::class) @@ -47,13 +49,21 @@ class NotepadDataType( val viewJob = CoroutineScope(Dispatchers.IO).launch { context.streamPreferences().collect { notes -> val result = glance.compose(context, DpSize.Unspecified) { - Text( - notes.firstOrNull()?.text ?: "", - modifier = GlanceModifier.fillMaxSize().padding(10.dp), - style = TextStyle( - color = ColorProvider(Color.Black, Color.White), - fontSize = 20.sp) - ) + val modifier = GlanceModifier.fillMaxSize() + + Box( + modifier = if (config.preview) modifier else modifier.clickable( + actionStartActivity() + ) + ) { + Text( + notes.firstOrNull()?.text ?: "", + modifier = GlanceModifier.fillMaxSize().padding(10.dp), + style = TextStyle( + color = ColorProvider(Color.Black, Color.White), + fontSize = 20.sp) + ) + } } emitter.updateView(result.remoteViews)