diff --git a/build.gradle b/build.gradle index 59f68bab..707f729c 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/App.kt b/mobile/src/main/java/be/mygod/vpnhotspot/App.kt index 4b3cee5d..526a9a41 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/App.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/App.kt @@ -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() } + val wifi by lazy { systemService() } val operatingChannel: Int get() { val result = pref.getString(KEY_OPERATING_CHANNEL, null)?.toIntOrNull() ?: 0 diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index e555b901..84e464e3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -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) { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt b/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt index 334e4015..45f2383c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/ServiceNotification.kt @@ -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>() - private val manager = app.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + private val manager = app.systemService() private fun buildNotification(context: Context): Notification { val builder = NotificationCompat.Builder(context, CHANNEL) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt index eb76c2e5..42cee995 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt @@ -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)) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt b/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt index 6c19c387..20d670b3 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/manage/LocalOnlyHotspotManager.kt @@ -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().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)) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt index dfef2819..d8226c5b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt @@ -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 Context.systemService() = ContextCompat.getSystemService(this, T::class.java)!! + fun Bundle.put(key: String, map: Array): Bundle { putStringArray(key, map) return this diff --git a/mobile/src/main/res/drawable/ic_action_bug_report.xml b/mobile/src/main/res/drawable/ic_action_bug_report.xml new file mode 100644 index 00000000..4d83902b --- /dev/null +++ b/mobile/src/main/res/drawable/ic_action_bug_report.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_action_dns.xml b/mobile/src/main/res/drawable/ic_action_dns.xml new file mode 100644 index 00000000..1a8528c5 --- /dev/null +++ b/mobile/src/main/res/drawable/ic_action_dns.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_action_pan_tool.xml b/mobile/src/main/res/drawable/ic_action_pan_tool.xml new file mode 100644 index 00000000..872664c0 --- /dev/null +++ b/mobile/src/main/res/drawable/ic_action_pan_tool.xml @@ -0,0 +1,5 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_action_settings_backup_restore.xml b/mobile/src/main/res/drawable/ic_action_settings_backup_restore.xml new file mode 100644 index 00000000..aa424c0d --- /dev/null +++ b/mobile/src/main/res/drawable/ic_action_settings_backup_restore.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_action_settings_ethernet.xml b/mobile/src/main/res/drawable/ic_action_settings_ethernet.xml new file mode 100644 index 00000000..d60cda4f --- /dev/null +++ b/mobile/src/main/res/drawable/ic_action_settings_ethernet.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_image_looks_6.xml b/mobile/src/main/res/drawable/ic_image_looks_6.xml new file mode 100644 index 00000000..6219b6d9 --- /dev/null +++ b/mobile/src/main/res/drawable/ic_image_looks_6.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/drawable/ic_toggle_star.xml b/mobile/src/main/res/drawable/ic_toggle_star.xml new file mode 100644 index 00000000..a87ca098 --- /dev/null +++ b/mobile/src/main/res/drawable/ic_toggle_star.xml @@ -0,0 +1,9 @@ + + + diff --git a/mobile/src/main/res/xml/pref_settings.xml b/mobile/src/main/res/xml/pref_settings.xml index 23f42f70..b89703bf 100644 --- a/mobile/src/main/res/xml/pref_settings.xml +++ b/mobile/src/main/res/xml/pref_settings.xml @@ -4,22 +4,27 @@ android:title="@string/settings_service">