Skip to content

Commit 5172249

Browse files
authored
Merge branch 'main' into clickable
2 parents 93fe952 + d1030b8 commit 5172249

File tree

38 files changed

+628
-170
lines changed

38 files changed

+628
-170
lines changed

ai/sample/core/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protobuf {
8181
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
8282
}
8383
create("grpc") {
84-
artifact = "io.grpc:protoc-gen-grpc-java:1.61.0"
84+
artifact = "io.grpc:protoc-gen-grpc-java:1.61.1"
8585
}
8686
create("grpckt") {
8787
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.3.0:jdk8@jar"

auth/sample/shared/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ protobuf {
8181
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
8282
}
8383
create("grpc") {
84-
artifact = "io.grpc:protoc-gen-grpc-java:1.61.0"
84+
artifact = "io.grpc:protoc-gen-grpc-java:1.61.1"
8585
}
8686
create("grpckt") {
8787
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.3.0:jdk8@jar"

compose-material/src/main/java/com/google/android/horologist/compose/material/ResponsiveDialog.kt

+58-12
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,32 @@ import android.R
2020
import androidx.compose.foundation.layout.Arrangement
2121
import androidx.compose.foundation.layout.Arrangement.spacedBy
2222
import androidx.compose.foundation.layout.Box
23+
import androidx.compose.foundation.layout.PaddingValues
2324
import androidx.compose.foundation.layout.Row
2425
import androidx.compose.foundation.layout.Spacer
2526
import androidx.compose.foundation.layout.fillMaxSize
2627
import androidx.compose.foundation.layout.fillMaxWidth
2728
import androidx.compose.foundation.layout.height
2829
import androidx.compose.foundation.layout.padding
30+
import androidx.compose.foundation.layout.size
31+
import androidx.compose.foundation.layout.width
32+
import androidx.compose.foundation.shape.CircleShape
2933
import androidx.compose.material.icons.Icons
3034
import androidx.compose.material.icons.filled.Check
3135
import androidx.compose.material.icons.filled.Close
3236
import androidx.compose.runtime.Composable
3337
import androidx.compose.runtime.CompositionLocalProvider
3438
import androidx.compose.ui.Alignment
3539
import androidx.compose.ui.Modifier
40+
import androidx.compose.ui.graphics.vector.ImageVector
41+
import androidx.compose.ui.platform.LocalConfiguration
3642
import androidx.compose.ui.res.stringResource
43+
import androidx.compose.ui.unit.Dp
3744
import androidx.compose.ui.unit.dp
3845
import androidx.wear.compose.foundation.lazy.ScalingLazyListScope
3946
import androidx.wear.compose.material.ButtonDefaults
47+
import androidx.wear.compose.material.ChipColors
48+
import androidx.wear.compose.material.ChipDefaults
4049
import androidx.wear.compose.material.LocalTextStyle
4150
import androidx.wear.compose.material.MaterialTheme
4251
import com.google.android.horologist.annotations.ExperimentalHorologistApi
@@ -45,6 +54,7 @@ import com.google.android.horologist.compose.layout.ScalingLazyColumnDefaults.re
4554
import com.google.android.horologist.compose.layout.ScalingLazyColumnState
4655
import com.google.android.horologist.compose.layout.ScreenScaffold
4756
import com.google.android.horologist.compose.layout.rememberColumnState
57+
import com.google.android.horologist.images.base.paintable.ImageVectorPaintable
4858

4959
@ExperimentalHorologistApi
5060
@Composable
@@ -115,31 +125,39 @@ public fun ResponsiveDialogContent(
115125
}
116126
if (onOk != null || onCancel != null) {
117127
item {
128+
val width = LocalConfiguration.current.screenWidthDp
129+
// Single buttons, or buttons on smaller screens are not meant to be
130+
// responsive.
131+
val buttonWidth = if (width < 225 || onOk == null || onCancel == null) {
132+
ButtonDefaults.DefaultButtonSize
133+
} else {
134+
// 14.52% margin on the sides, 4.dp between.
135+
((width * (1f - 2 * 0.1452f) - 4) / 2).dp
136+
}
118137
Row(
119138
Modifier
120139
.fillMaxWidth()
121140
.padding(
122141
top = if (content != null || message != null) 12.dp else 0.dp,
123142
),
124-
horizontalArrangement = spacedBy(
125-
4.dp,
126-
Alignment.CenterHorizontally,
127-
),
143+
horizontalArrangement = spacedBy(4.dp, Alignment.CenterHorizontally),
128144
verticalAlignment = Alignment.CenterVertically,
129145
) {
130146
onCancel?.let {
131-
Button(
132-
imageVector = Icons.Default.Close,
133-
contentDescription = cancelButtonContentDescription,
147+
ResponsiveButton(
148+
icon = Icons.Default.Close,
149+
cancelButtonContentDescription,
134150
onClick = it,
135-
colors = ButtonDefaults.secondaryButtonColors(),
151+
buttonWidth,
152+
ChipDefaults.secondaryChipColors(),
136153
)
137154
}
138155
onOk?.let {
139-
Button(
140-
imageVector = Icons.Default.Check,
141-
contentDescription = okButtonContentDescription,
142-
onClick = onOk,
156+
ResponsiveButton(
157+
icon = Icons.Default.Check,
158+
okButtonContentDescription,
159+
onClick = it,
160+
buttonWidth,
143161
)
144162
}
145163
}
@@ -150,6 +168,34 @@ public fun ResponsiveDialogContent(
150168
}
151169
}
152170

171+
@Composable
172+
private fun ResponsiveButton(
173+
icon: ImageVector,
174+
contentDescription: String,
175+
onClick: () -> Unit,
176+
buttonWidth: Dp,
177+
colors: ChipColors = ChipDefaults.primaryChipColors(),
178+
) {
179+
androidx.wear.compose.material.Chip(
180+
label = {
181+
Box(Modifier.fillMaxWidth()) {
182+
Icon(
183+
paintable = ImageVectorPaintable(icon),
184+
contentDescription = contentDescription,
185+
modifier = Modifier
186+
.size(ButtonDefaults.DefaultIconSize)
187+
.align(Alignment.Center),
188+
)
189+
}
190+
},
191+
contentPadding = PaddingValues(0.dp),
192+
shape = CircleShape,
193+
onClick = onClick,
194+
modifier = Modifier.width(buttonWidth),
195+
colors = colors,
196+
)
197+
}
198+
153199
internal const val globalHorizontalPadding = 5.2f
154200
internal const val messageExtraHorizontalPadding = 4.16f
155201
internal const val titleExtraHorizontalPadding = 8.84f

datalayer/grpc/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ protobuf {
9696
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0"
9797
}
9898
create("grpc") {
99-
artifact = "io.grpc:protoc-gen-grpc-java:1.61.0"
99+
artifact = "io.grpc:protoc-gen-grpc-java:1.61.1"
100100
}
101101
create("grpckt") {
102102
artifact = "io.grpc:protoc-gen-grpc-kotlin:1.3.0:jdk8@jar"

datalayer/phone-ui/api/current.api

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package com.google.android.horologist.datalayer.phone.ui {
33

44
@com.google.android.horologist.annotations.ExperimentalHorologistApi public final class PhoneUiDataLayerHelper {
55
ctor public PhoneUiDataLayerHelper();
6-
method public android.content.Intent getInstallPromptIntent(android.content.Context context, String appName, String appPackageName, String watchName, String message, @DrawableRes int image);
7-
method public void showInstallAppPrompt(android.app.Activity activity, String appName, String appPackageName, String watchName, String message, @DrawableRes int image, optional int requestCode);
6+
method public android.content.Intent getInstallPromptIntent(android.content.Context context, String appPackageName, @DrawableRes int image, String topMessage, String bottomMessage);
7+
method public void showInstallAppPrompt(android.app.Activity activity, String appPackageName, @DrawableRes int image, String topMessage, String bottomMessage, optional int requestCode);
88
}
99

1010
}
@@ -20,7 +20,7 @@ package com.google.android.horologist.datalayer.phone.ui.play {
2020
package com.google.android.horologist.datalayer.phone.ui.prompt.installapp {
2121

2222
public final class InstallAppBottomSheetKt {
23-
method @androidx.compose.runtime.Composable public static void InstallAppBottomSheet(String message, String appName, String watchName, kotlin.jvm.functions.Function0<kotlin.Unit>? icon, kotlin.jvm.functions.Function0<kotlin.Unit> onDismissRequest, kotlin.jvm.functions.Function0<kotlin.Unit> onConfirmation, optional androidx.compose.material3.SheetState sheetState);
23+
method @androidx.compose.runtime.Composable public static void InstallAppBottomSheet(kotlin.jvm.functions.Function0<kotlin.Unit>? image, String topMessage, String bottomMessage, kotlin.jvm.functions.Function0<kotlin.Unit> onDismissRequest, kotlin.jvm.functions.Function0<kotlin.Unit> onConfirmation, optional androidx.compose.ui.Modifier modifier, optional androidx.compose.material3.SheetState sheetState);
2424
}
2525

2626
}

datalayer/phone-ui/src/main/java/com/google/android/horologist/datalayer/phone/ui/PhoneUiDataLayerHelper.kt

+8-12
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,18 @@ public class PhoneUiDataLayerHelper {
4242
*/
4343
public fun showInstallAppPrompt(
4444
activity: Activity,
45-
appName: String,
4645
appPackageName: String,
47-
watchName: String,
48-
message: String,
4946
@DrawableRes image: Int,
47+
topMessage: String,
48+
bottomMessage: String,
5049
requestCode: Int = NO_RESULT_REQUESTED_REQUEST_CODE,
5150
) {
5251
val intent = getInstallPromptIntent(
5352
context = activity,
54-
appName = appName,
5553
appPackageName = appPackageName,
56-
watchName = watchName,
57-
message = message,
5854
image = image,
55+
topMessage = topMessage,
56+
bottomMessage = bottomMessage,
5957
)
6058
activity.startActivityForResult(
6159
intent,
@@ -97,17 +95,15 @@ public class PhoneUiDataLayerHelper {
9795
*/
9896
public fun getInstallPromptIntent(
9997
context: Context,
100-
appName: String,
10198
appPackageName: String,
102-
watchName: String,
103-
message: String,
10499
@DrawableRes image: Int,
100+
topMessage: String,
101+
bottomMessage: String,
105102
): Intent = InstallAppBottomSheetActivity.getIntent(
106103
context = context,
107-
appName = appName,
108104
appPackageName = appPackageName,
109-
watchName = watchName,
110-
message = message,
111105
image = image,
106+
topMessage = topMessage,
107+
bottomMessage = bottomMessage,
112108
)
113109
}

0 commit comments

Comments
 (0)