diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-01 14:29:57 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2020-04-27 16:21:51 +0000 |
| commit | 8cdba47a72444683861f4801c1989f4256c9adee (patch) | |
| tree | 7b7d41491f5c1da19ae582499159c889e91a24b7 /android/src | |
| parent | f688c78377ca14f2045c7f32fcd9e70601c394c5 (diff) | |
| download | mullvadvpn-8cdba47a72444683861f4801c1989f4256c9adee.tar.xz mullvadvpn-8cdba47a72444683861f4801c1989f4256c9adee.zip | |
Allow showing spinner when information is missing
Diffstat (limited to 'android/src')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ui/InformationView.kt | 27 | ||||
| -rw-r--r-- | android/src/main/res/layout/information_view.xml | 25 | ||||
| -rw-r--r-- | android/src/main/res/values/attrs.xml | 1 |
3 files changed, 36 insertions, 17 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/InformationView.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/InformationView.kt index 2dfd2f4128..b9d3fee793 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/InformationView.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/InformationView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.AttributeSet import android.util.TypedValue import android.view.LayoutInflater +import android.view.View import android.widget.LinearLayout import android.widget.TextView import net.mullvad.mullvadvpn.R @@ -11,13 +12,15 @@ import net.mullvad.mullvadvpn.R open class InformationView : LinearLayout { enum class WhenMissing { Nothing, - Hide; + Hide, + ShowSpinner; companion object { internal fun fromCode(code: Int): WhenMissing { when (code) { 0 -> return Nothing 1 -> return Hide + 2 -> return ShowSpinner else -> throw Exception("Invalid whenMissing attribute value") } } @@ -36,6 +39,7 @@ open class InformationView : LinearLayout { private val description: TextView = findViewById(R.id.description) private val informationDisplay: TextView = findViewById(R.id.information_display) + private val spinner: View = findViewById(R.id.spinner) var information: String? = null set(value) { @@ -101,15 +105,18 @@ open class InformationView : LinearLayout { } private fun updateStatus() { - when (whenMissing) { - WhenMissing.Nothing -> visibility = VISIBLE - WhenMissing.Hide -> { - if (information == null) { - visibility = INVISIBLE - } else { - visibility = VISIBLE - } - } + if (whenMissing == WhenMissing.Hide && information == null) { + visibility = INVISIBLE + } else { + visibility = VISIBLE + } + + if (whenMissing == WhenMissing.ShowSpinner && information == null) { + spinner.visibility = VISIBLE + informationDisplay.visibility = INVISIBLE + } else { + spinner.visibility = INVISIBLE + informationDisplay.visibility = VISIBLE } setEnabled(information != null) diff --git a/android/src/main/res/layout/information_view.xml b/android/src/main/res/layout/information_view.xml index b59aac9b7b..2b49e35b3c 100644 --- a/android/src/main/res/layout/information_view.xml +++ b/android/src/main/res/layout/information_view.xml @@ -7,11 +7,22 @@ android:textSize="13sp" android:textStyle="bold" android:text="" /> - <TextView android:id="@+id/information_display" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:textColor="@color/white" - android:textSize="16sp" - android:textStyle="bold" - android:text="" /> + <FrameLayout android:layout_width="wrap_content" + android:layout_height="wrap_content"> + <TextView android:id="@+id/information_display" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textColor="@color/white" + android:textSize="16sp" + android:textStyle="bold" + android:text="" /> + <ProgressBar android:id="@+id/spinner" + android:layout_width="20dp" + android:layout_height="20dp" + android:indeterminate="true" + android:indeterminateOnly="true" + android:indeterminateDuration="600" + android:indeterminateDrawable="@drawable/icon_spinner" + android:visibility="invisible" /> + </FrameLayout> </merge> diff --git a/android/src/main/res/values/attrs.xml b/android/src/main/res/values/attrs.xml index 9a51551410..20fd1f553e 100644 --- a/android/src/main/res/values/attrs.xml +++ b/android/src/main/res/values/attrs.xml @@ -8,6 +8,7 @@ <attr name="whenMissing" format="enum"> <enum name="nothing" value="0"/> <enum name="hide" value="1"/> + <enum name="showSpinner" value="2"/> </attr> </declare-styleable> </resources> |
