forked from upstream-mirrors/quik
Improved unread conversation visibility
This commit is contained in:
@@ -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 ->
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="72dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:gravity="top"
|
||||
android:minHeight="72dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
@@ -18,20 +18,27 @@
|
||||
android:id="@+id/selected"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<com.moez.QKSMS.ui.view.AvatarView
|
||||
android:id="@+id/conversation_list_avatar"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:src="@drawable/tools_avatar"
|
||||
app:initialSize="32dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginBottom="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_weight="1"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
@@ -68,7 +75,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:gravity="bottom">
|
||||
android:gravity="top">
|
||||
|
||||
<com.moez.QKSMS.ui.view.QKTextView
|
||||
android:id="@+id/conversation_list_snippet"
|
||||
@@ -76,15 +83,18 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="8dp"
|
||||
android:ellipsize="end"
|
||||
android:layout_weight="1"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:singleLine="false"
|
||||
tools:text="Hey! This is a test message. I'm just making this longer now" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/conversation_list_badges"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="16dp"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</declare-styleable>
|
||||
|
||||
<attr name="type">
|
||||
<flag name="primary_bold" value="0" />
|
||||
<flag name="primary" value="1" />
|
||||
<flag name="secondary" value="2" />
|
||||
<flag name="tertiary" value="3" />
|
||||
|
||||
Reference in New Issue
Block a user