Use LaunchActivity in HaControlsPanel#6870
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enables LaunchActivity to optionally render over the lock screen (via setShowWhenLocked) so the device controls panel can launch the new Compose-based frontend (FrontendScreen) while the device is locked.
Changes:
- Add an optional
showWhenLockedparameter toLaunchActivity.newInstance()and apply it duringonCreate - Update
HaControlsPanelActivityto launchLaunchActivity(with deep link +showWhenLocked = true) whenWIPFeature.USE_FRONTEND_V2is enabled - Add Robolectric tests covering the new
showWhenLockedbehavior inLaunchActivity
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt | Introduces showWhenLocked intent extra handling for lock-screen display |
| app/src/main/kotlin/io/homeassistant/companion/android/controls/HaControlsPanelActivity.kt | Switches controls panel launch target to LaunchActivity for Frontend v2 and enables lock-screen display |
| app/src/test/kotlin/io/homeassistant/companion/android/launch/LaunchActivityTest.kt | Adds tests validating showWhenLocked behavior |
| // Must run before super.onCreate so the window flag is set before the platform decides | ||
| // whether to draw over the keyguard. Only applied when the caller opts in explicitly. | ||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1 && intent.hasExtra(EXTRA_SHOW_WHEN_LOCKED)) { | ||
| setShowWhenLocked(intent.getBooleanExtra(EXTRA_SHOW_WHEN_LOCKED, false)) | ||
| } |
There was a problem hiding this comment.
I've applied the logic and used an alias and check the component name within the Intent. I hope it's enough.
There was a problem hiding this comment.
You could theoretically limit it even more to when the user's device controls preference is set to dashboard, as that is the only scenario in which we apply this flag. Your current implementation is easier to reuse though, also fine by me and seems good enough.
There was a problem hiding this comment.
Let's keep it like this for now 👍🏻
jpelgrom
left a comment
There was a problem hiding this comment.
Nice implementation and improvement.
I added two comments as replies on the Copilot comments. I guess it boils down to whether we want the extra to be generic, or scoped to the device controls usage, as for whether or not to address them. In my opinion it's fine to merge it as it currently is.
Summary
In order to be able to use the FrontendScreen in the lock screen when using a dashboard has ControlPanel we need the LaunchActivity to set the
setShowWhenLockedflag. Today it is behind the WIPFeature.Checklist