Skip to content

Commit

Permalink
Improve fonts import and added export to zip
Browse files Browse the repository at this point in the history
  • Loading branch information
T8RIN committed Jan 7, 2025
1 parent 684dbda commit e36ccda
Show file tree
Hide file tree
Showing 14 changed files with 492 additions and 206 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import androidx.compose.material.icons.rounded.QrCode
import androidx.compose.material.icons.rounded.QrCode2
import androidx.compose.material.icons.rounded.Save
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -68,11 +67,9 @@ import androidx.compose.ui.graphics.asAndroidBitmap
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.min
import androidx.compose.ui.unit.sp
import coil3.compose.rememberAsyncImagePainter
import coil3.request.ImageRequest
import coil3.request.error
Expand All @@ -96,6 +93,7 @@ import ru.tech.imageresizershrinker.core.ui.widget.modifier.shimmer
import ru.tech.imageresizershrinker.core.ui.widget.modifier.transparencyChecker
import ru.tech.imageresizershrinker.core.ui.widget.other.QrCode
import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItem
import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItemDefaults
import ru.tech.imageresizershrinker.core.ui.widget.text.TitleItem

@OptIn(ExperimentalComposeUiApi::class)
Expand Down Expand Up @@ -176,7 +174,7 @@ internal fun FilterTemplateInfoSheet(
)
.padding(16.dp)
) {
val targetSize = min(min(maxWidth, maxHeight), 300.dp)
val targetSize = min(min(this.maxWidth, maxHeight), 300.dp)
Column(
horizontalAlignment = Alignment.CenterHorizontally
) {
Expand Down Expand Up @@ -340,12 +338,7 @@ internal fun FilterTemplateInfoSheet(
.let(onShareImage)
}
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
Spacer(Modifier.height(4.dp))
PreferenceItem(
Expand All @@ -356,12 +349,7 @@ internal fun FilterTemplateInfoSheet(
showShareDialog = false
onShareFile(filterContent)
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
Spacer(Modifier.height(4.dp))
PreferenceItem(
Expand All @@ -377,12 +365,7 @@ internal fun FilterTemplateInfoSheet(
.let(onSaveImage)
}
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
Spacer(Modifier.height(4.dp))
PreferenceItem(
Expand All @@ -392,12 +375,7 @@ internal fun FilterTemplateInfoSheet(
onClick = {
saveLauncher.launch(onRequestTemplateFilename())
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package ru.tech.imageresizershrinker.core.resources.icons

import androidx.compose.material.icons.Icons
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val Icons.Rounded.FileExport: ImageVector by lazy {
ImageVector.Builder(
name = "Rounded.FileExport",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f
).apply {
path(fill = SolidColor(Color(0xFF000000))) {
moveTo(6f, 2f)
curveTo(4.89f, 2f, 4f, 2.9f, 4f, 4f)
verticalLineTo(20f)
arcTo(2f, 2f, 0f, isMoreThanHalf = false, isPositiveArc = false, 6f, 22f)
horizontalLineTo(18f)
arcTo(2f, 2f, 0f, isMoreThanHalf = false, isPositiveArc = false, 20f, 20f)
verticalLineTo(8f)
lineTo(14f, 2f)
moveTo(13f, 3.5f)
lineTo(18.5f, 9f)
horizontalLineTo(13f)
moveTo(8.93f, 12.22f)
horizontalLineTo(16f)
verticalLineTo(19.29f)
lineTo(13.88f, 17.17f)
lineTo(11.05f, 20f)
lineTo(8.22f, 17.17f)
lineTo(11.05f, 14.35f)
}
}.build()
}

val Icons.Outlined.FileExport: ImageVector by lazy {
ImageVector.Builder(
name = "Outlined.FileExport",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f
).apply {
path(fill = SolidColor(Color(0xFF000000))) {
moveTo(14f, 2f)
horizontalLineTo(6f)
curveTo(4.9f, 2f, 4f, 2.9f, 4f, 4f)
verticalLineTo(20f)
curveTo(4f, 21.1f, 4.9f, 22f, 6f, 22f)
horizontalLineTo(18f)
curveTo(19.1f, 22f, 20f, 21.1f, 20f, 20f)
verticalLineTo(8f)
lineTo(14f, 2f)
moveTo(18f, 20f)
horizontalLineTo(6f)
verticalLineTo(4f)
horizontalLineTo(13f)
verticalLineTo(9f)
horizontalLineTo(18f)
verticalLineTo(20f)
moveTo(16f, 11f)
verticalLineTo(18.1f)
lineTo(13.9f, 16f)
lineTo(11.1f, 18.8f)
lineTo(8.3f, 16f)
lineTo(11.1f, 13.2f)
lineTo(8.9f, 11f)
horizontalLineTo(16f)
close()
}
}.build()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package ru.tech.imageresizershrinker.core.resources.icons

import androidx.compose.material.icons.Icons
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

val Icons.Rounded.FileImport: ImageVector by lazy {
ImageVector.Builder(
name = "Rounded.FileImport",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f
).apply {
path(fill = SolidColor(Color(0xFF000000))) {
moveTo(6f, 2f)
curveTo(4.89f, 2f, 4f, 2.9f, 4f, 4f)
verticalLineTo(20f)
arcTo(2f, 2f, 0f, isMoreThanHalf = false, isPositiveArc = false, 6f, 22f)
horizontalLineTo(18f)
arcTo(2f, 2f, 0f, isMoreThanHalf = false, isPositiveArc = false, 20f, 20f)
verticalLineTo(8f)
lineTo(14f, 2f)
moveTo(13f, 3.5f)
lineTo(18.5f, 9f)
horizontalLineTo(13f)
moveTo(10.05f, 11.22f)
lineTo(12.88f, 14.05f)
lineTo(15f, 11.93f)
verticalLineTo(19f)
horizontalLineTo(7.93f)
lineTo(10.05f, 16.88f)
lineTo(7.22f, 14.05f)
}
}.build()
}

val Icons.Outlined.FileImport: ImageVector by lazy {
ImageVector.Builder(
name = "Outlined.FileImport",
defaultWidth = 24.dp,
defaultHeight = 24.dp,
viewportWidth = 24f,
viewportHeight = 24f
).apply {
path(fill = SolidColor(Color(0xFF000000))) {
moveTo(14f, 2f)
horizontalLineTo(6f)
curveTo(4.89f, 2f, 4f, 2.9f, 4f, 4f)
verticalLineTo(20f)
curveTo(4f, 21.11f, 4.89f, 22f, 6f, 22f)
horizontalLineTo(18f)
curveTo(19.11f, 22f, 20f, 21.11f, 20f, 20f)
verticalLineTo(8f)
lineTo(14f, 2f)
moveTo(18f, 20f)
horizontalLineTo(6f)
verticalLineTo(4f)
horizontalLineTo(13f)
verticalLineTo(9f)
horizontalLineTo(18f)
verticalLineTo(20f)
moveTo(15f, 11.93f)
verticalLineTo(19f)
horizontalLineTo(7.93f)
lineTo(10.05f, 16.88f)
lineTo(7.22f, 14.05f)
lineTo(10.05f, 11.22f)
lineTo(12.88f, 14.05f)
lineTo(15f, 11.93f)
close()
}
}.build()
}
2 changes: 2 additions & 0 deletions core/resources/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1550,4 +1550,6 @@
<string name="mesh_gradients">Mesh Gradients</string>
<string name="mesh_gradients_sub">Look at online collection of Mesh Gradients</string>
<string name="wrong_font">Only TTF fonts can be imported</string>
<string name="import_font">Import Font (TTF/OTF)</string>
<string name="export_fonts">Export Fonts</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ interface SettingsInteractor : SimpleSettingsInteractor {
suspend fun importCustomFont(uri: String): DomainFontFamily.Custom?

suspend fun removeCustomFont(font: DomainFontFamily.Custom)

suspend fun createCustomFontsExport(): ByteArray
}

fun SettingsInteractor.toSimpleSettingsInteractor(): SimpleSettingsInteractor =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import androidx.compose.material.icons.outlined.Image
import androidx.compose.material.icons.rounded.ContentCopy
import androidx.compose.material.icons.rounded.Share
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -41,10 +40,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ClipboardManager
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import ru.tech.imageresizershrinker.core.resources.R
import ru.tech.imageresizershrinker.core.resources.icons.MiniEdit
import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedAlertDialog
Expand All @@ -53,6 +49,7 @@ import ru.tech.imageresizershrinker.core.ui.widget.enhanced.EnhancedIconButton
import ru.tech.imageresizershrinker.core.ui.widget.modifier.ContainerShapeDefaults
import ru.tech.imageresizershrinker.core.ui.widget.modifier.fadingEdges
import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItem
import ru.tech.imageresizershrinker.core.ui.widget.preferences.PreferenceItemDefaults

@Composable
fun ShareButton(
Expand Down Expand Up @@ -123,12 +120,7 @@ fun ShareButton(
showSelectionDialog = false
onShare()
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
if (onCopy != null) {
Spacer(Modifier.height(4.dp))
Expand All @@ -141,12 +133,7 @@ fun ShareButton(
showSelectionDialog = false
onCopy(clipboardManager)
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
}
if (onEdit != null) {
Expand All @@ -159,12 +146,7 @@ fun ShareButton(
showSelectionDialog = false
onEdit()
},
titleFontStyle = LocalTextStyle.current.copy(
fontSize = 16.sp,
fontWeight = FontWeight.Medium,
lineHeight = 18.sp,
textAlign = TextAlign.Center
)
titleFontStyle = PreferenceItemDefaults.TitleFontStyleCentered
)
}
}
Expand Down
Loading

0 comments on commit e36ccda

Please sign in to comment.