diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-21 21:59:04 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-24 17:31:04 +0000 |
| commit | 5a8b3fd40724f23304f41a73f7a8a91538722c2d (patch) | |
| tree | bdda74a7ab08d588715816516e8e121394d35f1d | |
| parent | e24b67eab9ecc69781fd0f8f05039cf03914c91b (diff) | |
| download | mullvadvpn-5a8b3fd40724f23304f41a73f7a8a91538722c2d.tar.xz mullvadvpn-5a8b3fd40724f23304f41a73f7a8a91538722c2d.zip | |
Create `SwitchLocationButton` helper class
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt | 8 | ||||
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt | 14 |
2 files changed, 18 insertions, 4 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt index dac1426b2a..39c535c1d7 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt @@ -26,6 +26,7 @@ import net.mullvad.mullvadvpn.model.TunnelStateTransition class ConnectFragment : Fragment() { private lateinit var actionButton: ConnectActionButton + private lateinit var switchLocationButton: SwitchLocationButton private lateinit var headerBar: HeaderBar private lateinit var notificationBanner: NotificationBanner private lateinit var status: ConnectionStatus @@ -64,10 +65,6 @@ class ConnectFragment : Fragment() { parentActivity.openSettings() } - view.findViewById<Button>(R.id.switch_location).setOnClickListener { - openSwitchLocationScreen() - } - headerBar = HeaderBar(view, context!!) notificationBanner = NotificationBanner(view) status = ConnectionStatus(view, context!!) @@ -80,6 +77,9 @@ class ConnectFragment : Fragment() { onDisconnect = { disconnect() } } + switchLocationButton = SwitchLocationButton(view) + switchLocationButton.onClick = { openSwitchLocationScreen() } + attachListenerJob = attachListener() return view diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt new file mode 100644 index 0000000000..72a33dc295 --- /dev/null +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/SwitchLocationButton.kt @@ -0,0 +1,14 @@ +package net.mullvad.mullvadvpn + +import android.view.View +import android.widget.Button + +class SwitchLocationButton(val parentView: View) { + private val button: Button = parentView.findViewById(R.id.switch_location) + + var onClick: (() -> Unit)? = null + + init { + button.setOnClickListener { onClick?.invoke() } + } +} |
