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

Commit

Permalink
Fixup no-username bugs (crash and string change) (#496)
Browse files Browse the repository at this point in the history
* Fix crash on ItemDetail screen with no username logins.

* Use correct strings for no username in autofill.
  • Loading branch information
jhugman authored and Elise Richards committed Mar 12, 2019
1 parent 807c4f9 commit f929df2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,26 @@ open class FillResponseBuilder(
val datasetBuilder = Dataset.Builder()

val title = titleFromHostname(credential.hostname)
val username = credential.username ?: context.getString(R.string.no_username)

parsedStructure.usernameId?.let {
val presentation = RemoteViews(context.packageName, R.layout.autofill_item)
.apply {
setTextViewText(R.id.autofillValue, credential.username)
setTextViewText(R.id.autofillValue, username)
setTextViewText(R.id.hostname, title)
}

datasetBuilder.setValue(
it,
AutofillValue.forText(credential.username),
AutofillValue.forText(credential.username ?: ""),
presentation
)
}

parsedStructure.passwordId?.let {
val presentation = RemoteViews(context.packageName, R.layout.autofill_item)
.apply {
setTextViewText(R.id.autofillValue, context.getString(R.string.password_for, credential.username))
setTextViewText(R.id.autofillValue, context.getString(R.string.password_for, username))
setTextViewText(R.id.hostname, title)
}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/mozilla/lockbox/view/ItemDetailFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ class ItemDetailFragment : BackableFragment(), ItemDetailView {
inputUsername.readOnly = true

if (!item.hasUsername) {
inputUsername.btnUsernameCopy.setColorFilter(resources.getColor(R.color.white_60_percent))
btnUsernameCopy.setColorFilter(resources.getColor(R.color.white_60_percent, null))
inputUsername.isClickable = false
inputUsername.isFocusable = false
inputUsername.setText(R.string.empty_space, TextView.BufferType.NORMAL)
} else {
btnUsernameCopy.clearColorFilter()
inputUsername.isClickable = true
inputUsername.isFocusable = true
inputUsername.setText(item.username, TextView.BufferType.NORMAL)
Expand Down

0 comments on commit f929df2

Please sign in to comment.