summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
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) + "..."
}
}