Properly format calculation formula

This commit is contained in:
Naveen 2022-06-04 11:36:55 +05:30
parent 8668a5b680
commit 2af2a6175f

View file

@ -272,11 +272,14 @@ class CalculatorImpl(
}
showNewResult(result.format())
baseValue = result
val newFormula = expression.replace("sqrt", "").replace("*", "×").replace("/", "÷")
HistoryHelper(context).insertOrUpdateHistoryEntry(History(null, newFormula, result.format(), System.currentTimeMillis()))
inputDisplayedFormula = result.format()
val newFormula = "${baseValue.format()}$sign${secondValue.format()}"
HistoryHelper(context).insertOrUpdateHistoryEntry(
History(id = null, formula = newFormula, result = result.format(), timestamp = System.currentTimeMillis())
)
showNewFormula(newFormula)
inputDisplayedFormula = result.format()
baseValue = result
} catch (e: Exception) {
context.toast(R.string.unknown_error_occurred)
}