From 70d0c21c9e7ae788f0ea6c55222c1feaad5396fb Mon Sep 17 00:00:00 2001 From: serso Date: Sat, 10 Sep 2011 22:32:54 +0400 Subject: [PATCH] new interface implementation --- gen/org/solovyev/android/calculator/R.java | 12 ++++---- res/layout/main.xml | 28 +++++++++++-------- .../android/calculator/Preprocessor.java | 12 +++++--- .../solovyev/util/math/MathEntityType.java | 2 +- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/gen/org/solovyev/android/calculator/R.java b/gen/org/solovyev/android/calculator/R.java index 37993712..b7275ca9 100644 --- a/gen/org/solovyev/android/calculator/R.java +++ b/gen/org/solovyev/android/calculator/R.java @@ -49,25 +49,23 @@ containing a value of this type. public static final int divisionButton=0x7f090011; public static final int editText=0x7f090006; public static final int eigthDigitButton=0x7f090014; - public static final int equalsButton=0x7f090016; + public static final int equalsButton=0x7f09001d; public static final int fiveDigitButton=0x7f09000f; public static final int fourDigitButton=0x7f09000e; - public static final int historyButton=0x7f090020; - public static final int menu_item_help=0x7f090022; - public static final int menu_item_settings=0x7f090021; + public static final int historyButton=0x7f09001e; + public static final int menu_item_help=0x7f090020; + public static final int menu_item_settings=0x7f09001f; public static final int muliplicationButton=0x7f09000c; public static final int nineDigitButton=0x7f090015; - public static final int numericButton=0x7f09001e; public static final int oneDigitButton=0x7f090009; public static final int panelswitch=0x7f090008; public static final int piButton=0x7f09001c; public static final int plusButton=0x7f09000d; - public static final int pointDigitButton=0x7f09001d; + public static final int pointDigitButton=0x7f090016; public static final int resultEditText=0x7f090007; public static final int roundBracketsButton=0x7f090019; public static final int sevenDigitButton=0x7f090013; public static final int simplePad=0x7f090000; - public static final int simplifyButton=0x7f09001f; public static final int sixDigitButton=0x7f090010; public static final int sqrtButton=0x7f090017; public static final int squareBracketsButton=0x7f09001a; diff --git a/res/layout/main.xml b/res/layout/main.xml index dd3a7bd7..3a3be71d 100644 --- a/res/layout/main.xml +++ b/res/layout/main.xml @@ -101,22 +101,26 @@ + + - - + @@ -136,7 +140,7 @@ calc:textDown="}" style="@style/digitButtonStyle" a:onClick="digitButtonClickHandler"/> - @@ -145,17 +149,19 @@ - - - - + diff --git a/src/org/solovyev/android/calculator/Preprocessor.java b/src/org/solovyev/android/calculator/Preprocessor.java index f315b327..60e54bc4 100644 --- a/src/org/solovyev/android/calculator/Preprocessor.java +++ b/src/org/solovyev/android/calculator/Preprocessor.java @@ -15,8 +15,12 @@ public class Preprocessor { sb.append('('); } else if (ch == ']' || ch == '}') { sb.append(')'); - } else if ( ch == ',' ) { + } else if (ch == ',') { sb.append('.'); + } else if (ch == 'π') { + sb.append("pi"); + } else if (ch == '√') { + sb.append("sqrt"); } else { sb.append(ch); } @@ -24,8 +28,8 @@ public class Preprocessor { return sb.toString(); } - - public static String wrap (@NotNull JsclOperation operation, @NotNull String s) { - return operation.name() + "(\"" + s + "\");"; + + public static String wrap(@NotNull JsclOperation operation, @NotNull String s) { + return operation.name() + "(\"" + s + "\");"; } } diff --git a/src/org/solovyev/util/math/MathEntityType.java b/src/org/solovyev/util/math/MathEntityType.java index 248c0b63..db4e5ccb 100644 --- a/src/org/solovyev/util/math/MathEntityType.java +++ b/src/org/solovyev/util/math/MathEntityType.java @@ -19,7 +19,7 @@ public enum MathEntityType { private static final List binaryOperations = Arrays.asList('-', '+', '*', '/', '^' ); - private static final List functions = Arrays.asList("sin", "asin", "cos", "acos", "tg", "atg", "exp", "log", "ln", "mod", "sqrt"); + private static final List functions = Arrays.asList("sin", "asin", "cos", "acos", "tg", "atg", "exp", "log", "ln", "mod", "√"); private static final List groupSymbols = Arrays.asList("[]", "()", "{}");