Preliminary support for stacked links

This commit is contained in:
Mygod
2020-09-11 11:05:38 +08:00
parent 8e0eb1c0bc
commit 2225e6c80e
5 changed files with 18 additions and 4 deletions

View File

@@ -4,6 +4,8 @@ import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.*
import android.net.InetAddresses
import android.net.LinkProperties
import android.net.RouteInfo
import android.os.Build
import android.os.Handler
import android.os.RemoteException
@@ -109,6 +111,13 @@ fun parseNumericAddress(address: String) = if (Build.VERSION.SDK_INT >= 29) {
InetAddresses.parseNumericAddress(address)
} else parseNumericAddress(null, address) as InetAddress
private val getAllInterfaceNames by lazy { LinkProperties::class.java.getDeclaredMethod("getAllInterfaceNames") }
@Suppress("UNCHECKED_CAST")
val LinkProperties.allInterfaceNames get() = getAllInterfaceNames.invoke(this) as List<String>
private val getAllRoutes by lazy { LinkProperties::class.java.getDeclaredMethod("getAllRoutes") }
@Suppress("UNCHECKED_CAST")
val LinkProperties.allRoutes get() = getAllRoutes.invoke(this) as List<RouteInfo>
fun Context.launchUrl(url: String) {
if (app.hasTouch) try {
app.customTabsIntent.launchUrl(this, url.toUri())