mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Unique password field with password generator button
This commit is contained in:
@@ -118,6 +118,9 @@ class EntryEditActivity : LockingActivity(),
|
||||
.show(supportFragmentManager, "DatePickerFragment")
|
||||
}
|
||||
}
|
||||
entryEditContentsView?.entryPasswordGeneratorView?.setOnClickListener {
|
||||
openPasswordGenerator()
|
||||
}
|
||||
|
||||
lockView = findViewById(R.id.lock_button)
|
||||
lockView?.setOnClickListener {
|
||||
@@ -229,10 +232,6 @@ class EntryEditActivity : LockingActivity(),
|
||||
|
||||
setOnMenuItemClickListener { item ->
|
||||
when (item.itemId) {
|
||||
R.id.menu_generate_password -> {
|
||||
openPasswordGenerator()
|
||||
true
|
||||
}
|
||||
R.id.menu_add_field -> {
|
||||
addNewCustomField()
|
||||
true
|
||||
@@ -437,7 +436,7 @@ class EntryEditActivity : LockingActivity(),
|
||||
}
|
||||
|
||||
private fun performedNextEducation(entryEditActivityEducation: EntryEditActivityEducation) {
|
||||
val passwordGeneratorView: View? = entryEditAddToolBar?.findViewById(R.id.menu_generate_password)
|
||||
val passwordGeneratorView: View? = entryEditContentsView?.entryPasswordGeneratorView
|
||||
val generatePasswordEducationPerformed = passwordGeneratorView != null
|
||||
&& entryEditActivityEducation.checkAndPerformedGeneratePasswordEducation(
|
||||
passwordGeneratorView,
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
@@ -51,7 +52,7 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
private val entryUrlView: EditText
|
||||
private val entryPasswordLayoutView: TextInputLayout
|
||||
private val entryPasswordView: EditText
|
||||
private val entryConfirmationPasswordView: EditText
|
||||
val entryPasswordGeneratorView: View
|
||||
private val entryExpiresCheckBox: CompoundButton
|
||||
private val entryExpiresTextView: TextView
|
||||
private val entryNotesView: EditText
|
||||
@@ -80,7 +81,7 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
entryUrlView = findViewById(R.id.entry_edit_url)
|
||||
entryPasswordLayoutView = findViewById(R.id.entry_edit_container_password)
|
||||
entryPasswordView = findViewById(R.id.entry_edit_password)
|
||||
entryConfirmationPasswordView = findViewById(R.id.entry_edit_confirmation_password)
|
||||
entryPasswordGeneratorView = findViewById(R.id.entry_edit_password_generator_button)
|
||||
entryExpiresCheckBox = findViewById(R.id.entry_edit_expires_checkbox)
|
||||
entryExpiresTextView = findViewById(R.id.entry_edit_expires_text)
|
||||
entryNotesView = findViewById(R.id.entry_edit_notes)
|
||||
@@ -148,10 +149,8 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
}
|
||||
set(value) {
|
||||
entryPasswordView.setText(value)
|
||||
entryConfirmationPasswordView.setText(value)
|
||||
if (fontInVisibility) {
|
||||
entryPasswordView.applyFontVisibility()
|
||||
entryConfirmationPasswordView.applyFontVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,14 +252,6 @@ class EntryEditContentsView @JvmOverloads constructor(context: Context,
|
||||
* @return ErrorValidation An error with a message or a validation without message
|
||||
*/
|
||||
fun isValid(): Boolean {
|
||||
// Validate password
|
||||
if (entryPasswordView.text.toString() != entryConfirmationPasswordView.text.toString()) {
|
||||
entryPasswordLayoutView.error = context.getString(R.string.error_pass_match)
|
||||
return false
|
||||
} else {
|
||||
entryPasswordLayoutView.error = null
|
||||
}
|
||||
|
||||
// Validate extra fields
|
||||
entryExtraFieldsContainer.let {
|
||||
try {
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:contentDescription="@string/content_description_repeat_toggle_password_visibility"
|
||||
app:passwordToggleEnabled="true"
|
||||
app:passwordToggleTint="?attr/colorAccent">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
app:passwordToggleEnabled="true"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
app:layout_constraintEnd_toStartOf="@+id/entry_edit_password_generator_button">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/entry_edit_password"
|
||||
android:layout_width="match_parent"
|
||||
@@ -104,31 +104,19 @@
|
||||
android:inputType="textPassword"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:maxLines="1"
|
||||
android:maxLines="10"
|
||||
android:hint="@string/entry_password"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<!-- Confirm Password -->
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/entry_edit_container_confirmation_password"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/entry_edit_container_password"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/entry_edit_password_generator_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:passwordToggleEnabled="true"
|
||||
android:contentDescription="@string/content_description_repeat_toggle_password_visibility">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/entry_edit_confirmation_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="textPassword"
|
||||
android:importantForAccessibility="no"
|
||||
android:importantForAutofill="no"
|
||||
android:maxLines="1"
|
||||
android:hint="@string/entry_confpassword"/>
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
android:src="@drawable/ic_generate_password_white_24dp"
|
||||
android:contentDescription="@string/generate_password"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!-- URL -->
|
||||
|
||||
@@ -38,9 +38,4 @@
|
||||
android:title="@string/entry_setup_otp"
|
||||
android:orderInCategory="94"
|
||||
app:showAsAction="always" />
|
||||
<item android:id="@+id/menu_generate_password"
|
||||
android:icon="@drawable/ic_generate_password_white_24dp"
|
||||
android:title="@string/entry_password_generator"
|
||||
android:orderInCategory="95"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
||||
|
||||
Reference in New Issue
Block a user