Skip to content

CPDataStore

Harsh B. Bhakta edited this page Aug 26, 2020 · 2 revisions

CPData Store is responsible for following:

  • List of countries
  • Library messages
    • noMatchMsg : message text that appears when no entry matches search query
    • searchHint : hint text of search edit text
    • dialogTitle : title text of country picker dialog
    • selectionPlaceholderText : text shown as place holder when no country is selected
    • clearSelectionText : text of button that allows to clear country selection

CPDataStoreGenerator

  • CPData store can be created using CPDataStoreGenerator.generate().
  • Custom Master List
    • If you are interested in showing only a few countries, then you should define your CustomMasterCountryList
    • To define CustomMasterCountryList, pass comma separated alpha2/alpha3 of countries to generate() method.
    • val cpDataStore = CPDataStoreGenerator.generate(context = context, customMasterCountries = "IN,US,CN,AU") 
    • Generated cpDataStore will have only these 4 countries.
  • Custom excluded List
    • If you want to show full list except certain countries, then you should define your CustomExcludedCountryList
    • To define CustomExcludedCountryList, pass comma separated alpha2/alpha3 of countries to generate() method.
    • val cpDataStore = CPDataStoreGenerator.generate(context = context, customExcludedCountries = "IN,US,CN,AU") 
    • Generated cpDataStore will have all countries except these 4 countries.

Override Country Name

  • If there is a typo error in country name, feel free to create a new issue
  • If you want to change some country's name for your project do following
    • By default, country names are picked from string resource from cp_country_translation.xml.
    • Format of string resource key is cp_$$_name where $$ is alpha2 code (block letters) of the country. It will be cp_AU_name for Australia (AU).
    • If you add a string resource with this key in your project's app module, then your string resource will be the new name of the country.

Override Library Message

  • If there is a typo error in message text, feel free to create a new issue
  • If you want to change message text for your project do following
    • By default, country names are picked from string resource from cp_message_translation.xml.
    • Open cp_message_translation.xml to find key of the message that you want to override.
    • If you add a string resource with that key in your project's app module, then your string resource will be the new value of the library message.