Allow for setting of sample's default url/token through gradle properties
正在显示
2 个修改的文件
包含
21 行增加
和
3 行删除
| @@ -3,6 +3,17 @@ plugins { | @@ -3,6 +3,17 @@ plugins { | ||
| 3 | id 'kotlin-android' | 3 | id 'kotlin-android' |
| 4 | } | 4 | } |
| 5 | 5 | ||
| 6 | +def getDefaultUrl() { | ||
| 7 | + return hasProperty('livekitSampleUrl') ? livekitSampleUrl : "ws://www.example.com" | ||
| 8 | +} | ||
| 9 | + | ||
| 10 | +def getDefaultToken() { | ||
| 11 | + return hasProperty('livekitSampleToken') ? livekitSampleToken : "" | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +final url = getDefaultUrl() | ||
| 15 | +final token = getDefaultToken() | ||
| 16 | + | ||
| 6 | android { | 17 | android { |
| 7 | compileSdk androidSdk.compileVersion | 18 | compileSdk androidSdk.compileVersion |
| 8 | 19 | ||
| @@ -18,6 +29,14 @@ android { | @@ -18,6 +29,14 @@ android { | ||
| 18 | release { | 29 | release { |
| 19 | minifyEnabled false | 30 | minifyEnabled false |
| 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | 31 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 32 | + | ||
| 33 | + buildConfigField "String", "DEFAULT_URL", "\"$url\"" | ||
| 34 | + buildConfigField "String", "DEFAULT_TOKEN", "\"$token\"" | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + debug { | ||
| 38 | + buildConfigField "String", "DEFAULT_URL", "\"$url\"" | ||
| 39 | + buildConfigField "String", "DEFAULT_TOKEN", "\"$token\"" | ||
| 21 | } | 40 | } |
| 22 | } | 41 | } |
| 23 | compileOptions { | 42 | compileOptions { |
| @@ -32,8 +32,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { | @@ -32,8 +32,7 @@ class MainViewModel(application: Application) : AndroidViewModel(application) { | ||
| 32 | private const val PREFERENCES_KEY_URL = "url" | 32 | private const val PREFERENCES_KEY_URL = "url" |
| 33 | private const val PREFERENCES_KEY_TOKEN = "token" | 33 | private const val PREFERENCES_KEY_TOKEN = "token" |
| 34 | 34 | ||
| 35 | - const val URL = "ws://www.example.com" | ||
| 36 | - const val TOKEN = | ||
| 37 | - "" | 35 | + const val URL = BuildConfig.DEFAULT_URL |
| 36 | + const val TOKEN = BuildConfig.DEFAULT_TOKEN | ||
| 38 | } | 37 | } |
| 39 | } | 38 | } |
-
请 注册 或 登录 后发表评论