text + some fixes

This commit is contained in:
Sergey Solovyev 2011-12-24 21:20:51 +04:00
parent c67de4117a
commit 4cdceca650
15 changed files with 81 additions and 47 deletions

View File

@ -11,7 +11,7 @@
a:text="@string/c_history_button" a:text="@string/c_history_button"
c:textUp="@string/c_undo" c:textUp="@string/c_undo"
c:textDown="@string/c_redo" c:textDown="@string/c_redo"
c:directionTextScale="0.3" c:directionTextScale="0.27"
style="?controlButtonStyle" style="?controlButtonStyle"
a:textStyle="bold" a:textStyle="bold"
a:onClick="historyButtonClickHandler"/> a:onClick="historyButtonClickHandler"/>

View File

@ -18,6 +18,7 @@
<string name="c_fun_description_acot">Arccotangente - El inverso de la función cotangente.</string> <string name="c_fun_description_acot">Arccotangente - El inverso de la función cotangente.</string>
<string name="c_fun_description_ln">Logaritmo neperiano - logaritmo de base e.</string> <string name="c_fun_description_ln">Logaritmo neperiano - logaritmo de base e.</string>
<string name="c_fun_description_lg">Decadic logaritmo - logaritmo de base 10.</string> <string name="c_fun_description_lg">Decadic logaritmo - logaritmo de base 10.</string>
<string name="c_fun_description_log">Logaritmo - logaritmo de la base especificada.</string>
<string name="c_fun_description_exp">Función exponencial.</string> <string name="c_fun_description_exp">Función exponencial.</string>
<string name="c_fun_description_sqrt">Función Raíz cuadrado.</string> <string name="c_fun_description_sqrt">Función Raíz cuadrado.</string>
<string name="c_fun_description_cubic">Función Raíz cuadrada.</string> <string name="c_fun_description_cubic">Función Raíz cuadrada.</string>

View File

@ -120,8 +120,8 @@
<string name="c_empty_var_error">No se puede crear una constante vacía!</string> <string name="c_empty_var_error">No se puede crear una constante vacía!</string>
<string name="c_not_valid_result">El resultado actual no es válido!</string> <string name="c_not_valid_result">El resultado actual no es válido!</string>
<!--
<string name="c_plot_graph">Graph</string> <string name="c_plot_graph">Gráfico</string>
<string name="c_min_x_value">From</string> <string name="c_min_x_value">From</string>
<string name="c_max_x_value">To</string> <string name="c_max_x_value">To</string>
@ -129,25 +129,28 @@
<string name="c_swipe_distance_summary">Sets swipe distance for buttons that support additional swipe actions</string> <string name="c_swipe_distance_summary">Sets swipe distance for buttons that support additional swipe actions</string>
<string name="c_comment">Comment</string> <string name="c_comment">Comment</string>
<string name="c_history_item_saved">Saved</string> <string name="c_history_item_saved">Guardado</string>
<string name="c_history_item_not_saved">Not saved</string> <string name="c_history_item_not_saved">No se guarda</string>
<string name="c_expression_copied">Expression copied to the clipboard!</string> <string name="c_expression_copied">Expresión copiada en el portapapeles!</string>
<string name="c_history_item_status">Status: </string> <string name="c_history_item_status">Estado: </string>
<string name="c_history_item_comment">Comment: </string> <string name="c_history_item_comment">Comentario: </string>
<string name="c_use">Use</string> <string name="c_use">Utilizar</string>
<string name="c_copy_expression">Copy expression</string> <string name="c_copy_expression">Copia de la expresión</string>
<string name="c_copy_result">Copy result</string> <string name="c_copy_result">Copia resultado</string>
<string name="c_history_expression">Value</string> <string name="c_history_expression">Valor</string>
<string name="c_history_item_already_saved">Saved (see \'Saved history\' tab)</string> <string name="c_history_item_already_saved">Salvo (ver \'La historia guardada\' ficha)</string>
<string name="c_history_comment">Comment</string> <string name="c_history_comment">Comentario</string>
<string name="c_save_history">Save history</string> <string name="c_save_history">Guardar el historial de</string>
<string name="c_edit_history">Modify history</string> <string name="c_edit_history">Modificar la historia</string>
<string name="c_edit">Modify</string> <string name="c_edit">modificar</string>
<string name="c_saved_history">Saved history</string> <string name="c_saved_history">La historia guardada</string>
<string name="c_history_already_saved">La historia se salvó ya!</string>
<string name="c_history_must_be_saved">La historia debe ser salvado antes de editar!</string>
<string name="c_history_was_removed">La historia se ha eliminado correctamente!</string>
<string name="c_history_saved">La historia se ha guardado correctamente!</string>
<string name="c_copy_description">Сopia de la descripción</string>
<string name="c_copy_value">Сopia el valor</string>
<string name="c_history_already_saved">History was already saved!</string>
<string name="c_history_must_be_saved">History must be saved before editing!</string>
<string name="c_history_was_removed">History was successfully removed!</string>
<string name="c_history_saved">History was successfully saved!</string>
-->
</resources> </resources>

View File

@ -18,6 +18,7 @@
<string name="c_fun_description_acot">Arccotangente - inversa della funzione cotangente.</string> <string name="c_fun_description_acot">Arccotangente - inversa della funzione cotangente.</string>
<string name="c_fun_description_ln">Logaritmo naturale - logaritmo in base e.</string> <string name="c_fun_description_ln">Logaritmo naturale - logaritmo in base e.</string>
<string name="c_fun_description_lg">Logaritmo decimale - logaritmo in base 10.</string> <string name="c_fun_description_lg">Logaritmo decimale - logaritmo in base 10.</string>
<string name="c_fun_description_log">Logaritmo - logaritmo nella base specificata.</string>
<string name="c_fun_description_exp">Funzione esponenziale.</string> <string name="c_fun_description_exp">Funzione esponenziale.</string>
<string name="c_fun_description_sqrt">Funzione radice quadrata.</string> <string name="c_fun_description_sqrt">Funzione radice quadrata.</string>
<string name="c_fun_description_cubic">Funzione radice cubica.</string> <string name="c_fun_description_cubic">Funzione radice cubica.</string>

View File

@ -150,4 +150,7 @@
<string name="c_history_was_removed">La storia è stata rimossa con successo!</string> <string name="c_history_was_removed">La storia è stata rimossa con successo!</string>
<string name="c_history_saved">La storia è stata salvata correttamente!</string> <string name="c_history_saved">La storia è stata salvata correttamente!</string>
<string name="c_copy_description">Сopia descrizione</string>
<string name="c_copy_value">Сopia il valore</string>
</resources> </resources>

View File

@ -16,7 +16,7 @@
Если вам понравилось приложение -\nпоставьте 5 звёздочек в\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">андроид.маркете</a>\n\n Если вам понравилось приложение -\nпоставьте 5 звёздочек в\n<a href="https://market.android.com/details?id=org.solovyev.android.calculator">андроид.маркете</a>\n\n
Спасибо тем, кто переводил Калькулятор++:\n Спасибо тем, кто переводил Калькулятор++:\n
на итальянский - Gabriele Ravanetti\n на итальянский - Gabriele Ravanetti\n
на испанский - Jordi Luna\т\n на испанский - Jordi Luna\n\n
Это приложение использует следующие открытые библиотеки:\n Это приложение использует следующие открытые библиотеки:\n
<a href="http://simple.sourceforge.net">Simple (XML serialization)</a>\n <a href="http://simple.sourceforge.net">Simple (XML serialization)</a>\n
<a href="http://meditorworld.appspot.com/meditor.txt">JSCL</a>\n <a href="http://meditorworld.appspot.com/meditor.txt">JSCL</a>\n

View File

@ -18,6 +18,7 @@
<string name="c_fun_description_acot">Арккотангенс - обратная функция к котангенсу.</string> <string name="c_fun_description_acot">Арккотангенс - обратная функция к котангенсу.</string>
<string name="c_fun_description_ln">Натуральный логарифм - логарифм по основанию e.</string> <string name="c_fun_description_ln">Натуральный логарифм - логарифм по основанию e.</string>
<string name="c_fun_description_lg">Десятичный логарифм - логарифм по основанию 10.</string> <string name="c_fun_description_lg">Десятичный логарифм - логарифм по основанию 10.</string>
<string name="c_fun_description_log">Логирифм по заданному основанию.</string>
<string name="c_fun_description_exp">Экспонента.</string> <string name="c_fun_description_exp">Экспонента.</string>
<string name="c_fun_description_sqrt">Функция квадратного корня.</string> <string name="c_fun_description_sqrt">Функция квадратного корня.</string>
<string name="c_fun_description_cubic">Функция кубического корня.</string> <string name="c_fun_description_cubic">Функция кубического корня.</string>

View File

@ -150,4 +150,7 @@
<string name="c_history_was_removed">История успешно удалена!</string> <string name="c_history_was_removed">История успешно удалена!</string>
<string name="c_history_saved">История успешно сохранена!</string> <string name="c_history_saved">История успешно сохранена!</string>
<string name="c_copy_description">Копироват описание</string>
<string name="c_copy_value">Копировать значение</string>
</resources> </resources>

View File

@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<declare-styleable name="DragButton"> <declare-styleable name="DirectionDragButton">
<attr name="textUp" format="string"/> <attr name="textUp" format="string"/>
<attr name="textDown" format="string"/> <attr name="textDown" format="string"/>
<attr name="textRight" format="string"/> <attr name="textRight" format="string"/>
<attr name="textLeft" format="string"/> <attr name="textLeft" format="string"/>
<attr name="directionTextScale" format="string"/> <attr name="directionTextScale" format="string"/>
<attr name="directionTextAlpha" format="integer"/>
</declare-styleable>
<declare-styleable name="DragButton">
<attr name="hTextPosition" format="float"/> <attr name="hTextPosition" format="float"/>
</declare-styleable> </declare-styleable>

View File

@ -18,6 +18,7 @@
<string name="c_fun_description_acot">Arccotangent - the inverse of cotangent function.</string> <string name="c_fun_description_acot">Arccotangent - the inverse of cotangent function.</string>
<string name="c_fun_description_ln">Natural logarithm - logarithm the base e.</string> <string name="c_fun_description_ln">Natural logarithm - logarithm the base e.</string>
<string name="c_fun_description_lg">Decadic logarithm - logarithm the base 10.</string> <string name="c_fun_description_lg">Decadic logarithm - logarithm the base 10.</string>
<string name="c_fun_description_log">Logarithm - logarithm the specified base.</string>
<string name="c_fun_description_exp">Exponential function.</string> <string name="c_fun_description_exp">Exponential function.</string>
<string name="c_fun_description_sqrt">Square root function.</string> <string name="c_fun_description_sqrt">Square root function.</string>
<string name="c_fun_description_cubic">Cubic root function.</string> <string name="c_fun_description_cubic">Cubic root function.</string>

View File

@ -58,7 +58,7 @@ public class AndroidFunctionsMathRegistry extends AbstractAndroidMathRegistry<Fu
} }
}, },
common(R.string.c_fun_category_common, 100) { common(R.string.c_fun_category_common, 50) {
@Override @Override
boolean isInCategory(@NotNull Function function) { boolean isInCategory(@NotNull Function function) {
for (Category category : values()) { for (Category category : values()) {
@ -120,7 +120,7 @@ public class AndroidFunctionsMathRegistry extends AbstractAndroidMathRegistry<Fu
public void load(@Nullable Context context, @Nullable SharedPreferences preferences) { public void load(@Nullable Context context, @Nullable SharedPreferences preferences) {
super.load(context, preferences); super.load(context, preferences);
add(new CustomFunction.Builder(true, "log", new String[]{"a", "b"}, "ln(b)/ln(a)")); add(new CustomFunction.Builder(true, "log", new String[]{"base", "x"}, "ln(x)/ln(base)"));
} }
@NotNull @NotNull

View File

@ -37,7 +37,7 @@ public class AngleUnitsButton extends DirectionDragButton {
directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color)); directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color));
} else { } else {
directionTextPaint.setColor(resources.getColor(R.color.default_text_color)); directionTextPaint.setColor(resources.getColor(R.color.default_text_color));
directionTextPaint.setAlpha(getDefaultDirectionTextAlpha()); directionTextPaint.setAlpha(getDirectionTextAlpha());
} }
} }
} }

View File

@ -23,6 +23,7 @@ package org.solovyev.android.view.widgets;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
@ -64,7 +65,6 @@ public class ColorButton extends Button {
private static final float H_TEXT_POSITION_DEFAULT_VALUE = 0.5f; private static final float H_TEXT_POSITION_DEFAULT_VALUE = 0.5f;
// todo serso: check - currently not worked
private float hTextPosition = H_TEXT_POSITION_DEFAULT_VALUE; private float hTextPosition = H_TEXT_POSITION_DEFAULT_VALUE;
public ColorButton(Context context, AttributeSet attrs) { public ColorButton(Context context, AttributeSet attrs) {
@ -74,6 +74,22 @@ public class ColorButton extends Button {
public ColorButton(Context context, AttributeSet attrs, boolean init) { public ColorButton(Context context, AttributeSet attrs, boolean init) {
super(context, attrs); super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs, org.solovyev.android.calculator.R.styleable.DragButton);
final int N = a.getIndexCount();
for (int i = 0; i < N; i++) {
int attr = a.getIndex(i);
final String attrValue = a.getString(attr);
if (!StringUtils.isEmpty(attrValue)) {
switch (attr) {
case R.styleable.DragButton_hTextPosition:
this.hTextPosition = Float.valueOf(attrValue);
break;
}
}
}
if (init) { if (init) {
init(context); init(context);
} }
@ -219,14 +235,6 @@ public class ColorButton extends Button {
this.onClickListener.onClick(this); this.onClickListener.onClick(this);
} }
public float getHTextPosition() {
return hTextPosition;
}
public void setHTextPosition(float hTextPosition) {
this.hTextPosition = hTextPosition;
}
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
boolean result = super.onTouchEvent(event); boolean result = super.onTouchEvent(event);

View File

@ -35,6 +35,9 @@ public class DirectionDragButton extends DragButton {
@NotNull @NotNull
private final static Float DEFAULT_DIRECTION_TEXT_SCALE_FLOAT = 0.33f; private final static Float DEFAULT_DIRECTION_TEXT_SCALE_FLOAT = 0.33f;
@NotNull
private final static Integer DEFAULT_DIRECTION_TEXT_ALPHA = 140;
@NotNull @NotNull
private final static String DEFAULT_DIRECTION_TEXT_SCALE = "0.33;0.33;0.33;0.33"; private final static String DEFAULT_DIRECTION_TEXT_SCALE = "0.33;0.33;0.33;0.33";
@ -106,7 +109,7 @@ public class DirectionDragButton extends DragButton {
up(DragDirection.up, 0) { up(DragDirection.up, 0) {
@Override @Override
public int getAttributeId() { public int getAttributeId() {
return R.styleable.DragButton_textUp; return R.styleable.DirectionDragButton_textUp;
} }
@NotNull @NotNull
@ -118,7 +121,7 @@ public class DirectionDragButton extends DragButton {
down(DragDirection.down, 2) { down(DragDirection.down, 2) {
@Override @Override
public int getAttributeId() { public int getAttributeId() {
return R.styleable.DragButton_textDown; return R.styleable.DirectionDragButton_textDown;
} }
@NotNull @NotNull
@ -130,7 +133,7 @@ public class DirectionDragButton extends DragButton {
left(DragDirection.left, 3) { left(DragDirection.left, 3) {
@Override @Override
public int getAttributeId() { public int getAttributeId() {
return R.styleable.DragButton_textLeft; return R.styleable.DirectionDragButton_textLeft;
} }
@NotNull @NotNull
@ -143,7 +146,7 @@ public class DirectionDragButton extends DragButton {
right(DragDirection.right, 1) { right(DragDirection.right, 1) {
@Override @Override
public int getAttributeId() { public int getAttributeId() {
return R.styleable.DragButton_textRight; return R.styleable.DirectionDragButton_textRight;
} }
@NotNull @NotNull
@ -230,6 +233,9 @@ public class DirectionDragButton extends DragButton {
@NotNull @NotNull
private String directionTextScale = DEFAULT_DIRECTION_TEXT_SCALE; private String directionTextScale = DEFAULT_DIRECTION_TEXT_SCALE;
@NotNull
private Integer directionTextAlpha = DEFAULT_DIRECTION_TEXT_ALPHA;
private boolean initialized = false; private boolean initialized = false;
public DirectionDragButton(Context context, @NotNull AttributeSet attrs) { public DirectionDragButton(Context context, @NotNull AttributeSet attrs) {
@ -239,7 +245,7 @@ public class DirectionDragButton extends DragButton {
private void init(@NotNull Context context, @NotNull AttributeSet attrs) { private void init(@NotNull Context context, @NotNull AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(attrs, org.solovyev.android.calculator.R.styleable.DragButton); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.DirectionDragButton);
final int N = a.getIndexCount(); final int N = a.getIndexCount();
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
@ -249,9 +255,12 @@ public class DirectionDragButton extends DragButton {
if (!StringUtils.isEmpty(attrValue)) { if (!StringUtils.isEmpty(attrValue)) {
switch (attr) { switch (attr) {
case R.styleable.DragButton_directionTextScale: case R.styleable.DirectionDragButton_directionTextScale:
this.directionTextScale = attrValue; this.directionTextScale = attrValue;
break; break;
case R.styleable.DirectionDragButton_directionTextAlpha:
this.directionTextAlpha = Integer.valueOf(attrValue);
break;
default: default:
// try drag direction text // try drag direction text
for (GuiDragDirection guiDragDirection : GuiDragDirection.values()) { for (GuiDragDirection guiDragDirection : GuiDragDirection.values()) {
@ -318,14 +327,14 @@ public class DirectionDragButton extends DragButton {
final TextPaint directionTextPaint = new TextPaint(basePaint); final TextPaint directionTextPaint = new TextPaint(basePaint);
directionTextPaint.setColor(resources.getColor(R.color.button_text_color)); directionTextPaint.setColor(resources.getColor(R.color.button_text_color));
directionTextPaint.setAlpha(getDefaultDirectionTextAlpha()); directionTextPaint.setAlpha(getDirectionTextAlpha());
directionTextPaint.setTextSize(basePaint.getTextSize() * directionTextData.getTextScale()); directionTextPaint.setTextSize(basePaint.getTextSize() * directionTextData.getTextScale());
directionTextData.setPaint(directionTextPaint); directionTextData.setPaint(directionTextPaint);
} }
protected static int getDefaultDirectionTextAlpha() { protected int getDirectionTextAlpha() {
return 120; return directionTextAlpha;
} }
@Nullable @Nullable

View File

@ -37,7 +37,7 @@ public class NumeralBasesButton extends DirectionDragButton {
directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color)); directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color));
} else { } else {
directionTextPaint.setColor(resources.getColor(R.color.default_text_color)); directionTextPaint.setColor(resources.getColor(R.color.default_text_color));
directionTextPaint.setAlpha(getDefaultDirectionTextAlpha()); directionTextPaint.setAlpha(getDirectionTextAlpha());
} }
} }
} }