diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-07-31 08:35:26 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-07-31 11:55:29 +0000 |
| commit | 2e64ca76d5cc385e8837941d2f4b188f47ab7b5a (patch) | |
| tree | d7ee2f33b547c9c26143e0b61d01b8425d3290d3 /android/src/main | |
| parent | 9902674c131a5a1b7e731fa46f90e024e09827bf (diff) | |
| download | mullvadvpn-2e64ca76d5cc385e8837941d2f4b188f47ab7b5a.tar.xz mullvadvpn-2e64ca76d5cc385e8837941d2f4b188f47ab7b5a.zip | |
Allow setting the notification message
Diffstat (limited to 'android/src/main')
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt index b175cbd9ed..7b6309d9d7 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/NotificationBanner.kt @@ -10,6 +10,7 @@ import net.mullvad.mullvadvpn.model.TunnelState class NotificationBanner(val parentView: View) { private val banner: View = parentView.findViewById(R.id.notification_banner) private val title: TextView = parentView.findViewById(R.id.notification_title) + private val message: TextView = parentView.findViewById(R.id.notification_message) private var visible = false @@ -33,8 +34,8 @@ class NotificationBanner(val parentView: View) { when (keyState) { null -> return false is KeygenEvent.NewKey -> return false - is KeygenEvent.TooManyKeys -> show(R.string.too_many_keys) - is KeygenEvent.GenerationFailure -> show(R.string.failed_to_generate_key) + is KeygenEvent.TooManyKeys -> show(R.string.too_many_keys, null) + is KeygenEvent.GenerationFailure -> show(R.string.failed_to_generate_key, null) } return true @@ -47,20 +48,20 @@ class NotificationBanner(val parentView: View) { is TunnelState.Disconnecting -> { when (state.actionAfterDisconnect) { is ActionAfterDisconnect.Nothing -> hide() - is ActionAfterDisconnect.Block -> show(R.string.blocking_internet) - is ActionAfterDisconnect.Reconnect -> show(R.string.blocking_internet) + is ActionAfterDisconnect.Block -> show(R.string.blocking_internet, null) + is ActionAfterDisconnect.Reconnect -> show(R.string.blocking_internet, null) } } is TunnelState.Disconnected -> hide() - is TunnelState.Connecting -> show(R.string.blocking_internet) + is TunnelState.Connecting -> show(R.string.blocking_internet, null) is TunnelState.Connected -> hide() - is TunnelState.Blocked -> show(R.string.blocking_internet) + is TunnelState.Blocked -> show(R.string.blocking_internet, null) } return true } - private fun show(titleText: Int) { + private fun show(titleText: Int, messageText: Int?) { if (!visible) { visible = true banner.visibility = View.VISIBLE @@ -69,6 +70,13 @@ class NotificationBanner(val parentView: View) { } title.setText(titleText) + + if (messageText == null) { + message.visibility = View.GONE + } else { + message.setText(messageText) + message.visibility = View.VISIBLE + } } private fun hide() { |
