diff --git a/CHANGELOG.md b/CHANGELOG.md index 612f0dc9..f87b577c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Fixed issue that occurs after doing a percent operation ([#160]) + ## [1.2.0] - 2025-10-29 ### Changed - Compatibility updates for Android 15 & 16 @@ -60,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#31]: https://github.com/FossifyOrg/Calculator/issues/31 [#44]: https://github.com/FossifyOrg/Calculator/issues/44 [#64]: https://github.com/FossifyOrg/Calculator/issues/64 +[#160]: https://github.com/FossifyOrg/Calculator/issues/160 [Unreleased]: https://github.com/FossifyOrg/Calculator/compare/1.2.0...HEAD [1.2.0]: https://github.com/FossifyOrg/Calculator/compare/1.1.0...1.2.0 diff --git a/app/src/main/kotlin/org/fossify/math/helpers/CalculatorImpl.kt b/app/src/main/kotlin/org/fossify/math/helpers/CalculatorImpl.kt index af05ee3f..d422a89c 100644 --- a/app/src/main/kotlin/org/fossify/math/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/org/fossify/math/helpers/CalculatorImpl.kt @@ -114,6 +114,7 @@ class CalculatorImpl( if (lastKey == DIGIT || lastKey == DECIMAL) { if (lastOperation != "" && operation == PERCENT) { handlePercent() + lastOperation = "" } else { // split to multiple lines just to see when does the crash happen secondValue = when (operation) { @@ -140,7 +141,7 @@ class CalculatorImpl( if (getSecondValue() == BigDecimal.ZERO && inputDisplayedFormula.contains("รท")) { lastKey = DIVIDE lastOperation = DIVIDE - } else { + } else if(operation != PERCENT) { lastKey = operation lastOperation = operation } @@ -376,6 +377,7 @@ class CalculatorImpl( if (newValue == "" || newValue == "0") { newValue = "0" lastKey = CLEAR + resetValues() } else { if (operations.contains(lastDeletedValue) || lastKey == EQUALS) { lastOperation = ""