tv: initial draft of Android TV support
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
committed by
Jason A. Donenfeld
parent
d738161a2e
commit
0ad3781ae5
@@ -11,6 +11,7 @@ import androidx.annotation.AttrRes
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.preference.Preference
|
||||
import com.wireguard.android.Application
|
||||
import com.wireguard.android.R
|
||||
import com.wireguard.android.activity.SettingsActivity
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
@@ -20,6 +21,16 @@ fun Context.resolveAttribute(@AttrRes attrRes: Int): Int {
|
||||
return typedValue.data
|
||||
}
|
||||
|
||||
fun Context.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)
|
||||
}
|
||||
}
|
||||
|
||||
val Any.applicationScope: CoroutineScope
|
||||
get() = Application.getCoroutineScope()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user