Merge branch 'dev-axel-saveInstanceState' into fix_data_lost_during_rotation
This commit is contained in:
commit
790302184a
|
@ -62,7 +62,6 @@ class MainActivity : SimpleActivity(), Calculator {
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Log.v("SAVEDRES : ", savedRes)
|
//Log.v("SAVEDRES : ", savedRes)
|
||||||
//Log.v("SAVEDPREVIOUS : ", savedPreviousCalculation)
|
//Log.v("SAVEDPREVIOUS : ", savedPreviousCalculation)
|
||||||
//Log.v("SAVEDLASTKEY : ", savedLastKey)
|
//Log.v("SAVEDLASTKEY : ", savedLastKey)
|
||||||
|
@ -73,8 +72,7 @@ class MainActivity : SimpleActivity(), Calculator {
|
||||||
//Log.v("SECONDVALUE : ", savedSecondValue.toString())
|
//Log.v("SECONDVALUE : ", savedSecondValue.toString())
|
||||||
|
|
||||||
|
|
||||||
|
if (savedInstanceState != null) {
|
||||||
if(savedInstanceState != null) {
|
|
||||||
Log.v("MainActivity", "LOG TEST");
|
Log.v("MainActivity", "LOG TEST");
|
||||||
//savedRes = savedInstanceState?.getCharSequence("res") as String
|
//savedRes = savedInstanceState?.getCharSequence("res") as String
|
||||||
//savedPreviousCalculation = savedInstanceState?.getCharSequence("savedPreviousCalculation") as String
|
//savedPreviousCalculation = savedInstanceState?.getCharSequence("savedPreviousCalculation") as String
|
||||||
|
@ -86,7 +84,7 @@ class MainActivity : SimpleActivity(), Calculator {
|
||||||
json = savedInstanceState.getCharSequence("myJsonObject") as String
|
json = savedInstanceState.getCharSequence("myJsonObject") as String
|
||||||
}
|
}
|
||||||
|
|
||||||
calc = CalculatorImpl(this, applicationContext,decimalSeparator, groupingSeparator, json)
|
calc = CalculatorImpl(this, applicationContext, decimalSeparator, groupingSeparator, json)
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
|
@ -292,7 +290,6 @@ class MainActivity : SimpleActivity(), Calculator {
|
||||||
|
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
// ****** ADD ONSAVEINSTANCESTATE FUNCTION ******
|
|
||||||
override fun onSaveInstanceState(bundle: Bundle) {
|
override fun onSaveInstanceState(bundle: Bundle) {
|
||||||
super.onSaveInstanceState(bundle)
|
super.onSaveInstanceState(bundle)
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -43,7 +43,7 @@ class CalculatorImpl(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
//============================================================
|
//============================================================
|
||||||
if(jsonObj != "") {
|
if (jsonObj != "") {
|
||||||
setFromSaveInstanceState(jsonObj)
|
setFromSaveInstanceState(jsonObj)
|
||||||
}
|
}
|
||||||
Log.v("BASEVALUE INIT :", baseValue.toString())
|
Log.v("BASEVALUE INIT :", baseValue.toString())
|
||||||
|
@ -359,14 +359,14 @@ class CalculatorImpl(
|
||||||
|
|
||||||
private fun showNewResult(value: String) {
|
private fun showNewResult(value: String) {
|
||||||
//============================================================
|
//============================================================
|
||||||
mResult = value;
|
mResult = value
|
||||||
//============================================================
|
//============================================================
|
||||||
callback!!.showNewResult(value, context)
|
callback!!.showNewResult(value, context)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showNewFormula(value: String) {
|
private fun showNewFormula(value: String) {
|
||||||
//============================================================
|
//============================================================
|
||||||
previousCalculation = value;
|
previousCalculation = value
|
||||||
Log.v("BASEVALUE SHOWNF :", baseValue.toString())
|
Log.v("BASEVALUE SHOWNF :", baseValue.toString())
|
||||||
Log.v("SECONDVALUE SHOWNF:", secondValue.toString())
|
Log.v("SECONDVALUE SHOWNF:", secondValue.toString())
|
||||||
//============================================================
|
//============================================================
|
||||||
|
@ -470,17 +470,16 @@ class CalculatorImpl(
|
||||||
|
|
||||||
private fun String.removeGroupSeparator() = formatter.removeGroupingSeparator(this)
|
private fun String.removeGroupSeparator() = formatter.removeGroupingSeparator(this)
|
||||||
|
|
||||||
public fun getSecondValueV2() : Double
|
fun getSecondValueV2(): Double {
|
||||||
{
|
|
||||||
return this.secondValue
|
return this.secondValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//JSON
|
//JSON
|
||||||
public fun getJson() : JSONObject {
|
fun getJson(): JSONObject {
|
||||||
|
|
||||||
val jsonObj = JSONObject()
|
val jsonObj = JSONObject()
|
||||||
jsonObj.put("res",mResult)
|
jsonObj.put("res", mResult)
|
||||||
jsonObj.put("previousCalculation", previousCalculation)
|
jsonObj.put("previousCalculation", previousCalculation)
|
||||||
jsonObj.put("lastKey", lastKey)
|
jsonObj.put("lastKey", lastKey)
|
||||||
jsonObj.put("lastOperation", lastOperation)
|
jsonObj.put("lastOperation", lastOperation)
|
||||||
|
@ -491,8 +490,7 @@ class CalculatorImpl(
|
||||||
return jsonObj
|
return jsonObj
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun setFromSaveInstanceState( json: String )
|
private fun setFromSaveInstanceState(json: String) {
|
||||||
{
|
|
||||||
val jsonObject = JSONTokener(json).nextValue() as JSONObject
|
val jsonObject = JSONTokener(json).nextValue() as JSONObject
|
||||||
mResult = jsonObject.getString("res")
|
mResult = jsonObject.getString("res")
|
||||||
previousCalculation = jsonObject.getString("previousCalculation")
|
previousCalculation = jsonObject.getString("previousCalculation")
|
||||||
|
@ -504,5 +502,4 @@ class CalculatorImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<string name="app_name">ⵜⴰⵙⵎⵙⵙⵉⴹⵏⵜ ⵜⴰⴼⵔⴰⵔⵜ</string>
|
|
||||||
<string name="app_launcher_name">ⵜⴰⵙⵎⵙⵙⵉⴹⵏⵜ</string>
|
|
||||||
<string name="scientific_calculator">ⵜⴰⵙⵎⵙⵙⵉⴹⵏⵜ ⵜⴰⵎⴰⵙⵙⴰⵏⵜ</string>
|
|
||||||
<!-- Calculator field -->
|
|
||||||
<string name="formula_divide_by_zero_error">ⵜⴰⵣⴳⵍⵜ: ⴰⴱⵟⵟⵓ ⵅⴼ ⵓⵎⵢⴰ</string>
|
|
||||||
<!-- History -->
|
|
||||||
<string name="history">ⴰⵎⵣⵔⵓⵢ</string>
|
|
||||||
<string name="history_empty">ⴰⵎⵣⵔⵓⵢ ⵢⵓⵔⴰ</string>
|
|
||||||
<string name="clear_history">ⴽⴽⵙ</string>
|
|
||||||
<string name="history_cleared">ⵉⵜⵜⵡⴰⴽⴽⵙ ⵓⵎⵣⵔⵓⵢ</string>
|
|
||||||
<!-- Settings -->
|
|
||||||
<string name="vibrate_on_button_press">ⴰⵔⵎⵉⵎⵎⵉ ⴳ ⵡⴰⴱⴱⴰⵥ ⵅⴼ ⵜⴳⵎⵎⵓⵜⵉⵏ</string>
|
|
||||||
<string name="use_comma_as_decimal_mark">ⵙⵎⵔⵙ ⵜⵉⵙⴽⵔⵜ ⴷ ⵜⴰⵎⴰⵜⴰⵔⵜ ⵜⴰⵎⵔⴰⵡⴰⵏⵜ</string>
|
|
||||||
<!-- FAQ -->
|
|
||||||
<string name="faq_1_title">ⵎⴰⵎⴽ ⵜⵙⵡⵓⵔⵓⵢ ⵜⴳⵎⵎⵓⵜ C (ⴽⴽⵙ)\?</string>
|
|
||||||
<string name="faq_1_text">ⴰⴱⴱⴰⵥ ⵅⴼ ⵓⵢⵏⵏⴰ ⴰⴷ ⵉⴽⴽⵙ ⵢⴰⵏ ⵓⵙⴽⴽⵉⵍ ⴳ ⵢⴰⵏ ⵓⵣⵎⵣ. ⵎⵛ ⵉⵍⵍⴰ ⵡⴰⴱⴱⴰⵥ ⴰⵙⵓⵍⴰⵏ ⵔⴰⴷ ⵜⵜⵓⵙⵏⴼⵍⵏ ⵎⴰⵕⵕⴰ ⵉⴳⵔⴰⵏ ⴳ ⵢⴰⵏ ⵓⵣⵎⵣ.</string>
|
|
||||||
</resources>
|
|
|
@ -1 +0,0 @@
|
||||||
* Added some UI, translation and stability improvements
|
|
|
@ -1 +0,0 @@
|
||||||
Uma linda calculadora para calculos rápidos com uma interface de usuário suave
|
|
|
@ -1 +0,0 @@
|
||||||
Calculadora Simples
|
|
Loading…
Reference in New Issue