Loading data/src/main/java/com/moez/QKSMS/repository/ConversationRepositoryImpl.kt +18 −4 Original line number Diff line number Diff line Loading @@ -58,11 +58,18 @@ class ConversationRepositoryImpl @Inject constructor( return Realm.getDefaultInstance() .where(Conversation::class.java) .notEqualTo("id", 0L) .isNotNull("lastMessage") .equalTo("archived", archived) .equalTo("blocked", false) .isNotEmpty("recipients") .sort("pinned", Sort.DESCENDING, "lastMessage.date", Sort.DESCENDING) .beginGroup() .isNotNull("lastMessage") .or() .isNotEmpty("draft") .endGroup() .sort( arrayOf("pinned", "draft", "lastMessage.date"), arrayOf(Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING) ) .findAllAsync() } Loading @@ -71,11 +78,18 @@ class ConversationRepositoryImpl @Inject constructor( realm.refresh() realm.copyFromRealm(realm.where(Conversation::class.java) .notEqualTo("id", 0L) .isNotNull("lastMessage") .equalTo("archived", false) .equalTo("blocked", false) .isNotEmpty("recipients") .sort("pinned", Sort.DESCENDING, "lastMessage.date", Sort.DESCENDING) .beginGroup() .isNotNull("lastMessage") .or() .isNotEmpty("draft") .endGroup() .sort( arrayOf("pinned", "draft", "lastMessage.date"), arrayOf(Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING) ) .findAll()) } } Loading presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +4 −4 Original line number Diff line number Diff line Loading @@ -86,7 +86,6 @@ class ConversationsAdapter @Inject constructor( override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) { val conversation = getItem(position) ?: return val lastMessage = conversation.lastMessage ?: return val view = viewHolder.containerView view.isActivated = isSelected(conversation.id) Loading @@ -94,7 +93,7 @@ class ConversationsAdapter @Inject constructor( view.avatars.recipients = conversation.recipients view.title.collapseEnabled = conversation.recipients.size > 1 view.title.text = conversation.getTitle() view.date.text = dateFormatter.getConversationTimestamp(conversation.date) view.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp) view.snippet.text = when { conversation.draft.isNotEmpty() -> context.getString(R.string.main_draft, conversation.draft) conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet) Loading @@ -103,8 +102,9 @@ class ConversationsAdapter @Inject constructor( view.pinned.isVisible = conversation.pinned // If the last message wasn't incoming, then the colour doesn't really matter anyway val recipient = when (conversation.recipients.size) { 1 -> conversation.recipients.firstOrNull() val lastMessage = conversation.lastMessage val recipient = when { conversation.recipients.size == 1 || lastMessage == null -> conversation.recipients.firstOrNull() else -> conversation.recipients.find { recipient -> phoneNumberUtils.compare(recipient.address, lastMessage.address) } Loading presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt +7 −2 Original line number Diff line number Diff line Loading @@ -142,13 +142,18 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory { remoteViews.setTextViewText(R.id.name, boldText(conversation.getTitle(), conversation.unread)) // Date val timestamp = dateFormatter.getConversationTimestamp(conversation.date) val timestamp = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp) remoteViews.setTextColor(R.id.date, if (conversation.unread) textPrimary else textTertiary) remoteViews.setTextViewText(R.id.date, boldText(timestamp, conversation.unread)) // Snippet val snippet = when { conversation.draft.isNotEmpty() -> context.getString(R.string.main_draft, conversation.draft) conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet) else -> conversation.snippet } remoteViews.setTextColor(R.id.snippet, if (conversation.unread) textPrimary else textTertiary) remoteViews.setTextViewText(R.id.snippet, boldText(conversation.snippet, conversation.unread)) remoteViews.setTextViewText(R.id.snippet, boldText(snippet, conversation.unread)) // Launch conversation on click val clickIntent = Intent().putExtra("threadId", conversation.id) Loading Loading
data/src/main/java/com/moez/QKSMS/repository/ConversationRepositoryImpl.kt +18 −4 Original line number Diff line number Diff line Loading @@ -58,11 +58,18 @@ class ConversationRepositoryImpl @Inject constructor( return Realm.getDefaultInstance() .where(Conversation::class.java) .notEqualTo("id", 0L) .isNotNull("lastMessage") .equalTo("archived", archived) .equalTo("blocked", false) .isNotEmpty("recipients") .sort("pinned", Sort.DESCENDING, "lastMessage.date", Sort.DESCENDING) .beginGroup() .isNotNull("lastMessage") .or() .isNotEmpty("draft") .endGroup() .sort( arrayOf("pinned", "draft", "lastMessage.date"), arrayOf(Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING) ) .findAllAsync() } Loading @@ -71,11 +78,18 @@ class ConversationRepositoryImpl @Inject constructor( realm.refresh() realm.copyFromRealm(realm.where(Conversation::class.java) .notEqualTo("id", 0L) .isNotNull("lastMessage") .equalTo("archived", false) .equalTo("blocked", false) .isNotEmpty("recipients") .sort("pinned", Sort.DESCENDING, "lastMessage.date", Sort.DESCENDING) .beginGroup() .isNotNull("lastMessage") .or() .isNotEmpty("draft") .endGroup() .sort( arrayOf("pinned", "draft", "lastMessage.date"), arrayOf(Sort.DESCENDING, Sort.DESCENDING, Sort.DESCENDING) ) .findAll()) } } Loading
presentation/src/main/java/com/moez/QKSMS/feature/conversations/ConversationsAdapter.kt +4 −4 Original line number Diff line number Diff line Loading @@ -86,7 +86,6 @@ class ConversationsAdapter @Inject constructor( override fun onBindViewHolder(viewHolder: QkViewHolder, position: Int) { val conversation = getItem(position) ?: return val lastMessage = conversation.lastMessage ?: return val view = viewHolder.containerView view.isActivated = isSelected(conversation.id) Loading @@ -94,7 +93,7 @@ class ConversationsAdapter @Inject constructor( view.avatars.recipients = conversation.recipients view.title.collapseEnabled = conversation.recipients.size > 1 view.title.text = conversation.getTitle() view.date.text = dateFormatter.getConversationTimestamp(conversation.date) view.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp) view.snippet.text = when { conversation.draft.isNotEmpty() -> context.getString(R.string.main_draft, conversation.draft) conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet) Loading @@ -103,8 +102,9 @@ class ConversationsAdapter @Inject constructor( view.pinned.isVisible = conversation.pinned // If the last message wasn't incoming, then the colour doesn't really matter anyway val recipient = when (conversation.recipients.size) { 1 -> conversation.recipients.firstOrNull() val lastMessage = conversation.lastMessage val recipient = when { conversation.recipients.size == 1 || lastMessage == null -> conversation.recipients.firstOrNull() else -> conversation.recipients.find { recipient -> phoneNumberUtils.compare(recipient.address, lastMessage.address) } Loading
presentation/src/main/java/com/moez/QKSMS/feature/widget/WidgetAdapter.kt +7 −2 Original line number Diff line number Diff line Loading @@ -142,13 +142,18 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory { remoteViews.setTextViewText(R.id.name, boldText(conversation.getTitle(), conversation.unread)) // Date val timestamp = dateFormatter.getConversationTimestamp(conversation.date) val timestamp = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp) remoteViews.setTextColor(R.id.date, if (conversation.unread) textPrimary else textTertiary) remoteViews.setTextViewText(R.id.date, boldText(timestamp, conversation.unread)) // Snippet val snippet = when { conversation.draft.isNotEmpty() -> context.getString(R.string.main_draft, conversation.draft) conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet) else -> conversation.snippet } remoteViews.setTextColor(R.id.snippet, if (conversation.unread) textPrimary else textTertiary) remoteViews.setTextViewText(R.id.snippet, boldText(conversation.snippet, conversation.unread)) remoteViews.setTextViewText(R.id.snippet, boldText(snippet, conversation.unread)) // Launch conversation on click val clickIntent = Intent().putExtra("threadId", conversation.id) Loading