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

@@ -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
boolean isInCategory(@NotNull Function function) {
for (Category category : values()) {
@@ -120,7 +120,7 @@ public class AndroidFunctionsMathRegistry extends AbstractAndroidMathRegistry<Fu
public void load(@Nullable Context context, @Nullable SharedPreferences 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

View File

@@ -37,7 +37,7 @@ public class AngleUnitsButton extends DirectionDragButton {
directionTextPaint.setColor(resources.getColor(R.color.selected_angle_unit_text_color));
} else {
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.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
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;
// todo serso: check - currently not worked
private float hTextPosition = H_TEXT_POSITION_DEFAULT_VALUE;
public ColorButton(Context context, AttributeSet attrs) {
@@ -74,6 +74,22 @@ public class ColorButton extends Button {
public ColorButton(Context context, AttributeSet attrs, boolean init) {
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) {
init(context);
}
@@ -219,14 +235,6 @@ public class ColorButton extends Button {
this.onClickListener.onClick(this);
}
public float getHTextPosition() {
return hTextPosition;
}
public void setHTextPosition(float hTextPosition) {
this.hTextPosition = hTextPosition;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
boolean result = super.onTouchEvent(event);

View File

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

View File

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