aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationFragment.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationFragment.java')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java109
1 files changed, 64 insertions, 45 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 51caafbd..06ed41e5 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -33,6 +33,7 @@ import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
@@ -89,7 +90,6 @@ public class ConversationFragment extends Fragment {
@Override
public void onClick(View v) {
- Log.d("gultsch", "clicked to decrypt");
if (askForPassphraseIntent != null) {
try {
getActivity().startIntentSenderForResult(
@@ -97,7 +97,7 @@ public class ConversationFragment extends Fragment {
ConversationActivity.REQUEST_DECRYPT_PGP, null, 0,
0, 0);
} catch (SendIntentException e) {
- Log.d("gultsch", "couldnt fire intent");
+ Log.d("xmppService", "couldnt fire intent");
}
}
}
@@ -149,6 +149,8 @@ public class ConversationFragment extends Fragment {
public View onCreateView(final LayoutInflater inflater,
ViewGroup container, Bundle savedInstanceState) {
+ final DisplayMetrics metrics = getResources().getDisplayMetrics();
+
this.inflater = inflater;
final View view = inflater.inflate(R.layout.fragment_conversation,
@@ -177,19 +179,16 @@ public class ConversationFragment extends Fragment {
private static final int SENT = 0;
private static final int RECIEVED = 1;
- private static final int ERROR = 2;
@Override
public int getViewTypeCount() {
- return 3;
+ return 2;
}
@Override
public int getItemViewType(int position) {
- if (getItem(position).getStatus() == Message.STATUS_RECIEVED) {
+ if (getItem(position).getStatus() <= Message.STATUS_RECIEVED) {
return RECIEVED;
- } else if (getItem(position).getStatus() == Message.STATUS_ERROR) {
- return ERROR;
} else {
return SENT;
}
@@ -210,6 +209,7 @@ public class ConversationFragment extends Fragment {
.findViewById(R.id.message_photo);
viewHolder.imageView.setImageBitmap(selfBitmap);
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
+ viewHolder.image = (ImageView) view.findViewById(R.id.message_image);
break;
case RECIEVED:
view = (View) inflater.inflate(
@@ -227,14 +227,6 @@ public class ConversationFragment extends Fragment {
}
break;
- case ERROR:
- view = (View) inflater.inflate(R.layout.message_error,
- null);
- viewHolder.imageView = (ImageView) view
- .findViewById(R.id.message_photo);
- viewHolder.imageView.setImageBitmap(mBitmapCache
- .getError());
- break;
default:
viewHolder = null;
break;
@@ -262,40 +254,60 @@ public class ConversationFragment extends Fragment {
}
}
}
- String body = item.getBody();
- if (body != null) {
- if (item.getEncryption() == Message.ENCRYPTION_PGP) {
- viewHolder.messageBody
- .setText(getString(R.string.encrypted_message));
- viewHolder.messageBody.setTextColor(0xff33B5E5);
- viewHolder.messageBody.setTypeface(null,
- Typeface.ITALIC);
- viewHolder.indicator.setVisibility(View.VISIBLE);
- } else if ((item.getEncryption() == Message.ENCRYPTION_OTR)||(item.getEncryption() == Message.ENCRYPTION_DECRYPTED)) {
- viewHolder.messageBody.setText(body.trim());
- viewHolder.messageBody.setTextColor(0xff000000);
- viewHolder.messageBody.setTypeface(null,
- Typeface.NORMAL);
- viewHolder.indicator.setVisibility(View.VISIBLE);
- } else {
- viewHolder.messageBody.setText(body.trim());
- viewHolder.messageBody.setTextColor(0xff000000);
- viewHolder.messageBody.setTypeface(null,
- Typeface.NORMAL);
- if (item.getStatus() != Message.STATUS_ERROR) {
+ if (item.getType() == Message.TYPE_IMAGE) {
+ viewHolder.image.setVisibility(View.VISIBLE);
+ viewHolder.image.setImageBitmap(activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288)));
+ viewHolder.messageBody.setVisibility(View.GONE);
+ } else {
+ if (viewHolder.image != null) viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.VISIBLE);
+ String body = item.getBody();
+ if (body != null) {
+ if (item.getEncryption() == Message.ENCRYPTION_PGP) {
+ viewHolder.messageBody
+ .setText(getString(R.string.encrypted_message));
+ viewHolder.messageBody.setTextColor(0xff33B5E5);
+ viewHolder.messageBody.setTypeface(null,
+ Typeface.ITALIC);
+ viewHolder.indicator.setVisibility(View.VISIBLE);
+ } else if ((item.getEncryption() == Message.ENCRYPTION_OTR)||(item.getEncryption() == Message.ENCRYPTION_DECRYPTED)) {
+ viewHolder.messageBody.setText(body.trim());
+ viewHolder.messageBody.setTextColor(0xff333333);
+ viewHolder.messageBody.setTypeface(null,
+ Typeface.NORMAL);
+ viewHolder.indicator.setVisibility(View.VISIBLE);
+ } else {
+ viewHolder.messageBody.setText(body.trim());
+ viewHolder.messageBody.setTextColor(0xff333333);
+ viewHolder.messageBody.setTypeface(null,
+ Typeface.NORMAL);
viewHolder.indicator.setVisibility(View.GONE);
}
+ } else {
+ viewHolder.indicator.setVisibility(View.GONE);
}
- } else {
- viewHolder.indicator.setVisibility(View.GONE);
}
- if (item.getStatus() == Message.STATUS_UNSEND) {
+ switch (item.getStatus()) {
+ case Message.STATUS_UNSEND:
viewHolder.time.setTypeface(null, Typeface.ITALIC);
+ viewHolder.time.setTextColor(0xFF8e8e8e);
viewHolder.time.setText("sending\u2026");
- } else {
+ break;
+ case Message.STATUS_SEND_FAILED:
+ viewHolder.time.setText(getString(R.string.send_failed) + " \u00B7 " + UIHelper.readableTimeDifference(item
+ .getTimeSent()));
+ viewHolder.time.setTextColor(0xFFe92727);
+ viewHolder.time.setTypeface(null,Typeface.NORMAL);
+ break;
+ case Message.STATUS_SEND_REJECTED:
+ viewHolder.time.setText(getString(R.string.send_rejected));
+ viewHolder.time.setTextColor(0xFFe92727);
+ viewHolder.time.setTypeface(null,Typeface.NORMAL);
+ break;
+ default:
viewHolder.time.setTypeface(null, Typeface.NORMAL);
- if ((item.getConversation().getMode() == Conversation.MODE_SINGLE)
- || (type != RECIEVED)) {
+ viewHolder.time.setTextColor(0xFF8e8e8e);
+ if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
viewHolder.time.setText(UIHelper
.readableTimeDifference(item.getTimeSent()));
} else {
@@ -304,6 +316,7 @@ public class ConversationFragment extends Fragment {
+ UIHelper.readableTimeDifference(item
.getTimeSent()));
}
+ break;
}
return view;
}
@@ -320,7 +333,7 @@ public class ConversationFragment extends Fragment {
boolean showPhoneSelfContactPicture = sharedPref.getBoolean(
"show_phone_selfcontact_picture", true);
- return UIHelper.getSelfContactPicture(conversation.getAccount(), 200,
+ return UIHelper.getSelfContactPicture(conversation.getAccount(), 48,
showPhoneSelfContactPicture, getActivity());
}
@@ -505,7 +518,7 @@ public class ConversationFragment extends Fragment {
getActivity());
builder.setTitle("No openPGP key found");
builder.setIconAttribute(android.R.attr.alertDialogIcon);
- builder.setMessage("There is no openPGP key assoziated with this contact");
+ builder.setMessage("There is no openPGP key associated with this contact");
builder.setNegativeButton("Cancel", null);
builder.setPositiveButton("Send plain text",
new DialogInterface.OnClickListener() {
@@ -585,6 +598,7 @@ public class ConversationFragment extends Fragment {
private static class ViewHolder {
+ protected ImageView image;
protected ImageView indicator;
protected TextView time;
protected TextView messageBody;
@@ -600,7 +614,12 @@ public class ConversationFragment extends Fragment {
if (bitmaps.containsKey(name)) {
return bitmaps.get(name);
} else {
- Bitmap bm = UIHelper.getContactPicture(contact, name, 200, context);
+ Bitmap bm;
+ if (contact != null){
+ bm = UIHelper.getContactPicture(contact, 48, context, false);
+ } else {
+ bm = UIHelper.getContactPicture(name, 48, context, false);
+ }
bitmaps.put(name, bm);
return bm;
}