Support editing native Wi-Fi AP configurations

Support for repeater channel on Android 5 has been dropped because I am lazy.
This commit is contained in:
Mygod
2019-04-04 16:43:48 +08:00
parent 834498b1ff
commit 1145b0f23b
21 changed files with 488 additions and 295 deletions

View File

@@ -1,7 +1,9 @@
package be.mygod.vpnhotspot.util
import android.annotation.SuppressLint
import android.content.*
import android.os.Build
import android.os.Parcel
import android.text.Spannable
import android.text.SpannableString
import android.text.SpannableStringBuilder
@@ -15,7 +17,6 @@ import androidx.databinding.BindingAdapter
import be.mygod.vpnhotspot.App.Companion.app
import be.mygod.vpnhotspot.room.macToString
import be.mygod.vpnhotspot.widget.SmartSnackbar
import java.lang.RuntimeException
import java.net.InetAddress
import java.net.NetworkInterface
import java.net.SocketException
@@ -32,6 +33,15 @@ fun Long.toPluralInt(): Int {
return (this % 1000000000).toInt() + 1000000000
}
@SuppressLint("Recycle")
fun <T> useParcel(block: (Parcel) -> T) = Parcel.obtain().run {
try {
block(this)
} finally {
recycle()
}
}
fun broadcastReceiver(receiver: (Context, Intent) -> Unit) = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) = receiver(context, intent)
}