srctree

Roee Hershberg parent d9f24242 09a7d0b4
Change dpToPx to work with Float numbers

Change dpToPx to work with Float numbers instead of Int. Change allsubsequent calls to that method to pass Float numbers instead of Int.

inlinesplit
atox/src/main/kotlin/ui/AvatarFactory.kt added: 10, removed: 10, total 0
@@ -26,7 +26,7 @@ data class Px(val px: Int) : Size {
override fun asPx(res: Resources) = this
}
 
data class Dp(val dp: Int) : Size {
data class Dp(val dp: Float) : Size {
override fun asPx(res: Resources): Px = Px(dpToPx(dp, res))
}
 
@@ -34,7 +34,7 @@ data class Dp(val dp: Int) : Size {
internal class AvatarFactory(contact: Contact) {
 
companion object {
const val DEFAULT_AVATAR_SIZE_DP = 50
const val DEFAULT_AVATAR_SIZE_DP = 50f
}
 
private val name: String = contact.name
 
atox/src/main/kotlin/ui/Util.kt added: 10, removed: 10, total 0
@@ -24,5 +24,5 @@ internal fun colorFromStatus(context: Context, status: UserStatus) = when (statu
UserStatus.Busy -> ContextCompat.getColor(context, R.color.statusBusy)
}
 
internal fun dpToPx(dp: Int, res: Resources): Int =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), res.displayMetrics).toInt()
internal fun dpToPx(dp: Float, res: Resources): Int =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, res.displayMetrics).toInt()
 
atox/src/main/kotlin/ui/call/CallFragment.kt added: 10, removed: 10, total 0
@@ -29,7 +29,7 @@ import ltd.evilcorp.domain.tox.PublicKey
 
private const val PERMISSION = Manifest.permission.RECORD_AUDIO
 
private const val CALL_BACKGROUND_SIZE_DP = 500
private const val CALL_BACKGROUND_SIZE_DP = 500f
 
class CallFragment : BaseFragment<FragmentCallBinding>(FragmentCallBinding::inflate) {
private val vm: CallViewModel by viewModels { vmFactory }
 
atox/src/main/kotlin/ui/user_profile/UserProfileFragment.kt added: 10, removed: 10, total 0
@@ -41,7 +41,7 @@ private const val TOX_MAX_NAME_LENGTH = 128
private const val TOX_MAX_STATUS_MESSAGE_LENGTH = 1007
 
private const val QR_CODE_TO_SCREEN_RATIO = 0.5f
private const val QR_CODE_DIALOG_PADDING = 16 // in dp
private const val QR_CODE_DIALOG_PADDING = 16f // in dp
 
class UserProfileFragment : BaseFragment<FragmentUserProfileBinding>(FragmentUserProfileBinding::inflate) {
private val vm: UserProfileViewModel by viewModels { vmFactory }