Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
5 changes: 5 additions & 0 deletions app/src/main/kotlin/org/fossify/clock/views/MyTextClock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_clock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading