@@ -71,24 +71,15 @@ class GitServerConfigActivity : BaseGitActivity() {
7171 }
7272 }
7373
74- binding.serverUrl.setText(GitSettings .url)
74+ binding.serverUrl.setText(GitSettings .url.also {
75+ if (it.isNullOrEmpty()) return @also
76+ setAuthModes(it.startsWith(" http://" ) || it.startsWith(" https://" ))
77+ })
7578 binding.serverBranch.setText(GitSettings .branch)
7679
7780 binding.serverUrl.doOnTextChanged { text, _, _, _ ->
7881 if (text.isNullOrEmpty()) return @doOnTextChanged
79- if (text.startsWith(" http://" ) || text.startsWith(" https://" )) {
80- binding.authModeSshKey.isVisible = false
81- binding.authModeOpenKeychain.isVisible = false
82- binding.authModePassword.isVisible = true
83- if (binding.authModeGroup.checkedButtonId != binding.authModePassword.id)
84- binding.authModeGroup.check(View .NO_ID )
85- } else {
86- binding.authModeSshKey.isVisible = true
87- binding.authModeOpenKeychain.isVisible = true
88- binding.authModePassword.isVisible = true
89- if (binding.authModeGroup.checkedButtonId == View .NO_ID )
90- binding.authModeGroup.check(binding.authModeSshKey.id)
91- }
82+ setAuthModes(text.startsWith(" http://" ) || text.startsWith(" https://" ))
9283 }
9384
9485 binding.saveButton.setOnClickListener {
@@ -168,6 +159,22 @@ class GitServerConfigActivity : BaseGitActivity() {
168159 }
169160 }
170161
162+ private fun setAuthModes (isHttps : Boolean ) = with (binding) {
163+ if (isHttps) {
164+ authModeSshKey.isVisible = false
165+ authModeOpenKeychain.isVisible = false
166+ authModePassword.isVisible = true
167+ if (authModeGroup.checkedButtonId != authModePassword.id)
168+ authModeGroup.check(View .NO_ID )
169+ } else {
170+ authModeSshKey.isVisible = true
171+ authModeOpenKeychain.isVisible = true
172+ authModePassword.isVisible = true
173+ if (authModeGroup.checkedButtonId == View .NO_ID )
174+ authModeGroup.check(authModeSshKey.id)
175+ }
176+ }
177+
171178 /* *
172179 * Clones the repository, the directory exists, deletes it
173180 */
@@ -234,6 +241,7 @@ class GitServerConfigActivity : BaseGitActivity() {
234241 }
235242
236243 companion object {
244+
237245 fun createCloneIntent (context : Context ): Intent {
238246 return Intent (context, GitServerConfigActivity ::class .java).apply {
239247 putExtra(" cloning" , true )
0 commit comments