color operator buttons
This commit is contained in:
parent
fe4989e25d
commit
b6767a5be4
@ -7,6 +7,8 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<color name="magic_flame">#00ffffff</color>
|
<color name="magic_flame">#00ffffff</color>
|
||||||
<color name="button_text_color">#ffffffff</color>
|
<color name="button_text_color">#ffffffff</color>
|
||||||
|
<color name="button_operator_text_color">#ffffff99</color>
|
||||||
|
<color name="button_ce_text_color">#ffffffff</color>
|
||||||
<color name="default_text_color">#ffffffff</color>
|
<color name="default_text_color">#ffffffff</color>
|
||||||
<color name="default_background">#ff000000</color>
|
<color name="default_background">#ff000000</color>
|
||||||
</resources>
|
</resources>
|
@ -35,9 +35,12 @@ import android.widget.Button;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.solovyev.android.calculator.R;
|
import org.solovyev.android.calculator.R;
|
||||||
import org.solovyev.android.view.FontSizeAdjuster;
|
import org.solovyev.android.view.FontSizeAdjuster;
|
||||||
|
import org.solovyev.common.utils.CollectionsUtils;
|
||||||
import org.solovyev.common.utils.Point2d;
|
import org.solovyev.common.utils.Point2d;
|
||||||
import org.solovyev.common.utils.StringUtils;
|
import org.solovyev.common.utils.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: copied from com.android.calculator2.ColorButton
|
* NOTE: copied from com.android.calculator2.ColorButton
|
||||||
*/
|
*/
|
||||||
@ -79,13 +82,20 @@ public class ColorButton extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void init(Context context) {
|
protected void init(Context context) {
|
||||||
Resources res = getResources();
|
final Resources resources = getResources();
|
||||||
|
|
||||||
CLICK_FEEDBACK_COLOR = res.getColor(org.solovyev.android.calculator.R.color.magic_flame);
|
CLICK_FEEDBACK_COLOR = resources.getColor(org.solovyev.android.calculator.R.color.magic_flame);
|
||||||
feedbackPaint = new Paint();
|
feedbackPaint = new Paint();
|
||||||
feedbackPaint.setStyle(Style.STROKE);
|
feedbackPaint.setStyle(Style.STROKE);
|
||||||
feedbackPaint.setStrokeWidth(2);
|
feedbackPaint.setStrokeWidth(2);
|
||||||
getPaint().setColor(res.getColor(R.color.button_text_color));
|
|
||||||
|
if (CollectionsUtils.contains(getText().toString(), Arrays.asList("+", "-", "/", "×"))) {
|
||||||
|
getPaint().setColor(resources.getColor(R.color.button_operator_text_color));
|
||||||
|
} else if (getText().toString().equals("CE")) {
|
||||||
|
getPaint().setColor(resources.getColor(R.color.button_ce_text_color));
|
||||||
|
} else {
|
||||||
|
getPaint().setColor(resources.getColor(R.color.button_text_color));
|
||||||
|
}
|
||||||
|
|
||||||
animationStart = -1;
|
animationStart = -1;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package org.solovyev.android.view.widgets;
|
package org.solovyev.android.view.widgets;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
@ -165,7 +166,10 @@ public class DirectionDragButton extends DragButton {
|
|||||||
paint = getPaint();
|
paint = getPaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Resources resources = getResources();
|
||||||
|
|
||||||
upDownTextPaint = new TextPaint(paint);
|
upDownTextPaint = new TextPaint(paint);
|
||||||
|
upDownTextPaint.setColor(resources.getColor(R.color.button_text_color));
|
||||||
upDownTextPaint.setAlpha(150);
|
upDownTextPaint.setAlpha(150);
|
||||||
upDownTextPaint.setTextSize(paint.getTextSize() * getDirectionTextScale());
|
upDownTextPaint.setTextSize(paint.getTextSize() * getDirectionTextScale());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user