remove Utils class
This commit is contained in:
parent
334f28c2fa
commit
2191015062
|
@ -1,28 +0,0 @@
|
|||
package com.simplemobiletools.draw;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Utils {
|
||||
private final static double BRIGHTNESS_CUTOFF = 130.0;
|
||||
|
||||
public static void showToast(Context cxt, int msgId) {
|
||||
Toast.makeText(cxt, cxt.getResources().getString(msgId), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
// Used to determine the best foreground color (black or white) given a background color
|
||||
public static boolean shouldUseWhite(int color) {
|
||||
float r, g, b;
|
||||
r = Color.red(color);
|
||||
g = Color.green(color);
|
||||
b = Color.blue(color);
|
||||
|
||||
double brightness = Math.sqrt(
|
||||
r * r * .299 +
|
||||
g * g * .587 +
|
||||
b * b * .114);
|
||||
|
||||
return brightness < BRIGHTNESS_CUTOFF;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import android.os.Parcelable
|
|||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.simplemobiletools.commons.extensions.getContrastColor
|
||||
import java.util.*
|
||||
|
||||
class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
||||
|
@ -122,7 +123,7 @@ class MyCanvas(context: Context, attrs: AttributeSet) : View(context, attrs) {
|
|||
var y = height - res.getDimension(R.dimen.preview_dot_offset_y)
|
||||
canvas.drawCircle((width / 2).toFloat(), y, mPaintOptions!!.strokeWidth / 2, mPaint)
|
||||
mPaint.style = Paint.Style.STROKE
|
||||
mPaint.color = if (Utils.shouldUseWhite(mPaintOptions!!.color)) Color.WHITE else Color.BLACK
|
||||
mPaint.color = mPaintOptions!!.color.getContrastColor()
|
||||
mPaint.strokeWidth = res.getDimension(R.dimen.preview_dot_stroke_size)
|
||||
|
||||
y = height - res.getDimension(R.dimen.preview_dot_offset_y)
|
||||
|
|
|
@ -22,7 +22,10 @@ import butterknife.BindView
|
|||
import butterknife.ButterKnife
|
||||
import butterknife.OnClick
|
||||
import com.simplemobiletools.commons.activities.AboutActivity
|
||||
import com.simplemobiletools.draw.*
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.draw.MyCanvas
|
||||
import com.simplemobiletools.draw.R
|
||||
import com.simplemobiletools.draw.Svg
|
||||
import com.simplemobiletools.draw.helpers.Config
|
||||
import yuku.ambilwarna.AmbilWarnaDialog
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
@ -180,13 +183,13 @@ class MainActivity : SimpleActivity(), MyCanvas.PathsChangedListener {
|
|||
curFileName = fileName
|
||||
curExtensionId = fileExtensionRG.checkedRadioButtonId
|
||||
|
||||
Utils.showToast(applicationContext, R.string.saving_ok)
|
||||
toast(R.string.saving_ok)
|
||||
alertDialog.dismiss()
|
||||
} else {
|
||||
Utils.showToast(applicationContext, R.string.saving_error)
|
||||
toast(R.string.saving_error)
|
||||
}
|
||||
} else {
|
||||
Utils.showToast(applicationContext, R.string.enter_file_name)
|
||||
toast(R.string.enter_file_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue