Added magnetic flux conversion

This commit is contained in:
Sad Ellie 2022-12-30 20:50:06 +04:00
parent 7105ee90b6
commit d41f9a7d13
7 changed files with 71 additions and 3 deletions

View File

@ -128,6 +128,9 @@ android {
renderScript = false
shaders = false
}
lint {
this.warning.add("MissingTranslation")
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.0-alpha02"
}

View File

@ -61,7 +61,8 @@ class AllUnitsRepository @Inject constructor() {
UnitGroup.ENERGY to energyCollection,
UnitGroup.POWER to powerCollection,
UnitGroup.ANGLE to angleCollection,
UnitGroup.DATA_TRANSFER to dataTransferCollection
UnitGroup.DATA_TRANSFER to dataTransferCollection,
UnitGroup.FLUX to fluxCollection,
)
}
@ -750,4 +751,15 @@ class AllUnitsRepository @Inject constructor() {
MyUnit(MyUnitIDS.exabyte_per_second, BigDecimal.valueOf(8_000_000_000_000_000_000), UnitGroup.DATA_TRANSFER, R.string.exabyte_per_second, R.string.exabyte_per_second_short),
)
}
private val fluxCollection: List<AbstractUnit> by lazy {
listOf(
MyUnit(MyUnitIDS.maxwell, BigDecimal.valueOf(1), UnitGroup.FLUX, R.string.maxwell, R.string.maxwell_short),
MyUnit(MyUnitIDS.microweber, BigDecimal.valueOf(100), UnitGroup.FLUX, R.string.microweber, R.string.microweber_short),
MyUnit(MyUnitIDS.milliweber, BigDecimal.valueOf(100000), UnitGroup.FLUX, R.string.milliweber, R.string.milliweber_short),
MyUnit(MyUnitIDS.weber, BigDecimal.valueOf(100000000), UnitGroup.FLUX, R.string.weber, R.string.weber_short),
MyUnit(MyUnitIDS.kiloweber, BigDecimal.valueOf(100000000000), UnitGroup.FLUX, R.string.kiloweber, R.string.kiloweber_short),
MyUnit(MyUnitIDS.megaweber, BigDecimal.valueOf(100000000000000), UnitGroup.FLUX, R.string.megaweber, R.string.megaweber_short),
MyUnit(MyUnitIDS.gigaweber, BigDecimal.valueOf(100000000000000000), UnitGroup.FLUX, R.string.gigaweber, R.string.gigaweber_short),
)
}
}

View File

@ -78,7 +78,7 @@ object MyUnitIDS {
const val kelvin = "kelvin"
// SPEED
const val millimeter_per_hour = "millimeter_per_hour" // BASIC UNIT
const val millimeter_per_hour = "millimeter_per_hour"
const val millimeter_per_minute = "millimeter_per_minute"
const val millimeter_per_second = "millimeter_per_second"
const val centimeter_per_hour = "centimeter_per_hour"
@ -485,4 +485,13 @@ object MyUnitIDS {
const val currency_zmk = "zmk"
const val currency_zmw = "zmw"
const val currency_zwl = "zwl"
// FLUX
const val maxwell = "maxwell"
const val weber = "weber"
const val milliweber = "milliweber"
const val microweber = "microweber"
const val kiloweber = "kiloweber"
const val megaweber = "megaweber"
const val gigaweber = "gigaweber"
}

View File

@ -47,5 +47,6 @@ enum class UnitGroup(
ENERGY(res = R.string.energy),
POWER(res = R.string.power),
ANGLE(res = R.string.angle),
DATA_TRANSFER(res = R.string.data_transfer)
DATA_TRANSFER(res = R.string.data_transfer),
FLUX(res = R.string.flux),
}

View File

@ -686,5 +686,20 @@
<string name="about_unitto">О Unitto</string>
<string name="about_unitto_support">Узнайте больше о приложении</string>
<string name="unit_groups_support">Отключите или отсортируйте единицы измерений</string>
<string name="maxwell">Максвелл</string>
<string name="maxwell_short">Мкс</string>
<string name="weber">Вебер</string>
<string name="weber_short">Вб</string>
<string name="milliweber">Милливебер</string>
<string name="milliweber_short">мВб</string>
<string name="microweber">Микровебер</string>
<string name="microweber_short">мкВб</string>
<string name="kiloweber">Киловебер</string>
<string name="kiloweber_short">кВб</string>
<string name="megaweber">Мегавебер</string>
<string name="megaweber_short">МВб</string>
<string name="gigaweber">Гигавебер</string>
<string name="gigaweber_short">ГВб</string>
<string name="flux">Поток</string>
</resources>

View File

@ -913,6 +913,22 @@
<string name="currency_zwl">Zimbabwean Dollar</string>
<string name="currency_zwl_short" translatable="false">ZWL</string>
<!--Flux-->
<string name="maxwell">Maxwell</string>
<string name="maxwell_short">Mx</string>
<string name="weber">Weber</string>
<string name="weber_short">Wb</string>
<string name="milliweber">Milliweber</string>
<string name="milliweber_short">mWb</string>
<string name="microweber">Microweber</string>
<string name="microweber_short">μWb</string>
<string name="kiloweber">Kiloweber</string>
<string name="kiloweber_short">kWb</string>
<string name="megaweber">Megaweber</string>
<string name="megaweber_short">MWb</string>
<string name="gigaweber">Gigaweber</string>
<string name="gigaweber_short">GWb</string>
<!--Groups-->
<string name="length">Length</string>
<string name="time">Time</string>
@ -929,6 +945,7 @@
<string name="pressure">Pressure</string>
<string name="acceleration">Acceleration</string>
<string name="currency">Currency</string>
<string name="flux">Flux</string>
<!--Screen names-->
<string name="units_screen_from">Convert from</string>

View File

@ -339,6 +339,17 @@ class AllUnitsTest {
MyUnitIDS.cubic_kilometer.checkWith(MyUnitIDS.us_liquid_gallon, "0.0000001507", "39810.72829")
}
@Test
fun testFlux() {
MyUnitIDS.maxwell.checkWith(MyUnitIDS.milliweber, "68.2", "0.00068")
MyUnitIDS.weber.checkWith(MyUnitIDS.milliweber, "68.2", "68200")
MyUnitIDS.milliweber.checkWith(MyUnitIDS.weber, "68.2", "0.0682")
MyUnitIDS.microweber.checkWith(MyUnitIDS.milliweber, "68.2", "0.0682")
MyUnitIDS.kiloweber.checkWith(MyUnitIDS.weber, "68.2", "68200")
MyUnitIDS.megaweber.checkWith(MyUnitIDS.weber, "68.2", "68200000")
MyUnitIDS.gigaweber.checkWith(MyUnitIDS.weber, "68.2", "68200000000")
}
private fun String.checkWith(checkingId: String, value: String, expected: String) {
val unit = allUnitsRepository.getById(this)
val actual = unit