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/AccountInputContainer.kt50
1 files changed, 38 insertions, 12 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInputContainer.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInputContainer.kt
index 3dadd91872..70a5719eea 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInputContainer.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/AccountInputContainer.kt
@@ -15,6 +15,30 @@ class AccountInputContainer : RelativeLayout {
ERROR
}
+ private class StateDrawables(
+ val corner: Drawable,
+ val horizontalBorder: Drawable,
+ val verticalBorder: Drawable
+ )
+
+ private val unfocusedDrawables = StateDrawables(
+ resources.getDrawable(R.drawable.account_input_corner, null),
+ resources.getDrawable(R.drawable.account_input_border, null),
+ resources.getDrawable(R.drawable.account_input_border, null)
+ )
+
+ private val focusedDrawables = StateDrawables(
+ resources.getDrawable(R.drawable.account_input_corner_focused, null),
+ resources.getDrawable(R.drawable.account_input_border_focused, null),
+ resources.getDrawable(R.drawable.account_input_border_focused, null)
+ )
+
+ private val errorDrawables = StateDrawables(
+ resources.getDrawable(R.drawable.account_input_corner_error, null),
+ resources.getDrawable(R.drawable.account_input_border_error, null),
+ resources.getDrawable(R.drawable.account_input_border_error, null)
+ )
+
private val container =
context.getSystemService(Context.LAYOUT_INFLATER_SERVICE).let { service ->
val inflater = service as LayoutInflater
@@ -22,10 +46,6 @@ class AccountInputContainer : RelativeLayout {
inflater.inflate(R.layout.account_input_container, this)
}
- private val errorCorner = resources.getDrawable(R.drawable.account_input_corner_error, null)
- private val focusedCorner = resources.getDrawable(R.drawable.account_input_corner_focused, null)
- private val unfocusedCorner = resources.getDrawable(R.drawable.account_input_corner, null)
-
private val topLeftCorner: ImageView = container.findViewById(R.id.top_left_corner)
private val topRightCorner: ImageView = container.findViewById(R.id.top_right_corner)
private val bottomLeftCorner: ImageView = container.findViewById(R.id.bottom_left_corner)
@@ -41,9 +61,9 @@ class AccountInputContainer : RelativeLayout {
field = value
when (value) {
- BorderState.UNFOCUSED -> setBorder(unfocusedCorner)
- BorderState.FOCUSED -> setBorder(focusedCorner)
- BorderState.ERROR -> setBorder(errorCorner)
+ BorderState.UNFOCUSED -> setBorder(unfocusedDrawables)
+ BorderState.FOCUSED -> setBorder(focusedDrawables)
+ BorderState.ERROR -> setBorder(errorDrawables)
}
}
@@ -76,10 +96,16 @@ class AccountInputContainer : RelativeLayout {
) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) {
}
- private fun setBorder(corner: Drawable) {
- topLeftCorner.setImageDrawable(corner)
- topRightCorner.setImageDrawable(corner)
- bottomLeftCorner.setImageDrawable(corner)
- bottomRightCorner.setImageDrawable(corner)
+ private fun setBorder(drawables: StateDrawables) {
+ topLeftCorner.setImageDrawable(drawables.corner)
+ topRightCorner.setImageDrawable(drawables.corner)
+ bottomLeftCorner.setImageDrawable(drawables.corner)
+ bottomRightCorner.setImageDrawable(drawables.corner)
+
+ leftBorder.setImageDrawable(drawables.verticalBorder)
+ rightBorder.setImageDrawable(drawables.verticalBorder)
+
+ topBorder.setImageDrawable(drawables.horizontalBorder)
+ bottomBorder.setImageDrawable(drawables.horizontalBorder)
}
}