summaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-10-21 05:49:32 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-10-21 06:21:19 +0530
commitf2d0c186725e1f631151361cd32959eb2a2a2ea8 (patch)
tree49871fbe7bf32b6269a957a5495c371c9ce99605 /app/src/main/java
parent30c8c27770c3d901ac5f1930da55a85c321e5369 (diff)
GitServerConfigActivity: set auth mode visibility on launch as well
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt36
1 files changed, 22 insertions, 14 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
index 364dcc1a..7f1bb6b3 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt
@@ -71,24 +71,15 @@ class GitServerConfigActivity : BaseGitActivity() {
}
}
- binding.serverUrl.setText(GitSettings.url)
+ binding.serverUrl.setText(GitSettings.url.also {
+ if (it.isNullOrEmpty()) return@also
+ setAuthModes(it.startsWith("http://") || it.startsWith("https://"))
+ })
binding.serverBranch.setText(GitSettings.branch)
binding.serverUrl.doOnTextChanged { text, _, _, _ ->
if (text.isNullOrEmpty()) return@doOnTextChanged
- if (text.startsWith("http://") || text.startsWith("https://")) {
- binding.authModeSshKey.isVisible = false
- binding.authModeOpenKeychain.isVisible = false
- binding.authModePassword.isVisible = true
- if (binding.authModeGroup.checkedButtonId != binding.authModePassword.id)
- binding.authModeGroup.check(View.NO_ID)
- } else {
- binding.authModeSshKey.isVisible = true
- binding.authModeOpenKeychain.isVisible = true
- binding.authModePassword.isVisible = true
- if (binding.authModeGroup.checkedButtonId == View.NO_ID)
- binding.authModeGroup.check(binding.authModeSshKey.id)
- }
+ setAuthModes(text.startsWith("http://") || text.startsWith("https://"))
}
binding.saveButton.setOnClickListener {
@@ -168,6 +159,22 @@ class GitServerConfigActivity : BaseGitActivity() {
}
}
+ private fun setAuthModes(isHttps: Boolean) = with(binding) {
+ if (isHttps) {
+ authModeSshKey.isVisible = false
+ authModeOpenKeychain.isVisible = false
+ authModePassword.isVisible = true
+ if (authModeGroup.checkedButtonId != authModePassword.id)
+ authModeGroup.check(View.NO_ID)
+ } else {
+ authModeSshKey.isVisible = true
+ authModeOpenKeychain.isVisible = true
+ authModePassword.isVisible = true
+ if (authModeGroup.checkedButtonId == View.NO_ID)
+ authModeGroup.check(authModeSshKey.id)
+ }
+ }
+
/**
* Clones the repository, the directory exists, deletes it
*/
@@ -234,6 +241,7 @@ class GitServerConfigActivity : BaseGitActivity() {
}
companion object {
+
fun createCloneIntent(context: Context): Intent {
return Intent(context, GitServerConfigActivity::class.java).apply {
putExtra("cloning", true)