|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.lib.theme.view |
|
|
|
package io.legado.app.lib.theme.view |
|
|
|
|
|
|
|
|
|
|
|
import android.content.Context |
|
|
|
import android.content.Context |
|
|
|
|
|
|
|
import android.graphics.Color |
|
|
|
import android.util.AttributeSet |
|
|
|
import android.util.AttributeSet |
|
|
|
import androidx.appcompat.widget.AppCompatRadioButton |
|
|
|
import androidx.appcompat.widget.AppCompatRadioButton |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
@ -29,35 +30,47 @@ class ThemeRadioNoButton(context: Context, attrs: AttributeSet) : |
|
|
|
when { |
|
|
|
when { |
|
|
|
isInEditMode -> Unit |
|
|
|
isInEditMode -> Unit |
|
|
|
isBottomBackground -> { |
|
|
|
isBottomBackground -> { |
|
|
|
|
|
|
|
val accentColor = context.accentColor |
|
|
|
val isLight = ColorUtils.isColorLight(context.bottomBackground) |
|
|
|
val isLight = ColorUtils.isColorLight(context.bottomBackground) |
|
|
|
val textColor = context.getPrimaryTextColor(isLight) |
|
|
|
val textColor = context.getPrimaryTextColor(isLight) |
|
|
|
|
|
|
|
val checkedTextColor = if (ColorUtils.isColorLight(accentColor)) { |
|
|
|
|
|
|
|
Color.BLACK |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Color.WHITE |
|
|
|
|
|
|
|
} |
|
|
|
background = Selector.shapeBuild() |
|
|
|
background = Selector.shapeBuild() |
|
|
|
.setCornerRadius(2.dpToPx()) |
|
|
|
.setCornerRadius(2.dpToPx()) |
|
|
|
.setStrokeWidth(2.dpToPx()) |
|
|
|
.setStrokeWidth(2.dpToPx()) |
|
|
|
.setCheckedBgColor(context.accentColor) |
|
|
|
.setCheckedBgColor(accentColor) |
|
|
|
.setCheckedStrokeColor(context.accentColor) |
|
|
|
.setCheckedStrokeColor(accentColor) |
|
|
|
.setDefaultStrokeColor(textColor) |
|
|
|
.setDefaultStrokeColor(textColor) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
setTextColor( |
|
|
|
setTextColor( |
|
|
|
Selector.colorBuild() |
|
|
|
Selector.colorBuild() |
|
|
|
.setDefaultColor(textColor) |
|
|
|
.setDefaultColor(textColor) |
|
|
|
.setCheckedColor(context.getPrimaryTextColor(ColorUtils.isColorLight(context.accentColor))) |
|
|
|
.setCheckedColor(checkedTextColor) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
val textColor = context.getCompatColor(R.color.primaryText) |
|
|
|
val accentColor = context.accentColor |
|
|
|
|
|
|
|
val defaultTextColor = context.getCompatColor(R.color.primaryText) |
|
|
|
|
|
|
|
val checkedTextColor = if (ColorUtils.isColorLight(accentColor)) { |
|
|
|
|
|
|
|
Color.BLACK |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Color.WHITE |
|
|
|
|
|
|
|
} |
|
|
|
background = Selector.shapeBuild() |
|
|
|
background = Selector.shapeBuild() |
|
|
|
.setCornerRadius(2.dpToPx()) |
|
|
|
.setCornerRadius(2.dpToPx()) |
|
|
|
.setStrokeWidth(2.dpToPx()) |
|
|
|
.setStrokeWidth(2.dpToPx()) |
|
|
|
.setCheckedBgColor(context.accentColor) |
|
|
|
.setCheckedBgColor(accentColor) |
|
|
|
.setCheckedStrokeColor(context.accentColor) |
|
|
|
.setCheckedStrokeColor(accentColor) |
|
|
|
.setDefaultStrokeColor(textColor) |
|
|
|
.setDefaultStrokeColor(defaultTextColor) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
setTextColor( |
|
|
|
setTextColor( |
|
|
|
Selector.colorBuild() |
|
|
|
Selector.colorBuild() |
|
|
|
.setDefaultColor(textColor) |
|
|
|
.setDefaultColor(defaultTextColor) |
|
|
|
.setCheckedColor(context.getPrimaryTextColor(ColorUtils.isColorLight(context.accentColor))) |
|
|
|
.setCheckedColor(checkedTextColor) |
|
|
|
.create() |
|
|
|
.create() |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|