Minus button fix

This commit is contained in:
serso
2015-02-10 11:37:14 +01:00
parent 3d1731995a
commit d82d6f947d
7 changed files with 51 additions and 27 deletions

View File

@@ -25,15 +25,13 @@ package org.solovyev.android.calculator.math;
import jscl.JsclMathEngine;
import jscl.NumeralBase;
import jscl.math.function.Constants;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.solovyev.android.calculator.CalculatorParseException;
import org.solovyev.android.calculator.Locator;
import org.solovyev.common.JPredicate;
import org.solovyev.common.collections.Collections;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -82,16 +80,51 @@ public enum MathType {
}
},
unary_operation(500, false, false, MathGroupType.operation, "-", "="),
binary_operation(600, false, false, MathGroupType.operation, "-", "+", "*", "×", "", "/", "^") {
unary_operation(500, false, false, MathGroupType.operation, "", "-", "=") {
@Nullable
@Override
protected String getSubstituteToJscl(@Nonnull String match) {
if (match.equals("×") || match.equals("")) {
return "*";
if (match.equals("")) {
return "-";
} else {
return null;
}
}
@Nullable
@Override
protected String getSubstituteFromJscl(@Nonnull String match) {
if (match.equals("-")) {
return "";
} else {
return null;
}
}
},
binary_operation(600, false, false, MathGroupType.operation, "", "-", "+", "*", "×", "", "/", "^") {
@Nullable
@Override
protected String getSubstituteFromJscl(@Nonnull String match) {
if (match.equals("-")) {
return "";
} else {
return null;
}
}
@Override
protected String getSubstituteToJscl(@Nonnull String match) {
switch (match) {
case "×":
case "":
return "*";
case "":
return "-";
default:
return null;
}
}
},
open_group_symbol(800, true, false, MathGroupType.other, "[", "(", "{") {
@@ -149,7 +182,7 @@ public enum MathType {
digit(1125, true, true, MathGroupType.number) {
private final List<String> tokens = new ArrayList<String>(16);
private final List<String> tokens = new ArrayList<>(16);
{
for (Character character : NumeralBase.hex.getAcceptableCharacters()) {
tokens.add(character.toString());