fix: move clickable to content element to fix Glance layout ID collision#20
Merged
Conversation
getNextAlarmClock() returns the next AlarmClockInfo alarm from any app, not just the Clock app. Background system processes can set alarm clock alarms that fire before the user's actual Clock alarm. Check the alarm's showIntent.creatorPackage against PackageManager to verify it belongs to a user-facing app (has a launcher icon); if not, display "No alarm".
Both widgets sharing a Box > Box(clickable) > Content structure caused Glance to assign the same layout resource ID to both widgets, making one display the other's content. Move .clickable() directly onto the content element (Text for WeatherWidget, Row for AlarmWidget) so their composable trees are structurally distinct. Also narrows the tap target to the content only.
Reviewer's GuideMoves Glance widget click handling from a wrapper Box to the actual content elements to avoid layout ID collisions between Weather and Alarm widgets, and tightens Alarm widget alarm-text computation to only show real user-facing alarms from clock apps. Sequence diagram for Glance layout ID assignment for Weather and Alarm widgetssequenceDiagram
participant Launcher
participant AppWidgetManager
participant Glance
participant WeatherWidget
participant AlarmWidget
Launcher->>AppWidgetManager: Request to pin WeatherWidget
AppWidgetManager->>Glance: Create WeatherWidget instance
Glance->>WeatherWidget: WeatherWidgetContent()
WeatherWidget-->>Glance: Box > Text(clickable)
Glance->>Glance: Generate layoutId_Weather based on tree
Launcher->>AppWidgetManager: Request to pin AlarmWidget
AppWidgetManager->>Glance: Create AlarmWidget instance
Glance->>AlarmWidget: AlarmWidgetContent()
AlarmWidget-->>Glance: Box > Row(clickable) > Image + Text
Glance->>Glance: Generate layoutId_Alarm based on tree
Glance->>AppWidgetManager: Provide distinct layouts for both widgets
AppWidgetManager->>Launcher: Render WeatherWidget and AlarmWidget with correct content
Updated class diagram for AlarmWidgetReceiver and widget content composablesclassDiagram
class GlanceAppWidgetReceiver
class AlarmWidgetReceiver {
+onReceive(context: Context, intent: Intent): void
-isUserFacingApp(context: Context, packageName: String): Boolean
}
AlarmWidgetReceiver --|> GlanceAppWidgetReceiver
class AlarmWidgetContent {
+AlarmWidgetContent(tapAction: Action, alarmText: String, fontSize: Int, textColorProvider: ColorProvider): void
}
class WeatherWidgetContent {
+WeatherWidgetContent(tapAction: Action, displayTemp: String, fontSize: Int, textColorProvider: ColorProvider): void
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="app/src/main/java/com/wassupluke/widgets/widget/AlarmWidgetReceiver.kt" line_range="46-44" />
<code_context>
context.getString(R.string.widget_alarm_none)
} else {
- DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(nextAlarm.triggerTime))
+ val creator = nextAlarm.showIntent?.creatorPackage
+ val fromClockApp = creator != null && isUserFacingApp(context, creator)
+ if (fromClockApp) {
+ DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(nextAlarm.triggerTime))
+ } else {
+ context.getString(R.string.widget_alarm_none)
+ }
}
</code_context>
<issue_to_address>
**question:** Filtering to only alarms from launcher-visible apps may hide legitimate alarms from non-launcher apps.
Because `fromClockApp` relies on `isUserFacingApp` (i.e., having a launcher activity), any alarm from a package without a launcher will be treated as “no next alarm”. That affects valid alarms from automation tools, companion apps, or OEM/system components that don’t expose launcher activities. If the intent is to exclude specific system/internal sources (e.g., System UI or framework packages), it would be safer to explicitly whitelist known clock apps or blacklist known internal packages instead of using `CATEGORY_LAUNCHER` as a proxy, to avoid the widget incorrectly showing "none" when an alarm is actually set.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Box(fillMaxSize) > Box(clickable) > Contentstructure, which caused Glance to assign the same layout resource ID to both — making one widget display the other's contentBoxwrapper from both widgets;.clickable()now lives directly on the content element (TextinWeatherWidget,RowinAlarmWidget)Box > TextvsBox > Row > …), preventing the layout ID collisionTest plan
./gradlew :app:compileDebugKotlinpasses cleanlySummary by Sourcery
Prevent content bleed and layout ID collisions between the Weather and Alarm Glance widgets.
Bug Fixes: