Skip to content

Convert ms timeouts to seconds in UI#225

Merged
sjp4 merged 3 commits into
coredevices:masterfrom
jmsunseri:jmsunseri/feat/slider-ux-improvements-only
Jun 8, 2026
Merged

Convert ms timeouts to seconds in UI#225
sjp4 merged 3 commits into
coredevices:masterfrom
jmsunseri:jmsunseri/feat/slider-ux-improvements-only

Conversation

@jmsunseri

Copy link
Copy Markdown
Contributor

Display BacklightTimeoutMs and NotificationTimeoutMs as seconds and minutes:seconds respectively. Adjusts slider steps and formats default values to match the new units.

Display BacklightTimeoutMs and NotificationTimeoutMs as
seconds and minutes:seconds respectively. Adjusts slider
steps and formats default values to match the new units.
@CLAassistant

CLAassistant commented May 31, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ jmsunseri
❌ Justin Sunseri


Justin Sunseri seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@jmsunseri

Copy link
Copy Markdown
Contributor Author

cc @ericmigi

)
return when (pref) {
NumberWatchPref.BacklightTimeoutMs -> {
val secValue = item.valueOrDefault() / 1000

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer using kotlin duration to do all the maths here e.g. item.valueOrDefault().milliseconds.inWholeSeconds

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be resolved

topLevelType = TopLevelType.Watch,
section = pref.section(),
value = secValue,
min = 1,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min/are already defined in the NumberWatchPref enum - shouldn't be defining them again separately (e.g. use pref.min.milliseconds.inWholeSeconds here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be resolved

min = 1,
max = 10,
onValueChange = {
libPebble.setWatchPref(item.copy(value = it * 1000))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all of these - use kotlin time functions, not / 1000, for better code clarity

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be resolved

valueFormatter = { v ->
"${v / 60}:${(v % 60).toString().padStart(2, '0')}"
},
stepsOverride = 19,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test code left in?

isDebugSetting: Boolean = false,
defaultValue: Long? = null,
valueFormatter: ((Long) -> String)? = null,
stepsOverride: Int? = null,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test code?

valueFormatter = { "$it seconds" },
)
}
NumberWatchPref.NotificationTimeoutMs -> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of the same as the one above but with a different formatter - worth splitting out into a basicSettingsNumberSecondsItem and passing in through a different formatter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this has been addressed. thanks for the comment

topLevelType = TopLevelType.Watch,
section = pref.section(),
value = secValue,
min = 0,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above - don't repeat the defaults here (they'll get out of sync if we ever change them)

val minF = remember(min) { min.toFloat() }
val maxF = remember(max) { max.toFloat() }
val steps = remember(max, min) {
val steps = stepsOverride ?: remember(max, min) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this is actually setting the number of steps... not test code!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. i renamed this a bit so it reads a little bit better to me though.

Justin Sunseri and others added 2 commits June 6, 2026 09:44
@jmsunseri

Copy link
Copy Markdown
Contributor Author

@sjp4 I know these edit's compile but I'm traveling for work and my personal laptop that i do hobby dev on is so under powered that i can barely compile the mobile app and the emulator crashes because of some incompatibility in the graphics drivers (2013 MacBook Air running Fedora). Could you please try this out locally? If not it will have to wait till i get back from my trip.

@sjp4 sjp4 merged commit cf1bcac into coredevices:master Jun 8, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants