Commit 0f004f1 1 parent 5aab3d4 commit 0f004f1 Copy full SHA for 0f004f1
File tree 3 files changed +24
-7
lines changed
library/src/main/java/org/xmtp/android/library
3 files changed +24
-7
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ data class GRPCApiClient(
90
90
91
91
private val channel: ManagedChannel =
92
92
Grpc .newChannelBuilderForAddress(
93
- environment.rawValue ,
93
+ environment.getValue() ,
94
94
5556 ,
95
95
if (secure) {
96
96
TlsChannelCredentials .create()
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package org.xmtp.android.library
2
2
3
3
import android.content.Context
4
4
import android.os.Build
5
+ import android.os.Environment
5
6
import android.security.keystore.KeyGenParameterSpec
6
7
import android.security.keystore.KeyProperties
7
8
import android.util.Log
@@ -66,7 +67,7 @@ data class ClientOptions(
66
67
val enableAlphaMls : Boolean = false ,
67
68
) {
68
69
data class Api (
69
- val env : XMTPEnvironment = XMTPEnvironment .DEV ,
70
+ val env : XMTPEnvironment = XMTPEnvironment .LOCAL ,
70
71
val isSecure : Boolean = true ,
71
72
val appVersion : String? = null ,
72
73
)
@@ -323,7 +324,7 @@ class Client() {
323
324
324
325
createClient(
325
326
logger = logger,
326
- host = " http://10.0.2.2 :5556" ,
327
+ host = " http://${options.api.env.getValue()} :5556" ,
327
328
isSecure = false ,
328
329
db = dbPath,
329
330
encryptionKey = retrievedKey.encoded,
Original file line number Diff line number Diff line change @@ -3,11 +3,27 @@ package org.xmtp.android.library
3
3
enum class XMTPEnvironment (val rawValue : String ) {
4
4
DEV (" dev.xmtp.network" ),
5
5
PRODUCTION (" production.xmtp.network" ),
6
- LOCAL (" 10.0.2.2" ),
7
- ;
6
+ LOCAL (" 10.0.2.2" ) {
7
+ override fun withValue (value : String ): XMTPEnvironment {
8
+ return LOCAL .apply { customValue = value }
9
+ }
10
+ };
11
+
12
+ private var customValue: String = " "
13
+
14
+ open fun withValue (value : String ): XMTPEnvironment {
15
+ return this
16
+ }
8
17
9
18
companion object {
10
- operator fun invoke (rawValue : String ) =
11
- XMTPEnvironment .values().firstOrNull { it.rawValue == rawValue }
19
+ operator fun invoke (rawValue : String ): XMTPEnvironment {
20
+ return XMTPEnvironment .values().firstOrNull { it.rawValue == rawValue }
21
+ ? : LOCAL .withValue(rawValue)
22
+ }
23
+ }
24
+
25
+ // This function returns the actual raw value for the enum, handling the CUSTOM case.
26
+ fun getValue (): String {
27
+ return if (this == LOCAL && customValue.isNotEmpty()) customValue else rawValue
12
28
}
13
29
}
You can’t perform that action at this time.
0 commit comments