diff --git a/res/layout/calc_history_button.xml b/res/layout/calc_history_button.xml index 5f30f01b..5b604df1 100644 --- a/res/layout/calc_history_button.xml +++ b/res/layout/calc_history_button.xml @@ -11,6 +11,7 @@ a:text="@string/c_history_button" c:textUp="@string/c_undo" c:textDown="@string/c_redo" + c:directionTextScale="0.3" style="?controlButtonStyle" a:textStyle="bold" a:onClick="historyButtonClickHandler"/> \ No newline at end of file diff --git a/res/layout/calc_round_brackets_button.xml b/res/layout/calc_round_brackets_button.xml index 9f72a781..e8fe401b 100644 --- a/res/layout/calc_round_brackets_button.xml +++ b/res/layout/calc_round_brackets_button.xml @@ -13,6 +13,6 @@ a:text="()" c:textDown=")" c:textLeft="(…)" - c:directionTextScale="0.5" + c:directionTextScale="0.5;0.5;0.5;0.33" style="?digitButtonStyle" a:onClick="digitButtonClickHandler"/> \ No newline at end of file diff --git a/res/layout/calc_six_digit_button.xml b/res/layout/calc_six_digit_button.xml index f81f525a..c534dfc2 100644 --- a/res/layout/calc_six_digit_button.xml +++ b/res/layout/calc_six_digit_button.xml @@ -14,5 +14,6 @@ c:textLeft="F" c:textRight="grad" c:textDown="rad" + c:directionTextScale="0.33;0.30;0.33;0.33" style="?digitButtonStyle" a:onClick="digitButtonClickHandler"/> \ No newline at end of file diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index bd484c7e..927a76b7 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -202,7 +202,7 @@ Ejemplos:\n 268° = 4.67748\n 30.21° = 0.52726\n - rad(30, 21, 0) = 0.52726\n + rad(30, 21, 0) = 0.52971\n deg(4.67748) = 268\n\n ¿Soporta C+ %?\n\n @@ -242,7 +242,7 @@ Ejemplos:\n\n - (2i + 1) ^ = -3 + 4i\n + (2i + 1) ^ 2 = -3 + 4i\n e ^ i = 0.5403 + 0.84147i\n\n ¿Puede C+ dibujar gráficas de las funciones?\n\n diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index b8549f57..89da8588 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -198,7 +198,7 @@ Attualente C++ non supporta questa funzione ma è possibile utilizzare le funzio Esempi:\n 268° = 4.67748\n 30.21° = 0.52726\n -rad(30, 21, 0) = 0.52726\n +rad(30, 21, 0) = 0.52971\n deg(4.67748) = 268\n \n C++ supporta la %?\n @@ -233,7 +233,7 @@ Sì, basta inserire una espressione complessa (usando i o √(-1) come numero im \n Esempi:\n \n -(2i + 1) ^ = -3 + 4i\n +(2i + 1) ^ 2 = -3 + 4i\n e ^ i = 0.5403 + 0.84147i\n \n C++ può disegnare i grafici delle funzioni?\n diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 30621e55..1d826ad3 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -213,7 +213,7 @@ Примеры:\n 268° = 4.67748\n 30.21° = 0.52726\n -rad(30, 21, 0) = 0.52726\n +rad(30, 21, 0) = 0.52971\n deg(4.67748) = 268\n \n Поддерживает ли К++ проценты?\n @@ -248,7 +248,7 @@ deg(4.67748) = 268\n \n Примеры:\n \n -(2i + 1) ^ = -3 + 4i\n +(2i + 1) ^ 2 = -3 + 4i\n e ^ i = 0.5403 + 0.84147i\n \n Умеет ли К++ строить графики функций?\n @@ -291,4 +291,21 @@ e ^ i = 0.5403 + 0.84147i\n Длина свайпа для клавиш Устанавливает длину свайпа для клавиш которые поддерживают дополнительные действия по свайпу + Комментарий + Сохранено + Не сохранено + Выражение скопировано в буфер! + Статус: + Комментарий: + Использовать + Копировать выражение + Копировать результат + Значение + Сохранено (см. вкладку \'Сохранённая история\') + Комментарий + Сохранить + Изменить + Изменить + Сохранённая история + diff --git a/res/values/strings.xml b/res/values/strings.xml index f889b39d..c41564d6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -216,7 +216,7 @@ Also you can use deg() and rad() functions and ° operator to convert degrees to Examples:\n 268° = 4.67748\n 30.21° = 0.52726\n -rad(30, 21, 0) = 0.52726\n +rad(30, 21, 0) = 0.52971\n deg(4.67748) = 268\n \n Does C++ support %?\n @@ -251,7 +251,7 @@ Yes, just enter complex expression (using i or √(-1) as imaginary number).\n \n Examples:\n \n -(2i + 1) ^ = -3 + 4i\n +(2i + 1) ^ 2 = -3 + 4i\n e ^ i = 0.5403 + 0.84147i\n \n Can C++ plot graph of the function?\n @@ -302,7 +302,7 @@ Check the \'Round result\' preference in application settings - it should be tur Comment Saved Not saved - Expression copied to the clipboard + Expression copied to the clipboard! Status: Comment: Use diff --git a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java index 659ab3c6..70b9c8b3 100644 --- a/src/main/java/org/solovyev/android/calculator/CalculatorModel.java +++ b/src/main/java/org/solovyev/android/calculator/CalculatorModel.java @@ -31,8 +31,8 @@ import org.solovyev.android.calculator.model.CalculatorEngine; import org.solovyev.android.calculator.model.CalculatorEvalException; import org.solovyev.android.calculator.model.CalculatorParseException; import org.solovyev.android.calculator.model.Var; -import org.solovyev.android.view.CursorControl; -import org.solovyev.android.view.HistoryControl; +import org.solovyev.android.view.*; +import org.solovyev.android.view.prefs.ResourceCache; import org.solovyev.common.msg.Message; import org.solovyev.common.utils.CollectionsUtils; import org.solovyev.common.utils.MutableObject; @@ -396,21 +396,19 @@ public enum CalculatorModel implements CursorControl, HistoryControl 1) { copyResult(activity, cd); } else { - final CharSequence[] items = {activity.getText(R.string.c_plot), activity.getText(R.string.c_copy)}; - AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setItems(items, new DialogInterface.OnClickListener() { + final AMenu menu = new EnumMenu(CalculatorDisplayMenuItem.class); + + final AlertDialog.Builder menuBuilder = new AlertDialog.Builder(activity); + menuBuilder.setItems(menu.getMenuCaptions(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { - if (item == 0) { - final Constant constant = CollectionsUtils.getFirstCollectionElement(notSystemConstants); - assert constant != null; - CalculatorActivityLauncher.plotGraph(activity, genericResult, constant); - } else if ( item == 1 ) { - copyResult(activity, cd); + final AMenuItem menuItem = menu.itemAt(item); + if ( menuItem != null ){ + menuItem.doAction(new CalculatorDisplayMenuData(cd, genericResult, notSystemConstants), activity); } } }); - builder.create().show(); + menuBuilder.create().show(); } } else { @@ -434,4 +432,68 @@ public enum CalculatorModel implements CursorControl, HistoryControl notSystemConstants; + + private CalculatorDisplayMenuData(@NotNull CalculatorDisplay display, @NotNull Generic result, @NotNull Set notSystemConstants) { + this.display = display; + this.result = result; + this.notSystemConstants = notSystemConstants; + } + + @NotNull + public CalculatorDisplay getDisplay() { + return display; + } + + @NotNull + public Generic getResult() { + return result; + } + + @NotNull + public Set getNotSystemConstants() { + return notSystemConstants; + } + } + + private static enum CalculatorDisplayMenuItem implements AMenuItem { + plot("c_plot"){ + @Override + public void doAction(@NotNull CalculatorDisplayMenuData data, @NotNull Context context) { + final Constant constant = CollectionsUtils.getFirstCollectionElement(data.getNotSystemConstants()); + assert constant != null; + CalculatorActivityLauncher.plotGraph(context, data.getResult(), constant); + } + }, + copy("c_copy"){ + @Override + public void doAction(@NotNull CalculatorDisplayMenuData data, @NotNull Context context) { + copyResult(context, data.getDisplay()); + } + }; + + private final String captionId; + + CalculatorDisplayMenuItem(@NotNull String captionId) { + + this.captionId = captionId; + } + + @NotNull + @Override + public String getCaption() { + final String caption = ResourceCache.instance.getCaption(captionId); + return caption == null ? name() : caption; + } + } } diff --git a/src/main/java/org/solovyev/android/view/widgets/DirectionDragButton.java b/src/main/java/org/solovyev/android/view/widgets/DirectionDragButton.java index b787824f..7e849d9b 100644 --- a/src/main/java/org/solovyev/android/view/widgets/DirectionDragButton.java +++ b/src/main/java/org/solovyev/android/view/widgets/DirectionDragButton.java @@ -325,7 +325,7 @@ public class DirectionDragButton extends DragButton { } protected static int getDefaultDirectionTextAlpha() { - return 100; + return 120; } @Nullable diff --git a/src/test/java/org/solovyev/android/calculator/history/HistoryUtilsTest.java b/src/test/java/org/solovyev/android/calculator/history/HistoryUtilsTest.java index 7f73d43e..7f0b0311 100644 --- a/src/test/java/org/solovyev/android/calculator/history/HistoryUtilsTest.java +++ b/src/test/java/org/solovyev/android/calculator/history/HistoryUtilsTest.java @@ -202,6 +202,12 @@ public class HistoryUtilsTest { Assert.assertEquals(history.getStates().size(), historyFromXml.getStates().size()); + for (CalculatorHistoryState historyState : history.getStates()) { + historyState.setId(0); + } + for (CalculatorHistoryState historyState : historyFromXml.getStates()) { + historyState.setId(0); + } Assert.assertTrue(EqualsTool.areEqual(history.getStates(), historyFromXml.getStates(), new CollectionEqualizer(null))); }