diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java
index 0d911403..ef3f49a1 100644
--- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java
+++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java
@@ -16,7 +16,8 @@ public interface CalculatorLocator {
@NotNull CalculatorNotifier notifier,
@NotNull CalculatorHistory history,
@NotNull CalculatorLogger logger,
- @NotNull CalculatorPreferenceService preferenceService);
+ @NotNull CalculatorPreferenceService preferenceService,
+ @NotNull CalculatorKeyboard keyboard);
@NotNull
Calculator getCalculator();
diff --git a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java
index 68d519ab..e427a45e 100644
--- a/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java
+++ b/calculatorpp-core/src/main/java/org/solovyev/android/calculator/CalculatorLocatorImpl.java
@@ -53,7 +53,8 @@ public class CalculatorLocatorImpl implements CalculatorLocator {
@NotNull CalculatorNotifier notifier,
@NotNull CalculatorHistory history,
@NotNull CalculatorLogger logger,
- @NotNull CalculatorPreferenceService preferenceService) {
+ @NotNull CalculatorPreferenceService preferenceService,
+ @NotNull CalculatorKeyboard keyboard) {
this.calculator = calculator;
this.calculatorEngine = engine;
@@ -65,7 +66,7 @@ public class CalculatorLocatorImpl implements CalculatorLocator {
calculatorEditor = new CalculatorEditorImpl(this.calculator);
calculatorDisplay = new CalculatorDisplayImpl(this.calculator);
- calculatorKeyboard = new CalculatorKeyboardImpl(this.calculator);
+ calculatorKeyboard = keyboard;
}
@NotNull
diff --git a/calculatorpp-core/src/test/java/org/solovyev/android/calculator/AbstractCalculatorTest.java b/calculatorpp-core/src/test/java/org/solovyev/android/calculator/AbstractCalculatorTest.java
index 80547dbe..4483804e 100644
--- a/calculatorpp-core/src/test/java/org/solovyev/android/calculator/AbstractCalculatorTest.java
+++ b/calculatorpp-core/src/test/java/org/solovyev/android/calculator/AbstractCalculatorTest.java
@@ -11,7 +11,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory;
public class AbstractCalculatorTest {
protected void setUp() throws Exception {
- CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
+ CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), CalculatorTestUtils.newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
CalculatorLocatorImpl.getInstance().getEngine().init();
}
diff --git a/calculatorpp-core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java b/calculatorpp-core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
index 01f02041..d024db58 100644
--- a/calculatorpp-core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
+++ b/calculatorpp-core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
@@ -23,7 +23,7 @@ public class CalculatorTestUtils {
public static final int TIMEOUT = 3;
public static void staticSetUp() throws Exception {
- CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
+ CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
CalculatorLocatorImpl.getInstance().getEngine().init();
}
diff --git a/calculatorpp/res/layout/function_add_param.xml b/calculatorpp/res/layout/function_add_param.xml
index 9846a28e..8c1232c0 100644
--- a/calculatorpp/res/layout/function_add_param.xml
+++ b/calculatorpp/res/layout/function_add_param.xml
@@ -8,7 +8,13 @@
+
+
diff --git a/calculatorpp/res/layout/function_edit_param.xml b/calculatorpp/res/layout/function_edit_param.xml
index 9906f0de..8497312a 100644
--- a/calculatorpp/res/layout/function_edit_param.xml
+++ b/calculatorpp/res/layout/function_edit_param.xml
@@ -8,25 +8,29 @@
-
+
-
+
diff --git a/calculatorpp/res/values-ru/text_about.xml b/calculatorpp/res/values-ru/text_about.xml
index fec8cab2..1396202b 100644
--- a/calculatorpp/res/values-ru/text_about.xml
+++ b/calculatorpp/res/values-ru/text_about.xml
@@ -230,5 +230,16 @@
3. Ручные вычисления (Настройки->Настройки вычислений->Результат вычисляется…)
+
+ 1. Поддержка пользовательских функций (кнопка +f или кнопка + на экране функций)\n
+ 2. Добавлены различные размеры виджета: 3x3, 3x4, 4x4\n
+ 3. Добавлено несколько функций: re(x), im(x), √3(x), √4(x), √n(x, n)\n
+ 4. Система счисления/единицы измерения углов по умолчанию + окно с ошибками расчётов\n
+ 5. Ускорена работа приложения\n
+ 6. Исправлена проблема размера шрифта кнопок в мобильной раскладке (для планшетов)\n
+ 7. Другие исправления
+
+
+
\ No newline at end of file
diff --git a/calculatorpp/res/values/text_about.xml b/calculatorpp/res/values/text_about.xml
index f28acd0f..d06c00d9 100644
--- a/calculatorpp/res/values/text_about.xml
+++ b/calculatorpp/res/values/text_about.xml
@@ -229,4 +229,14 @@
3. Manual calculations (Preferences->Calculations Preferences->Result is calculated…)
+
+ 1. Support for user-defined functions (see +f button or + button inside functions screen)\n
+ 2. Widget in different sizes: 3x3, 3x4, 4x4\n
+ 3. Several functions added: re(x), im(x), √3(x), √4(x), √n(x, n)\n
+ 4. Default number systems/angle units + special warning dialog in case of calculations errors\n
+ 5. Performance improvements\n
+ 6. Text size in mobile layout for tablets fixed\n
+ 7. Bug fixes
+
+
\ No newline at end of file
diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorKeyboard.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorKeyboard.java
new file mode 100644
index 00000000..7b3fe6e0
--- /dev/null
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/AndroidCalculatorKeyboard.java
@@ -0,0 +1,86 @@
+package org.solovyev.android.calculator;
+
+import android.app.Activity;
+import android.app.Application;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.Vibrator;
+import android.preference.PreferenceManager;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+import org.solovyev.android.view.VibratorContainer;
+
+/**
+ * User: serso
+ * Date: 11/18/12
+ * Time: 6:05 PM
+ */
+public class AndroidCalculatorKeyboard implements CalculatorKeyboard {
+
+ @NotNull
+ private final CalculatorKeyboard calculatorKeyboard;
+
+ @NotNull
+ private final Context context;
+
+ private VibratorContainer vibrator;
+
+ public AndroidCalculatorKeyboard(@NotNull Application application,
+ @NotNull CalculatorKeyboard calculatorKeyboard) {
+ this.context = application;
+ this.calculatorKeyboard = calculatorKeyboard;
+ }
+
+ @Override
+ public void buttonPressed(@Nullable String text) {
+ vibrate();
+ calculatorKeyboard.buttonPressed(text);
+ }
+
+ private void vibrate() {
+ if (this.vibrator == null) {
+ final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+ final Vibrator vibrator = (Vibrator) context.getSystemService(Activity.VIBRATOR_SERVICE);
+
+ this.vibrator = new VibratorContainer(vibrator, preferences, 0.5f);
+ }
+
+ this.vibrator.vibrate();
+ }
+
+ @Override
+ public void roundBracketsButtonPressed() {
+ vibrate();
+ calculatorKeyboard.roundBracketsButtonPressed();
+ }
+
+ @Override
+ public void pasteButtonPressed() {
+ vibrate();
+ calculatorKeyboard.pasteButtonPressed();
+ }
+
+ @Override
+ public void clearButtonPressed() {
+ vibrate();
+ calculatorKeyboard.clearButtonPressed();
+ }
+
+ @Override
+ public void copyButtonPressed() {
+ vibrate();
+ calculatorKeyboard.copyButtonPressed();
+ }
+
+ @Override
+ public void moveCursorLeft() {
+ vibrate();
+ calculatorKeyboard.moveCursorLeft();
+ }
+
+ @Override
+ public void moveCursorRight() {
+ vibrate();
+ calculatorKeyboard.moveCursorRight();
+ }
+}
diff --git a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java
index cb6462f8..2d2701cb 100644
--- a/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java
+++ b/calculatorpp/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java
@@ -91,7 +91,8 @@ public class CalculatorApplication extends android.app.Application {
new AndroidCalculatorNotifier(this),
new AndroidCalculatorHistory(this, calculator),
new AndroidCalculatorLogger(),
- new AndroidCalculatorPreferenceService(this));
+ new AndroidCalculatorPreferenceService(this),
+ new AndroidCalculatorKeyboard(this, new CalculatorKeyboardImpl(calculator)));
CalculatorLocatorImpl.getInstance().getCalculator().init();
diff --git a/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java b/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
index 09306825..71229446 100644
--- a/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
+++ b/calculatorpp/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
@@ -15,7 +15,7 @@ import org.solovyev.android.calculator.history.CalculatorHistory;
public class CalculatorTestUtils {
public static void staticSetUp(@Nullable Context context) throws Exception {
- CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class));
+ CalculatorLocatorImpl.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class));
CalculatorLocatorImpl.getInstance().getEngine().init();
if ( context != null ) {