| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -10,14 +10,13 @@ import android.util.AttributeSet | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import androidx.annotation.ColorInt | 
					 | 
					 | 
					 | 
					import androidx.annotation.ColorInt | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import androidx.appcompat.widget.AppCompatTextView | 
					 | 
					 | 
					 | 
					import androidx.appcompat.widget.AppCompatTextView | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import io.legado.app.utils.dp | 
					 | 
					 | 
					 | 
					import io.legado.app.utils.dp | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					import java.io.File | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					class BatteryView @JvmOverloads constructor( | 
					 | 
					 | 
					 | 
					class BatteryView @JvmOverloads constructor( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    context: Context, | 
					 | 
					 | 
					 | 
					    context: Context, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    attrs: AttributeSet? = null | 
					 | 
					 | 
					 | 
					    attrs: AttributeSet? = null | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					) : AppCompatTextView(context, attrs) { | 
					 | 
					 | 
					 | 
					) : AppCompatTextView(context, attrs) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private val batteryTypeface by lazy { | 
					 | 
					 | 
					 | 
					    private val batteryTypeface by lazy { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        Typeface.createFromAsset(context.assets, "font${File.separator}number.ttf") | 
					 | 
					 | 
					 | 
					        Typeface.createFromAsset(context.assets, "font/number.ttf") | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private val batteryPaint = Paint() | 
					 | 
					 | 
					 | 
					    private val batteryPaint = Paint() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    private val outFrame = Rect() | 
					 | 
					 | 
					 | 
					    private val outFrame = Rect() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -26,18 +25,24 @@ class BatteryView @JvmOverloads constructor( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        set(value) { | 
					 | 
					 | 
					 | 
					        set(value) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            field = value | 
					 | 
					 | 
					 | 
					            field = value | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if (value) { | 
					 | 
					 | 
					 | 
					            if (value) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                typeface = batteryTypeface | 
					 | 
					 | 
					 | 
					                super.setTypeface(batteryTypeface) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                postInvalidate() | 
					 | 
					 | 
					 | 
					                postInvalidate() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            } | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        } | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    init { | 
					 | 
					 | 
					 | 
					    init { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setPadding(4.dp, 0, 6.dp, 0) | 
					 | 
					 | 
					 | 
					        setPadding(4.dp, 2.dp, 6.dp, 2.dp) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        batteryPaint.strokeWidth = 1.dp.toFloat() | 
					 | 
					 | 
					 | 
					        batteryPaint.strokeWidth = 1.dp.toFloat() | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        batteryPaint.isAntiAlias = true | 
					 | 
					 | 
					 | 
					        batteryPaint.isAntiAlias = true | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        batteryPaint.color = paint.color | 
					 | 
					 | 
					 | 
					        batteryPaint.color = paint.color | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    } | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    override fun setTypeface(tf: Typeface?) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (!isBattery) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            super.setTypeface(tf) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    fun setColor(@ColorInt color: Int) { | 
					 | 
					 | 
					 | 
					    fun setColor(@ColorInt color: Int) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        setTextColor(color) | 
					 | 
					 | 
					 | 
					        setTextColor(color) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        batteryPaint.color = color | 
					 | 
					 | 
					 | 
					        batteryPaint.color = color | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -54,9 +59,9 @@ class BatteryView @JvmOverloads constructor( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if (!isBattery) return | 
					 | 
					 | 
					 | 
					        if (!isBattery) return | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        outFrame.set( | 
					 | 
					 | 
					 | 
					        outFrame.set( | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            1.dp, | 
					 | 
					 | 
					 | 
					            1.dp, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            layout.getLineBaseline(0) + layout.getLineAscent(0) + 2.dp, | 
					 | 
					 | 
					 | 
					            1.dp, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            width - 3.dp, | 
					 | 
					 | 
					 | 
					            width - 3.dp, | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            layout.getLineBaseline(0) + 2.dp | 
					 | 
					 | 
					 | 
					            height - 1.dp | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ) | 
					 | 
					 | 
					 | 
					        ) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        val dj = (outFrame.bottom - outFrame.top) / 3 | 
					 | 
					 | 
					 | 
					        val dj = (outFrame.bottom - outFrame.top) / 3 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        polar.set( | 
					 | 
					 | 
					 | 
					        polar.set( | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |