Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.nfc.NfcAdapter
import android.os.Build
import android.os.PowerManager
import android.telephony.TelephonyManager
import android.webkit.WebView
import androidx.core.content.ContextCompat
import coil3.ImageLoader
import coil3.PlatformContext
Expand Down Expand Up @@ -99,6 +100,7 @@ open class HomeAssistantApplication :
registerActivityLifecycleCallbacks(LifecycleHandler)

ioScope.launch {
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG || prefsRepository.isWebViewDebugEnabled())
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 may want to consider moving this down in this block so if it crashes we actually have crash reporting enabled

initCrashReporting(
applicationContext,
prefsRepository.isCrashReporting(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package io.homeassistant.companion.android.settings.developer

import android.content.Context
import android.webkit.WebStorage
import android.webkit.WebView
import androidx.activity.result.ActivityResult
import androidx.preference.PreferenceDataStore
import androidx.webkit.WebStorageCompat
import androidx.webkit.WebViewFeature
import io.homeassistant.companion.android.BuildConfig
import io.homeassistant.companion.android.common.R as commonR
import io.homeassistant.companion.android.common.data.prefs.PrefsRepository
import io.homeassistant.companion.android.common.data.servers.ServerManager
Expand Down Expand Up @@ -51,7 +53,10 @@ class DeveloperSettingsPresenterImpl @Inject constructor(
override fun putBoolean(key: String?, value: Boolean) {
mainScope.launch {
when (key) {
"webview_debug" -> prefsRepository.setWebViewDebugEnabled(value)
"webview_debug" -> {
prefsRepository.setWebViewDebugEnabled(value)
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG || value)
}
else -> throw IllegalArgumentException("No boolean found by this key: $key")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ import androidx.webkit.WebViewCompat
import androidx.webkit.WebViewFeature
import dagger.hilt.android.AndroidEntryPoint
import io.homeassistant.companion.android.BaseActivity
import io.homeassistant.companion.android.BuildConfig
import io.homeassistant.companion.android.R
import io.homeassistant.companion.android.assist.AssistActivity
import io.homeassistant.companion.android.authenticator.Authenticator
Expand Down Expand Up @@ -1355,8 +1354,6 @@ class WebViewActivity :
SensorWorker.start(this@WebViewActivity)
WebsocketManager.start(this@WebViewActivity)

WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG || presenter.isWebViewDebugEnabled())

requestedOrientation = when (presenter.getScreenOrientation()) {
getString(
R.string.screen_orientation_option_array_value_portrait,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ interface WebViewPresenter {

suspend fun getPageZoomLevel(): Int
suspend fun isPinchToZoomEnabled(): Boolean
suspend fun isWebViewDebugEnabled(): Boolean

suspend fun isAppLocked(): Boolean
suspend fun setAppActive(active: Boolean)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,6 @@ class WebViewPresenterImpl @Inject constructor(
return prefsRepository.isPinchToZoomEnabled()
}

override suspend fun isWebViewDebugEnabled(): Boolean {
return prefsRepository.isWebViewDebugEnabled()
}

override suspend fun isAppLocked(): Boolean = if (serverManager.isRegistered()) {
try {
serverManager.integrationRepository(serverId).isAppLocked()
Expand Down
Loading