summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-26 17:21:14 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-05-27 12:15:13 +0000
commitd518b626606514643a2fe794357fdbfabf2f2a36 (patch)
tree64d504b824247877c6ac444710742adb45bb658d /android/src
parent25dfa99c3de49419c0739c08ac514467d399b17d (diff)
downloadmullvadvpn-d518b626606514643a2fe794357fdbfabf2f2a36.tar.xz
mullvadvpn-d518b626606514643a2fe794357fdbfabf2f2a36.zip
Add `displayFormatter` prop. to `InformationView`
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt14
1 files changed, 11 insertions, 3 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt
index 67d2dd07cc..8395d6ad27 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/widget/InformationView.kt
@@ -41,6 +41,12 @@ open class InformationView : LinearLayout {
private val informationDisplay: TextView = findViewById(R.id.information_display)
private val spinner: View = findViewById(R.id.spinner)
+ var displayFormatter: ((String) -> String)? = null
+ set(value) {
+ field = value
+ updateStatus()
+ }
+
var shouldEnable = false
set(value) {
field = value
@@ -150,12 +156,14 @@ open class InformationView : LinearLayout {
informationDisplay.setTextColor(errorColor)
informationDisplay.text = error
} else if (information != null) {
+ val formattedInformation = displayFormatter?.invoke(information) ?: information
+
informationDisplay.setTextColor(informationColor)
- if (maxLength == 0 || information.length <= maxLength) {
- informationDisplay.text = information
+ if (maxLength == 0 || formattedInformation.length <= maxLength) {
+ informationDisplay.text = formattedInformation
} else {
- informationDisplay.text = information.substring(0, maxLength) + "..."
+ informationDisplay.text = formattedInformation.substring(0, maxLength) + "..."
}
}