mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
code cleanup
This commit is contained in:
parent
0d8bf660db
commit
dc73a25ae4
@ -83,4 +83,5 @@
|
|||||||
<string name="openkeychain_required_long">Conversations utilizes a third party app called <b>OpenKeychain</b> to encrypt and decrypt messages and to mange your public keys.\n\nOpenKeychain is licensed under GPLv3 and available on F-Droid and Google Play.\n\n<small>(Please restart Conversations afterwards.)</small></string>
|
<string name="openkeychain_required_long">Conversations utilizes a third party app called <b>OpenKeychain</b> to encrypt and decrypt messages and to mange your public keys.\n\nOpenKeychain is licensed under GPLv3 and available on F-Droid and Google Play.\n\n<small>(Please restart Conversations afterwards.)</small></string>
|
||||||
<string name="restart">Restart</string>
|
<string name="restart">Restart</string>
|
||||||
<string name="install">Install</string>
|
<string name="install">Install</string>
|
||||||
|
<string name="offering">offering…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -15,7 +15,6 @@ import android.content.ContentValues;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class Conversation extends AbstractEntity {
|
public class Conversation extends AbstractEntity {
|
||||||
|
|
||||||
@ -238,7 +237,6 @@ public class Conversation extends AbstractEntity {
|
|||||||
}
|
}
|
||||||
return this.otrSession;
|
return this.otrSession;
|
||||||
} catch (OtrException e) {
|
} catch (OtrException e) {
|
||||||
Log.d("xmppServic", "couldnt start otr");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,7 +345,6 @@ public class Conversation extends AbstractEntity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setNextMessage(String message) {
|
public void setNextMessage(String message) {
|
||||||
Log.d("xmppService","saving text: "+message);
|
|
||||||
this.nextMessage = message;
|
this.nextMessage = message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ public class Message extends AbstractEntity {
|
|||||||
public static final int STATUS_SEND = 2;
|
public static final int STATUS_SEND = 2;
|
||||||
public static final int STATUS_SEND_FAILED = 3;
|
public static final int STATUS_SEND_FAILED = 3;
|
||||||
public static final int STATUS_SEND_REJECTED = 4;
|
public static final int STATUS_SEND_REJECTED = 4;
|
||||||
public static final int STATUS_PREPARING = 5;
|
|
||||||
public static final int STATUS_OFFERED = 6;
|
public static final int STATUS_OFFERED = 6;
|
||||||
|
|
||||||
public static final int ENCRYPTION_NONE = 0;
|
public static final int ENCRYPTION_NONE = 0;
|
||||||
|
@ -451,18 +451,14 @@ public class XmppConnectionService extends Service {
|
|||||||
final Message message = new Message(conversation, "",Message.ENCRYPTION_NONE);
|
final Message message = new Message(conversation, "",Message.ENCRYPTION_NONE);
|
||||||
message.setPresence(presence);
|
message.setPresence(presence);
|
||||||
message.setType(Message.TYPE_IMAGE);
|
message.setType(Message.TYPE_IMAGE);
|
||||||
message.setStatus(Message.STATUS_PREPARING);
|
message.setStatus(Message.STATUS_OFFERED);
|
||||||
conversation.getMessages().add(message);
|
|
||||||
if (convChangedListener != null) {
|
|
||||||
convChangedListener.onConversationListChanged();
|
|
||||||
}
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getFileBackend().copyImageToPrivateStorage(message, uri);
|
getFileBackend().copyImageToPrivateStorage(message, uri);
|
||||||
message.setStatus(Message.STATUS_OFFERED);
|
|
||||||
databaseBackend.createMessage(message);
|
databaseBackend.createMessage(message);
|
||||||
|
conversation.getMessages().add(message);
|
||||||
if (convChangedListener != null) {
|
if (convChangedListener != null) {
|
||||||
convChangedListener.onConversationListChanged();
|
convChangedListener.onConversationListChanged();
|
||||||
}
|
}
|
||||||
@ -477,14 +473,13 @@ public class XmppConnectionService extends Service {
|
|||||||
final Message message = new Message(conversation, "",Message.ENCRYPTION_DECRYPTED);
|
final Message message = new Message(conversation, "",Message.ENCRYPTION_DECRYPTED);
|
||||||
message.setPresence(presence);
|
message.setPresence(presence);
|
||||||
message.setType(Message.TYPE_IMAGE);
|
message.setType(Message.TYPE_IMAGE);
|
||||||
message.setStatus(Message.STATUS_PREPARING);
|
message.setStatus(Message.STATUS_OFFERED);
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getFileBackend().copyImageToPrivateStorage(message, uri);
|
getFileBackend().copyImageToPrivateStorage(message, uri);
|
||||||
getPgpEngine().encrypt(message, callback);
|
getPgpEngine().encrypt(message, callback);
|
||||||
message.setStatus(Message.STATUS_OFFERED);
|
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
return message;
|
return message;
|
||||||
|
@ -178,16 +178,14 @@ public class ConversationActivity extends XmppActivity {
|
|||||||
convLastMsg.setVisibility(View.VISIBLE);
|
convLastMsg.setVisibility(View.VISIBLE);
|
||||||
imagePreview.setVisibility(View.GONE);
|
imagePreview.setVisibility(View.GONE);
|
||||||
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
|
} else if (latestMessage.getType() == Message.TYPE_IMAGE) {
|
||||||
if ((latestMessage.getStatus() >= Message.STATUS_RECIEVED)&&(latestMessage.getStatus() != Message.STATUS_PREPARING)) {
|
if (latestMessage.getStatus() >= Message.STATUS_RECIEVED) {
|
||||||
convLastMsg.setVisibility(View.GONE);
|
convLastMsg.setVisibility(View.GONE);
|
||||||
imagePreview.setVisibility(View.VISIBLE);
|
imagePreview.setVisibility(View.VISIBLE);
|
||||||
loadBitmap(latestMessage, imagePreview);
|
loadBitmap(latestMessage, imagePreview);
|
||||||
} else {
|
} else {
|
||||||
convLastMsg.setVisibility(View.VISIBLE);
|
convLastMsg.setVisibility(View.VISIBLE);
|
||||||
imagePreview.setVisibility(View.GONE);
|
imagePreview.setVisibility(View.GONE);
|
||||||
if (latestMessage.getStatus() == Message.STATUS_PREPARING) {
|
if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
|
||||||
convLastMsg.setText(getText(R.string.preparing_image));
|
|
||||||
} else if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
|
|
||||||
convLastMsg.setText(getText(R.string.image_offered_for_download));
|
convLastMsg.setText(getText(R.string.image_offered_for_download));
|
||||||
} else if (latestMessage.getStatus() == Message.STATUS_RECIEVING) {
|
} else if (latestMessage.getStatus() == Message.STATUS_RECIEVING) {
|
||||||
convLastMsg.setText(getText(R.string.receiving_image));
|
convLastMsg.setText(getText(R.string.receiving_image));
|
||||||
|
@ -192,6 +192,155 @@ public class ConversationFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void displayStatus(ViewHolder viewHolder, Message message) {
|
||||||
|
String filesize = null;
|
||||||
|
String info = null;
|
||||||
|
boolean error = false;
|
||||||
|
if (message.getType() == Message.TYPE_IMAGE) {
|
||||||
|
String[] fileParams = message.getBody().split(",");
|
||||||
|
long size = Long.parseLong(fileParams[0]);
|
||||||
|
filesize = size / 1024 + " KB";
|
||||||
|
}
|
||||||
|
switch (message.getStatus()) {
|
||||||
|
case Message.STATUS_UNSEND:
|
||||||
|
info = getString(R.string.sending);
|
||||||
|
break;
|
||||||
|
case Message.STATUS_OFFERED:
|
||||||
|
info = getString(R.string.offering);
|
||||||
|
break;
|
||||||
|
case Message.STATUS_SEND_FAILED:
|
||||||
|
info = getString(R.string.send_failed);
|
||||||
|
error = true;
|
||||||
|
break;
|
||||||
|
case Message.STATUS_SEND_REJECTED:
|
||||||
|
info = getString(R.string.send_rejected);
|
||||||
|
error = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if ((message.getConversation().getMode() == Conversation.MODE_MULTI)
|
||||||
|
&& (message.getStatus() <= Message.STATUS_RECIEVED)) {
|
||||||
|
info = message.getCounterpart();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (error) {
|
||||||
|
viewHolder.time.setTextColor(0xFFe92727);
|
||||||
|
} else {
|
||||||
|
viewHolder.time.setTextColor(0xFF8e8e8e);
|
||||||
|
}
|
||||||
|
if (message.getEncryption() == Message.ENCRYPTION_NONE) {
|
||||||
|
viewHolder.indicator.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
viewHolder.indicator.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
String formatedTime = UIHelper.readableTimeDifference(message
|
||||||
|
.getTimeSent());
|
||||||
|
if (message.getStatus() <= Message.STATUS_RECIEVED) {
|
||||||
|
if ((filesize != null) && (info != null)) {
|
||||||
|
viewHolder.time.setText(filesize + " \u00B7 " + info);
|
||||||
|
} else if ((filesize == null) && (info != null)) {
|
||||||
|
viewHolder.time.setText(formatedTime + " \u00B7 "
|
||||||
|
+ info);
|
||||||
|
} else if ((filesize != null) && (info == null)) {
|
||||||
|
viewHolder.time.setText(formatedTime + " \u00B7 "
|
||||||
|
+ filesize);
|
||||||
|
} else {
|
||||||
|
viewHolder.time.setText(formatedTime);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((filesize != null) && (info != null)) {
|
||||||
|
viewHolder.time.setText(filesize + " \u00B7 " + info);
|
||||||
|
} else if ((filesize == null) && (info != null)) {
|
||||||
|
viewHolder.time.setText(info + " \u00B7 "
|
||||||
|
+ formatedTime);
|
||||||
|
} else if ((filesize != null) && (info == null)) {
|
||||||
|
viewHolder.time.setText(filesize + " \u00B7 "
|
||||||
|
+ formatedTime);
|
||||||
|
} else {
|
||||||
|
viewHolder.time.setText(formatedTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayInfoMessage(ViewHolder viewHolder, int r) {
|
||||||
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.messageBody.setText(getString(r));
|
||||||
|
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||||
|
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayDecryptionFailed(ViewHolder viewHolder) {
|
||||||
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.messageBody
|
||||||
|
.setText(getString(R.string.decryption_failed));
|
||||||
|
viewHolder.messageBody.setTextColor(0xFFe92727);
|
||||||
|
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayTextMessage(ViewHolder viewHolder, String text) {
|
||||||
|
if (viewHolder.download_button != null) {
|
||||||
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
if (text != null) {
|
||||||
|
viewHolder.messageBody.setText(text.trim());
|
||||||
|
} else {
|
||||||
|
viewHolder.messageBody.setText("");
|
||||||
|
}
|
||||||
|
viewHolder.messageBody.setTextColor(0xff333333);
|
||||||
|
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void displayImageMessage(ViewHolder viewHolder,
|
||||||
|
final Message message) {
|
||||||
|
if (viewHolder.download_button != null) {
|
||||||
|
viewHolder.download_button.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
viewHolder.messageBody.setVisibility(View.GONE);
|
||||||
|
viewHolder.image.setVisibility(View.VISIBLE);
|
||||||
|
String[] fileParams = message.getBody().split(",");
|
||||||
|
if (fileParams.length == 3) {
|
||||||
|
double target = metrics.density * 288;
|
||||||
|
int w = Integer.parseInt(fileParams[1]);
|
||||||
|
int h = Integer.parseInt(fileParams[2]);
|
||||||
|
int scalledW;
|
||||||
|
int scalledH;
|
||||||
|
if (w <= h) {
|
||||||
|
scalledW = (int) (w / ((double) h / target));
|
||||||
|
scalledH = (int) target;
|
||||||
|
} else {
|
||||||
|
scalledW = (int) target;
|
||||||
|
scalledH = (int) (h / ((double) w / target));
|
||||||
|
}
|
||||||
|
viewHolder.image
|
||||||
|
.setLayoutParams(new LinearLayout.LayoutParams(
|
||||||
|
scalledW, scalledH));
|
||||||
|
}
|
||||||
|
activity.loadBitmap(message, viewHolder.image);
|
||||||
|
viewHolder.image.setOnClickListener(new OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
Uri uri = Uri
|
||||||
|
.parse("content://eu.siacs.conversations.images/"
|
||||||
|
+ message.getConversationUuid()
|
||||||
|
+ "/"
|
||||||
|
+ message.getUuid());
|
||||||
|
Log.d("xmppService",
|
||||||
|
"staring intent with uri:" + uri.toString());
|
||||||
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
|
intent.setDataAndType(uri, "image/*");
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View view, ViewGroup parent) {
|
public View getView(int position, View view, ViewGroup parent) {
|
||||||
final Message item = getItem(position);
|
final Message item = getItem(position);
|
||||||
@ -265,36 +414,9 @@ public class ConversationFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.getEncryption() == Message.ENCRYPTION_NONE) {
|
|
||||||
viewHolder.indicator.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
viewHolder.indicator.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
String filesize = "";
|
|
||||||
|
|
||||||
if (item.getType() == Message.TYPE_IMAGE) {
|
if (item.getType() == Message.TYPE_IMAGE) {
|
||||||
String[] fileParams = item.getBody().split(",");
|
if (item.getStatus() == Message.STATUS_RECIEVING) {
|
||||||
if ((fileParams.length >= 1)
|
displayInfoMessage(viewHolder, R.string.receiving_image);
|
||||||
&& (item.getStatus() != Message.STATUS_PREPARING)) {
|
|
||||||
long size = Long.parseLong(fileParams[0]);
|
|
||||||
filesize = size / 1024 + " KB \u00B7 ";
|
|
||||||
}
|
|
||||||
if ((item.getStatus() == Message.STATUS_PREPARING)
|
|
||||||
|| (item.getStatus() == Message.STATUS_RECIEVING)) {
|
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
|
||||||
if (item.getStatus() == Message.STATUS_PREPARING) {
|
|
||||||
viewHolder.messageBody
|
|
||||||
.setText(getString(R.string.preparing_image));
|
|
||||||
} else if (item.getStatus() == Message.STATUS_RECIEVING) {
|
|
||||||
viewHolder.download_button.setVisibility(View.GONE);
|
|
||||||
viewHolder.messageBody
|
|
||||||
.setText(getString(R.string.receiving_image));
|
|
||||||
}
|
|
||||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
|
||||||
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);
|
||||||
@ -316,129 +438,26 @@ public class ConversationFragment extends Fragment {
|
|||||||
});
|
});
|
||||||
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
|
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
|
||||||
|| (item.getEncryption() == Message.ENCRYPTION_NONE)) {
|
|| (item.getEncryption() == Message.ENCRYPTION_NONE)) {
|
||||||
viewHolder.messageBody.setVisibility(View.GONE);
|
displayImageMessage(viewHolder, item);
|
||||||
viewHolder.image.setVisibility(View.VISIBLE);
|
|
||||||
if (fileParams.length == 3) {
|
|
||||||
double target = metrics.density * 288;
|
|
||||||
int w = Integer.parseInt(fileParams[1]);
|
|
||||||
int h = Integer.parseInt(fileParams[2]);
|
|
||||||
int scalledW;
|
|
||||||
int scalledH;
|
|
||||||
if (w <= h) {
|
|
||||||
scalledW = (int) (w / ((double) h / target));
|
|
||||||
scalledH = (int) target;
|
|
||||||
} else {
|
|
||||||
scalledW = (int) 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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
} else if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
displayInfoMessage(viewHolder,
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
R.string.encrypted_message);
|
||||||
viewHolder.messageBody
|
|
||||||
.setText(getString(R.string.encrypted_message));
|
|
||||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
|
||||||
viewHolder.messageBody.setTypeface(null,
|
|
||||||
Typeface.ITALIC);
|
|
||||||
} else {
|
} else {
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
displayDecryptionFailed(viewHolder);
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
|
||||||
viewHolder.messageBody
|
|
||||||
.setText(getString(R.string.decryption_failed));
|
|
||||||
viewHolder.messageBody.setTextColor(0xFFe92727);
|
|
||||||
viewHolder.messageBody.setTypeface(null,
|
|
||||||
Typeface.NORMAL);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
viewHolder.image.setVisibility(View.GONE);
|
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
|
||||||
String body = item.getBody();
|
|
||||||
if (body != null) {
|
|
||||||
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
if (item.getEncryption() == Message.ENCRYPTION_PGP) {
|
||||||
viewHolder.messageBody
|
displayInfoMessage(viewHolder,
|
||||||
.setText(getString(R.string.encrypted_message));
|
R.string.encrypted_message);
|
||||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
|
||||||
viewHolder.messageBody.setTypeface(null,
|
|
||||||
Typeface.ITALIC);
|
|
||||||
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
} else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
|
||||||
viewHolder.messageBody
|
displayDecryptionFailed(viewHolder);
|
||||||
.setText(getString(R.string.decryption_failed));
|
|
||||||
viewHolder.messageBody.setTextColor(0xFFe92727);
|
|
||||||
viewHolder.messageBody.setTypeface(null,
|
|
||||||
Typeface.NORMAL);
|
|
||||||
} else {
|
} else {
|
||||||
viewHolder.messageBody.setText(body.trim());
|
displayTextMessage(viewHolder, item.getBody());
|
||||||
viewHolder.messageBody.setTextColor(0xff333333);
|
|
||||||
viewHolder.messageBody.setTypeface(null,
|
|
||||||
Typeface.NORMAL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
switch (item.getStatus()) {
|
displayStatus(viewHolder, item);
|
||||||
case Message.STATUS_UNSEND:
|
|
||||||
viewHolder.time.setTypeface(null, Typeface.ITALIC);
|
|
||||||
viewHolder.time.setTextColor(0xFF8e8e8e);
|
|
||||||
viewHolder.time.setText(filesize + "sending\u2026");
|
|
||||||
break;
|
|
||||||
case Message.STATUS_OFFERED:
|
|
||||||
viewHolder.time.setTypeface(null, Typeface.ITALIC);
|
|
||||||
viewHolder.time.setTextColor(0xFF8e8e8e);
|
|
||||||
viewHolder.time.setText(filesize + "offering\u2026");
|
|
||||||
break;
|
|
||||||
case Message.STATUS_SEND_FAILED:
|
|
||||||
viewHolder.time.setText(filesize
|
|
||||||
+ 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(filesize
|
|
||||||
+ getString(R.string.send_rejected));
|
|
||||||
viewHolder.time.setTextColor(0xFFe92727);
|
|
||||||
viewHolder.time.setTypeface(null, Typeface.NORMAL);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
viewHolder.time.setTypeface(null, Typeface.NORMAL);
|
|
||||||
viewHolder.time.setTextColor(0xFF8e8e8e);
|
|
||||||
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
|
|
||||||
viewHolder.time.setText(filesize
|
|
||||||
+ UIHelper.readableTimeDifference(item
|
|
||||||
.getTimeSent()));
|
|
||||||
} else {
|
|
||||||
viewHolder.time.setText(item.getCounterpart()
|
|
||||||
+ " \u00B7 "
|
|
||||||
+ UIHelper.readableTimeDifference(item
|
|
||||||
.getTimeSent()));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -533,7 +552,6 @@ public class ConversationFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void decryptMessage(final Message message) {
|
private void decryptMessage(final Message message) {
|
||||||
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() {
|
||||||
@ -546,7 +564,6 @@ public class ConversationFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
Log.d("xmppService", "successfully decrypted");
|
|
||||||
activity.xmppConnectionService.databaseBackend
|
activity.xmppConnectionService.databaseBackend
|
||||||
.updateMessage(message);
|
.updateMessage(message);
|
||||||
updateMessages();
|
updateMessages();
|
||||||
@ -561,7 +578,7 @@ public class ConversationFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Log.d("xmppService", "engine was null");
|
pgpInfo.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user