From 93fb0125de7d04f9f6a6d164e3ebc4b9dbdb9738 Mon Sep 17 00:00:00 2001 From: Axel Labarre Date: Thu, 16 Feb 2023 10:50:23 +0100 Subject: [PATCH] Fix problem while adding operators with result after rotation --- .../calculator/activities/MainActivity.kt | 15 +++++---------- .../calculator/helpers/CalculatorImpl.kt | 7 ++++--- 2 files changed, 9 insertions(+), 13 deletions(-) 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 d65a00f7..bb858d93 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/activities/MainActivity.kt @@ -37,8 +37,9 @@ class MainActivity : SimpleActivity(), Calculator { private var savedPreviousCalculation = "" private var savedLastKey: String = "" private var savedLastOperation: String = "" - private var savedBaseValue : Double= 5.5 - private var savedSecondValue : Double = 7.5 + private var savedBaseValue : Double= 0.0 + private var savedSecondValue : Double = 0.0 + private var savedInputDisplayedFormula : String = "0" //============================================================ @@ -52,14 +53,6 @@ class MainActivity : SimpleActivity(), Calculator { refreshMenuItems() //============================================================ - //Log.v("SAVEDRES : ", savedRes) - //Log.v("SAVEDPREVIOUS : ", savedPreviousCalculation) - //Log.v("SAVEDLASTKEY : ", savedLastKey) - //Log.v("SAVEDLASTOP : ", savedLastOperation) - //Log.v("DECIMALSEP : ", decimalSeparator) - //Log.v("GROUPINGSEP : ", groupingSeparator) - //Log.v("BASEVALUE : ", savedBaseValue.toString()) - //Log.v("SECONDVALUE : ", savedSecondValue.toString()) if(savedInstanceState != null) { Log.v("MainActivity", "LOG TEST"); @@ -69,6 +62,7 @@ class MainActivity : SimpleActivity(), Calculator { savedLastOperation = savedInstanceState?.getCharSequence("savedLastOperation") as String savedBaseValue = savedInstanceState.getDouble("savedBaseValue") savedSecondValue = savedInstanceState.getDouble("savedSecondValue") + savedInputDisplayedFormula = savedInstanceState.getCharSequence("savedInputDisplayedFormula") as String } @@ -298,6 +292,7 @@ class MainActivity : SimpleActivity(), Calculator { bundle.putString("savedLastOperation", calc.lastOperation) bundle.putDouble("savedBaseValue", calc.baseValue) bundle.putDouble("savedSecondValue", calc.getSecondValue()) + bundle.putString("savedInputDisplayedFormula", calc.inputDisplayedFormula) } //============================================================ 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 976ccbb0..eaa703f0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/helpers/CalculatorImpl.kt @@ -12,7 +12,6 @@ import java.math.BigDecimal class CalculatorImpl( calculator: Calculator, private val context: Context, - private var decimalSeparator: String = DOT, private var groupingSeparator: String = COMMA, @@ -22,7 +21,8 @@ class CalculatorImpl( aLastKey: String = "", aLastOperation: String = "", aBaseValue: Double = 0.0, - aSecondValue: Double = 99.0 + aSecondValue: Double = 0.0, + aInputDisplayedFormula: String = "0" //============================================================ ) { @@ -36,11 +36,12 @@ class CalculatorImpl( public var lastOperation = aLastOperation public var baseValue = aBaseValue private var secondValue = aSecondValue + public var inputDisplayedFormula = aInputDisplayedFormula //============================================================ //private var baseValue = 0.0 //private var secondValue = 0.0 - private var inputDisplayedFormula = "0" + //private var inputDisplayedFormula = "0" //private var lastKey = "" //private var lastOperation = "" private val operations = listOf("+", "-", "×", "÷", "^", "%", "√")