Calculation time preference removed
This commit is contained in:
parent
5ba8937f06
commit
6b89deee80
@ -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<IConstant> getVarsRegistry();
|
||||
|
||||
@Nonnull
|
||||
CalculatorMathRegistry<Function> getFunctionsRegistry();
|
||||
|
||||
@Nonnull
|
||||
CalculatorMathRegistry<Operator> getOperatorsRegistry();
|
||||
|
||||
@Nonnull
|
||||
CalculatorMathRegistry<Operator> 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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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> 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<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>();
|
||||
|
||||
@ -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
|
||||
|
@ -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" 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" translatable="false">true</string>
|
||||
|
||||
|
@ -79,13 +79,6 @@
|
||||
a:summary="@string/c_numeral_bases_summary"
|
||||
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
|
||||
a:key="calculations_calculate_on_fly"
|
||||
a:summary="@string/p_calculations_calculate_on_fly_summary"
|
||||
|
Loading…
Reference in New Issue
Block a user