Skip to content

allow to add autofill domain info into text input #5774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,8 @@ class BrowserTabFragment :

val authDialogBinding = HttpAuthenticationBinding.inflate(layoutInflater)
authDialogBinding.httpAuthInformationText.text = getString(R.string.authenticationDialogMessage, request.site)
authDialogBinding.usernameInput.setAutofillDomain(request.site)
authDialogBinding.passwordInput.setAutofillDomain(request.site)
CustomAlertDialogBuilder(requireActivity())
.setPositiveButton(R.string.authenticationDialogPositiveButton)
.setNegativeButton(R.string.authenticationDialogNegativeButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import android.util.AttributeSet
import android.util.SparseArray
import android.view.View
import android.view.View.OnFocusChangeListener
import android.view.ViewStructure
import android.view.inputmethod.EditorInfo
import android.widget.TextView.OnEditorActionListener
import androidx.annotation.DrawableRes
Expand Down Expand Up @@ -102,6 +103,7 @@ class DaxTextInput @JvmOverloads constructor(
private var isPasswordShown: Boolean = false
private var isClickable: Boolean = false
private var internalFocusChangedListener: OnFocusChangeListener? = null
private var autofillDomain: String = ""

init {
context.obtainStyledAttributes(
Expand Down Expand Up @@ -226,6 +228,20 @@ class DaxTextInput @JvmOverloads constructor(
}
}

fun setAutofillDomain(domain: String) {
this.autofillDomain = domain
}

override fun onProvideAutofillStructure(
structure: ViewStructure?,
flags: Int,
) {
super.onProvideAutofillStructure(structure, flags)
this.autofillDomain.takeUnless { it.isBlank() }?.let {
structure?.setWebDomain(it)
}
}

private fun handleIsEditableChangeForEndIcon(isEditable: Boolean) {
if (binding.internalInputLayout.endIconMode != END_ICON_NONE) {
binding.internalInputLayout.isEndIconVisible = !isEditable
Expand Down
Loading