Correct ktlint for FocusDialog
This commit is contained in:
parent
09ab141d97
commit
8f08b1b678
|
@ -17,7 +17,12 @@ package com.keylesspalace.tusky.components.compose.dialog
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.graphics.*
|
import android.graphics.Bitmap
|
||||||
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
|
import android.graphics.Matrix
|
||||||
|
import android.graphics.Paint
|
||||||
|
import android.graphics.Path
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
@ -47,9 +52,7 @@ import java.security.MessageDigest
|
||||||
import java.util.concurrent.locks.Lock
|
import java.util.concurrent.locks.Lock
|
||||||
|
|
||||||
// Private, but necessary to implement BitmapTransformation, function extracted from Glide
|
// Private, but necessary to implement BitmapTransformation, function extracted from Glide
|
||||||
private fun getAlphaSafeBitmap(
|
private fun getAlphaSafeBitmap(pool: BitmapPool, maybeAlphaSafe: Bitmap): Bitmap {
|
||||||
pool: BitmapPool, maybeAlphaSafe: Bitmap
|
|
||||||
): Bitmap {
|
|
||||||
val safeConfig: Bitmap.Config = getAlphaSafeConfig(maybeAlphaSafe)
|
val safeConfig: Bitmap.Config = getAlphaSafeConfig(maybeAlphaSafe)
|
||||||
if (safeConfig == maybeAlphaSafe.config) {
|
if (safeConfig == maybeAlphaSafe.config) {
|
||||||
return maybeAlphaSafe
|
return maybeAlphaSafe
|
||||||
|
@ -77,9 +80,7 @@ private val transparentDarkGray = 0x40000000
|
||||||
|
|
||||||
/** Glide BitmapTransformation which overlays a highlight on a focus point. */
|
/** Glide BitmapTransformation which overlays a highlight on a focus point. */
|
||||||
class HighlightFocus(val focus: Focus) : BitmapTransformation() {
|
class HighlightFocus(val focus: Focus) : BitmapTransformation() {
|
||||||
override fun transform(
|
override fun transform(pool: BitmapPool, inBitmap: Bitmap, outWidth: Int, outHeight: Int): Bitmap {
|
||||||
pool: BitmapPool, inBitmap: Bitmap, outWidth: Int, outHeight: Int
|
|
||||||
): Bitmap {
|
|
||||||
// Draw overlaid target
|
// Draw overlaid target
|
||||||
val bitmapDrawableLock: Lock = TransformationUtils.getBitmapDrawableLock()
|
val bitmapDrawableLock: Lock = TransformationUtils.getBitmapDrawableLock()
|
||||||
val safeConfig: Bitmap.Config = getAlphaSafeConfig(inBitmap)
|
val safeConfig: Bitmap.Config = getAlphaSafeConfig(inBitmap)
|
||||||
|
@ -90,7 +91,7 @@ class HighlightFocus(val focus: Focus) : BitmapTransformation() {
|
||||||
val strokePaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
val strokePaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
strokePaint.setAntiAlias(true)
|
strokePaint.setAntiAlias(true)
|
||||||
strokePaint.setStyle(Paint.Style.STROKE)
|
strokePaint.setStyle(Paint.Style.STROKE)
|
||||||
val strokeWidth = 10.0f;
|
val strokeWidth = 10.0f
|
||||||
strokePaint.setStrokeWidth(strokeWidth)
|
strokePaint.setStrokeWidth(strokeWidth)
|
||||||
strokePaint.setColor(Color.WHITE)
|
strokePaint.setColor(Color.WHITE)
|
||||||
val curtainPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
val curtainPaint = Paint(Paint.ANTI_ALIAS_FLAG)
|
||||||
|
@ -106,9 +107,9 @@ class HighlightFocus(val focus: Focus) : BitmapTransformation() {
|
||||||
// Canvas range is 0..size Y-down but Mastodon API range is -1..1 Y-up
|
// Canvas range is 0..size Y-down but Mastodon API range is -1..1 Y-up
|
||||||
val width = result.width.toFloat()
|
val width = result.width.toFloat()
|
||||||
val height = result.height.toFloat()
|
val height = result.height.toFloat()
|
||||||
val x = (focus.x+1.0f)/2.0f*width;
|
val x = (focus.x + 1.0f) / 2.0f * width
|
||||||
val y = (1.0f-focus.y)/2.0f*height
|
val y = (1.0f - focus.y) / 2.0f * height
|
||||||
val circleRadius = Math.min(width, height).toFloat()/4.0f
|
val circleRadius = Math.min(width, height).toFloat() / 4.0f
|
||||||
|
|
||||||
val curtainPath = Path() // Draw a flood fill with a hole cut out of it
|
val curtainPath = Path() // Draw a flood fill with a hole cut out of it
|
||||||
curtainPath.setFillType(Path.FillType.WINDING)
|
curtainPath.setFillType(Path.FillType.WINDING)
|
||||||
|
@ -117,7 +118,7 @@ class HighlightFocus(val focus: Focus) : BitmapTransformation() {
|
||||||
canvas.drawPath(curtainPath, curtainPaint)
|
canvas.drawPath(curtainPath, curtainPaint)
|
||||||
|
|
||||||
canvas.drawCircle(x, y, circleRadius, strokePaint)
|
canvas.drawCircle(x, y, circleRadius, strokePaint)
|
||||||
canvas.drawCircle(x, y, strokeWidth/2.0f, strokePaint)
|
canvas.drawCircle(x, y, strokeWidth / 2.0f, strokePaint)
|
||||||
|
|
||||||
canvas.setBitmap(null)
|
canvas.setBitmap(null)
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -171,7 +172,7 @@ fun <T> T.makeFocusDialog(
|
||||||
.load(previewUri)
|
.load(previewUri)
|
||||||
.downsample(DownsampleStrategy.CENTER_INSIDE)
|
.downsample(DownsampleStrategy.CENTER_INSIDE)
|
||||||
|
|
||||||
var imageView:PhotoView? = null
|
var imageView: PhotoView? = null
|
||||||
|
|
||||||
// Note all calls of this function are after imageView goes non-null
|
// Note all calls of this function are after imageView goes non-null
|
||||||
fun imageRequest() {
|
fun imageRequest() {
|
||||||
|
|
Loading…
Reference in New Issue