aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Contact.java16
-rw-r--r--src/main/java/de/pixart/messenger/services/NotificationService.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java21
3 files changed, 30 insertions, 15 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java
index 06fd4592c..090486243 100644
--- a/src/main/java/de/pixart/messenger/entities/Contact.java
+++ b/src/main/java/de/pixart/messenger/entities/Contact.java
@@ -3,6 +3,8 @@ package de.pixart.messenger.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/de/pixart/messenger/services/NotificationService.java b/src/main/java/de/pixart/messenger/services/NotificationService.java
index 34496a3c2..92876205c 100644
--- a/src/main/java/de/pixart/messenger/services/NotificationService.java
+++ b/src/main/java/de/pixart/messenger/services/NotificationService.java
@@ -36,6 +36,7 @@ import java.util.regex.Pattern;
import de.pixart.messenger.Config;
import de.pixart.messenger.R;
import de.pixart.messenger.entities.Account;
+import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Message;
import de.pixart.messenger.ui.ConversationActivity;
@@ -329,6 +330,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/de/pixart/messenger/ui/ContactDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
index 99a44303f..ca0c8ce9c 100644
--- a/src/main/java/de/pixart/messenger/ui/ContactDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/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;
@@ -138,7 +137,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));
@@ -148,12 +148,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);
}
}
};
@@ -254,7 +251,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
@@ -267,10 +265,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);
}