diff options
Diffstat (limited to 'app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt')
-rw-r--r-- | app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt index 2dd1c46..6e74891 100644 --- a/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt +++ b/app/src/main/java/org/pacien/tincapp/activities/StartActivity.kt | |||
@@ -3,7 +3,6 @@ package org.pacien.tincapp.activities | |||
3 | import android.app.Activity | 3 | import android.app.Activity |
4 | import android.app.ProgressDialog | 4 | import android.app.ProgressDialog |
5 | import android.content.Intent | 5 | import android.content.Intent |
6 | import android.content.IntentFilter | ||
7 | import android.net.VpnService | 6 | import android.net.VpnService |
8 | import android.os.Bundle | 7 | import android.os.Bundle |
9 | import android.support.v4.widget.SwipeRefreshLayout | 8 | import android.support.v4.widget.SwipeRefreshLayout |
@@ -22,7 +21,7 @@ import org.pacien.tincapp.R | |||
22 | import org.pacien.tincapp.context.AppPaths | 21 | import org.pacien.tincapp.context.AppPaths |
23 | import org.pacien.tincapp.extensions.Android.setElements | 22 | import org.pacien.tincapp.extensions.Android.setElements |
24 | import org.pacien.tincapp.intent.Actions | 23 | import org.pacien.tincapp.intent.Actions |
25 | import org.pacien.tincapp.intent.SimpleBroadcastReceiver | 24 | import org.pacien.tincapp.intent.BroadcastMapper |
26 | import org.pacien.tincapp.service.TincVpnService | 25 | import org.pacien.tincapp.service.TincVpnService |
27 | import org.pacien.tincapp.utils.TincKeyring | 26 | import org.pacien.tincapp.utils.TincKeyring |
28 | 27 | ||
@@ -116,8 +115,9 @@ class StartActivity : BaseActivity() { | |||
116 | } | 115 | } |
117 | } | 116 | } |
118 | 117 | ||
119 | private val startupBroadcastReceiver = SimpleBroadcastReceiver(IntentFilter(Actions.EVENT_CONNECTED), this::onVpnStart) | 118 | private val broadcastMapper = BroadcastMapper(mapOf( |
120 | private val errorBroadcastReceiver = SimpleBroadcastReceiver(IntentFilter(Actions.EVENT_ABORTED), this::onVpnStartError) | 119 | Actions.EVENT_CONNECTED to this::onVpnStart, |
120 | Actions.EVENT_ABORTED to this::onVpnStartError)) | ||
121 | 121 | ||
122 | private var connectDialog: ProgressDialog? = null | 122 | private var connectDialog: ProgressDialog? = null |
123 | 123 | ||
@@ -148,13 +148,11 @@ class StartActivity : BaseActivity() { | |||
148 | override fun onResume() { | 148 | override fun onResume() { |
149 | super.onResume() | 149 | super.onResume() |
150 | if (TincVpnService.isConnected()) openStatusActivity() | 150 | if (TincVpnService.isConnected()) openStatusActivity() |
151 | startupBroadcastReceiver.register() | 151 | broadcastMapper.register() |
152 | errorBroadcastReceiver.register() | ||
153 | } | 152 | } |
154 | 153 | ||
155 | override fun onPause() { | 154 | override fun onPause() { |
156 | startupBroadcastReceiver.unregister() | 155 | broadcastMapper.unregister() |
157 | errorBroadcastReceiver.unregister() | ||
158 | super.onPause() | 156 | super.onPause() |
159 | } | 157 | } |
160 | 158 | ||