https://github.com/micahsphelele/phonecodepicker
An android library for country codes
https://github.com/micahsphelele/phonecodepicker
android-library androidstudio country-codes country-picker dependencies java kotlin utils
Last synced: 3 months ago
JSON representation
An android library for country codes
- Host: GitHub
- URL: https://github.com/micahsphelele/phonecodepicker
- Owner: MicahSphelele
- Created: 2020-05-02T12:29:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-14T15:20:06.000Z (about 5 years ago)
- Last Synced: 2025-01-14T08:13:10.691Z (5 months ago)
- Topics: android-library, androidstudio, country-codes, country-picker, dependencies, java, kotlin, utils
- Language: Java
- Homepage:
- Size: 991 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android Phone Code Picker
![]()
An open source android library that is compatible with Java and Kotlin
Phone code picker is a simple and easy to use picker, which makes it easier to select and search for a country code for a mobile number. The library is supports API level 17 and up. The reason I wrote this library was for me to add a few new features and also implement a `RecyclerView` instead of `ListView`. The developement of this library was inspired by [**Joielechong**](https://github.com/joielechong/)
Phone code picker will provide a proffesional and seamless look into your UI whether you want to use it for a sign up screen or a sign screen.
### How to add to project
1. Add jitpack.io to your root build.gradle file:````groovy
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
````
2. Add library to your project build.gradle file and then sync
````groovy
dependencies {
implementation 'com.github.MicahSphelele:phonecodepicker:1.1.1'
}
````3. Add picker to layout using the following:
````xml
````
4. Add EditText/AppCompatEditText view to layout:````xml
````
5. Register the EditText/AppCompatEditText with code:```java
CountryCodePicker picker;
AppCompatEditText phoneEdit;...
picker = findViewById(R.id.picker);
phoneEdit = findViewById(R.id.phone_edit);...
picker.registerPhoneNumberTextView(phoneEdit);
```
Some of the attributes that can be used in PhoneCodePicker layout:| Attribute | method | Description
|---------------|---------------------------------|-------------------------------
|picker_defaultCode | setDefaultCountryUsingPhoneCodeAndApply(int defaultCode) | set selected Flag and phone in CCP by phone code.
|picker_showFullName| showFullName(boolean show) | Show full name of country in CCP. Default is false|
|picker_hideNameCode| hideNameCode(boolean hide) | Hide the country name code. Default is false|
|picker_hidePhoneCode| hidePhoneCode(boolean hide)| Hide the phone code. Default is false|
|picker_DialogMode| setDialogMode(int mode)| Set fullscreen mode or dialog mode (full_dialog or dialog)Library Features
--------
What inspired me from re-wrtting this library was these features.### 1. Dialog Mode
* You can pick how you want to view the list from countries by using two different modes `full_dialog` or `dialog`
* NB: dialog mode is alway default
#### A. Through xml
##### Using dialog mode
Add `app:picker_DialogMode="dialog"`
#### B. Programmatically
##### Using set dialog mode
Use `setDialogMode(PhoneCodePicker.DIALOG_MODE_DIALOG)` method.
| Full Dialog Mode | Dialog Mode
|---------------|---------------------------------
||
### 2. Dialog Adaptive OS Theme (DARK MODE) support
* You can set the library dialogs to adapt colors if os is using dark mode
* NB: this will only work on devices using API level 29> and ensure that you don't interfere with default colors when using this attribute
#### A. Through xml
##### Using os theme support
Add `app:picker_supportOSTheme="true"`
#### B. Programmatically
##### Using os theme support
Use `setIsSupportOSTheme(true)` method.
| OS in dark mode
|---------------
||
### More about features
* Should you feel that you need more info about the features please ref : [**CountryCodePicker**](https://github.com/joielechong/CountryCodePicker/)
### 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](https://github.com/MichaelRocks/libphonenumber-android)