Skip to content

Use LaunchActivity in HaControlsPanel#6870

Merged
TimoPtr merged 3 commits into
mainfrom
feature/show_in_lock
May 26, 2026
Merged

Use LaunchActivity in HaControlsPanel#6870
TimoPtr merged 3 commits into
mainfrom
feature/show_in_lock

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented May 20, 2026

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 setShowWhenLocked flag. Today it is behind the WIPFeature.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Copilot AI review requested due to automatic review settings May 20, 2026 09:02
@TimoPtr TimoPtr requested a review from jpelgrom May 20, 2026 09:02
@TimoPtr TimoPtr added the WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav. label May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 showWhenLocked parameter to LaunchActivity.newInstance() and apply it during onCreate
  • Update HaControlsPanelActivity to launch LaunchActivity (with deep link + showWhenLocked = true) when WIPFeature.USE_FRONTEND_V2 is enabled
  • Add Robolectric tests covering the new showWhenLocked behavior in LaunchActivity

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

Comment on lines +139 to +143
// 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))
}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpelgrom what do you think?

Copy link
Copy Markdown
Member Author

@TimoPtr TimoPtr May 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied the logic and used an alias and check the component name within the Intent. I hope it's enough.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep it like this for now 👍🏻

Comment thread app/src/main/kotlin/io/homeassistant/companion/android/launch/LaunchActivity.kt Outdated
Copy link
Copy Markdown
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@TimoPtr TimoPtr merged commit 27e2130 into main May 26, 2026
24 checks passed
@TimoPtr TimoPtr deleted the feature/show_in_lock branch May 26, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed WebViewActivity replacement Ongoing work to replace the WebViewActivity in favor of a well tested compose screen using nav.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants