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 .github/workflows/android_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
TERM: dumb

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down Expand Up @@ -134,7 +134,7 @@ jobs:
TERM: dumb

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand All @@ -160,7 +160,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand All @@ -27,7 +27,7 @@ jobs:
- name: Generate cache key
run: ./checksum.sh checksum.txt

- uses: actions/cache@v5
- uses: actions/cache@v6
with:
path: |
~/.gradle/caches/modules-*
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fixup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 40

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macrobenchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
TERM: dumb

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand All @@ -27,7 +27,7 @@ jobs:
- name: Generate cache key
run: ./checksum.sh checksum.txt

- uses: actions/cache@v5
- uses: actions/cache@v6
with:
path: |
~/.gradle/caches/modules-*
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
TERM: dumb

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
lfs: 'true'

Expand All @@ -31,7 +31,7 @@ jobs:
- name: Generate cache key
run: ./checksum.sh checksum.txt

- uses: actions/cache@v5
- uses: actions/cache@v6
with:
path: |
~/.gradle/caches/modules-*
Expand All @@ -40,7 +40,7 @@ jobs:
key: gradle-${{ hashFiles('checksum.txt') }}

- name: Setup Python
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: '3.x'

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The currently maintained branches of Horologist are.
| Version | Branch | Min SDK (Wear) | Kotlin/JDK | Description |
|---------|---------------|----------------|------------|-------------------------------------------------------------------------------------|
| 0.7.x | release-0.7.x | 26 | 2.2.0 / 17 | Wear Compose 1.5.x, Compose 1.8.x and generally latest stable Androidx. |
| 0.8.x | main | 26 | 2.x / 17 | Wear Compose 1.6.x, Compose 1.9.x and generally latest relevant alphas of Androidx. |
| 0.8.x | main | 26 | 2.2 / 17 | Wear Compose 1.6.x, Compose 1.9.x and generally latest relevant alphas of Androidx. |

Maintenance branches will not delete existing APIs and they should remain stable. However
the main branch will actively update to incorporate new API guidance, removing or changing
Expand Down
1 change: 1 addition & 0 deletions auth/composables-material3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ dependencies {
implementation(libs.compose.material.iconsext)
implementation(libs.compose.material3)
implementation(libs.compose.ui.graphics)
implementation(libs.androidx.graphics.shapes)
implementation(libs.compose.ui.text)
implementation(libs.compose.ui.unit)
implementation(libs.kotlin.stdlib)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/*
* Copyright 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.android.horologist.auth.composables.material3.screens

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.geometry.center
import androidx.compose.ui.graphics.Matrix
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.asComposePath
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import androidx.graphics.shapes.CornerRounding
import androidx.graphics.shapes.RoundedPolygon
import androidx.graphics.shapes.toPath
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin

internal data class PointNRound(val o: Offset, val r: CornerRounding = CornerRounding.Unrounded)

private fun Float.toRadians(): Float = (this * Math.PI / 180f).toFloat()

private fun Offset.angleDegrees(): Float =
atan2(y, x) * 180f / Math.PI.toFloat()

private fun Offset.rotateDegrees(angle: Float, center: Offset): Offset {
val rad = angle.toRadians()
val cos = cos(rad)
val sin = sin(rad)
val dx = x - center.x
val dy = y - center.y
return Offset(
dx * cos - dy * sin + center.x,
dx * sin + dy * cos + center.y
)
}

internal fun doRepeat(points: List<PointNRound>, reps: Int, center: Offset, mirroring: Boolean) =
if (mirroring) {
buildList {
val angles = points.map { (it.o - center).angleDegrees() }
val distances = points.map { (it.o - center).getDistance() }
val actualReps = reps * 2
val sectionAngle = 360f / actualReps
repeat(actualReps) {
points.indices.forEach { index ->
val i = if (it % 2 == 0) index else points.lastIndex - index
if (i > 0 || it % 2 == 0) {
val a =
(sectionAngle * it +
if (it % 2 == 0) angles[i] else sectionAngle - angles[i] + 2 * angles[0])
.toRadians()
val finalPoint = Offset(cos(a), sin(a)) * distances[i] + center
add(PointNRound(finalPoint, points[i].r))
}
}
}
}
} else {
points.size.let { np ->
(0 until np * reps).map {
val point = points[it % np].o.rotateDegrees((it / np) * 360f / reps, center)
PointNRound(point, points[it % np].r)
}
}
}

internal fun customPolygon(
points: List<PointNRound>,
reps: Int,
mirroring: Boolean,
center: Offset = Offset(0.5f, 0.5f)
): RoundedPolygon {
val repeatedPoints = doRepeat(points, reps, center, mirroring)
val vertices = FloatArray(repeatedPoints.size * 2)
val roundings = mutableListOf<CornerRounding>()
for (i in repeatedPoints.indices) {
vertices[2 * i] = repeatedPoints[i].o.x
vertices[2 * i + 1] = repeatedPoints[i].o.y
roundings.add(repeatedPoints[i].r)
}
return RoundedPolygon(
vertices = vertices,
perVertexRounding = roundings,
centerX = center.x,
centerY = center.y
)
}

internal fun pill(): RoundedPolygon {
return customPolygon(
listOf(
PointNRound(Offset(0.961f, 0.039f), CornerRounding(0.426f)),
PointNRound(Offset(1.001f, 0.428f)),
PointNRound(Offset(1.000f, 0.609f), CornerRounding(1.000f)),
),
reps = 2,
mirroring = true,
)
}

@Composable
internal fun RoundedPolygon.toShape(): Shape {
return remember(this) {
object : Shape {
private val shapePath: Path = toPath().asComposePath()
private val workPath: Path = Path()

override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density,
): Outline {
workPath.rewind()
workPath.addPath(shapePath)
val scaleMatrix = Matrix().apply { scale(x = size.width, y = size.height) }
workPath.transform(scaleMatrix)
workPath.translate(size.center - workPath.getBounds().center)
return Outline.Generic(workPath)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountCircle
import androidx.compose.material.icons.outlined.AccountCircle
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialShapes
import androidx.compose.material3.toShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
Expand Down Expand Up @@ -161,11 +159,15 @@ internal fun SignedInConfirmationDialogContent(
horizontalAlignment = Alignment.CenterHorizontally,
) {
val hasName = !name.isNullOrEmpty()
// TODO: Revert to MaterialShapes.Pill.toShape() once we can upgrade compose-material3 version.
// Using graphics-shapes directly as a workaround to avoid compileSdk 37.
val pillPolygon = remember { pill() }
val pillShape = pillPolygon.toShape()
Box(
modifier = Modifier
.padding(4.dp)
.size(96.dp)
.clip(MaterialShapes.Pill.toShape())
.clip(pillShape)
.background(MaterialTheme.colorScheme.surfaceContainer),
contentAlignment = Alignment.Center,
) {
Expand Down
11 changes: 6 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ allprojects {
exclude(group = "com.google.protobuf", module = "protobuf-java")
resolutionStrategy {
dependencySubstitution {
substitute(module("com.google.protobuf:protobuf-java")).using(module("com.google.protobuf:protobuf-javalite:4.34.1"))
substitute(module("com.google.protobuf:protobuf-java")).using(module("com.google.protobuf:protobuf-javalite:4.35.1"))
}
force("io.grpc:grpc-stub:1.80.0")
force("io.grpc:grpc-protobuf-lite:1.80.0")
force("io.grpc:grpc-android:1.80.0")
force("io.grpc:grpc-binder:1.80.0")
force("io.grpc:grpc-stub:1.82.2")
force("io.grpc:grpc-protobuf-lite:1.82.2")
force("io.grpc:grpc-android:1.82.2")
force("io.grpc:grpc-binder:1.82.2")
}
}

Expand Down Expand Up @@ -142,6 +142,7 @@ subprojects {
allWarningsAsErrors = true
}
jvmTarget.set(JvmTarget.JVM_17)
languageVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
freeCompilerArgs.addAll(
listOf(
// Allow use of @OptIn
Expand Down
2 changes: 0 additions & 2 deletions compose-material/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ android {

packaging { resources { excludes += listOf("/META-INF/AL2.0", "/META-INF/LGPL2.1") } }

sourceSets.getByName("main") { assets.srcDir("src/main/assets") }

testOptions {
unitTests { isIncludeAndroidResources = true }
animationsDisabled = true
Expand Down
Loading
Loading