From e904efa6ed7539beda781dae376a2ad962e265d9 Mon Sep 17 00:00:00 2001 From: Naveen Singh <36371707+naveensingh@users.noreply.github.com> Date: Mon, 26 Jan 2026 00:08:09 +0530 Subject: [PATCH] feat: add font customization (#676) * fix: use AndroidX AppCompat PopupMenu * feat: add font customization --- CHANGELOG.md | 1 + .../messages/adapters/BaseConversationsAdapter.kt | 8 +++++--- .../org/fossify/messages/adapters/ThreadAdapter.kt | 5 +++-- .../messages/dialogs/ManageBlockedKeywordsAdapter.kt | 2 +- app/src/main/res/layout/item_attachment_document.xml | 4 ++-- app/src/main/res/layout/item_attachment_vcard.xml | 6 +++--- app/src/main/res/layout/item_conversation.xml | 10 +++++----- app/src/main/res/layout/item_message.xml | 2 +- .../main/res/layout/layout_invalid_short_code_info.xml | 2 +- 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c89f39c..b013ff28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Added support for custom fonts - Added "Copy number to clipboard" option inside chat overflow menu ([#651]) ### Changed diff --git a/app/src/main/kotlin/org/fossify/messages/adapters/BaseConversationsAdapter.kt b/app/src/main/kotlin/org/fossify/messages/adapters/BaseConversationsAdapter.kt index 3a425719..2d5c0857 100644 --- a/app/src/main/kotlin/org/fossify/messages/adapters/BaseConversationsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/messages/adapters/BaseConversationsAdapter.kt @@ -18,6 +18,7 @@ import org.fossify.commons.extensions.formatDateOrTime import org.fossify.commons.extensions.getContrastColor import org.fossify.commons.extensions.getTextSize import org.fossify.commons.extensions.setupViewBackground +import org.fossify.commons.helpers.FontHelper import org.fossify.commons.helpers.SimpleContactsHelper import org.fossify.commons.helpers.ensureBackgroundThread import org.fossify.commons.views.MyRecyclerView @@ -181,9 +182,10 @@ abstract class BaseConversationsAdapter( conversationBodyShort.alpha = 0.7f if (conversation.isScheduled) Typeface.ITALIC else Typeface.NORMAL } - conversationAddress.setTypeface(null, style) - conversationBodyShort.setTypeface(null, style) - conversationDate.setTypeface(null, style) + val customTypeface = FontHelper.getTypeface(activity) + conversationAddress.setTypeface(customTypeface, style) + conversationBodyShort.setTypeface(customTypeface, style) + conversationDate.setTypeface(customTypeface, style) arrayListOf(conversationAddress, conversationBodyShort, conversationDate).forEach { it.setTextColor(textColor) diff --git a/app/src/main/kotlin/org/fossify/messages/adapters/ThreadAdapter.kt b/app/src/main/kotlin/org/fossify/messages/adapters/ThreadAdapter.kt index d9aec0e6..1151bc5d 100644 --- a/app/src/main/kotlin/org/fossify/messages/adapters/ThreadAdapter.kt +++ b/app/src/main/kotlin/org/fossify/messages/adapters/ThreadAdapter.kt @@ -42,6 +42,7 @@ import org.fossify.commons.extensions.getTimeFormat import org.fossify.commons.extensions.shareTextIntent import org.fossify.commons.extensions.showErrorToast import org.fossify.commons.extensions.usableScreenSize +import org.fossify.commons.helpers.FontHelper import org.fossify.commons.helpers.SimpleContactsHelper import org.fossify.commons.helpers.ensureBackgroundThread import org.fossify.commons.views.MyRecyclerView @@ -473,7 +474,7 @@ class ThreadAdapter( setLinkTextColor(contrastColor) if (message.isScheduled) { - typeface = Typeface.create(Typeface.DEFAULT, Typeface.ITALIC) + typeface = Typeface.create(FontHelper.getTypeface(activity), Typeface.ITALIC) val scheduledDrawable = AppCompatResources.getDrawable(activity, org.fossify.commons.R.drawable.ic_clock_vector)?.apply { applyColorFilter(contrastColor) val size = lineHeight @@ -482,7 +483,7 @@ class ThreadAdapter( setCompoundDrawables(null, null, scheduledDrawable, null) } else { - typeface = Typeface.DEFAULT + typeface = FontHelper.getTypeface(activity) setCompoundDrawables(null, null, null, null) } } diff --git a/app/src/main/kotlin/org/fossify/messages/dialogs/ManageBlockedKeywordsAdapter.kt b/app/src/main/kotlin/org/fossify/messages/dialogs/ManageBlockedKeywordsAdapter.kt index 05ff3bbf..57d2883f 100644 --- a/app/src/main/kotlin/org/fossify/messages/dialogs/ManageBlockedKeywordsAdapter.kt +++ b/app/src/main/kotlin/org/fossify/messages/dialogs/ManageBlockedKeywordsAdapter.kt @@ -1,7 +1,7 @@ package org.fossify.messages.dialogs import android.view.* -import android.widget.PopupMenu +import androidx.appcompat.widget.PopupMenu import org.fossify.commons.activities.BaseSimpleActivity import org.fossify.commons.adapters.MyRecyclerViewAdapter import org.fossify.commons.extensions.copyToClipboard diff --git a/app/src/main/res/layout/item_attachment_document.xml b/app/src/main/res/layout/item_attachment_document.xml index ba70eef4..01ce75d9 100644 --- a/app/src/main/res/layout/item_attachment_document.xml +++ b/app/src/main/res/layout/item_attachment_document.xml @@ -33,7 +33,7 @@ android:layout_marginStart="@dimen/medium_margin" android:orientation="vertical"> - - - - - - - - - - - -