Implement negative temperature conversion (#44)
What is it?
- [ ] Bugfix
- [x] Feature
- [ ] Codebase improvement
Description of the changes in your PR
- Added +/- button for temperature converter
- Implemented
toggleNegative()method inConverterViewto handle sign changes - Set conditional button visibility (only for temperature)
Before/After Screenshots/Screen Record
-
Before: No button for negative values
-
After: +/- button appears below numpad (only in temperature converter)
Fixes the following issue(s)
- Fixes #44 (Add +/- to Temperature Unit Converter)
Relies on the following changes
- Updated view_unit_converter.xml layout (new LinearLayout container with id
plus_minus_layout) - Updated UnitConverterActivity.kt button click handler and visibility logic for the +/-
- Updated ConverterView.kt with sign toggle method and
numpadClicked
Acknowledgement
- [x] I read the contribution guidelines.
I've tested and found two issues:
+/-button should also work when there's no value. Most people first enter-, then the rest of the number.- Deleting a negative number causes a crash.
There are also two issues that I'm not sure whether we should address them in this PR:
- There's no such thing as negative Kelvins and negative Rankines. It shouldn't be possible to enter a negative value for these units.
- By analogy, you shouldn't allow entering values for Celsius and Fahrenheit that are below absolute zero.
I fixed the crash issue (deleting negative value resets to 0) and added the possibility to use the - before entering a number.
Concerning the other remarks, I made sure to enforce temperature limits during input by automatically adjusting values that exceed absolute zero for each unit type: Celsius cannot go below -273.15, Fahrenheit below -459.67, and Kelvin/Rankine are blocked entirely from being negative (minimum 0)
Hello @Aga-C Just checking in to see if there's anything else needed on this PR. I haven't planned to make any changes unless needed so if everything looks good, a review would be much appreciated. Thanks
Hi! @Lionheart-Y2J
I'll do a final review and merge this soon.
Thanks.
The functionality itself seems to work. Left some comments and nitpicks regarding the code.