diff --git a/changelog.d/3545.feature b/changelog.d/3545.feature new file mode 100644 index 00000000000..f582affbf22 --- /dev/null +++ b/changelog.d/3545.feature @@ -0,0 +1 @@ +Reveal password: use facility from com.google.android.material.textfield.TextInputLayout instead of manual handling. \ No newline at end of file diff --git a/library/ui-styles/src/debug/java/im/vector/lib/ui/styles/debug/DebugVectorTextViewActivity.kt b/library/ui-styles/src/debug/java/im/vector/lib/ui/styles/debug/DebugVectorTextViewActivity.kt index ac3d4ea6964..db505001954 100644 --- a/library/ui-styles/src/debug/java/im/vector/lib/ui/styles/debug/DebugVectorTextViewActivity.kt +++ b/library/ui-styles/src/debug/java/im/vector/lib/ui/styles/debug/DebugVectorTextViewActivity.kt @@ -17,6 +17,8 @@ package im.vector.lib.ui.styles.debug import android.os.Bundle +import android.text.InputType +import android.widget.EditText import androidx.appcompat.app.AppCompatActivity import im.vector.lib.ui.styles.databinding.ActivityDebugTextViewBinding @@ -27,5 +29,20 @@ abstract class DebugVectorTextViewActivity : AppCompatActivity() { super.onCreate(savedInstanceState) val views = ActivityDebugTextViewBinding.inflate(layoutInflater) setContentView(views.root) + + views.debugShowPassword.setOnClickListener { + views.debugTextInputEditText.showPassword(true) + } + views.debugHidePassword.setOnClickListener { + views.debugTextInputEditText.showPassword(false) + } + } + + private fun EditText.showPassword(visible: Boolean) { + if (visible) { + inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD + } else { + inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_VARIATION_PASSWORD + } } } diff --git a/library/ui-styles/src/debug/res/layout/activity_debug_text_view.xml b/library/ui-styles/src/debug/res/layout/activity_debug_text_view.xml index 0c16f889ec3..1b38f04b979 100644 --- a/library/ui-styles/src/debug/res/layout/activity_debug_text_view.xml +++ b/library/ui-styles/src/debug/res/layout/activity_debug_text_view.xml @@ -1,9 +1,11 @@ + + + + + + +