Skip to content

Commit

Permalink
Suppress system Matter device discovery bottom sheet (#4062)
Browse files Browse the repository at this point in the history
- Prevents the system's Matter device discovery bottom sheet from showing up while the Home Assistant app is opened.
  • Loading branch information
jpelgrom authored Dec 20, 2023
1 parent 7cc545b commit 1162a82
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ class MatterManagerImpl @Inject constructor(
return config != null && config.components.contains("matter")
}

override fun suppressDiscoveryBottomSheet(context: Context) {
if (!appSupportsCommissioning()) return
Matter.getCommissioningClient(context).suppressHalfSheetNotification()
}

override fun startNewCommissioningFlow(
context: Context,
onSuccess: (IntentSender) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ interface MatterManager {
*/
suspend fun coreSupportsCommissioning(serverId: Int): Boolean

/**
* Prevent the bottom sheet for discovered Matter devices from showing up while the app is open.
*/
fun suppressDiscoveryBottomSheet(context: Context)

/**
* Start a flow to commission a Matter device that is on the same network as this device.
* @param onSuccess Callback that receives an intent to launch the commissioning flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ class WebViewActivity : BaseActivity(), io.homeassistant.companion.android.webvi
}
}

override fun onStart() {
super.onStart()
presenter.onStart(this)
}

override fun onResume() {
super.onResume()
if (currentAutoplay != presenter.isAutoPlayVideoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ interface WebViewPresenter {

fun sessionTimeOut(): Int

fun onStart(context: Context)

fun onFinish()

fun isSsidUsed(): Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ class WebViewPresenterImpl @Inject constructor(
} ?: 0
}

override fun onStart(context: Context) {
matterUseCase.suppressDiscoveryBottomSheet(context)
}

override fun onFinish() {
mainScope.cancel()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class MatterManagerImpl @Inject constructor() : MatterManager {

override suspend fun coreSupportsCommissioning(serverId: Int): Boolean = false

override fun suppressDiscoveryBottomSheet(context: Context) {
// No support, so nothing to suppress
}

override fun startNewCommissioningFlow(
context: Context,
onSuccess: (IntentSender) -> Unit,
Expand Down

0 comments on commit 1162a82

Please sign in to comment.