Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Rename text selection method. Clean up padding on item detail card view.
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Richards committed Nov 21, 2019
1 parent 24c4a24 commit 88297cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface EditItemDetailView {
fun displayUsernameError(@StringRes errorMessage: Int? = null)
fun displayPasswordError(@StringRes errorMessage: Int? = null)
fun setSaveEnabled(enabled: Boolean)
fun setTextSelectionOnPasswordToggle()
fun setTextSelectionToEndOfLine()
}

@ExperimentalCoroutinesApi
Expand Down Expand Up @@ -133,13 +133,13 @@ class EditItemPresenter(
dispatcher.dispatch(
ItemDetailAction.SetPasswordVisibility(view.isPasswordVisible.not())
)
view.setTextSelectionOnPasswordToggle()
view.setTextSelectionToEndOfLine()
}
.addTo(compositeDisposable)

view.usernameFieldClicks
.subscribe {
view.setTextSelectionOnPasswordToggle()
view.setTextSelectionToEndOfLine()
}
.addTo(compositeDisposable)

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/mozilla/lockbox/view/EditItemFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,10 @@ class EditItemFragment : BackableFragment(), EditItemDetailView {
}
}

override fun setTextSelectionOnPasswordToggle() {
/**
* Ensure that the text selector is at the end of the line when password visibility is toggled.
*/
override fun setTextSelectionToEndOfLine() {
view?.inputPassword?.setSelection(view?.inputPassword?.length() ?: 0)
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_item_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
android:layout_height="wrap_content"
android:paddingTop="26dp"
android:paddingEnd="14dp"
android:paddingBottom="26dp"
android:paddingBottom="36dp"
tools:ignore="RtlSymmetry">

<androidx.constraintlayout.widget.ConstraintLayout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ class EditItemPresenterTest {
_saveEnabled = enabled
}

override fun setTextSelectionOnPasswordToggle() {
override fun setTextSelectionToEndOfLine() {
// make sure the text selector is at the end of the line when password is toggled
// or a field is selected
// NOOP
}
}
Expand Down

0 comments on commit 88297cf

Please sign in to comment.