mirror of
https://github.com/FossifyOrg/Clock.git
synced 2026-05-19 12:34:39 -04:00
feat: add font customization (#374)
This commit is contained in:
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- Added support for custom fonts
|
||||
|
||||
### Fixed
|
||||
- Fixed overlap/truncation in stopwatch lap times ([#346])
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.util.TypedValue
|
||||
import android.widget.TextView
|
||||
import org.fossify.commons.extensions.applyFontToTextView
|
||||
|
||||
/**
|
||||
* A simple wrapper TextView that restores the original text size
|
||||
@@ -17,6 +18,10 @@ class AutoFitTextView @JvmOverloads constructor(
|
||||
defStyle: Int = 0,
|
||||
) : TextView(context, attrs, defStyle) {
|
||||
|
||||
init {
|
||||
if (!isInEditMode) context.applyFontToTextView(this)
|
||||
}
|
||||
|
||||
private var originalTextSize: Float = textSize
|
||||
private var originalWidth: Int = 0
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.util.AttributeSet
|
||||
import android.widget.TextClock
|
||||
import androidx.annotation.AttrRes
|
||||
import org.fossify.clock.extensions.config
|
||||
import org.fossify.commons.extensions.applyFontToTextView
|
||||
import java.text.DateFormatSymbols
|
||||
|
||||
private const val AM_PM_SCALE = 0.4f
|
||||
@@ -18,6 +19,10 @@ class MyTextClock @JvmOverloads constructor(
|
||||
@AttrRes defStyleAttr: Int = android.R.attr.textViewStyle,
|
||||
) : TextClock(context, attrs, defStyleAttr) {
|
||||
|
||||
init {
|
||||
if (!isInEditMode) context.applyFontToTextView(this)
|
||||
}
|
||||
|
||||
private val amPmStrings by lazy {
|
||||
DateFormatSymbols.getInstance(
|
||||
resources.configuration.locales[0]
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
android:textSize="@dimen/clock_text_size"
|
||||
tools:text="00:00:00" />
|
||||
|
||||
<TextClock
|
||||
<org.fossify.clock.views.MyTextClock
|
||||
android:id="@+id/clock_date"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
Reference in New Issue
Block a user