Fix WebView issues from DevMode in app version 1.0.10 (#73)

* Fix WebView showing error when trying to open the code of a file in Github from DevMode

* Fix single-screen DevContentFragment always showing design pattern page instead of the button which was clicked in DevControlFragment
This commit is contained in:
Bianca Miron 2023-07-12 12:20:43 +03:00 коммит произвёл GitHub
Родитель 2631715a8d
Коммит 778faae6b5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -21,6 +21,7 @@ import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewFeature
import com.microsoft.device.samples.dualscreenexperience.R
import com.microsoft.device.samples.dualscreenexperience.databinding.FragmentDevContentBinding
import com.microsoft.device.samples.dualscreenexperience.presentation.util.LayoutInfoViewModel
import com.microsoft.device.samples.dualscreenexperience.presentation.util.NetworkConnectionLiveData
import com.microsoft.device.samples.dualscreenexperience.presentation.util.RestrictedWebViewClient
import com.microsoft.device.samples.dualscreenexperience.presentation.util.isNightMode
@ -30,6 +31,7 @@ class DevContentFragment : Fragment() {
private var binding: FragmentDevContentBinding? = null
private val viewModel: DevModeViewModel by activityViewModels()
private val layoutInfoViewModel: LayoutInfoViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
@ -79,6 +81,7 @@ class DevContentFragment : Fragment() {
private fun setupWebView() {
binding?.devContentWebView?.apply {
settings.javaScriptEnabled = true
settings.domStorageEnabled = true
setBackgroundColor(Color.TRANSPARENT)
if (context.isNightMode() && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
WebSettingsCompat.setForceDark(settings, WebSettingsCompat.FORCE_DARK_ON)
@ -92,7 +95,9 @@ class DevContentFragment : Fragment() {
)
}
selectFirstPage()
if (layoutInfoViewModel.isDualMode.value == true) {
selectFirstPage()
}
}
private fun selectFirstPage() {