From 11d3b576ba5b775870e052d3613d958ac8e904c8 Mon Sep 17 00:00:00 2001 From: Cloudburst <18114966+C10udburst@users.noreply.github.com> Date: Sat, 10 Sep 2022 19:33:30 +0200 Subject: [PATCH] add RepoApi.installRepo for the website --- .../com/lagradost/cloudstream3/ui/WebviewFragment.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt index d773b3a2..cb4bbf37 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt @@ -4,10 +4,12 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.webkit.JavascriptInterface import android.webkit.WebResourceRequest import android.webkit.WebView import android.webkit.WebViewClient import androidx.fragment.app.Fragment +import androidx.fragment.app.FragmentActivity import androidx.navigation.fragment.findNavController import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.network.WebViewResolver @@ -46,6 +48,7 @@ class WebviewFragment : Fragment() { return super.shouldOverrideUrlLoading(view, request) } } + web_view.addJavascriptInterface(RepoApi(activity), "RepoApi") web_view.settings.javaScriptEnabled = true web_view.settings.domStorageEnabled = true @@ -69,4 +72,11 @@ class WebviewFragment : Fragment() { putString(WEBVIEW_URL, webViewUrl) } } + + private class RepoApi(val activity: FragmentActivity?) { + @JavascriptInterface + fun installRepo(repoUrl: String) { + activity?.loadRepository(repoUrl) + } + } } \ No newline at end of file