Skip to content

Commit d8e7bc1

Browse files
committed
Align the AppWidgets showcase entrypoint to highlight canonical layout samples.
The main "AppWidgets" page now displays link to the canonical layout showcase page and then below it, demonstrates the functionality to pin and show widget information.
1 parent bc9a162 commit d8e7bc1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/AppWidgets.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ fun AppWidgetsList(widgetProviders: List<AppWidgetProviderInfo>) {
8888
}
8989

9090
item {
91-
CanonicalLayoutPinActivityCard()
91+
CanonicalLayoutsInfoCard()
9292
}
9393

9494
// If the launcher does not support pinning request show a banner
@@ -112,7 +112,7 @@ fun AppWidgetsList(widgetProviders: List<AppWidgetProviderInfo>) {
112112
}
113113

114114
@Composable
115-
private fun CanonicalLayoutPinActivityCard() {
115+
private fun CanonicalLayoutsInfoCard() {
116116
val context = LocalContext.current
117117
Card(
118118
modifier = Modifier
@@ -122,12 +122,12 @@ private fun CanonicalLayoutPinActivityCard() {
122122
val preview = painterResource(id = R.drawable.cl_activity_row_hero_image)
123123
Column(modifier = Modifier.padding(16.dp)) {
124124
Text(
125-
text = "☆ Canonical widget layouts",
125+
text = stringResource(R.string.canonical_layouts_info_card_title),
126126
style = MaterialTheme.typography.titleMedium,
127127
fontWeight = FontWeight.Bold
128128
)
129129
Text(
130-
text = "Explore and pin the recommended, intentionally designed widget samples",
130+
text = stringResource(R.string.canonical_layouts_info_card_description),
131131
style = MaterialTheme.typography.bodyMedium,
132132
maxLines = 3,
133133
)
@@ -198,7 +198,7 @@ private fun WidgetInfoCard(providerInfo: AppWidgetProviderInfo) {
198198
val context = LocalContext.current
199199
val label = providerInfo.loadLabel(context.packageManager)
200200
val description = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
201-
(providerInfo.loadDescription(context) ?: "").toString();
201+
(providerInfo.loadDescription(context) ?: "").toString()
202202
} else {
203203
"Description not available"
204204
}

samples/user-interface/appwidgets/src/main/res/values/strings.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
<string name="placeholder_app_widget_pin">Pin an App Widget:</string>
1919
<string name="placeholder_app_widget_pin_unavailable">Pinning is not supported in the default launcher</string>
2020
<string name="placeholder_pin_app_widget">Sample to demonstrate how to get the app\'s appwidgets info and request the user to pin them in the launcher.</string>
21-
<string name="placeholder_tap_to_add_to_home">Tap \"Add to home\" button on any of the items in the canonical widget layouts demo page to pin:</string>
21+
<string name="placeholder_tap_to_add_to_home">Tap \"Add to home\" button on any of the items in the canonical widget layouts demo page:</string>
2222
<string name="placeholder_tap_to_pin">Or tap on any of the items below to request the launcher to pin them:</string>
23+
<string name="canonical_layouts_info_card_title">☆ Canonical widget layouts</string>
24+
<string name="canonical_layouts_info_card_description">Explore and pin the recommended, intentionally designed widget samples</string>
2325
<string name="remote_views_weather">RemoteViews Weather</string>
2426
<string name="glance_weather">Glance Weather</string>
2527
<string name="app_widget_weather_description">Widget for weather forecast</string>

0 commit comments

Comments
 (0)