Combine event listener interfaces

This commit is contained in:
Johannes Marbach 2022-05-30 20:28:09 +02:00
parent 5b64946dfb
commit 70bb2b7fee
2 changed files with 7 additions and 10 deletions

View File

@ -44,8 +44,7 @@ import im.vector.app.core.platform.OnBackPressed
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.openUrlInExternalBrowser
import im.vector.app.databinding.FragmentRoomWidgetBinding
import im.vector.app.features.webview.WebChromeEventListener
import im.vector.app.features.webview.WebViewEventListener
import im.vector.app.features.webview.WebEventListener
import im.vector.app.features.widgets.webview.WebviewPermissionUtils
import im.vector.app.features.widgets.webview.clearAfterWidget
import im.vector.app.features.widgets.webview.setupForWidget
@ -68,8 +67,7 @@ class WidgetFragment @Inject constructor(
private val permissionUtils: WebviewPermissionUtils
) :
VectorBaseFragment<FragmentRoomWidgetBinding>(),
WebViewEventListener,
WebChromeEventListener,
WebEventListener,
OnBackPressed {
private val fragmentArgs: WidgetArgs by args()
@ -82,7 +80,7 @@ class WidgetFragment @Inject constructor(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setHasOptionsMenu(true)
views.widgetWebView.setupForWidget(this, this)
views.widgetWebView.setupForWidget(this)
if (fragmentArgs.kind.isAdmin()) {
viewModel.getPostAPIMediator().setWebView(views.widgetWebView)
}

View File

@ -25,11 +25,10 @@ import android.webkit.WebView
import im.vector.app.R
import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.webview.VectorWebViewClient
import im.vector.app.features.webview.WebChromeEventListener
import im.vector.app.features.webview.WebViewEventListener
import im.vector.app.features.webview.WebEventListener
@SuppressLint("NewApi")
fun WebView.setupForWidget(webViewEventListener: WebViewEventListener, webChromeEventListener: WebChromeEventListener) {
fun WebView.setupForWidget(eventListener: WebEventListener) {
// xml value seems ignored
setBackgroundColor(ThemeUtils.getColor(context, R.attr.colorSurface))
@ -60,10 +59,10 @@ fun WebView.setupForWidget(webViewEventListener: WebViewEventListener, webChrome
// Permission requests
webChromeClient = object : WebChromeClient() {
override fun onPermissionRequest(request: PermissionRequest) {
webChromeEventListener.onPermissionRequest(request)
eventListener.onPermissionRequest(request)
}
}
webViewClient = VectorWebViewClient(webViewEventListener)
webViewClient = VectorWebViewClient(eventListener)
val cookieManager = CookieManager.getInstance()
cookieManager.setAcceptThirdPartyCookies(this, false)