Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit f2d0c18

Browse files
committed
GitServerConfigActivity: set auth mode visibility on launch as well
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent 30c8c27 commit f2d0c18

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
99
- Some classes of errors would be swallowed by an unhelpful 'Invalid remote: origin' message
1010
- Repositories created within APS would contain invalid `.gpg-id` files with no ability to fix them from the app
1111
- Button labels were invisible in Autofill phishing warning screen
12+
- Unsupported authentication modes would appear briefly in the server config screen
1213

1314
### Added
1415

app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)