DomainGroupOSS / accounts-autocomplete

An M-compatible custom AutoCompleteTextView that shows the user's Google accounts as autocomplete suggestions.
Apache License 2.0
16 stars 4 forks source link

accounts-autocomplete

An M-compatible custom AutoCompleteTextView that shows the user's Google accounts as autocomplete suggestions.

This widget is based on the GMail behaviour of subtly asking for permissions for autcompleting email addresses.

Before permission is granted:
Allow Suggestions

After permission is granted:
With Suggestions

Usage

compile 'au.com.domain:accounts-autocomplete:1.0.0'

Drop in au.com.domain.AccountsAutoCompleteTextView in your layout:

<au.com.domain.AccountsAutoCompleteTextView
        android:id="@+id/accounts_autocomplete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

and set it up in the Activity:

mAccountsAutoCompleteTextView.setParentActivity(this);

or Fragment:

mAccountsAutoCompleteTextView.setParentFragment(this);

You would then need to override the onRequestPermissionsResult callback:

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    mAccountsAutoCompleteTextView.onPermissionResponse(requestCode, permissions, grantResults);
}