properly handle pressing Plus after a decimal

This commit is contained in:
tibbi 2020-11-07 09:20:42 +01:00
parent a6c1847701
commit 04a191c66b

View File

@ -49,6 +49,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
} }
} }
lastKey = DECIMAL
showNewResult(inputDisplayedFormula) showNewResult(inputDisplayedFormula)
} }
@ -61,7 +62,8 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
inputDisplayedFormula = "" inputDisplayedFormula = ""
} }
if (operations.contains(inputDisplayedFormula.last().toString())) { val lastChar = inputDisplayedFormula.last().toString()
if (operations.contains(lastChar) || lastChar == ".") {
inputDisplayedFormula = inputDisplayedFormula.dropLast(1) inputDisplayedFormula = inputDisplayedFormula.dropLast(1)
inputDisplayedFormula += getSign(operation) inputDisplayedFormula += getSign(operation)
} else if (!inputDisplayedFormula.trimStart('-').contains(operationsRegex.toRegex())) { } else if (!inputDisplayedFormula.trimStart('-').contains(operationsRegex.toRegex())) {