CountryCodePickerProject icon indicating copy to clipboard operation
CountryCodePickerProject copied to clipboard

Country selection is not working.

Open shreya2224 opened this issue 6 years ago • 17 comments

Hi,

I have implemented the library which seems to be working fine, until today when I found that the country selector is not working without changing any respective code. If I choose any country from the list of countries, it does not change in the selector. I also see error "D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection" in android logcats. Any idea on what could have gone wrong?

shreya2224 avatar Feb 27 '19 20:02 shreya2224

Sorry to hear that. If you can provide following details that will be helpful to find out the issue.

  1. Library version
  2. XML Code of CCP
  3. Java or Kotlin code related to CCP operations
  4. Gradle file content for version verification

On Wed, Feb 27, 2019 at 14:35 shreya2224 [email protected] wrote:

Hi,

I have implemented the library which seems to be working fine, until today when I found that the country selector is not working without changing any respective code. If I choose any country from the list of countries, it does not change in the selector. I also see error "D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection" in android logcats. Any idea on what could have gone wrong?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/hbb20/CountryCodePickerProject/issues/291, or mute the thread https://github.com/notifications/unsubscribe-auth/AEsN6O4j3yZPahZhgLRHsEs4u1QuO9s6ks5vRuwkgaJpZM4bVZmy .

hbb20 avatar Feb 27 '19 20:02 hbb20

Thanks for the prompt response! Here are the details.

1)Library version used in gradle:

implementation 'com.hbb20:ccp:2.2.3'

  1. XML Code of CCP

<com.hbb20.CountryCodePicker android:id="@+id/ccp" android:layout_width="200dp" android:layout_height="wrap_content" android:layout_weight="0.7" android:layout_below="@id/phone" android:gravity="center" android:visibility="gone" app:ccp_defaultNameCode="US"/>

  1. Java or Kotlin code related to CCP operations

if ((phoneNumber.getText().toString().charAt(0) != '+')) { ccp.setVisibility(View.VISIBLE); ccp.setCountryForNameCode(locale); ccp.setCustomMasterCountries(sRequiredCountries); ccp.setOnCountryChangeListener(new CountryCodePicker.OnCountryChangeListener() { @Override public void onCountrySelected() { sCountryPrefix = ccp.getSelectedCountryCode(); sCountryCode = ccp.getSelectedCountryNameCode(); } }); }

  1. Gradle file content for version verification

android { compileSdkVersion 27 buildToolsVersion '27.0.3' }

defaultConfig {
    applicationId "...."
    minSdkVersion 21
    targetSdkVersion 27
    versionCode 8
    versionName "1.0.7"
}
buildTypes {
    release {
        shrinkResources true
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

shreya2224 avatar Feb 27 '19 20:02 shreya2224

Thank you for the details. The code looks perfectly OK. I would like to see result after changing minifyEnabled and shrinkResources to false.

hbb20 avatar Feb 27 '19 21:02 hbb20

I tried after changing those two parameters to false, but unfortunately it is still selector is still not working.

shreya2224 avatar Feb 27 '19 21:02 shreya2224

oh. Can you try by updating library to the latest version (2.2.4). Then clean and rebuild the project. If that does not work, show me entire error log.

hbb20 avatar Feb 27 '19 21:02 hbb20

Thanks for looking into it. Looks like I was using location services which were not correctly picking up the current location, because of which the selector got messed up. I commented that part of code, and now it is working fine.

shreya2224 avatar Feb 27 '19 21:02 shreya2224

Awesome. Glad to know that it's now working for you. 👍

hbb20 avatar Feb 27 '19 21:02 hbb20

Sorry for jumping on the conclusion so soon. After digging up a little, I find out that if I comment out ccp.setCountryForNameCode("UK"); everything works fine, but if I use it, it wouldn't let me select the country.

Below is what I see in error log:

D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection D/CCP: updateFormattingTextWatcher: EditText not registered CCP_last_selection

shreya2224 avatar Feb 27 '19 21:02 shreya2224

How are you assign value of argument locale ?

hbb20 avatar Feb 27 '19 21:02 hbb20

I am assigning the value to locale. But it doesn't matter, because I even tries with country codes like "US", "UK" and for Italy as well.

shreya2224 avatar Feb 27 '19 21:02 shreya2224

What is value of sRequiredCountries? Side note: Name code for U.K is "GB" and not "UK".

hbb20 avatar Feb 27 '19 22:02 hbb20

sRequiredCountries is the list of countries that I want to show in the selector, not all the countries. That includes all European countries and US.

shreya2224 avatar Feb 28 '19 00:02 shreya2224

I am trying to reproduce the issue with the same code and configuration but somehow unable to reproduce it.

hbb20 avatar Feb 28 '19 01:02 hbb20

Can you give me the exact string value for sRequiredCountries?

hbb20 avatar Feb 28 '19 01:02 hbb20

Here is the value of sRequiredCountries:

public String sRequiredCountries = "AL,AD,AM,AT,BY,BE,BA,BG,CH,CY,CZ,DE,DK,EE,ES,FO,FI,FR,GB,GE,GI,GR,HU,HR,IE,IS,IT,LT,LU,LV,MC,MK,MT,NO,NL,PO,PL,PT,RO,RU,SE,SI,SK,SM,TR,UA,US,VA";

shreya2224 avatar Feb 28 '19 12:02 shreya2224

Oh...that too worked... I have been trying to reproduce the issue but somehow not able to achieve it. If you can create some demo app that can reproduce it, that will be helpful.

hbb20 avatar Mar 18 '19 00:03 hbb20

Hello @shreya2224, were you able to reproduce on demo app?

hbb20 avatar Aug 03 '19 18:08 hbb20