Merge pull request #115 from yschimke/glance2

Glance upgrades
This commit is contained in:
John O'Reilly 2022-01-29 13:26:02 +00:00 committed by GitHub
commit c666ae73b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 32 additions and 24 deletions

View file

@ -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)

View file

@ -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<ISSMapWidget.Data>() {
override fun Content(data: Data?) {
Box(
modifier = GlanceModifier.background(Color.DarkGray).fillMaxSize().clickable(
actionLaunchActivity<MainActivity>()
actionStartActivity<MainActivity>()
)
) {
val bitmap = data?.bitmap
if (bitmap != null) {
androidx.glance.layout.Image(
Image(
modifier = GlanceModifier.fillMaxSize(),
provider = ImageProvider(bitmap),
contentDescription = "ISS Location"

View file

@ -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<PeopleInSpaceWidget.Data>() {
)
}
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)

View file

@ -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

View file

@ -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")
}
}

View file

@ -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"
}
}

View file

@ -2,7 +2,6 @@ pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
resolutionStrategy {
eachPlugin {

View file

@ -85,7 +85,9 @@ dependencies {
debugImplementation(composeUiTestManifest)
}
implementation("androidx.glance:glance-wear:1.0.0-SNAPSHOT")
with(Deps.Glance) {
implementation(tiles)
}
implementation(project(":common"))
}

View file

@ -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<PeopleInSpaceTile.Data>() {
val repository: PeopleInSpaceRepositoryInterface by inject()

View file

@ -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<T> : GlanceTileService(), KoinComponent {
val context: Context by inject()
abstract class BaseGlanceTileService<T> : GlanceTileService() {
@Composable
override fun Content() {
// Terrible hack for lack of suspend load function