pull/1705/head
kunfei 3 years ago
parent 54e311ac81
commit f68c730416
  1. 6
      app/src/main/java/io/legado/app/lib/theme/MaterialValueHelper.kt
  2. 10
      app/src/main/java/io/legado/app/lib/theme/view/ThemeRadioNoButton.kt
  3. 2
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  4. 2
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  5. 2
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  6. 2
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  7. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  8. 4
      app/src/main/java/io/legado/app/ui/book/read/config/MoreConfigDialog.kt
  9. 2
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  10. 16
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  11. 18
      app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt
  12. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  13. 2
      app/src/main/java/io/legado/app/ui/login/SourceLoginDialog.kt
  14. 4
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  15. 18
      app/src/main/java/io/legado/app/ui/widget/BatteryView.kt
  16. 6
      app/src/main/java/io/legado/app/ui/widget/LabelsBar.kt
  17. 8
      app/src/main/java/io/legado/app/ui/widget/anima/RotateLoading.kt
  18. 4
      app/src/main/java/io/legado/app/ui/widget/checkbox/SmoothCheckBox.kt
  19. 5
      app/src/main/java/io/legado/app/ui/widget/image/CircleImageView.kt
  20. 4
      app/src/main/java/io/legado/app/ui/widget/image/FilletImageView.kt
  21. 4
      app/src/main/java/io/legado/app/ui/widget/keyboard/KeyboardAssistsConfig.kt
  22. 4
      app/src/main/java/io/legado/app/ui/widget/text/AccentBgTextView.kt
  23. 6
      app/src/main/java/io/legado/app/ui/widget/text/AccentStrokeTextView.kt
  24. 12
      app/src/main/java/io/legado/app/ui/widget/text/StrokeTextView.kt
  25. 23
      app/src/main/java/io/legado/app/utils/ConvertExtensions.kt

@ -11,7 +11,7 @@ import androidx.fragment.app.Fragment
import io.legado.app.R
import io.legado.app.help.config.AppConfig
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
/**
* @author Karim Abou Zeid (kabouzeid)
@ -127,14 +127,14 @@ val Context.elevation: Float
resources.getDimension(R.dimen.design_appbar_elevation)
)
} else {
AppConfig.elevation.dp.toFloat()
AppConfig.elevation.toFloat().dpToPx()
}
}
val Context.filletBackground: GradientDrawable
get() {
val background = GradientDrawable()
background.cornerRadius = 3F.dp
background.cornerRadius = 3f.dpToPx()
background.setColor(backgroundColor)
return background
}

@ -9,7 +9,7 @@ import io.legado.app.lib.theme.accentColor
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor
class ThemeRadioNoButton(context: Context, attrs: AttributeSet) :
@ -32,8 +32,8 @@ class ThemeRadioNoButton(context: Context, attrs: AttributeSet) :
val isLight = ColorUtils.isColorLight(context.bottomBackground)
val textColor = context.getPrimaryTextColor(isLight)
background = Selector.shapeBuild()
.setCornerRadius(2.dp)
.setStrokeWidth(2.dp)
.setCornerRadius(2.dpToPx())
.setStrokeWidth(2.dpToPx())
.setCheckedBgColor(context.accentColor)
.setCheckedStrokeColor(context.accentColor)
.setDefaultStrokeColor(textColor)
@ -48,8 +48,8 @@ class ThemeRadioNoButton(context: Context, attrs: AttributeSet) :
else -> {
val textColor = context.getCompatColor(R.color.primaryText)
background = Selector.shapeBuild()
.setCornerRadius(2.dp)
.setStrokeWidth(2.dp)
.setCornerRadius(2.dpToPx())
.setStrokeWidth(2.dpToPx())
.setCheckedBgColor(context.accentColor)
.setCheckedStrokeColor(context.accentColor)
.setDefaultStrokeColor(textColor)

@ -164,7 +164,7 @@ class ImportBookSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_vie
}
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
editView.dropDownHeight = 180.dpToPx()
}
customView {
alertBinding.root

@ -140,7 +140,7 @@ class ImportReplaceRuleDialog() : BaseDialogFragment(R.layout.dialog_recycler_vi
}
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
editView.dropDownHeight = 180.dpToPx()
}
customView {
alertBinding.root

@ -163,7 +163,7 @@ class ImportRssSourceDialog() : BaseDialogFragment(R.layout.dialog_recycler_view
}
textInputLayout.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
editView.dropDownHeight = 180.dpToPx()
}
customView {
alertBinding.root

@ -394,7 +394,7 @@ class BookInfoActivity :
setText(R.string.delete_book_file)
}
val view = LinearLayout(this@BookInfoActivity).apply {
setPadding(16.dp, 0, 16.dp, 0)
setPadding(16.dpToPx(), 0, 16.dpToPx(), 0)
addView(checkBox)
}
customView { view }

@ -86,7 +86,7 @@ class ReadMenu @JvmOverloads constructor(
}
initAnimation()
val brightnessBackground = GradientDrawable()
brightnessBackground.cornerRadius = 5F.dp
brightnessBackground.cornerRadius = 5F.dpToPx()
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
llBrightness.background = brightnessBackground
llBottomBg.setBackgroundColor(bgColor)

@ -18,7 +18,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.read.page.provider.ChapterProvider
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getPrefBoolean
import io.legado.app.utils.postEvent
import io.legado.app.utils.setEdgeEffectColor
@ -36,7 +36,7 @@ class MoreConfigDialog : DialogFragment() {
attr.dimAmount = 0.0f
attr.gravity = Gravity.BOTTOM
attributes = attr
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dp)
setLayout(ViewGroup.LayoutParams.MATCH_PARENT, 360.dpToPx())
}
}

@ -80,7 +80,7 @@ class ReadStyleDialog : BaseDialogFragment(R.layout.dialog_read_book_style),
rvStyle.adapter = styleAdapter
styleAdapter.addFooterView {
ItemReadStyleBinding.inflate(layoutInflater, it, false).apply {
ivStyle.setPadding(6.dp, 6.dp, 6.dp, 6.dp)
ivStyle.setPadding(6.dpToPx(), 6.dpToPx(), 6.dpToPx(), 6.dpToPx())
ivStyle.setText(null)
ivStyle.setColorFilter(textColor)
ivStyle.borderColor = textColor

@ -73,16 +73,16 @@ class PageView(context: Context) : FrameLayout(context) {
tvFooterRight.setColor(tipColor)
upStatusBar()
llHeader.setPadding(
it.headerPaddingLeft.dp,
it.headerPaddingTop.dp,
it.headerPaddingRight.dp,
it.headerPaddingBottom.dp
it.headerPaddingLeft.dpToPx(),
it.headerPaddingTop.dpToPx(),
it.headerPaddingRight.dpToPx(),
it.headerPaddingBottom.dpToPx()
)
llFooter.setPadding(
it.footerPaddingLeft.dp,
it.footerPaddingTop.dp,
it.footerPaddingRight.dp,
it.footerPaddingBottom.dp
it.footerPaddingLeft.dpToPx(),
it.footerPaddingTop.dpToPx(),
it.footerPaddingRight.dpToPx(),
it.footerPaddingBottom.dpToPx()
)
vwTopDivider.visible(it.showHeaderLine)
vwBottomDivider.visible(it.showFooterLine)

@ -181,7 +181,7 @@ object ChapterProvider {
}
}
}
textPages.last().height = durY + 20.dp
textPages.last().height = durY + 20.dpToPx()
textPages.last().text = stringBuilder.toString()
textPages.forEachIndexed { index, item ->
item.index = index
@ -537,8 +537,8 @@ object ChapterProvider {
//间距
lineSpacingExtra = ReadBookConfig.lineSpacingExtra / 10f
paragraphSpacing = ReadBookConfig.paragraphSpacing
titleTopSpacing = ReadBookConfig.titleTopSpacing.dp
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dp
titleTopSpacing = ReadBookConfig.titleTopSpacing.dpToPx()
titleBottomSpacing = ReadBookConfig.titleBottomSpacing.dpToPx()
upLayout()
}
@ -593,14 +593,14 @@ object ChapterProvider {
tPaint.color = ReadBookConfig.textColor
tPaint.letterSpacing = ReadBookConfig.letterSpacing
tPaint.typeface = titleFont
tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.sp.toFloat()
tPaint.textSize = with(ReadBookConfig) { textSize + titleSize }.toFloat().spToPx()
tPaint.isAntiAlias = true
//正文
val cPaint = TextPaint()
cPaint.color = ReadBookConfig.textColor
cPaint.letterSpacing = ReadBookConfig.letterSpacing
cPaint.typeface = textFont
cPaint.textSize = ReadBookConfig.textSize.sp.toFloat()
cPaint.textSize = ReadBookConfig.textSize.toFloat().spToPx()
cPaint.isAntiAlias = true
return Pair(tPaint, cPaint)
}
@ -625,10 +625,10 @@ object ChapterProvider {
&& ReadBook.pageAnim() != 3
&& AppConfig.doublePageHorizontal
if (viewWidth > 0 && viewHeight > 0) {
paddingLeft = ReadBookConfig.paddingLeft.dp
paddingTop = ReadBookConfig.paddingTop.dp
paddingRight = ReadBookConfig.paddingRight.dp
paddingBottom = ReadBookConfig.paddingBottom.dp
paddingLeft = ReadBookConfig.paddingLeft.dpToPx()
paddingTop = ReadBookConfig.paddingTop.dpToPx()
paddingRight = ReadBookConfig.paddingRight.dpToPx()
paddingBottom = ReadBookConfig.paddingBottom.dpToPx()
visibleWidth = if (doublePage) {
viewWidth / 2 - paddingLeft - paddingRight
} else {

@ -389,7 +389,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
editView.dropDownHeight = 180.dpToPx()
}
customView { alertBinding.root }
okButton {
@ -409,7 +409,7 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setHint(R.string.group_name)
editView.setFilterValues(groups.toList())
editView.dropDownHeight = 180.dp
editView.dropDownHeight = 180.dpToPx()
}
customView { alertBinding.root }
okButton {

@ -63,7 +63,7 @@ class SourceLoginDialog : BaseDialogFragment(R.layout.dialog_login) {
binding.flexbox.addView(it.root)
it.root.id = index
it.textView.text = rowUi.name
it.textView.setPadding(16.dp)
it.textView.setPadding(16.dpToPx())
it.root.onClick {
if (rowUi.action.isAbsUrl()) {
context?.openUrl(rowUi.action!!)

@ -42,9 +42,9 @@ class ExploreAdapter(context: Context, val callBack: CallBack) :
) {
binding.run {
if (holder.layoutPosition == itemCount - 1) {
root.setPadding(16.dp, 12.dp, 16.dp, 12.dp)
root.setPadding(16.dpToPx(), 12.dpToPx(), 16.dpToPx(), 12.dpToPx())
} else {
root.setPadding(16.dp, 12.dp, 16.dp, 0)
root.setPadding(16.dpToPx(), 12.dpToPx(), 16.dpToPx(), 0)
}
if (payloads.isEmpty()) {
tvName.text = item.bookSourceName

@ -10,7 +10,7 @@ import android.text.StaticLayout
import android.util.AttributeSet
import androidx.annotation.ColorInt
import androidx.appcompat.widget.AppCompatTextView
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
class BatteryView @JvmOverloads constructor(
context: Context,
@ -33,8 +33,8 @@ class BatteryView @JvmOverloads constructor(
private var battery: Int = 0
init {
setPadding(4.dp, 3.dp, 6.dp, 3.dp)
batteryPaint.strokeWidth = 1.dp.toFloat()
setPadding(4.dpToPx(), 3.dpToPx(), 6.dpToPx(), 3.dpToPx())
batteryPaint.strokeWidth = 1f.dpToPx()
batteryPaint.isAntiAlias = true
batteryPaint.color = paint.color
}
@ -67,20 +67,20 @@ class BatteryView @JvmOverloads constructor(
layout.getLineBounds(0, outFrame)
val batteryStart = layout
.getPrimaryHorizontal(text.length - battery.toString().length)
.toInt() + 2.dp
val batteryEnd =
batteryStart + StaticLayout.getDesiredWidth(battery.toString(), paint).toInt() + 4.dp
.toInt() + 2.dpToPx()
val batteryEnd = batteryStart +
StaticLayout.getDesiredWidth(battery.toString(), paint).toInt() + 4.dpToPx()
outFrame.set(
batteryStart,
2.dp,
2.dpToPx(),
batteryEnd,
height - 2.dp
height - 2.dpToPx()
)
val dj = (outFrame.bottom - outFrame.top) / 3
polar.set(
batteryEnd,
outFrame.top + dj,
batteryEnd + 2.dp,
batteryEnd + 2.dpToPx(),
outFrame.bottom - dj
)
batteryPaint.style = Paint.Style.STROKE

@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.widget.LinearLayout
import android.widget.TextView
import io.legado.app.ui.widget.text.AccentBgTextView
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
@Suppress("unused", "MemberVisibilityCanBePrivate")
class LabelsBar @JvmOverloads constructor(
@ -40,10 +40,10 @@ class LabelsBar @JvmOverloads constructor(
fun addLabel(label: String) {
val tv = if (unUsedViews.isEmpty()) {
AccentBgTextView(context, null).apply {
setPadding(3.dp, 0, 3.dp, 0)
setPadding(3.dpToPx(), 0, 3.dpToPx(), 0)
setRadius(2)
val lp = LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)
lp.setMargins(0, 0, 2.dp, 0)
lp.setMargins(0, 0, 2.dpToPx(), 0)
layoutParams = lp
text = label
maxLines = 1

@ -11,7 +11,7 @@ import android.util.AttributeSet
import android.view.View
import io.legado.app.R
import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
/**
* RotateLoading
@ -60,8 +60,8 @@ class RotateLoading @JvmOverloads constructor(
init {
loadingColor = context.accentColor
thisWidth = DEFAULT_WIDTH.dp
shadowPosition = DEFAULT_SHADOW_POSITION.dp
thisWidth = DEFAULT_WIDTH.dpToPx()
shadowPosition = DEFAULT_SHADOW_POSITION.dpToPx()
speedOfDegree = DEFAULT_SPEED_OF_DEGREE
if (null != attrs) {
@ -70,7 +70,7 @@ class RotateLoading @JvmOverloads constructor(
typedArray.getColor(R.styleable.RotateLoading_loading_color, loadingColor)
thisWidth = typedArray.getDimensionPixelSize(
R.styleable.RotateLoading_loading_width,
DEFAULT_WIDTH.dp
DEFAULT_WIDTH.dpToPx()
)
shadowPosition = typedArray.getInt(
R.styleable.RotateLoading_shadow_position,

@ -9,7 +9,7 @@ import android.view.animation.LinearInterpolator
import android.widget.Checkable
import io.legado.app.R
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor
import kotlin.math.min
import kotlin.math.pow
@ -127,7 +127,7 @@ class SmoothCheckBox @JvmOverloads constructor(
}
private fun measureSize(measureSpec: Int): Int {
val defSize: Int = DEF_DRAW_SIZE.dp
val defSize: Int = DEF_DRAW_SIZE.dpToPx()
val specSize = MeasureSpec.getSize(measureSpec)
val specMode = MeasureSpec.getMode(measureSpec)
var result = 0

@ -21,8 +21,7 @@ import androidx.appcompat.widget.AppCompatImageView
import io.legado.app.R
import io.legado.app.utils.getCompatColor
import io.legado.app.utils.printOnDebug
import io.legado.app.utils.sp
import io.legado.app.utils.spToPx
import kotlin.math.min
import kotlin.math.pow
@ -202,7 +201,7 @@ class CircleImageView @JvmOverloads constructor(
text?.let {
textPaint.color = textColor
textPaint.isFakeBoldText = textBold
textPaint.textSize = 15.sp.toFloat()
textPaint.textSize = 15f.spToPx()
val fm = textPaint.fontMetrics
canvas.drawText(
it,

@ -7,7 +7,7 @@ import android.graphics.Path
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import io.legado.app.R
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import kotlin.math.max
class FilletImageView @JvmOverloads constructor(
@ -24,7 +24,7 @@ class FilletImageView @JvmOverloads constructor(
init {
// 读取配置
val array = context.obtainStyledAttributes(attrs, R.styleable.FilletImageView)
val defaultRadius = 5.dp
val defaultRadius = 5.dpToPx()
val radius =
array.getDimensionPixelOffset(R.styleable.FilletImageView_radius, defaultRadius)
leftTopRadius = array.getDimensionPixelOffset(

@ -24,7 +24,7 @@ import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.recycler.ItemTouchCallback
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.applyTint
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.setLayout
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
@ -120,7 +120,7 @@ class KeyboardAssistsConfig : BaseDialogFragment(R.layout.dialog_recycler_view),
override fun getViewBinding(parent: ViewGroup): Item1lineTextAndDelBinding {
return Item1lineTextAndDelBinding.inflate(inflater, parent, false).apply {
root.setPadding(16.dp)
root.setPadding(16.dpToPx())
ivDelete.visible()
}
}

@ -8,7 +8,7 @@ import io.legado.app.R
import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor
class AccentBgTextView @JvmOverloads constructor(
@ -27,7 +27,7 @@ class AccentBgTextView @JvmOverloads constructor(
}
fun setRadius(radius: Int) {
this.radius = radius.dp
this.radius = radius.dpToPx()
upBackground()
}

@ -8,13 +8,13 @@ import io.legado.app.lib.theme.Selector
import io.legado.app.lib.theme.ThemeStore
import io.legado.app.lib.theme.bottomBackground
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor
class AccentStrokeTextView(context: Context, attrs: AttributeSet) :
AppCompatTextView(context, attrs) {
private var radius = 3.dp
private var radius = 3.dpToPx()
private val isBottomBackground: Boolean
init {
@ -39,7 +39,7 @@ class AccentStrokeTextView(context: Context, attrs: AttributeSet) :
}
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setStrokeWidth(1.dpToPx())
.setDisabledStrokeColor(disableColor)
.setDefaultStrokeColor(ThemeStore.accentColor(context))
.setPressedBgColor(context.getCompatColor(R.color.transparent30))

@ -6,14 +6,14 @@ import androidx.appcompat.widget.AppCompatTextView
import io.legado.app.R
import io.legado.app.lib.theme.*
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.dp
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatColor
@Suppress("unused")
open class StrokeTextView(context: Context, attrs: AttributeSet?) :
AppCompatTextView(context, attrs) {
private var radius = 1.dp
private var radius = 1.dpToPx()
private val isBottomBackground: Boolean
init {
@ -26,7 +26,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
}
fun setRadius(radius: Int) {
this.radius = radius.dp
this.radius = radius.dpToPx()
upBackground()
}
@ -35,7 +35,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
isInEditMode -> {
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setStrokeWidth(1.dpToPx())
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDefaultStrokeColor(context.getCompatColor(R.color.secondaryText))
.setSelectedStrokeColor(context.getCompatColor(R.color.accent))
@ -53,7 +53,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
val isLight = ColorUtils.isColorLight(context.bottomBackground)
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setStrokeWidth(1.dpToPx())
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDefaultStrokeColor(context.getPrimaryTextColor(isLight))
.setSelectedStrokeColor(context.accentColor)
@ -70,7 +70,7 @@ open class StrokeTextView(context: Context, attrs: AttributeSet?) :
else -> {
background = Selector.shapeBuild()
.setCornerRadius(radius)
.setStrokeWidth(1.dp)
.setStrokeWidth(1.dpToPx())
.setDisabledStrokeColor(context.getCompatColor(R.color.md_grey_500))
.setDefaultStrokeColor(ThemeStore.textColorSecondary(context))
.setSelectedStrokeColor(ThemeStore.accentColor(context))

@ -114,22 +114,17 @@ object ConvertUtils {
}
val Int.dp: Int
get() = this.toFloat().dp.toInt()
val Int.sp: Int
get() = this.toFloat().sp.toInt()
val Int.hexString: String
get() = Integer.toHexString(this)
fun Int.dpToPx(): Int = this.toFloat().dpToPx().toInt()
fun Int.spToPx(): Int = this.toFloat().spToPx().toInt()
val Float.dp: Float
get() = android.util.TypedValue.applyDimension(
android.util.TypedValue.COMPLEX_UNIT_DIP, this, Resources.getSystem().displayMetrics
)
fun Float.dpToPx(): Float = android.util.TypedValue.applyDimension(
android.util.TypedValue.COMPLEX_UNIT_DIP, this, Resources.getSystem().displayMetrics
)
val Float.sp: Float
get() = android.util.TypedValue.applyDimension(
android.util.TypedValue.COMPLEX_UNIT_SP, this, Resources.getSystem().displayMetrics
)
fun Float.spToPx(): Float = android.util.TypedValue.applyDimension(
android.util.TypedValue.COMPLEX_UNIT_SP, this, Resources.getSystem().displayMetrics
)
Loading…
Cancel
Save