feat: add font customization (#676)

* fix: use AndroidX AppCompat PopupMenu

* feat: add font customization
This commit is contained in:
Naveen Singh 2026-01-26 00:08:09 +05:30 committed by GitHub
parent d5a6ef09b1
commit e904efa6ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 22 additions and 18 deletions

View file

@ -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

View file

@ -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)

View file

@ -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)
}
}

View file

@ -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

View file

@ -33,7 +33,7 @@
android:layout_marginStart="@dimen/medium_margin"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/filename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -44,7 +44,7 @@
android:textStyle="bold"
tools:text="Event_16_02_2022.ics" />
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/file_size"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -27,7 +27,7 @@
android:layout_marginStart="@dimen/medium_margin"
android:orientation="vertical">
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/vcard_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -39,7 +39,7 @@
tools:text="Elon Reeve Musk"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/vcard_subtitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -48,7 +48,7 @@
tools:text="and 6 others"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/view_contact_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

@ -23,7 +23,7 @@
app:layout_constraintTop_toTopOf="@id/conversation_address"
tools:src="@mipmap/ic_launcher" />
<TextView
<org.fossify.commons.views.MyTextView
android:id="@+id/conversation_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -39,7 +39,7 @@
app:layout_constraintTop_toTopOf="parent"
tools:text="John" />
<TextView
<org.fossify.commons.views.MyTextView
android:id="@+id/draft_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -57,7 +57,7 @@
app:layout_constraintStart_toStartOf="@id/conversation_address"
app:layout_constraintTop_toTopOf="@id/conversation_body_short" />
<TextView
<org.fossify.commons.views.MyTextView
android:id="@+id/conversation_body_short"
android:layout_width="0dp"
android:layout_height="wrap_content"
@ -73,7 +73,7 @@
app:layout_constraintTop_toBottomOf="@id/conversation_address"
tools:text="Hey buddy!" />
<TextView
<org.fossify.commons.views.MyTextView
android:id="@+id/conversation_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -99,7 +99,7 @@
app:layout_constraintTop_toTopOf="@id/conversation_body_short"
tools:visibility="visible" />
<TextView
<org.fossify.commons.views.MyTextView
android:id="@+id/unread_count_badge"
android:layout_width="@dimen/small_icon_size"
android:layout_height="@dimen/small_icon_size"

View file

@ -51,7 +51,7 @@
android:visibility="gone"
tools:ignore="ContentDescription" />
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/thread_message_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -4,7 +4,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
<org.fossify.commons.views.MyTextView
android:id="@+id/reply_disabled_text"
android:layout_width="0dp"
android:layout_height="wrap_content"