{"id":17713605,"url":"https://github.com/waffiqaziz/country-picker-android","last_synced_at":"2025-05-05T17:57:45.002Z","repository":{"id":258359070,"uuid":"871890420","full_name":"waffiqaziz/country-picker-android","owner":"waffiqaziz","description":"An android library which provides an easy way to search and select country using country name, country iso code, or international phone code.","archived":false,"fork":false,"pushed_at":"2025-05-03T13:12:04.000Z","size":4260,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-03T13:52:04.683Z","etag":null,"topics":["android","circleci","country","country-codes","country-names","country-picker","country-search","country-selector","kotlin","library","xml"],"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/waffiqaziz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-13T08:24:51.000Z","updated_at":"2025-05-03T13:12:08.000Z","dependencies_parsed_at":"2025-05-03T13:57:29.316Z","dependency_job_id":null,"html_url":"https://github.com/waffiqaziz/country-picker-android","commit_stats":null,"previous_names":["waffiqaziz/country-picker-android"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waffiqaziz%2Fcountry-picker-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waffiqaziz%2Fcountry-picker-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waffiqaziz%2Fcountry-picker-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waffiqaziz%2Fcountry-picker-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waffiqaziz","download_url":"https://codeload.github.com/waffiqaziz/country-picker-android/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252547657,"owners_count":21766033,"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","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","circleci","country","country-codes","country-names","country-picker","country-search","country-selector","kotlin","library","xml"],"created_at":"2024-10-25T10:05:29.514Z","updated_at":"2025-05-05T17:57:44.982Z","avatar_url":"https://github.com/waffiqaziz.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Country Picker Android\n\n![Header](/assets/images/feature_graphic.png)\n\n[![](https://jitpack.io/v/waffiqaziz/country-picker-android.svg)](https://jitpack.io/#waffiqaziz/country-picker-android)\n![Unit Testing](https://github.com/waffiqaziz/country-picker-android/actions/workflows/unit_testing.yml/badge.svg)\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/waffiqaziz/country-picker-android/tree/master.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/waffiqaziz/country-picker-android/tree/master)\n![GitHub License](https://img.shields.io/github/license/waffiqaziz/country-picker-android)\n[![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fwaffiqaziz%2Fcountry-picker-android%2F\u0026countColor=%2388d66c\u0026style=flat)](https://visitorbadge.io/status?path=https%3A%2F%2Fgithub.com%2Fwaffiqaziz%2Fcountry-picker-android%2F)\n![Monthly download statistics](https://jitpack.io/v/waffiqaziz/country-picker-android/month.svg)\n![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/waffiqaziz/country-picker-android)\n![GitHub forks](https://img.shields.io/github/forks/waffiqaziz/country-picker-android)\n[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fwaffiqaziz%2Fcountry-picker-android.svg?type=small)](https://app.fossa.com/projects/git%2Bgithub.com%2Fwaffiqaziz%2Fcountry-picker-android?ref=badge_small)\n\n\nA user-friendly country picker for Android that allows users to select countries and search using\ncountry names, country code names, and country phone codes.\n\n## How to Integrate into Your Project\n\nIntegrating the `Country Picker Android` library into your Android project is simple and\nstraightforward.\nFollow the steps below based on your Gradle setup.\n\n1. Add JitPack to Your Repositories\n\n   To use the Country Picker Android library, ensure you include the JitPack repository in your\n   build.gradle\n   files.\n   For Gradle Version 7.0 and Above (Using Dependency Resolution Management)\n   In your project's settings.gradle (or settings.gradle.kts for Kotlin), add the following:\n\n    ```groovy\n    dependencyResolutionManagement {\n      repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n      repositories {\n        mavenCentral()\n        \n        // groovy\n        maven { url 'https://jitpack.io' }\n   \n        // kotlin\n        maven(\"https://jitpack.io\")\n      }\n    }\n    ```\n\n   For Gradle Version Below 7.0\n   In your project-level build.gradle (or build.gradle.kts for Kotlin), add JitPack to the\n   repositories\n   section:\n\n    ```groovy\n    allprojects {\n      repositories {\n        google()\n        mavenCentral()\n        \n        // groovy\n        maven { url 'https://jitpack.io' }\n        \n        // kotlin\n        maven(\"https://jitpack.io\")\n      }\n    }\n    ```\n\n2. Add the Dependency\n   Next, add the CountryPicker library dependency in your app-level build.gradle (or\n   build.gradle.kts for Kotlin):\n   ```groovy\n   dependencies {\n       // ...others dependency\n       \n       // groovy\n       implementation 'com.github.waffiqaziz:country-picker-android:Tag'                                                                        \n   \n       // kotlin\n       implementation(\"com.github.waffiqaziz:country-picker-android:Tag\")\n   }\n   ```\n\n   *change `Tag` with the latest version*\n3. Sync Your Project\n\n   After adding the dependency, sync your project with Gradle files. You can do this by clicking on\n   the \"Sync Now\" prompt that appears or by going to File \u003e Sync Project with Gradle Files.\n4. Usage Example\n\n   The `CountryPicker` library is integrated using XML layouts.\n\n    \u003cdetails\u003e\n      \u003csummary\u003eBasic implementation\u003c/summary\u003e\n\n      ```xml\n      \u003ccom.waffiq.CountryPickerButton\n        android:id=\"@+id/cpb\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:foreground=\"?attr/selectableItemBackgroundBorderless\"\n        app:cardBackgroundColor=\"@android:color/transparent\"\n        app:cardCornerRadius=\"15dp\"\n        app:cardElevation=\"0dp\"\n        app:strokeWidth=\"0dp\" /\u003e\n      ```\n\n   |                 CountryPickerButton                  |                                                                                                  CountryPickerDialog                                                                                                   |\n   |:----------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n   | \u003cimg src=\"assets/images/button_basic.png\" width=100\u003e | \u003cimg src=\"assets/images/dialog_basic.png\" width=200\u003e  \u003cimg src=\"assets/images/dialog_basic.jpg\" width=200\u003e \u003cimg src=\"assets/images/dialog_basic2.jpg\" width=200\u003e \u003cimg src=\"assets/images/dialog_basic3.jpg\" width=200\u003e |\n    \n   \u003c/details\u003e\n\n   \u003cdetails\u003e\n      \u003csummary\u003eWith customization\u003c/summary\u003e\n\n      ```xml\n      \u003ccom.waffiq.CountryPickerButton\n        android:id=\"@+id/cpb_custom\"\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:layout_gravity=\"center\"\n        android:clickable=\"true\"\n        android:focusable=\"true\"\n        android:foreground=\"?attr/selectableItemBackgroundBorderless\"\n        app:cardBackgroundColor=\"@color/darkPurple\"\n        app:cardCornerRadius=\"15dp\"\n        app:cardElevation=\"0dp\"\n        app:cpa_defaultCountryISO=\"US\"\n        app:cpa_dialogApplyBorderSearch=\"true\"\n        app:cpa_dialogAutoFocus=\"true\"\n        app:cpa_dialogBackgroundColor=\"@color/darkPurple\"\n        app:cpa_dialogSearchBackgroundColor=\"@color/darkPurple\"\n        app:cpa_dialogSearchCrossIconColor=\"@color/gray\"\n        app:cpa_dialogTextColor=\"@color/gray\"\n        app:cpa_dialogTextHintColor=\"@color/dark_gray\"\n        app:cpa_fontFamily=\"@font/nunito_sans_regular\"\n        app:strokeWidth=\"0dp\" /\u003e\n   ```\n\n   |                  CountryPickerButton                  |                                                                                                    CountryPickerDialog                                                                                                    |\n   |:-----------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n   | \u003cimg src=\"assets/images/button_custom.png\" width=100\u003e | \u003cimg src=\"assets/images/dialog_custom.png\" width=200\u003e \u003cimg src=\"assets/images/dialog_custom.jpg\" width=200\u003e \u003cimg src=\"assets/images/dialog_custom2.jpg\" width=200\u003e \u003cimg src=\"assets/images/dialog_custom3.jpg\" width=200\u003e |\n   \n   \u003c/details\u003e\n\n## Listeners and functions\n\n### Set default country\n\nTo set the default country programmatically, you can use the `setCountry()` method:\n\n  ```kotlin\n  binding.cpb.setCountry(\"MY\")  // use viewbinding\n\n  // or\n\n  findViewById\u003cCountryPickerButton\u003e(R.id.cpb).setCountry(\"MY\")\n  ```\n\n### Get selected country\n\nTo get the selected country when using `CountryPickerButton`, you can implement\nthe `onCountrySelectedListener`:\n\n   ```kotlin\n   binding.cpb.onCountrySelectedListener = {\n      Toast.makeText(this@MainActivity, it.name, Toast.LENGTH_SHORT).show()\n   }\n   ```\n\nTo get the selected country without listener using `selectedCountryCode`\n\n   ```kotlin\n   binding.cpb.selectedCountryCode // return \"ID\" (default country)\n   ```\n\nNote : You can also explore more about `CountryPickerButton`\nvia [activity_layout](https://github.com/waffiqaziz/country-picker-android/blob/master/app/src/main/res/layout/activity_main.xml). `CountryPickerButton`\nbasically implemented as an extension of `MaterialCardView`, giving you more flexibility to\ncustomize its appearance and behavior according to the Material Design guidelines. You can read more\nabout\nMaterialCardView [here](https://github.com/material-components/material-components-android/blob/master/docs/components/Card.md).\n\n## How to Contribute\n\nRead this [page](CONTRIBUTING.md)\n\n## Reporting Issues\n\nIf you encounter any issues or bugs, feel free to open a new issue in the repository and provide as\nmuch detail as possible. Include `steps to reproduce the issue`, the `expected behavior`, and any\n`relevant logs`.\n\n## Special Thanks\n\nGrateful acknowledgment to the following resources and projects for their valuable contributions:\n\n\n- [Flagpedia.net](https://flagpedia.net/download) - For providing the country flags used in this\n  project.\n- [CountryCodePickerProject](https://github.com/hbb20/CountryCodePickerProject) - For inspiring the\n  creation of this project.\n\n## License\n\n[Apache Version 2.0](LICENSE)\n\n```text\nCopyright 2024 Waffiq Aziz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaffiqaziz%2Fcountry-picker-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaffiqaziz%2Fcountry-picker-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaffiqaziz%2Fcountry-picker-android/lists"}