Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="15dp"
android:height="15dp"
android:viewportWidth="15"
android:viewportHeight="15">
<path
android:pathData="M0,0H3V3H0V0ZM6,3H3V6H0V9H3V12H0V15H3V12H6V15H9V12H12V15H15V12H12V9H15V6H12V3H15V0H12V3H9V0H6V3ZM6,6V3H9V6H6ZM6,9H3V6H6V9ZM9,9V6H12V9H9ZM9,9H6V12H9V9Z"
android:fillColor="#000000"
android:fillAlpha="0.25"
android:fillType="evenOdd"/>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,26 @@
*/
package com.maxkeppeler.sheets.color.utils

import androidx.compose.ui.graphics.Color

/** Receive the clipboard data. */
@OptIn(ExperimentalStdlibApi::class)
internal fun getFormattedColor(color: Int): String {
return "#" + (0xFFFFFFFF and color.toLong()).toHexString()
val c = Color(color)
return toArgbHexManual(c.alpha * 255F, c.red * 255F, c.green * 255F, c.blue * 255F)
}

private fun toArgbHexManual(a: Float, r: Float, g: Float, b: Float): String {
require(a in 0F..255F && r in 0F..255F && g in 0F..255F && b in 0F..255F) {
"ARGB values must be between 0 and 255."
}
return "#${a.toInt().toHex()}${r.toInt().toHex()}${g.toInt().toHex()}${b.toInt().toHex()}"
}

private fun Int.toHex(): String = toHexString(HexFormat {
upperCase = true
number {
removeLeadingZeros = true
minLength = 2
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal fun ColorCustomControlComponent(
) { entry ->
val index = colorItems.indexOf(entry)
val onValueChange: (Int) -> Unit = {
entry.second.value = it.toFloat()
entry.second.value = it / 256F
}
val sliderTestTag = testSequenceTagOf(
TestTags.COLOR_CUSTOM_VALUE_SLIDER,
Expand All @@ -103,7 +103,7 @@ internal fun ColorCustomControlComponent(
LibOrientation.PORTRAIT ->
ColorCustomControlListItemComponent(
label = entry.first,
value = entry.second.value.toInt(),
value = (entry.second.value * 256F).toInt(),
onValueChange = onValueChange,
colorItemLabelWidth = colorItemLabelWidth,
colorValueLabelWidth = colorValueLabelWidth,
Expand All @@ -112,7 +112,7 @@ internal fun ColorCustomControlComponent(
LibOrientation.LANDSCAPE ->
ColorCustomControlGridItemComponent(
label = entry.first,
value = entry.second.value.toInt(),
value = (entry.second.value * 256F).toInt(),
onValueChange = onValueChange,
sliderTestTag = sliderTestTag,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal fun ColorSelectionModeComponent(
}
)
Icon(
modifier = Modifier.size(48.dp),
modifier = Modifier.size(24.dp),
imageVector = if (mode != ColorSelectionMode.TEMPLATE) config.icons.Apps else config.icons.Tune,
contentDescription = text,
tint = MaterialTheme.colorScheme.primary
Expand All @@ -102,7 +102,7 @@ internal fun ColorSelectionModeComponent(
shape = RoundedCornerShape(50)
) {
Icon(
modifier = Modifier.size(48.dp),
modifier = Modifier.size(24.dp),
imageVector = config.icons.NotInterested,
contentDescription = stringResource(Res.string.scd_color_dialog_no_color),
tint = MaterialTheme.colorScheme.primary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal fun ColorTemplateItemComponent(
colors = IconButtonDefaults.filledIconButtonColors(containerColor = MaterialTheme.colorScheme.background),
modifier = Modifier
.align(Alignment.Center)
.size(48.dp),
.size(24.dp),
onClick = {}
) {
Icon(
Expand Down