Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#225): 24-hour binary clock #229

Merged
merged 2 commits into from
Mar 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.RectF
import android.text.format.DateFormat
import android.util.AttributeSet
import com.sduduzog.slimlauncher.R
import java.util.Calendar
Expand Down Expand Up @@ -89,4 +90,18 @@ class BinaryClockView(context: Context, attrs: AttributeSet) :

setMeasuredDimension(w, h)
}

override fun updateClock() {
super.updateClock()

val timeFormat = context.getSharedPreferences(
context.getString(R.string.prefs_settings),
Context.MODE_PRIVATE
)?.getInt(context.getString(R.string.prefs_settings_key_time_format), 0)
is24Hour = when (timeFormat) {
1 -> true
2 -> false
else -> DateFormat.is24HourFormat(context)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class ClockView(context: Context, attrs: AttributeSet) : View(context,
return paint
}

fun updateClock() {
open fun updateClock() {
requestLayout()
invalidate()
}
Expand Down
Loading