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

Commit 12db2d0

Browse files
authored
Refactor auth mode check/uncheck (#1115)
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent 37ea5d4 commit 12db2d0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ class GitServerConfigActivity : BaseGitActivity() {
5656

5757
binding.authModeGroup.apply {
5858
when (newAuthMode) {
59-
AuthMode.SshKey -> check(R.id.auth_mode_ssh_key)
60-
AuthMode.Password -> check(R.id.auth_mode_password)
61-
AuthMode.OpenKeychain -> check(R.id.auth_mode_open_keychain)
62-
AuthMode.None -> uncheck(checkedButtonId)
59+
AuthMode.SshKey -> check(binding.authModeSshKey.id)
60+
AuthMode.Password -> check(binding.authModePassword.id)
61+
AuthMode.OpenKeychain -> check(binding.authModeOpenKeychain.id)
62+
AuthMode.None -> check(View.NO_ID)
6363
}
6464
addOnButtonCheckedListener { _, _, _ ->
6565
when (checkedButtonId) {
66-
R.id.auth_mode_ssh_key -> newAuthMode = AuthMode.SshKey
67-
R.id.auth_mode_open_keychain -> newAuthMode = AuthMode.OpenKeychain
68-
R.id.auth_mode_password -> newAuthMode = AuthMode.Password
66+
binding.authModeSshKey.id -> newAuthMode = AuthMode.SshKey
67+
binding.authModeOpenKeychain.id -> newAuthMode = AuthMode.OpenKeychain
68+
binding.authModePassword.id -> newAuthMode = AuthMode.Password
6969
View.NO_ID -> newAuthMode = AuthMode.None
7070
}
7171
}
@@ -80,10 +80,14 @@ class GitServerConfigActivity : BaseGitActivity() {
8080
binding.authModeSshKey.isVisible = false
8181
binding.authModeOpenKeychain.isVisible = false
8282
binding.authModePassword.isVisible = true
83+
if (binding.authModeGroup.checkedButtonId != binding.authModePassword.id)
84+
binding.authModeGroup.check(View.NO_ID)
8385
} else {
8486
binding.authModeSshKey.isVisible = true
8587
binding.authModeOpenKeychain.isVisible = true
8688
binding.authModePassword.isVisible = true
89+
if (binding.authModeGroup.checkedButtonId == View.NO_ID)
90+
binding.authModeGroup.check(binding.authModeSshKey.id)
8791
}
8892
}
8993

0 commit comments

Comments
 (0)