Moved preview dot constants to dimens.xml resource file

This commit is contained in:
Brian Pinsard 2017-01-18 17:48:28 +01:00
parent 7ca648004b
commit 17bce7fa9b
3 changed files with 7 additions and 6 deletions

View File

@ -9,7 +9,4 @@ public class Constants {
public static final String IS_FIRST_RUN = "is_first_run"; public static final String IS_FIRST_RUN = "is_first_run";
public static final String IS_DARK_THEME = "is_dark_theme"; public static final String IS_DARK_THEME = "is_dark_theme";
public static final String IS_STROKE_WIDTH_BAR_ENABLED = "is_stroke_width_bar_enabled"; public static final String IS_STROKE_WIDTH_BAR_ENABLED = "is_stroke_width_bar_enabled";
// canvas
public static final int PREVIEW_DOT_STROKE_SIZE = 5;
public static final int PREVIEW_DOT_OFFSET_Y = 120;
} }

View File

@ -1,6 +1,7 @@
package com.simplemobiletools.draw; package com.simplemobiletools.draw;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
@ -111,11 +112,12 @@ public class MyCanvas extends View {
} }
private void drawPreviewDot(Canvas canvas) { private void drawPreviewDot(Canvas canvas) {
Resources res = getResources();
mPaint.setColor(Utils.shouldUseWhite(mPaintOptions.color) ? Color.WHITE : Color.BLACK); mPaint.setColor(Utils.shouldUseWhite(mPaintOptions.color) ? Color.WHITE : Color.BLACK);
mPaint.setStrokeWidth(mPaintOptions.strokeWidth + Constants.PREVIEW_DOT_STROKE_SIZE); mPaint.setStrokeWidth(mPaintOptions.strokeWidth + res.getDimension(R.dimen.preview_dot_stroke_size));
canvas.drawPoint(getWidth() / 2, getHeight() - Constants.PREVIEW_DOT_OFFSET_Y, mPaint); canvas.drawPoint(getWidth() / 2, getHeight() - res.getDimension(R.dimen.preview_dot_offset_y), mPaint);
changePaint(mPaintOptions); changePaint(mPaintOptions);
canvas.drawPoint(getWidth() / 2, getHeight() - Constants.PREVIEW_DOT_OFFSET_Y, mPaint); canvas.drawPoint(getWidth() / 2, getHeight() - res.getDimension(R.dimen.preview_dot_offset_y), mPaint);
} }
private void changePaint(PaintOptions paintOptions) { private void changePaint(PaintOptions paintOptions) {

View File

@ -6,6 +6,8 @@
<dimen name="social_logo">40dp</dimen> <dimen name="social_logo">40dp</dimen>
<dimen name="settings_padding">8dp</dimen> <dimen name="settings_padding">8dp</dimen>
<dimen name="stroke_bar_size">150dp</dimen> <dimen name="stroke_bar_size">150dp</dimen>
<dimen name="preview_dot_stroke_size">2dp</dimen>
<dimen name="preview_dot_offset_y">50dp</dimen>
<dimen name="normal_text_size">14sp</dimen> <dimen name="normal_text_size">14sp</dimen>
</resources> </resources>