Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corner radius for Glance app widget background #101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

valentinilk
Copy link

@valentinilk valentinilk commented Sep 20, 2023

The cornerRadius modifiers included in appWidgetBackgroundCornerRadius() and appWidgetInnerCornerRadius() where actually never applied to the widget. The CombinedGlanceModifier created by the cornerRadius functions was only ever created, but was never be made part of the modifier chain.

This can be seen by comparing the Glance widget (bottom) to the legacy one (on top), where the system's radius is applied correctly:

After the fix it will look like this:

Unfortunately the fix reveals a bug in Glance. If you select the widget by using a long press, you can see that the system still thinks that the smaller radius is applied. The small radius is probably the fallback radius of 16 dp.
I'll wait with the bug report until this PR is merged, so I can provide this project as a sample.

@secondsun
Copy link
Contributor

Hi!

Thanks for your PR, apply the following patch to your code to fix the glance corner radius and I will merge.

From 6980289919901279d73148a3981d1a10e926d3d4 Mon Sep 17 00:00:00 2001
From: Summers Pittman <secondsun@gmail.com>
Date: Fri, 8 Dec 2023 10:25:49 -0500
Subject: [PATCH] fixing radius

---
 .../com/example/platform/ui/appwidgets/glance/GlanceKtx.kt     | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/GlanceKtx.kt b/samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/GlanceKtx.kt
index 0d9d461..1762029 100644
--- a/samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/GlanceKtx.kt
+++ b/samples/user-interface/appwidgets/src/main/java/com/example/platform/ui/appwidgets/glance/GlanceKtx.kt
@@ -75,13 +75,12 @@ fun AppWidgetColumn(
 fun appWidgetBackgroundModifier() = GlanceModifier
     .fillMaxSize()
     .padding(16.dp)
-    .appWidgetBackground()
     .background(GlanceTheme.colors.background)
     .appWidgetBackgroundCornerRadius()
 
 fun GlanceModifier.appWidgetBackgroundCornerRadius(): GlanceModifier =
     if (Build.VERSION.SDK_INT >= 31) {
-        cornerRadius(android.R.dimen.system_app_widget_background_radius)
+        this.appWidgetBackground()
     } else {
         cornerRadius(16.dp)
     }
-- 
2.43.0.472.g3155946c3a-goog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants