mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
fixing some decimal related glitches
This commit is contained in:
@@ -70,14 +70,16 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val lastChar = inputDisplayedFormula.last().toString()
|
val lastChar = inputDisplayedFormula.last().toString()
|
||||||
if (operations.contains(lastChar) || lastChar == ".") {
|
if (lastChar == ".") {
|
||||||
|
inputDisplayedFormula = inputDisplayedFormula.dropLast(1)
|
||||||
|
} else 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())) {
|
||||||
inputDisplayedFormula += getSign(operation)
|
inputDisplayedFormula += getSign(operation)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastKey == DIGIT) {
|
if (lastKey == DIGIT || lastKey == DECIMAL) {
|
||||||
if (lastOperation != "" && operation == PERCENT) {
|
if (lastOperation != "" && operation == PERCENT) {
|
||||||
handlePercent()
|
handlePercent()
|
||||||
} else {
|
} else {
|
||||||
@@ -109,7 +111,7 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
|
|||||||
calculateResult()
|
calculateResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastKey != DIGIT) {
|
if (lastKey != DIGIT && lastKey != DECIMAL) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user