common: change UrlLauncher to be backed by UriHandler

This commit is contained in:
Harsh Shandilya 2021-10-28 21:59:02 +05:30
parent d285afed0b
commit 67893552e7
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80
5 changed files with 13 additions and 16 deletions

View file

@ -1,14 +1,15 @@
package dev.msfjarvis.claw.common.urllauncher
import androidx.compose.ui.platform.UriHandler
import java.awt.Desktop
import java.net.URI
actual class UrlLauncher {
actual fun launch(url: String) {
class UrlLauncher : UriHandler {
override fun openUri(uri: String) {
if (Desktop.isDesktopSupported()) {
val desktop = Desktop.getDesktop()
if (desktop.isSupported(Desktop.Action.BROWSE)) {
desktop.browse(URI(url))
desktop.browse(URI(uri))
}
}
}