diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt b/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt
index 3e341ded..5b159d59 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/client/ClientsFragment.kt
@@ -32,6 +32,7 @@ import be.mygod.vpnhotspot.net.monitor.TrafficRecorder
import be.mygod.vpnhotspot.room.*
import be.mygod.vpnhotspot.util.ServiceForegroundConnector
import be.mygod.vpnhotspot.util.toPluralInt
+import be.mygod.vpnhotspot.widget.SmartSnackbar
import java.text.NumberFormat
class ClientsFragment : Fragment(), ServiceConnection {
@@ -118,10 +119,14 @@ class ClientsFragment : Fragment(), ServiceConnection {
}
R.id.block, R.id.unblock -> {
val client = binding.client ?: return false
+ val wasWorking = TrafficRecorder.isWorking(client.mac.macToLong())
client.record.apply {
AppDatabase.instance.clientRecordDao.update(ClientRecord(mac, nickname, !blocked))
}
IpNeighbourMonitor.instance?.flush()
+ if (!wasWorking && item.itemId == R.id.block) {
+ SmartSnackbar.make(R.string.clients_popup_block_service_inactive).show()
+ }
true
}
R.id.stats -> {
diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TrafficRecorder.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TrafficRecorder.kt
index f047abef..74fde249 100644
--- a/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TrafficRecorder.kt
+++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/monitor/TrafficRecorder.kt
@@ -146,4 +146,9 @@ object TrafficRecorder {
unscheduleUpdateLocked()
records.clear()
}
+
+ /**
+ * Possibly inefficient. Don't call this too often.
+ */
+ fun isWorking(mac: Long) = records.values.any { it.mac == mac }
}
diff --git a/mobile/src/main/res/values-zh-rCN/strings.xml b/mobile/src/main/res/values-zh-rCN/strings.xml
index dcfa6ed2..8f095bb3 100644
--- a/mobile/src/main/res/values-zh-rCN/strings.xml
+++ b/mobile/src/main/res/values-zh-rCN/strings.xml
@@ -59,6 +59,7 @@
昵称…
拉黑
+ 拉黑需要为该接口打开服务。
洗白
流量…
%s 的昵称
diff --git a/mobile/src/main/res/values/strings.xml b/mobile/src/main/res/values/strings.xml
index 1e2fc30f..575f3868 100644
--- a/mobile/src/main/res/values/strings.xml
+++ b/mobile/src/main/res/values/strings.xml
@@ -63,6 +63,7 @@
Nickname…
Block
+ Turn on service for this interface to block the client.
Unblock
Stats…
Nickname for %s