use the apps color on the focus rect
This commit is contained in:
parent
e309221b76
commit
5a04995b77
|
@ -316,17 +316,17 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
}
|
||||
|
||||
private fun calculateFocusArea(x: Float, y: Float): Rect {
|
||||
var left = java.lang.Float.valueOf(x / mSurfaceView.width * 2000 - 1000)!!.toInt()
|
||||
var top = java.lang.Float.valueOf(y / mSurfaceView.height * 2000 - 1000)!!.toInt()
|
||||
var left = x / mSurfaceView.width * 2000 - 1000
|
||||
var top = y / mSurfaceView.height * 2000 - 1000
|
||||
|
||||
val tmp = left
|
||||
left = top
|
||||
top = -tmp
|
||||
|
||||
val rectLeft = Math.max(left - FOCUS_AREA_SIZE / 2, -1000)
|
||||
val rectTop = Math.max(top - FOCUS_AREA_SIZE / 2, -1000)
|
||||
val rectRight = Math.min(left + FOCUS_AREA_SIZE / 2, 1000)
|
||||
val rectBottom = Math.min(top + FOCUS_AREA_SIZE / 2, 1000)
|
||||
val rectLeft = Math.max(left.toInt() - FOCUS_AREA_SIZE / 2, -1000)
|
||||
val rectTop = Math.max(top.toInt() - FOCUS_AREA_SIZE / 2, -1000)
|
||||
val rectRight = Math.min(left.toInt() + FOCUS_AREA_SIZE / 2, 1000)
|
||||
val rectBottom = Math.min(top.toInt() + FOCUS_AREA_SIZE / 2, 1000)
|
||||
return Rect(rectLeft, rectTop, rectRight, rectBottom)
|
||||
}
|
||||
|
||||
|
|
|
@ -436,6 +436,7 @@ class MainActivity : SimpleActivity(), SensorEventListener, PreviewListener, Pho
|
|||
resumeCameraItems()
|
||||
setupPreviewImage(mIsInPhotoMode)
|
||||
scheduleFadeOut()
|
||||
mFocusRectView.setStrokeColor(config.primaryColor)
|
||||
|
||||
if (mIsVideoCaptureIntent && mIsInPhotoMode) {
|
||||
togglePhotoVideo()
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.graphics.Paint
|
|||
import android.graphics.Rect
|
||||
import android.os.Handler
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
|
||||
class FocusRectView(context: Context) : ViewGroup(context) {
|
||||
companion object {
|
||||
|
@ -14,7 +14,6 @@ class FocusRectView(context: Context) : ViewGroup(context) {
|
|||
private val RECT_DURATION = 500
|
||||
|
||||
private var mDrawRect = false
|
||||
private var mPrimaryColor = 0
|
||||
|
||||
lateinit var mPaint: Paint
|
||||
lateinit var mHandler: Handler
|
||||
|
@ -24,18 +23,21 @@ class FocusRectView(context: Context) : ViewGroup(context) {
|
|||
init {
|
||||
setWillNotDraw(false)
|
||||
mHandler = Handler()
|
||||
mPrimaryColor = resources.getColor(R.color.color_primary)
|
||||
setupPaint()
|
||||
}
|
||||
|
||||
private fun setupPaint() {
|
||||
mPaint = Paint().apply {
|
||||
style = Paint.Style.STROKE
|
||||
color = mPrimaryColor
|
||||
color = context.config.primaryColor
|
||||
strokeWidth = 2f
|
||||
}
|
||||
}
|
||||
|
||||
fun setStrokeColor(color: Int) {
|
||||
mPaint.color = color
|
||||
}
|
||||
|
||||
fun drawFocusRect(x: Int, y: Int) {
|
||||
mRect = Rect(x - RECT_SIZE, y - RECT_SIZE, x + RECT_SIZE, y + RECT_SIZE)
|
||||
toggleRect(true)
|
||||
|
|
Loading…
Reference in New Issue