mirror of
https://github.com/T8RIN/ImageToolbox.git
synced 2025-05-17 13:35:58 +08:00
Code refactors
This commit is contained in:
@ -31,7 +31,6 @@ import ru.tech.imageresizershrinker.core.domain.model.ImageModel
|
||||
import ru.tech.imageresizershrinker.core.resources.R
|
||||
import java.net.URLDecoder
|
||||
import java.util.LinkedList
|
||||
import kotlin.io.use
|
||||
|
||||
fun ImageModel.toUri(): Uri? = when (data) {
|
||||
is Uri -> data as Uri
|
||||
|
@ -53,7 +53,7 @@ private fun diffHelper(
|
||||
): Pair<String, String> {
|
||||
val key = (a.length.toLong()) shl 32 or b.length.toLong()
|
||||
if (!lookup.containsKey(key)) {
|
||||
var value: Pair<String, String> = if (a.isEmpty() || b.isEmpty()) {
|
||||
val value: Pair<String, String> = if (a.isEmpty() || b.isEmpty()) {
|
||||
a to b
|
||||
} else if (a[0] == b[0]) {
|
||||
diffHelper(
|
||||
@ -71,7 +71,7 @@ private fun diffHelper(
|
||||
bb.first to (b[0].toString() + bb.second)
|
||||
}
|
||||
}
|
||||
lookup.put(key, value)
|
||||
lookup[key] = value
|
||||
}
|
||||
return lookup.getOrElse(key) { "" to "" }
|
||||
}
|
||||
|
@ -214,11 +214,11 @@ fun AdaptiveLayoutScreen(
|
||||
)
|
||||
val cutout =
|
||||
if (!placeImagePreview && addHorizontalCutoutPaddingIfNoPreview) {
|
||||
WindowInsets
|
||||
.displayCutout
|
||||
.asPaddingValues()
|
||||
.calculateStartPadding(direction)
|
||||
} else 0.dp
|
||||
WindowInsets
|
||||
.displayCutout
|
||||
.asPaddingValues()
|
||||
.calculateStartPadding(direction)
|
||||
} else 0.dp
|
||||
|
||||
val listState = rememberLazyListState()
|
||||
var isScrolled by rememberSaveable(canShowScreenData) {
|
||||
|
@ -436,7 +436,6 @@ private fun Modifier.sliderSemantics(
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Stable
|
||||
private fun Modifier.sliderTapModifier(
|
||||
state: CustomSliderState,
|
||||
|
@ -49,7 +49,6 @@ import ru.tech.imageresizershrinker.feature.base64_tools.domain.Base64Converter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlin.toString
|
||||
|
||||
class Base64ToolsComponent @AssistedInject internal constructor(
|
||||
@Assisted componentContext: ComponentContext,
|
||||
|
@ -31,7 +31,6 @@ import ru.tech.imageresizershrinker.core.domain.saving.io.Readable
|
||||
import ru.tech.imageresizershrinker.feature.checksum_tools.domain.ChecksumManager
|
||||
import ru.tech.imageresizershrinker.feature.checksum_tools.domain.ChecksumSource
|
||||
import javax.inject.Inject
|
||||
import kotlin.text.encodeToByteArray
|
||||
|
||||
internal class AndroidChecksumManager @Inject constructor(
|
||||
@ApplicationContext private val context: Context,
|
||||
|
@ -41,13 +41,14 @@ import androidx.compose.material.icons.rounded.ContentPaste
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
@ -34,13 +34,14 @@ import androidx.compose.material.icons.rounded.ContentPaste
|
||||
import androidx.compose.material.icons.rounded.Info
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
@ -36,14 +36,15 @@ import androidx.compose.material.icons.rounded.ContentPaste
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
@ -36,13 +36,14 @@ import androidx.compose.material.icons.rounded.ContentPaste
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
|
@ -49,7 +49,8 @@ import ru.tech.imageresizershrinker.feature.draw.presentation.components.element
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.element.PolygonParamsSelector
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.element.RectParamsSelector
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.element.StarParamsSelector
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.utils.*
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.utils.getIcon
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.utils.saveState
|
||||
|
||||
@Composable
|
||||
fun DrawPathModeSelector(
|
||||
|
@ -18,12 +18,13 @@
|
||||
package ru.tech.imageresizershrinker.feature.draw.presentation.components
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.graphics.BlendMode
|
||||
import androidx.compose.ui.graphics.Canvas
|
||||
|
@ -119,6 +119,7 @@ fun DrawPathMode.toUi(): UiDrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
DrawPathMode.Free -> UiDrawPathMode.Free
|
||||
DrawPathMode.Lasso -> UiDrawPathMode.Lasso
|
||||
DrawPathMode.Line -> UiDrawPathMode.Line
|
||||
@ -126,6 +127,7 @@ fun DrawPathMode.toUi(): UiDrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
DrawPathMode.OutlinedOval -> UiDrawPathMode.OutlinedOval
|
||||
is DrawPathMode.OutlinedPolygon -> UiDrawPathMode.OutlinedPolygon(
|
||||
vertices = vertices,
|
||||
@ -147,6 +149,7 @@ fun DrawPathMode.toUi(): UiDrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
is DrawPathMode.Polygon -> UiDrawPathMode.Polygon(
|
||||
vertices = vertices,
|
||||
rotationDegrees = rotationDegrees,
|
||||
@ -174,6 +177,7 @@ fun UiDrawPathMode.toDomain(): DrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
UiDrawPathMode.Free -> DrawPathMode.Free
|
||||
UiDrawPathMode.Lasso -> DrawPathMode.Lasso
|
||||
UiDrawPathMode.Line -> DrawPathMode.Line
|
||||
@ -181,6 +185,7 @@ fun UiDrawPathMode.toDomain(): DrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
UiDrawPathMode.OutlinedOval -> DrawPathMode.OutlinedOval
|
||||
is UiDrawPathMode.OutlinedPolygon -> DrawPathMode.OutlinedPolygon(
|
||||
vertices = vertices,
|
||||
@ -202,6 +207,7 @@ fun UiDrawPathMode.toDomain(): DrawPathMode = when (this) {
|
||||
sizeScale = sizeScale,
|
||||
angle = angle
|
||||
)
|
||||
|
||||
is UiDrawPathMode.Polygon -> DrawPathMode.Polygon(
|
||||
vertices = vertices,
|
||||
rotationDegrees = rotationDegrees,
|
||||
|
@ -15,19 +15,44 @@
|
||||
* along with this program. If not, see <http://www.apache.org/licenses/LICENSE-2.0>.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
|
||||
package ru.tech.imageresizershrinker.feature.filters.data.utils
|
||||
|
||||
import android.opengl.GLES20.*
|
||||
import android.opengl.GLES20.GL_COLOR_BUFFER_BIT
|
||||
import android.opengl.GLES20.GL_COMPILE_STATUS
|
||||
import android.opengl.GLES20.GL_DEPTH_BUFFER_BIT
|
||||
import android.opengl.GLES20.GL_FLOAT
|
||||
import android.opengl.GLES20.GL_FRAGMENT_SHADER
|
||||
import android.opengl.GLES20.GL_TRIANGLES
|
||||
import android.opengl.GLES20.GL_VERTEX_SHADER
|
||||
import android.opengl.GLES20.glAttachShader
|
||||
import android.opengl.GLES20.glClear
|
||||
import android.opengl.GLES20.glClearColor
|
||||
import android.opengl.GLES20.glCompileShader
|
||||
import android.opengl.GLES20.glCreateProgram
|
||||
import android.opengl.GLES20.glCreateShader
|
||||
import android.opengl.GLES20.glDeleteShader
|
||||
import android.opengl.GLES20.glDisableVertexAttribArray
|
||||
import android.opengl.GLES20.glDrawArrays
|
||||
import android.opengl.GLES20.glEnableVertexAttribArray
|
||||
import android.opengl.GLES20.glGetAttribLocation
|
||||
import android.opengl.GLES20.glGetShaderiv
|
||||
import android.opengl.GLES20.glGetUniformLocation
|
||||
import android.opengl.GLES20.glLinkProgram
|
||||
import android.opengl.GLES20.glShaderSource
|
||||
import android.opengl.GLES20.glUniform1f
|
||||
import android.opengl.GLES20.glUniform2f
|
||||
import android.opengl.GLES20.glUniform3fv
|
||||
import android.opengl.GLES20.glUseProgram
|
||||
import android.opengl.GLES20.glVertexAttribPointer
|
||||
import android.opengl.GLES20.glViewport
|
||||
import android.opengl.GLSurfaceView.Renderer
|
||||
import java.lang.RuntimeException
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.FloatBuffer
|
||||
import javax.microedition.khronos.egl.EGLConfig
|
||||
import javax.microedition.khronos.opengles.GL10
|
||||
import kotlin.also
|
||||
import kotlin.apply
|
||||
import kotlin.run
|
||||
|
||||
|
||||
// from https://www.shadertoy.com/view/wdyczG, Created by hahnzhu in 2020-10-20
|
||||
|
@ -49,8 +49,6 @@ import ru.tech.imageresizershrinker.feature.draw.presentation.components.UiPathP
|
||||
import ru.tech.imageresizershrinker.feature.draw.presentation.components.toUiPathPaint
|
||||
import ru.tech.imageresizershrinker.feature.filters.domain.FilterMaskApplier
|
||||
import ru.tech.imageresizershrinker.feature.filters.presentation.components.UiFilterMask
|
||||
import kotlin.collections.minus
|
||||
import kotlin.collections.plus
|
||||
|
||||
class AddMaskSheetComponent @AssistedInject internal constructor(
|
||||
@Assisted componentContext: ComponentContext,
|
||||
|
@ -17,8 +17,10 @@
|
||||
|
||||
package ru.tech.imageresizershrinker.feature.markup_layers.presentation.components
|
||||
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableFloatStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.unit.Density
|
||||
import androidx.compose.ui.unit.DpSize
|
||||
@ -95,10 +97,10 @@ class EditBoxState(
|
||||
scale = (scale * zoomChange).fastCoerceIn(0.3f, 10f)
|
||||
val panChange = (offsetChange * scale).rotateBy(rotation)
|
||||
|
||||
val contentSize = contentSize.rotateBy(rotation)
|
||||
val rotatedSize = contentSize.rotateBy(rotation)
|
||||
|
||||
val extraWidth = (parentMaxWidth - contentSize.width * scale).absoluteValue
|
||||
val extraHeight = (parentMaxHeight - contentSize.height * scale).absoluteValue
|
||||
val extraWidth = (parentMaxWidth - rotatedSize.width * scale).absoluteValue
|
||||
val extraHeight = (parentMaxHeight - rotatedSize.height * scale).absoluteValue
|
||||
|
||||
val maxX = extraWidth / 2 // + contentSize.width * scale / 2
|
||||
val maxY = extraHeight / 2 // + contentSize.height * scale / 2
|
||||
|
@ -32,9 +32,11 @@ import androidx.compose.material.icons.outlined.Image
|
||||
import androidx.compose.material.icons.rounded.TextFields
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
@ -41,11 +41,13 @@ import androidx.compose.material.icons.outlined.FormatPaint
|
||||
import androidx.compose.material.icons.rounded.FormatColorFill
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@ -165,67 +167,67 @@ internal fun MarkupLayersNoDataControls(
|
||||
},
|
||||
sheetContent = {
|
||||
Column(Modifier.verticalScroll(rememberScrollState())) {
|
||||
Row(
|
||||
Modifier
|
||||
.padding(16.dp)
|
||||
.container(shape = RoundedCornerShape(24.dp))
|
||||
) {
|
||||
RoundedTextField(
|
||||
value = width.takeIf { it != 0 }?.toString() ?: "",
|
||||
onValueChange = {
|
||||
width = it.restrict(8192).toIntOrNull() ?: 0
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number
|
||||
),
|
||||
label = {
|
||||
Text(stringResource(R.string.width, " "))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(
|
||||
start = 8.dp,
|
||||
top = 8.dp,
|
||||
bottom = 4.dp,
|
||||
end = 4.dp
|
||||
)
|
||||
)
|
||||
RoundedTextField(
|
||||
value = height.takeIf { it != 0 }?.toString() ?: "",
|
||||
onValueChange = {
|
||||
height = it.restrict(8192).toIntOrNull() ?: 0
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
label = {
|
||||
Text(stringResource(R.string.height, " "))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(
|
||||
start = 4.dp,
|
||||
top = 8.dp,
|
||||
bottom = 4.dp,
|
||||
end = 8.dp
|
||||
),
|
||||
)
|
||||
}
|
||||
ColorRowSelector(
|
||||
value = sheetBackgroundColor,
|
||||
onValueChange = { sheetBackgroundColor = it },
|
||||
icon = Icons.Rounded.FormatColorFill,
|
||||
Row(
|
||||
Modifier
|
||||
.padding(16.dp)
|
||||
.container(shape = RoundedCornerShape(24.dp))
|
||||
) {
|
||||
RoundedTextField(
|
||||
value = width.takeIf { it != 0 }?.toString() ?: "",
|
||||
onValueChange = {
|
||||
width = it.restrict(8192).toIntOrNull() ?: 0
|
||||
},
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number
|
||||
),
|
||||
label = {
|
||||
Text(stringResource(R.string.width, " "))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
bottom = 16.dp
|
||||
start = 8.dp,
|
||||
top = 8.dp,
|
||||
bottom = 4.dp,
|
||||
end = 4.dp
|
||||
)
|
||||
.container(RoundedCornerShape(24.dp))
|
||||
)
|
||||
RoundedTextField(
|
||||
value = height.takeIf { it != 0 }?.toString() ?: "",
|
||||
onValueChange = {
|
||||
height = it.restrict(8192).toIntOrNull() ?: 0
|
||||
},
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Number
|
||||
),
|
||||
shape = RoundedCornerShape(12.dp),
|
||||
label = {
|
||||
Text(stringResource(R.string.height, " "))
|
||||
},
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(
|
||||
start = 4.dp,
|
||||
top = 8.dp,
|
||||
bottom = 4.dp,
|
||||
end = 8.dp
|
||||
),
|
||||
)
|
||||
}
|
||||
ColorRowSelector(
|
||||
value = sheetBackgroundColor,
|
||||
onValueChange = { sheetBackgroundColor = it },
|
||||
icon = Icons.Rounded.FormatColorFill,
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
start = 16.dp,
|
||||
end = 16.dp,
|
||||
bottom = 16.dp
|
||||
)
|
||||
.container(RoundedCornerShape(24.dp))
|
||||
)
|
||||
}
|
||||
},
|
||||
visible = showBackgroundDrawingSetup,
|
||||
onDismiss = {
|
||||
|
@ -45,8 +45,8 @@ import androidx.compose.material.icons.rounded.Delete
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -23,9 +23,11 @@ import androidx.compose.material.icons.rounded.Tune
|
||||
import androidx.compose.material3.BottomSheetScaffoldState
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.SheetValue
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -21,9 +21,9 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Matrix
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asAndroidBitmap
|
||||
@ -201,7 +201,7 @@ class MarkupLayersComponent @AssistedInject internal constructor(
|
||||
) {
|
||||
savingJob = componentScope.launch {
|
||||
_isSaving.value = true
|
||||
getDrawingBitmap()?.let { localBitmap ->
|
||||
getDrawingBitmap().let { localBitmap ->
|
||||
onComplete(
|
||||
fileController.save(
|
||||
saveTarget = ImageSaveTarget<ExifInterface>(
|
||||
@ -302,7 +302,7 @@ class MarkupLayersComponent @AssistedInject internal constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getDrawingBitmap(): Bitmap? = withContext(defaultDispatcher) {
|
||||
private suspend fun getDrawingBitmap(): Bitmap = withContext(defaultDispatcher) {
|
||||
coroutineScope {
|
||||
deactivateAllLayers()
|
||||
delay(500)
|
||||
@ -313,9 +313,9 @@ class MarkupLayersComponent @AssistedInject internal constructor(
|
||||
layers.setHasAlpha(true)
|
||||
val background = imageGetter.getImage(data = _uri.value)
|
||||
?: (backgroundBehavior as? BackgroundBehavior.Color)?.run {
|
||||
ImageBitmap(width, height).asAndroidBitmap()
|
||||
.applyCanvas { drawColor(color) }
|
||||
}
|
||||
ImageBitmap(width, height).asAndroidBitmap()
|
||||
.applyCanvas { drawColor(color) }
|
||||
}
|
||||
|
||||
background?.overlay(layers) ?: layers
|
||||
}
|
||||
@ -351,7 +351,7 @@ class MarkupLayersComponent @AssistedInject internal constructor(
|
||||
fun shareBitmap(onComplete: () -> Unit) {
|
||||
savingJob = componentScope.launch {
|
||||
_isSaving.value = true
|
||||
getDrawingBitmap()?.let {
|
||||
getDrawingBitmap().let {
|
||||
shareProvider.shareImage(
|
||||
image = it,
|
||||
imageInfo = ImageInfo(
|
||||
@ -375,7 +375,7 @@ class MarkupLayersComponent @AssistedInject internal constructor(
|
||||
fun cacheCurrentImage(onComplete: (Uri) -> Unit) {
|
||||
savingJob = componentScope.launch {
|
||||
_isSaving.value = true
|
||||
getDrawingBitmap()?.let { image ->
|
||||
getDrawingBitmap().let { image ->
|
||||
shareProvider.cacheImage(
|
||||
image = image,
|
||||
imageInfo = ImageInfo(
|
||||
|
@ -26,11 +26,14 @@ import android.database.MergeCursor
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.MediaStore
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.channels.awaitClose
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import ru.tech.imageresizershrinker.feature.media_picker.domain.model.FULL_DATE_FORMAT
|
||||
import ru.tech.imageresizershrinker.feature.media_picker.domain.model.Media
|
||||
import ru.tech.imageresizershrinker.feature.media_picker.domain.model.MediaOrder
|
||||
|
@ -44,9 +44,9 @@ import androidx.compose.material3.LocalMinimumInteractiveComponentSize
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -51,7 +51,6 @@ import ru.tech.imageresizershrinker.core.resources.R
|
||||
import ru.tech.imageresizershrinker.core.ui.widget.other.LoadingIndicator
|
||||
import ru.tech.imageresizershrinker.feature.recognize.text.domain.OCRLanguage
|
||||
import ru.tech.imageresizershrinker.feature.recognize.text.domain.RecognitionType
|
||||
import kotlin.collections.indexOf
|
||||
|
||||
@Composable
|
||||
internal fun RecognizeLanguageSelectorSheetContent(
|
||||
|
Reference in New Issue
Block a user