diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-08-03 22:17:22 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-08-03 22:17:22 +0200 |
commit | c0ed19f913d8969d5cde9afed892ff4b516ddbc8 (patch) | |
tree | 18db331eb43271c4c76b34b172364651c0bf24b3 /src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java | |
parent | 59684c709e9a6f9fb620a2ac9ddd798f7fb2d8a8 (diff) |
show toast if no address book app is installed
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java index 4919a4251..5dce3fca2 100644 --- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java @@ -1,5 +1,6 @@ package de.pixart.messenger.ui; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -116,12 +117,14 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); intent.setType(Contacts.CONTENT_ITEM_TYPE); - intent.putExtra(Intents.Insert.IM_HANDLE, contact.getJid().toString()); - intent.putExtra(Intents.Insert.IM_PROTOCOL, - CommonDataKinds.Im.PROTOCOL_JABBER); + intent.putExtra(Intents.Insert.IM_HANDLE, contact.getJid().toEscapedString()); + intent.putExtra(Intents.Insert.IM_PROTOCOL, CommonDataKinds.Im.PROTOCOL_JABBER); intent.putExtra("finishActivityOnSaveCompleted", true); - ContactDetailsActivity.this.startActivityForResult(intent, 0); - overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + try { + ContactDetailsActivity.this.startActivityForResult(intent, 0); + } catch (ActivityNotFoundException e) { + Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show(); + } } }; @@ -308,8 +311,12 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp Intent intent = new Intent(Intent.ACTION_EDIT); intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE); intent.putExtra("finishActivityOnSaveCompleted", true); - startActivity(intent); - overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + try { + startActivity(intent); + overridePendingTransition(R.animator.fade_in, R.animator.fade_out); + } catch (ActivityNotFoundException e) { + Toast.makeText(ContactDetailsActivity.this, R.string.no_application_found_to_view_contact, Toast.LENGTH_SHORT).show(); + } } break; case R.id.action_block: |