Refinements
This commit is contained in:
@@ -50,6 +50,7 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
|
||||
ContextCompat.startForegroundService(context, Intent(context, RepeaterService::class.java))
|
||||
}
|
||||
RepeaterService.Status.ACTIVE -> if (!value) binder.shutdown()
|
||||
else -> { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,13 +81,13 @@ class RepeaterFragment : Fragment(), ServiceConnection, Toolbar.OnMenuItemClickL
|
||||
|
||||
val icon get() = TetherType.ofInterface(iface, p2pInterface).icon
|
||||
val title get() = listOf(ip, mac).filter { !it.isNullOrEmpty() }.joinToString()
|
||||
val description get() = when (neighbour?.state) {
|
||||
IpNeighbour.State.INCOMPLETE, null -> "Connecting to $iface"
|
||||
IpNeighbour.State.VALID -> "Connected to $iface"
|
||||
IpNeighbour.State.VALID_DELAY -> "Connected to $iface (losing)"
|
||||
IpNeighbour.State.FAILED -> "Failed to connect to $iface"
|
||||
val description get() = getString(when (neighbour?.state) {
|
||||
IpNeighbour.State.INCOMPLETE, null -> R.string.connected_state_incomplete
|
||||
IpNeighbour.State.VALID -> R.string.connected_state_valid
|
||||
IpNeighbour.State.VALID_DELAY -> R.string.connected_state_valid_delay
|
||||
IpNeighbour.State.FAILED -> R.string.connected_state_failed
|
||||
else -> throw IllegalStateException()
|
||||
}
|
||||
}, iface)
|
||||
}
|
||||
private class ClientViewHolder(val binding: ListitemClientBinding) : RecyclerView.ViewHolder(binding.root)
|
||||
private inner class ClientAdapter : RecyclerView.Adapter<ClientViewHolder>() {
|
||||
|
||||
@@ -60,7 +60,7 @@ data class IpNeighbour(val ip: String, val dev: String, val lladdr: String, val
|
||||
private const val ARP_CACHE_EXPIRE = 1L * 1000 * 1000 * 1000
|
||||
private var arpCache = emptyList<List<String>>()
|
||||
private var arpCacheTime = -ARP_CACHE_EXPIRE
|
||||
fun arp(): List<List<String>> {
|
||||
private fun arp(): List<List<String>> {
|
||||
if (System.nanoTime() - arpCacheTime >= ARP_CACHE_EXPIRE) try {
|
||||
arpCache = File("/proc/net/arp").bufferedReader().useLines {
|
||||
it.map { it.split(spaces) }
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package be.mygod.vpnhotspot.net
|
||||
|
||||
import android.content.res.Resources
|
||||
import be.mygod.vpnhotspot.App
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.R
|
||||
import java.util.regex.Pattern
|
||||
|
||||
enum class TetherType {
|
||||
NONE, WIFI_P2P, USB, WIFI, WIMAX, BLUETOOTH;
|
||||
@@ -15,21 +16,30 @@ enum class TetherType {
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val usbRegexes: List<Pattern>
|
||||
private val wifiRegexes: List<Pattern>
|
||||
private val wimaxRegexes: List<Pattern>
|
||||
private val bluetoothRegexes: List<Pattern>
|
||||
|
||||
/**
|
||||
* Source: https://android.googlesource.com/platform/frameworks/base/+/61fa313/core/res/res/values/config.xml#328
|
||||
*/
|
||||
private val usbRegexes = App.app.resources.getStringArray(Resources.getSystem()
|
||||
init {
|
||||
val appRes = app.resources
|
||||
val sysRes = Resources.getSystem()
|
||||
usbRegexes = appRes.getStringArray(sysRes
|
||||
.getIdentifier("config_tether_usb_regexs", "array", "android"))
|
||||
.map { it.toPattern() }
|
||||
private val wifiRegexes = App.app.resources.getStringArray(Resources.getSystem()
|
||||
wifiRegexes = appRes.getStringArray(sysRes
|
||||
.getIdentifier("config_tether_wifi_regexs", "array", "android"))
|
||||
.map { it.toPattern() }
|
||||
private val wimaxRegexes = App.app.resources.getStringArray(Resources.getSystem()
|
||||
wimaxRegexes = appRes.getStringArray(sysRes
|
||||
.getIdentifier("config_tether_wimax_regexs", "array", "android"))
|
||||
.map { it.toPattern() }
|
||||
private val bluetoothRegexes = App.app.resources.getStringArray(Resources.getSystem()
|
||||
bluetoothRegexes = appRes.getStringArray(sysRes
|
||||
.getIdentifier("config_tether_bluetooth_regexs", "array", "android"))
|
||||
.map { it.toPattern() }
|
||||
}
|
||||
|
||||
fun ofInterface(iface: String, p2pDev: String? = null) = when {
|
||||
iface == p2pDev -> WIFI_P2P
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="@string/repeater_connected_devices"
|
||||
android:text="@string/connected_devices"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
<View
|
||||
|
||||
@@ -24,6 +24,6 @@
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
|
||||
android:text="Manage..."/>
|
||||
android:text="@string/tethering_manage"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
<string name="repeater_ssid">中继名称</string>
|
||||
<string name="repeater_password">中继密码</string>
|
||||
<string name="repeater_connected_devices">已连接设备</string>
|
||||
<string name="connected_devices">已连接设备</string>
|
||||
<string name="repeater_wps_dialog_title">输入 PIN</string>
|
||||
<string name="repeater_wps_dialog_pbc">一键加密</string>
|
||||
<string name="repeater_wps_success_pbc">请在 2 分钟内在需要连接的设备上使用一键加密以连接到此中继。</string>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
<string name="repeater_ssid">Network name</string>
|
||||
<string name="repeater_password">Password</string>
|
||||
<string name="repeater_connected_devices">Connected devices</string>
|
||||
<string name="repeater_wps">WPS</string>
|
||||
<string name="repeater_wps_dialog_title">Enter PIN</string>
|
||||
<string name="repeater_wps_dialog_pbc">Push Button</string>
|
||||
@@ -23,7 +22,6 @@
|
||||
<string name="repeater_reset_credentials_failure">Failed to reset credentials (reason: %s)</string>
|
||||
|
||||
<string name="repeater_inactive">Service inactive</string>
|
||||
<string name="repeater_connecting">Connecting…</string>
|
||||
<string name="repeater_vpn_unavailable">VPN unavailable, please enable any VPN</string>
|
||||
<string name="repeater_root_unavailable">Root unavailable</string>
|
||||
<string name="repeater_p2p_unavailable">Wi-Fi direct unavailable</string>
|
||||
@@ -37,6 +35,14 @@
|
||||
<string name="repeater_failure_reason_no_service_requests">no service requests added</string>
|
||||
<string name="repeater_failure_reason_unknown">unknown #%d</string>
|
||||
|
||||
<string name="tethering_manage">Manage…</string>
|
||||
|
||||
<string name="connected_devices">Connected devices</string>
|
||||
<string name="connected_state_incomplete">Connecting to %s</string>
|
||||
<string name="connected_state_valid">Connected to %s</string>
|
||||
<string name="connected_state_valid_delay">Connected to %s (losing)</string>
|
||||
<string name="connected_state_failed">Failed to connect to %s</string>
|
||||
|
||||
<string name="settings_service">Service</string>
|
||||
<string name="settings_service_dns">Downstream DNS server:port</string>
|
||||
<string name="settings_service_clean">Clean/reapply routing rules</string>
|
||||
|
||||
Reference in New Issue
Block a user