android_calculator-15: Add numeral systems
This commit is contained in:
parent
d7935db77b
commit
04b7fcfd4c
@ -102,7 +102,14 @@
|
||||
<string name="p_rad">Радианы</string>
|
||||
<string name="p_grad">Грады</string>
|
||||
<string name="p_turns">Обороты</string>
|
||||
<string name="c_angle_units_summary">Определяет единицы измерения углов.</string>
|
||||
<string name="c_angle_units_summary">Устанавливает единицы измерения углов.</string>
|
||||
|
||||
<string name="c_calc_numeral_bases">Системы счичления</string>
|
||||
<string name="c_numeral_bases_summary">Устанавливает систему счисления для всех вводимых чисел.</string>
|
||||
<string name="p_dec">Десятичная</string>
|
||||
<string name="p_hex">Шестнадцатеричная</string>
|
||||
<string name="p_oct">Восьмиричная</string>
|
||||
<string name="p_bin">Бинарная</string>
|
||||
|
||||
<string name="c_calc_theme">Тема оформления</string>
|
||||
<string name="p_default_theme">По умолчанию</string>
|
||||
|
@ -60,4 +60,17 @@
|
||||
<item>turns</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_numeral_bases_names">
|
||||
<item>@string/p_dec</item>
|
||||
<item>@string/p_hex</item>
|
||||
<item>@string/p_oct</item>
|
||||
<item>@string/p_bin</item>
|
||||
</string-array>
|
||||
<string-array name="p_numeral_bases">
|
||||
<item>dec</item>
|
||||
<item>hex</item>
|
||||
<item>oct</item>
|
||||
<item>bin</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -30,6 +30,9 @@
|
||||
<string name="p_calc_angle_units_key">org.solovyev.android.calculator.CalculatorActivity_angle_units</string>
|
||||
<string name="p_calc_angle_units">deg</string>
|
||||
|
||||
<string name="p_calc_numeral_bases_key">org.solovyev.android.calculator.CalculatorActivity_numeral_bases</string>
|
||||
<string name="p_calc_numeral_bases">dec</string>
|
||||
|
||||
<string name="p_calc_theme_key">org.solovyev.android.calculator.CalculatorActivity_calc_theme</string>
|
||||
<string name="p_calc_theme">default_theme</string>
|
||||
|
||||
|
@ -105,6 +105,13 @@
|
||||
<string name="p_turns">Turns</string>
|
||||
<string name="c_angle_units_summary">Defines the default units for angles.</string>
|
||||
|
||||
<string name="c_calc_numeral_bases">Numeral systems</string>
|
||||
<string name="c_numeral_bases_summary">Defines the default numeral system for all input numbers.</string>
|
||||
<string name="p_dec">Decimal</string>
|
||||
<string name="p_hex">Hexadecimal</string>
|
||||
<string name="p_oct">Octal</string>
|
||||
<string name="p_bin">Binary</string>
|
||||
|
||||
<string name="c_calc_theme">Theme</string>
|
||||
<string name="p_default_theme">Default</string>
|
||||
<string name="p_violet_theme">Violet</string>
|
||||
|
@ -29,6 +29,12 @@
|
||||
a:summary="@string/c_angle_units_summary"
|
||||
a:entryValues="@array/p_angle_units"/>
|
||||
|
||||
<ListPreference a:key="@string/p_calc_numeral_bases_key"
|
||||
a:title="@string/c_calc_numeral_bases"
|
||||
a:entries="@array/p_numeral_bases_names"
|
||||
a:summary="@string/c_numeral_bases_summary"
|
||||
a:entryValues="@array/p_numeral_bases"/>
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import android.content.SharedPreferences;
|
||||
import jscl.AngleUnit;
|
||||
import jscl.JsclMathEngine;
|
||||
import jscl.MathEngine;
|
||||
import jscl.NumeralBase;
|
||||
import jscl.math.Generic;
|
||||
import jscl.math.function.Function;
|
||||
import jscl.math.operator.Operator;
|
||||
@ -48,8 +49,12 @@ public enum CalculatorEngine {
|
||||
public static final String RESULT_PRECISION_P_KEY = "org.solovyev.android.calculator.CalculatorModel_result_precision";
|
||||
public static final String RESULT_PRECISION_DEFAULT = "5";
|
||||
|
||||
public static final String NUMERAL_BASES_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_numeral_bases";
|
||||
public static final String NUMERAL_BASES_DEFAULT = "dec";
|
||||
|
||||
public static final String ANGLE_UNITS_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_angle_units";
|
||||
public static final String ANGLE_UNITS_DEFAULT = "deg";
|
||||
|
||||
public static final int DEFAULT_TIMEOUT = 3000;
|
||||
|
||||
@NotNull
|
||||
@ -285,7 +290,8 @@ public enum CalculatorEngine {
|
||||
//noinspection ConstantConditions
|
||||
this.setPrecision(integerNumberMapper.parseValue(preferences.getString(RESULT_PRECISION_P_KEY, RESULT_PRECISION_DEFAULT)));
|
||||
this.setRoundResult(preferences.getBoolean(ROUND_RESULT_P_KEY, ROUND_RESULT_DEFAULT));
|
||||
this.setDefaultAngleUnits(AngleUnit.valueOf(preferences.getString(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT)));
|
||||
this.setAngleUnits(AngleUnit.valueOf(preferences.getString(ANGLE_UNITS_P_KEY, ANGLE_UNITS_DEFAULT)));
|
||||
this.setNumeralBase(NumeralBase.valueOf(preferences.getString(NUMERAL_BASES_P_KEY, NUMERAL_BASES_DEFAULT)));
|
||||
|
||||
final String groupingSeparator = preferences.getString(GROUPING_SEPARATOR_P_KEY, GROUPING_SEPARATOR_DEFAULT);
|
||||
if (StringUtils.isEmpty(groupingSeparator)) {
|
||||
@ -337,10 +343,14 @@ public enum CalculatorEngine {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public void setDefaultAngleUnits(@NotNull AngleUnit angleUnits) {
|
||||
public void setAngleUnits(@NotNull AngleUnit angleUnits) {
|
||||
getEngine().setAngleUnits(angleUnits);
|
||||
}
|
||||
|
||||
public void setNumeralBase(@NotNull NumeralBase numeralBase) {
|
||||
getEngine().setNumeralBase(numeralBase);
|
||||
}
|
||||
|
||||
// for tests only
|
||||
void setThreadKiller(@NotNull ThreadKiller threadKiller) {
|
||||
this.threadKiller = threadKiller;
|
||||
|
@ -34,7 +34,7 @@ public class AngleUnitsButton extends DirectionDragButton {
|
||||
|
||||
if (result != null) {
|
||||
final Resources resources = getResources();
|
||||
if ( CalculatorEngine.instance.getEngine().getDefaultAngleUnit().name().equals(getDirectionText(direction)) ) {
|
||||
if ( CalculatorEngine.instance.getEngine().getAngleUnits().name().equals(getDirectionText(direction)) ) {
|
||||
result.setColor(resources.getColor(R.color.selected_angle_unit_text_color));
|
||||
} else {
|
||||
result.setColor(resources.getColor(R.color.default_text_color));
|
||||
|
Loading…
Reference in New Issue
Block a user