From 12db2d00df73b150054ddead1b0ee2af0370ddff Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 21 Sep 2020 22:56:34 +0530 Subject: Refactor auth mode check/uncheck (#1115) Signed-off-by: Harsh Shandilya --- .../com/zeapo/pwdstore/git/GitServerConfigActivity.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 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 0d4246b0..4b220be5 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitServerConfigActivity.kt @@ -56,16 +56,16 @@ class GitServerConfigActivity : BaseGitActivity() { binding.authModeGroup.apply { when (newAuthMode) { - AuthMode.SshKey -> check(R.id.auth_mode_ssh_key) - AuthMode.Password -> check(R.id.auth_mode_password) - AuthMode.OpenKeychain -> check(R.id.auth_mode_open_keychain) - AuthMode.None -> uncheck(checkedButtonId) + AuthMode.SshKey -> check(binding.authModeSshKey.id) + AuthMode.Password -> check(binding.authModePassword.id) + AuthMode.OpenKeychain -> check(binding.authModeOpenKeychain.id) + AuthMode.None -> check(View.NO_ID) } addOnButtonCheckedListener { _, _, _ -> when (checkedButtonId) { - R.id.auth_mode_ssh_key -> newAuthMode = AuthMode.SshKey - R.id.auth_mode_open_keychain -> newAuthMode = AuthMode.OpenKeychain - R.id.auth_mode_password -> newAuthMode = AuthMode.Password + binding.authModeSshKey.id -> newAuthMode = AuthMode.SshKey + binding.authModeOpenKeychain.id -> newAuthMode = AuthMode.OpenKeychain + binding.authModePassword.id -> newAuthMode = AuthMode.Password View.NO_ID -> newAuthMode = AuthMode.None } } @@ -80,10 +80,14 @@ class GitServerConfigActivity : BaseGitActivity() { 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) } } -- cgit v1.2.3