mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 10:25:35 +03:00
keeping the http:// schema in the server selection input field
- helps to highlight a non secture connection, for https we strip the prefix
This commit is contained in:
parent
7f90dda96f
commit
985dbfe97d
2 changed files with 6 additions and 3 deletions
|
@ -19,8 +19,8 @@ package im.vector.app.core.extensions
|
|||
/**
|
||||
* Ex: "https://matrix.org/" -> "matrix.org"
|
||||
*/
|
||||
fun String?.toReducedUrl(): String {
|
||||
fun String?.toReducedUrl(keepSchema: Boolean = false): String {
|
||||
return (this ?: "")
|
||||
.substringAfter("://")
|
||||
.run { if (keepSchema) this else substringAfter("://") }
|
||||
.trim { it == '/' }
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ class FtueAuthCombinedServerSelectionFragment @Inject constructor() : AbstractSS
|
|||
}
|
||||
|
||||
override fun updateWithState(state: OnboardingViewState) {
|
||||
views.chooseServerInput.editText().setText(state.serverSelectionState.userUrlInput.toReducedUrl())
|
||||
val userUrlInput = state.serverSelectionState.userUrlInput?.toReducedUrlKeepingSchemaIfInsecure()
|
||||
views.chooseServerInput.editText().setText(userUrlInput)
|
||||
}
|
||||
|
||||
private fun String.toReducedUrlKeepingSchemaIfInsecure() = toReducedUrl(keepSchema = this.startsWith("http://"))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue