Skip to content

Commit

Permalink
Add additional convert units
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Oct 30, 2024
1 parent 82b6f62 commit dd92727
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ class FormatService private constructor(private val context: Context) {
)

DistanceUnits.Yards -> strings.getString(R.string.yards_format, formatted)
DistanceUnits.Millimeters -> strings.getString(
R.string.milliliter_format,
formatted
)
}
}

Expand Down Expand Up @@ -337,6 +341,13 @@ class FormatService private constructor(private val context: Context) {
)

VolumeUnits.ImperialGallons -> strings.getString(R.string.gallon_format, formatted)
VolumeUnits.USTeaspoons -> strings.getString(R.string.teaspooon_format, formatted)
VolumeUnits.USTablespoons -> strings.getString(R.string.tablespoon_format, formatted)
VolumeUnits.ImperialTeaspoons -> strings.getString(R.string.teaspooon_format, formatted)
VolumeUnits.ImperialTablespoons -> strings.getString(
R.string.tablespoon_format,
formatted
)
}
}

Expand Down Expand Up @@ -644,6 +655,10 @@ class FormatService private constructor(private val context: Context) {

DistanceUnits.Inches -> strings.getString(R.string.precise_inches_format, "")
DistanceUnits.Yards -> strings.getString(R.string.yards_format, "")
DistanceUnits.Millimeters -> strings.getString(
R.string.milliliter_format,
""
)
}.replace(" ", "")
}
return when (unit) {
Expand All @@ -655,6 +670,7 @@ class FormatService private constructor(private val context: Context) {
DistanceUnits.Centimeters -> strings.getString(R.string.unit_centimeters)
DistanceUnits.Inches -> strings.getString(R.string.unit_inches)
DistanceUnits.Yards -> strings.getString(R.string.unit_yards)
DistanceUnits.Millimeters -> strings.getString(R.string.unit_millimeters)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class FragmentDistanceConverter :
private val formatService by lazy { FormatService.getInstance(requireContext()) }

override val units = listOf(
DistanceUnits.Millimeters,
DistanceUnits.Centimeters,
DistanceUnits.Meters,
DistanceUnits.Kilometers,
Expand All @@ -33,6 +34,7 @@ class FragmentDistanceConverter :
DistanceUnits.Centimeters -> getString(R.string.unit_centimeters)
DistanceUnits.Inches -> getString(R.string.unit_inches)
DistanceUnits.Yards -> getString(R.string.unit_yards)
DistanceUnits.Millimeters -> getString(R.string.unit_millimeters)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@ class FragmentVolumeConverter : SimpleConvertFragment<VolumeUnits>(VolumeUnits.L

private val formatService by lazy { FormatService.getInstance(requireContext()) }

override val units = VolumeUnits.values().toList()
override val units = listOf(
VolumeUnits.Milliliter,
VolumeUnits.Liters,
VolumeUnits.USTeaspoons,
VolumeUnits.USTablespoons,
VolumeUnits.USOunces,
VolumeUnits.USCups,
VolumeUnits.USPints,
VolumeUnits.USQuarts,
VolumeUnits.USGallons,
VolumeUnits.ImperialTeaspoons,
VolumeUnits.ImperialTablespoons,
VolumeUnits.ImperialOunces,
VolumeUnits.ImperialCups,
VolumeUnits.ImperialPints,
VolumeUnits.ImperialQuarts,
VolumeUnits.ImperialGallons
)

override fun getUnitName(unit: VolumeUnits): String {
return when (unit) {
Expand All @@ -26,6 +43,10 @@ class FragmentVolumeConverter : SimpleConvertFragment<VolumeUnits>(VolumeUnits.L
VolumeUnits.ImperialQuarts -> getString(R.string.imperial_quarts)
VolumeUnits.ImperialOunces -> getString(R.string.imperial_ounces_volume)
VolumeUnits.ImperialGallons -> getString(R.string.imperial_gallons)
VolumeUnits.USTeaspoons -> getString(R.string.us_teaspoons)
VolumeUnits.USTablespoons -> getString(R.string.us_tablespoons)
VolumeUnits.ImperialTeaspoons -> getString(R.string.imperial_teaspoons)
VolumeUnits.ImperialTablespoons -> getString(R.string.imperial_tablespoons)
}
}

Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,7 @@
<string name="daylight">Daylight</string>
<string name="find_next_occurrence">Find next occurrence</string>
<string name="yards_format">%s yd</string>
<string name="millimeters_format">%s mm</string>
<string name="unit_yards">Yards</string>
<string name="base_elevation">Base elevation</string>
<string name="base_temperature">Base temperature</string>
Expand All @@ -778,6 +779,8 @@
<string name="quart_format">%s qt</string>
<string name="ounces_volume_format">%s oz</string>
<string name="gallon_format">%s gal</string>
<string name="teaspooon_format">%s tsp</string>
<string name="tablespoon_format">%s tbsp</string>
<string name="liters">Liters</string>
<string name="milliliters">Milliliters</string>
<string name="us_cups">US cups</string>
Expand Down Expand Up @@ -1479,4 +1482,9 @@
<!--Occurs when the data/photo/file is imported. Shown as a summary in settings.-->
<string name="on_import">On import</string>
<string name="reduce_pdf_resolution">Reduce PDF resolution</string>
<string name="us_teaspoons">US teaspoons</string>
<string name="us_tablespoons">US tablespoons</string>
<string name="unit_millimeters">Millimeters</string>
<string name="imperial_teaspoons">Imperial teaspoons</string>
<string name="imperial_tablespoons">Imperial tablespoons</string>
</resources>
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ material = "1.10.0"
luna = "0.3.5"
mockitoKotlin = "5.1.0"
roomVersion = "2.6.1"
sol = "9.9.2"
sol = "9.10.1"
subsamplingScaleImageView = "3.11.9"
workRuntimeKtx = "2.9.1"
preferenceKtx = "1.2.1"
Expand Down

0 comments on commit dd92727

Please sign in to comment.