Improved unread conversation visibility

This commit is contained in:
Moez Bhatti
2016-01-06 18:09:42 -05:00
parent 18abeb4e29
commit eddb255985
6 changed files with 34 additions and 6 deletions
@@ -16,6 +16,7 @@ public class FontManager {
public static final int TEXT_SIZE_LARGEST = 3;
// Attribute codes
public static final int TEXT_TYPE_PRIMARY_BOLD = 0x0;
public static final int TEXT_TYPE_PRIMARY = 0x1;
public static final int TEXT_TYPE_SECONDARY = 0x2;
public static final int TEXT_TYPE_TERTIARY = 0x3;
@@ -49,6 +50,7 @@ public class FontManager {
if (fontSize == TEXT_SIZE_LARGE) return 16;
if (fontSize == TEXT_SIZE_LARGEST) return 18;
break;
case TEXT_TYPE_PRIMARY_BOLD:
case TEXT_TYPE_PRIMARY:
case TEXT_TYPE_DIALOG_MESSAGE:
if (fontSize == TEXT_SIZE_SMALL) return 14;
@@ -77,6 +79,7 @@ public class FontManager {
case FontManager.TEXT_TYPE_TOOLBAR:
return false;
case FontManager.TEXT_TYPE_PRIMARY_BOLD:
case FontManager.TEXT_TYPE_CATEGORY:
case FontManager.TEXT_TYPE_DIALOG_TITLE:
case FontManager.TEXT_TYPE_DIALOG_BUTTON:
@@ -88,6 +91,7 @@ public class FontManager {
public static ColorStateList getTextColor(Context context, int type) {
// Colors and font weight
switch (type) {
case FontManager.TEXT_TYPE_PRIMARY_BOLD:
case FontManager.TEXT_TYPE_PRIMARY:
boolean isNight = ThemeManager.getTheme() == ThemeManager.Theme.DARK ||
ThemeManager.getTheme() == ThemeManager.Theme.BLACK;
@@ -94,7 +94,9 @@ public abstract class LiveViewManager {
if (!parents.containsKey(parent)) {
parents.put(parent, new HashSet<>());
}
parents.get(parent).add(view);
if (!parents.get(parent).contains(view)) {
parents.get(parent).add(view);
}
} else {
WeakHashMap<Object, Set<LiveView>> set = new WeakHashMap<>();
set.put(parent, new HashSet<>());
@@ -6,12 +6,13 @@ import android.view.View;
import android.view.ViewGroup;
import com.moez.QKSMS.R;
import com.moez.QKSMS.common.ConversationPrefsHelper;
import com.moez.QKSMS.common.FontManager;
import com.moez.QKSMS.common.LiveViewManager;
import com.moez.QKSMS.common.emoji.EmojiRegistry;
import com.moez.QKSMS.enums.QKPreference;
import com.moez.QKSMS.common.utils.DateFormatter;
import com.moez.QKSMS.data.Contact;
import com.moez.QKSMS.data.Conversation;
import com.moez.QKSMS.enums.QKPreference;
import com.moez.QKSMS.ui.ThemeManager;
import com.moez.QKSMS.ui.base.QKActivity;
import com.moez.QKSMS.ui.base.RecyclerCursorAdapter;
@@ -71,10 +72,14 @@ public class ConversationListAdapter extends RecyclerCursorAdapter<ConversationL
holder.unreadView.setVisibility(View.VISIBLE);
holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundPrimary());
holder.dateView.setTextColor(ThemeManager.getColor());
holder.fromView.setType(FontManager.TEXT_TYPE_PRIMARY_BOLD);
holder.snippetView.setMaxLines(5);
} else {
holder.unreadView.setVisibility(View.GONE);
holder.snippetView.setTextColor(ThemeManager.getTextOnBackgroundSecondary());
holder.dateView.setTextColor(ThemeManager.getTextOnBackgroundSecondary());
holder.fromView.setType(FontManager.TEXT_TYPE_PRIMARY);
holder.snippetView.setMaxLines(1);
}
LiveViewManager.registerView(QKPreference.THEME, this, key -> {
@@ -63,6 +63,12 @@ public class QKTextView extends TextView {
setTextColor(FontManager.getTextColor(mContext, mType));
setText(getText());
setType(mType);
}
public void setType(int type) {
mType = type;
// Register for theme updates if we're text that changes color dynamically.
if (mType == FontManager.TEXT_TYPE_CATEGORY) {
LiveViewManager.registerView(QKPreference.THEME, this, key ->