|
|
|
@ -62,6 +62,12 @@ class ReaderInfoBarView @JvmOverloads constructor(
|
|
|
|
private val innerWidth
|
|
|
|
private val innerWidth
|
|
|
|
get() = width - paddingLeft - paddingRight - insetLeft - insetRight
|
|
|
|
get() = width - paddingLeft - paddingRight - insetLeft - insetRight
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isTimeVisible: Boolean = true
|
|
|
|
|
|
|
|
set(value) {
|
|
|
|
|
|
|
|
field = value
|
|
|
|
|
|
|
|
invalidate()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
paint.strokeWidth = context.resources.resolveDp(2f)
|
|
|
|
paint.strokeWidth = context.resources.resolveDp(2f)
|
|
|
|
val insetCorner = getSystemUiDimensionOffset("rounded_corner_content_padding")
|
|
|
|
val insetCorner = getSystemUiDimensionOffset("rounded_corner_content_padding")
|
|
|
|
@ -92,6 +98,7 @@ class ReaderInfoBarView @JvmOverloads constructor(
|
|
|
|
(paddingLeft + insetLeft + cutoutInsetLeft).toFloat(),
|
|
|
|
(paddingLeft + insetLeft + cutoutInsetLeft).toFloat(),
|
|
|
|
paddingTop + insetTop + ty,
|
|
|
|
paddingTop + insetTop + ty,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
if (isTimeVisible) {
|
|
|
|
paint.textAlign = Paint.Align.RIGHT
|
|
|
|
paint.textAlign = Paint.Align.RIGHT
|
|
|
|
canvas.drawTextOutline(
|
|
|
|
canvas.drawTextOutline(
|
|
|
|
timeText,
|
|
|
|
timeText,
|
|
|
|
@ -99,6 +106,7 @@ class ReaderInfoBarView @JvmOverloads constructor(
|
|
|
|
paddingTop + insetTop + ty,
|
|
|
|
paddingTop + insetTop + ty,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
|
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
|
|
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
|
|
super.onSizeChanged(w, h, oldw, oldh)
|
|
|
|
@ -183,9 +191,11 @@ class ReaderInfoBarView @JvmOverloads constructor(
|
|
|
|
|
|
|
|
|
|
|
|
override fun onReceive(context: Context?, intent: Intent?) {
|
|
|
|
override fun onReceive(context: Context?, intent: Intent?) {
|
|
|
|
timeText = timeFormat.format(LocalTime.now())
|
|
|
|
timeText = timeFormat.format(LocalTime.now())
|
|
|
|
|
|
|
|
if (isTimeVisible) {
|
|
|
|
invalidate()
|
|
|
|
invalidate()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("DiscouragedApi")
|
|
|
|
@SuppressLint("DiscouragedApi")
|
|
|
|
private fun getSystemUiDimensionOffset(name: String, fallback: Int = 0): Int = runCatching {
|
|
|
|
private fun getSystemUiDimensionOffset(name: String, fallback: Int = 0): Int = runCatching {
|
|
|
|
|