aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/ui
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-01 01:25:56 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-01 01:25:56 +0100
commit43531113b798cda6b2f76257641f38b0af986437 (patch)
tree73107f086ec5d772a9041aa3ad4b1c7b8e0dcce9 /src/de/gultsch/chat/ui
parentc3e4f0eaacf8ab32ceab32b8f46e8b7d85c71cfb (diff)
more code cleanup for xmpp parser. more eventy. nice unknown contact pictures
Diffstat (limited to 'src/de/gultsch/chat/ui')
-rw-r--r--src/de/gultsch/chat/ui/ConversationActivity.java11
-rw-r--r--src/de/gultsch/chat/ui/NewConversationActivity.java20
2 files changed, 23 insertions, 8 deletions
diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java
index d831f9b8..79d1e218 100644
--- a/src/de/gultsch/chat/ui/ConversationActivity.java
+++ b/src/de/gultsch/chat/ui/ConversationActivity.java
@@ -9,6 +9,7 @@ import de.gultsch.chat.R;
import de.gultsch.chat.R.id;
import de.gultsch.chat.entities.Conversation;
import de.gultsch.chat.utils.Beautifier;
+import android.net.Uri;
import android.os.Bundle;
import android.app.FragmentTransaction;
import android.content.Context;
@@ -106,6 +107,16 @@ public class ConversationActivity extends XmppActivity {
((TextView) view.findViewById(R.id.conversation_lastmsg)).setText(getItem(position).getLatestMessage());
((TextView) view.findViewById(R.id.conversation_lastupdate))
.setText(Beautifier.readableTimeDifference(getItem(position).getLatestMessageDate()));
+
+ Uri profilePhoto = getItem(position).getProfilePhotoUri();
+ ImageView imageView = (ImageView) view.findViewById(R.id.conversation_image);
+ if (profilePhoto!=null) {
+ imageView.setImageURI(profilePhoto);
+ } else {
+ imageView.setImageBitmap(Beautifier.getUnknownContactPicture(getItem(position).getName(),200));
+ }
+
+
((ImageView) view.findViewById(R.id.conversation_image))
.setImageURI(getItem(position).getProfilePhotoUri());
return view;
diff --git a/src/de/gultsch/chat/ui/NewConversationActivity.java b/src/de/gultsch/chat/ui/NewConversationActivity.java
index 9df5d5eb..b8061b23 100644
--- a/src/de/gultsch/chat/ui/NewConversationActivity.java
+++ b/src/de/gultsch/chat/ui/NewConversationActivity.java
@@ -9,7 +9,9 @@ import de.gultsch.chat.R;
import de.gultsch.chat.entities.Account;
import de.gultsch.chat.entities.Contact;
import de.gultsch.chat.entities.Conversation;
+import de.gultsch.chat.utils.Beautifier;
import de.gultsch.chat.utils.Validator;
+import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.text.Editable;
@@ -74,8 +76,7 @@ public class NewConversationActivity extends XmppActivity {
if (Validator.isValidJid(searchString)) {
String name = searchString.split("@")[0];
- Contact newContact = new Contact(name, searchString,
- DEFAULT_PROFILE_PHOTO);
+ Contact newContact = new Contact(name, searchString,null);
aggregatedContacts.add(newContact);
contactsHeader.setText("Create new contact");
} else {
@@ -100,8 +101,6 @@ public class NewConversationActivity extends XmppActivity {
+ "\") AND (" + ContactsContract.CommonDataKinds.Im.PROTOCOL
+ "=\"" + ContactsContract.CommonDataKinds.Im.PROTOCOL_JABBER
+ "\")";
- protected static final String DEFAULT_PROFILE_PHOTO = "android.resource://de.gultsch.chat/"
- + R.drawable.ic_profile;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -150,8 +149,13 @@ public class NewConversationActivity extends XmppActivity {
.setText(getItem(position).getDisplayName());
((TextView) view.findViewById(R.id.contact_jid))
.setText(getItem(position).getJid());
- ((ImageView) view.findViewById(R.id.contact_photo))
- .setImageURI(getItem(position).getProfilePhoto());
+ String profilePhoto = getItem(position).getProfilePhoto();
+ ImageView imageView = (ImageView) view.findViewById(R.id.contact_photo);
+ if (profilePhoto!=null) {
+ imageView.setImageURI(Uri.parse(profilePhoto));
+ } else {
+ imageView.setImageBitmap(Beautifier.getUnknownContactPicture(getItem(position).getDisplayName(),90));
+ }
return view;
}
};
@@ -222,9 +226,9 @@ public class NewConversationActivity extends XmppActivity {
while (cursor.moveToNext()) {
String profilePhoto = cursor.getString(cursor
.getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI));
- if (profilePhoto == null) {
+ /*if (profilePhoto == null) {
profilePhoto = DEFAULT_PROFILE_PHOTO;
- }
+ }*/
Contact contact = new Contact(
cursor.getString(cursor
.getColumnIndex(ContactsContract.Data.DISPLAY_NAME)),