1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-26 17:57:16 +00:00

Check if contact picker

This commit is contained in:
M66B 2018-11-13 20:45:09 +01:00
parent 5dc342eed4
commit 3326088820
2 changed files with 25 additions and 18 deletions

View file

@ -201,29 +201,35 @@ public class FragmentCompose extends FragmentEx {
}
});
ivToAdd.setOnClickListener(new View.OnClickListener() {
View.OnClickListener onPick = new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);
startActivityForResult(intent, ActivityCompose.REQUEST_CONTACT_TO);
}
});
int request;
switch (view.getId()) {
case R.id.ivToAdd:
request = ActivityCompose.REQUEST_CONTACT_TO;
break;
case R.id.ivCcAdd:
request = ActivityCompose.REQUEST_CONTACT_CC;
break;
case R.id.ivBccAdd:
request = ActivityCompose.REQUEST_CONTACT_BCC;
break;
default:
return;
}
ivCcAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);
startActivityForResult(intent, ActivityCompose.REQUEST_CONTACT_CC);
Intent pick = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);
if (pick.resolveActivity(getContext().getPackageManager()) == null)
Snackbar.make(view, R.string.title_no_contacts, Snackbar.LENGTH_LONG).show();
else
startActivityForResult(pick, request);
}
});
};
ivBccAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);
startActivityForResult(intent, ActivityCompose.REQUEST_CONTACT_BCC);
}
});
ivToAdd.setOnClickListener(onPick);
ivCcAdd.setOnClickListener(onPick);
ivBccAdd.setOnClickListener(onPick);
edit_bar.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override

View file

@ -219,6 +219,7 @@
<string name="title_no_answers">No reply templates defined</string>
<string name="title_no_viewer">No viewer app available for %1$s</string>
<string name="title_no_saf">Storage access framework not available</string>
<string name="title_no_contacts">Contact picker not available</string>
<string name="title_attachment_saved">Attachment saved</string>
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be forwarded, continue?</string>
<string name="title_ask_delete">Delete message permanently?</string>