remembering text. awesome

This commit is contained in:
Daniel Gultsch 2014-05-07 12:59:15 +02:00
parent 12a3865c47
commit 247f45f46b
2 changed files with 227 additions and 214 deletions

View file

@ -57,6 +57,7 @@ public class Conversation extends AbstractEntity {
private transient String otrFingerprint = null; private transient String otrFingerprint = null;
private int nextMessageEncryption = Message.ENCRYPTION_NONE; private int nextMessageEncryption = Message.ENCRYPTION_NONE;
private String nextMessage;
private transient MucOptions mucOptions = null; private transient MucOptions mucOptions = null;
@ -337,4 +338,13 @@ public class Conversation extends AbstractEntity {
public void setNextEncryption(int encryption) { public void setNextEncryption(int encryption) {
this.nextMessageEncryption = encryption; this.nextMessageEncryption = encryption;
} }
public String getNextMessage() {
return this.nextMessage;
}
public void setNextMessage(String message) {
Log.d("xmppService","saving text: "+message);
this.nextMessage = message;
}
} }

View file

@ -35,6 +35,8 @@ import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.Selection;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -157,10 +159,6 @@ public class ConversationFragment extends Fragment {
container, false); container, false);
chatMsg = (EditText) view.findViewById(R.id.textinput); chatMsg = (EditText) view.findViewById(R.id.textinput);
if (pastedText!=null) {
chatMsg.setText(pastedText);
}
ImageButton sendButton = (ImageButton) view ImageButton sendButton = (ImageButton) view
.findViewById(R.id.textSendButton); .findViewById(R.id.textSendButton);
sendButton.setOnClickListener(this.sendMsgListener); sendButton.setOnClickListener(this.sendMsgListener);
@ -215,13 +213,17 @@ public class ConversationFragment extends Fragment {
viewHolder.contact_picture = (ImageView) view viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo); .findViewById(R.id.message_photo);
viewHolder.download_button = (Button) view.findViewById(R.id.download_button); viewHolder.download_button = (Button) view
.findViewById(R.id.download_button);
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) { if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
viewHolder.contact_picture.setImageBitmap(mBitmapCache viewHolder.contact_picture
.get(item.getConversation().getName(useSubject), item .setImageBitmap(mBitmapCache.get(
.getConversation().getContact(), item.getConversation().getName(
useSubject), item
.getConversation()
.getContact(),
getActivity() getActivity()
.getApplicationContext())); .getApplicationContext()));
@ -231,8 +233,10 @@ public class ConversationFragment extends Fragment {
viewHolder = null; viewHolder = null;
break; break;
} }
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator); viewHolder.indicator = (ImageView) view
viewHolder.image = (ImageView) view.findViewById(R.id.message_image); .findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
.findViewById(R.id.message_image);
viewHolder.messageBody = (TextView) view viewHolder.messageBody = (TextView) view
.findViewById(R.id.message_body); .findViewById(R.id.message_body);
viewHolder.time = (TextView) view viewHolder.time = (TextView) view
@ -245,14 +249,17 @@ public class ConversationFragment extends Fragment {
if (type == RECIEVED) { if (type == RECIEVED) {
if (item.getConversation().getMode() == Conversation.MODE_MULTI) { if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
if (item.getCounterpart() != null) { if (item.getCounterpart() != null) {
viewHolder.contact_picture.setImageBitmap(mBitmapCache viewHolder.contact_picture
.get(item.getCounterpart(), null, .setImageBitmap(mBitmapCache.get(item
.getCounterpart(), null,
getActivity() getActivity()
.getApplicationContext())); .getApplicationContext()));
} else { } else {
viewHolder.contact_picture.setImageBitmap(mBitmapCache viewHolder.contact_picture
.get(item.getConversation().getName(useSubject), .setImageBitmap(mBitmapCache.get(
null, getActivity() item.getConversation().getName(
useSubject), null,
getActivity()
.getApplicationContext())); .getApplicationContext()));
} }
} }
@ -266,71 +273,90 @@ public class ConversationFragment extends Fragment {
String filesize = ""; String filesize = "";
if ((item.getType() == Message.TYPE_IMAGE)&&((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)||(item.getEncryption() == Message.ENCRYPTION_NONE))) { if ((item.getType() == Message.TYPE_IMAGE)
&& ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED) || (item
.getEncryption() == Message.ENCRYPTION_NONE))) {
String[] fileParams = item.getBody().split(","); String[] fileParams = item.getBody().split(",");
if ((fileParams.length>=1)&&(item.getStatus() != Message.STATUS_PREPARING)) { if ((fileParams.length >= 1)
&& (item.getStatus() != Message.STATUS_PREPARING)) {
long size = Long.parseLong(fileParams[0]); long size = Long.parseLong(fileParams[0]);
filesize = size/1024+" KB \u00B7 "; filesize = size / 1024 + " KB \u00B7 ";
} }
if ((item.getStatus() == Message.STATUS_PREPARING)||(item.getStatus() == Message.STATUS_RECIEVING)) { if ((item.getStatus() == Message.STATUS_PREPARING)
|| (item.getStatus() == Message.STATUS_RECIEVING)) {
viewHolder.image.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setVisibility(View.VISIBLE);
if (item.getStatus() == Message.STATUS_PREPARING) { if (item.getStatus() == Message.STATUS_PREPARING) {
viewHolder.messageBody.setText(getString(R.string.preparing_image)); viewHolder.messageBody
.setText(getString(R.string.preparing_image));
} else if (item.getStatus() == Message.STATUS_RECIEVING) { } else if (item.getStatus() == Message.STATUS_RECIEVING) {
viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.GONE);
viewHolder.messageBody.setText(getString(R.string.receiving_image)); viewHolder.messageBody
.setText(getString(R.string.receiving_image));
} }
viewHolder.messageBody.setTextColor(0xff33B5E5); viewHolder.messageBody.setTextColor(0xff33B5E5);
viewHolder.messageBody.setTypeface(null,Typeface.ITALIC); viewHolder.messageBody.setTypeface(null,
Typeface.ITALIC);
} else if (item.getStatus() == Message.STATUS_RECEIVED_OFFER) { } else if (item.getStatus() == Message.STATUS_RECEIVED_OFFER) {
viewHolder.image.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE); viewHolder.download_button.setVisibility(View.VISIBLE);
viewHolder.download_button.setOnClickListener(new OnClickListener() { viewHolder.download_button
.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
JingleConnection connection = item.getJingleConnection(); JingleConnection connection = item
if (connection!=null) { .getJingleConnection();
connection.accept(); if (connection != null) {
} else { connection.accept();
Log.d("xmppService","attached jingle connection was null"); } else {
} Log.d("xmppService",
} "attached jingle connection was null");
}); }
}
});
} else { } else {
viewHolder.messageBody.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.image.setVisibility(View.VISIBLE); viewHolder.image.setVisibility(View.VISIBLE);
if (fileParams.length==3) { if (fileParams.length == 3) {
double target = metrics.density * 288; double target = metrics.density * 288;
int w = Integer.parseInt(fileParams[1]); int w = Integer.parseInt(fileParams[1]);
int h = Integer.parseInt(fileParams[2]); int h = Integer.parseInt(fileParams[2]);
int scalledW; int scalledW;
int scalledH; int scalledH;
if (w <= h) { if (w <= h) {
scalledW = (int) (w / ((double) h / target)); scalledW = (int) (w / ((double) h / target));
scalledH = (int) target; scalledH = (int) target;
} else { } else {
scalledW = (int) target; scalledW = (int) target;
scalledH = (int) (h / ((double) w / target)); scalledH = (int) (h / ((double) w / target));
}
viewHolder.image.setLayoutParams(new LinearLayout.LayoutParams(scalledW, scalledH));
} else {
Log.d("xmppService","message body has less than 3 params");
}
activity.loadBitmap(item, viewHolder.image);
viewHolder.image.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("content://eu.siacs.conversations.images/"+item.getConversationUuid()+"/"+item.getUuid());
Log.d("xmppService","staring intent with uri:"+uri.toString());
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
} }
}); viewHolder.image
.setLayoutParams(new LinearLayout.LayoutParams(
scalledW, scalledH));
} else {
Log.d("xmppService",
"message body has less than 3 params");
}
activity.loadBitmap(item, viewHolder.image);
viewHolder.image
.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Uri uri = Uri.parse("content://eu.siacs.conversations.images/"
+ item.getConversationUuid()
+ "/" + item.getUuid());
Log.d("xmppService",
"staring intent with uri:"
+ uri.toString());
Intent intent = new Intent(
Intent.ACTION_VIEW);
intent.setDataAndType(uri, "image/*");
startActivity(intent);
}
});
} }
} else { } else {
viewHolder.image.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE);
@ -344,9 +370,11 @@ public class ConversationFragment extends Fragment {
viewHolder.messageBody.setTypeface(null, viewHolder.messageBody.setTypeface(null,
Typeface.ITALIC); Typeface.ITALIC);
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
viewHolder.messageBody.setText(getString(R.string.decryption_failed)); viewHolder.messageBody
.setText(getString(R.string.decryption_failed));
viewHolder.messageBody.setTextColor(0xFFe92727); viewHolder.messageBody.setTextColor(0xFFe92727);
viewHolder.messageBody.setTypeface(null,Typeface.NORMAL); viewHolder.messageBody.setTypeface(null,
Typeface.NORMAL);
} else { } else {
viewHolder.messageBody.setText(body.trim()); viewHolder.messageBody.setText(body.trim());
viewHolder.messageBody.setTextColor(0xff333333); viewHolder.messageBody.setTextColor(0xff333333);
@ -359,30 +387,35 @@ public class ConversationFragment extends Fragment {
case Message.STATUS_UNSEND: case Message.STATUS_UNSEND:
viewHolder.time.setTypeface(null, Typeface.ITALIC); viewHolder.time.setTypeface(null, Typeface.ITALIC);
viewHolder.time.setTextColor(0xFF8e8e8e); viewHolder.time.setTextColor(0xFF8e8e8e);
viewHolder.time.setText(filesize+"sending\u2026"); viewHolder.time.setText(filesize + "sending\u2026");
break; break;
case Message.STATUS_OFFERED: case Message.STATUS_OFFERED:
viewHolder.time.setTypeface(null, Typeface.ITALIC); viewHolder.time.setTypeface(null, Typeface.ITALIC);
viewHolder.time.setTextColor(0xFF8e8e8e); viewHolder.time.setTextColor(0xFF8e8e8e);
viewHolder.time.setText(filesize+"offering\u2026"); viewHolder.time.setText(filesize + "offering\u2026");
break; break;
case Message.STATUS_SEND_FAILED: case Message.STATUS_SEND_FAILED:
viewHolder.time.setText(filesize+getString(R.string.send_failed) + " \u00B7 " + UIHelper.readableTimeDifference(item viewHolder.time.setText(filesize
.getTimeSent())); + getString(R.string.send_failed)
+ " \u00B7 "
+ UIHelper.readableTimeDifference(item
.getTimeSent()));
viewHolder.time.setTextColor(0xFFe92727); viewHolder.time.setTextColor(0xFFe92727);
viewHolder.time.setTypeface(null,Typeface.NORMAL); viewHolder.time.setTypeface(null, Typeface.NORMAL);
break; break;
case Message.STATUS_SEND_REJECTED: case Message.STATUS_SEND_REJECTED:
viewHolder.time.setText(filesize+getString(R.string.send_rejected)); viewHolder.time.setText(filesize
+ getString(R.string.send_rejected));
viewHolder.time.setTextColor(0xFFe92727); viewHolder.time.setTextColor(0xFFe92727);
viewHolder.time.setTypeface(null,Typeface.NORMAL); viewHolder.time.setTypeface(null, Typeface.NORMAL);
break; break;
default: default:
viewHolder.time.setTypeface(null, Typeface.NORMAL); viewHolder.time.setTypeface(null, Typeface.NORMAL);
viewHolder.time.setTextColor(0xFF8e8e8e); viewHolder.time.setTextColor(0xFF8e8e8e);
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) { if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
viewHolder.time.setText(filesize+UIHelper viewHolder.time.setText(filesize
.readableTimeDifference(item.getTimeSent())); + UIHelper.readableTimeDifference(item
.getTimeSent()));
} else { } else {
viewHolder.time.setText(item.getCounterpart() viewHolder.time.setText(item.getCounterpart()
+ " \u00B7 " + " \u00B7 "
@ -414,26 +447,42 @@ public class ConversationFragment extends Fragment {
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
this.activity = (ConversationActivity) getActivity(); this.activity = (ConversationActivity) getActivity();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); SharedPreferences preferences = PreferenceManager
.getDefaultSharedPreferences(activity);
this.useSubject = preferences.getBoolean("use_subject_in_muc", true); this.useSubject = preferences.getBoolean("use_subject_in_muc", true);
if (activity.xmppConnectionServiceBound) { if (activity.xmppConnectionServiceBound) {
this.onBackendConnected(); this.onBackendConnected();
} }
} }
@Override
public void onStop() {
super.onStop();
this.conversation.setNextMessage(chatMsg.getText().toString());
}
public void onBackendConnected() { public void onBackendConnected() {
this.conversation = activity.getSelectedConversation(); this.conversation = activity.getSelectedConversation();
if (this.conversation == null) { if (this.conversation == null) {
return; return;
} }
if (this.pastedText == null) {
this.chatMsg.setText(conversation.getNextMessage());
} else {
chatMsg.setText(conversation.getNextMessage() + " " + pastedText);
pastedText = null;
}
int position = chatMsg.length();
Editable etext = chatMsg.getText();
Selection.setSelection(etext, position);
this.selfBitmap = findSelfPicture(); this.selfBitmap = findSelfPicture();
updateMessages(); updateMessages();
// rendering complete. now go tell activity to close pane
if (activity.getSlidingPaneLayout().isSlideable()) { if (activity.getSlidingPaneLayout().isSlideable()) {
if (!activity.shouldPaneBeOpen()) { if (!activity.shouldPaneBeOpen()) {
activity.getSlidingPaneLayout().closePane(); activity.getSlidingPaneLayout().closePane();
activity.getActionBar().setDisplayHomeAsUpEnabled(true); activity.getActionBar().setDisplayHomeAsUpEnabled(true);
activity.getActionBar().setTitle(conversation.getName(useSubject)); activity.getActionBar().setTitle(
conversation.getName(useSubject));
activity.invalidateOptionsMenu(); activity.invalidateOptionsMenu();
} }
@ -444,7 +493,8 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void onRename(final boolean success) { public void onRename(final boolean success) {
activity.xmppConnectionService.updateConversation(conversation); activity.xmppConnectionService
.updateConversation(conversation);
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
@ -455,7 +505,8 @@ public class ConversationFragment extends Fragment {
getString(R.string.your_nick_has_been_changed), getString(R.string.your_nick_has_been_changed),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} else { } else {
Toast.makeText(getActivity(), Toast.makeText(
getActivity(),
getString(R.string.nick_in_use), getString(R.string.nick_in_use),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
} }
@ -467,10 +518,10 @@ public class ConversationFragment extends Fragment {
} }
private void decryptMessage(final Message message) { private void decryptMessage(final Message message) {
Log.d("xmppService","called to decrypt"); Log.d("xmppService", "called to decrypt");
PgpEngine engine = activity.xmppConnectionService.getPgpEngine(); PgpEngine engine = activity.xmppConnectionService.getPgpEngine();
if (engine!=null) { if (engine != null) {
engine.decrypt(message,new OnPgpEngineResult() { engine.decrypt(message, new OnPgpEngineResult() {
@Override @Override
public void userInputRequried(PendingIntent pi) { public void userInputRequried(PendingIntent pi) {
@ -480,20 +531,22 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void success() { public void success() {
Log.d("xmppService","successfully decrypted"); Log.d("xmppService", "successfully decrypted");
activity.xmppConnectionService.databaseBackend.updateMessage(message); activity.xmppConnectionService.databaseBackend
.updateMessage(message);
updateMessages(); updateMessages();
} }
@Override @Override
public void error(OpenPgpError openPgpError) { public void error(OpenPgpError openPgpError) {
Log.d("xmppService","decryption error"+openPgpError.getMessage()); Log.d("xmppService",
"decryption error" + openPgpError.getMessage());
message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED); message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
//updateMessages(); // updateMessages();
} }
}); });
} else { } else {
Log.d("xmppService","engine was null"); Log.d("xmppService", "engine was null");
} }
} }
@ -501,7 +554,8 @@ public class ConversationFragment extends Fragment {
ConversationActivity activity = (ConversationActivity) getActivity(); ConversationActivity activity = (ConversationActivity) getActivity();
if (this.conversation != null) { if (this.conversation != null) {
for (Message message : this.conversation.getMessages()) { for (Message message : this.conversation.getMessages()) {
if ((message.getEncryption() == Message.ENCRYPTION_PGP)&&(message.getStatus() == Message.STATUS_RECIEVED)) { if ((message.getEncryption() == Message.ENCRYPTION_PGP)
&& (message.getStatus() == Message.STATUS_RECIEVED)) {
decryptMessage(message); decryptMessage(message);
break; break;
} }
@ -511,7 +565,8 @@ public class ConversationFragment extends Fragment {
this.messageListAdapter.notifyDataSetChanged(); this.messageListAdapter.notifyDataSetChanged();
if (conversation.getMode() == Conversation.MODE_SINGLE) { if (conversation.getMode() == Conversation.MODE_SINGLE) {
if (messageList.size() >= 1) { if (messageList.size() >= 1) {
conversation.setNextEncryption(conversation.getLatestEncryption()); conversation.setNextEncryption(conversation
.getLatestEncryption());
makeFingerprintWarning(conversation.getLatestEncryption()); makeFingerprintWarning(conversation.getLatestEncryption());
} }
} else { } else {
@ -585,44 +640,52 @@ public class ConversationFragment extends Fragment {
final Account account = message.getConversation().getAccount(); final Account account = message.getConversation().getAccount();
if (activity.hasPgp()) { if (activity.hasPgp()) {
if (contact.getPgpKeyId() != 0) { if (contact.getPgpKeyId() != 0) {
xmppService.getPgpEngine().hasKey(contact, new OnPgpEngineResult() { xmppService.getPgpEngine().hasKey(contact,
new OnPgpEngineResult() {
@Override
public void userInputRequried(PendingIntent pi) {
activity.runIntent(pi, ConversationActivity.REQUEST_SEND_MESSAGE);
}
@Override
public void success() {
xmppService.getPgpEngine().encrypt(account, message,new OnPgpEngineResult() {
@Override @Override
public void userInputRequried(PendingIntent pi) { public void userInputRequried(PendingIntent pi) {
activity.runIntent(pi, ConversationActivity.REQUEST_SEND_MESSAGE); activity.runIntent(
pi,
ConversationActivity.REQUEST_SEND_MESSAGE);
} }
@Override @Override
public void success() { public void success() {
xmppService.sendMessage(message, null); xmppService.getPgpEngine().encrypt(account,
chatMsg.setText(""); message, new OnPgpEngineResult() {
@Override
public void userInputRequried(
PendingIntent pi) {
activity.runIntent(
pi,
ConversationActivity.REQUEST_SEND_MESSAGE);
}
@Override
public void success() {
xmppService.sendMessage(
message, null);
chatMsg.setText("");
}
@Override
public void error(
OpenPgpError openPgpError) {
// TODO Auto-generated method
// stub
}
});
} }
@Override @Override
public void error(OpenPgpError openPgpError) { public void error(OpenPgpError openPgpError) {
// TODO Auto-generated method stub Log.d("xmppService", "openpgp error"
+ openPgpError.getMessage());
} }
}); });
}
@Override
public void error(OpenPgpError openPgpError) {
Log.d("xmppService","openpgp error"+openPgpError.getMessage());
}
});
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder( AlertDialog.Builder builder = new AlertDialog.Builder(
@ -637,7 +700,8 @@ public class ConversationFragment extends Fragment {
@Override @Override
public void onClick(DialogInterface dialog, public void onClick(DialogInterface dialog,
int which) { int which) {
conversation.setNextEncryption(Message.ENCRYPTION_NONE); conversation
.setNextEncryption(Message.ENCRYPTION_NONE);
message.setEncryption(Message.ENCRYPTION_NONE); message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message, null); xmppService.sendMessage(message, null);
chatMsg.setText(""); chatMsg.setText("");
@ -655,23 +719,25 @@ public class ConversationFragment extends Fragment {
activity.xmppConnectionService.sendMessage(message, null); activity.xmppConnectionService.sendMessage(message, null);
chatMsg.setText(""); chatMsg.setText("");
} else { } else {
activity.selectPresence(message.getConversation(), new OnPresenceSelected() { activity.selectPresence(message.getConversation(),
new OnPresenceSelected() {
@Override @Override
public void onPresenceSelected(boolean success, String presence) { public void onPresenceSelected(boolean success,
if (success) { String presence) {
xmppService.sendMessage(message,presence); if (success) {
chatMsg.setText(""); xmppService.sendMessage(message, presence);
} chatMsg.setText("");
} }
}
@Override @Override
public void onSendPlainTextInstead() { public void onSendPlainTextInstead() {
message.setEncryption(Message.ENCRYPTION_NONE); message.setEncryption(Message.ENCRYPTION_NONE);
xmppService.sendMessage(message,null); xmppService.sendMessage(message, null);
chatMsg.setText(""); chatMsg.setText("");
} }
},"otr"); }, "otr");
} }
} }
@ -695,8 +761,9 @@ public class ConversationFragment extends Fragment {
return bitmaps.get(name); return bitmaps.get(name);
} else { } else {
Bitmap bm; Bitmap bm;
if (contact != null){ if (contact != null) {
bm = UIHelper.getContactPicture(contact, 48, context, false); bm = UIHelper
.getContactPicture(contact, 48, context, false);
} else { } else {
bm = UIHelper.getContactPicture(name, 48, context, false); bm = UIHelper.getContactPicture(name, 48, context, false);
} }
@ -706,70 +773,6 @@ public class ConversationFragment extends Fragment {
} }
} }
/*class DecryptMessage extends AsyncTask<Message, Void, Boolean> {
@Override
protected Boolean doInBackground(Message... params) {
final ConversationActivity activity = (ConversationActivity) getActivity();
askForPassphraseIntent = null;
for (int i = 0; i < params.length; ++i) {
if (params[i].getEncryption() == Message.ENCRYPTION_PGP) {
String body = params[i].getBody();
String decrypted = null;
if (activity == null) {
return false;
} else if (!activity.xmppConnectionServiceBound) {
return false;
}
try {
decrypted = activity.xmppConnectionService
.getPgpEngine().decrypt(conversation.getAccount(),body);
} catch (UserInputRequiredException e) {
askForPassphraseIntent = e.getPendingIntent()
.getIntentSender();
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
pgpInfo.setVisibility(View.VISIBLE);
}
});
return false;
} catch (OpenPgpException e) {
Log.d("gultsch", "error decrypting pgp");
}
if (decrypted != null) {
params[i].setBody(decrypted);
params[i].setEncryption(Message.ENCRYPTION_DECRYPTED);
activity.xmppConnectionService.updateMessage(params[i]);
}
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
messageListAdapter.notifyDataSetChanged();
}
});
}
}
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
activity.updateConversationList();
}
});
}
}
return true;
}
}*/
public void setText(String text) { public void setText(String text) {
this.pastedText = text; this.pastedText = text;
} }