CountryCodePickerProject
CountryCodePickerProject copied to clipboard
Country selection is not working.
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?
Sorry to hear that. If you can provide following details that will be helpful to find out the issue.
- Library version
- XML Code of CCP
- Java or Kotlin code related to CCP operations
- 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 .
Thanks for the prompt response! Here are the details.
1)Library version used in gradle:
implementation 'com.hbb20:ccp:2.2.3'
- 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"/>
- 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(); } }); }
- 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
}
Thank you for the details. The code looks perfectly OK. I would like to see result after changing minifyEnabled and shrinkResources to false.
I tried after changing those two parameters to false, but unfortunately it is still selector is still not working.
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.
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.
Awesome. Glad to know that it's now working for you. 👍
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
How are you assign value of argument locale ?
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.
What is value of sRequiredCountries? Side note: Name code for U.K is "GB" and not "UK".
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.
I am trying to reproduce the issue with the same code and configuration but somehow unable to reproduce it.
Can you give me the exact string value for sRequiredCountries?
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";
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.
Hello @shreya2224, were you able to reproduce on demo app?