Refine code style

This commit is contained in:
Mygod
2021-05-27 13:33:26 -04:00
parent b6bdf8cfb7
commit 87a1b8b08d
17 changed files with 65 additions and 52 deletions

View File

@@ -1,15 +1,12 @@
package be.mygod.vpnhotspot.util
import android.annotation.SuppressLint
import android.content.Context
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
import android.net.wifi.p2p.WifiP2pManager
import android.util.Log
import androidx.core.content.getSystemService
import timber.log.Timber
@SuppressLint("LogNotTimber")
object Services {
private lateinit var contextInit: () -> Context
val context by lazy { contextInit() }
@@ -22,7 +19,7 @@ object Services {
try {
context.getSystemService<WifiP2pManager>()
} catch (e: RuntimeException) {
if (android.os.Process.myUid() == 0) Log.w("WifiP2pManager", e) else Timber.w(e)
Timber.w(e)
null
}
}

View File

@@ -90,7 +90,6 @@ private val formatSequence = "%([0-9]+\\$|<?)([^a-zA-z%]*)([[a-zA-Z%]&&[^tT]]|[t
*
* @param locale
* the locale to apply; `null` value means no localization.
* @param format the format string (see [java.util.Formatter.format])
* @param args
* the list of arguments passed to the formatter.
* @return the formatted string (with spans).
@@ -160,7 +159,8 @@ fun NetworkInterface.formatAddresses(macOnly: Boolean = false) = SpannableString
}
}.trimEnd()
private val parseNumericAddress by lazy @SuppressLint("SoonBlockedPrivateApi") {
@delegate:SuppressLint("SoonBlockedPrivateApi")
private val parseNumericAddress by lazy {
InetAddress::class.java.getDeclaredMethod("parseNumericAddress", String::class.java).apply {
isAccessible = true
}
@@ -201,8 +201,9 @@ fun Resources.findIdentifier(name: String, defType: String, defPackage: String,
if (alternativePackage != null && it == 0) getIdentifier(name, defType, alternativePackage) else it
}
@delegate:TargetApi(26)
@get:RequiresApi(26)
private val newLookup by lazy @TargetApi(26) {
private val newLookup by lazy {
MethodHandles.Lookup::class.java.getDeclaredConstructor(Class::class.java, Int::class.java).apply {
isAccessible = true
}