Skip to content
Merged
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 @@ -23,6 +23,7 @@ import android.view.Gravity
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputConnection
Expand Down Expand Up @@ -596,6 +597,9 @@ internal class SelectionAwareEditText(
var maxInputChars = Int.MAX_VALUE
var clipboardFragment = ""

// Keeps autofill services such as SMS verification codes from writing into the draft.
override fun getAutofillType(): Int = View.AUTOFILL_TYPE_NONE

/**
* Editable TextView hints do not ellipsize, so long placeholders wrap and grow the composer.
* Truncate the hint to the measured width instead.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@ class ComposerPasteTest {
assertNull(intercepted)
}

@Test
fun autofillCannotWriteIntoTheDraft() {
assertEquals(
"Autofill services such as SMS verification codes must not target the composer",
View.AUTOFILL_TYPE_NONE,
editor.autofillType,
)
}

private fun dropEditor(): SelectionAwareEditText {
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
return SelectionAwareEditText(activity).apply {
Expand Down
Loading