diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/ClockWidget.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/ClockWidget.kt
index a762e0a7c..91975f824 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/ClockWidget.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/ClockWidget.kt
@@ -27,6 +27,7 @@ import androidx.compose.material.icons.rounded.AutoAwesome
import androidx.compose.material.icons.rounded.BatteryFull
import androidx.compose.material.icons.rounded.ColorLens
import androidx.compose.material.icons.rounded.DarkMode
+import androidx.compose.material.icons.rounded.FormatColorText
import androidx.compose.material.icons.rounded.Height
import androidx.compose.material.icons.rounded.HorizontalSplit
import androidx.compose.material.icons.rounded.LightMode
@@ -272,6 +273,7 @@ fun Clock(
val context = LocalContext.current
val clockSettings: ClockWidgetSettings = koinInject()
val showSeconds by clockSettings.showSeconds.collectAsState(initial = false)
+ val monospaced by clockSettings.monospaced.collectAsState(initial = false)
val useThemeColor by clockSettings.useThemeColor.collectAsState(initial = false)
val timeFormat by clockSettings.timeFormat.collectAsState(null)
@@ -285,6 +287,7 @@ fun Clock(
compact = compact,
showSeconds = showSeconds,
twentyFourHours = isTwentyFourHours,
+ monospaced = monospaced,
useThemeColor = useThemeColor,
darkColors = darkColors,
style = style,
@@ -295,6 +298,7 @@ fun Clock(
compact = compact,
showSeconds = showSeconds,
twentyFourHours = isTwentyFourHours,
+ monospaced = monospaced,
useThemeColor = useThemeColor,
darkColors = darkColors,
)
@@ -322,6 +326,7 @@ fun Clock(
compact = compact,
showSeconds = showSeconds,
twentyFourHours = isTwentyFourHours,
+ monospaced = monospaced,
useThemeColor = useThemeColor,
darkColors = darkColors,
)
@@ -366,6 +371,7 @@ fun ConfigureClockWidgetSheet(
val widgetsOnHome by viewModel.widgetsOnHome.collectAsState()
val alignment by viewModel.alignment.collectAsState()
val showSeconds by viewModel.showSeconds.collectAsState()
+ val monospaced by viewModel.monospaced.collectAsState()
val timeFormat by viewModel.timeFormat.collectAsState()
val useAccentColor by viewModel.useThemeColor.collectAsState()
val parts by viewModel.parts.collectAsState()
@@ -513,6 +519,20 @@ fun ConfigureClockWidgetSheet(
}
)
}
+ AnimatedVisibility(
+ style is ClockWidgetStyle.Digital1 ||
+ style is ClockWidgetStyle.Digital2 ||
+ style is ClockWidgetStyle.Orbit
+ ) {
+ SwitchPreference(
+ title = stringResource(R.string.preference_clock_widget_monospaced),
+ icon = Icons.Rounded.FormatColorText,
+ value = monospaced,
+ onValueChanged = {
+ viewModel.setMonospaced(it)
+ }
+ )
+ }
AnimatedVisibility(
style !is ClockWidgetStyle.Analog &&
style !is ClockWidgetStyle.Custom &&
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock1.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock1.kt
index b6b977903..59a730a7f 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock1.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock1.kt
@@ -35,6 +35,7 @@ fun DigitalClock1(
compact: Boolean,
twentyFourHours: Boolean,
showSeconds: Boolean,
+ monospaced: Boolean,
useThemeColor: Boolean,
darkColors: Boolean,
) {
@@ -75,6 +76,7 @@ fun DigitalClock1(
val textStyle = MaterialTheme.typography.displayLarge.copy(
fontSize = if (verticalLayout) 100.sp else 48.sp,
fontWeight = FontWeight.Black,
+ fontFeatureSettings = if (monospaced) "tnum" else null,
textAlign = TextAlign.Center,
lineHeight = 0.8.em,
drawStyle = if (style.outlined) Stroke(width = 2.dp.toPixels()) else Fill,
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock2.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock2.kt
index 5050e710f..b7a399b8c 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock2.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/DigitalClock2.kt
@@ -22,6 +22,7 @@ fun DigitalClock2(
compact: Boolean,
showSeconds: Boolean,
twentyFourHours: Boolean,
+ monospaced: Boolean,
useThemeColor: Boolean,
darkColors: Boolean,
) {
@@ -64,6 +65,7 @@ fun DigitalClock2(
text = formatter.format(time),
style = MaterialTheme.typography.displaySmall.copy(
fontWeight = FontWeight.Normal,
+ fontFeatureSettings = if (monospaced) "tnum" else null,
color = color
)
)
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/OrbitClock.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/OrbitClock.kt
index 1305f9064..f72ca4a51 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/OrbitClock.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/launcher/widgets/clock/clocks/OrbitClock.kt
@@ -49,6 +49,7 @@ fun OrbitClock(
compact: Boolean,
showSeconds: Boolean,
twentyFourHours: Boolean,
+ monospaced: Boolean,
useThemeColor: Boolean,
darkColors: Boolean,
) {
@@ -126,8 +127,12 @@ fun OrbitClock(
val contentColor = LocalContentColor.current
val textMeasurer = rememberTextMeasurer()
- val minuteStyle = MaterialTheme.typography.labelMedium
- val hourStyle = MaterialTheme.typography.labelLarge
+ val minuteStyle = MaterialTheme.typography.labelMedium.copy(
+ fontFeatureSettings = if (monospaced) "tnum" else null
+ )
+ val hourStyle = MaterialTheme.typography.labelLarge.copy(
+ fontFeatureSettings = if (monospaced) "tnum" else null
+ )
val strokeWidth = if (verticalLayout) 2.dp else 1.dp
diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/clockwidget/ClockWidgetSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/clockwidget/ClockWidgetSettingsScreenVM.kt
index bb6f68862..dd5be4250 100644
--- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/clockwidget/ClockWidgetSettingsScreenVM.kt
+++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/clockwidget/ClockWidgetSettingsScreenVM.kt
@@ -57,6 +57,13 @@ class ClockWidgetSettingsScreenVM : ViewModel(), KoinComponent {
settings.setShowSeconds(showSeconds)
}
+ val monospaced = settings.monospaced
+ .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false)
+
+ fun setMonospaced(monospaced: Boolean) {
+ settings.setMonospaced(monospaced)
+ }
+
val timeFormat = settings.timeFormat
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), TimeFormat.System)
diff --git a/core/i18n/src/main/res/values/strings.xml b/core/i18n/src/main/res/values/strings.xml
index 4077b8c77..d73a8342b 100644
--- a/core/i18n/src/main/res/values/strings.xml
+++ b/core/i18n/src/main/res/values/strings.xml
@@ -583,6 +583,7 @@
Default
Compact
Show seconds
+ Monospaced digits
Time format
24-hour
12-hour
diff --git a/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt b/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt
index 5e01f759e..e307f64b5 100644
--- a/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt
+++ b/core/preferences/src/main/java/de/mm20/launcher2/preferences/LauncherSettingsData.kt
@@ -45,6 +45,7 @@ data class LauncherSettingsData internal constructor(
val clockWidgetCustom: ClockWidgetStyle.Custom = ClockWidgetStyle.Custom(),
val clockWidgetColors: ClockWidgetColors = ClockWidgetColors.Auto,
val clockWidgetShowSeconds: Boolean = false,
+ val clockWidgetMonospaced: Boolean = false,
val clockWidgetTimeFormat: TimeFormat = TimeFormat.System,
val clockWidgetUseThemeColor: Boolean = false,
val clockWidgetAlarmPart: Boolean = true,
diff --git a/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/ClockWidgetSettings.kt b/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/ClockWidgetSettings.kt
index 6341536ad..9b290093b 100644
--- a/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/ClockWidgetSettings.kt
+++ b/core/preferences/src/main/java/de/mm20/launcher2/preferences/ui/ClockWidgetSettings.kt
@@ -136,6 +136,15 @@ class ClockWidgetSettings internal constructor(
}
}
+ val monospaced
+ get() = launcherDataStore.data.map { it.clockWidgetMonospaced }
+
+ fun setMonospaced(enabled: Boolean) {
+ launcherDataStore.update {
+ it.copy(clockWidgetMonospaced = enabled)
+ }
+ }
+
val timeFormat
get() = launcherDataStore.data.map { it.clockWidgetTimeFormat }