Merge pull request #155 from ochagovdanil/master

Show division by zero Toast message
This commit is contained in:
Tibor Kaputa
2020-05-19 14:39:39 +02:00
committed by GitHub
25 changed files with 83 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package com.simplemobiletools.calculator.helpers
import android.content.Context import android.content.Context
import android.util.Log import android.util.Log
import android.widget.Toast
import com.simplemobiletools.calculator.R import com.simplemobiletools.calculator.R
import com.simplemobiletools.calculator.operation.OperationFactory import com.simplemobiletools.calculator.operation.OperationFactory
@ -56,13 +57,16 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
val second = secondValue.format() val second = secondValue.format()
val sign = getSign(lastOperation) val sign = getSign(lastOperation)
if (sign == "") { when {
setFormula(sign + first) sign == "" -> setFormula(sign + first)
} else if (sign == "!") { sign == "!" -> setFormula(first + sign)
setFormula(first + sign) sign.isNotEmpty() -> {
} else if (!sign.isEmpty()) { if (secondValue == 0.0 && sign == "/") {
var formula = first + sign + second context.toast(context.getString(R.string.formula_divide_by_zero_error))
setFormula(formula) }
setFormula(first + sign + second)
}
} }
} }

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">الحاسبة</string> <string name="app_launcher_name">الحاسبة</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">خطأ: القسمة على صفر</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">الاهتزاز عند الضغط على الازرار</string> <string name="vibrate_on_button_press">الاهتزاز عند الضغط على الازرار</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulyator</string> <string name="app_launcher_name">Kalkulyator</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Səhv: sıfıra bölünmə</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Düyməyə basdıqda titrə</string> <string name="vibrate_on_button_press">Düyməyə basdıqda titrə</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulačka</string> <string name="app_launcher_name">Kalkulačka</string>
<string name="scientific_calculator">Vědecká kalkulačka</string> <string name="scientific_calculator">Vědecká kalkulačka</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Chyba: dělení nulou</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrovat při stisku tlačítka</string> <string name="vibrate_on_button_press">Vibrovat při stisku tlačítka</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Cyfrifiannell</string> <string name="app_launcher_name">Cyfrifiannell</string>
<string name="scientific_calculator">Cyfrifiannell Gwyddonol</string> <string name="scientific_calculator">Cyfrifiannell Gwyddonol</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Gwall: rhannu â sero</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Dirgrynu wrth wasgu botymau</string> <string name="vibrate_on_button_press">Dirgrynu wrth wasgu botymau</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Rechner</string>ng> <string name="app_launcher_name">Rechner</string>ng>
<string name="scientific_calculator">Wissenschaftlicher Rechner</string> <string name="scientific_calculator">Wissenschaftlicher Rechner</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Fehler: Division durch Null</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Bei Tastendruck vibrieren</string> <string name="vibrate_on_button_press">Bei Tastendruck vibrieren</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Αριθμομηχανή</string> <string name="app_launcher_name">Αριθμομηχανή</string>
<string name="scientific_calculator">Επιστημονική Αριθμομηχανή</string> <string name="scientific_calculator">Επιστημονική Αριθμομηχανή</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Σφάλμα: διαίρεση με μηδέν</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Δόνηση στο πάτημα πλήκτρου</string> <string name="vibrate_on_button_press">Δόνηση στο πάτημα πλήκτρου</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Calculadora</string> <string name="app_launcher_name">Calculadora</string>
<string name="scientific_calculator">Calculadora Científica</string> <string name="scientific_calculator">Calculadora Científica</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Error: división por cero</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrar al presionar un botón</string> <string name="vibrate_on_button_press">Vibrar al presionar un botón</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Calculatrice</string> <string name="app_launcher_name">Calculatrice</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Erreur: division par zéro</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrer lors de l\'appui sur les boutons</string> <string name="vibrate_on_button_press">Vibrer lors de l\'appui sur les boutons</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulator</string> <string name="app_launcher_name">Kalkulator</string>
<string name="scientific_calculator">Znanstveni kalkulator</string> <string name="scientific_calculator">Znanstveni kalkulator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Pogreška: podjela prema nuli</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibriraj prilikom pritiska na gumb</string> <string name="vibrate_on_button_press">Vibriraj prilikom pritiska na gumb</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulator</string> <string name="app_launcher_name">Kalkulator</string>
<string name="scientific_calculator">Kalkulator Sains</string> <string name="scientific_calculator">Kalkulator Sains</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Kesalahan: pembagian dengan nol</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Getar saat tombol ditekan</string> <string name="vibrate_on_button_press">Getar saat tombol ditekan</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulator</string> <string name="app_launcher_name">Kalkulator</string>
<string name="scientific_calculator">Kalkulator Sains</string> <string name="scientific_calculator">Kalkulator Sains</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Kesalahan: pembagian dengan nol</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Getar saat tombol ditekan</string> <string name="vibrate_on_button_press">Getar saat tombol ditekan</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Calcolatrice</string> <string name="app_launcher_name">Calcolatrice</string>
<string name="scientific_calculator">Calcolatrice scientifica</string> <string name="scientific_calculator">Calcolatrice scientifica</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Errore: divisione per zero</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibra alla pressione di un tasto</string> <string name="vibrate_on_button_press">Vibra alla pressione di un tasto</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">電卓</string> <string name="app_launcher_name">電卓</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">エラー:ゼロによる除算</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">ボタンのタップ時に振動する</string> <string name="vibrate_on_button_press">ボタンのタップ時に振動する</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Skaičiuotuvas</string> <string name="app_launcher_name">Skaičiuotuvas</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Klaida: padalijimas iš nulio</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibruoti kai spaudžiami mygtukai</string> <string name="vibrate_on_button_press">Vibruoti kai spaudžiami mygtukai</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Rekenmachine</string> <string name="app_launcher_name">Rekenmachine</string>
<string name="scientific_calculator">Wetenschappelijke Rekenmachine</string> <string name="scientific_calculator">Wetenschappelijke Rekenmachine</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Fout: delen door nul</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Trillen bij toetsaanslagen</string> <string name="vibrate_on_button_press">Trillen bij toetsaanslagen</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulator</string> <string name="app_launcher_name">Kalkulator</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Błąd: dzielenie przez zero</string>
<!-- Settings --> <!-- Settings -->
   <string name="vibrate_on_button_press">Wibracja po wciśnięciu przycisku</string>    <string name="vibrate_on_button_press">Wibracja po wciśnięciu przycisku</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Calculadora</string> <string name="app_launcher_name">Calculadora</string>
<string name="scientific_calculator">Calculadora científica</string> <string name="scientific_calculator">Calculadora científica</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Erro: divisão por zero</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrar ao tocar nos botões</string> <string name="vibrate_on_button_press">Vibrar ao tocar nos botões</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Калькулятор</string> <string name="app_launcher_name">Калькулятор</string>
<string name="scientific_calculator">Научный калькулятор</string> <string name="scientific_calculator">Научный калькулятор</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Ошибка: деление на ноль</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Вибрация при нажатии кнопок</string> <string name="vibrate_on_button_press">Вибрация при нажатии кнопок</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkulačka</string> <string name="app_launcher_name">Kalkulačka</string>
<string name="scientific_calculator">Vedecká kalkulačka</string> <string name="scientific_calculator">Vedecká kalkulačka</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Chyba: delenie nulou</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrovať pri stlačení tlačidla</string> <string name="vibrate_on_button_press">Vibrovať pri stlačení tlačidla</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Kalkylator</string> <string name="app_launcher_name">Kalkylator</string>
<string name="scientific_calculator">Avancerad kalkylator</string> <string name="scientific_calculator">Avancerad kalkylator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Fel: delning med noll</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrera när jag trycker på knapparna</string> <string name="vibrate_on_button_press">Vibrera när jag trycker på knapparna</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Hesap Makinesi</string> <string name="app_launcher_name">Hesap Makinesi</string>
<string name="scientific_calculator">Bilimsel Hesap Makinesi</string> <string name="scientific_calculator">Bilimsel Hesap Makinesi</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Hata: sıfıra bölme</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Düğmeye basıldığında titret</string> <string name="vibrate_on_button_press">Düğmeye basıldığında titret</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Калькулятор</string> <string name="app_launcher_name">Калькулятор</string>
<string name="scientific_calculator">Науковий Калькулятор</string> <string name="scientific_calculator">Науковий Калькулятор</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Помилка: ділення на нуль</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Вібрувати з натиском кнопок</string> <string name="vibrate_on_button_press">Вібрувати з натиском кнопок</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">簡易計算機</string> <string name="app_launcher_name">簡易計算機</string>
<string name="scientific_calculator">工程計算機</string> <string name="scientific_calculator">工程計算機</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">錯誤:被零除</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">按下按鈕時震動</string> <string name="vibrate_on_button_press">按下按鈕時震動</string>

View File

@ -3,6 +3,9 @@
<string name="app_launcher_name">Calculator</string> <string name="app_launcher_name">Calculator</string>
<string name="scientific_calculator">Scientific Calculator</string> <string name="scientific_calculator">Scientific Calculator</string>
<!-- Calculator field -->
<string name="formula_divide_by_zero_error">Error: division by zero</string>
<!-- Settings --> <!-- Settings -->
<string name="vibrate_on_button_press">Vibrate on button press</string> <string name="vibrate_on_button_press">Vibrate on button press</string>