From 90c19516456f5e4b534d4e9e728e98bd1f8b829e Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 9 May 2018 15:57:41 -0700 Subject: [PATCH] Move Utils.kt --- .../be/mygod/vpnhotspot/LocalOnlyHotspotService.kt | 3 +++ .../main/java/be/mygod/vpnhotspot/RepeaterFragment.kt | 3 +++ .../main/java/be/mygod/vpnhotspot/RepeaterService.kt | 3 +-- .../be/mygod/vpnhotspot/SettingsPreferenceFragment.kt | 1 + .../main/java/be/mygod/vpnhotspot/TetheringFragment.kt | 3 +++ .../main/java/be/mygod/vpnhotspot/TetheringService.kt | 2 ++ .../java/be/mygod/vpnhotspot/net/IpNeighbourMonitor.kt | 10 ++++++---- .../src/main/java/be/mygod/vpnhotspot/net/Routing.kt | 4 ++-- .../main/java/be/mygod/vpnhotspot/net/VpnMonitor.kt | 2 +- .../vpnhotspot/net/wifi/P2pSupplicantConfiguration.kt | 4 ++-- .../main/java/be/mygod/vpnhotspot/{ => util}/Utils.kt | 4 +++- 11 files changed, 27 insertions(+), 12 deletions(-) rename mobile/src/main/java/be/mygod/vpnhotspot/{ => util}/Utils.kt (97%) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt index 4713c07d..f3a98119 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt @@ -8,6 +8,9 @@ import android.widget.Toast import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.net.IpNeighbourMonitor import be.mygod.vpnhotspot.net.TetheringManager +import be.mygod.vpnhotspot.util.broadcastReceiver +import be.mygod.vpnhotspot.util.debugLog +import be.mygod.vpnhotspot.util.intentFilter @RequiresApi(26) class LocalOnlyHotspotService : IpNeighbourMonitoringService() { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt index b790c474..d6690efc 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterFragment.kt @@ -31,6 +31,9 @@ import be.mygod.vpnhotspot.net.TetherType import be.mygod.vpnhotspot.net.TetheringManager import be.mygod.vpnhotspot.net.wifi.P2pSupplicantConfiguration import be.mygod.vpnhotspot.net.wifi.WifiP2pDialog +import be.mygod.vpnhotspot.util.broadcastReceiver +import be.mygod.vpnhotspot.util.formatAddresses +import be.mygod.vpnhotspot.util.intentFilter import java.net.NetworkInterface import java.net.SocketException import java.util.* diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt index b6a08e67..f9c3be6c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/RepeaterService.kt @@ -21,8 +21,7 @@ import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.netId import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.requestPersistentGroupInfo import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.setWifiP2pChannels import be.mygod.vpnhotspot.net.wifi.WifiP2pManagerHelper.startWps -import be.mygod.vpnhotspot.util.StickyEvent0 -import be.mygod.vpnhotspot.util.StickyEvent1 +import be.mygod.vpnhotspot.util.* import java.lang.reflect.InvocationTargetException import java.net.InetAddress diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt index 1f6e9189..5bcb3bdc 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/SettingsPreferenceFragment.kt @@ -11,6 +11,7 @@ import android.support.v4.content.FileProvider import android.widget.Toast import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.net.Routing +import be.mygod.vpnhotspot.util.loggerSuStream import com.takisoft.fix.support.v7.preference.PreferenceFragmentCompatDividers import java.io.File import java.io.IOException diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringFragment.kt index 7b49c03a..430cf3e8 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringFragment.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringFragment.kt @@ -34,6 +34,9 @@ import be.mygod.vpnhotspot.databinding.ListitemManageTetherBinding import be.mygod.vpnhotspot.net.TetherType import be.mygod.vpnhotspot.net.TetheringManager import be.mygod.vpnhotspot.net.wifi.WifiApManager +import be.mygod.vpnhotspot.util.broadcastReceiver +import be.mygod.vpnhotspot.util.formatAddresses +import be.mygod.vpnhotspot.util.intentFilter import java.lang.reflect.InvocationTargetException import java.net.NetworkInterface import java.net.SocketException diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt index 3db34e65..a0ec420b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/TetheringService.kt @@ -8,6 +8,8 @@ import be.mygod.vpnhotspot.net.IpNeighbourMonitor import be.mygod.vpnhotspot.net.Routing import be.mygod.vpnhotspot.net.TetheringManager import be.mygod.vpnhotspot.net.VpnMonitor +import be.mygod.vpnhotspot.util.broadcastReceiver +import be.mygod.vpnhotspot.util.intentFilter import java.net.InetAddress import java.net.SocketException diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbourMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbourMonitor.kt index 1ef0ccab..1a52170c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbourMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/IpNeighbourMonitor.kt @@ -4,8 +4,8 @@ import android.os.Handler import android.util.Log import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.R -import be.mygod.vpnhotspot.debugLog -import be.mygod.vpnhotspot.thread +import be.mygod.vpnhotspot.util.debugLog +import be.mygod.vpnhotspot.util.thread import java.io.InterruptedIOException import java.util.concurrent.Executors import java.util.concurrent.ScheduledExecutorService @@ -57,7 +57,8 @@ class IpNeighbourMonitor private constructor() : Runnable { thread("$TAG-error") { try { monitor.errorStream.bufferedReader().forEachLine { Log.e(TAG, it) } - } catch (ignore: InterruptedIOException) { } + } catch (ignore: InterruptedIOException) { + } } try { monitor.inputStream.bufferedReader().forEachLine { @@ -76,7 +77,8 @@ class IpNeighbourMonitor private constructor() : Runnable { val pool = Executors.newScheduledThreadPool(1) pool.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS) this.pool = pool - } catch (ignore: InterruptedIOException) { } + } catch (ignore: InterruptedIOException) { + } } } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index daa60ef2..8173540b 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -3,8 +3,8 @@ package be.mygod.vpnhotspot.net import android.os.Build import be.mygod.vpnhotspot.App.Companion.app import be.mygod.vpnhotspot.R -import be.mygod.vpnhotspot.debugLog -import be.mygod.vpnhotspot.noisySu +import be.mygod.vpnhotspot.util.debugLog +import be.mygod.vpnhotspot.util.noisySu import java.net.Inet4Address import java.net.InetAddress import java.net.NetworkInterface diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/VpnMonitor.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/VpnMonitor.kt index f482cac3..9323a68c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/VpnMonitor.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/VpnMonitor.kt @@ -5,7 +5,7 @@ import android.net.Network import android.net.NetworkCapabilities import android.net.NetworkRequest import be.mygod.vpnhotspot.App.Companion.app -import be.mygod.vpnhotspot.debugLog +import be.mygod.vpnhotspot.util.debugLog import java.net.InetAddress object VpnMonitor : ConnectivityManager.NetworkCallback() { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/P2pSupplicantConfiguration.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/P2pSupplicantConfiguration.kt index 0779b098..b253b89c 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/P2pSupplicantConfiguration.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/wifi/P2pSupplicantConfiguration.kt @@ -5,8 +5,8 @@ import android.os.Build import android.util.Log import android.widget.Toast import be.mygod.vpnhotspot.App.Companion.app -import be.mygod.vpnhotspot.loggerSu -import be.mygod.vpnhotspot.noisySu +import be.mygod.vpnhotspot.util.loggerSu +import be.mygod.vpnhotspot.util.noisySu import java.io.File class P2pSupplicantConfiguration { diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/Utils.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt similarity index 97% rename from mobile/src/main/java/be/mygod/vpnhotspot/Utils.kt rename to mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt index fa9cd819..9dd1db86 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/Utils.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt @@ -1,4 +1,4 @@ -package be.mygod.vpnhotspot +package be.mygod.vpnhotspot.util import android.content.BroadcastReceiver import android.content.Context @@ -9,6 +9,8 @@ import android.support.annotation.DrawableRes import android.util.Log import android.widget.ImageView import be.mygod.vpnhotspot.App.Companion.app +import be.mygod.vpnhotspot.BuildConfig +import be.mygod.vpnhotspot.R import java.io.IOException import java.io.InputStream import java.net.NetworkInterface