aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-08-26 13:35:01 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-08-26 13:35:01 +0200
commite33d8451a899bd014ef5b142289c3c1c35c989bd (patch)
treef653c678bdadfb69249fb82d1e6801f4d1f1477a /src/main
parentf931c08da7fba912592fe7be495bfd47a4069178 (diff)
attach contact to notification
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/entities/Contact.java16
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java8
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java21
3 files changed, 30 insertions, 15 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/Contact.java b/src/main/java/eu/siacs/conversations/entities/Contact.java
index 676c91d0..e512b586 100644
--- a/src/main/java/eu/siacs/conversations/entities/Contact.java
+++ b/src/main/java/eu/siacs/conversations/entities/Contact.java
@@ -3,6 +3,8 @@ package eu.siacs.conversations.entities;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
+import android.net.Uri;
+import android.provider.ContactsContract;
import org.json.JSONArray;
import org.json.JSONException;
@@ -265,8 +267,18 @@ public class Contact implements ListItem, Blockable {
this.presenceName = presenceName;
}
- public String getSystemAccount() {
- return systemAccount;
+ public Uri getSystemAccount() {
+ if (systemAccount == null) {
+ return null;
+ } else {
+ String[] parts = systemAccount.split("#");
+ if (parts.length != 2) {
+ return null;
+ } else {
+ long id = Long.parseLong(parts[0]);
+ return ContactsContract.Contacts.getLookupUri(id, parts[1]);
+ }
+ }
}
public void setSystemAccount(String account) {
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index f6b6ce00..f86152e2 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -35,6 +35,7 @@ import java.util.regex.Pattern;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
@@ -324,6 +325,13 @@ public class NotificationService {
createShowLocationIntent(message));
}
}
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ Contact contact = conversation.getContact();
+ Uri systemAccount = contact.getSystemAccount();
+ if (systemAccount != null) {
+ mBuilder.addPerson(systemAccount.toString());
+ }
+ }
mBuilder.setWhen(conversation.getLatestMessage().getTimeSent());
mBuilder.setSmallIcon(R.drawable.ic_notification);
mBuilder.setDeleteIntent(createDeleteIntent(conversation));
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index d663cbd1..af1a9917 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -10,7 +10,6 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
-import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Intents;
@@ -137,7 +136,8 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
@Override
public void onClick(View v) {
- if (contact.getSystemAccount() == null) {
+ Uri systemAccount = contact.getSystemAccount();
+ if (systemAccount == null) {
AlertDialog.Builder builder = new AlertDialog.Builder(
ContactDetailsActivity.this);
builder.setTitle(getString(R.string.action_add_phone_book));
@@ -147,12 +147,9 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
builder.setPositiveButton(getString(R.string.add), addToPhonebook);
builder.create().show();
} else {
- String[] systemAccount = contact.getSystemAccount().split("#");
- long id = Long.parseLong(systemAccount[0]);
- Uri uri = ContactsContract.Contacts.getLookupUri(id, systemAccount[1]);
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setData(uri);
- startActivity(intent);
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(systemAccount);
+ startActivity(intent);
}
}
};
@@ -253,7 +250,8 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
removeFromRoster).create().show();
break;
case R.id.action_edit_contact:
- if (contact.getSystemAccount() == null) {
+ Uri systemAccount = contact.getSystemAccount();
+ if (systemAccount == null) {
quickEdit(contact.getDisplayName(), 0, new OnValueEdited() {
@Override
@@ -266,10 +264,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
});
} else {
Intent intent = new Intent(Intent.ACTION_EDIT);
- String[] systemAccount = contact.getSystemAccount().split("#");
- long id = Long.parseLong(systemAccount[0]);
- Uri uri = Contacts.getLookupUri(id, systemAccount[1]);
- intent.setDataAndType(uri, Contacts.CONTENT_ITEM_TYPE);
+ intent.setDataAndType(systemAccount, Contacts.CONTENT_ITEM_TYPE);
intent.putExtra("finishActivityOnSaveCompleted", true);
startActivity(intent);
}