Refine code style

This commit is contained in:
Mygod
2019-04-14 13:23:21 +08:00
parent 44a0f675ed
commit 243d103ca7
4 changed files with 12 additions and 18 deletions

View File

@@ -88,19 +88,15 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService() {
} }
override fun onFailed(reason: Int) { override fun onFailed(reason: Int) {
val message = getString(R.string.tethering_temp_hotspot_failure, SmartSnackbar.make(getString(R.string.tethering_temp_hotspot_failure, when (reason) {
when (reason) { ERROR_NO_CHANNEL -> getString(R.string.tethering_temp_hotspot_failure_no_channel)
WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL -> ERROR_GENERIC -> getString(R.string.tethering_temp_hotspot_failure_generic)
getString(R.string.tethering_temp_hotspot_failure_no_channel) ERROR_INCOMPATIBLE_MODE -> getString(R.string.tethering_temp_hotspot_failure_incompatible_mode)
WifiManager.LocalOnlyHotspotCallback.ERROR_GENERIC -> ERROR_TETHERING_DISALLOWED -> {
getString(R.string.tethering_temp_hotspot_failure_generic)
WifiManager.LocalOnlyHotspotCallback.ERROR_INCOMPATIBLE_MODE ->
getString(R.string.tethering_temp_hotspot_failure_incompatible_mode)
WifiManager.LocalOnlyHotspotCallback.ERROR_TETHERING_DISALLOWED ->
getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed) getString(R.string.tethering_temp_hotspot_failure_tethering_disallowed)
}
else -> getString(R.string.failure_reason_unknown, reason) else -> getString(R.string.failure_reason_unknown, reason)
}) })).show()
SmartSnackbar.make(message).show()
startFailure() startFailure()
} }
}, null) }, null)

View File

@@ -36,7 +36,7 @@ class TetheringService : IpNeighbourMonitoringService() {
RoutingManager(caller, downstream, TetherType.ofInterface(downstream).isWifi) { RoutingManager(caller, downstream, TetherType.ofInterface(downstream).isWifi) {
override fun Routing.configure() { override fun Routing.configure() {
forward() forward()
masquerade(RoutingManager.masqueradeMode) masquerade(masqueradeMode)
if (app.pref.getBoolean("service.disableIpv6", true)) disableIpv6() if (app.pref.getBoolean("service.disableIpv6", true)) disableIpv6()
commit() commit()
} }

View File

@@ -105,8 +105,7 @@ sealed class TetherManager(protected val parent: TetheringFragment) : Manager(),
fun updateErrorMessage(errored: List<String>) { fun updateErrorMessage(errored: List<String>) {
data.text = errored.filter { TetherType.ofInterface(it) == tetherType }.joinToString("\n") { data.text = errored.filter { TetherType.ofInterface(it) == tetherType }.joinToString("\n") {
"$it: " + try { "$it: " + try {
val error = TetheringManager.getLastTetherError(it) when (val error = TetheringManager.getLastTetherError(it)) {
when (error) {
TetheringManager.TETHER_ERROR_NO_ERROR -> "TETHER_ERROR_NO_ERROR" TetheringManager.TETHER_ERROR_NO_ERROR -> "TETHER_ERROR_NO_ERROR"
TetheringManager.TETHER_ERROR_UNKNOWN_IFACE -> "TETHER_ERROR_UNKNOWN_IFACE" TetheringManager.TETHER_ERROR_UNKNOWN_IFACE -> "TETHER_ERROR_UNKNOWN_IFACE"
TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL -> "TETHER_ERROR_SERVICE_UNAVAIL" TetheringManager.TETHER_ERROR_SERVICE_UNAVAIL -> "TETHER_ERROR_SERVICE_UNAVAIL"

View File

@@ -59,9 +59,8 @@ object SpanFormatter {
val argTerm = m.group(1) val argTerm = m.group(1)
val modTerm = m.group(2) val modTerm = m.group(2)
val typeTerm = m.group(3)
val cookedArg = when (typeTerm) { val cookedArg = when (val typeTerm = m.group(3)) {
"%" -> "%" "%" -> "%"
"n" -> "\n" "n" -> "\n"
else -> { else -> {