fixed some colors in message adapter

This commit is contained in:
Daniel Gultsch 2015-07-30 12:40:50 +02:00
parent 58d80f58be
commit 1ed550b5c5
5 changed files with 33 additions and 28 deletions

View File

@ -351,7 +351,7 @@ public abstract class XmppActivity extends Activity {
mPrimaryTextColor = getResources().getColor(R.color.black87); mPrimaryTextColor = getResources().getColor(R.color.black87);
mSecondaryTextColor = getResources().getColor(R.color.black54); mSecondaryTextColor = getResources().getColor(R.color.black54);
mTertiaryTextColor = getResources().getColor(R.color.black12); mTertiaryTextColor = getResources().getColor(R.color.black12);
mColorRed = getResources().getColor(R.color.red500); mColorRed = getResources().getColor(R.color.red800);
mColorOrange = getResources().getColor(R.color.orange500); mColorOrange = getResources().getColor(R.color.orange500);
mColorGreen = getResources().getColor(R.color.green500); mColorGreen = getResources().getColor(R.color.green500);
mPrimaryColor = getResources().getColor(R.color.green500); mPrimaryColor = getResources().getColor(R.color.green500);

View File

@ -96,19 +96,15 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return this.getItemViewType(getItem(position)); return this.getItemViewType(getItem(position));
} }
private int getMessageTextColor(Message message) { private int getMessageTextColor(int type, boolean primary) {
int type = this.getItemViewType(message);
if (type == SENT) { if (type == SENT) {
return activity.getResources().getColor(R.color.black87); return activity.getResources().getColor(primary ? R.color.black87 : R.color.black54);
} else if (type == RECEIVED) { } else {
return activity.getResources().getColor(R.color.white); return activity.getResources().getColor(primary ? R.color.white : R.color.white70);
} }
return activity.getPrimaryTextColor();
} }
private void displayStatus(ViewHolder viewHolder, Message message) { private void displayStatus(ViewHolder viewHolder, Message message, int type) {
String filesize = null; String filesize = null;
String info = null; String info = null;
boolean error = false; boolean error = false;
@ -163,10 +159,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
break; break;
} }
if (error) { if (error && type == SENT) {
viewHolder.time.setTextColor(activity.getWarningTextColor()); viewHolder.time.setTextColor(activity.getWarningTextColor());
} else { } else {
viewHolder.time.setTextColor(this.getMessageTextColor(message)); viewHolder.time.setTextColor(this.getMessageTextColor(type,false));
} }
if (message.getEncryption() == Message.ENCRYPTION_NONE) { if (message.getEncryption() == Message.ENCRYPTION_NONE) {
viewHolder.indicator.setVisibility(View.GONE); viewHolder.indicator.setVisibility(View.GONE);
@ -178,12 +174,23 @@ public class MessageAdapter extends ArrayAdapter<Message> {
message.getAxolotlFingerprint()); message.getAxolotlFingerprint());
if(trust == null || trust != SQLiteAxolotlStore.Trust.TRUSTED) { if(trust == null || trust != SQLiteAxolotlStore.Trust.TRUSTED) {
viewHolder.indicator.setColorFilter(Color.RED); viewHolder.indicator.setColorFilter(activity.getWarningTextColor());
viewHolder.indicator.setAlpha(1.0f);
} else { } else {
viewHolder.indicator.clearColorFilter(); viewHolder.indicator.clearColorFilter();
if (type == SENT) {
viewHolder.indicator.setAlpha(0.57f);
} else {
viewHolder.indicator.setAlpha(0.7f);
}
} }
} else { } else {
viewHolder.indicator.clearColorFilter(); viewHolder.indicator.clearColorFilter();
if (type == SENT) {
viewHolder.indicator.setAlpha(0.57f);
} else {
viewHolder.indicator.setAlpha(0.7f);
}
} }
} }
@ -216,19 +223,19 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
} }
private void displayInfoMessage(ViewHolder viewHolder, String text) { private void displayInfoMessage(ViewHolder viewHolder, String text, int type) {
if (viewHolder.download_button != null) { if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.GONE);
} }
viewHolder.image.setVisibility(View.GONE); viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setVisibility(View.VISIBLE);
viewHolder.messageBody.setText(text); viewHolder.messageBody.setText(text);
viewHolder.messageBody.setTextColor(activity.getSecondaryTextColor()); viewHolder.messageBody.setTextColor(getMessageTextColor(type,false));
viewHolder.messageBody.setTypeface(null, Typeface.ITALIC); viewHolder.messageBody.setTypeface(null, Typeface.ITALIC);
viewHolder.messageBody.setTextIsSelectable(false); viewHolder.messageBody.setTextIsSelectable(false);
} }
private void displayDecryptionFailed(ViewHolder viewHolder) { private void displayDecryptionFailed(ViewHolder viewHolder, int type) {
if (viewHolder.download_button != null) { if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.GONE);
} }
@ -236,7 +243,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setVisibility(View.VISIBLE); viewHolder.messageBody.setVisibility(View.VISIBLE);
viewHolder.messageBody.setText(getContext().getString( viewHolder.messageBody.setText(getContext().getString(
R.string.decryption_failed)); R.string.decryption_failed));
viewHolder.messageBody.setTextColor(activity.getWarningTextColor()); viewHolder.messageBody.setTextColor(getMessageTextColor(type,false));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
viewHolder.messageBody.setTextIsSelectable(false); viewHolder.messageBody.setTextIsSelectable(false);
} }
@ -254,7 +261,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setText(span); viewHolder.messageBody.setText(span);
} }
private void displayTextMessage(final ViewHolder viewHolder, final Message message) { private void displayTextMessage(final ViewHolder viewHolder, final Message message, int type) {
if (viewHolder.download_button != null) { if (viewHolder.download_button != null) {
viewHolder.download_button.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.GONE);
} }
@ -312,7 +319,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else { } else {
viewHolder.messageBody.setText(""); viewHolder.messageBody.setText("");
} }
viewHolder.messageBody.setTextColor(this.getMessageTextColor(message)); viewHolder.messageBody.setTextColor(this.getMessageTextColor(type,true));
viewHolder.messageBody.setTypeface(null, Typeface.NORMAL); viewHolder.messageBody.setTypeface(null, Typeface.NORMAL);
viewHolder.messageBody.setTextIsSelectable(true); viewHolder.messageBody.setTextIsSelectable(true);
} }
@ -521,7 +528,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (transferable.getStatus() == Transferable.STATUS_OFFER_CHECK_FILESIZE) { } else if (transferable.getStatus() == Transferable.STATUS_OFFER_CHECK_FILESIZE) {
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message))); displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
} else { } else {
displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first); displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first,type);
} }
} else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { } else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
displayImageMessage(viewHolder, message); displayImageMessage(viewHolder, message);
@ -533,10 +540,9 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
} else if (message.getEncryption() == Message.ENCRYPTION_PGP) { } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
if (activity.hasPgp()) { if (activity.hasPgp()) {
displayInfoMessage(viewHolder,activity.getString(R.string.encrypted_message)); displayInfoMessage(viewHolder,activity.getString(R.string.encrypted_message),type);
} else { } else {
displayInfoMessage(viewHolder, displayInfoMessage(viewHolder,activity.getString(R.string.install_openkeychain),type);
activity.getString(R.string.install_openkeychain));
if (viewHolder != null) { if (viewHolder != null) {
viewHolder.message_box viewHolder.message_box
.setOnClickListener(new OnClickListener() { .setOnClickListener(new OnClickListener() {
@ -549,7 +555,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
} }
} else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
displayDecryptionFailed(viewHolder); displayDecryptionFailed(viewHolder,type);
} else { } else {
if (GeoHelper.isGeoUri(message.getBody())) { if (GeoHelper.isGeoUri(message.getBody())) {
displayLocationMessage(viewHolder,message); displayLocationMessage(viewHolder,message);
@ -558,7 +564,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (message.treatAsDownloadable() == Message.Decision.MUST) { } else if (message.treatAsDownloadable() == Message.Decision.MUST) {
displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message))); displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
} else { } else {
displayTextMessage(viewHolder, message); displayTextMessage(viewHolder, message, type);
} }
} }
@ -592,7 +598,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} }
} }
displayStatus(viewHolder, message); displayStatus(viewHolder, message, type);
return view; return view;
} }

View File

@ -89,7 +89,6 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/sending" android:text="@string/sending"
android:textColor="@color/white70" android:textColor="@color/white70"
android:alpha="0.70"
android:textSize="?attr/TextSizeInfo" /> android:textSize="?attr/TextSizeInfo" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View File

@ -80,7 +80,6 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/sending" android:text="@string/sending"
android:textColor="@color/black54" android:textColor="@color/black54"
android:alpha="0.54"
android:textSize="?attr/TextSizeInfo" /> android:textSize="?attr/TextSizeInfo" />
<ImageView <ImageView

View File

@ -13,5 +13,6 @@
<color name="grey200">#ffeeeeee</color> <color name="grey200">#ffeeeeee</color>
<color name="grey800">#ff424242</color> <color name="grey800">#ff424242</color>
<color name="red500">#fff44336</color> <color name="red500">#fff44336</color>
<color name="red800">#ffc62828</color>
<color name="orange500">#ffff9800</color> <color name="orange500">#ffff9800</color>
</resources> </resources>