forked from upstream-mirrors/quik
Change draft indicator to be in the snippet
This commit is contained in:
+5
-4
@@ -109,16 +109,17 @@ class ConversationsAdapter @Inject constructor(
|
||||
holder.title.collapseEnabled = conversation.recipients.size > 1
|
||||
holder.title.text = buildSpannedString {
|
||||
append(conversation.getTitle())
|
||||
if (conversation.draft.isNotEmpty()) {
|
||||
color(theme) { append(" " + context.getString(R.string.main_draft)) }
|
||||
}
|
||||
}
|
||||
holder.date.text = conversation.date.takeIf { it > 0 }?.let(dateFormatter::getConversationTimestamp)
|
||||
holder.snippet.text = when {
|
||||
conversation.draft.isNotEmpty() -> conversation.draft
|
||||
conversation.draft.isNotEmpty() -> context.getString(R.string.main_sender_draft, conversation.draft)
|
||||
conversation.me -> context.getString(R.string.main_sender_you, conversation.snippet)
|
||||
else -> conversation.snippet
|
||||
}
|
||||
|
||||
// Make the preview in italics if draft
|
||||
if (conversation.draft.isNotEmpty()) holder.snippet.setTypeface(null, Typeface.ITALIC)
|
||||
|
||||
holder.pinned.isVisible = conversation.pinned
|
||||
holder.unread.setTint(theme)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import android.widget.RemoteViewsService
|
||||
import androidx.core.text.bold
|
||||
import androidx.core.text.buildSpannedString
|
||||
import androidx.core.text.color
|
||||
import androidx.core.text.italic
|
||||
import dev.octoshrimpy.quik.R
|
||||
import dev.octoshrimpy.quik.common.util.Colors
|
||||
import dev.octoshrimpy.quik.common.util.DateFormatter
|
||||
@@ -142,9 +143,6 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
remoteViews.setTextColor(R.id.name, textPrimary)
|
||||
remoteViews.setTextViewText(R.id.name, boldText(buildSpannedString {
|
||||
append(conversation.getTitle())
|
||||
if (conversation.draft.isNotEmpty()) {
|
||||
color(theme.theme) { append(" " + context.getString(R.string.main_draft)) }
|
||||
}
|
||||
}, conversation.unread))
|
||||
|
||||
// Date
|
||||
@@ -154,12 +152,17 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
|
||||
// Snippet
|
||||
val snippet = when {
|
||||
conversation.draft.isNotEmpty() -> conversation.draft
|
||||
conversation.draft.isNotEmpty() -> context.getString(
|
||||
R.string.main_sender_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(snippet, conversation.unread))
|
||||
remoteViews.setTextViewText(R.id.snippet, italicText(snippet, conversation.draft.isNotEmpty()))
|
||||
|
||||
// set fill-in intent to be used for current item
|
||||
remoteViews.setOnClickFillInIntent(
|
||||
@@ -190,6 +193,12 @@ class WidgetAdapter(intent: Intent) : RemoteViewsService.RemoteViewsFactory {
|
||||
else -> text
|
||||
}
|
||||
|
||||
private fun italicText(text: CharSequence?, shouldBold: Boolean): CharSequence? = when {
|
||||
shouldBold -> SpannableStringBuilder()
|
||||
.italic { append(text) }
|
||||
else -> text
|
||||
}
|
||||
|
||||
override fun getLoadingView(): RemoteViews {
|
||||
val view = RemoteViews(context.packageName, R.layout.widget_loading)
|
||||
view.setTextViewText(R.id.loadingText, context.getText(R.string.widget_loading))
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<string name="main_menu_rename_conversation">Rename conversation</string>
|
||||
<string name="main_syncing">Syncing messages…</string>
|
||||
<string name="main_sender_you">You: %s</string>
|
||||
<string name="main_sender_draft">Draft: %s</string>
|
||||
<string name="main_draft">Draft</string>
|
||||
<string name="main_message_results_title">Results in messages</string>
|
||||
<string name="main_message_results">%d messages</string>
|
||||
|
||||
Reference in New Issue
Block a user