Hello everybody, I would like to replace the defa...
# android
z
Hello everybody, I would like to replace the default password mask by a custom drawable, with a delay on the last character so that the user can see the last character before it is replaced by the drawable. So far I managed to replace all the character by the drawable. However, I cannot add a delay. The last character is automatically replaced by the drawable. I have been trying with a coroutines but it does not change anything. The TextWatcher on the EditText:
Copy code
paswword.addTextChangedListener(object : TextWatcher {
            
            override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {}

            override fun onTextChanged(p0: CharSequence?, start: Int, before: Int, count: Int) {}

            override fun afterTextChanged(source: Editable?) {

                val passwordDotDrawable = resources.getDrawable(R.drawable.password_dot)
                passwordDotDrawable.setBounds(0, 0, 49, 49)
                
                val spannableTag = Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
                
                source?.forEachIndexed { index, char ->
                    val image = ImageSpan(passwordDotDrawable, ImageSpan.ALIGN_CENTER)
                    if (index < source.lastIndex) {
                        source.setSpan(image, index, index + 1, spannableTag)
                    } else if (index == source.lastIndex) {
                        CoroutineScope(Dispatchers.Main).launch {
                            delay(1000L)
                            source.setSpan(image, source.lastIndex, source.length, spannableTag)
                        }
                    }

                }

            }
        })
Thank you in advance for your help