Calculation time preference removed

This commit is contained in:
serso 2016-01-07 20:38:20 +01:00
parent 5ba8937f06
commit 6b89deee80
5 changed files with 20 additions and 117 deletions

View File

@ -22,10 +22,6 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import java.text.DecimalFormatSymbols;
import javax.annotation.Nonnull;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.MathEngine; import jscl.MathEngine;
import jscl.NumeralBase; import jscl.NumeralBase;
@ -33,88 +29,42 @@ import jscl.math.function.Function;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
/** import javax.annotation.Nonnull;
* User: Solovyev_S import java.text.DecimalFormatSymbols;
* Date: 20.09.12
* Time: 12:43
*/
public interface CalculatorEngine { public interface CalculatorEngine {
/*
**********************************************************************
*
* INIT
*
**********************************************************************
*/
void init(); void init();
void reset(); void reset();
void softReset(); void softReset();
/*
**********************************************************************
*
* REGISTRIES
*
**********************************************************************
*/
@Nonnull @Nonnull
CalculatorMathRegistry<IConstant> getVarsRegistry(); CalculatorMathRegistry<IConstant> getVarsRegistry();
@Nonnull @Nonnull
CalculatorMathRegistry<Function> getFunctionsRegistry(); CalculatorMathRegistry<Function> getFunctionsRegistry();
@Nonnull @Nonnull
CalculatorMathRegistry<Operator> getOperatorsRegistry(); CalculatorMathRegistry<Operator> getOperatorsRegistry();
@Nonnull @Nonnull
CalculatorMathRegistry<Operator> getPostfixFunctionsRegistry(); CalculatorMathRegistry<Operator> getPostfixFunctionsRegistry();
@Nonnull @Nonnull
CalculatorMathEngine getMathEngine(); CalculatorMathEngine getMathEngine();
@Deprecated @Deprecated
@Nonnull @Nonnull
MathEngine getMathEngine0(); MathEngine getMathEngine0();
/*
**********************************************************************
*
* PREFERENCES
*
**********************************************************************
*/
@Nonnull @Nonnull
String getMultiplicationSign(); String getMultiplicationSign();
void setMultiplicationSign(@Nonnull String multiplicationSign); void setMultiplicationSign(@Nonnull String multiplicationSign);
void setUseGroupingSeparator(boolean useGroupingSeparator); void setUseGroupingSeparator(boolean useGroupingSeparator);
void setGroupingSeparator(char groupingSeparator); void setGroupingSeparator(char groupingSeparator);
void setPrecision(@Nonnull Integer precision); void setPrecision(@Nonnull Integer precision);
void setRoundResult(@Nonnull Boolean round); void setRoundResult(@Nonnull Boolean round);
@Nonnull @Nonnull
AngleUnit getAngleUnits(); AngleUnit getAngleUnits();
void setAngleUnits(@Nonnull AngleUnit angleUnits); void setAngleUnits(@Nonnull AngleUnit angleUnits);
@Nonnull @Nonnull
NumeralBase getNumeralBase(); NumeralBase getNumeralBase();
void setNumeralBase(@Nonnull NumeralBase numeralBase); void setNumeralBase(@Nonnull NumeralBase numeralBase);
void setScienceNotation(@Nonnull Boolean scienceNotation); void setScienceNotation(@Nonnull Boolean scienceNotation);
void setTimeout(@Nonnull Integer timeout);
void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols); void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols);
} }

View File

@ -22,11 +22,6 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import java.text.DecimalFormatSymbols;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import jscl.AngleUnit; import jscl.AngleUnit;
import jscl.JsclMathEngine; import jscl.JsclMathEngine;
import jscl.MathEngine; import jscl.MathEngine;
@ -37,11 +32,10 @@ import jscl.math.function.IConstant;
import jscl.math.operator.Operator; import jscl.math.operator.Operator;
import jscl.text.ParseException; import jscl.text.ParseException;
/** import javax.annotation.Nonnull;
* User: serso import javax.annotation.Nullable;
* Date: 9/23/12 import java.text.DecimalFormatSymbols;
* Time: 5:34 PM
*/
public class CalculatorEngineImpl implements CalculatorEngine { 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 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 @Nonnull
private String multiplicationSign = MULTIPLICATION_SIGN_DEFAULT; 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 @Override
public void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols) { public void setDecimalGroupSymbols(@Nonnull DecimalFormatSymbols decimalGroupSymbols) {
synchronized (lock) { synchronized (lock) {

View File

@ -26,30 +26,6 @@ import android.app.Application;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.preference.PreferenceManager; 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.AngleUnit;
import jscl.JsclMathEngine; import jscl.JsclMathEngine;
import jscl.MathEngine; import jscl.MathEngine;
@ -57,6 +33,19 @@ import jscl.NumeralBase;
import jscl.math.function.Function; import jscl.math.function.Function;
import jscl.math.function.IConstant; import jscl.math.function.IConstant;
import jscl.math.operator.Operator; 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 * 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_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_multiplication_sign";
private static final String MULTIPLICATION_SIGN_DEFAULT = "×"; 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 String SCIENCE_NOTATION_P_KEY = "calculation.output.science_notation";
private static final boolean SCIENCE_NOTATION_DEFAULT = false; private static final boolean SCIENCE_NOTATION_DEFAULT = false;
@ -231,11 +217,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
calculatorEngine.setScienceNotation(scienceNotation); calculatorEngine.setScienceNotation(scienceNotation);
} }
@Override
public void setTimeout(@Nonnull Integer timeout) {
calculatorEngine.setTimeout(timeout);
}
private void softReset(@Nonnull SharedPreferences preferences) { private void softReset(@Nonnull SharedPreferences preferences) {
this.setPrecision(Preferences.precision.getPreference(preferences)); this.setPrecision(Preferences.precision.getPreference(preferences));
this.setRoundResult(Preferences.roundResult.getPreference(preferences)); this.setRoundResult(Preferences.roundResult.getPreference(preferences));
@ -243,7 +224,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
this.setNumeralBase(getNumeralBaseFromPrefs(preferences)); this.setNumeralBase(getNumeralBaseFromPrefs(preferences));
this.setMultiplicationSign(Preferences.multiplicationSign.getPreference(preferences)); this.setMultiplicationSign(Preferences.multiplicationSign.getPreference(preferences));
this.setScienceNotation(Preferences.scienceNotation.getPreference(preferences)); this.setScienceNotation(Preferences.scienceNotation.getPreference(preferences));
this.setTimeout(Preferences.maxCalculationTime.getPreference(preferences));
final String groupingSeparator = Preferences.groupingSeparator.getPreference(preferences); final String groupingSeparator = Preferences.groupingSeparator.getPreference(preferences);
if (Strings.isEmpty(groupingSeparator)) { if (Strings.isEmpty(groupingSeparator)) {
@ -285,7 +265,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
public static final Preference<NumeralBase> numeralBase = StringPreference.ofTypedValue(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT, EnumMapper.of(NumeralBase.class)); public static final Preference<NumeralBase> numeralBase = StringPreference.ofTypedValue(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT, EnumMapper.of(NumeralBase.class));
public static final Preference<AngleUnit> angleUnit = StringPreference.ofTypedValue(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT, EnumMapper.of(AngleUnit.class)); public static final Preference<AngleUnit> angleUnit = StringPreference.ofTypedValue(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT, EnumMapper.of(AngleUnit.class));
public static final Preference<Boolean> scienceNotation = BooleanPreference.of(SCIENCE_NOTATION_P_KEY, SCIENCE_NOTATION_DEFAULT); public static final Preference<Boolean> scienceNotation = BooleanPreference.of(SCIENCE_NOTATION_P_KEY, SCIENCE_NOTATION_DEFAULT);
public static final Preference<Integer> maxCalculationTime = StringPreference.ofTypedValue(MAX_CALCULATION_TIME_P_KEY, MAX_CALCULATION_TIME_DEFAULT, NumberMapper.of(Integer.class));
private static final List<String> preferenceKeys = new ArrayList<String>(); private static final List<String> preferenceKeys = new ArrayList<String>();
@ -297,7 +276,6 @@ public class AndroidCalculatorEngine implements CalculatorEngine, SharedPreferen
preferenceKeys.add(numeralBase.getKey()); preferenceKeys.add(numeralBase.getKey());
preferenceKeys.add(angleUnit.getKey()); preferenceKeys.add(angleUnit.getKey());
preferenceKeys.add(scienceNotation.getKey()); preferenceKeys.add(scienceNotation.getKey());
preferenceKeys.add(maxCalculationTime.getKey());
} }
@Nonnull @Nonnull

View File

@ -24,9 +24,6 @@
<string name="p_calc_result_precision_key" translatable="false">org.solovyev.android.calculator.CalculatorModel_result_precision</string> <string name="p_calc_result_precision_key" translatable="false">org.solovyev.android.calculator.CalculatorModel_result_precision</string>
<string name="p_calc_result_precision" translatable="false">5</string> <string name="p_calc_result_precision" translatable="false">5</string>
<string name="p_calc_max_calculation_time_key" translatable="false">calculation.max_calculation_time</string>
<string name="p_calc_max_calculation_time" translatable="false">5</string>
<string name="p_calc_color_display_key" translatable="false">org.solovyev.android.calculator.CalculatorModel_color_display</string> <string name="p_calc_color_display_key" translatable="false">org.solovyev.android.calculator.CalculatorModel_color_display</string>
<string name="p_calc_color_display" translatable="false">true</string> <string name="p_calc_color_display" translatable="false">true</string>

View File

@ -79,13 +79,6 @@
a:summary="@string/c_numeral_bases_summary" a:summary="@string/c_numeral_bases_summary"
a:title="@string/c_calc_numeral_bases" /> a:title="@string/c_calc_numeral_bases" />
<org.solovyev.android.prefs.IntegerPickerDialogPreference
a:defaultValue="5"
a:key="@string/p_calc_max_calculation_time_key"
a:summary="@string/p_calc_max_calculation_time_summary"
a:title="@string/p_calc_max_calculation_time_title"
range:boundaries="3;1000" />
<android.preference.CheckBoxPreference <android.preference.CheckBoxPreference
a:key="calculations_calculate_on_fly" a:key="calculations_calculate_on_fly"
a:summary="@string/p_calculations_calculate_on_fly_summary" a:summary="@string/p_calculations_calculate_on_fly_summary"