summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android/fragment
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-09-22 16:41:08 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2020-09-22 23:53:27 +0200
commit0ad3781ae5956aa2dbf217edf48c5f8445a92db8 (patch)
tree7bbf4029e44a73b3a6efe209ed9d5f3b4484c159 /ui/src/main/java/com/wireguard/android/fragment
parentd738161a2ebd6d6494ea5357026fa33884633ae4 (diff)
tv: initial draft of Android TV support
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/fragment')
-rw-r--r--ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt13
1 files changed, 2 insertions, 11 deletions
diff --git a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
index ce39fd8f..9b643e5f 100644
--- a/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
+++ b/ui/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.kt
@@ -17,6 +17,7 @@ import com.wireguard.android.backend.Tunnel
import com.wireguard.android.databinding.TunnelDetailFragmentBinding
import com.wireguard.android.databinding.TunnelDetailPeerBinding
import com.wireguard.android.model.ObservableTunnel
+import com.wireguard.android.util.formatBytes
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -28,16 +29,6 @@ class TunnelDetailFragment : BaseFragment() {
private var lastState = Tunnel.State.TOGGLE
private var timerActive = true
- private fun formatBytes(bytes: Long): String {
- return when {
- bytes < 1024 -> getString(R.string.transfer_bytes, bytes)
- bytes < 1024 * 1024 -> getString(R.string.transfer_kibibytes, bytes / 1024.0)
- bytes < 1024 * 1024 * 1024 -> getString(R.string.transfer_mibibytes, bytes / (1024.0 * 1024.0))
- bytes < 1024 * 1024 * 1024 * 1024L -> getString(R.string.transfer_gibibytes, bytes / (1024.0 * 1024.0 * 1024.0))
- else -> getString(R.string.transfer_tibibytes, bytes / (1024.0 * 1024.0 * 1024.0) / 1024.0)
- }
- }
-
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
@@ -117,7 +108,7 @@ class TunnelDetailFragment : BaseFragment() {
peer.transferText.visibility = View.GONE
continue
}
- peer.transferText.text = getString(R.string.transfer_rx_tx, formatBytes(rx), formatBytes(tx))
+ peer.transferText.text = getString(R.string.transfer_rx_tx, context?.formatBytes(rx), context?.formatBytes(tx))
peer.transferLabel.visibility = View.VISIBLE
peer.transferText.visibility = View.VISIBLE
}