Update support lib to 28.0.0-alpha3
This commit is contained in:
@@ -13,6 +13,7 @@ import android.preference.PreferenceManager
|
||||
import android.support.annotation.StringRes
|
||||
import android.widget.Toast
|
||||
import be.mygod.vpnhotspot.util.Event0
|
||||
import be.mygod.vpnhotspot.util.systemService
|
||||
|
||||
class App : Application() {
|
||||
companion object {
|
||||
@@ -43,8 +44,8 @@ class App : Application() {
|
||||
lateinit var deviceContext: Context
|
||||
val handler = Handler()
|
||||
val pref: SharedPreferences by lazy { PreferenceManager.getDefaultSharedPreferences(deviceContext) }
|
||||
val connectivity by lazy { getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager }
|
||||
val wifi by lazy { app.getSystemService(Context.WIFI_SERVICE) as WifiManager }
|
||||
val connectivity by lazy { systemService<ConnectivityManager>() }
|
||||
val wifi by lazy { systemService<WifiManager>() }
|
||||
|
||||
val operatingChannel: Int get() {
|
||||
val result = pref.getString(KEY_OPERATING_CHANNEL, null)?.toIntOrNull() ?: 0
|
||||
|
||||
@@ -131,7 +131,7 @@ class RepeaterService : Service(), WifiP2pManager.ChannelListener, SharedPrefere
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
try {
|
||||
p2pManager = getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager
|
||||
p2pManager = systemService()
|
||||
onChannelDisconnected()
|
||||
app.pref.registerOnSharedPreferenceChangeListener(this)
|
||||
} catch (exc: TypeCastException) {
|
||||
|
||||
@@ -8,13 +8,14 @@ import android.os.Build
|
||||
import android.support.v4.app.NotificationCompat
|
||||
import android.support.v4.content.ContextCompat
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.util.systemService
|
||||
|
||||
object ServiceNotification {
|
||||
private const val CHANNEL = "tethering"
|
||||
private const val CHANNEL_ID = 1
|
||||
|
||||
private val deviceCountsMap = HashMap<Service, Map<String, Int>>()
|
||||
private val manager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
private val manager = app.systemService<NotificationManager>()
|
||||
|
||||
private fun buildNotification(context: Context): Notification {
|
||||
val builder = NotificationCompat.Builder(context, CHANNEL)
|
||||
|
||||
@@ -18,14 +18,14 @@ import be.mygod.vpnhotspot.preference.SharedPreferenceDataStore
|
||||
import be.mygod.vpnhotspot.util.loggerSuStream
|
||||
import be.mygod.vpnhotspot.util.put
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers
|
||||
import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompat
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.io.PrintWriter
|
||||
import java.net.NetworkInterface
|
||||
import java.net.SocketException
|
||||
|
||||
class SettingsPreferenceFragment : PreferenceFragmentCompatDividers() {
|
||||
class SettingsPreferenceFragment : PreferenceFragmentCompat() {
|
||||
private val customTabsIntent by lazy {
|
||||
CustomTabsIntent.Builder()
|
||||
.setToolbarColor(ContextCompat.getColor(requireContext(), R.color.colorPrimary))
|
||||
|
||||
@@ -20,6 +20,7 @@ import be.mygod.vpnhotspot.databinding.ListitemInterfaceBinding
|
||||
import be.mygod.vpnhotspot.net.TetherType
|
||||
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
|
||||
import be.mygod.vpnhotspot.util.formatAddresses
|
||||
import be.mygod.vpnhotspot.util.systemService
|
||||
import com.crashlytics.android.Crashlytics
|
||||
import java.net.NetworkInterface
|
||||
|
||||
@@ -51,7 +52,7 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager()
|
||||
if (if (Build.VERSION.SDK_INT < 28) @Suppress("DEPRECATION") {
|
||||
Settings.Secure.getInt(view.context.contentResolver, Settings.Secure.LOCATION_MODE,
|
||||
Settings.Secure.LOCATION_MODE_OFF) == Settings.Secure.LOCATION_MODE_OFF
|
||||
} else !context.getSystemService(LocationManager::class.java).isLocationEnabled) {
|
||||
} else !context.systemService<LocationManager>().isLocationEnabled) {
|
||||
Toast.makeText(view.context, R.string.tethering_temp_hotspot_location, Toast.LENGTH_LONG).show()
|
||||
try {
|
||||
view.context.startActivity(Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS))
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.*
|
||||
import android.databinding.BindingAdapter
|
||||
import android.os.Bundle
|
||||
import android.support.annotation.DrawableRes
|
||||
import android.support.v4.content.ContextCompat
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
@@ -29,6 +30,8 @@ fun intentFilter(vararg actions: String): IntentFilter {
|
||||
return result
|
||||
}
|
||||
|
||||
inline fun <reified T> Context.systemService() = ContextCompat.getSystemService(this, T::class.java)!!
|
||||
|
||||
fun Bundle.put(key: String, map: Array<String>): Bundle {
|
||||
putStringArray(key, map)
|
||||
return this
|
||||
|
||||
Reference in New Issue
Block a user