bright background for unread messages

Closes #3909
// FREEBIE
This commit is contained in:
Jake McGinty 2015-08-06 16:28:51 -07:00 committed by Moxie Marlinspike
parent 06e137aee9
commit ae17b4b24a
7 changed files with 59 additions and 12 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/textsecure_primary">
<item android:id="@android:id/mask" android:drawable="@android:color/black" />
<item>
<selector>
<item android:drawable="@color/textsecure_primary_alpha33" android:state_selected="true" />
<item android:drawable="@color/conversation_list_item_background_unread_light" />
</selector>
</item>
</ripple>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/textsecure_primary">
<item android:id="@android:id/mask" android:drawable="@android:color/black" />
<item>
<selector>
<item android:drawable="@color/textsecure_primary_alpha33" android:state_selected="true" />
<item android:drawable="@color/conversation_list_item_background_unread_dark" />
</selector>
</item>
</ripple>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/textsecure_primary_alpha33" android:state_selected="true" />
<item android:drawable="@color/textsecure_primary_alpha33" android:state_pressed="true" />
<item android:drawable="@color/conversation_list_item_background_unread_light" />
</selector>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/textsecure_primary_alpha33" android:state_selected="true" />
<item android:drawable="@color/textsecure_primary_alpha33" android:state_pressed="true" />
<item android:drawable="@color/conversation_list_item_background_unread_dark" />
</selector>

View File

@ -79,6 +79,8 @@
<item name="android:windowBackground">@color/gray5</item>
<!--<item name="android:windowContentOverlay">@drawable/compat_actionbar_shadow_background</item>-->
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_light</item>
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_unread_background</item>
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background</item>
<item name="conversation_list_item_count_color">#66333333</item>
<item name="conversation_list_item_contact_color">#FF333333</item>
<item name="conversation_list_item_subject_color">#FF444444</item>
@ -190,6 +192,8 @@
<item name="android:windowBackground">@color/black</item>
<item name="md_dark_theme">true</item>
<item name="conversation_list_item_background_selected">@drawable/list_selected_holo_dark</item>
<item name="conversation_list_item_background_unread">@drawable/conversation_list_item_unread_background_dark</item>
<item name="conversation_list_item_background_read">@drawable/conversation_list_item_background</item>
<item name="conversation_list_item_count_color">#66dddddd</item>
<item name="conversation_list_item_contact_color">#ffdddddd</item>
<item name="conversation_list_item_subject_color">#ffdddddd</item>

View File

@ -24,8 +24,8 @@ import android.graphics.drawable.RippleDrawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.os.Handler;
import android.support.annotation.DrawableRes;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.components.FromTextView;
import org.thoughtcrime.securesms.database.model.ThreadRecord;
import org.thoughtcrime.securesms.recipients.Recipients;
import org.thoughtcrime.securesms.util.DateUtils;
import org.thoughtcrime.securesms.util.ResUtil;
import java.util.Locale;
import java.util.Set;
@ -55,7 +56,6 @@ public class ConversationListItem extends RelativeLayout
private final static Typeface BOLD_TYPEFACE = Typeface.create("sans-serif", Typeface.BOLD);
private final static Typeface LIGHT_TYPEFACE = Typeface.create("sans-serif-light", Typeface.NORMAL);
private Context context;
private Set<Long> selectedThreads;
private Recipients recipients;
private long threadId;
@ -65,17 +65,20 @@ public class ConversationListItem extends RelativeLayout
private boolean read;
private AvatarImageView contactPhotoImage;
private final @DrawableRes int readBackground;
private final @DrawableRes int unreadBackround;
private final Handler handler = new Handler();
private int distributionType;
public ConversationListItem(Context context) {
super(context);
this.context = context;
this(context, null);
}
public ConversationListItem(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
readBackground = ResUtil.getDrawableRes(context, R.attr.conversation_list_item_background_read);
unreadBackround = ResUtil.getDrawableRes(context, R.attr.conversation_list_item_background_unread);
}
@Override
@ -101,12 +104,13 @@ public class ConversationListItem extends RelativeLayout
this.subjectView.setTypeface(read ? LIGHT_TYPEFACE : BOLD_TYPEFACE);
if (thread.getDate() > 0) {
CharSequence date = DateUtils.getBriefRelativeTimeSpanString(context, locale, thread.getDate());
CharSequence date = DateUtils.getBriefRelativeTimeSpanString(getContext(), locale, thread.getDate());
dateView.setText(read ? date : color(getResources().getColor(R.color.textsecure_primary), date));
dateView.setTypeface(read ? LIGHT_TYPEFACE : BOLD_TYPEFACE);
}
setBatchState(batchMode);
setBackground(thread);
setRippleColor(recipients);
this.contactPhotoImage.setAvatar(recipients, true);
}
@ -132,11 +136,16 @@ public class ConversationListItem extends RelativeLayout
return distributionType;
}
private void setBackground(ThreadRecord thread) {
if (thread.isRead()) setBackgroundResource(readBackground);
else setBackgroundResource(unreadBackround);
}
@TargetApi(VERSION_CODES.LOLLIPOP)
public void setRippleColor(Recipients recipients) {
private void setRippleColor(Recipients recipients) {
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
((RippleDrawable)(getBackground()).mutate())
.setColor(ColorStateList.valueOf(recipients.getColor().toConversationColor(context)));
.setColor(ColorStateList.valueOf(recipients.getColor().toConversationColor(getContext())));
}
}