Skip to content

Commit

Permalink
Merge pull request #107 from Yet-Zio/v1.1.2
Browse files Browse the repository at this point in the history
V1.1.2
  • Loading branch information
Yet-Zio committed Feb 28, 2024
2 parents a29b1ec + 0761bbd commit 1aa5222
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 250 deletions.
10 changes: 0 additions & 10 deletions .gitpod.yml

This file was deleted.

20 changes: 10 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "yetzio.yetcalc"
minSdk 21
targetSdk 34
versionCode 12
versionName "1.1.1"
versionCode 13
versionName "1.1.2"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -50,23 +50,23 @@ dependencies {

implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation("org.mariuszgromada.math:MathParser.org-mXparser:5.2.1")
implementation("org.mariuszgromada.math:MathParser.org-mXparser:4.4.3")

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.7.0"

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'

implementation 'com.google.android.material:material:1.10.0'
implementation 'com.google.android.material:material:1.11.0'
implementation 'io.github.muddz:styleabletoast:2.4.0'

implementation 'androidx.preference:preference-ktx:1.2.1'

implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.15.3'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1'
implementation 'com.afollestad.material-dialogs:core:3.3.0'

implementation 'com.airbnb.android:paris:2.0.2'
Expand Down
60 changes: 28 additions & 32 deletions app/src/main/java/yetzio/yetcalc/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import org.mariuszgromada.math.mxparser.License
import yetzio.yetcalc.component.AngleMode
import yetzio.yetcalc.component.CalcMode
import yetzio.yetcalc.component.Calculator
Expand All @@ -46,6 +45,7 @@ val Calc = Calculator()
class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnItemSelectedListener{
private lateinit var mviewModel: CalcViewModel
private val mCoroutineScope = CoroutineScope(Dispatchers.Main)
private val IOCoroutineScope = CoroutineScope(Dispatchers.IO)
private var variable_charlist = ArrayList<String>()

private lateinit var histLauncher: ActivityResultLauncher<Intent>
Expand Down Expand Up @@ -154,9 +154,6 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// mxParser non-commerical use confirmation
confirm_mXparserUse()

mviewModel = ViewModelProvider(this)[CalcViewModel::class.java]
if(getScreenOrientation(applicationContext) == Configuration.ORIENTATION_PORTRAIT){
if(mviewModel.spinnerPos > 0){
Expand Down Expand Up @@ -626,24 +623,6 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
TODO("Not yet implemented")
}

private fun confirm_mXparserUse(){
// confirming use of mXParser for non commercial use
val mXparser_init = preferences.getBoolean(getString(R.string.mx_parser_init), false)

if(!mXparser_init){
val isCallSuccessful = License.iConfirmNonCommercialUse(getString(R.string.author_name))
val isConfirmed = License.checkIfUseTypeConfirmed()
val confirm_message = License.getUseTypeConfirmationMessage()

println("isCallSuccessful = $isCallSuccessful")
println("isConfirmed = $isConfirmed")
println("message = $confirm_message")

editor.putBoolean(getString(R.string.mx_parser_init), true)
editor.apply()
}
}

private fun restoreModesAndConfiguration(savedInstanceState: Bundle?){
if(savedInstanceState != null){
textres.text = savedInstanceState.getString(getString(R.string.text_res))
Expand Down Expand Up @@ -884,7 +863,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
private fun portraitButtonHandler(id: Int){
when(id){
R.id.sqrtbutton -> {
addExpression(getString(R.string.sqroot))
addExpression(getString(R.string.sqrootval))
evaluate_expr()
}
else -> {
Expand Down Expand Up @@ -919,7 +898,7 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
}
R.id.sqrtbutton -> {
if(mviewModel.calcMode == CalcMode.FIRSTMODE){
addExpression(getString(R.string.sqroot))
addExpression(getString(R.string.sqrootval))
evaluate_expr()
}
else if(mviewModel.calcMode == CalcMode.SECONDMODE){
Expand Down Expand Up @@ -1237,11 +1216,11 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
evaluate_expr()
}
else if(mviewModel.calcMode == CalcMode.THIRDMODE){
addExpression(getString(R.string.cuberoottext))
addExpression(getString(R.string.cuberootval))
evaluate_expr()
}
else if(mviewModel.calcMode == CalcMode.FOURTHMODE){
addExpression(getString(R.string.fourthroottext))
addExpression(getString(R.string.fourthrootval))
evaluate_expr()
}
else if(mviewModel.calcMode == CalcMode.FIFTHMODE){
Expand Down Expand Up @@ -1338,12 +1317,29 @@ class MainActivity : AppCompatActivity(), View.OnClickListener, AdapterView.OnIt
evaluate_expr()
}
R.id.equalop -> {
if(!textexpression.text.isEmpty() && !textres.text.isEmpty()){
Calc.addToHistory(textexpression.text.toString(), textres.text.toString())
textexpression.setText(textres.text)
textres.setText("")
textexpression.setSelection(textexpression.length())
result = textres.text.toString()
if (textexpression.text.isNotEmpty() && textres.text.isNotEmpty()) {
val expression = textexpression.text.toString()
val resultText = textres.text.toString()

IOCoroutineScope.launch {
Calc.addToHistory(expression, resultText)
}

textexpression.setText(resultText)
textres.text = ""
textexpression.setSelection(textexpression.text.length)

val prefMgr = PreferenceManager.getDefaultSharedPreferences(this)
val leftjustres = prefMgr.getBoolean("leftjustifyres", true)

if (leftjustres) {
val maxScrollX = textexpression.layout.getLineLeft(0).toInt().coerceAtLeast(0)
textexpression.post {
textexpression.scrollTo(maxScrollX, 0)
}
}

result = resultText
}
}
R.id.backspacebutton -> {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/yetzio/yetcalc/component/History.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class History{
}
}

// sort in descending order
ret_list.reverse()

return ret_list
}

Expand Down
29 changes: 16 additions & 13 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>
<string name="author_name">Yet Zio</string>
<string name="app_name">yetCalc</string>
<string name="VERSION_NUM">1.1.1</string>
<string name="VERSION_NUM">1.1.2</string>
<string name="app_descrp">Yet another calculator by Yet Zio</string>
<string name="ghbtext">View on GitHub</string>
<string name="app_details">Free and open source software\nLicensed under the BSD-3-Clause license.</string>
Expand All @@ -25,6 +25,7 @@
<string name="dividetext">÷</string>
<string name="mulop">×</string>
<string name="sqroot">√</string>
<string name="sqrootval">^(1/2)</string>
<string name="numberfour">4</string>
<string name="numberfive">5</string>
<string name="numbersix">6</string>
Expand All @@ -48,7 +49,7 @@
<string name="naturallogtext">ln</string>
<string name="commonlogtext">log</string>
<string name="divide_expr">/</string>
<string name="mul_expr">×</string>
<string name="mul_expr">*</string>
<string name="zero_text">0</string>
<string name="text_res">textres</string>
<string name="mode_text">calcmode</string>
Expand All @@ -70,7 +71,7 @@
<string name="cot_func">cot(</string>
<string name="eraised_func">e^</string>
<string name="naturallog_func">ln(</string>
<string name="commonlog_func">lg(</string>
<string name="commonlog_func">log10(</string>
<string name="tenraised_func">10^</string>
<string name="mx_parser_init">mxparse</string>
<string name="eulermascheroni">γ</string>
Expand Down Expand Up @@ -153,22 +154,22 @@
<string name="boltzmannconstnum">1.380648509796223E-23</string>
<string name="ncr_func">nCr(n,r)</string>
<string name="kdelta_func">KDelta(i, j)</string>
<string name="integralfunc">(expr, arg, from, to)</string>
<string name="backward_difffunc"><![CDATA[(expr, arg, <delta>)]]></string>
<string name="sigma_func"><![CDATA[(i, from, to, expr, <by>)]]></string>
<string name="derfunc"><![CDATA[(expr, arg, <point>)]]></string>
<string name="integralfunc">int(expr, arg, from, to)</string>
<string name="backward_difffunc"><![CDATA[difb(expr, arg, <delta>)]]></string>
<string name="sigma_func"><![CDATA[sum(i, from, to, expr, <by>)]]></string>
<string name="derfunc"><![CDATA[der(expr, arg, <point>)]]></string>
<string name="eqsolvefunc">solve(expr, arg, from, to)</string>
<string name="prod_func"><![CDATA[(i, from, to, expr, <by>)]]></string>
<string name="prod_func"><![CDATA[prod(i, from, to, expr, <by>)]]></string>
<string name="stirlingnumfunc">Stirl1(n, k)</string>
<string name="avg_func"><![CDATA[avg(i, from, to, expr, <by>)]]></string>
<string name="nderfunc">dern(expr, n, arg)</string>
<string name="bernfunc">Bern(m,n)</string>
<string name="vari_func"><![CDATA[vari(i, from, to, expr, <by>)]]></string>
<string name="fwd_func"><![CDATA[(expr, arg, <delta>)]]></string>
<string name="fwd_func"><![CDATA[diff(expr, arg, <delta>)]]></string>
<string name="worpfunc">Worp(n, k)</string>
<string name="stdi_func"><![CDATA[stdi(i, from, to, expr, <by>)]]></string>
<string name="leftderfunc"><![CDATA[-(expr, arg, <point>)]]></string>
<string name="rightderfunc"><![CDATA[+(expr, arg, <point>)]]></string>
<string name="leftderfunc"><![CDATA[der-(expr, arg, <point>)]]></string>
<string name="rightderfunc"><![CDATA[der+(expr, arg, <point>)]]></string>
<string name="stirlingnum2func">Stirl2(n, k)</string>
<string name="mean_func">mean(a1, …, an)</string>
<string name="parabolicconstant">[P2]</string>
Expand All @@ -184,8 +185,10 @@
<string name="deftext">x</string>
<string name="drop_downarr">▼</string>
<string name="modulotext">#(mod)</string>
<string name="cuberoottext">∛</string>
<string name="fourthroottext">∜</string>
<string name="cuberoottext">³√</string>
<string name="cuberootval">^(1/3)</string>
<string name="fourthroottext">⁴√</string>
<string name="fourthrootval">^(1/4)</string>
<string name="powertower">^^</string>
<string name="moduloop">#</string>

Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/xml/root_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

<PreferenceCategory app:title="Calculator">

<SwitchPreferenceCompat
app:key="leftjustifyres"
app:summary="Results are always left justified no matter small or large. Right justifies after pressing a button automatically."
app:title="Left Justify Result"
app:defaultValue="true"/>

<SwitchPreferenceCompat
app:key="almostintkey"
app:summary="A number is rounded to the nearest integer if it is close enough to an integer."
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.android.application' version '8.1.1' apply false
id 'com.android.library' version '8.1.1' apply false
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
id 'com.android.application' version '8.2.2' apply false
id 'com.android.library' version '8.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.22' apply false
}

task clean(type: Delete) {
Expand Down
9 changes: 9 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bug Fixes

- Fixed a UI freezing issue caused by history reading whenever the equal to button was clicked.

Enhancements

- From now on, results will be left aligned in calculator component for easier reading. Can be turned off from settings.

- Results are now sorted in descending order by default in history.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionUrl=https://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https://services.gradle.org/distributions/gradle-8.6-all.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading

0 comments on commit 1aa5222

Please sign in to comment.