Skip to content

Commit

Permalink
fix(#225): 24-hour binary clock (#229)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Kuestersteffen <[email protected]>
  • Loading branch information
khwolf and jkuester authored Mar 23, 2024
1 parent bfc36e6 commit fdd08a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit fdd08a5

Please sign in to comment.