-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.0.6 - Broadcast Receiver for Plugins
- Loading branch information
1 parent
59dc61a
commit da341f4
Showing
4 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
...eVPNService/src/main/java/org/operatorfoundation/moonbouncevpnservice/MoonbounceKotlin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...c/main/java/org/operatorfoundation/moonbouncevpnservice/MoonbouncePluginStatusReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package org.operatorfoundation.moonbouncevpnservice | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.widget.Toast | ||
|
||
class MoonbouncePluginStatusReceiver: BroadcastReceiver() | ||
{ | ||
override fun onReceive(context: Context, intent: Intent) | ||
{ | ||
// This method is called when the BroadcastReceiver is receiving an Intent broadcast. | ||
val statusString: String | ||
|
||
if (intent.action == MBAKVpnService.vpnStatusNotification) | ||
{ | ||
if (intent.hasExtra(MBAKVpnService.VPN_CONNECTED_STATUS)) | ||
{ | ||
val connected = intent.getBooleanExtra(MBAKVpnService.VPN_CONNECTED_STATUS, false) | ||
|
||
statusString = if (connected) { | ||
"VPN connected." | ||
} else { | ||
"VPN failed to connect." | ||
} | ||
} | ||
else | ||
{ | ||
statusString = "Received a VPN connection notification that did not provide a status." | ||
} | ||
} | ||
else | ||
{ | ||
statusString = "Received an unknown notification: ${intent.action}" | ||
} | ||
|
||
Toast.makeText(context, statusString, Toast.LENGTH_LONG).show() | ||
} | ||
} |