This commit is contained in:
Sergey Solovyev 2011-12-19 01:48:16 +04:00
parent 452f5ebde7
commit 03cc14a097
10 changed files with 110 additions and 23 deletions

View File

@ -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"/>

View File

@ -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"/>

View File

@ -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"/>

View File

@ -202,7 +202,7 @@
<b>Ejemplos:</b>\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
<b>¿Soporta C+ %?</b>\n\n
@ -242,7 +242,7 @@
<b>Ejemplos:</b>\n\n
(2i + 1) ^ = -3 + 4i\n
(2i + 1) ^ 2 = -3 + 4i\n
e ^ i = 0.5403 + 0.84147i\n\n
<b>¿Puede C+ dibujar gráficas de las funciones?</b>\n\n

View File

@ -198,7 +198,7 @@ Attualente C++ non supporta questa funzione ma è possibile utilizzare le funzio
<b>Esempi:</b>\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
<b>C++ supporta la %?</b>\n
@ -233,7 +233,7 @@ Sì, basta inserire una espressione complessa (usando i o √(-1) come numero im
\n
<b>Esempi:</b>\n
\n
(2i + 1) ^ = -3 + 4i\n
(2i + 1) ^ 2 = -3 + 4i\n
e ^ i = 0.5403 + 0.84147i\n
\n
<b>C++ può disegnare i grafici delle funzioni?</b>\n

View File

@ -213,7 +213,7 @@
<b>Примеры:</b>\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
<b>Поддерживает ли К++ проценты?</b>\n
@ -248,7 +248,7 @@ deg(4.67748) = 268\n
\n
<b>Примеры:</b>\n
\n
(2i + 1) ^ = -3 + 4i\n
(2i + 1) ^ 2 = -3 + 4i\n
e ^ i = 0.5403 + 0.84147i\n
\n
<b>Умеет ли К++ строить графики функций?</b>\n
@ -291,4 +291,21 @@ e ^ i = 0.5403 + 0.84147i\n
<string name="c_swipe_distance">Длина свайпа для клавиш</string>
<string name="c_swipe_distance_summary">Устанавливает длину свайпа для клавиш которые поддерживают дополнительные действия по свайпу</string>
<string name="c_comment">Комментарий</string>
<string name="c_history_item_saved">Сохранено</string>
<string name="c_history_item_not_saved">Не сохранено</string>
<string name="c_expression_copied">Выражение скопировано в буфер!</string>
<string name="c_history_item_status">Статус: </string>
<string name="c_history_item_comment">Комментарий: </string>
<string name="c_use_expression">Использовать</string>
<string name="c_copy_expression">Копировать выражение</string>
<string name="c_copy_result">Копировать результат</string>
<string name="c_history_expression">Значение</string>
<string name="c_history_item_already_saved">Сохранено (см. вкладку \'Сохранённая история\')</string>
<string name="c_history_comment">Комментарий</string>
<string name="c_save_history">Сохранить</string>
<string name="c_edit_history">Изменить</string>
<string name="c_edit">Изменить</string>
<string name="c_saved_history">Сохранённая история</string>
</resources>

View File

@ -216,7 +216,7 @@ Also you can use deg() and rad() functions and ° operator to convert degrees to
<b>Examples:</b>\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
<b>Does C++ support %?</b>\n
@ -251,7 +251,7 @@ Yes, just enter complex expression (using i or √(-1) as imaginary number).\n
\n
<b>Examples:</b>\n
\n
(2i + 1) ^ = -3 + 4i\n
(2i + 1) ^ 2 = -3 + 4i\n
e ^ i = 0.5403 + 0.84147i\n
\n
<b>Can C++ plot graph of the function?</b>\n
@ -302,7 +302,7 @@ Check the \'Round result\' preference in application settings - it should be tur
<string name="c_comment">Comment</string>
<string name="c_history_item_saved">Saved</string>
<string name="c_history_item_not_saved">Not saved</string>
<string name="c_expression_copied">Expression copied to the clipboard</string>
<string name="c_expression_copied">Expression copied to the clipboard!</string>
<string name="c_history_item_status">Status: </string>
<string name="c_history_item_comment">Comment: </string>
<string name="c_use_expression">Use</string>

View File

@ -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<CalculatorH
if (notSystemConstants.size() > 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<CalculatorDisplayMenuItem> menu = new EnumMenu<CalculatorDisplayMenuItem>(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<CalculatorDisplayMenuData> 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<CalculatorH
}
}
}
private static class CalculatorDisplayMenuData {
@NotNull
private final CalculatorDisplay display;
@NotNull
private final Generic result;
@NotNull
private final Set<Constant> notSystemConstants;
private CalculatorDisplayMenuData(@NotNull CalculatorDisplay display, @NotNull Generic result, @NotNull Set<Constant> 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<Constant> getNotSystemConstants() {
return notSystemConstants;
}
}
private static enum CalculatorDisplayMenuItem implements AMenuItem<CalculatorDisplayMenuData> {
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;
}
}
}

View File

@ -325,7 +325,7 @@ public class DirectionDragButton extends DragButton {
}
protected static int getDefaultDirectionTextAlpha() {
return 100;
return 120;
}
@Nullable

View File

@ -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<CalculatorHistoryState>(null)));
}