Add style to BinaryClock for 24-hour time (#1190)
* Add style to BinaryClock for 24-hour time * Use global time format preference for all clock widget styles * Add support for time format preference to remaining clock styles --------- Co-authored-by: MM20 <15646950+MM2-0@users.noreply.github.com>
This commit is contained in:
@@ -567,6 +567,10 @@
|
||||
<string name="preference_clockwidget_layout_vertical">Default</string>
|
||||
<string name="preference_clockwidget_layout_horizontal">Compact</string>
|
||||
<string name="preference_clock_widget_show_seconds">Show seconds</string>
|
||||
<string name="preference_clock_widget_time_format">Time format</string>
|
||||
<string name="preference_clock_widget_time_format_24h">24-hour</string>
|
||||
<string name="preference_clock_widget_time_format_12h">12-hour</string>
|
||||
<string name="preference_clock_widget_time_format_system">System default</string>
|
||||
<string name="widget_use_theme_colors">Use theme color</string>
|
||||
<string name="preference_clock_widget_fill_height">Fill screen height</string>
|
||||
<string name="preference_clock_widget_alignment">Alignment</string>
|
||||
|
||||
@@ -34,6 +34,7 @@ data class LauncherSettingsData internal constructor(
|
||||
val clockWidgetCustom: ClockWidgetStyle.Custom = ClockWidgetStyle.Custom(),
|
||||
val clockWidgetColors: ClockWidgetColors = ClockWidgetColors.Auto,
|
||||
val clockWidgetShowSeconds: Boolean = false,
|
||||
val clockWidgetTimeFormat: TimeFormat = TimeFormat.System,
|
||||
val clockWidgetUseThemeColor: Boolean = false,
|
||||
val clockWidgetAlarmPart: Boolean = true,
|
||||
val clockWidgetBatteryPart: Boolean = true,
|
||||
@@ -408,4 +409,11 @@ enum class KeyboardFilterBarItem {
|
||||
@SerialName("events") Events,
|
||||
@SerialName("tools") Tools,
|
||||
@SerialName("hidden") HiddenResults,
|
||||
}
|
||||
|
||||
@Serializable
|
||||
enum class TimeFormat {
|
||||
@SerialName("system") System,
|
||||
@SerialName("12h") TwelveHour,
|
||||
@SerialName("24h") TwentyFourHour
|
||||
}
|
||||
+10
@@ -5,6 +5,7 @@ import de.mm20.launcher2.preferences.ClockWidgetColors
|
||||
import de.mm20.launcher2.preferences.ClockWidgetStyle
|
||||
import de.mm20.launcher2.preferences.ClockWidgetStyleEnum
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import de.mm20.launcher2.preferences.TimeFormat
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
@@ -137,6 +138,15 @@ class ClockWidgetSettings internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val timeFormat
|
||||
get() = launcherDataStore.data.map { it.clockWidgetTimeFormat }
|
||||
|
||||
fun setTimeFormat(timeFormat: TimeFormat) {
|
||||
launcherDataStore.update {
|
||||
it.copy(clockWidgetTimeFormat = timeFormat)
|
||||
}
|
||||
}
|
||||
|
||||
val useThemeColor
|
||||
get() = launcherDataStore.data.map { it.clockWidgetUseThemeColor }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user