Android Q beta 4 support

This commit is contained in:
Mygod
2019-06-10 21:34:37 +08:00
parent 98246ec6d8
commit 0cb28477e4
9 changed files with 23 additions and 31 deletions

View File

@@ -14,7 +14,6 @@ import android.view.View
import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.core.net.toUri
import androidx.core.os.BuildCompat
import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
import be.mygod.vpnhotspot.App.Companion.app
@@ -95,12 +94,12 @@ fun NetworkInterface.formatAddresses(macOnly: Boolean = false) = SpannableString
}
}.trimEnd()
private val parseNumericAddress by lazy {
private val parseNumericAddress by lazy @SuppressLint("SoonBlockedPrivateApi") {
InetAddress::class.java.getDeclaredMethod("parseNumericAddress", String::class.java).apply {
isAccessible = true
}
}
fun parseNumericAddress(address: String) = if (BuildCompat.isAtLeastQ())
fun parseNumericAddress(address: String) = if (Build.VERSION.SDK_INT >= 29)
InetAddresses.parseNumericAddress(address) else parseNumericAddress.invoke(null, address) as InetAddress
fun Context.launchUrl(url: String) {