show encryption type in warned/red messages

This commit is contained in:
Daniel Gultsch 2015-10-28 22:40:09 +01:00
parent ec473a4437
commit a7fd629c05
3 changed files with 32 additions and 0 deletions

View file

@ -36,6 +36,7 @@ import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.entities.Message.FileParams;
import eu.siacs.conversations.entities.Transferable;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.utils.GeoHelper;
import eu.siacs.conversations.utils.UIHelper;
@ -462,6 +463,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
.findViewById(R.id.message_time);
viewHolder.indicatorReceived = (ImageView) view
.findViewById(R.id.indicator_received);
viewHolder.encryption = (TextView) view.findViewById(R.id.message_encryption);
break;
case STATUS:
view = activity.getLayoutInflater().inflate(R.layout.message_status, parent, false);
@ -585,8 +587,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else {
viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received);
}
viewHolder.encryption.setVisibility(View.GONE);
} else {
viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_warning);
viewHolder.encryption.setVisibility(View.VISIBLE);
viewHolder.encryption.setText(CryptoHelper.encryptionTypeToText(message.getEncryption()));
}
}
@ -667,5 +672,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
protected TextView messageBody;
protected ImageView contact_picture;
protected TextView status_message;
protected TextView encryption;
}
}

View file

@ -23,6 +23,8 @@ import java.util.LinkedHashSet;
import java.util.List;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.xmpp.jid.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid;
@ -164,4 +166,17 @@ public final class CryptoHelper {
return null;
}
}
public static int encryptionTypeToText(int encryption) {
switch (encryption) {
case Message.ENCRYPTION_OTR:
return R.string.encryption_choice_otr;
case Message.ENCRYPTION_AXOLOTL:
return R.string.encryption_choice_omemo;
case Message.ENCRYPTION_NONE:
return R.string.encryption_choice_unencrypted;
default:
return R.string.encryption_choice_pgp;
}
}
}

View file

@ -72,6 +72,17 @@
android:orientation="horizontal"
android:paddingBottom="2dp">
<TextView
android:id="@+id/message_encryption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:layout_marginRight="4sp"
android:textColor="@color/white70"
android:textStyle="bold"
android:textSize="?attr/TextSizeInfo" />
<ImageView
android:id="@+id/security_indicator"
android:layout_width="?attr/TextSizeInfo"