From 9adea2ee8b7b9746e75699325d5d28983b3923ac Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 8 Mar 2020 19:48:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/ui/book/read/page/ContentView.kt | 1 + app/src/main/java/io/legado/app/ui/widget/BatteryView.kt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 389d924f6..5ecc2bba3 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -68,6 +68,7 @@ class ContentView(context: Context) : FrameLayout(context) { tv_top_right.setTextColor(it) tv_bottom_left.setTextColor(it) tv_bottom_right.setTextColor(it) + battery_view.setColor(it) } if (hideStatusBar) { tv_bottom_left.text = timeFormat.format(Date(System.currentTimeMillis())) diff --git a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt index 9fb62a57f..60e781c93 100644 --- a/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/BatteryView.kt @@ -9,6 +9,7 @@ import android.text.StaticLayout import android.text.TextPaint import android.util.AttributeSet import android.view.View +import androidx.annotation.ColorInt import io.legado.app.R import io.legado.app.utils.dp import io.legado.app.utils.getCompatColor @@ -23,7 +24,7 @@ class BatteryView(context: Context, attrs: AttributeSet?) : View(context, attrs) private val polar = Rect() init { - textPaint.textSize = 12.sp.toFloat() + textPaint.textSize = 10.sp.toFloat() textPaint.strokeWidth = 1.dp.toFloat() textPaint.isAntiAlias = true textPaint.textAlign = Paint.Align.CENTER @@ -42,6 +43,11 @@ class BatteryView(context: Context, attrs: AttributeSet?) : View(context, attrs) ) } + fun setColor(@ColorInt color: Int) { + textPaint.color = color + invalidate() + } + fun setBattery(battery: Int) { this.battery = battery invalidate()