Move the debug flag for WebView into the Application and Settings#6813
Move the debug flag for WebView into the Application and Settings#6813
Conversation
There was a problem hiding this comment.
Pull request overview
This PR centralizes WebView remote debugging enablement by moving the WebView.setWebContentsDebuggingEnabled(...) call out of WebViewActivity and into app-level startup plus the Developer Settings toggle, aiming to apply the setting globally and immediately when changed.
Changes:
- Remove WebView debugging preference plumbing from
WebViewPresenter/WebViewPresenterImpland stop setting it fromWebViewActivity - Apply the saved WebView remote debugging setting during
HomeAssistantApplicationstartup - Apply WebView remote debugging immediately when toggled in Developer Settings
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenterImpl.kt | Removes the presenter method that exposed the WebView debug preference |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewPresenter.kt | Removes isWebViewDebugEnabled() from the presenter interface |
| app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt | Stops enabling WebView debugging from the activity lifecycle |
| app/src/main/kotlin/io/homeassistant/companion/android/settings/developer/DeveloperSettingsPresenterImpl.kt | Enables/disables WebView debugging immediately when the developer preference is toggled |
| app/src/main/kotlin/io/homeassistant/companion/android/HomeAssistantApplication.kt | Attempts to apply the saved WebView debugging setting on app startup |
| @@ -99,6 +100,7 @@ open class HomeAssistantApplication : | |||
| registerActivityLifecycleCallbacks(LifecycleHandler) | |||
|
|
|||
jpelgrom
left a comment
There was a problem hiding this comment.
Verified. I don't see a new race happening here as this should result in it being set earlier in the lifecycle, but good to stay alert to reports of it not working.
| registerActivityLifecycleCallbacks(LifecycleHandler) | ||
|
|
||
| ioScope.launch { | ||
| WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG || prefsRepository.isWebViewDebugEnabled()) |
There was a problem hiding this comment.
You may want to consider moving this down in this block so if it crashes we actually have crash reporting enabled
Summary
Move the set of the debug capability of the WebView at the Application level and also in the settings level. The idea is to enable/disable it globally so that it apply right away when changing and also when the app starts.
There is a risk where maybe the debug flag is set after the webview load since it uses the ioScope in the Application but I'm not sure.