Update support lib to 28.0.0-alpha3

This commit is contained in:
Mygod
2018-06-10 22:28:09 +08:00
parent 3fbca0abef
commit 814f42311b
15 changed files with 80 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ buildscript {
ext {
androidPluginVersion = '3.1.3'
kotlinVersion = '1.2.41'
supportLibraryVersion = '27.1.1'
supportLibraryVersion = '28.0.0-alpha3'
takisoftFixVersion = '27.1.1.1'
}
repositories {

View File

@@ -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

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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))

View File

@@ -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))

View File

@@ -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

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,8h-2.81c-0.45,-0.78 -1.07,-1.45 -1.82,-1.96L17,4.41 15.59,3l-2.17,2.17C12.96,5.06 12.49,5 12,5c-0.49,0 -0.96,0.06 -1.41,0.17L8.41,3 7,4.41l1.62,1.63C7.88,6.55 7.26,7.22 6.81,8L4,8v2h2.09c-0.05,0.33 -0.09,0.66 -0.09,1v1L4,12v2h2v1c0,0.34 0.04,0.67 0.09,1L4,16v2h2.81c1.04,1.79 2.97,3 5.19,3s4.15,-1.21 5.19,-3L20,18v-2h-2.09c0.05,-0.33 0.09,-0.66 0.09,-1v-1h2v-2h-2v-1c0,-0.34 -0.04,-0.67 -0.09,-1L20,10L20,8zM14,16h-4v-2h4v2zM14,12h-4v-2h4v2z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,13H4c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1v-6c0,-0.55 -0.45,-1 -1,-1zM7,19c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2zM20,3H4c-0.55,0 -1,0.45 -1,1v6c0,0.55 0.45,1 1,1h16c0.55,0 1,-0.45 1,-1V4c0,-0.55 -0.45,-1 -1,-1zM7,9c-1.1,0 -2,-0.9 -2,-2s0.9,-2 2,-2 2,0.9 2,2 -0.9,2 -2,2z"/>
</vector>

View File

@@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M23,5.5V20c0,2.2 -1.8,4 -4,4h-7.3c-1.08,0 -2.1,-0.43 -2.85,-1.19L1,14.83s1.26,-1.23 1.3,-1.25c0.22,-0.19 0.49,-0.29 0.79,-0.29 0.22,0 0.42,0.06 0.6,0.16 0.04,0.01 4.31,2.46 4.31,2.46V4c0,-0.83 0.67,-1.5 1.5,-1.5S11,3.17 11,4v7h1V1.5c0,-0.83 0.67,-1.5 1.5,-1.5S15,0.67 15,1.5V11h1V2.5c0,-0.83 0.67,-1.5 1.5,-1.5s1.5,0.67 1.5,1.5V11h1V5.5c0,-0.83 0.67,-1.5 1.5,-1.5s1.5,0.67 1.5,1.5z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M14,12c0,-1.1 -0.9,-2 -2,-2s-2,0.9 -2,2 0.9,2 2,2 2,-0.9 2,-2zM12,3c-4.97,0 -9,4.03 -9,9L0,12l4,4 4,-4L5,12c0,-3.87 3.13,-7 7,-7s7,3.13 7,7 -3.13,7 -7,7c-1.51,0 -2.91,-0.49 -4.06,-1.3l-1.42,1.44C8.04,20.3 9.94,21 12,21c4.97,0 9,-4.03 9,-9s-4.03,-9 -9,-9z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M7.77,6.76L6.23,5.48 0.82,12l5.41,6.52 1.54,-1.28L3.42,12l4.35,-5.24zM7,13h2v-2L7,11v2zM17,11h-2v2h2v-2zM11,13h2v-2h-2v2zM17.77,5.48l-1.54,1.28L20.58,12l-4.35,5.24 1.54,1.28L23.18,12l-5.41,-6.52z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11,15h2v-2h-2v2zM19,3L5,3c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2L21,5c0,-1.1 -0.9,-2 -2,-2zM15,9h-4v2h2c1.1,0 2,0.89 2,2v2c0,1.11 -0.9,2 -2,2h-2c-1.1,0 -2,-0.89 -2,-2L9,9c0,-1.11 0.9,-2 2,-2h4v2z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,17.27L18.18,21l-1.64,-7.03L22,9.24l-7.19,-0.61L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21z"/>
</vector>

View File

@@ -4,22 +4,27 @@
android:title="@string/settings_service">
<Preference
android:key="service.clean"
android:icon="@drawable/ic_action_settings_backup_restore"
android:title="@string/settings_service_clean"/>
<SwitchPreference
android:key="service.repeater.strict"
android:icon="@drawable/ic_action_pan_tool"
android:title="@string/settings_service_repeater_strict"
android:summary="@string/settings_service_repeater_strict_summary"/>
<SwitchPreference
android:key="service.disableIpv6"
android:icon="@drawable/ic_image_looks_6"
android:title="@string/settings_service_disable_ipv6"
android:summary="@string/settings_service_disable_ipv6_summary"/>
<AutoSummaryEditTextPreference
android:key="service.dns"
android:icon="@drawable/ic_action_dns"
android:title="@string/settings_service_dns"
android:singleLine="true"
android:defaultValue="8.8.8.8"/>
<be.mygod.vpnhotspot.preference.AlwaysAutoCompleteEditTextPreference
android:key="service.upstream"
android:icon="@drawable/ic_action_settings_ethernet"
android:title="@string/settings_service_upstream"
android:summary="@string/settings_service_upstream_auto"
android:hint="@string/settings_service_upstream_auto"
@@ -29,10 +34,12 @@
android:title="@string/settings_misc">
<Preference
android:key="misc.logcat"
android:icon="@drawable/ic_action_bug_report"
android:title="@string/settings_misc_logcat"
android:summary="@string/settings_misc_logcat_summary"/>
<Preference
android:key="misc.source"
android:icon="@drawable/ic_toggle_star"
android:title="@string/settings_misc_source"
android:summary="@string/settings_misc_source_summary"/>
</PreferenceCategory>