diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java
index f73c2bc061..4e1201565a 100644
--- a/app/src/main/java/eu/faircode/email/FragmentCompose.java
+++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java
@@ -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
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6840b7aa20..8b36372ada 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -219,6 +219,7 @@
No reply templates defined
No viewer app available for %1$s
Storage access framework not available
+ Contact picker not available
Attachment saved
Some attachments are not downloaded and will not be forwarded, continue?
Delete message permanently?