summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-08-02 13:45:00 +0000
committerJanito Vaqueiro Ferreira Filho <janito@mullvad.net>2019-08-02 22:13:23 +0000
commitd20d24bdbce33e4cacebeecec0d518ffbea6a2e9 (patch)
treedc1203de56f3bc562d8ee80dac63b654d62303fc
parent63e2ca95f9c6b3068ed0c3c34bf4387c12df6166 (diff)
downloadmullvadvpn-d20d24bdbce33e4cacebeecec0d518ffbea6a2e9.tar.xz
mullvadvpn-d20d24bdbce33e4cacebeecec0d518ffbea6a2e9.zip
Save tunnel info expanded state
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt22
-rw-r--r--android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt2
2 files changed, 23 insertions, 1 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
index d80d385970..a0c94873f4 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ConnectFragment.kt
@@ -21,6 +21,8 @@ import net.mullvad.mullvadvpn.dataproxy.RelayListListener
import net.mullvad.mullvadvpn.model.KeygenEvent
import net.mullvad.mullvadvpn.model.TunnelState
+val KEY_IS_TUNNEL_INFO_EXPANDED = "is_tunnel_info_expanded"
+
class ConnectFragment : Fragment() {
private lateinit var actionButton: ConnectActionButton
private lateinit var switchLocationButton: SwitchLocationButton
@@ -39,6 +41,8 @@ class ConnectFragment : Fragment() {
private lateinit var updateKeyStatusJob: Job
private lateinit var updateTunnelStateJob: Job
+ private var isTunnelInfoExpanded = false
+
override fun onAttach(context: Context) {
super.onAttach(context)
@@ -50,6 +54,13 @@ class ConnectFragment : Fragment() {
versionInfoCache = parentActivity.appVersionInfoCache
}
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+
+ isTunnelInfoExpanded =
+ savedInstanceState?.getBoolean(KEY_IS_TUNNEL_INFO_EXPANDED, false) ?: false
+ }
+
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@@ -64,7 +75,9 @@ class ConnectFragment : Fragment() {
headerBar = HeaderBar(view, context!!)
notificationBanner = NotificationBanner(view, context!!, versionInfoCache)
status = ConnectionStatus(view, context!!)
+
locationInfo = LocationInfo(view, context!!)
+ locationInfo.isTunnelInfoExpanded = isTunnelInfoExpanded
actionButton = ConnectActionButton(view)
actionButton.apply {
@@ -90,6 +103,8 @@ class ConnectFragment : Fragment() {
override fun onResume() {
super.onResume()
+ locationInfo.isTunnelInfoExpanded = isTunnelInfoExpanded
+
keyStatusListener.onKeyStatusChange = { keyStatus ->
updateKeyStatusJob.cancel()
updateKeyStatusJob = updateKeyStatus(keyStatus)
@@ -109,6 +124,8 @@ class ConnectFragment : Fragment() {
locationInfoCache.onNewLocation = null
relayListListener.onRelayListChange = null
+ isTunnelInfoExpanded = locationInfo.isTunnelInfoExpanded
+
super.onPause()
}
@@ -121,6 +138,11 @@ class ConnectFragment : Fragment() {
super.onDestroyView()
}
+ override fun onSaveInstanceState(state: Bundle) {
+ isTunnelInfoExpanded = locationInfo.isTunnelInfoExpanded
+ state.putBoolean(KEY_IS_TUNNEL_INFO_EXPANDED, isTunnelInfoExpanded)
+ }
+
private fun updateTunnelState(uiState: TunnelState) = GlobalScope.launch(Dispatchers.Main) {
val realState = connectionProxy.state
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
index b6f2aaa9e9..68e5840550 100644
--- a/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
+++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/LocationInfo.kt
@@ -21,7 +21,7 @@ class LocationInfo(val parentView: View, val context: Context) {
private var endpoint: Endpoint? = null
private var isTunnelInfoVisible = false
- private var isTunnelInfoExpanded = false
+ var isTunnelInfoExpanded = false
var location: GeoIpLocation? = null
set(value) {