diff --git a/app/src/main/java/com/darkempire78/opencalculator/activities/MainActivity.kt b/app/src/main/java/com/darkempire78/opencalculator/activities/MainActivity.kt
index 13dd8033..85717553 100644
--- a/app/src/main/java/com/darkempire78/opencalculator/activities/MainActivity.kt
+++ b/app/src/main/java/com/darkempire78/opencalculator/activities/MainActivity.kt
@@ -479,14 +479,24 @@ class MainActivity : AppCompatActivity() {
).last()
}
var firstNumberAfter = ""
- if (cursorPosition < binding.input.text.length - 1) {
+ var nextChar = ' '
+ if (cursorPosition <= binding.input.text.length - 1) {
+ nextChar = binding.input.text[cursorPosition]
+ }
+
+ if (cursorPosition <= binding.input.text.length - 1) {
firstNumberAfter = NumberFormatter.extractNumbers(
binding.input.text.toString()
.substring(cursorPosition, binding.input.text.length),
decimalSeparatorSymbol
).first()
+
+ if (nextChar == '.') {
+ firstNumberAfter = nextChar.toString()
+ }
}
- if (decimalSeparatorSymbol in lastNumberBefore) { // || decimalSeparatorSymbol in firstNumberAfter) {
+ if (decimalSeparatorSymbol in lastNumberBefore
+ || decimalSeparatorSymbol in firstNumberAfter) {
return@withContext
}
}
@@ -500,7 +510,7 @@ class MainActivity : AppCompatActivity() {
val cursorOffset = newValueFormatted.length - newValue.length
binding.input.setSelection(cursorPosition + value.length + cursorOffset)
} else {
- val desiredCursorPosition = (leftValueFormatted.length + value.length)
+ val desiredCursorPosition = leftValueFormatted.length + value.length
// Limit the cursor position to the length of the input
val safeCursorPosition = desiredCursorPosition.coerceAtMost(binding.input.text.length)
binding.input.setSelection(safeCursorPosition)
@@ -958,6 +968,8 @@ class MainActivity : AppCompatActivity() {
val calculation = binding.input.text.toString()
+ Expression().addParenthesis(calculation)
+
if (calculation != "") {
val resultString = calculationResult.toString()
diff --git a/app/src/main/java/com/darkempire78/opencalculator/calculator/parser/Expression.kt b/app/src/main/java/com/darkempire78/opencalculator/calculator/parser/Expression.kt
index 9694d236..04a41c57 100644
--- a/app/src/main/java/com/darkempire78/opencalculator/calculator/parser/Expression.kt
+++ b/app/src/main/java/com/darkempire78/opencalculator/calculator/parser/Expression.kt
@@ -102,7 +102,7 @@ class Expression {
}
- private fun addParenthesis(calculation: String): String {
+ fun addParenthesis(calculation: String): String {
// Add ")" which lack
var cleanCalculation = calculation
var openParentheses = 0
@@ -121,6 +121,10 @@ class Expression {
cleanCalculation += ')'
}
}
+ // Trigger syntax error if missing '('
+ if (closeParentheses > openParentheses) {
+ syntax_error = true
+ }
return cleanCalculation
}
diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml
index bd3cb22d..0de7bab8 100644
--- a/app/src/main/res/values-cs/strings.xml
+++ b/app/src/main/res/values-cs/strings.xml
@@ -3,7 +3,7 @@
Vibrace
Motiv
Kalkulačka
- Vymazat historii
+ Smazat historii
O aplikaci
Amoled
Světlý
@@ -17,9 +17,9 @@
HISTORIE
Vibrovat při stisknutí tlačítka
Výsledky byly uloženy do historie
- Zabránit uspání telefonu
+ Udržovat zařízení vzhůru
POKROČILÉ
- Při otevření aplikace automaticky zapnout vědecký režim
+ Používat vědecký režim jako výchozí
Radiány
Používat radiány místo stupňů
POMOZTE NÁM
@@ -29,8 +29,8 @@
Chyba syntaxe
INFO O APLIKACI
Překlad
- Ohodnotit aplikaci
- Děkujeme za používání OpenCalc ❤️
+ Napsat recenzi
+ Děkujeme že používáte OpenCalc ❤️
Vytvořeno s ❤️ ve Francii
Počet desetinných míst
Zásady ochrany soukromí
@@ -38,23 +38,23 @@
Systém
Vědecký režim
Verze
- Zabrání uspání telefonu, když je aplikace v popředí
+ Zabrání uspání zařízení když je aplikace otevřená
Nahradit \"X²\" modulem (dostupný když je \"INV\" zmáčknuté)
FORMÁTOVÁNÍ
Licence GPL 3.0
- Odstranit \"AC\" tlačítko k rozdvojení tlačítka se závorkami
- Převést všechny výsledky do vědeckého zápisu
+ Nahradit tlačítko \"AC\" tlačítky se závorkami
+ Převést všechny výsledky do vědecké notace
Dlouhé zmáčknutí zkopíruje text položky místo výběru
Dlouhé zmačknutí ke zkopírování čísla
Přidat tlačítko modula
- Číslo do vědeckého zápisu
+ Vědecká notace
Je potřeba opravdové číslo
Rozdvojit tlačítko se závorkami
Zkopírovaný výsledek
Zkopírovaný výpočet z historie
Zkopírovaný výsledek z historie
Povolit selektivní mazání historie
- Smazat konkrétní položku historie při přejetí prstem
+ Smazat konkrétní položku historie po přejetí prstem
tečna
logaritmus
Automaticky ukládat počty
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 8c84dcf7..4376bea9 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -9,7 +9,7 @@
Översätt
FORMATERING
Vetenskapligt läge
- Resultat sparade i historik
+ Resultat sparade i historiken
Antal decimaler
Ta bort \"AC\"-knappen för att dela upp parenteser-knappen i två knappar
Inställningar
@@ -53,4 +53,13 @@
Kopierade resultat
Kopierade historikuträkning
Kopierade historikresultat
-
\ No newline at end of file
+ komma
+ backsteg
+ procent
+ parenteser
+ rensa
+ Tillåt selektiv radering av historiken
+ Radera specifik historikpost vid svepning
+ Spara uträkningar automatiskt
+ Spara automatiskt uträkningar i historiken utan att behöva klicka på likamedknappen
+