All Projects → quiin → Unifiedcontactpicker

quiin / Unifiedcontactpicker

Licence: apache-2.0

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Unifiedcontactpicker

FireFiles
Powerful Android File Manager for everything that runs on Android OS (Android TV, Android Watch, Mobile, etc)
Stars: ✭ 37 (-79.21%)
Mutual labels:  material, phone
Md2
Angular2 based Material Design components, directives and services are Accordion, Autocomplete, Collapse, Colorpicker, Datepicker, Dialog(Modal), Menu, Multiselect, Select, Tabs, Tags(Chips), Toast and Tooltip.
Stars: ✭ 389 (+118.54%)
Mutual labels:  chip, material
Chips Input Layout
A customizable Android ViewGroup for displaying Chips (specified in the Material Design Guide).
Stars: ✭ 591 (+232.02%)
Mutual labels:  chip, material
Material Apex
A Material Design Theme for Oracle APEX
Stars: ✭ 161 (-9.55%)
Mutual labels:  material
Django Material Admin
Material design for django administration
Stars: ✭ 163 (-8.43%)
Mutual labels:  material
Materialdesign2
A beautiful app designed with Material Design 2 using Android X.
Stars: ✭ 170 (-4.49%)
Mutual labels:  material
Polybar Collection
Beautiful collection of Polybar themes
Stars: ✭ 172 (-3.37%)
Mutual labels:  material
React Ripples
🏊 Material ripple effect. Ripples everything
Stars: ✭ 160 (-10.11%)
Mutual labels:  material
Ficsave
This is the repo for FicSave, an open-source online fanfiction downloader.
Stars: ✭ 172 (-3.37%)
Mutual labels:  material
Materialsearchbar
Material Design Search Bar for Android
Stars: ✭ 2,008 (+1028.09%)
Mutual labels:  material
Material Components Flutter Codelabs
Codelabs for Material Components for Flutter (MDC-Flutter)
Stars: ✭ 165 (-7.3%)
Mutual labels:  material
Mui Datatables
Datatables for React using Material-UI - https://www.material-ui-datatables.com
Stars: ✭ 2,246 (+1161.8%)
Mutual labels:  material
Rimlight
Customizable rimlight shader for Unity that includes pulsation and noise scrolling. Give your scenes that extra oomph!
Stars: ✭ 170 (-4.49%)
Mutual labels:  material
Primereact
The Most Complete React UI Component Library
Stars: ✭ 2,393 (+1244.38%)
Mutual labels:  material
Libphonenumber Js
A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript
Stars: ✭ 2,233 (+1154.49%)
Mutual labels:  phone
Expansionpanel
Android - Expansion panels contain creation flows and allow lightweight editing of an element.
Stars: ✭ 1,984 (+1014.61%)
Mutual labels:  material
Johnny Five
JavaScript Robotics and IoT programming framework, developed at Bocoup.
Stars: ✭ 12,498 (+6921.35%)
Mutual labels:  chip
Jekyll Material Theme
A Jekyll Theme based on Material Design using Materialize.
Stars: ✭ 165 (-7.3%)
Mutual labels:  material
Rhsidebuttons
Library provides easy to implement variation of Android (Material Design) Floating Action Button for iOS. You can use it as your app small side menu. 🌶
Stars: ✭ 164 (-7.87%)
Mutual labels:  material
Minimal Todo
Material To-Do App
Stars: ✭ 2,051 (+1052.25%)
Mutual labels:  material

Unified Contact Picker Android Library

GitHub release Min SDK GitHub license Android Arsenal

Introduction

This library unifies the user contacts in a compact and user intuitive way allowing the end-user to choose between the contact's available communication options (email/phone number) follows Material Design guidelines.

Although there is a standard way to call the contact list in Android, it does not always feel well-integrated in your app Android applications. UnifiedContactPicker is an Android library which allows you to easily integrate contact picking workflow into your application with minimal effort

IMPORTANT ❗️


This library is no longer in active development. However, pull requests for new features or bugfixes are always welcomed and will be attended.

Demo

Features

  • Unifies user's contacts
  • Customizable UI
  • Easy and redy to use
  • Display list of contacts
  • Intuitive interface
  • Follows Material Design guidelines
  • Asynchronous contact loading

Installation

In order to use the library, add the following line to your root gradle file:

 
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    ...
}
 

As well as this line in your project build.gradle file

 
dependencies {
    compile 'com.github.quiin:unifiedContactPicker:{LATEST_VERSION}'
    ...
}
 

Usage

To use UnifiedContactPicker in your app simply follow this 3 simple steps:

  1. Add read contacts permission in your manifest
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
  1. Launch ContactPickerActivity.java as activity result
// Your Activity or Fragment
public void launchContactPicker(View view) {
        int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);
        if(permissionCheck == PackageManager.PERMISSION_GRANTED){
            Intent contactPicker = new Intent(this, ContactPickerActivity.class);
            startActivityForResult(contactPicker, CONTACT_PICKER_REQUEST);
        }else{
            ActivityCompat.requestPermissions(this,
                    new String[] {Manifest.permission.READ_CONTACTS},
                    READ_CONTACT_REQUEST);
        }
    }

  1. Override onActivityResult() and wait for the user to select the contacts.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode){
        case CONTACT_PICKER_REQUEST:
            if(resultCode == RESULT_OK){
                TreeSet<SimpleContact> selectedContacts = (TreeSet<SimpleContact>)data.getSerializableExtra(ContactPickerActivity.CP_SELECTED_CONTACTS);
                for (SimpleContact selectedContact : selectedContacts)
                        Log.e("Selected", selectedContact.toString());
            }else
                Toast.makeText(this, "No contacts selected", Toast.LENGTH_LONG).show();
        break;
        default:
            super.onActivityResult(requestCode,resultCode,data);
        }
}

Contacts are returned in a TreeSet of SimpleContact; each SimpleContact object ha the following accessible properties:

  • DisplayName - Contact display name
  • Communication - Contact selected communication (email/phone)

⚠️ IMPORTANT

As of SDK 23 (Android 6) developers are requested to explicitly ask for permissions at runtime. So please be sure to request for contact reading permissions using the previous code or any other means you prefer.

Customization

The following UI views can be customized:

UI component Intent extra Expected value Type Sugestion
FAB color CP_EXTRA_FAB_COLOR hexColor String -
Selection color CP_EXTRA_SELECTION_COLOR hexColor String -
Selection Drawable CP_EXTRA_SELECTION_DRAWABLE Image byte [] use PickerUtils.sendDrawable()
Fab drawable CP_EXTRA_FAB_DRAWABLE Image byte [] use PickerUtils.sendDrawable()
Chips CP_EXTRA_SHOW_CHIPS boolean boolean -

Aditionally, you can customize the contact query parameters used to extract the user's contacts adding the following extras to the intent

Extra Type
CP_EXTRA_PROJECTION String []
CP_EXTRA_SELECTION String
CP_EXTRA_SELECTION_ARGS String []
CP_EXTRA_HAS_CUSTOM_SELECTION_ARGS boolean
CP_EXTRA_SORT_BY String

Example

public void launchContactPicker(View view) {
        int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS);
        if(permissionCheck == PackageManager.PERMISSION_GRANTED){
            Intent contactPicker = new Intent(this, ContactPickerActivity.class);
            //Don't show Chips
            contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SHOW_CHIPS, false);
            //Customize Floating action button color
            contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_FAB_COLOR, "#FFF722");
            //Customize Selection drawable
            contactPicker.putExtra(ContactPickerActivity.CP_EXTRA_SELECTION_DRAWABLE, PickerUtils.sendDrawable(getResources(),R.drawable.my_drawable));
            startActivityForResult(contactPicker, CONTACT_PICKER_REQUEST);
        }else{
            ActivityCompat.requestPermissions(this,
                    new String[] {Manifest.permission.READ_CONTACTS},
                    READ_CONTACT_REQUEST);
        }
    }

Default values & behavior

  • Default projection columns:

    • ContactsContract.Data._ID
    • ContactsContract.Contacts.DISPLAY_NAME
    • ContactsContract.CommonDataKinds.Phone.NUMBER
    • ContactsContract.Data.MIMETYPE
  • Default selection query:

"(" + ContactsContract.Data.MIMETYPE + "=? OR " + ContactsContract.Data.MIMETYPE + "=?)"
  • Default selection params:
    • ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE
    • ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE
  • Default sorting: DisplayName Ascendant
  • A chip is added to the textview when one of the following happens:
    • User chooses a contact from the contact list
    • User writes a new email/phone - the chip is created after an empty space is found (" ")

Considerations

  • In the absence of any of these extras, its value will fallback to the default value
  • If you wish to use a custom selection string (CP_EXTRA_SELECTION) with custom selection arguments (CP_EXTRA_SELECTION_ARGS) the use of CP_EXTRA_HAS_CUSTOM_SELECTION_ARGS is required in order for the query to work (see defaults section for more information)

Support & extension

  • Feel free to make any pull request to add a new behaviour or fix some existing bug
  • Feel free to open issues if you find some bug or unexpected behaviour
  • I'll keep polishing and giving support to this library in my free time

Acknowledgments

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].