multiplication sign fix
This commit is contained in:
parent
7af1dcdbb9
commit
ecb2f742b0
@ -127,6 +127,8 @@
|
||||
<string name="p_grouping_separator_space">Пробел ( )</string>
|
||||
<string name="c_calc_grouping_separator">Разделитель разрядов</string>
|
||||
<string name="c_calc_grouping_separator_summary">Устанавливает разделитель разрядов числа</string>
|
||||
<string name="c_calc_multiplication_sign">Знак произведения</string>
|
||||
<string name="c_calc_multiplication_sign_summary">Устанавливает знак произведения</string>
|
||||
|
||||
<string name="c_calc_layout">Раскладка</string>
|
||||
<string name="p_layout_cellphone">Телефон</string>
|
||||
|
@ -27,6 +27,12 @@
|
||||
<item>" "</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_multiplication_sign_values">
|
||||
<item>"*"</item>
|
||||
<item>"×"</item>
|
||||
<item>"∙"</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="p_layout_names">
|
||||
<item>@string/p_layout_cellphone</item>
|
||||
<item>@string/p_layout_calculator</item>
|
||||
|
@ -44,6 +44,9 @@
|
||||
<string name="p_calc_grouping_separator_key">org.solovyev.android.calculator.CalculatorActivity_calc_grouping_separator</string>
|
||||
<string name="p_calc_grouping_separator">" "</string>
|
||||
|
||||
<string name="p_calc_multiplication_sign_key">org.solovyev.android.calculator.CalculatorActivity_calc_multiplication_sign</string>
|
||||
<string name="p_calc_multiplication_sign">"×"</string>
|
||||
|
||||
<string name="p_calc_haptic_feedback_duration_key">org.solovyev.android.calculator.CalculatorActivity_calc_haptic_feedback_duration_key</string>
|
||||
<string name="p_calc_haptic_feedback_duration">" "</string>
|
||||
|
||||
|
@ -128,6 +128,8 @@
|
||||
<string name="p_grouping_separator_space">Space ( )</string>
|
||||
<string name="c_calc_grouping_separator">Grouping separator</string>
|
||||
<string name="c_calc_grouping_separator_summary">Sets grouping separator</string>
|
||||
<string name="c_calc_multiplication_sign">Multiplication sign</string>
|
||||
<string name="c_calc_multiplication_sign_summary">Sets multiplication sign</string>
|
||||
|
||||
<string name="c_calc_layout">Layout</string>
|
||||
<string name="p_layout_cellphone">Cellphone</string>
|
||||
|
@ -23,6 +23,12 @@
|
||||
a:summary="@string/c_calc_grouping_separator_summary"
|
||||
a:entryValues="@array/p_grouping_separator_values"/>
|
||||
|
||||
<ListPreference a:key="@string/p_calc_multiplication_sign_key"
|
||||
a:title="@string/c_calc_multiplication_sign"
|
||||
a:entries="@array/p_multiplication_sign_values"
|
||||
a:summary="@string/c_calc_multiplication_sign_summary"
|
||||
a:entryValues="@array/p_multiplication_sign_values"/>
|
||||
|
||||
<ListPreference a:key="@string/p_calc_angle_units_key"
|
||||
a:title="@string/c_calc_angle_units"
|
||||
a:entries="@array/p_angle_units_names"
|
||||
|
@ -19,6 +19,7 @@ import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.*;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import jscl.AngleUnit;
|
||||
@ -141,6 +142,8 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
|
||||
CalculatorEngine.instance.reset(this, preferences);
|
||||
|
||||
initMultiplicationButton();
|
||||
|
||||
preferences.registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@ -410,7 +413,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
public void digitButtonClickHandler(@NotNull View v) {
|
||||
Log.d(String.valueOf(v.getId()), "digitButtonClickHandler() for: " + v.getId() + ". Pressed: " + v.isPressed());
|
||||
calculatorModel.processDigitButtonAction(((DirectionDragButton) v).getTextMiddle());
|
||||
calculatorModel.processDigitButtonAction(((DirectionDragButton) v).getText().toString());
|
||||
}
|
||||
|
||||
@SuppressWarnings({"UnusedDeclaration"})
|
||||
@ -561,6 +564,7 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
dpclRegister.announce().onDragPreferencesChange(SimpleOnDragListener.getPreferences(preferences, this));
|
||||
|
||||
if (CalculatorEngine.GROUPING_SEPARATOR_P_KEY.equals(key) ||
|
||||
CalculatorEngine.MULTIPLICATION_SIGN_P_KEY.equals(key) ||
|
||||
CalculatorEngine.ROUND_RESULT_P_KEY.equals(key) ||
|
||||
CalculatorEngine.RESULT_PRECISION_P_KEY.equals(key) ||
|
||||
CalculatorEngine.ANGLE_UNITS_P_KEY.equals(key) ||
|
||||
@ -568,5 +572,16 @@ public class CalculatorActivity extends Activity implements FontSizeAdjuster, Sh
|
||||
CalculatorEngine.instance.reset(this, preferences);
|
||||
this.calculatorModel.evaluate();
|
||||
}
|
||||
|
||||
if ( CalculatorEngine.MULTIPLICATION_SIGN_P_KEY.equals(key) ) {
|
||||
initMultiplicationButton();
|
||||
}
|
||||
}
|
||||
|
||||
private void initMultiplicationButton() {
|
||||
final View multiplicationButton = findViewById(R.id.multiplicationButton);
|
||||
if ( multiplicationButton instanceof Button) {
|
||||
((Button) multiplicationButton).setText(CalculatorEngine.instance.getMultiplicationSign());
|
||||
}
|
||||
}
|
||||
}
|
@ -40,7 +40,11 @@ public abstract class AbstractNumberBuilder {
|
||||
* @return true if we can continue of processing of current number, if false - new number should be constructed
|
||||
*/
|
||||
protected boolean canContinue(@NotNull MathType.Result mathTypeResult) {
|
||||
return ((mathTypeResult.getMathType().getGroupType() == MathType.MathGroupType.number && numeralBaseCheck(mathTypeResult) && numeralBaseInTheStart(mathTypeResult.getMathType()) || isSignAfterE(mathTypeResult)));
|
||||
return ((mathTypeResult.getMathType().getGroupType() == MathType.MathGroupType.number && !spaceBefore(mathTypeResult) && numeralBaseCheck(mathTypeResult) && numeralBaseInTheStart(mathTypeResult.getMathType()) || isSignAfterE(mathTypeResult)));
|
||||
}
|
||||
|
||||
private boolean spaceBefore(@NotNull MathType.Result mathTypeResult) {
|
||||
return numberBuilder == null && mathTypeResult.getMatch().trim().isEmpty();
|
||||
}
|
||||
|
||||
private boolean numeralBaseInTheStart(@NotNull MathType mathType) {
|
||||
|
@ -36,6 +36,9 @@ public enum CalculatorEngine {
|
||||
|
||||
public static final String GROUPING_SEPARATOR_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_grouping_separator";
|
||||
|
||||
public static final String MULTIPLICATION_SIGN_P_KEY = "org.solovyev.android.calculator.CalculatorActivity_calc_multiplication_sign";
|
||||
public static final String MULTIPLICATION_SIGN_DEFAULT = "×";
|
||||
|
||||
public static final String ROUND_RESULT_P_KEY = "org.solovyev.android.calculator.CalculatorModel_round_result";
|
||||
public static final boolean ROUND_RESULT_DEFAULT = true;
|
||||
|
||||
@ -48,6 +51,7 @@ public enum CalculatorEngine {
|
||||
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
|
||||
@ -76,11 +80,23 @@ public enum CalculatorEngine {
|
||||
// calculation thread timeout in milliseconds, after timeout thread would be interrupted
|
||||
private int timeout = DEFAULT_TIMEOUT;
|
||||
|
||||
@NotNull
|
||||
private String multiplicationSign = MULTIPLICATION_SIGN_DEFAULT;
|
||||
|
||||
CalculatorEngine() {
|
||||
this.engine.setRoundResult(true);
|
||||
this.engine.setUseGroupingSeparator(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMultiplicationSign() {
|
||||
return multiplicationSign;
|
||||
}
|
||||
|
||||
public void setMultiplicationSign(@NotNull String multiplicationSign) {
|
||||
this.multiplicationSign = multiplicationSign;
|
||||
}
|
||||
|
||||
public static class Result {
|
||||
|
||||
@NotNull
|
||||
@ -256,6 +272,7 @@ public enum CalculatorEngine {
|
||||
this.setRoundResult(preferences.getBoolean(ROUND_RESULT_P_KEY, ROUND_RESULT_DEFAULT));
|
||||
this.setAngleUnits(getAngleUnitsFromPrefs(preferences));
|
||||
this.setNumeralBase(getNumeralBaseFromPrefs(preferences));
|
||||
this.setMultiplicationSign(preferences.getString(MULTIPLICATION_SIGN_P_KEY, MULTIPLICATION_SIGN_DEFAULT));
|
||||
|
||||
final String groupingSeparator = preferences.getString(GROUPING_SEPARATOR_P_KEY, JsclMathEngine.GROUPING_SEPARATOR_DEFAULT);
|
||||
if (StringUtils.isEmpty(groupingSeparator)) {
|
||||
|
@ -53,7 +53,7 @@ public class FromJsclSimplifyTextProcessor implements TextProcessor<String, Gene
|
||||
}
|
||||
|
||||
if (needMultiplicationSign(mathTypeBefore == null ? null : mathTypeBefore.getMathType(), mathTypeAfter == null ? null : mathTypeAfter.getMathType())) {
|
||||
sb.append("×");
|
||||
sb.append(CalculatorEngine.instance.getMultiplicationSign());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -90,7 +90,7 @@ public class ColorButton extends Button {
|
||||
feedbackPaint.setStrokeWidth(2);
|
||||
|
||||
|
||||
if (CollectionsUtils.contains(getText().toString(), Arrays.asList("+", "-", "/", "×"))) {
|
||||
if (CollectionsUtils.contains(getText().toString(), Arrays.asList("+", "-", "/", "×", "*", "∙"))) {
|
||||
getPaint().setColor(resources.getColor(R.color.button_operator_text_color));
|
||||
} else if (getText().toString().equals("C")) {
|
||||
getPaint().setColor(resources.getColor(R.color.button_ce_text_color));
|
||||
|
@ -38,9 +38,6 @@ public class DirectionDragButton extends DragButton {
|
||||
@NotNull
|
||||
private final static String DEFAULT_DIRECTION_TEXT_SCALE = "0.33;0.33;0.33;0.33";
|
||||
|
||||
@Nullable
|
||||
private String textMiddle;
|
||||
|
||||
protected static class DirectionTextData {
|
||||
|
||||
@NotNull
|
||||
@ -258,9 +255,6 @@ public class DirectionDragButton extends DragButton {
|
||||
}
|
||||
}
|
||||
|
||||
// backup text
|
||||
this.textMiddle = String.valueOf(getText());
|
||||
|
||||
super.init(context);
|
||||
initialized = true;
|
||||
}
|
||||
@ -327,11 +321,6 @@ public class DirectionDragButton extends DragButton {
|
||||
return getText(GuiDragDirection.down);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTextMiddle() {
|
||||
return textMiddle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getText(@NotNull DragDirection direction) {
|
||||
final GuiDragDirection guiDragDirection = GuiDragDirection.valueOf(direction);
|
||||
|
Loading…
Reference in New Issue
Block a user