diff options
| author | Albin <albin@mullvad.net> | 2023-07-28 09:59:13 +0200 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2023-07-28 10:45:57 +0200 |
| commit | 47bc546a330544b420aab2bdd8c5f91abe7f3161 (patch) | |
| tree | f9d4e0356c24cb5dcf086105e7e56cc781bc8930 /android | |
| parent | fde17e6352e964c2809f0469fe3b8acd8dcb8fec (diff) | |
| download | mullvadvpn-47bc546a330544b420aab2bdd8c5f91abe7f3161.tar.xz mullvadvpn-47bc546a330544b420aab2bdd8c5f91abe7f3161.zip | |
Move class and action constants to common module
Diffstat (limited to 'android')
5 files changed, 18 insertions, 8 deletions
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt new file mode 100644 index 0000000000..6d8dbf697f --- /dev/null +++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Actions.kt @@ -0,0 +1,5 @@ +package net.mullvad.mullvadvpn.lib.common.constant + +const val KEY_CONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.connect_action" +const val KEY_DISCONNECT_ACTION = "$MULLVAD_PACKAGE_NAME.disconnect_action" +const val KEY_QUIT_ACTION = "$MULLVAD_PACKAGE_NAME.quit_action" diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt new file mode 100644 index 0000000000..e8888cc3cd --- /dev/null +++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/constant/Classes.kt @@ -0,0 +1,5 @@ +package net.mullvad.mullvadvpn.lib.common.constant + +const val MULLVAD_PACKAGE_NAME = "net.mullvad.mullvadvpn" +const val MAIN_ACTIVITY_CLASS = "$MULLVAD_PACKAGE_NAME.ui.MainActivity" +const val VPN_SERVICE_CLASS = "$MULLVAD_PACKAGE_NAME.service.MullvadVpnService" diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt index b29b7edfe0..5b327d91c2 100644 --- a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt +++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt @@ -15,6 +15,10 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeoutOrNull +import net.mullvad.mullvadvpn.lib.common.constant.KEY_CONNECT_ACTION +import net.mullvad.mullvadvpn.lib.common.constant.KEY_DISCONNECT_ACTION +import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME +import net.mullvad.mullvadvpn.lib.common.constant.VPN_SERVICE_CLASS import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.setSubtitleIfSupported import net.mullvad.mullvadvpn.model.ServiceResult import net.mullvad.mullvadvpn.model.TunnelState @@ -74,7 +78,7 @@ class MullvadTileService : TileService() { private fun toggleTunnel() { val intent = Intent().apply { - setClassName(VPN_SERVICE_PACKAGE, VPN_SERVICE_CLASS) + setClassName(MULLVAD_PACKAGE_NAME, VPN_SERVICE_CLASS) action = if (qsTile.state == Tile.STATE_INACTIVE) { KEY_CONNECT_ACTION diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt index c04820d177..9673b33e18 100644 --- a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt +++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt @@ -23,6 +23,8 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch +import net.mullvad.mullvadvpn.lib.common.constant.MULLVAD_PACKAGE_NAME +import net.mullvad.mullvadvpn.lib.common.constant.VPN_SERVICE_CLASS import net.mullvad.mullvadvpn.lib.common.util.DispatchingFlow import net.mullvad.mullvadvpn.lib.common.util.bindServiceFlow import net.mullvad.mullvadvpn.lib.common.util.dispatchTo @@ -79,7 +81,7 @@ class ServiceConnection(context: Context, scope: CoroutineScope) { } private suspend fun connect(context: Context) { - val intent = Intent().apply { setClassName(VPN_SERVICE_PACKAGE, VPN_SERVICE_CLASS) } + val intent = Intent().apply { setClassName(MULLVAD_PACKAGE_NAME, VPN_SERVICE_CLASS) } context .bindServiceFlow(intent) diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt deleted file mode 100644 index 6229c1478b..0000000000 --- a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt +++ /dev/null @@ -1,6 +0,0 @@ -package net.mullvad.mullvadvpn.tile - -internal const val VPN_SERVICE_PACKAGE = "net.mullvad.mullvadvpn" -internal const val VPN_SERVICE_CLASS = "$VPN_SERVICE_PACKAGE.service.MullvadVpnService" -internal const val KEY_CONNECT_ACTION = "$VPN_SERVICE_PACKAGE.connect_action" -internal const val KEY_DISCONNECT_ACTION = "$VPN_SERVICE_PACKAGE.disconnect_action" |
