You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Set the country to "France". The hint shown is "6 12 34 56 78".
If I type "612345678", the phone number is not formatted. I have to type "0612345678" (leading 0) to have it formatted nicely.
An idea to fix the bug:
show "06 12 34 56 78" as hint
when the user type, if the first number is not "0", insert automatically a zero at the first position
Another idea:
Format the phone number either for "612345678" and "0612345678"
This is a known issue and we are looking for the solution. The fact here is, CCP uses google's libphonenumber library behind the scene. Example number for hint and text formatting while typing is handled by google library only. CCP does not do any alteration in it.
Still, we will try our best to solve this as soon as possible. If you find any solution, we will be happy to get a pull request.
private void updateHint() {
if (editText_registeredCarrierNumber != null && hintExampleNumberEnabled) {
Phonenumber.PhoneNumber exampleNumber = getPhoneUtil().getExampleNumberForType(getSelectedCountryNameCode(), getSelectedHintNumberType());
if (exampleNumber != null) {
String formattedNumber = getPhoneUtil().format(exampleNumber, PhoneNumberUtil.PhoneNumberFormat.NATIONAL);
editText_registeredCarrierNumber.setHint(formattedNumber);
Log.d(TAG, "updateHint: after format " + formattedNumber + " " + selectionMemoryTag);
} else {
Log.w(TAG, "updateHint: No example number found for this country (" + getSelectedCountryNameCode() + ") or this type (" + hintExampleNumberType.name() + ").");
}
}
}
The hint give the good results! For me but also for issue #163
It still doesn't format the number when we write it in an international way, but at least we are consistent with what is showed
We looked at the situation and realized that not all developers need number national format. Different countries follow different conventions.
For now in version 2.1.5, to get the hint in the national format we have introduced app:ccp_hintExampleNumberFormat="NATIONAL". This should give hint with leading zeros.
We understand asYouTypeFormatter should be improved in order to support other formats as well. We will be looking around for the solution.
Activity
hbb20 commentedon Mar 4, 2018
Sorry for the inconvenience,
This is a known issue and we are looking for the solution. The fact here is, CCP uses google's libphonenumber library behind the scene. Example number for hint and text formatting while typing is handled by google library only. CCP does not do any alteration in it.
Still, we will try our best to solve this as soon as possible. If you find any solution, we will be happy to get a pull request.
Flo354 commentedon Mar 5, 2018
I just looked at the file CountryCodePicker.java.
Seems to me that we can change:
formattedNumber = PhoneNumberUtils.formatNumber(formattedNumber);with:
formattedNumber = getPhoneUtil().format(exampleNumber, PhoneNumberFormat.NATIONAL);Since the user should write the number in national format, we can show the hint formatted as national number.
Flo354 commentedon Mar 5, 2018
I just tested with the following code:
The hint give the good results! For me but also for issue #163
It still doesn't format the number when we write it in an international way, but at least we are consistent with what is showed
Flo354 commentedon Mar 5, 2018
And here is a way to "force" input to be compliant with the formatting.
The goal is to check if the phone number require a leading zero:
If the phone number needs a leading 0, we insert it automatically for the user.
The modified code of CountryCodePicker.java
Hope it will help. Of course, you can modify the code.
Flo354 commentedon Mar 6, 2018
Can we expect a release including those fixes soon?
hbb20 commentedon Mar 6, 2018
Your suggestions are truly helpful. We always want to make releases as soon as possible. But we won't be able to release before next weekend.
Flo354 commentedon Mar 6, 2018
No problem for that. I just wanted some ETA ;)
Thanks,
hbb20 commentedon Mar 20, 2018
We looked at the situation and realized that not all developers need number national format. Different countries follow different conventions.
For now in version 2.1.5, to get the hint in the national format we have introduced
app:ccp_hintExampleNumberFormat="NATIONAL". This should give hint with leading zeros.We understand asYouTypeFormatter should be improved in order to support other formats as well. We will be looking around for the solution.