Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 18 additions & 8 deletions app/src/main/kotlin/de/timklge/karoonotepad/NotepadDataType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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<MainActivity>()
)
) {
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)
Expand Down