From 6b89deee808a0c00b61caa33fe968868bee93451 Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 7 Jan 2016 20:38:20 +0100 Subject: [PATCH] Calculation time preference removed --- .../android/calculator/CalculatorEngine.java | 56 +------------------ .../calculator/CalculatorEngineImpl.java | 23 ++------ .../model/AndroidCalculatorEngine.java | 48 +++++----------- app/src/main/res/values/preferences.xml | 3 - .../main/res/xml/preferences_calculations.xml | 7 --- 5 files changed, 20 insertions(+), 117 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorEngine.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorEngine.java index a4c7f6c2..4a25af88 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorEngine.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorEngine.java @@ -22,10 +22,6 @@ package org.solovyev.android.calculator; -import java.text.DecimalFormatSymbols; - -import javax.annotation.Nonnull; - import jscl.AngleUnit; import jscl.MathEngine; import jscl.NumeralBase; @@ -33,88 +29,42 @@ import jscl.math.function.Function; import jscl.math.function.IConstant; import jscl.math.operator.Operator; -/** - * User: Solovyev_S - * Date: 20.09.12 - * Time: 12:43 - */ +import javax.annotation.Nonnull; +import java.text.DecimalFormatSymbols; + public interface CalculatorEngine { - /* - ********************************************************************** - * - * INIT - * - ********************************************************************** - */ - void init(); - void reset(); - void softReset(); - /* - ********************************************************************** - * - * REGISTRIES - * - ********************************************************************** - */ - @Nonnull CalculatorMathRegistry getVarsRegistry(); - @Nonnull CalculatorMathRegistry getFunctionsRegistry(); - @Nonnull CalculatorMathRegistry getOperatorsRegistry(); - @Nonnull CalculatorMathRegistry getPostfixFunctionsRegistry(); - @Nonnull CalculatorMathEngine getMathEngine(); - @Deprecated @Nonnull MathEngine getMathEngine0(); - /* - ********************************************************************** - * - * PREFERENCES - * - ********************************************************************** - */ - @Nonnull String getMultiplicationSign(); - void setMultiplicationSign(@Nonnull String multiplicationSign); - void setUseGroupingSeparator(boolean useGroupingSeparator); - void setGroupingSeparator(char groupingSeparator); - void setPrecision(@Nonnull Integer precision); - void setRoundResult(@Nonnull Boolean round); - @Nonnull AngleUnit getAngleUnits(); - void setAngleUnits(@Nonnull AngleUnit angleUnits); - @Nonnull NumeralBase getNumeralBase(); - void setNumeralBase(@Nonnull NumeralBase numeralBase); - void setScienceNotation(@Nonnull Boolean scienceNotation); - - void setTimeout(@Nonnull Integer timeout); - void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols); } diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorEngineImpl.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorEngineImpl.java index 23959f46..f955c6d3 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorEngineImpl.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorEngineImpl.java @@ -22,11 +22,6 @@ package org.solovyev.android.calculator; -import java.text.DecimalFormatSymbols; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - import jscl.AngleUnit; import jscl.JsclMathEngine; import jscl.MathEngine; @@ -37,11 +32,10 @@ import jscl.math.function.IConstant; import jscl.math.operator.Operator; import jscl.text.ParseException; -/** - * User: serso - * Date: 9/23/12 - * Time: 5:34 PM - */ +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.text.DecimalFormatSymbols; + public class CalculatorEngineImpl implements CalculatorEngine { /* @@ -54,8 +48,6 @@ public class CalculatorEngineImpl implements CalculatorEngine { private static final String MULTIPLICATION_SIGN_DEFAULT = "×"; - private static final String MAX_CALCULATION_TIME_DEFAULT = "5"; - /* ********************************************************************** * @@ -93,8 +85,6 @@ public class CalculatorEngineImpl implements CalculatorEngine { */ - private int timeout = Integer.valueOf(MAX_CALCULATION_TIME_DEFAULT); - @Nonnull private String multiplicationSign = MULTIPLICATION_SIGN_DEFAULT; @@ -288,11 +278,6 @@ public class CalculatorEngineImpl implements CalculatorEngine { } } - @Override - public void setTimeout(@Nonnull Integer timeout) { - this.timeout = timeout; - } - @Override public void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols) { synchronized (lock) { diff --git a/app/src/main/java/org/solovyev/android/calculator/model/AndroidCalculatorEngine.java b/app/src/main/java/org/solovyev/android/calculator/model/AndroidCalculatorEngine.java index ee8345e3..88a06190 100644 --- a/app/src/main/java/org/solovyev/android/calculator/model/AndroidCalculatorEngine.java +++ b/app/src/main/java/org/solovyev/android/calculator/model/AndroidCalculatorEngine.java @@ -26,30 +26,6 @@ import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; - -import org.solovyev.android.calculator.CalculatorEngine; -import org.solovyev.android.calculator.CalculatorEngineImpl; -import org.solovyev.android.calculator.CalculatorFunctionsMathRegistry; -import org.solovyev.android.calculator.CalculatorMathEngine; -import org.solovyev.android.calculator.CalculatorMathRegistry; -import org.solovyev.android.calculator.CalculatorOperatorsMathRegistry; -import org.solovyev.android.calculator.CalculatorPostfixFunctionsRegistry; -import org.solovyev.android.calculator.CalculatorVarsRegistry; -import org.solovyev.android.calculator.MathPersistenceEntity; -import org.solovyev.android.prefs.BooleanPreference; -import org.solovyev.android.prefs.Preference; -import org.solovyev.android.prefs.StringPreference; -import org.solovyev.common.text.EnumMapper; -import org.solovyev.common.text.NumberMapper; -import org.solovyev.common.text.Strings; - -import java.text.DecimalFormatSymbols; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nonnull; - import jscl.AngleUnit; import jscl.JsclMathEngine; import jscl.MathEngine; @@ -57,6 +33,19 @@ import jscl.NumeralBase; import jscl.math.function.Function; import jscl.math.function.IConstant; import jscl.math.operator.Operator; +import org.solovyev.android.calculator.*; +import org.solovyev.android.prefs.BooleanPreference; +import org.solovyev.android.prefs.Preference; +import org.solovyev.android.prefs.StringPreference; +import org.solovyev.common.text.EnumMapper; +import org.solovyev.common.text.NumberMapper; +import org.solovyev.common.text.Strings; + +import javax.annotation.Nonnull; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; /** * User: serso @@ -71,9 +60,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen private static final String MULTIPLICATION_SIGN_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_multiplication_sign"; private static final String MULTIPLICATION_SIGN_DEFAULT = "×"; - private static final String MAX_CALCULATION_TIME_P_KEY = "calculation.max_calculation_time"; - private static final String MAX_CALCULATION_TIME_DEFAULT = "5"; - private static final String SCIENCE_NOTATION_P_KEY = "calculation.output.science_notation"; private static final boolean SCIENCE_NOTATION_DEFAULT = false; @@ -231,11 +217,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen calculatorEngine.setScienceNotation(scienceNotation); } - @Override - public void setTimeout(@Nonnull Integer timeout) { - calculatorEngine.setTimeout(timeout); - } - private void softReset(@Nonnull SharedPreferences preferences) { this.setPrecision(Preferences.precision.getPreference(preferences)); this.setRoundResult(Preferences.roundResult.getPreference(preferences)); @@ -243,7 +224,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen this.setNumeralBase(getNumeralBaseFromPrefs(preferences)); this.setMultiplicationSign(Preferences.multiplicationSign.getPreference(preferences)); this.setScienceNotation(Preferences.scienceNotation.getPreference(preferences)); - this.setTimeout(Preferences.maxCalculationTime.getPreference(preferences)); final String groupingSeparator = Preferences.groupingSeparator.getPreference(preferences); if (Strings.isEmpty(groupingSeparator)) { @@ -285,7 +265,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen public static final Preference numeralBase = StringPreference.ofTypedValue(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT, EnumMapper.of(NumeralBase.class)); public static final Preference angleUnit = StringPreference.ofTypedValue(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT, EnumMapper.of(AngleUnit.class)); public static final Preference scienceNotation = BooleanPreference.of(SCIENCE_NOTATION_P_KEY, SCIENCE_NOTATION_DEFAULT); - public static final Preference maxCalculationTime = StringPreference.ofTypedValue(MAX_CALCULATION_TIME_P_KEY, MAX_CALCULATION_TIME_DEFAULT, NumberMapper.of(Integer.class)); private static final List preferenceKeys = new ArrayList(); @@ -297,7 +276,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen preferenceKeys.add(numeralBase.getKey()); preferenceKeys.add(angleUnit.getKey()); preferenceKeys.add(scienceNotation.getKey()); - preferenceKeys.add(maxCalculationTime.getKey()); } @Nonnull diff --git a/app/src/main/res/values/preferences.xml b/app/src/main/res/values/preferences.xml index 5abe7118..24b13ff7 100644 --- a/app/src/main/res/values/preferences.xml +++ b/app/src/main/res/values/preferences.xml @@ -24,9 +24,6 @@ org.solovyev.android.calculator.CalculatorModel_result_precision 5 - calculation.max_calculation_time - 5 - org.solovyev.android.calculator.CalculatorModel_color_display true diff --git a/app/src/main/res/xml/preferences_calculations.xml b/app/src/main/res/xml/preferences_calculations.xml index fab09924..9751a104 100644 --- a/app/src/main/res/xml/preferences_calculations.xml +++ b/app/src/main/res/xml/preferences_calculations.xml @@ -79,13 +79,6 @@ a:summary="@string/c_numeral_bases_summary" a:title="@string/c_calc_numeral_bases" /> - -