{"id":18655213,"url":"https://github.com/ibrahimsn98/phonenumberkit","last_synced_at":"2025-08-02T13:39:49.027Z","repository":{"id":41401838,"uuid":"291533450","full_name":"ibrahimsn98/PhoneNumberKit","owner":"ibrahimsn98","description":"Android Kotlin library to parse and format international phone numbers. Country code picker.","archived":false,"fork":false,"pushed_at":"2023-10-06T07:08:01.000Z","size":1325,"stargazers_count":165,"open_issues_count":16,"forks_count":42,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T12:48:03.371Z","etag":null,"topics":["android","country-codes","kotlin","library","lilphonenumber","mask","number","phone","phone-mask","phone-number","phonenumberkit","picker"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibrahimsn98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-30T19:00:33.000Z","updated_at":"2025-04-01T18:10:17.000Z","dependencies_parsed_at":"2022-09-03T11:32:23.613Z","dependency_job_id":null,"html_url":"https://github.com/ibrahimsn98/PhoneNumberKit","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/ibrahimsn98/PhoneNumberKit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimsn98%2FPhoneNumberKit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimsn98%2FPhoneNumberKit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimsn98%2FPhoneNumberKit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimsn98%2FPhoneNumberKit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibrahimsn98","download_url":"https://codeload.github.com/ibrahimsn98/PhoneNumberKit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimsn98%2FPhoneNumberKit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268400668,"owners_count":24244445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","country-codes","kotlin","library","lilphonenumber","mask","number","phone","phone-mask","phone-number","phonenumberkit","picker"],"created_at":"2024-11-07T07:18:08.161Z","updated_at":"2025-08-02T13:39:48.976Z","avatar_url":"https://github.com/ibrahimsn98.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PhoneNumberKit\nAndroid **Kotlin** library to parse and format international phone numbers. Based on Google's libphonenumber library.\n\n[![](https://jitpack.io/v/ibrahimsn98/PhoneNumberKit.svg)](https://jitpack.io/#ibrahimsn98/PhoneNumberKit)\n\n\n## Features\n\n| |Features |\n--------------------------|------------------------------------------------------------\n:phone: | Validate, normalize and extract the elements of any phone number string.\n:dart: | Convert raw phone number to formatted phone number string.\n:mag: | Automatically detects country flag of the phone number. \n:bookmark: | Country code selection bottom sheet.\n:pushpin: | Convert country codes to country names and vice versa.\n:tr: | Get country flag icon for given iso2 code.\n\n\n## Usage\n\nCreate a phoneNumberKit instance and attach it to an editTextLayout. That's all you have to do.\n\n```kotlin\nval phoneNumberKit = PhoneNumberKit.Builder(this)\n    .setIconEnabled(true)\n    .admitCountries(listOf(\"tr\", \"ca\", \"de\")) // List only those county formats\n    .excludeCountries(listOf(\"tr\", \"ca\")) // Exclude those county formats\n    .build()\n\nphoneNumberKit.attachToInput(textField, \"tr\")\n// OR\nphoneNumberKit.attachToInput(textField, 1)\n```\n\nTo setup with country code selection bottom sheet\n\n```kotlin\nphoneNumberKit.setupCountryPicker(this) // Requires activity context\n```\n\nTo get an example phone number for given **iso2 code**\n\n```kotlin\nval exampleNumber = phoneNumberKit.getExampleNumber(\"tr\")\n```\n\nTo parse raw text to phone number and receive country code, national number\n\n```kotlin\nval parsedNumber = phoneNumberKit.parsePhoneNumber(\n    number = \"1266120000\",\n    defaultRegion = \"us\"\n)\n\nparsedNumber?.nationalNumber\nparsedNumber?.countryCode\nparsedNumber?.numberOfLeadingZeros\n```\n\nTo convert raw text to formatted phone number string\n\n```kotlin\nval formattedNumber = phoneNumberKit.formatPhoneNumber(\n    number = \"1266120000\",\n    defaultRegion = \"us\"\n)\n```\n\nTo receive a country **flag icon** for given iso2 code\n\n```kotlin\nval flag = phoneNumberKit.getFlagIcon(\"ca\")\n```\n\n## Usage with Custom Item Layout\n\nAdd your custom item layout resource as a parameter\n\n```kotlin\nphoneNumberKit.setupCountryPicker(this, R.layout.my_item_layout, searchEnabled = true)\n```\n\nYou need to use below view ids in your layout file\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n\u003cLinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:orientation=\"horizontal\"\n    android:paddingVertical=\"12dp\"\n    android:paddingHorizontal=\"18dp\"\n    android:clickable=\"true\"\n    android:focusable=\"true\"\n    android:background=\"?android:attr/selectableItemBackground\"\u003e\n\n    \u003cImageView\n        android:id=\"@+id/imageViewFlag\"\n        android:layout_width=\"22dp\"\n        android:layout_height=\"22dp\" /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/textViewName\"\n        android:layout_width=\"0dp\"\n        android:layout_height=\"wrap_content\"\n        android:layout_weight=\"1\"\n        android:layout_marginStart=\"16dp\"\n        android:layout_marginEnd=\"16dp\"\n        android:singleLine=\"true\"\n        android:maxLines=\"1\"\n        android:ellipsize=\"end\"\n        android:textSize=\"16sp\"\n        android:textColor=\"#232425\" /\u003e\n\n    \u003cTextView\n        android:id=\"@+id/textViewCode\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:textSize=\"16sp\"\n        android:textColor=\"#838383\" /\u003e\n\n\u003c/LinearLayout\u003e\n```\n\n\n## Demo\n\u003ctable\u003e\n\t\u003ctr\u003e\n\t\t\u003cth\u003eCountry Code Picker\u003c/th\u003e\n\t\t\u003cth\u003eFormat Example\u003c/th\u003e\n\t\t\u003cth\u003eFormat Example\u003c/th\u003e\n \t\u003c/tr\u003e\n \t\u003ctr\u003e\n  \t\t\u003ctd\u003e\u003cimg src=\"https://github.com/ibrahimsn98/PhoneNumberKit/blob/master/art/ss1.jpg\" width=\"250\" /\u003e\u003c/td\u003e\n   \t\t\u003ctd\u003e\u003cimg src=\"https://github.com/ibrahimsn98/PhoneNumberKit/blob/master/art/ss3.jpg\" width=\"250\" /\u003e\u003c/td\u003e\n\t\t\u003ctd\u003e\u003cimg src=\"https://github.com/ibrahimsn98/PhoneNumberKit/blob/master/art/ss2.jpg\" width=\"250\" /\u003e\u003c/td\u003e\n \t\u003c/tr\u003e\n\u003c/table\u003e\n\n## Installation\n\n\u003e Follow me on Twitter [@ibrahimsn98](https://twitter.com/ibrahimsn98)\n\nStep 1. Add the JitPack repository to your build file\n```\nallprojects {\n\trepositories {\n\t\t...\n\t\tmaven { url 'https://jitpack.io' }\n\t}\n}\n```\nStep 2. Add the dependency\n```\ndependencies {\n    implementation 'com.github.ibrahimsn98:PhoneNumberKit:2.0.6'\n}\n```\n\n## Checklist\n- [x] Search for country codes\n- [x] Custom list item layout support\n- [x] Better performance with coroutines\n- [ ] Phone number validation indicator\n- [x] Dark theme\n- [ ] Tests\n\n## Conception\n- This library is based on Google's lilPhoneNumber library (https://github.com/google/libphonenumber)\n- Inspired from PhoneNumberKit Swift library by [marmelloy](https://github.com/marmelroy) (https://github.com/marmelroy/PhoneNumberKit)\n- Flag images from [region-flags](https://github.com/behdad/region-flags)\n\n## License\nPhoneNumberKit is available under the Apache license. See the [LICENSE](https://github.com/ibrahimsn98/PhoneNumberKit/blob/master/LICENSE) file for more info.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibrahimsn98%2Fphonenumberkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibrahimsn98%2Fphonenumberkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibrahimsn98%2Fphonenumberkit/lists"}