summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2024-12-18 11:15:23 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2024-12-18 11:15:23 +0330
commit5a670d6cae41d77280a98936f2baddf31f069656 (patch)
treeb1a15d3794f820278bbae5c1fb0cf73627e55139
parentd4573cacc141748c44bb6bbea7528bdd46afc3d5 (diff)
fixed bugs in multiple operators
updated launcher icon
-rw-r--r--app/build.gradle.kts4
-rw-r--r--app/src/main/ic_launcher-playstore.pngbin2688 -> 2748 bytes
-rw-r--r--app/src/main/java/com/a404m/calculator/model/CalcButtonModel.kt2
-rw-r--r--app/src/main/java/com/a404m/calculator/util/MathHelper.kt (renamed from app/src/main/java/com/a404m/calculator/MathHelper.kt)25
-rw-r--r--app/src/main/res/drawable/ic_launcher_background.xml170
-rw-r--r--app/src/main/res/drawable/ic_launcher_foreground.xml8
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher.webpbin558 -> 564 bytes
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher_round.webpbin1972 -> 1986 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher.webpbin446 -> 468 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher_round.webpbin1156 -> 1198 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher.webpbin702 -> 722 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher_round.webpbin2746 -> 2796 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher.webpbin944 -> 958 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webpbin4174 -> 4178 bytes
-rw-r--r--app/src/main/res/mipmap-xxxhdpi/ic_launcher.webpbin1266 -> 1276 bytes
-rw-r--r--app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webpbin5964 -> 6008 bytes
16 files changed, 22 insertions, 187 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 6848831..7fc29a3 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -12,8 +12,8 @@ android {
applicationId = "com.a404m.calculator"
minSdk = 21
targetSdk = 35
- versionCode = 2
- versionName = "0.1.0"
+ versionCode = 3
+ versionName = "0.1.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
diff --git a/app/src/main/ic_launcher-playstore.png b/app/src/main/ic_launcher-playstore.png
index 2d94637..1915ec0 100644
--- a/app/src/main/ic_launcher-playstore.png
+++ b/app/src/main/ic_launcher-playstore.png
Binary files differ
diff --git a/app/src/main/java/com/a404m/calculator/model/CalcButtonModel.kt b/app/src/main/java/com/a404m/calculator/model/CalcButtonModel.kt
index 435acef..c6a10da 100644
--- a/app/src/main/java/com/a404m/calculator/model/CalcButtonModel.kt
+++ b/app/src/main/java/com/a404m/calculator/model/CalcButtonModel.kt
@@ -1,6 +1,6 @@
package com.a404m.calculator.model
-import com.a404m.calculator.MathHelper
+import com.a404m.calculator.util.MathHelper
data class CalcButtonModel(
val text: String,
diff --git a/app/src/main/java/com/a404m/calculator/MathHelper.kt b/app/src/main/java/com/a404m/calculator/util/MathHelper.kt
index fa6cfc7..d0c3ee3 100644
--- a/app/src/main/java/com/a404m/calculator/MathHelper.kt
+++ b/app/src/main/java/com/a404m/calculator/util/MathHelper.kt
@@ -1,7 +1,7 @@
-package com.a404m.calculator
+package com.a404m.calculator.util
import android.util.Log
-import com.a404m.calculator.MathHelper.Operator.Kind
+import com.a404m.calculator.util.MathHelper.Operator.Kind
import java.nio.charset.UnsupportedCharsetException
object MathHelper {
@@ -113,7 +113,8 @@ object MathHelper {
if (lexed.size == 1) {
break
}
- for (i in lexed.indices) {
+ var i = -1
+ while(++i < lexed.size) {
val item = lexed[i]
if (item is BasicOperator) {
var op = item.toOperator(
@@ -132,17 +133,19 @@ object MathHelper {
Kind.INFIX -> {
op.operands.add(lexed.removeAt(i - 1))
op.operands.add(lexed.removeAt(i))
+ i -= 2
}
Kind.PREFIX -> {
op.operands.add(lexed.removeAt(i + 1))
+ --i
}
Kind.POSTFIX -> {
op.operands.add(lexed.removeAt(i - 1))
+ --i
}
}
- break
}
}
}
@@ -195,10 +198,10 @@ object MathHelper {
private class Operator(
val operator: Char,
val kind: Kind,
- val operate: (operands:List<Operand>)->Operand,
+ val operate: (operands:List<Operand>)-> Operand,
val operands: ArrayList<Any> = arrayListOf(),
) {
- fun cloneWithoutOperands():Operator{
+ fun cloneWithoutOperands(): Operator {
return Operator(
operator,
kind,
@@ -262,15 +265,17 @@ object MathHelper {
items: List<Any>,
i: Int
): Operator {
- val left = items.getOrElse(
+ val leftItem = items.getOrElse(
i - 1,
{ Any() },
- ) is Operand
+ )
+ val left = leftItem is Operand || leftItem is Operator
- val right = items.getOrElse(
+ val rightItem = items.getOrElse(
i + 1,
{ Any() },
- ) is Operand
+ )
+ val right = rightItem is Operand || rightItem is Operator
val k:Kind
diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml
deleted file mode 100644
index 07d5da9..0000000
--- a/app/src/main/res/drawable/ic_launcher_background.xml
+++ /dev/null
@@ -1,170 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="108dp"
- android:height="108dp"
- android:viewportWidth="108"
- android:viewportHeight="108">
- <path
- android:fillColor="#3DDC84"
- android:pathData="M0,0h108v108h-108z" />
- <path
- android:fillColor="#00000000"
- android:pathData="M9,0L9,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,0L19,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M29,0L29,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M39,0L39,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M49,0L49,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M59,0L59,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M69,0L69,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M79,0L79,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M89,0L89,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M99,0L99,108"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,9L108,9"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,19L108,19"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,29L108,29"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,39L108,39"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,49L108,49"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,59L108,59"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,69L108,69"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,79L108,79"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,89L108,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M0,99L108,99"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,29L89,29"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,39L89,39"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,49L89,49"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,59L89,59"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,69L89,69"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M19,79L89,79"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M29,19L29,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M39,19L39,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M49,19L49,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M59,19L59,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M69,19L69,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
- <path
- android:fillColor="#00000000"
- android:pathData="M79,19L79,89"
- android:strokeWidth="0.8"
- android:strokeColor="#33FFFFFF" />
-</vector>
diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml
index c5eec94..09bb996 100644
--- a/app/src/main/res/drawable/ic_launcher_foreground.xml
+++ b/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -4,10 +4,10 @@
android:height="108dp"
android:viewportWidth="87"
android:viewportHeight="167.625">
- <group android:scaleX="0.23874721"
- android:scaleY="0.46"
- android:translateX="33.1145"
- android:translateY="45.25875">
+ <group android:scaleX="0.3581208"
+ android:scaleY="0.69"
+ android:translateX="27.921745"
+ android:translateY="25.981874">
<group android:translateY="133.66406">
<path android:pathData="M6.1875,-36.84375L80.515625,-36.84375L80.515625,-24.75L6.1875,-24.75L6.1875,-36.84375ZM6.1875,-65.390625L80.515625,-65.390625L80.515625,-53.4375L6.1875,-53.4375L6.1875,-65.390625Z"
android:fillColor="#A437DB"/>
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
index ee62035..643e96f 100644
--- a/app/src/main/res/mipmap-hdpi/ic_launcher.webp
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
index 6452b49..b06dba0 100644
--- a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
index 8f60d53..66e9095 100644
--- a/app/src/main/res/mipmap-mdpi/ic_launcher.webp
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
index 3cd3848..47aa47d 100644
--- a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
index 9cb323b..f45a26e 100644
--- a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
index 6941df4..738dd8b 100644
--- a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
index eb514e1..876afd1 100644
--- a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
index 749d7c1..62c18af 100644
--- a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
index e404ad0..bdf47e0 100644
--- a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
+++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary files differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
index f7f408b..0de6d41 100644
--- a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
+++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
Binary files differ