diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt index 2d31451e..89d22a77 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt @@ -34,6 +34,7 @@ class MainActivity : SimpleActivity(), Calculator { //============================================================ private var savedRes: String = "999" + private var savedPreviousCalculation = "" //============================================================ @@ -51,10 +52,10 @@ class MainActivity : SimpleActivity(), Calculator { if(savedInstanceState != null) { Log.v("MainActivity", "LOG TEST"); savedRes = savedInstanceState?.getCharSequence("res", "123") as String - + savedPreviousCalculation = savedInstanceState?.getCharSequence("savedPreviousCalculation", "") as String } Log.v("MainActivity", "LOG NO IF TEST"); - calc = CalculatorImpl(this, applicationContext, savedRes) + calc = CalculatorImpl(this, applicationContext, savedRes, savedPreviousCalculation) //============================================================ @@ -264,6 +265,7 @@ class MainActivity : SimpleActivity(), Calculator { override fun onSaveInstanceState(bundle: Bundle) { super.onSaveInstanceState(bundle) bundle.putString("res", calc.mResult) + bundle.putString("savedPreviousCalculation", calc.previousCalculation) } //============================================================ diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt index 7ff024ac..9725139e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -13,6 +13,7 @@ class CalculatorImpl( private val context: Context, //============================================================ var res: String, + savedLastOperation: String, //============================================================ private var decimalSeparator: String = DOT, private var groupingSeparator: String = COMMA @@ -22,6 +23,7 @@ class CalculatorImpl( //============================================================ // Trying Fix it public var mResult = res + public var previousCalculation = savedLastOperation //============================================================ private var baseValue = 0.0 @@ -41,6 +43,7 @@ class CalculatorImpl( //============================================================ //showNewResult("0") showNewResult(mResult) + showNewFormula(previousCalculation) //============================================================ } @@ -295,6 +298,10 @@ class CalculatorImpl( ) showNewFormula(newFormula) + //============================================================ + previousCalculation = newFormula + //============================================================ + inputDisplayedFormula = result.format() baseValue = result } catch (e: Exception) {