Miscellaneous UI tweaking (#771)

* Remove dangling UI element and relayout authentication modes

* Drop unnecessary actionBarPopupTheme declaration

* Improve ssh keygen UI

* Commonize button styling

* Tweak save button in server config

* Tweak generate button in ssh keygen

* Commonize OutlinedButton style

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-05-10 14:25:59 +05:30 committed by GitHub
parent 9a77f6bbea
commit 94dc92f8d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 103 deletions

View file

@ -5,7 +5,6 @@
package com.zeapo.pwdstore.sshkeygen package com.zeapo.pwdstore.sshkeygen
import android.os.Bundle import android.os.Bundle
import android.text.InputType
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -47,19 +46,6 @@ class SshKeyGenFragment : Fragment() {
generate.setOnClickListener { generate.setOnClickListener {
lifecycleScope.launch { generate(passphrase.text.toString(), comment.text.toString()) } lifecycleScope.launch { generate(passphrase.text.toString(), comment.text.toString()) }
} }
showPassphrase.setOnCheckedChangeListener { _, isChecked: Boolean ->
val selection = passphrase.selectionEnd
if (isChecked) {
passphrase.inputType = (
InputType.TYPE_CLASS_TEXT
or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD)
} else {
passphrase.inputType = (
InputType.TYPE_CLASS_TEXT
or InputType.TYPE_TEXT_VARIATION_PASSWORD)
}
passphrase.setSelection(selection)
}
keyLengthGroup.check(R.id.key_length_4096) keyLengthGroup.check(R.id.key_length_4096)
keyLengthGroup.addOnButtonCheckedListener { _, checkedId, isChecked -> keyLengthGroup.addOnButtonCheckedListener { _, checkedId, isChecked ->
if (isChecked) { if (isChecked) {
@ -82,10 +68,9 @@ class SshKeyGenFragment : Fragment() {
// ShowSshKeyFragment which displays the public key. // ShowSshKeyFragment which displays the public key.
private suspend fun generate(passphrase: String, comment: String) { private suspend fun generate(passphrase: String, comment: String) {
binding.generate.text = getString(R.string.ssh_key_gen_generating_progress) binding.generate.text = getString(R.string.ssh_key_gen_generating_progress)
val jsch = JSch()
val e = try { val e = try {
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
val kp = KeyPair.genKeyPair(jsch, KeyPair.RSA, keyLength) val kp = KeyPair.genKeyPair(JSch(), KeyPair.RSA, keyLength)
var file = File(requireActivity().filesDir, ".ssh_key") var file = File(requireActivity().filesDir, ".ssh_key")
var out = FileOutputStream(file, false) var out = FileOutputStream(file, false)
if (passphrase.isNotEmpty()) { if (passphrase.isNotEmpty()) {

View file

@ -33,15 +33,6 @@
app:layout_constraintTop_toBottomOf="@id/server_label" app:layout_constraintTop_toBottomOf="@id/server_label"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="@+id/clone_protocol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/server_label"
app:layout_constraintStart_toEndOf="@id/label_server_protocol" />
<com.google.android.material.button.MaterialButtonToggleGroup <com.google.android.material.button.MaterialButtonToggleGroup
style="@style/TextAppearance.MaterialComponents.Headline1" style="@style/TextAppearance.MaterialComponents.Headline1"
android:id="@+id/clone_protocol_group" android:id="@+id/clone_protocol_group"
@ -54,26 +45,18 @@
app:singleSelection="true"> app:singleSelection="true">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="?attr/materialButtonOutlinedStyle"
android:id="@+id/clone_protocol_ssh" android:id="@+id/clone_protocol_ssh"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/clone_protocol_ssh" android:text="@string/clone_protocol_ssh" />
android:textColor="?android:attr/textColorPrimary"
app:rippleColor="@color/ripple_color"
app:strokeColor="?attr/colorSecondary"
app:backgroundTint="@color/toggle_button_selector" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="?attr/materialButtonOutlinedStyle"
android:id="@+id/clone_protocol_https" android:id="@+id/clone_protocol_https"
style="?attr/materialButtonOutlinedStyle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/clone_protocol_https" android:text="@string/clone_protocol_https" />
android:textColor="?android:attr/textColorPrimary"
app:rippleColor="@color/ripple_color"
app:strokeColor="?attr/colorSecondary"
app:backgroundTint="@color/toggle_button_selector" />
</com.google.android.material.button.MaterialButtonToggleGroup> </com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
@ -160,7 +143,7 @@
android:id="@+id/connection_mode_group" android:id="@+id/connection_mode_group"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@id/label_connection_mode" app:layout_constraintTop_toBottomOf="@id/label_connection_mode"
app:layout_constraintStart_toStartOf="parent"> app:layout_constraintStart_toStartOf="parent">
@ -168,38 +151,39 @@
android:id="@+id/connection_mode_ssh_key" android:id="@+id/connection_mode_ssh_key"
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 <RadioButton
android:id="@+id/connection_mode_password" android:id="@+id/connection_mode_password"
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 <RadioButton
android:id="@+id/connection_mode_open_keychain" android:id="@+id/connection_mode_open_keychain"
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" />
<RadioButton <RadioButton
android:id="@+id/connection_mode_none" android:id="@+id/connection_mode_none"
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_none" /> android:text="@string/connection_mode_none" />
</RadioGroup> </RadioGroup>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/save_button" android:id="@+id/save_button"
android:text="@string/crypto_save" android:text="@string/crypto_save"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?android:attr/windowBackground"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:backgroundTint="?attr/colorSecondary"
app:layout_constraintTop_toBottomOf="@id/connection_mode_group" app:layout_constraintTop_toBottomOf="@id/connection_mode_group"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>

View file

@ -45,14 +45,11 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/save_button" android:id="@+id/save_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:text="@string/crypto_save" android:text="@string/crypto_save"
android:textColor="?android:attr/windowBackground"
app:backgroundTint="?attr/colorSecondary"
app:layout_constraintTop_toBottomOf="@id/email_input_layout" app:layout_constraintTop_toBottomOf="@id/email_input_layout"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintEnd_toEndOf="parent"/>
@ -88,25 +85,19 @@
tools:text="HASH"/> tools:text="HASH"/>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/git_abort_rebase" android:id="@+id/git_abort_rebase"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:text="@string/abort_rebase" android:text="@string/abort_rebase"
android:textColor="?android:attr/windowBackground"
app:backgroundTint="?attr/colorSecondary"
app:layout_constraintTop_toBottomOf="@id/commit_hash_label" /> app:layout_constraintTop_toBottomOf="@id/commit_hash_label" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/git_reset_to_remote" android:id="@+id/git_reset_to_remote"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:text="@string/reset_to_remote" android:text="@string/reset_to_remote"
android:textColor="?android:attr/windowBackground"
app:backgroundTint="?attr/colorSecondary"
app:layout_constraintTop_toBottomOf="@id/git_abort_rebase" /> app:layout_constraintTop_toBottomOf="@id/git_abort_rebase" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -95,15 +95,12 @@
android:typeface="monospace" /> android:typeface="monospace" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/crypto_password_toggle_show" android:id="@+id/crypto_password_toggle_show"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="?android:attr/windowBackground"
android:text="@string/show_password" android:text="@string/show_password"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@id/crypto_password_show_label" app:layout_constraintTop_toBottomOf="@id/crypto_password_show_label" />
app:backgroundTint="?attr/colorSecondary"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -53,14 +53,11 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/generate_password" android:id="@+id/generate_password"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="8dp" android:layout_margin="8dp"
android:text="@string/pwd_generate_button" android:text="@string/pwd_generate_button"
android:textColor="?android:attr/windowBackground"
app:backgroundTint="?attr/colorSecondary"
app:layout_constraintTop_toBottomOf="@id/password_input_layout" app:layout_constraintTop_toBottomOf="@id/password_input_layout"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintEnd_toEndOf="parent"/>

View file

@ -59,14 +59,11 @@
android:layout_weight="1"/> android:layout_weight="1"/>
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="+" android:text="+"
android:id="@+id/matchButton" android:id="@+id/matchButton"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:textColor="?android:attr/windowBackground"
app:backgroundTint="?attr/colorSecondary"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<RadioButton <RadioButton

View file

@ -25,32 +25,25 @@
app:selectionRequired="true" app:selectionRequired="true"
app:singleSelection="true"> app:singleSelection="true">
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="?attr/materialButtonOutlinedStyle"
android:id="@+id/key_length_2048" android:id="@+id/key_length_2048"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/key_length_2048"
android:textColor="?android:attr/textColorPrimary"
app:rippleColor="@color/ripple_color"
app:strokeColor="?attr/colorSecondary"
app:backgroundTint="@color/toggle_button_selector" />
<com.google.android.material.button.MaterialButton
style="?attr/materialButtonOutlinedStyle" style="?attr/materialButtonOutlinedStyle"
android:id="@+id/key_length_4096"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/key_length_4096" android:text="@string/key_length_2048" />
android:textColor="?android:attr/textColorPrimary" <com.google.android.material.button.MaterialButton
app:rippleColor="@color/ripple_color" android:id="@+id/key_length_4096"
app:strokeColor="?attr/colorSecondary" style="?attr/materialButtonOutlinedStyle"
app:backgroundTint="@color/toggle_button_selector" /> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/key_length_4096" />
</com.google.android.material.button.MaterialButtonToggleGroup> </com.google.android.material.button.MaterialButtonToggleGroup>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:hint="@string/ssh_keygen_passphrase"> android:hint="@string/ssh_keygen_passphrase"
app:endIconMode="password_toggle">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/passphrase" android:id="@+id/passphrase"
@ -61,14 +54,6 @@
android:inputType="textPassword" /> android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/show_passphrase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checked="false"
android:text="@string/ssh_keygen_show_passphrase" />
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -84,12 +69,10 @@
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/generate" android:id="@+id/generate"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:text="@string/ssh_keygen_generate" android:text="@string/ssh_keygen_generate" />
android:textColor="@android:color/white"
app:backgroundTint="?attr/colorSecondary" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>

View file

@ -42,37 +42,27 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginEnd="@dimen/activity_horizontal_margin" android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:textAllCaps="true"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:id="@+id/use_local_directory" android:id="@+id/use_local_directory"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="createNewRepository" android:onClick="createNewRepository"
android:textColor="@android:color/white"
android:text="@string/initialize" android:text="@string/initialize"
android:textSize="12sp" android:textSize="12sp"
android:layout_marginTop="48dp" android:layout_marginTop="48dp"
app:backgroundTint="?attr/colorSecondary"
app:rippleColor="?attr/colorControlHighlight"
app:layout_constraintTop_toBottomOf="@id/app_name" app:layout_constraintTop_toBottomOf="@id/app_name"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent" />
tools:ignore="UnusedAttribute" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:onClick="cloneExistingRepository" android:onClick="cloneExistingRepository"
android:textColor="@android:color/white"
android:text="@string/clone" android:text="@string/clone"
android:textSize="12sp" android:textSize="12sp"
app:backgroundTint="?attr/colorSecondary"
app:rippleColor="?attr/colorControlHighlight"
app:layout_constraintTop_toBottomOf="@id/use_local_directory" app:layout_constraintTop_toBottomOf="@id/use_local_directory"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />

View file

@ -19,11 +19,25 @@
<item name="actionModeStyle">@style/ActionMode</item> <item name="actionModeStyle">@style/ActionMode</item>
<item name="alertDialogTheme">@style/AppTheme.Dialog</item> <item name="alertDialogTheme">@style/AppTheme.Dialog</item>
<item name="materialAlertDialogTheme">@style/AppTheme.Dialog</item> <item name="materialAlertDialogTheme">@style/AppTheme.Dialog</item>
<item name="actionBarPopupTheme">@style/ThemeOverlay.MaterialComponents.ActionBar</item> <item name="materialButtonStyle">@style/AppTheme.MaterialButton</item>
<item name="materialButtonOutlinedStyle">@style/AppTheme.OutlinedButton</item>
<item name="textInputStyle">@style/TextInputLayoutBase</item> <item name="textInputStyle">@style/TextInputLayoutBase</item>
<item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item> <item name="bottomSheetDialogTheme">@style/BottomSheetDialogTheme</item>
</style> </style>
<style name="AppTheme.MaterialButton" parent="Widget.MaterialComponents.Button">
<item name="android:textColor">@android:color/white</item>
<item name="backgroundTint">?attr/colorSecondary</item>
<item name="rippleColor">?attr/colorControlHighlight</item>
</style>
<style name="AppTheme.OutlinedButton" parent="Widget.MaterialComponents.Button.OutlinedButton">
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="rippleColor">@color/ripple_color</item>
<item name="strokeColor">?attr/colorSecondary</item>
<item name="backgroundTint">@color/toggle_button_selector</item>
</style>
<style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog.Alert"> <style name="AppTheme.Dialog" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
<item name="colorPrimary">@color/secondary_color</item> <item name="colorPrimary">@color/secondary_color</item>
<item name="colorSecondary">@color/secondary_color</item> <item name="colorSecondary">@color/secondary_color</item>