This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.bindProcessToNetwork(null) | |
| } else { | |
| ConnectivityManager.setProcessDefaultNetwork(null) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.bindProcessToNetwork(network) | |
| } else { | |
| ConnectivityManager.setProcessDefaultNetwork(network) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val network: Network? = connectivityManager.allNetworks.find { | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
| connectivityManager.getNetworkCapabilities(it) | |
| .hasTransport(NetworkCapabilities.TRANSPORT_WIFI) | |
| } else { | |
| connectivityManager.getNetworkInfo(it).extraInfo == wifiSSID | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun checkLocationSettings(onSuccessCallback: () -> Unit) { | |
| val locationRequest = LocationRequest.create() | |
| locationRequest.priority = LocationRequest.PRIORITY_LOW_POWER | |
| val builder = LocationSettingsRequest.Builder() | |
| builder.addLocationRequest(locationRequest) | |
| val client = LocationServices.getSettingsClient(this) | |
| val task = client.checkLocationSettings(builder.build()) | |
| task.addOnSuccessListener(this) { | |
| onSuccessCallback() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun isWiFiEnabled(): Boolean { | |
| val wifiManager = applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager | |
| return wifiManager.isWifiEnabled | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include(":shared", ":androidApp") | |
| rootProject.name = "xxx" | |
| enableFeaturePreview("GRADLE_METADATA") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Top-level build file where you can add configuration options common to all sub-projects/modules. | |
| buildscript { | |
| repositories { | |
| google() | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath("com.android.tools.build:gradle:3.6.3") | |
| classpath(kotlin("gradle-plugin", "1.3.71")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| plugins { | |
| id("com.android.application") | |
| kotlin("android") | |
| kotlin("android.extensions") | |
| kotlin("kapt") | |
| id("androidx.navigation.safeargs.kotlin") | |
| } | |
| android { | |
| compileSdkVersion(Versions.compile_sdk) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget | |
| plugins { | |
| kotlin("multiplatform") | |
| id("com.android.library") | |
| } | |
| android { | |
| compileSdkVersion(29) | |
| defaultConfig { | |
| minSdkVersion(21) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class WifiConnectionViewModel( | |
| private val context: Context, | |
| wifiScanUseCase: WiFiScanUseCase, | |
| private val wifiConnectUseCase: WiFiConnectDockUseCase, | |
| private val wifiConnectLegacyUseCase: WiFiConnectDockLegacyUseCase, | |
| private val wifiDisconnectUseCase: WiFiDisconnectDockUseCase | |
| ) : ViewModel() { | |
| private val disposables = CompositeDisposable(); |
NewerOlder