PhoneNumberKit icon indicating copy to clipboard operation
PhoneNumberKit copied to clipboard

MaskedTextChangedListener implementation bug

Open derkicker opened this issue 3 years ago • 2 comments

Came across an issue with mask format. When a textChangedListener is installed on a text edit it uses number example to make a mask. Problem is that number example is just on of the possible variants of the input so using it for the mask restricts from another valid input of different format.

Example: Indonesian mobile number + 62 812 111-222-33 which is perfectly valid, it's number pattern in the google lib is 8[1-35-9]\d{7,10}. It's impossible to input the whole number because textChangedListener uses short variant of mask +[00] [000]-[000]-[000] so it allows only + 62 812 111-222.

The workaround is using a widest possible mask format i guess.

derkicker avatar Nov 14 '21 19:11 derkicker

Hi @derkicker do you have any suggestion to cover that case? As far as I know lilphonenumber provides just 1 sample number for the given country code.

ibrahimsn98 avatar Nov 14 '21 20:11 ibrahimsn98

Hi @ibrahimsn98! I'd suggest using possibleLengths block from resources:

image image

So we could get max value from mobile.possibleLength_ and compose a mask of that length

derkicker avatar Nov 15 '21 10:11 derkicker