Skip to content
Snippets Groups Projects
Commit 4074ef1e authored by Diego Fernando Nieto's avatar Diego Fernando Nieto Committed by Jean-Baptiste Kempf
Browse files

License: Open external links in browser app

parent c289ef58
No related branches found
No related tags found
No related merge requests found
package org.videolan.television.ui
import android.annotation.SuppressLint
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.util.Base64
import android.view.View
......@@ -34,6 +36,16 @@ class LicenceActivity : FragmentActivity() {
super.onPageFinished(view, url)
}
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if (url.contains("file://")) {
view.loadUrl(url)
} else {
val i = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(i)
}
return true
}
}
setContentView(webView)
(webView.layoutParams as? FrameLayout.LayoutParams)?.let {
......@@ -57,6 +69,8 @@ class LicenceActivity : FragmentActivity() {
"style.innerHTML = window.atob('" + encoded + "');" +
"parent.appendChild(style);" +
"})()")
webView.settings.javaScriptEnabled = false
} catch (e: Exception) {
e.printStackTrace()
}
......@@ -73,6 +87,8 @@ class LicenceActivity : FragmentActivity() {
"link.setAttribute('href', newLink);" +
"link.innerText = newLink;" +
"})()")
webView.settings.javaScriptEnabled = false
} catch (e: Exception) {
e.printStackTrace()
}
......
......@@ -21,7 +21,9 @@
package org.videolan.vlc.gui
import android.annotation.SuppressLint
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.os.Bundle
import android.util.Base64
import android.view.LayoutInflater
......@@ -45,6 +47,7 @@ import org.videolan.vlc.R
import org.videolan.vlc.gui.audio.AudioPagerAdapter
import org.videolan.vlc.gui.helpers.UiTools
private const val TAG = "VLC/AboutFragment"
private const val MODE_TOTAL = 2 // Number of audio browser modes
......@@ -100,6 +103,16 @@ class AboutFragment : Fragment() {
}
super.onPageFinished(view, url)
}
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
if (url.contains("file://")) {
view.loadUrl(url)
} else {
val i = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(i)
}
return true
}
}
}
}
......@@ -121,6 +134,8 @@ class AboutFragment : Fragment() {
"style.innerHTML = window.atob('" + encoded + "');" +
"parent.appendChild(style);" +
"})()")
webView.settings.javaScriptEnabled = false
} catch (e: Exception) {
e.printStackTrace()
}
......@@ -137,6 +152,8 @@ class AboutFragment : Fragment() {
"link.setAttribute('href', newLink);" +
"link.innerText = newLink;" +
"})()")
webView.settings.javaScriptEnabled = false
} catch (e: Exception) {
e.printStackTrace()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment