hbb20 / CountryCodePickerProject

Country Code Picker (CCP) is an android library which provides an easy way to search and select country or international phone code. Also supports Android EditText phone mask and international phone validation.
Apache License 2.0
1.52k stars 506 forks source link

Country nameCode are different if from XML or from code #307

Closed CmoaToto closed 5 years ago

CmoaToto commented 5 years ago

Hello,

Is there any reason why the country nameCode are in lowerCase when coming from the LibraryMasterCountriesEnglish code:

https://github.com/hbb20/CountryCodePickerProject/blob/master/ccp/src/main/java/com/hbb20/CCPCountry.java#L1412

    public static List<CCPCountry> getLibraryMasterCountriesEnglish() {
        List<CCPCountry> countries = new ArrayList<>();
        countries.add(new CCPCountry("ad", "376", "Andorra", DEFAULT_FLAG_RES));
        // ...
    }

and in uppercase when coming from XML:

https://github.com/hbb20/CountryCodePickerProject/blob/master/ccp/src/main/java/com/hbb20/CCPCountry.java#L92

    static void loadDataFromXML(Context context, CountryCodePicker.Language language) {
        // ...
                        case XmlPullParser.END_TAG:
                        if (name.equals("country")) {
                            CCPCountry ccpCountry = new CCPCountry();
                            ccpCountry.setNameCode(xmlPullParser.getAttributeValue(null, "name_code").toUpperCase());
        //...
    }

This leads to inconsistency, especially in UnitTest when there is no ressource to use to test. Am I missing something?

hbb20 commented 5 years ago

Thank you so much for catching it and reporting. There is truly no reason for that. I missed it. I will make it consistent in next version. Please allow some time.

CmoaToto commented 5 years ago

Hey @hbb20 , I had a few minutes so I leave you a PR to fix this issue. :)

CmoaToto commented 5 years ago

Merged -> Fixed