All Projects → ibrahimsn98 → PhoneNumberKit

ibrahimsn98 / PhoneNumberKit

Licence: Apache-2.0 license
Android Kotlin library to parse and format international phone numbers. Country code picker.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to PhoneNumberKit

PhoneCountryCodePicker
An iOS tableview picker for PhoneCountryCode (English & Chinese supported)
Stars: ✭ 31 (-75%)
Mutual labels:  phone, country-codes, picker
Vue Phone Number Input
A phone number input made with Vue JS (format & valid phone number)
Stars: ✭ 407 (+228.23%)
Mutual labels:  phone-number, phone, number
yup-phone
☎️ Adds a phone number validation check to yup validator using google-libphonenumber
Stars: ✭ 219 (+76.61%)
Mutual labels:  phone, number
Phoneinfoga
PhoneInfoga is one of the most advanced tools to scan international phone numbers using only free resources. It allows you to first gather standard information such as country, area, carrier and line type on any international phone number. Then search for footprints on search engines to try to find the VoIP provider or identify the owner.
Stars: ✭ 5,927 (+4679.84%)
Mutual labels:  phone-number, phone
Mini phone
A fast phone number lib for Ruby (binds to Google's C++ libphonenumber)
Stars: ✭ 131 (+5.65%)
Mutual labels:  phone-number, phone
haoma
手机固话电话号码标记批量查询📞📌
Stars: ✭ 52 (-58.06%)
Mutual labels:  phone-number, phone
Edittext Mask
The custom masks for EditText. The solution for input phone numbers, SSN, and so on for Android
Stars: ✭ 413 (+233.06%)
Mutual labels:  phone-number, mask
Crboxinputview
Verify code input view. Support security type for password.短信验证码输入框,支持密文模式
Stars: ✭ 749 (+504.03%)
Mutual labels:  phone-number, phone
Brazilian Utils
Utils library for specific Brazilian businesses
Stars: ✭ 1,023 (+725%)
Mutual labels:  phone, mask
Moriarty Project
This tool gives information about the phone number that you entered.
Stars: ✭ 223 (+79.84%)
Mutual labels:  phone-number, phone
Phonia
Phonia Toolkit is one of the most advanced toolkits to scan phone numbers using only free resources. The goal is to first gather standard information such as country, area, carrier and line type on any international phone numbers with a very good accuracy.
Stars: ✭ 221 (+78.23%)
Mutual labels:  phone-number, phone
phonenumber
With a given country and phone number, validate and format the MOBILE phone number to E.164 standard
Stars: ✭ 108 (-12.9%)
Mutual labels:  phone, number
CHRTextFieldFormatter
Provides UITextField formatting masks. Such as phone number and credit card number formatters.
Stars: ✭ 52 (-58.06%)
Mutual labels:  phone-number, mask
Libphonenumber Js
A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
Stars: ✭ 2,233 (+1700.81%)
Mutual labels:  phone, number
Nkvphonepicker
An UITextField subclass to simplify country code's picking. Swift 5.0
Stars: ✭ 131 (+5.65%)
Mutual labels:  phone, picker
Phone
With a given country and phone number, validate and reformat the mobile phone number to the E.164 standard. The purpose of this is to allow us to send SMS to mobile phones only.
Stars: ✭ 531 (+328.23%)
Mutual labels:  phone-number, phone
React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (+259.68%)
Mutual labels:  phone, number
React Phone Number Input
React component for international phone number input
Stars: ✭ 725 (+484.68%)
Mutual labels:  phone, number
Maskededittext
It allows you to add a mask to EditText
Stars: ✭ 184 (+48.39%)
Mutual labels:  phone-number, mask
international-telephone-input
Integration to Magento 2 a jQuery plugin for entering and validating international telephone numbers.
Stars: ✭ 26 (-79.03%)
Mutual labels:  phone-number, country-codes

PhoneNumberKit

Android Kotlin library to parse and format international phone numbers. Based on Google's libphonenumber library.

Features

Features
☎️ Validate, normalize and extract the elements of any phone number string.
🎯 Convert raw phone number to formatted phone number string.
🔍 Automatically detects country flag of the phone number.
🔖 Country code selection bottom sheet.
📌 Convert country codes to country names and vice versa.
🇹🇷 Get country flag icon for given iso2 code.

Usage

Create a phoneNumberKit instance and attach it to an editTextLayout. That's all you have to do.

val phoneNumberKit = PhoneNumberKit.Builder(this)
    .setIconEnabled(true)
    .admitCountries(listOf("tr", "ca", "de")) // List only those county formats
    .excludeCountries(listOf("tr", "ca")) // Exclude those county formats
    .build()

phoneNumberKit.attachToInput(textField, "tr")
// OR
phoneNumberKit.attachToInput(textField, 1)

To setup with country code selection bottom sheet

phoneNumberKit.setupCountryPicker(this) // Requires activity context

To get an example phone number for given iso2 code

val exampleNumber = phoneNumberKit.getExampleNumber("tr")

To parse raw text to phone number and receive country code, national number

val parsedNumber = phoneNumberKit.parsePhoneNumber(
    number = "1266120000",
    defaultRegion = "us"
)

parsedNumber?.nationalNumber
parsedNumber?.countryCode
parsedNumber?.numberOfLeadingZeros

To convert raw text to formatted phone number string

val formattedNumber = phoneNumberKit.formatPhoneNumber(
    number = "1266120000",
    defaultRegion = "us"
)

To receive a country flag icon for given iso2 code

val flag = phoneNumberKit.getFlagIcon("ca")

Usage with Custom Item Layout

Add your custom item layout resource as a parameter

phoneNumberKit.setupCountryPicker(this, R.layout.my_item_layout, searchEnabled = true)

You need to use below view ids in your layout file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingVertical="12dp"
    android:paddingHorizontal="18dp"
    android:clickable="true"
    android:focusable="true"
    android:background="?android:attr/selectableItemBackground">

    <ImageView
        android:id="@+id/imageViewFlag"
        android:layout_width="22dp"
        android:layout_height="22dp" />

    <TextView
        android:id="@+id/textViewName"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        android:singleLine="true"
        android:maxLines="1"
        android:ellipsize="end"
        android:textSize="16sp"
        android:textColor="#232425" />

    <TextView
        android:id="@+id/textViewCode"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="16sp"
        android:textColor="#838383" />

</LinearLayout>

Demo

Country Code Picker Format Example Format Example

Installation

Follow me on Twitter @ibrahimsn98

Step 1. Add the JitPack repository to your build file

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Step 2. Add the dependency

dependencies {
    implementation 'com.github.ibrahimsn98:PhoneNumberKit:2.0.6'
}

Checklist

  • Search for country codes
  • Custom list item layout support
  • Better performance with coroutines
  • Phone number validation indicator
  • Dark theme
  • Tests

Conception

License

PhoneNumberKit is available under the Apache license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].