summaryrefslogtreecommitdiffhomepage
path: root/android/src
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-03-21 20:15:51 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2020-04-27 16:21:50 +0000
commit621ae7d59e36b8ead06f882570d164fc1d4b7e9d (patch)
tree8b9331591ba27e53c8cc34a6aec3e073c598c323 /android/src
parent92ef274725d3c795cb6ffe034f91b5505929073e (diff)
downloadmullvadvpn-621ae7d59e36b8ead06f882570d164fc1d4b7e9d.tar.xz
mullvadvpn-621ae7d59e36b8ead06f882570d164fc1d4b7e9d.zip
Create custom `Button` widget
Makes the button slightly transparent when disabled.
Diffstat (limited to 'android/src')
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ui/Button.kt31
1 files changed, 31 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/Button.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/Button.kt
new file mode 100644
index 0000000000..bea4eeed78
--- /dev/null
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/Button.kt
@@ -0,0 +1,31 @@
+package net.mullvad.mullvadvpn.ui
+
+import android.content.Context
+import android.util.AttributeSet
+
+class Button : android.widget.Button {
+ constructor(context: Context) : super(context) {}
+
+ constructor(context: Context, attributes: AttributeSet) : super(context, attributes) {}
+
+ constructor(context: Context, attributes: AttributeSet, defaultStyleAttribute: Int) :
+ super(context, attributes, defaultStyleAttribute) {}
+
+ constructor(
+ context: Context,
+ attributes: AttributeSet,
+ defaultStyleAttribute: Int,
+ defaultStyleResource: Int
+ ) : super(context, attributes, defaultStyleAttribute, defaultStyleResource) {
+ }
+
+ override fun setEnabled(enabled: Boolean) {
+ super.setEnabled(enabled)
+
+ if (enabled) {
+ alpha = 1.0f
+ } else {
+ alpha = 0.5f
+ }
+ }
+}