Skip to content

Commit

Permalink
Align the AppWidgets showcase entrypoint to highlight canonical layou…
Browse files Browse the repository at this point in the history
…t 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.
  • Loading branch information
shamalip committed Jan 18, 2025
1 parent bc9a162 commit d8e7bc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fun AppWidgetsList(widgetProviders: List<AppWidgetProviderInfo>) {
}

item {
CanonicalLayoutPinActivityCard()
CanonicalLayoutsInfoCard()
}

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

@Composable
private fun CanonicalLayoutPinActivityCard() {
private fun CanonicalLayoutsInfoCard() {
val context = LocalContext.current
Card(
modifier = Modifier
Expand All @@ -122,12 +122,12 @@ private fun CanonicalLayoutPinActivityCard() {
val preview = painterResource(id = R.drawable.cl_activity_row_hero_image)
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "☆ Canonical widget layouts",
text = stringResource(R.string.canonical_layouts_info_card_title),
style = MaterialTheme.typography.titleMedium,
fontWeight = FontWeight.Bold
)
Text(
text = "Explore and pin the recommended, intentionally designed widget samples",
text = stringResource(R.string.canonical_layouts_info_card_description),
style = MaterialTheme.typography.bodyMedium,
maxLines = 3,
)
Expand Down Expand Up @@ -198,7 +198,7 @@ private fun WidgetInfoCard(providerInfo: AppWidgetProviderInfo) {
val context = LocalContext.current
val label = providerInfo.loadLabel(context.packageManager)
val description = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
(providerInfo.loadDescription(context) ?: "").toString();
(providerInfo.loadDescription(context) ?: "").toString()
} else {
"Description not available"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
<string name="placeholder_app_widget_pin">Pin an App Widget:</string>
<string name="placeholder_app_widget_pin_unavailable">Pinning is not supported in the default launcher</string>
<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>
<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>
<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>
<string name="placeholder_tap_to_pin">Or tap on any of the items below to request the launcher to pin them:</string>
<string name="canonical_layouts_info_card_title">☆ Canonical widget layouts</string>
<string name="canonical_layouts_info_card_description">Explore and pin the recommended, intentionally designed widget samples</string>
<string name="remote_views_weather">RemoteViews Weather</string>
<string name="glance_weather">Glance Weather</string>
<string name="app_widget_weather_description">Widget for weather forecast</string>
Expand Down

0 comments on commit d8e7bc1

Please sign in to comment.