mirror of
https://github.com/amir1376/ab-download-manager.git
synced 2025-02-20 11:43:24 +08:00
add extensions to platform util
This commit is contained in:
parent
62a37606fd
commit
5468ed159d
@ -2,6 +2,7 @@ package ir.amirab.util.platform
|
||||
|
||||
import ir.amirab.util.platform.Platform.Android
|
||||
import ir.amirab.util.platform.Platform.Desktop
|
||||
import kotlin.contracts.contract
|
||||
|
||||
sealed class Platform(val name: String) {
|
||||
data object Android : Platform("Android")
|
||||
@ -67,4 +68,30 @@ private class JvmPlatformFinder : PlatformFInder {
|
||||
sealed interface DesktopPlatform
|
||||
|
||||
|
||||
/**
|
||||
* use this only in desktop environments
|
||||
*/
|
||||
fun PlatformFInder.asDesktop(): Desktop {
|
||||
val platform = getCurrentPlatform()
|
||||
if (platform is Desktop) {
|
||||
return platform
|
||||
} else {
|
||||
error("Current platform is not a desktop platform")
|
||||
}
|
||||
}
|
||||
|
||||
fun PlatformFInder.isWindows(): Boolean {
|
||||
return getCurrentPlatform() == Desktop.Windows
|
||||
}
|
||||
|
||||
fun PlatformFInder.isMac(): Boolean {
|
||||
return getCurrentPlatform() == Desktop.MacOS
|
||||
}
|
||||
|
||||
fun PlatformFInder.isLinux(): Boolean {
|
||||
return getCurrentPlatform() == Desktop.Linux
|
||||
}
|
||||
|
||||
fun PlatformFInder.isAndroid(): Boolean {
|
||||
return getCurrentPlatform() == Android
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import com.abdownloadmanager.integration.Integration
|
||||
import com.abdownloadmanager.shared.utils.DownloadSystem
|
||||
import com.abdownloadmanager.shared.utils.appinfo.PreviousVersion
|
||||
import ir.amirab.util.platform.Platform
|
||||
import ir.amirab.util.platform.isWindows
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okio.Path.Companion.toOkioPath
|
||||
import org.koin.core.component.KoinComponent
|
||||
@ -176,7 +177,7 @@ private fun defaultApp(
|
||||
System.getProperty("skiko.renderApi") != null
|
||||
|
||||
if (!customRenderApiRequested) {
|
||||
if (Platform.getCurrentPlatform() == Platform.Desktop.Windows) {
|
||||
if (Platform.isWindows()) {
|
||||
// At the moment default render api have some problems on windows!
|
||||
// - when I resize a window, the contents of the window will be stretched
|
||||
// - sometimes when I close a window, the window flashes on exiting
|
||||
|
Loading…
x
Reference in New Issue
Block a user