Make connection mode a <= 1 toggle group to prevent UI overflow (#778)
This commit is contained in:
parent
3711bb9aa7
commit
a6eb4b4e21
2 changed files with 31 additions and 33 deletions
|
@ -6,6 +6,7 @@ package com.zeapo.pwdstore.git
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.view.View
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.os.postDelayed
|
import androidx.core.os.postDelayed
|
||||||
import androidx.core.widget.doOnTextChanged
|
import androidx.core.widget.doOnTextChanged
|
||||||
|
@ -50,18 +51,20 @@ class GitServerConfigActivity : BaseGitActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.connectionModeGroup.check(when (connectionMode) {
|
binding.connectionModeGroup.apply {
|
||||||
ConnectionMode.SshKey -> R.id.connection_mode_ssh_key
|
when (connectionMode) {
|
||||||
ConnectionMode.Password -> R.id.connection_mode_password
|
ConnectionMode.SshKey -> check(R.id.connection_mode_ssh_key)
|
||||||
ConnectionMode.OpenKeychain -> R.id.connection_mode_open_keychain
|
ConnectionMode.Password -> check(R.id.connection_mode_password)
|
||||||
ConnectionMode.None -> R.id.connection_mode_none
|
ConnectionMode.OpenKeychain -> check(R.id.connection_mode_open_keychain)
|
||||||
})
|
ConnectionMode.None -> uncheck(checkedButtonId)
|
||||||
binding.connectionModeGroup.setOnCheckedChangeListener { group, _ ->
|
}
|
||||||
when (group.checkedRadioButtonId) {
|
addOnButtonCheckedListener { group, _, _ ->
|
||||||
R.id.connection_mode_ssh_key -> connectionMode = ConnectionMode.SshKey
|
when (checkedButtonId) {
|
||||||
R.id.connection_mode_open_keychain -> connectionMode = ConnectionMode.OpenKeychain
|
R.id.connection_mode_ssh_key -> connectionMode = ConnectionMode.SshKey
|
||||||
R.id.connection_mode_password -> connectionMode = ConnectionMode.Password
|
R.id.connection_mode_open_keychain -> connectionMode = ConnectionMode.OpenKeychain
|
||||||
R.id.connection_mode_none -> connectionMode = ConnectionMode.None
|
R.id.connection_mode_password -> connectionMode = ConnectionMode.Password
|
||||||
|
View.NO_ID -> connectionMode = ConnectionMode.None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateConnectionModeToggleGroup()
|
updateConnectionModeToggleGroup()
|
||||||
|
@ -120,12 +123,14 @@ class GitServerConfigActivity : BaseGitActivity() {
|
||||||
|
|
||||||
private fun updateConnectionModeToggleGroup() {
|
private fun updateConnectionModeToggleGroup() {
|
||||||
if (protocol == Protocol.Ssh) {
|
if (protocol == Protocol.Ssh) {
|
||||||
if (binding.connectionModeNone.isChecked)
|
// Reset connection mode to SSH key if the current value (none) is not valid for SSH
|
||||||
|
if (binding.connectionModeGroup.checkedButtonIds.isEmpty())
|
||||||
binding.connectionModeGroup.check(R.id.connection_mode_ssh_key)
|
binding.connectionModeGroup.check(R.id.connection_mode_ssh_key)
|
||||||
binding.connectionModeSshKey.isEnabled = true
|
binding.connectionModeSshKey.isEnabled = true
|
||||||
binding.connectionModeOpenKeychain.isEnabled = true
|
binding.connectionModeOpenKeychain.isEnabled = true
|
||||||
binding.connectionModeNone.isEnabled = false
|
binding.connectionModeGroup.isSelectionRequired = true
|
||||||
} else {
|
} else {
|
||||||
|
binding.connectionModeGroup.isSelectionRequired = false
|
||||||
// Reset connection mode to password if the current value is not valid for HTTPS
|
// Reset connection mode to password if the current value is not valid for HTTPS
|
||||||
// Important note: This has to happen before disabling the other toggle buttons or they
|
// Important note: This has to happen before disabling the other toggle buttons or they
|
||||||
// won't uncheck.
|
// won't uncheck.
|
||||||
|
@ -133,7 +138,6 @@ class GitServerConfigActivity : BaseGitActivity() {
|
||||||
binding.connectionModeGroup.check(R.id.connection_mode_password)
|
binding.connectionModeGroup.check(R.id.connection_mode_password)
|
||||||
binding.connectionModeSshKey.isEnabled = false
|
binding.connectionModeSshKey.isEnabled = false
|
||||||
binding.connectionModeOpenKeychain.isEnabled = false
|
binding.connectionModeOpenKeychain.isEnabled = false
|
||||||
binding.connectionModeNone.isEnabled = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,43 +145,37 @@
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/label_server_path" />
|
app:layout_constraintTop_toBottomOf="@id/label_server_path" />
|
||||||
|
|
||||||
<RadioGroup
|
<com.google.android.material.button.MaterialButtonToggleGroup
|
||||||
android:id="@+id/connection_mode_group"
|
android:id="@+id/connection_mode_group"
|
||||||
|
style="@style/TextAppearance.MaterialComponents.Headline1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_margin="8dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/label_connection_mode">
|
app:layout_constraintTop_toBottomOf="@id/label_connection_mode"
|
||||||
|
app:singleSelection="true">
|
||||||
|
|
||||||
<RadioButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/connection_mode_ssh_key"
|
android:id="@+id/connection_mode_ssh_key"
|
||||||
|
style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="4dp"
|
|
||||||
android:text="@string/connection_mode_ssh_key" />
|
android:text="@string/connection_mode_ssh_key" />
|
||||||
|
|
||||||
<RadioButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/connection_mode_password"
|
android:id="@+id/connection_mode_password"
|
||||||
|
style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="4dp"
|
|
||||||
android:text="@string/connection_mode_basic_authentication" />
|
android:text="@string/connection_mode_basic_authentication" />
|
||||||
|
|
||||||
<RadioButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/connection_mode_open_keychain"
|
android:id="@+id/connection_mode_open_keychain"
|
||||||
|
style="?attr/materialButtonOutlinedStyle"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:padding="4dp"
|
|
||||||
android:text="@string/connection_mode_openkeychain" />
|
android:text="@string/connection_mode_openkeychain" />
|
||||||
|
</com.google.android.material.button.MaterialButtonToggleGroup>
|
||||||
<RadioButton
|
|
||||||
android:id="@+id/connection_mode_none"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="4dp"
|
|
||||||
android:text="@string/connection_mode_none" />
|
|
||||||
|
|
||||||
</RadioGroup>
|
|
||||||
|
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
android:id="@+id/save_button"
|
android:id="@+id/save_button"
|
||||||
|
|
Loading…
Reference in a new issue