summaryrefslogtreecommitdiffhomepage
path: root/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt24
1 files changed, 14 insertions, 10 deletions
diff --git a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
index 16c3e6a3..33a2e8a0 100644
--- a/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
+++ b/ui/src/main/java/com/wireguard/android/viewmodel/InterfaceProxy.kt
@@ -21,12 +21,14 @@ import com.wireguard.crypto.KeyFormatException
import com.wireguard.crypto.KeyPair
object Constants {
- const val HTTP_PROXY_NONE = "None"
- const val HTTP_PROXY_MANUAL = "Manual"
- const val HTTP_PROXY_PAC = "Proxy Auto-Config"
+ const val HTTP_PROXY_NONE = 1
+ const val HTTP_PROXY_MANUAL = 2
+ const val HTTP_PROXY_PAC = 3
}
class InterfaceProxy : BaseObservable, Parcelable {
+ val httpProxyItems: List<String>
+
@get:Bindable
val excludedApplications: ObservableList<String> = ObservableArrayList()
@@ -72,7 +74,7 @@ class InterfaceProxy : BaseObservable, Parcelable {
@get:Bindable
var httpProxyManualVisibility: Int = 0
- get() = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) android.view.View.GONE else (if (httpProxyMenu == Constants.HTTP_PROXY_MANUAL) android.view.View.VISIBLE else android.view.View.GONE)
+ get() = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) android.view.View.GONE else (if (httpProxyMenu == httpProxyItems[Constants.HTTP_PROXY_MANUAL]) android.view.View.VISIBLE else android.view.View.GONE)
@get:Bindable
var httpProxyHostname: String = ""
@@ -115,7 +117,7 @@ class InterfaceProxy : BaseObservable, Parcelable {
""
}
- private constructor(parcel: Parcel) {
+ private constructor(httpProxyItems: List<String>, parcel: Parcel) : this(httpProxyItems) {
addresses = parcel.readString() ?: ""
dnsServers = parcel.readString() ?: ""
parcel.readStringList(excludedApplications)
@@ -129,7 +131,7 @@ class InterfaceProxy : BaseObservable, Parcelable {
privateKey = parcel.readString() ?: ""
}
- constructor(other: Interface) {
+ constructor(httpProxyItems: List<String>, other: Interface) : this(httpProxyItems) {
addresses = Attribute.join(other.addresses)
val dnsServerStrings = other.dnsServers.map { it.hostAddress }.plus(other.dnsSearchDomains)
dnsServers = Attribute.join(dnsServerStrings)
@@ -145,7 +147,9 @@ class InterfaceProxy : BaseObservable, Parcelable {
privateKey = keyPair.privateKey.toBase64()
}
- constructor()
+ constructor(httpProxyItems: List<String>) {
+ this.httpProxyItems = httpProxyItems
+ }
override fun describeContents() = 0
@@ -199,7 +203,7 @@ class InterfaceProxy : BaseObservable, Parcelable {
private class InterfaceProxyCreator : Parcelable.Creator<InterfaceProxy> {
override fun createFromParcel(parcel: Parcel): InterfaceProxy {
- return InterfaceProxy(parcel)
+ return InterfaceProxy(httpProxyItems, parcel)
}
override fun newArray(size: Int): Array<InterfaceProxy?> {
@@ -207,8 +211,8 @@ class InterfaceProxy : BaseObservable, Parcelable {
}
}
- companion object {
+// companion object {
@JvmField
val CREATOR: Parcelable.Creator<InterfaceProxy> = InterfaceProxyCreator()
- }
+// }
}