Disable autofill for PIN entry fields.

This commit is contained in:
jeffrey-signal
2025-09-16 09:31:19 -04:00
committed by Greyson Parrelli
parent 6d90330e86
commit 5807cbc9e9
11 changed files with 31 additions and 10 deletions

View File

@@ -0,0 +1,21 @@
/*
* Copyright 2025 Signal Messenger, LLC
* SPDX-License-Identifier: AGPL-3.0-only
*/
package org.thoughtcrime.securesms.components
import android.content.Context
import android.util.AttributeSet
import com.google.android.material.textfield.TextInputEditText
/**
* An EditText that completely disables Android's auto-fill functionality.
*/
class NoAutofillEditText : TextInputEditText {
constructor(context: Context) : super(context, null)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
override fun getAutofillType(): Int = AUTOFILL_TYPE_NONE
}

View File

@@ -205,7 +205,7 @@ class ChangeNumberRegistrationLockFragment : LoggingFragment(R.layout.fragment_c
private fun onIncorrectKbsRegistrationLockPin(svrTriesRemaining: Int) {
binding.kbsLockPinConfirm.cancelSpinning()
binding.kbsLockPinInput.getText().clear()
binding.kbsLockPinInput.getText()?.clear()
enableAndFocusPinEntry()
if (svrTriesRemaining == 0) {

View File

@@ -29,7 +29,7 @@ enum class PinKeyboardType(val code: String) {
private val inputType: Int by lazy {
when (this) {
NUMERIC -> InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
ALPHA_NUMERIC -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
ALPHA_NUMERIC -> InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD
}
}

View File

@@ -185,7 +185,7 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
private fun onIncorrectKbsRegistrationLockPin(svrTriesRemaining: Int) {
binding.kbsLockPinConfirm.cancelSpinning()
binding.kbsLockPinInput.getText().clear()
binding.kbsLockPinInput.getText()?.clear()
enableAndFocusPinEntry()
if (svrTriesRemaining == 0) {

View File

@@ -185,7 +185,7 @@ class RegistrationLockFragment : LoggingFragment(R.layout.fragment_registration_
private fun onIncorrectKbsRegistrationLockPin(svrTriesRemaining: Int) {
binding.kbsLockPinConfirm.cancelSpinning()
binding.kbsLockPinInput.getText().clear()
binding.kbsLockPinInput.getText()?.clear()
enableAndFocusPinEntry()
if (svrTriesRemaining == 0) {

View File

@@ -63,7 +63,7 @@
app:layout_constraintTop_toBottomOf="@+id/edit_kbs_pin_description"
app:materialThemeOverlay="@style/Signal.ThemeOverlay.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/edit_kbs_pin_input"
style="@style/Widget.MaterialComponents.TextInputEditText.FilledBox"
android:layout_width="match_parent"

View File

@@ -35,7 +35,7 @@
android:textColor="@color/signal_text_secondary"
app:layout_constraintTop_toBottomOf="@id/kbs_lock_pin_title" />
<EditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/kbs_lock_pin_input"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -54,7 +54,7 @@
app:layout_constraintTop_toBottomOf="@+id/pin_restore_pin_description"
app:materialThemeOverlay="@style/Signal.ThemeOverlay.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/pin_restore_pin_input"
style="@style/Widget.MaterialComponents.TextInputEditText.FilledBox"
android:layout_width="match_parent"

View File

@@ -21,7 +21,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -34,7 +34,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/reminder_disable_title" />
<EditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/reminder_disable_pin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@@ -55,7 +55,7 @@
app:layout_constraintTop_toBottomOf="@+id/pin_restore_pin_description"
app:materialThemeOverlay="@style/Signal.ThemeOverlay.TextInputLayout">
<com.google.android.material.textfield.TextInputEditText
<org.thoughtcrime.securesms.components.NoAutofillEditText
android:id="@+id/pin_restore_pin_input"
style="@style/Widget.MaterialComponents.TextInputEditText.FilledBox"
android:layout_width="match_parent"