Update ui About page & fix! openweburl desktop
This commit is contained in:
parent
ea4975df9b
commit
6b83955e05
2 changed files with 24 additions and 15 deletions
|
|
@ -50,8 +50,8 @@ fun AboutDialog(onDismiss: () -> Unit) {
|
|||
val appVersion = rememberAppVersion()
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val developers = listOf(
|
||||
"RAKOTOARIMALALA Hasinjato Mickaël" to "https://github.com/Hasinjato",
|
||||
"RANDIMBISOA Mahefa" to "https://github.com/DotMG",
|
||||
"RAKOTOARIMALALA Hasinjato M." to "https://github.com/Hasinjato",
|
||||
"RAMANAHADRAY Tsinjo Anjaratahina" to "https://github.com/Tiji-Tahina"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,37 +6,46 @@ import java.net.URI
|
|||
actual fun openWebUrl(url: String) {
|
||||
Thread {
|
||||
try {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(URI(url))
|
||||
return@Thread
|
||||
} catch (e: Exception) {
|
||||
println("AWT Desktop browse a échoué, tentative de fallback : ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val os = System.getProperty("os.name")?.lowercase() ?: ""
|
||||
when {
|
||||
os.contains("win") -> {
|
||||
try {
|
||||
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
|
||||
Desktop.getDesktop().browse(URI(url))
|
||||
} else {
|
||||
ProcessBuilder("rundll32", "url.dll,FileProtocolHandler", url).start()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
ProcessBuilder("cmd.exe", "/c", "start", "", url).start()
|
||||
}
|
||||
}
|
||||
os.contains("mac") -> {
|
||||
ProcessBuilder("open", url).start()
|
||||
}
|
||||
else -> {
|
||||
val candidates = listOf(
|
||||
arrayOf("xdg-open", url),
|
||||
arrayOf("/usr/bin/xdg-open", url),
|
||||
arrayOf("gio", "open", url),
|
||||
arrayOf("/usr/bin/gio", "open", url),
|
||||
arrayOf("/usr/bin/kioclient6", "exec", url),
|
||||
arrayOf("/usr/bin/kioclient5", "exec", url),
|
||||
arrayOf("/usr/bin/x-www-browser", url),
|
||||
arrayOf("/usr/bin/firefox", url)
|
||||
arrayOf("kioclient6", "exec", url),
|
||||
arrayOf("kioclient5", "exec", url),
|
||||
arrayOf("x-www-browser", url),
|
||||
arrayOf("firefox", url)
|
||||
)
|
||||
|
||||
var success = false
|
||||
for (cmd in candidates) {
|
||||
try {
|
||||
val process = ProcessBuilder(*cmd).start()
|
||||
if (process.isAlive || process.waitFor() == 0) {
|
||||
ProcessBuilder(*cmd).start()
|
||||
success = true
|
||||
break
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue