Git Product home page Git Product logo

countrycodepicker's Introduction

Android Arsenal

Country Code Picker Library

Country Code Picker (CCP) is an android library which provides an easy way to search and select country phone code for the telephone number.

Introduction

  • CCP gives professional touch to your well designed form like login screen, sign up screen, edit profile screen. CCP removes confusion about how to add number and thus make view more understandable. Finally reduces mistakes in user input.

  • Phone number screen without CCP

  • Above view can be transformed by using CCP

  • Tapping on CCP will open a dialog to search and select country

The most recommended usage for CCP is using the default setting so the library will auto check the all the value. To do that, you need to follow the following steps:

  1. Add CCP view to layout
  2. Add EditText view to layout
  3. register the EditText using registerPhoneNumberTextView(editText) we can also use TextView instead of editText.
  4. Let the magic happens ;)

Here the more details steps:

  1. Add CCP to layout using the following:

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
          android:id="@+id/ccp"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />
  2. Add EditText view to layout:

    <EditText
           android:id="@+id/phone_number_edt"
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:hint="phone"
           android:inputType="phone"/>
  3. register the EditText with code:

    CountryCodePicker ccp;
    AppCompatEditText edtPhoneNumber;
    
    ...
    
    ccp = (CountryCodePicker) findViewById(R.id.ccp);
    edtPhoneNumber = findViewById(R.id.phone_number_edt);
    
    ...
    
    ccp.registerPhoneNumberTextView(edtPhoneNumber);
  4. Now look at the magic ;)

you can check validity of phone number using isValid() method.

How to add to your project

  1. Add jitpack.io to your root build.gradle file:

    allprojects {
        repositories {
            jcenter()
            maven { url "https://jitpack.io" }
        }
    }
  2. Add library to your app build.gradle file then sync

    dependencies {
        implementation 'com.github.joielechong:countrycodepicker:2.4.2'
    }
  3. Add ccp view to xml layout

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
          android:id="@+id/ccp"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />
  4. Add ccp object in Activity / Fragment

    CountryCodePicker ccp;
    
  5. Bind ccp from layout

    ccp = (CountryCodePicker) findViewById(R.id.ccp);
    
  6. That's it. Run the project and see the results.

For DexGuard users

If your project is obfuscated with DexGuard you may need to add the following line to the DexGuard configuration:

  -keepresourcefiles assets/io/michaelrocks/libphonenumber/android/**

This is because this library use libphonenumber-android

Attributes

Here the attributes that can be used in CountryCodePicker layout:

Attribute method Description
ccp_defaultCode setDefaultCountryUsingPhoneCodeAndApply(int defaultCode) set selected Flag and phone in CCP by phone code.
ccp_showFullName showFullName(boolean show) Show full name of country in CCP. Default is false
ccp_hideNameCode hideNameCode(boolean hide) Hide the country name code. Default is false
ccp_hidePhoneCode hidePhoneCode(boolean hide) Hide the phone code. Default is false

TBD.

Features

If you prefer experience along with only reads, an demo android app is available that demonstrates all the features of this library. Click below button to download from Playstore.

If you just want to read them, here you go:

1. Default country

  • Default country is the country where most of your target audience belong.

  • The default country can be set through xml layout and programmatically as well.

    A. Through xml

    Using country code name

    Add app:ccp_defaultNameCode="US" (replace "US" with your default country name code) to xml layout. Refer List of countries for name codes.

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_defaultNameCode="US"  />
    Using phone code
    • add app:ccp_defaultCode="81" (replace 81 with your default country code) to xml layout.Refer List of countries for country codes.

    • Setting default country using phone code is not recommended. There are few cases where more than one countries have same phone code. Say US and Canada have +1. Putting '1' will result in Canada even if you were intended for US. Use app:cpp_defaultNameCode or app:cpp_countryPreference to overcome issue.

      <com.rilixtech.widget.countrycodepicker.CountryCodePicker
            android:id="@+id/ccp"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:ccp_defaultCode="81" />

      app:ccp_defaultNameCode has higher priority than app:ccp_defaultCode.

    B. Programmatically

    Using country name code

    Use setDefaultCountryUsingNameCode() method.

    Using phone code
    • To set default country programmatically, use setDefaultCountryUsingPhoneCode() method.

    • setDefaultCountryUsingNameCode() or setDefaultCountryUsingPhoneCode() will not set default country as selected country in CCP view. To set default country as selected country in CCP view, call resetToDefaultCountry() method.

    • resetToDefaultCountry() will set default country as selected country in CCP, it can be used at the time of form reset.

    • If you do not specify default country from xml, ID +91 (Indonesia) will be the default country until you update default country programmatically.

2. Choose and set country

Choosing and setting country will update selected country in CCP view.

Choose Country

  1. In order to choose country, click on CCP view.
  2. Then search country by country name or phone code or name code in dialog.
  3. Click on county from list to choose

Set country programmatically

Using country code name
Country in CCP can be using setCountryForNameCode() method.

Using phone code

  • Country in CCP can be using setCountryForCode() method.
  • If specified country code / name code does not match with any country, default country will be set in to CCP.

How to listen change in selection? To get call back when country is changed, you need to add OnCountryChangeListener from code.

ccp.setOnCountryChangeListener(new CountryCodePicker.OnCountryChangeListener() {
 	 @Override
 	 public void onCountrySelected(Country selectedCountry) {
 	     Toast.makeText(getContext(), "Updated " + selectedCountry.getName(), Toast.LENGTH_SHORT).show();
      }
 });

3. Country preference

  • Library has list of countries in alphabetical order. It searches for country in same order. But preferred country/countries have higher priority than rest.

  • There are few cases where more than one countries have same code. For example, Canada, Puerto Rico and US have +1. When lilbrary will try to find country with +1, it will always pick Canada as it's alphabetically first in (1)Canada-(2)Puerto Rico-(3)US.

  • If US is set in country preference, order for search will be (1)US-(2)Canada-(3)Puerto Rico, so it will pick US for +1.

  • Countries of preference will be listed at top in selection dialog. It is helpful when target audience is from a set of countries.

  • Any number of countries can be set in preference.

  • Set through xml

    Add app:ccp_countryPreference="US,ID,NZ" (replace "US,ID,NZ" with your preference) to xml layout. Refer List of countries for name codes.

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
              android:id="@+id/ccp"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              app:ccp_countryPreference="US,ID,NZ"  />
  • Programmatically

    Use setCountryPreference() method.

4. Read selected country

Country's 3 properties (Country name, phone code and name code) can be read individually.
  • Read selected country phone code

    • To get selected country code as String type and without prefix “+”, use getSelectedCountryCode(); method. => “91”
    • To get selected country code as String type and with prefix “+”, use getSelectedCountryCodeWithPlus(); method. => “+91”
    • To get selected country code as int (Integer) type, use getSelectedCountryCodeAsInt(); method. => 91
  • Read selected country name

    To get selected country’s name, use getSelectedCountryName(); => “Indonesia”

  • Read selected country name code

    To get selected country’s name code, use getSelectedCountryNameCode(); => “ID”

5. Full number support

Full number is combination of country code and carrier number. for example, if country code is 91 and carrier number is 8866667722 then 918866667722 or +918866667722 is the full number.

  • Register phoneNumberTextView

    • CarrierNumberEditText is the supplementary editText in which carrier number part of full number is entered.
    • A carrierNumberEditText must be registered in order to work with full number.
    • editText can be registered using registerPhoneNumberTextView().
  • Load full number

    • To load full number, use setFullNumber() method. In this method you need to pass the full number.
    • Prefix “+” is optional for full number so full number can be “91886667722” or “+918866667722”. Both will set same country and carrier number."
    • This will detect country code from full number and set that county to ccp and carrier number ( remaining part of full number other than country code) will be set as text of registered carrier editText.
    • If no valid country code is found in beginning part of full number, default country will be set to CCP and full number will be set as text of registered carrier editText.
  • Get full number

    • Use getFullNumber(); for full number without “+” prefix.
    • Use getFullNumberWithPlus(); for full number with “+” prefix.
    • A phoneNumberTextView must be registered before any function call of full number like setFullNumber() or getFullNumber().
    • None of the above functions validate the number format of phone.

6. Custom text color

Color of CCP text can be changed according to different background.

  • Using XML

    Add app:ccp_textColor property to xml layout

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:ccp_textColor="@color/custom_color"/>

    You can also change the dialog text color with ccp_dialogTextColor attribute. It will be defaulting to your current theme text color.

  • Programmatically

    To set color programmatically, use setTextColor() method.

    You can also change the dialog text color with setDialogTextColor() method.

7. Custom background color

CCP background color can be set to any custom color. It will be defaulting to application theme if not set up.

  • Using XML

    Add app:ccp_backgroundColor property to xml layout

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:ccp_backgroundColor="@color/custom_color"/>
  • Programmatically

    To set color programmatically, use setBackgroundColor() method.

8. Custom textSize

  • Text size of CCP content can be changed in order to match rest of the view of form.
  • Everytime when textSize is updated, arrowsize will be updated itself.

  • Using XML

    Add app:ccp_textSize property to xml layout

     <com.rilixtech.widget.countrycodepicker.CountryCodePicker
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               app:ccp_textSize="26sp"/>
  • Programmatically

    To set textSize programmatically, use setTextSize() method.

9. Custom arrow size

Size if Down arrow of CCP view can be modified in order to match rest of the view of form.

  • Using XML

    Add app:ccp_arrowSize property to xml layout

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:ccp_arrowSize="26sp"/>
  • Programmatically

To set arrow size programmatically, use setArrowSize() method.

10. Hide country name code

By default, text of CCP contains country's name code. i.e "(US) +1". Country name code can be removed if required.

  • Using XML

    Add app:ccp_hideCodeName property to xml layout

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          app:ccp_hideNameCode="true"/>
  • Programmatically

    To hide name code programmatically, use hideNameCode() method.

11. Custom master country list

  • If your app expects users from only few countries then you might wish to remove all other countries from selection list.

  • You can remove unnecessary countries by setting your custom master country list.

  • Also it will keep user from selecting irrelevant country.

  • Countries of preference will be listed at top in selection dialog. It is helpful when target audience is from a set of countries.

  • Custom master list will only limit the visibility of irrelevant countries from selection dialog. But all other functions like setCountryForCodeName() or setFullNumber() will consider all the countries.

  • Preferred country list will be a subset of custom master list. If some xyz country is not in custom master list, it won't be added to preferred country list.

  • Set through xml

    Add app:ccp_customMasterCountries="US,ID,NZ,BD,PL,RO,ZW" (replace "US,ID,NZ,BD,PL,RO,ZW" by your own country code names) to xml layout. Refer List of countries for name codes.

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_customMasterCountries="US,IN,NZ,BD,PL,RO,ZW"  />
  • Programmatically

    • Use setCustomMasterCountries() method.
    • setCustomMasterCountries(null) will remove custom list and revert to library default list.

12. Custom font

FontFamily of CCP content can be changed in order to match rest of the view of form.

  • For programmatically and xml

    Do the following step first:

    • Step 1: Create a folder named assets under app/src/main/ folder. If you already have app/src/main/assets then jump to next step.
    • Step 2: Put your font's .ttf file in assets folder. For example if file name is myfonts.ttf, it should be app/src/main/assets/myfonts.ttf. Make sure that the extension '.ttf' have contain small letters only. '.TTF' will not work.
  • Programmatically

    • Step 1: Now prepare typeFace using Typeface typeFace=Typeface.createFromAsset(getContext().getAssets(),"myfonts.ttf");
    • Step 2: Finally apply the type face on ccp ccp.setTypeFace(typeFace); OR ccp.setTypeFace(typeFace,customStyle);
  • Set through xml

    Add app:ccp_textFont="myfonts.ttf" to use the font

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
        	 android:id="@+id/ccp"
        	 android:layout_width="wrap_content"
          android:layout_height="wrap_content"
        	 app:ccp_textFont="myfonts.ttf" />

13. National Flag Thumbnail

  • Added flag thumbnail to cpp and selector dialog

  • More thumbnail packs can be added

  • By default flag will be added to the ccp view

  • Set through xml

Add app:ccp_showFlag="false" to remove flag using xml layout

<com.rilixtech.widget.countrycodepicker.CountryCodePicker
       android:id="@+id/ccp"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       app:ccp_showFlag="false" />
  • Programmatically

    Use showFlag(false) method to hide the flag.

14. Show Full Country Name

  • Developer might wish to show full country name instead of only code name
  • showFullName will replace name code with full name.
  • If name code was hidden using app:hideNameCode="true" then this will not work.
  • Some country names are real long so go for this option only if your UI has dedicated enough space for it.

  • Set through xml

    Add app:ccp_showFullName="true" to show full nameinstead of name code

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_showFullName="true"/>
  • Programmatically

    Use showFullName(true) or showFullName(false) method to show / hide the full name.

15. Enable / Disable click

Developer can toggle click listener of CCP

  • Set through xml

    Add app:ccp_clickable="true" to enable click listener.

    <com.rilixtech.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_clickable="false"/>
  • Programmatically

    Use setClickable(true) or setClickable(false) method to enable / disable the click.

16. Hide / Show Phone Code

The phone code can be hide or show if you want. By default the phone code is shown. We don't need to add the attribute to show the phone code.

  • Set through xml

    Add app:ccp_hidePhoneCode="true" to hide the phone code.

    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_hidePhoneCode="true"/>
  • Programmatically

    Use setHidePhoneCode(true) or setHidePhoneCode(false) method to hide / show the phone code.

17. Enable / Disable Auto Formatter

You need to set an EditText for phone number with registerPhoneNumberTextView() to make use of this. Ignore this if you don't. The auto formatter for EditText can be enable/disable by using enablePhoneAutoFormatter attribute. By default, auto formatter is enabled.

  • Set through xml

    Add app:ccp_enablePhoneAutoFormatter="false" to disable.

    ````xml
    <com.rilixtech.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_enablePhoneAutoFormatter="false"/>
    ````
    
  • Programmatically

    Use enablePhoneAutoFormatter(true) or enablePhoneAutoFormatter(false) method to enable / disable auto formatter.

    To check for it, use isPhoneAutoFormatterEnabled()

18. Enable / Disable Set Country Code By TimeZone

You need to set an EditText for phone number with registerPhoneNumberTextView() to make use of this. Ignore this if you don't. By default, CCP will checking for country code from time zone if no default country code set and no country code is found from device network. The default value is true.

Use ccp_setCountryByTimeZone attribute to change. This attribute is having the least order from defaultNameCode. Here the order CCP use:

  1. defaultNameCode by using ccp_defaultNameCode
  2. Auto detect from device by checking network
  3. time zone from device by using ccp_setCountryByTimeZone
  4. country iso from device locale.
  5. the last default will be defaulting to country code ID (Indonesia).
  • Set through xml

    Add app:ccp_setCountryByTimeZone="false" to disable.

    ````xml
    <com.rilixtech.widget.countrycodepicker.CountryCodePicker
           android:id="@+id/ccp"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           app:ccp_setCountryByTimeZone="false"/>
    ````
    
  • Programmatically

    Use enableSetCountryByTimeZone(true) or enableSetCountryByTimeZone(false) method to enable / disable time zone.

    To check for it, use isPhoneAutoFormatterEnabled()

Thanks for the Contributors

Tejas N A for the PR. [sadegh] (https://github.com/sadeghpro) for the PR.

Credits

Michael Rozumyanskiy for libphonenumber-android

Harsh Bhakta for the original project at CountryCodePickerProject

egek92 for Turkish translation.

License

Apache Version 2.0

Copyright (C) 2019 Joielechong

Copyright (C) 2016 Harsh Bhakta

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

countrycodepicker's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

countrycodepicker's Issues

French "Guyana"

The correct name for this French territory in English is "French Guiana". The form "Guyana" only applies to the independent English-speaking country to the west.

Heading error

There's a small spelling mistake in the dialog. "Select county" instead of "Select country" . Is there any way to change the heading without changing the library?

Only want to show flag

Hello, this is awesome library. Only problem is now i only want to show flag and nothing else.

Error in Inflating view in some device

I integrate this library in my app. I t is working fine till now. but yesterday it crash in some user's device .
Device list is as below:
Xioami Redmi 5A
Xioami Redmi 3S
YuLong 3600i
Samsung Galaxy J2 Pro
And Android api version is
Android 6.0.1
Android 8.1.0

Issues that is occurs:
Caused by android.content.res.Resources$NotFoundException
Unable to find resource ID #0x7f070175

android.content.res.Resources.getResourceName (Resources.java:3740)
android.content.res.Resources.loadDrawableForCookie (Resources.java:4246)
android.content.res.Resources.loadDrawable (Resources.java:4153)
android.content.res.Resources.loadDrawable (Resources.java:3998)
android.content.res.TypedArray.getDrawable (TypedArray.java:886)
android.widget.ImageView. (ImageView.java:157)
android.widget.ImageView. (ImageView.java:145)
androidx.appcompat.widget.AppCompatImageView. (AppCompatImageView.java:72)
androidx.appcompat.widget.AppCompatImageView. (AppCompatImageView.java:68)
androidx.appcompat.app.AppCompatViewInflater.createImageView (AppCompatViewInflater.java:182)
androidx.appcompat.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:106)
androidx.appcompat.app.AppCompatDelegateImpl.createView (AppCompatDelegateImpl.java:1266)
androidx.appcompat.app.AppCompatDelegateImpl.onCreateView (AppCompatDelegateImpl.java:1316)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:758)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.inflate (LayoutInflater.java:527)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)
android.view.LayoutInflater.inflate (LayoutInflater.java:380)
android.view.View.inflate (View.java:21232)
com.rilixtech.CountryCodePicker.init (CountryCodePicker.java:140)
com.rilixtech.CountryCodePicker. (CountryCodePicker.java:124)
java.lang.reflect.Constructor.newInstance (Constructor.java)
android.view.LayoutInflater.createView (LayoutInflater.java:631)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:776)
android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:716)
android.view.LayoutInflater.rInflate (LayoutInflater.java:847)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.rInflate (LayoutInflater.java:855)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:810)
android.view.LayoutInflater.inflate (LayoutInflater.java:527)
android.view.LayoutInflater.inflate (LayoutInflater.java:429)

Please help me to solve this issue.

Localization

I want to localize only the "select country " and "search" texts to my own language(Turkish), can I make pull request after I change the string resources

Missing country

This is a cool library but there is some mistakes with some countries.
Your library has the same Congo repeat twice. There are two Congo in the world
D.R.Congo and Congo

Best regards

Brazilian phone numbers not formatted correctly

For instance, if I enter the number 11 3209-6622, where 11 is the area code for São Paulo, Brazil's largest city, your device will format it as 1132-096-622. I understand it if you don't have the time to make sure every country's phone numbers are formatting correctly, so is there a way for users to modify the device to make sure the countries they need are formatting correctly?

onCountrySelectedIsCalledTooManyTimes

When I am adding a listner onCountry selected keeps running for too many times and crashes the app. what I am trying to do is if I select a country the country code automaticaly gets selected or vice versa

NullPointerException: Crash during Firebase Pre-launch report creation.

I have encountered this crash when Firebase ran it's automated tests for the uploaded Production apk. I'd tried to reproduce the crash manually, but unable to do so.

Here is the associated info related to crash:
Logcat:

04-03 09:56:57.424: I/Robo(11852): resource_name: "com.app.android:id/item_country_rly" with ActionParameters{}}.
04-03 09:56:57.433: I/Robo(11907): Espresso: performing single click on EspressoElement {# androidx.test.tools.crawler.proto.Rectangle@2ed4e7ff
04-03 09:56:57.433: I/Robo(11907): bottom: 602
04-03 09:56:57.433: I/Robo(11907): left: 88
04-03 09:56:57.433: I/Robo(11907): right: 632
04-03 09:56:57.433: I/Robo(11907): top: 598, # androidx.test.tools.crawler.proto.ElementDescription@385041b
04-03 09:56:57.433: I/Robo(11907): class_name: "android.widget.RelativeLayout"
04-03 09:56:57.433: I/Robo(11907): component_type: CONTAINER
04-03 09:56:57.433: I/Robo(11907): identifiers {
04-03 09:56:57.433: I/Robo(11907):   child_position: 3
04-03 09:56:57.433: I/Robo(11907):   mode_agnostic_sequence: "0.0.0.0.2.0"
04-03 09:56:57.433: I/Robo(11907):   mode_specific_sequence: "0.0.0.0.2.3"
04-03 09:56:57.433: I/Robo(11907): }
04-03 09:56:57.433: I/Robo(11907): input_type: NONE
04-03 09:56:57.433: I/Robo(11907): resource_name: "com.app.android:id/item_country_rly", # androidx.test.tools.crawler.proto.ElementState@485a255d
04-03 09:56:57.433: I/Robo(11907): capability: CLICK
04-03 09:56:57.433: I/Robo(11907): is_shown: true
04-03 09:56:57.433: I/Robo(11907): visible_bounds {
04-03 09:56:57.433: I/Robo(11907):   bottom: 602
04-03 09:56:57.433: I/Robo(11907):   left: 88
04-03 09:56:57.433: I/Robo(11907):   right: 632
04-03 09:56:57.433: I/Robo(11907):   top: 598
04-03 09:56:57.433: I/Robo(11907): }} with ActionParameters{}.
04-03 09:56:57.433: I/Robo(11907): [ 04-03 09:56:57.554 11907:11907 W/         ]
04-03 09:56:57.433: I/Robo(11907): Unable to open '/system/framework/prcui-config.jar': No such file or directory
04-03 09:56:57.554: W/art(11907): Failed to open zip archive '/system/framework/prcui-config.jar': I/O Error
04-03 09:56:57.573: I/Robo(11907): Rethrowing the exception thrown by the app.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.rilixtech.a.c()' on a null object reference
	at com.rilixtech.CountryCodePicker.setSelectedCountry(CountryCodePicker.java:314)
	at com.rilixtech.CountryCodeDialog$ItemRecyclerViewClickListener.onItemClick(CountryCodeDialog.java:219)
	at android.widget.AdapterView.performItemClick(AdapterView.java:310)
	at android.widget.AbsListView.performItemClick(AbsListView.java:1145)
	at android.widget.AbsListView$PerformClick.run(AbsListView.java:3073)
	at android.widget.AbsListView$3.run(AbsListView.java:3910)
	at android.os.Handler.handleCallback(Handler.java:746)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at androidx.test.espresso.base.Interrogator.a(Interrogator.java:19)
	at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:164)
	at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:156)
	at androidx.test.espresso.base.UiControllerImpl.a(UiControllerImpl.java:136)
	at androidx.test.espresso.action.Tap$1.a(Tap.java:6)
	at androidx.test.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:22)
	at androidx.test.espresso.ViewInteraction$SingleExecutionViewAction.perform(ViewInteraction.java:9)
	at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:79)
	at androidx.test.espresso.ViewInteraction.a(ViewInteraction.java:96)
	at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:3)
	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
	at android.os.Handler.handleCallback(Handler.java:746)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5459)
	at java.lang.reflect.Method.invoke(Method.java)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)

Scenario:
crash

App crashes when clicked on CPP view

When I click on CPP view, it crashes instead of opening the dialog. Here is the error:
java.lang.NoSuchFieldError: No static field item_country_rly of type I in class Lcom/rilixtech/R$id; or its superclasses

Crashing while inflating view

Process: com.elev8valley.suk, PID: 19991
android.view.InflateException: Binary XML file line #146: Binary XML file line #146: Error inflating class com.rilixtech.CountryCodePicker
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at com.elev8valley.suk.fragments.SignUpFragment.onCreateView(SignUpFragment.java:107)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #146: Error inflating class com.rilixtech.CountryCodePicker
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at com.elev8valley.suk.fragments.SignUpFragment.onCreateView(SignUpFragment.java:107) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) 
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) 
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) 
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) 
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7331) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at com.elev8valley.suk.fragments.SignUpFragment.onCreateView(SignUpFragment.java:107) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) 
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) 
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) 
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) 
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7331) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.NoSuchFieldError: No static field selected_country_tv of type I in class Lcom/rilixtech/R$id; or its superclasses (declaration of 'com.rilixtech.R$id' appears in /data/app/com.elev8valley.suk-2/base.apk)
at com.rilixtech.CountryCodePicker.init(CountryCodePicker.java:142)
at com.rilixtech.CountryCodePicker.(CountryCodePicker.java:124)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:631) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:776) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at com.elev8valley.suk.fragments.SignUpFragment.onCreateView(SignUpFragment.java:107) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) 
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) 
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) 
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) 
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) 
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:7331) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 

Country data is not updated

many country like south sudan, kosova not added in lib. please add their country std codes and corresponding flags.

Proguard rules

Hi,
I'm testing your library in one of my projects and it looks good until I had to make a production build :) .
I have a really hard time to deobfuscate the build with proguard after the library was added.
Do you have any progruard rules to suggest ?

Padding layout

pls padding of layout content deleted because i want to following align top and bottom of other content

Phone Number Auto Formatted

Why the phone number auto formatted only works when I set a default country code in the .xml, but if I select another country the phone number doesn't get formatted

hint problem... extra digit that confuses users

Hint shows extra digit that is supposed to be in the country code.
Example...
Country Code: (TR) +90
Hint: 05012345678
So when combined: +90 05012345678. The problem is there are 2 zeros. Actual Turkish numbers are +905012345678 like this. It confuses the user when typing their phone number.
Hints for other countries should also be checked.

country code selection automatically

Default country code is being set in Android L and M devices but Android P devices don't seem to be setting the current country code based on the timezone. I have tried this.

country_code_picker.enableSetCountryByTimeZone(true)

But it is still being set to "IN" even if the time zone is Australia/Perth

Lib version: 2.3.3
Devices Tested: Samsung J2 Android Pie, Redmi 6 Pro Android Pie, Moto G Android 5.1, Moto G4 Android Marshmallow

Sometimes it's crashed during inflation from xml.

java.lang.NullPointerException CountryCodePicker.java line 343 in CountryCodePicker.setSelectedCountry()
Attempt to invoke virtual method 'java.lang.String com.rilixtech.Country.getIso()' on a null object reference
com.rilixtech | CountryCodePicker.java line 343 in CountryCodePicker.setSelectedCountry()
com.rilixtech | CountryCodePicker.java line 772 in CountryCodePicker.setCountryForNameCode()
me.runningcoach.ui.activities | SWControlActivity.java line 131 in SWControlActivity.showPhoneDialog()

Issue when selecting a country while registering EditText

When you register EditText and try to select a country then validate the phone number, it always evaluates to false.
After debugging, i found that after selecting a country, the mRegisteredPhoneNumberTextView points to selected_country_tv not the registered EditText.
As a result, an exception, NumberParseException, occurs internally in getPhoneNumber() as the string is a code like this "+999".

Workaround: before calling `isValid(), i register the EditText.

Rendering Issue: The following classes could not be instantiated

The following classes could not be instantiated:
- com.rilixtech.CountryCodePicker (Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE. If this is an unexpected error you can also try to build the project, then manually refresh the layout. Exception Details
java.lang.NullPointerException at com.rilixtech.CountryCodePicker.applyCustomProperty(CountryCodePicker.java:308) at com.rilixtech.CountryCodePicker.init(CountryCodePicker.java:151) at com.rilixtech.CountryCodePicker.<init>(CountryCodePicker.java:127) at sun.reflect.GeneratedConstructorAccessor1174.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:481) at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:264) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:222) at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:211) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:337) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:348) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:248) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:866) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:325) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:384) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:193) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:547) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$3(RenderTask.java:681) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
Android Studio 3.0.1
how fix this Rendering Issue?

Gradle dependency not syncing -

implementation 'com.github.joielechong:countrycodepicker:2.1.5'

error :
Error:(43, 20) Failed to resolve: com.github.joielechong:countrycodepicker:2.1.5

Error setting registered Phone Number TextView

At line 311 you call setRegisteredPhoneNumberTextView and pass mTvSelectedCountry as an edittext. In this function you initialize your mRegisteredPhoneNumberTextView variable with the textview parameter, this causes that when you call getFullNumber or setFullNumber, the number obtained or set is erroneous.

You can see it in your sample at FullNumberFragment when you click buttonLoadNumber and load the text of editTextLoadFullNumber to CPP

Unable to properly align flag and number in layout

this is my layout code for placing the views.

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="20dp"
        android:layout_marginEnd = "10dp"
        android:layout_marginStart="10dp"
        android:padding="5dp"
        android:layout_below="@+id/make_sure_sms"
        android:weightSum="6"
         >

        <com.rilixtech.CountryCodePicker
            android:id="@+id/ccp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            app:ccp_textSize="24sp"
            app:ccp_hideNameCode="true"
            tools:ignore="RtlSymmetry" />

        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/phone_number_edt"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:hint="@string/otp_login_enter_mobile_number"
            android:inputType="phone"
            android:layout_weight="4"/>
    </LinearLayout>

The problem is country flag icon seems to be on top and not properly aligning with mobile number app compat edit text.can you please guide me how to fix this??

Phone number formatting NOT being updated when selected country changes

When selecting a new country code, the phone number formatting is not being updated.

After some research into library code, I found out the issue is because even though mPhoneNumberWatcher gets updated with a new instance, it is not being added again to textView as a TextWatcher.

From library code:

private void setPhoneNumberWatcherToTextView(TextView textView, String countryNameCode) {
    if (mIsEnablePhoneNumberWatcher) {
        if (mPhoneNumberWatcher == null) {
            mPhoneNumberWatcher = new PhoneNumberWatcher(countryNameCode);
            textView.addTextChangedListener(mPhoneNumberWatcher);
        } else {
            if (!mPhoneNumberWatcher.getPreviousCountryCode().equalsIgnoreCase(countryNameCode)) {
                mPhoneNumberWatcher = new PhoneNumberWatcher(countryNameCode); // <- HERE
            }
        }
    }
}

Please note that just assigning a new value to mPhoneNumberWatcher won't update the object within textView listeners list.

Please refer to: https://stackoverflow.com/questions/7080546/add-an-object-to-an-arraylist-and-modify-it-later

Possible solution

We should remove previous mPhoneNumberWatcher and then add the new instance using textView.addTextChangedListener(mPhoneNumberWatcher) to properly update the phone number format according to the new selected country.

ArrayIndexOutOfBoundsException in CountryCodeDialog.java

One of our user had following crash:

Fatal Exception: java.lang.ArrayIndexOutOfBoundsExceptionlength=303; index=-1 Raw Text
--
  | java.util.ArrayList.get (ArrayList.java:310)
  | com.rilixtech.CountryCodeDialog$ItemRecyclerViewClickListener.onClick (CountryCodeDialog.java:204)
  | android.view.View.performClick (View.java:4780)
  | com.android.internal.os.ZygoteInit.main (ZygoteInit.java:698)

On checking Crashlytics, I found the device GI I9500 TMMARS running Android 5.1.
On some investigation I found some insight about such devices here

Could you check if this is a genuine issue & fix it or its something because TMMARS is blocking something by detecting some threat.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.