Changelog¶
All notable changes to this project will be documented in this document.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased¶
Changed¶
- Upgrade to Kotlin
1.6.10. - Upgrade to Startup
1.1.0.
2.0.2 - 2021-06-27¶
Changed¶
- Upgrade to Kotlin
1.5.20.
2.0.1 - 2021-05-04¶
Changed¶
- Upgrade to Kotlin
1.5.0.
2.0.0 - 2020-12-31¶
Added¶
Distance.format()andLength.format()that do not require specifyingandroid.content.Context. This a part of a large overhaul of this library. SeeChangedsection for more information.Distance.Epsilonconstant that represents smallest possible change in ofDistance.LengthUnits.boundsproperty to the public API. It holds min and max distances that only that unit can represent as a natural count of self.Length.withFittingUnit(units, fitter)that selects the best unit for a length using supplied units and fitting algorithm. A complementaryUnitFitterinterface is added along withInRangeUnitFitterandLogDistanceUnitFitterimplementations.- New SI units – centimeters, decimeters, decameters and hectometers.
Length.roundDown()to get a length with whole unit count rounded towards 0.Measureclass to model a distance normalized to a unit.io.mehow.ruler:android-ruler-startupartifact to initialize Ruler automatically with Android formatting rules.
Changed¶
- Complete redesign of the formatting part of this library. Formatting is now a part of the JVM
io.mehow.ruler:rulerartifacts. It allows to plug different formatting contexts such as the one from Android.io.mehow.ruler:ruler-androidartifact is now much smaller and provides only default implementations that can be enabled at runtime. As a part of this redesign most of formatting classes are moved toio.mehow.ruler.formatpackage. For more details check the API documentation. - Added one nanometer to
Distance.Min. This change was made in order to makeDistance.abs()operation safe. - Distance and length formatting use better mechanisms. Instead of custom parsing it relies on
java.textorandroid.icupackages. Length.measureis now ofMeasuretype.ImperialLengthFormatterrounds smallest unit part instead of dropping the fraction.
Removed¶
- Duplicated Android resources. Formatting relies now on a single pattern and translated units.
- Android resource for formatting negative imperial lengths. It is now handled automatically by generic formatting mechanism.
Ruler.removeConverter()in favour ofLength.removeConverterFactory().Length.withAutoUnit()in favour ofLength.withFittingUnit()with default arguments.FlooredLengthFormatterand floored formatting mechanism. Formatting with a custom fractional precision should be used instead.
Fixed¶
LengthUnitreturning false-negative when negative distance was checked if it is contained in a unit.
1.0.0 - 2020-12-28¶
Added¶
AutoLengthFormatterclass. Use it to format lengths using resources defined in the library based on a unit.FlooredLengthFormatterclass. Use it to floor a length unit quantities and format them using resources defined in the library.AutoFitLengthConverterclass. Use it to convert lengths to different lengths a best fitting units based onLength.withAutoUnit()and unit coercion.LengthFormatter.Factoryinterface. Use it to install custom formatters inRuler.LengthConverter.Factoryinterface. Use it to install custom converters inRuler.Distance.abs()andLength.abs()methods.Rulerimplements nowLengthConverterandLengthFormatter.
Changed¶
DistanceandLengththrow nowArithmeticExceptionin case of failures due to overflows or math operations.Distance.exactTotalMetersproperty name tometers.LengthUnitis no longer an interface. It is now a sealed class with two implementations –SiLengthUnitandImperialLengthUnit.LengthUnitis no longerIterable. It exposes nowunitsproperty.- Custom
LengthFormatters must be now installed usingLengthFormatter.Factoryinterface andRuler.addFormatterFactory()method. LengthFormatterto a functional interface.LengthFormattercan no longer returnnull.Lengthno longer changes units automatically based onLocaleduring formatting.- Order of arguments in
LengthFormatter.format()method. ImperialLengthFormattersubstitutesImperialDistanceFormatter. It offers a more unified API without bloated configurability.- Custom
LengthConverters must be now installed usingLengthConverter.Factoryinterface andRuler.addConverterFactory()method. LengthConverterto a functional interface.LengthConvertercan no longer returnnull.- Upgrade to Kotlin
1.4.21.
Removed¶
- Explicit Java support with
@Jvm*annotations. Distance.metersPartandDistance.nanosPartproperties.Distance.create(meters, nanometers)method.Distance.format()andDistance.formatFloored()overloads that acceptLengthUnit.Ruler.flooredFormattersproperty. Flooring is now available solely viaFlooredLengthFormatter.
Fixed¶
- Wrong lower meter bound of
Milesunit. - Wrong name of an argument in
Length.div()methods. - Imperial formatting not handling negative distances.
0.6.0 - 2020-11-11¶
Added¶
meterRatioproperty toLengthUnitinterface.containsfunction toLengthUnitinterface. This allows to useinsugar syntax.
Changed¶
io.mehow.ruler:androidtoio.mehow.ruler:ruler-androidartifact.- Changelog format follows now Keep a Changelog format. Format is applied retroactively to this file.
Length.measureLengthproperty tomeasure.Distance.min,Distance.zeroandDistance.maxrespectively toDistance.Min,Distance.ZeroandDistance.Max. They are now available as fields from Java.ImperialDistanceFormatter.basicandImperialDistanceFormatter.fulltoImperialDistanceFormatter.BasicandImperialDistanceFormatter.Fullrespectively.- Upgrade to Kotlin
1.4.10.
Removed¶
toDistance()methods fromLengthUnitinterface.-Xjvm-default=enablecompiler argument is no longer required.toMeasuredLength()function fromLengthUnitinterface.appliesRangeTo()function fromLengthUnitinterface.
0.5.3 - 2020-06-14¶
Changed¶
- Upgrade to Kotlin
1.3.72.
Fixed¶
- Long to double conversion when computing distances.
0.5.2 - 2020-04-15¶
Added¶
- Arabic language support.
Fixed¶
- Fix a bug with no inches displayed for 0 length.
0.5.1 - 2020-03-01¶
Removed¶
- Remove
totalMetersproperty fromDistancethat approximates it.
Fixed¶
- Fix wrong unit displayed for feet.
0.5.0 - 2020-02-29¶
Added¶
- Support for floored formatting of any length units.
- Allow to set globally if UK should use imperial or SI units.
0.4.1 - 2020-02-07¶
Added¶
- Support for negative distances.
- Support for floored SI unit lengths formatting. It displays only whole parts of a unit.
0.4.0 - 2020-02-05¶
Added¶
Rulerclass as a central point for distance and length formatting.- Imperial unit formatter. It allows to display measurements in a imperial-friendly format. For example
105ft 12in.
0.3.2 2020-02-03¶
Fixed¶
- Fix issue with high precision Float and Double multiplication.
0.3.1 - 2020-02-03¶
Fixed¶
- Make library JDK 7 compatible.
0.3.0 - 2020-02-03¶
Added¶
- Add
Distance(oldLength) formatter for Android. - Add basic math operators like multiplication and division.
- Add Double factories to
Distance(oldLength).
Changed¶
- Swap names of
DistanceandLengthclasses. - Use Long as an underlying
Distanceprimitive. It is more suitable for application that have UI interaction and distance of ~975 light years seems sufficient for most day-to-day applications.
0.2.0 - 2020-02-03¶
Changed¶
DistanceUnitCoercerchanged toDistanceConverter.Distanceconstructor is no longer public.lengthinDistanceis no longer public.metersandnanometersproperties renamed respectively tometersPartandnanometersPartsinLengthclass.
0.1.0 - 2020-02-02¶
- Initial release.