diff options
| author | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2024-02-08 11:17:02 +0100 |
|---|---|---|
| committer | Jonatan Rhodin <jonatan.rhodin@mullvad.net> | 2024-02-08 11:17:02 +0100 |
| commit | ec4c473c5c08e30e16822a8a82531d3ff5a1135f (patch) | |
| tree | ad2ced90d3ece795a71a004a6006c377c04c1bf0 /android/lib | |
| parent | 1b80203504f58fab47dc6dbe53f223084acecc6a (diff) | |
| parent | af3df963648d4cc535b552f75cf3abdfe936b395 (diff) | |
| download | mullvadvpn-ec4c473c5c08e30e16822a8a82531d3ff5a1135f.tar.xz mullvadvpn-ec4c473c5c08e30e16822a8a82531d3ff5a1135f.zip | |
Merge branch 'add-support-for-custom-list-in-the-app-layer-droid-653'
Diffstat (limited to 'android/lib')
6 files changed, 29 insertions, 26 deletions
diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/LocationConstraintExtensions.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/LocationConstraintExtensions.kt deleted file mode 100644 index d845e3aba9..0000000000 --- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/LocationConstraintExtensions.kt +++ /dev/null @@ -1,23 +0,0 @@ -package net.mullvad.mullvadvpn.lib.common.util - -import net.mullvad.mullvadvpn.model.Constraint -import net.mullvad.mullvadvpn.model.GeographicLocationConstraint -import net.mullvad.mullvadvpn.model.LocationConstraint - -fun LocationConstraint.toGeographicLocationConstraint(): GeographicLocationConstraint? = - when (this) { - is LocationConstraint.Location -> this.location - is LocationConstraint.CustomList -> null - } - -fun Constraint<LocationConstraint>.toGeographicLocationConstraint(): - Constraint<GeographicLocationConstraint> = - when (this) { - is Constraint.Only -> - when (value) { - is LocationConstraint.Location -> - Constraint.Only((value as LocationConstraint.Location).location) - is LocationConstraint.CustomList -> Constraint.Any() - } - is Constraint.Any -> Constraint.Any() - } diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt index 69c28bb379..1136ae8c55 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Event.kt @@ -65,6 +65,8 @@ sealed class Event : Message.EventMessage() { @Parcelize object VpnPermissionRequest : Event() + @Parcelize data class CreateCustomListResult(val listId: String) : Event() + companion object { private const val MESSAGE_KEY = "event" diff --git a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt index 267f1f2619..fe9d3b46d9 100644 --- a/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt +++ b/android/lib/ipc/src/main/kotlin/net/mullvad/mullvadvpn/lib/ipc/Request.kt @@ -5,8 +5,9 @@ import android.os.Messenger import java.net.InetAddress import kotlinx.parcelize.Parcelize import net.mullvad.mullvadvpn.model.Constraint +import net.mullvad.mullvadvpn.model.CustomList import net.mullvad.mullvadvpn.model.DnsOptions -import net.mullvad.mullvadvpn.model.GeographicLocationConstraint +import net.mullvad.mullvadvpn.model.LocationConstraint import net.mullvad.mullvadvpn.model.ObfuscationSettings import net.mullvad.mullvadvpn.model.Ownership import net.mullvad.mullvadvpn.model.PlayPurchase @@ -77,8 +78,7 @@ sealed class Request : Message.RequestMessage() { @Parcelize data class SetEnableSplitTunneling(val enable: Boolean) : Request() - @Parcelize - data class SetRelayLocation(val relayLocation: GeographicLocationConstraint) : Request() + @Parcelize data class SetRelayLocation(val locationConstraint: LocationConstraint) : Request() @Parcelize data class SetWireGuardMtu(val mtu: Int?) : Request() @@ -111,6 +111,12 @@ sealed class Request : Message.RequestMessage() { val providers: Constraint<Providers> ) : Request() + @Parcelize data class CreateCustomList(val name: String) : Request() + + @Parcelize data class DeleteCustomList(val id: String) : Request() + + @Parcelize data class UpdateCustomList(val customList: CustomList) : Request() + companion object { private const val MESSAGE_KEY = "request" diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomList.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomList.kt new file mode 100644 index 0000000000..cdfa1b9687 --- /dev/null +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomList.kt @@ -0,0 +1,11 @@ +package net.mullvad.mullvadvpn.model + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +data class CustomList( + val id: String, + val name: String, + val locations: ArrayList<GeographicLocationConstraint> +) : Parcelable diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomListsSettings.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomListsSettings.kt new file mode 100644 index 0000000000..8a8c03ef05 --- /dev/null +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/CustomListsSettings.kt @@ -0,0 +1,6 @@ +package net.mullvad.mullvadvpn.model + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize data class CustomListsSettings(val customLists: ArrayList<CustomList>) : Parcelable diff --git a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt index 0d45b38179..304edc404a 100644 --- a/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt +++ b/android/lib/model/src/main/kotlin/net/mullvad/mullvadvpn/model/Settings.kt @@ -7,6 +7,7 @@ import kotlinx.parcelize.Parcelize data class Settings( val relaySettings: RelaySettings, val obfuscationSettings: ObfuscationSettings, + val customLists: CustomListsSettings, val allowLan: Boolean, val autoConnect: Boolean, val tunnelOptions: TunnelOptions, |
