diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 7f03cbd..ecbc339 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -64,8 +64,9 @@ dependencies { implementation(activityCompose) } - implementation("androidx.glance:glance-appwidget:1.0.0-SNAPSHOT") - + with(Deps.Glance) { + implementation(appwidget) + } with(Deps.Compose) { implementation(compiler) @@ -79,8 +80,6 @@ dependencies { implementation(uiTooling) } - - with(Deps.Koin) { implementation(core) implementation(android) diff --git a/app/src/main/java/com/surrus/peopleinspace/glance/ISSMapWidget.kt b/app/src/main/java/com/surrus/peopleinspace/glance/ISSMapWidget.kt index 3e5e213..6b89e13 100644 --- a/app/src/main/java/com/surrus/peopleinspace/glance/ISSMapWidget.kt +++ b/app/src/main/java/com/surrus/peopleinspace/glance/ISSMapWidget.kt @@ -7,13 +7,14 @@ import androidx.compose.ui.unit.ExperimentalUnitApi import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.TextUnitType import androidx.glance.GlanceModifier -import androidx.glance.action.actionLaunchActivity +import androidx.glance.Image +import androidx.glance.ImageProvider +import androidx.glance.action.actionStartActivity import androidx.glance.action.clickable import androidx.glance.background import androidx.glance.layout.Box -import androidx.glance.layout.ImageProvider -import androidx.glance.layout.Text import androidx.glance.layout.fillMaxSize +import androidx.glance.text.Text import androidx.glance.text.TextStyle import androidx.glance.unit.ColorProvider import com.surrus.common.repository.PeopleInSpaceRepositoryInterface @@ -81,12 +82,12 @@ class ISSMapWidget : BaseGlanceAppWidget() { override fun Content(data: Data?) { Box( modifier = GlanceModifier.background(Color.DarkGray).fillMaxSize().clickable( - actionLaunchActivity() + actionStartActivity() ) ) { val bitmap = data?.bitmap if (bitmap != null) { - androidx.glance.layout.Image( + Image( modifier = GlanceModifier.fillMaxSize(), provider = ImageProvider(bitmap), contentDescription = "ISS Location" diff --git a/app/src/main/java/com/surrus/peopleinspace/glance/PeopleInSpaceWidget.kt b/app/src/main/java/com/surrus/peopleinspace/glance/PeopleInSpaceWidget.kt index 694d593..553dc9f 100644 --- a/app/src/main/java/com/surrus/peopleinspace/glance/PeopleInSpaceWidget.kt +++ b/app/src/main/java/com/surrus/peopleinspace/glance/PeopleInSpaceWidget.kt @@ -7,13 +7,12 @@ import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.TextUnitType import androidx.compose.ui.unit.dp import androidx.glance.GlanceModifier -import androidx.glance.appwidget.layout.LazyColumn -import androidx.glance.appwidget.layout.items +import androidx.glance.appwidget.lazy.LazyColumn import androidx.glance.background import androidx.glance.layout.Row -import androidx.glance.layout.Text import androidx.glance.layout.padding import androidx.glance.text.FontWeight +import androidx.glance.text.Text import androidx.glance.text.TextStyle import androidx.glance.unit.ColorProvider import com.surrus.common.remote.Assignment @@ -49,10 +48,10 @@ class PeopleInSpaceWidget : BaseGlanceAppWidget() { ) } if (data != null) { - items(data.people) { + items(data.people.size) { Row { Text( - text = it.name, + text = data.people[it].name, style = TextStyle( color = ColorProvider(Color.White), fontSize = TextUnit(10f, TextUnitType.Sp) diff --git a/app/src/main/java/com/surrus/peopleinspace/glance/util/BaseGlanceAppWidget.kt b/app/src/main/java/com/surrus/peopleinspace/glance/util/BaseGlanceAppWidget.kt index e55bcf9..00cdc2c 100644 --- a/app/src/main/java/com/surrus/peopleinspace/glance/util/BaseGlanceAppWidget.kt +++ b/app/src/main/java/com/surrus/peopleinspace/glance/util/BaseGlanceAppWidget.kt @@ -7,10 +7,10 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.unit.DpSize +import androidx.glance.GlanceId +import androidx.glance.LocalGlanceId import androidx.glance.LocalSize import androidx.glance.appwidget.GlanceAppWidget -import androidx.glance.appwidget.GlanceId -import androidx.glance.appwidget.LocalGlanceId import kotlinx.coroutines.MainScope import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.firstOrNull diff --git a/build.gradle.kts b/build.gradle.kts index 4899fa6..b004e35 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,9 +33,7 @@ allprojects { mavenCentral() maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers") maven(url = "https://jitpack.io") - maven(url = "https://androidx.dev/snapshots/builds/7888785/artifacts/repository") maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") - maven(url = "https://maven.pkg.jetbrains.space/public/p/ktor/eap") } } diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 1dc81dc..aadf33d 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -156,4 +156,9 @@ object Deps { const val logback = "ch.qos.logback:logback-classic:${Versions.logback}" const val kermit = "co.touchlab:kermit:${Versions.kermit}" } + + object Glance { + const val tiles = "androidx.glance:glance-wear-tiles:1.0.0-alpha02" + const val appwidget = "androidx.glance:glance-appwidget:1.0.0-alpha02" + } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 3a35e31..6f462b1 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -2,7 +2,6 @@ pluginManagement { repositories { gradlePluginPortal() mavenCentral() - maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev") } resolutionStrategy { eachPlugin { diff --git a/wearApp/build.gradle.kts b/wearApp/build.gradle.kts index 3fcfa36..b79eba2 100644 --- a/wearApp/build.gradle.kts +++ b/wearApp/build.gradle.kts @@ -85,7 +85,9 @@ dependencies { debugImplementation(composeUiTestManifest) } - implementation("androidx.glance:glance-wear:1.0.0-SNAPSHOT") + with(Deps.Glance) { + implementation(tiles) + } implementation(project(":common")) } \ No newline at end of file diff --git a/wearApp/src/main/java/com/surrus/peopleinspace/tile/PeopleInSpaceTile.kt b/wearApp/src/main/java/com/surrus/peopleinspace/tile/PeopleInSpaceTile.kt index 10f7f0e..d83209d 100644 --- a/wearApp/src/main/java/com/surrus/peopleinspace/tile/PeopleInSpaceTile.kt +++ b/wearApp/src/main/java/com/surrus/peopleinspace/tile/PeopleInSpaceTile.kt @@ -8,16 +8,16 @@ import androidx.compose.ui.unit.TextUnitType import androidx.compose.ui.unit.dp import androidx.glance.GlanceModifier import androidx.glance.layout.Column -import androidx.glance.layout.Text import androidx.glance.layout.padding import androidx.glance.text.FontWeight +import androidx.glance.text.Text import androidx.glance.text.TextStyle import androidx.glance.unit.ColorProvider import com.surrus.common.remote.Assignment import com.surrus.common.repository.PeopleInSpaceRepositoryInterface import com.surrus.peopleinspace.tile.util.BaseGlanceTileService import kotlinx.coroutines.flow.first -import org.koin.android.ext.android.inject +import org.koin.core.component.inject class PeopleInSpaceTile : BaseGlanceTileService() { val repository: PeopleInSpaceRepositoryInterface by inject() diff --git a/wearApp/src/main/java/com/surrus/peopleinspace/tile/util/BaseGlanceTileService.kt b/wearApp/src/main/java/com/surrus/peopleinspace/tile/util/BaseGlanceTileService.kt index 62901a8..7b02bae 100644 --- a/wearApp/src/main/java/com/surrus/peopleinspace/tile/util/BaseGlanceTileService.kt +++ b/wearApp/src/main/java/com/surrus/peopleinspace/tile/util/BaseGlanceTileService.kt @@ -1,11 +1,16 @@ package com.surrus.peopleinspace.tile.util +import android.content.Context import androidx.compose.runtime.Composable -import androidx.glance.wear.GlanceTileService +import androidx.glance.wear.tiles.GlanceTileService import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.runBlocking +import org.koin.core.component.KoinComponent +import org.koin.core.component.inject + +abstract class BaseGlanceTileService : GlanceTileService(), KoinComponent { + val context: Context by inject() -abstract class BaseGlanceTileService : GlanceTileService() { @Composable override fun Content() { // Terrible hack for lack of suspend load function