feat: compact look carousel and preset UI optimizations
This commit is contained in:
1 parent
ecab71a7fc
commit
5b0ad9ebb5
26 files changed
+426
-390
No files matched your search
@@ -3,7 +3,6 @@ package com.hinnka.mycamera.lut
|
||||
import com.hinnka.mycamera.data.UserPreferences
|
||||
|
||||
private val DEFAULT_FREQUENT_LUT_IDS = listOf("standard", "leica_m9", "monochrome", "cc", "ricoh_negative")
|
||||
private const val FREQUENT_LUT_LIMIT = 8
|
||||
|
||||
/** 只初始化一次;默认推荐的计数为零,不伪造用户使用记录。 */
|
||||
fun UserPreferences.initializeFrequentLuts(luts: List<LutInfo>) {
|
||||
@@ -16,14 +15,3 @@ fun UserPreferences.initializeFrequentLuts(luts: List<LutInfo>) {
|
||||
}
|
||||
frequentLutUsage = seeds.associate { it.id to 0L }
|
||||
}
|
||||
|
||||
fun frequentLuts(luts: List<LutInfo>, usage: Map<String, Long>?): List<LutInfo> {
|
||||
val counts = usage.orEmpty()
|
||||
// 同频次保持首次加入顺序,不受其他分类的手动排序影响。
|
||||
val insertionOrder = counts.keys.withIndex().associate { it.value to it.index }
|
||||
val ranked = luts.filter { it.id != "none" && it.id in counts }
|
||||
.sortedWith(compareByDescending<LutInfo> { counts[it.id] ?: 0L }
|
||||
.thenBy { insertionOrder[it.id] })
|
||||
.take(FREQUENT_LUT_LIMIT)
|
||||
return luts.filter { it.id == "none" } + ranked
|
||||
}
|
||||
@@ -16,9 +16,8 @@ fun orderedLutCategoryTitles(
|
||||
uncategorizedText: String,
|
||||
favoriteText: String? = null,
|
||||
includeEmptyCategories: Boolean = false,
|
||||
frequentText: String? = null
|
||||
): List<String> {
|
||||
val reservedCategoryNames = setOfNotNull(builtInText, uncategorizedText, favoriteText, frequentText)
|
||||
val reservedCategoryNames = setOfNotNull(builtInText, uncategorizedText, favoriteText)
|
||||
val dynamicCategories = luts.map { it.category }
|
||||
.distinct()
|
||||
.filter { it.isNotEmpty() && it !in reservedCategoryNames }
|
||||
@@ -31,7 +30,6 @@ fun orderedLutCategoryTitles(
|
||||
val remainingDynamic = dynamicCategories.filterNot { it in orderedKnownCategories }.sorted()
|
||||
|
||||
return buildList {
|
||||
frequentText?.let { add(it) }
|
||||
favoriteText?.let { add(it) }
|
||||
if (orderedKnownCategories.isEmpty()) {
|
||||
add(builtInText)
|
||||
@@ -53,8 +51,6 @@ fun groupLutsForDisplay(
|
||||
builtInText: String,
|
||||
uncategorizedText: String,
|
||||
favoriteText: String? = null,
|
||||
frequentText: String? = null,
|
||||
frequentUsage: Map<String, Long>? = null
|
||||
): List<Pair<String, List<LutInfo>>> {
|
||||
val categories = orderedLutCategoryTitles(
|
||||
luts = luts,
|
||||
@@ -62,11 +58,9 @@ fun groupLutsForDisplay(
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText,
|
||||
favoriteText = favoriteText,
|
||||
frequentText = frequentText
|
||||
)
|
||||
return categories.mapNotNull { category ->
|
||||
val items = when (category) {
|
||||
frequentText -> frequentLuts(luts, frequentUsage)
|
||||
favoriteText -> luts.filter { it.isFavorite }
|
||||
builtInText -> luts.filter { it.isBuiltIn }
|
||||
uncategorizedText -> luts.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
|
||||
@@ -798,16 +798,12 @@ private fun ApplyLutScreen(
|
||||
val listState = rememberLazyListState()
|
||||
val builtInText = androidx.compose.ui.res.stringResource(R.string.built_in)
|
||||
val uncategorizedText = androidx.compose.ui.res.stringResource(R.string.uncategorized)
|
||||
val frequentText = androidx.compose.ui.res.stringResource(R.string.frequent_filters)
|
||||
val frequentUsage by com.hinnka.mycamera.ui.prefs.preferenceValue { it.frequentLutUsage }
|
||||
val groupedLuts = remember(lutData.first, lutData.second, builtInText, uncategorizedText, frequentText, frequentUsage) {
|
||||
val groupedLuts = remember(lutData.first, lutData.second, builtInText, uncategorizedText) {
|
||||
groupLutsForDisplay(
|
||||
luts = lutData.first,
|
||||
categoryOrder = lutData.second,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText,
|
||||
frequentText = frequentText,
|
||||
frequentUsage = frequentUsage
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1657,16 +1657,10 @@ fun CameraScreen(
|
||||
viewModel.prepareCurrentSettingsPresetDraft(defaultPresetName)
|
||||
onPresetEditClick(null)
|
||||
},
|
||||
onResetPresetClick = {
|
||||
discardTransientLookEdits()
|
||||
val preset = allPresets.firstOrNull { it.id == activePresetId }
|
||||
if (presetRequiresPreviewTransition(preset)) {
|
||||
runPreviewTransition { viewModel.resetActivePreset() }
|
||||
} else {
|
||||
viewModel.resetActivePreset()
|
||||
}
|
||||
onEditPreset = { presetId ->
|
||||
activePanel = ActivePanel.NONE
|
||||
onPresetEditClick(presetId)
|
||||
},
|
||||
onSavePresetClick = viewModel::saveCurrentSettingsToActivePreset,
|
||||
onPresetManagementClick = {
|
||||
activePanel = ActivePanel.NONE
|
||||
onPresetManagementClick()
|
||||
|
||||
@@ -33,7 +33,7 @@ import com.hinnka.mycamera.ui.theme.AccentColor
|
||||
internal val CameraLookModeRailWidth = 44.dp
|
||||
internal val CameraLookPanelSurface = Color(0xFF0A0C0F)
|
||||
|
||||
/** Expanded tabs split the measured browser height into equal, full-width hit regions. */
|
||||
/** Each mode gets an equal share of the panel height. */
|
||||
@Composable
|
||||
internal fun CameraLookModeRail(
|
||||
selectedMode: LutSelectorMode,
|
||||
@@ -45,15 +45,11 @@ internal fun CameraLookModeRail(
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.width(CameraLookModeRailWidth)
|
||||
.then(if (expanded) Modifier.fillMaxHeight() else Modifier)
|
||||
.fillMaxHeight()
|
||||
.selectableGroup(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
val tabModifier = if (expanded) {
|
||||
Modifier.fillMaxWidth().weight(1f)
|
||||
} else {
|
||||
Modifier.size(width = CameraLookModeRailWidth, height = 36.dp)
|
||||
}
|
||||
val tabModifier = Modifier.fillMaxWidth().weight(1f)
|
||||
CameraLookModeButton(
|
||||
icon = AppIcons.ColorFilters,
|
||||
label = stringResource(R.string.filter),
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.hinnka.mycamera.ui.components
|
||||
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.pager.HorizontalPager
|
||||
import androidx.compose.foundation.pager.PageSize
|
||||
import androidx.compose.foundation.pager.PagerDefaults
|
||||
import androidx.compose.foundation.pager.PagerSnapDistance
|
||||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.drawWithCache
|
||||
import androidx.compose.ui.graphics.Brush
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.hinnka.mycamera.ui.theme.AccentColor
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
internal fun <T> CompactLookCarousel(
|
||||
options: List<T>,
|
||||
key: (T) -> String,
|
||||
selectedId: String?,
|
||||
onSelected: (T) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
selectOnSettle: Boolean = false,
|
||||
content: @Composable (item: T, selected: Boolean, onClick: () -> Unit, modifier: Modifier) -> Unit
|
||||
) {
|
||||
if (options.isEmpty()) return
|
||||
val ids = remember(options) { options.map(key) }
|
||||
val pager = remember(ids) {
|
||||
PagerState(currentPage = ids.indexOf(selectedId).coerceAtLeast(0)) { ids.size }
|
||||
}
|
||||
val items by rememberUpdatedState(options)
|
||||
val scope = rememberCoroutineScope()
|
||||
val activeId by rememberUpdatedState(selectedId)
|
||||
val select by rememberUpdatedState(onSelected)
|
||||
|
||||
LaunchedEffect(pager, selectOnSettle) {
|
||||
var previousActive = activeId
|
||||
fun selectionPage() = if (selectOnSettle) pager.settledPage else pager.currentPage
|
||||
var previousPage = selectionPage()
|
||||
val pendingSelections = mutableListOf<String>()
|
||||
snapshotFlow { activeId to selectionPage() }.collect { (active, page) ->
|
||||
if (active != previousActive) {
|
||||
previousActive = active
|
||||
// Recomposition may acknowledge several crossed thumbnails at once.
|
||||
val acknowledged = pendingSelections.lastIndexOf(active)
|
||||
if (acknowledged >= 0) {
|
||||
pendingSelections.subList(0, acknowledged + 1).clear()
|
||||
} else {
|
||||
pendingSelections.clear()
|
||||
val index = ids.indexOf(active)
|
||||
if (index >= 0 && index != page) pager.scrollToPage(index)
|
||||
previousPage = selectionPage()
|
||||
return@collect
|
||||
}
|
||||
}
|
||||
if (page != previousPage) {
|
||||
previousPage = page
|
||||
val centeredId = ids[page]
|
||||
if (centeredId != (pendingSelections.lastOrNull() ?: active)) {
|
||||
pendingSelections.add(centeredId)
|
||||
select(items[page])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BoxWithConstraints(modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||
val slot = maxWidth / 5
|
||||
val thumb = (slot - 10.dp).coerceIn(1.dp, 40.dp)
|
||||
HorizontalPager(
|
||||
state = pager,
|
||||
pageSize = PageSize.Fixed(slot),
|
||||
contentPadding = PaddingValues(horizontal = (maxWidth - slot) / 2),
|
||||
flingBehavior = PagerDefaults.flingBehavior(pager, pagerSnapDistance = PagerSnapDistance.atMost(5)),
|
||||
key = { ids[it] },
|
||||
modifier = Modifier.fillMaxWidth().drawWithCache {
|
||||
val clear = CameraLookPanelSurface.copy(alpha = 0f)
|
||||
val edges = Brush.horizontalGradient(
|
||||
0f to CameraLookPanelSurface, 0.16f to clear, 0.84f to clear, 1f to CameraLookPanelSurface
|
||||
)
|
||||
onDrawWithContent {
|
||||
drawContent()
|
||||
drawRect(edges)
|
||||
}
|
||||
}
|
||||
) { index ->
|
||||
val centered = pager.currentPage == index && !pager.isScrollInProgress
|
||||
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||
content(options[index], centered && ids[index] == selectedId, {
|
||||
if (centered) {
|
||||
if (ids[index] != activeId) select(items[index])
|
||||
} else {
|
||||
scope.launch { pager.animateScrollToPage(index) }
|
||||
}
|
||||
}, Modifier.width(thumb))
|
||||
}
|
||||
}
|
||||
if (selectedId in ids || pager.isScrollInProgress) Box(Modifier.size(thumb).border(2.dp, AccentColor, RoundedCornerShape(12.dp)))
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,6 @@ private val LookOptionVerticalPadding = 4.dp
|
||||
private val LookOptionColumnSpacing = 8.dp
|
||||
private val LookOptionRowSpacing = 6.dp
|
||||
private val LookOptionExpandedSize = 48.dp
|
||||
private val LookOptionCompactSize = 40.dp
|
||||
|
||||
private fun lookOptionCellWidth(width: Dp, density: Density): Dp = with(density) {
|
||||
// Round down in pixels so five compact cards never clip the last card at fractional densities.
|
||||
@@ -54,7 +53,6 @@ internal fun <T> LookOptionList(
|
||||
key: (T) -> String,
|
||||
selectedIndex: Int,
|
||||
expanded: Boolean,
|
||||
compact: Boolean = false,
|
||||
itemFooterHeight: Dp = 0.dp,
|
||||
modifier: Modifier = Modifier,
|
||||
contentKey: Any? = null,
|
||||
@@ -70,10 +68,9 @@ internal fun <T> LookOptionList(
|
||||
}
|
||||
}
|
||||
BoxWithConstraints(modifier.fillMaxWidth()) {
|
||||
val cellWidth = lookOptionCellWidth(maxWidth, LocalDensity.current)
|
||||
val itemWidth = minOf(cellWidth, if (expanded) LookOptionExpandedSize else LookOptionCompactSize)
|
||||
val cellHeight = itemWidth + itemFooterHeight
|
||||
if (expanded) {
|
||||
val itemWidth = minOf(lookOptionCellWidth(maxWidth, LocalDensity.current), LookOptionExpandedSize)
|
||||
val cellHeight = itemWidth + itemFooterHeight
|
||||
LazyVerticalGrid(
|
||||
columns = GridCells.Fixed(LookOptionColumns),
|
||||
state = gridState,
|
||||
@@ -98,17 +95,7 @@ internal fun <T> LookOptionList(
|
||||
contentPadding = PaddingValues(horizontal = LookOptionPadding),
|
||||
horizontalArrangement = Arrangement.spacedBy(LookOptionColumnSpacing)
|
||||
) {
|
||||
items(options, key = key) {
|
||||
Box(
|
||||
modifier = if (compact) Modifier.width(cellWidth) else Modifier,
|
||||
contentAlignment = Alignment.TopCenter
|
||||
) {
|
||||
Box(
|
||||
modifier = if (compact) Modifier.width(itemWidth) else Modifier,
|
||||
propagateMinConstraints = compact
|
||||
) { content(it) }
|
||||
}
|
||||
}
|
||||
items(options, key = key) { content(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.basicMarquee
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
@@ -22,6 +21,8 @@ import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -46,14 +47,22 @@ internal fun LookThumbnailItem(
|
||||
onLongClick: (() -> Unit)? = null,
|
||||
onEditClick: (() -> Unit)? = null,
|
||||
isVip: Boolean = false,
|
||||
thumbnailOnly: Boolean = false,
|
||||
content: @Composable BoxScope.() -> Unit
|
||||
) {
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
val highlight = selected && !thumbnailOnly
|
||||
val edit = onEditClick.takeIf { selected }
|
||||
val border = animateColorAsState(
|
||||
if (selected) AccentColor else Color.White.copy(alpha = 0.15f), label = "lookItemBorder"
|
||||
if (highlight) AccentColor else Color.White.copy(alpha = 0.15f), label = "lookItemBorder"
|
||||
)
|
||||
Column(
|
||||
modifier = modifier.width(56.dp).combinedClickable(onClick = onClick, onLongClick = onLongClick),
|
||||
modifier = modifier.width(56.dp).combinedClickable(
|
||||
onClick = edit ?: onClick,
|
||||
onClickLabel = if (edit != null) stringResource(R.string.edit) else null,
|
||||
onLongClick = onLongClick
|
||||
)
|
||||
.then(if (thumbnailOnly) Modifier.semantics { contentDescription = name } else Modifier),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
@@ -64,16 +73,10 @@ internal fun LookThumbnailItem(
|
||||
) {
|
||||
content()
|
||||
// Draw the border above the preview image, so selection remains visible.
|
||||
Box(Modifier.matchParentSize().border(if (selected) 1.2.dp else 1.dp, border.value, shape))
|
||||
if (selected && onEditClick != null) {
|
||||
Box(
|
||||
modifier = Modifier.align(Alignment.BottomEnd).padding(2.dp).size(28.dp)
|
||||
.clip(CircleShape).background(Color.Black.copy(alpha = 0.7f)).clickable(onClick = onEditClick),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(Icons.Default.Edit, stringResource(R.string.edit), tint = Color.White, modifier = Modifier.size(15.dp))
|
||||
}
|
||||
} else if (selected) {
|
||||
Box(Modifier.matchParentSize().border(if (highlight) 1.2.dp else 1.dp, border.value, shape))
|
||||
if (edit != null) {
|
||||
Icon(Icons.Default.Edit, null, tint = AccentColor, modifier = Modifier.align(Alignment.Center).size(18.dp))
|
||||
} else if (highlight) {
|
||||
Icon(
|
||||
Icons.Default.Check, null, tint = Color.Black,
|
||||
modifier = Modifier.align(Alignment.BottomEnd).padding(5.dp).size(18.dp)
|
||||
@@ -90,7 +93,7 @@ internal fun LookThumbnailItem(
|
||||
)
|
||||
}
|
||||
}
|
||||
Text(
|
||||
if (!thumbnailOnly) Text(
|
||||
name, color = if (selected) AccentColor else Color.White,
|
||||
fontSize = 9.sp, lineHeight = 11.sp,
|
||||
fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Normal,
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyRow
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
@@ -39,8 +40,6 @@ import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.data.ContentRepository
|
||||
import com.hinnka.mycamera.frame.FrameInfo
|
||||
import com.hinnka.mycamera.lut.BaselineColorCorrectionTarget
|
||||
import com.hinnka.mycamera.lut.frequentLuts
|
||||
import com.hinnka.mycamera.ui.prefs.preferenceValue
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.model.CameraPreset
|
||||
import com.hinnka.mycamera.model.LutSelectorMode
|
||||
@@ -52,7 +51,6 @@ import com.hinnka.mycamera.ui.icons.AppIcons
|
||||
enum class LutSelectorPresentation { Horizontal, Compact, Expanded }
|
||||
|
||||
private sealed class LutCategoryTab {
|
||||
data object Frequent : LutCategoryTab()
|
||||
data object Favorite : LutCategoryTab()
|
||||
data object BuiltIn : LutCategoryTab()
|
||||
data object Uncategorized : LutCategoryTab()
|
||||
@@ -60,7 +58,6 @@ private sealed class LutCategoryTab {
|
||||
}
|
||||
|
||||
private fun LutCategoryTab.stableKey(): String = when (this) {
|
||||
LutCategoryTab.Frequent -> "fixed:frequent"
|
||||
LutCategoryTab.Favorite -> "fixed:favorite"
|
||||
LutCategoryTab.BuiltIn -> "fixed:built_in"
|
||||
LutCategoryTab.Uncategorized -> "fixed:uncategorized"
|
||||
@@ -139,7 +136,6 @@ private fun LutPanelIconButton(
|
||||
private fun LutPanelPresetActionButton(
|
||||
text: String,
|
||||
onClick: () -> Unit,
|
||||
showAddIcon: Boolean = true,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val shape = RoundedCornerShape(12.dp)
|
||||
@@ -153,14 +149,12 @@ private fun LutPanelPresetActionButton(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(3.dp)
|
||||
) {
|
||||
if (showAddIcon) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(12.dp)
|
||||
)
|
||||
}
|
||||
Icon(
|
||||
imageVector = Icons.Default.Add,
|
||||
contentDescription = null,
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(12.dp)
|
||||
)
|
||||
Text(
|
||||
text = text,
|
||||
color = Color.White,
|
||||
@@ -195,8 +189,6 @@ fun LutSelector(
|
||||
onFrameManagementClick: (() -> Unit)? = null,
|
||||
onPresetSelected: (CameraPreset?) -> Unit = {},
|
||||
onCreatePresetClick: () -> Unit = {},
|
||||
onResetPresetClick: () -> Unit = {},
|
||||
onSavePresetClick: () -> Unit = {},
|
||||
onPresetManagementClick: () -> Unit = {},
|
||||
onEditClick: (() -> Unit)? = null,
|
||||
onManageClick: ((String) -> Unit)? = null,
|
||||
@@ -205,11 +197,9 @@ fun LutSelector(
|
||||
modifier: Modifier = Modifier,
|
||||
presentation: LutSelectorPresentation = LutSelectorPresentation.Horizontal,
|
||||
onExpandedChange: (Boolean) -> Unit = {},
|
||||
presetThumbnailInput: com.hinnka.mycamera.lut.PresetThumbnailInput? = null
|
||||
presetThumbnailInput: com.hinnka.mycamera.lut.PresetThumbnailInput? = null,
|
||||
onEditPreset: ((String) -> Unit)? = null
|
||||
) {
|
||||
val frequentUsage by preferenceValue { it.frequentLutUsage }
|
||||
val frequentItems = remember(availableLuts, frequentUsage) { frequentLuts(availableLuts, frequentUsage) }
|
||||
val frequentText = stringResource(R.string.frequent_filters)
|
||||
val favoriteText = stringResource(R.string.favorite)
|
||||
val builtInText = stringResource(R.string.built_in)
|
||||
val uncategorizedText = stringResource(R.string.uncategorized)
|
||||
@@ -218,8 +208,8 @@ fun LutSelector(
|
||||
val presetText = stringResource(R.string.preset_title)
|
||||
|
||||
// 分类逻辑
|
||||
val categoryTabs = remember(availableLuts, categoryOrder, frequentText, favoriteText, builtInText, uncategorizedText) {
|
||||
val reservedCategoryNames = setOf(frequentText, favoriteText, builtInText, uncategorizedText)
|
||||
val categoryTabs = remember(availableLuts, categoryOrder, favoriteText, builtInText, uncategorizedText) {
|
||||
val reservedCategoryNames = setOf(favoriteText, builtInText, uncategorizedText)
|
||||
val dynamicCategories = availableLuts.map { it.category }
|
||||
.distinct()
|
||||
.filter { it.isNotEmpty() && it !in reservedCategoryNames }
|
||||
@@ -228,7 +218,6 @@ fun LutSelector(
|
||||
val remainingDynamic = dynamicCategories.filterNot { it in orderedEntries }.sorted()
|
||||
|
||||
buildList {
|
||||
add(LutCategoryTab.Frequent)
|
||||
add(LutCategoryTab.Favorite)
|
||||
if (orderedEntries.isEmpty()) {
|
||||
add(LutCategoryTab.BuiltIn)
|
||||
@@ -250,7 +239,6 @@ fun LutSelector(
|
||||
}
|
||||
}
|
||||
fun LutCategoryTab.contains(lut: LutInfo): Boolean = when (this) {
|
||||
LutCategoryTab.Frequent -> frequentItems.any { it.id == lut.id }
|
||||
LutCategoryTab.Favorite -> lut.isFavorite
|
||||
LutCategoryTab.BuiltIn -> lut.isBuiltIn
|
||||
LutCategoryTab.Uncategorized -> !lut.isBuiltIn && lut.category.isEmpty()
|
||||
@@ -258,14 +246,12 @@ fun LutSelector(
|
||||
}
|
||||
|
||||
fun preferredCategoryFor(lut: LutInfo): LutCategoryTab = when {
|
||||
frequentItems.any { it.id == lut.id } -> LutCategoryTab.Frequent
|
||||
lut.isFavorite -> LutCategoryTab.Favorite
|
||||
lut.category.isNotEmpty() -> LutCategoryTab.Category(lut.category)
|
||||
LutCategoryTab.Category(lut.category) in categoryTabs -> LutCategoryTab.Category(lut.category)
|
||||
lut.isBuiltIn -> LutCategoryTab.BuiltIn
|
||||
else -> LutCategoryTab.Uncategorized
|
||||
}
|
||||
|
||||
var selectedCategory by remember { mutableStateOf<LutCategoryTab>(LutCategoryTab.Frequent) }
|
||||
val activeLutId = currentLutId
|
||||
val supportsFrames = onFrameSelected != null
|
||||
val supportsPresets = presetModeEnabled
|
||||
@@ -277,32 +263,28 @@ fun LutSelector(
|
||||
LutSelectorMode.Presets -> if (supportsPresets) LutSelectorMode.Presets else LutSelectorMode.Style
|
||||
}
|
||||
|
||||
LaunchedEffect(activeLutId, availableLuts, categoryTabs, compact, frequentUsage != null) {
|
||||
if (frequentUsage == null || compact) return@LaunchedEffect
|
||||
val selectedLut = availableLuts.find { it.id == activeLutId }
|
||||
selectedCategory = when {
|
||||
selectedLut != null && selectedCategory.contains(selectedLut) -> selectedCategory
|
||||
selectedLut != null -> preferredCategoryFor(selectedLut)
|
||||
selectedCategory in categoryTabs -> selectedCategory
|
||||
else -> LutCategoryTab.Frequent
|
||||
val selectedLut = remember(availableLuts, activeLutId) { availableLuts.find { it.id == activeLutId } }
|
||||
var browsedCategory by remember(expanded, expanded && actualMode == LutSelectorMode.Style) {
|
||||
mutableStateOf<LutCategoryTab?>(if (expanded) null else LutCategoryTab.BuiltIn)
|
||||
}
|
||||
val selectedCategory = browsedCategory?.takeIf { it in categoryTabs }
|
||||
?: selectedLut?.let(::preferredCategoryFor) ?: LutCategoryTab.BuiltIn
|
||||
LaunchedEffect(activeLutId, availableLuts, compact) {
|
||||
if (!compact && selectedLut != null && !selectedCategory.contains(selectedLut)) {
|
||||
browsedCategory = null
|
||||
}
|
||||
}
|
||||
|
||||
val filteredLuts = remember(selectedCategory, availableLuts, frequentItems) {
|
||||
when (selectedCategory) {
|
||||
LutCategoryTab.Frequent -> frequentItems
|
||||
val lutOptions = remember(selectedCategory, availableLuts) {
|
||||
when (val category = selectedCategory) {
|
||||
LutCategoryTab.Favorite -> availableLuts.filter { it.isFavorite }
|
||||
LutCategoryTab.BuiltIn -> availableLuts.filter { it.isBuiltIn }
|
||||
LutCategoryTab.Uncategorized -> availableLuts.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
is LutCategoryTab.Category -> {
|
||||
val categoryName = (selectedCategory as LutCategoryTab.Category).name
|
||||
availableLuts.filter { it.category == categoryName }
|
||||
}
|
||||
is LutCategoryTab.Category -> availableLuts.filter { it.category == category.name }
|
||||
}
|
||||
}
|
||||
|
||||
val lutFooterHeight = lookThumbnailFooterHeight()
|
||||
val lutOptions = if (compact) frequentItems else filteredLuts
|
||||
val optionContent = @Composable {
|
||||
when (actualMode) {
|
||||
LutSelectorMode.Style -> LookOptionList(
|
||||
@@ -310,9 +292,8 @@ fun LutSelector(
|
||||
key = { it.id },
|
||||
selectedIndex = lutOptions.indexOfFirst { it.id == activeLutId },
|
||||
expanded = expanded,
|
||||
compact = compact,
|
||||
itemFooterHeight = lutFooterHeight,
|
||||
contentKey = if (compact) LutCategoryTab.Frequent else selectedCategory
|
||||
contentKey = selectedCategory
|
||||
) { lut ->
|
||||
var lastManageClickTime by remember { mutableLongStateOf(0L) }
|
||||
LutItem(
|
||||
@@ -321,10 +302,11 @@ fun LutSelector(
|
||||
previewBitmap = thumbnail,
|
||||
isSelected = activeLutId == lut.id,
|
||||
isVip = lut.isVip,
|
||||
isCustom = !lut.isBuiltIn,
|
||||
onClick = {
|
||||
if (activeLutId != lut.id) onLutSelected(lut.id)
|
||||
else if (presentation == LutSelectorPresentation.Horizontal || lut.id != "none") {
|
||||
if (activeLutId != lut.id) {
|
||||
browsedCategory = selectedCategory
|
||||
onLutSelected(lut.id)
|
||||
} else if (presentation == LutSelectorPresentation.Horizontal || lut.id != "none") {
|
||||
onEditClick?.invoke()
|
||||
}
|
||||
},
|
||||
@@ -358,7 +340,8 @@ fun LutSelector(
|
||||
thumbnail = thumbnail,
|
||||
thumbnailInput = presetThumbnailInput,
|
||||
expanded = expanded,
|
||||
compact = compact
|
||||
compact = compact,
|
||||
onEditPreset = onEditPreset
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -399,16 +382,28 @@ fun LutSelector(
|
||||
}
|
||||
val browserContent = @Composable {
|
||||
if (actualMode == LutSelectorMode.Style) {
|
||||
val tabIndex = categoryTabs.indexOf(selectedCategory).coerceAtLeast(0)
|
||||
val tabListState = rememberLazyListState(initialFirstVisibleItemIndex = if (expanded) tabIndex else 0)
|
||||
if (expanded) {
|
||||
LaunchedEffect(selectedCategory, tabIndex, activeLutId) {
|
||||
val layout = tabListState.layoutInfo
|
||||
val fullyVisible = layout.visibleItemsInfo.any {
|
||||
it.key == selectedCategory.stableKey() && it.offset >= layout.viewportStartOffset &&
|
||||
it.offset + it.size <= layout.viewportEndOffset
|
||||
}
|
||||
if (!fullyVisible) tabListState.scrollToItem(tabIndex)
|
||||
}
|
||||
}
|
||||
// 分类使用白色文字保证取景画面上的可读性,选中项以金色区分。
|
||||
LazyRow(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
state = tabListState,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp)
|
||||
) {
|
||||
items(categoryTabs, key = { it.stableKey() }) { category ->
|
||||
val isSelected = selectedCategory == category
|
||||
val categoryName = when (category) {
|
||||
LutCategoryTab.Frequent -> frequentText
|
||||
LutCategoryTab.Favorite -> favoriteText
|
||||
LutCategoryTab.BuiltIn -> builtInText
|
||||
LutCategoryTab.Uncategorized -> uncategorizedText
|
||||
@@ -426,7 +421,7 @@ fun LutSelector(
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
indication = null
|
||||
) {
|
||||
selectedCategory = category
|
||||
browsedCategory = category
|
||||
}
|
||||
.padding(horizontal = 9.dp, vertical = 3.dp)
|
||||
)
|
||||
@@ -454,6 +449,7 @@ fun LutSelector(
|
||||
}
|
||||
}
|
||||
|
||||
val activePreset = allPresets.firstOrNull { it.id == activePresetId }
|
||||
val cameraModeRail = @Composable {
|
||||
CameraLookModeRail(
|
||||
selectedMode = actualMode,
|
||||
@@ -468,25 +464,73 @@ fun LutSelector(
|
||||
if (compact) {
|
||||
Column(modifier = modifier.fillMaxWidth()) {
|
||||
headerContent?.invoke()
|
||||
Row(
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.heightIn(min = if (supportsPresets) 84.dp else 64.dp)
|
||||
.clip(RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp))
|
||||
.background(CameraLookPanelSurface),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
cameraModeRail()
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.padding(horizontal = CameraLookModeRailWidth + 4.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
if (actualMode == LutSelectorMode.Style) {
|
||||
val compactLuts = remember(availableLuts) {
|
||||
availableLuts.sortedWith(
|
||||
compareBy<LutInfo> { it.id != "none" }.thenByDescending { it.isFavorite }
|
||||
)
|
||||
}
|
||||
CompactLookCarousel(
|
||||
options = compactLuts,
|
||||
key = { it.id },
|
||||
selectedId = activeLutId ?: "none",
|
||||
onSelected = { onLutSelected(it.id) }
|
||||
) { lut, selected, click, cardModifier ->
|
||||
LutItem(
|
||||
id = lut.id, name = lut.getName(), previewBitmap = thumbnail,
|
||||
isSelected = selected, isVip = lut.isVip, thumbnailOnly = true,
|
||||
onClick = click,
|
||||
onEditClick = onEditClick.takeUnless { lut.id == "none" },
|
||||
onManageClick = onManageClick?.let { manage -> { manage(lut.id) } },
|
||||
modifier = cardModifier
|
||||
)
|
||||
}
|
||||
} else {
|
||||
optionContent()
|
||||
}
|
||||
val caption = when (actualMode) {
|
||||
LutSelectorMode.Style -> availableLuts.firstOrNull { it.id == (activeLutId ?: "none") }?.getName()
|
||||
LutSelectorMode.Presets -> activePreset?.let {
|
||||
val name = presetDisplayName(it)
|
||||
if (activePresetModified) "$name*" else name
|
||||
}
|
||||
LutSelectorMode.Frame -> null
|
||||
}
|
||||
if (caption != null) {
|
||||
Text(
|
||||
caption,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.basicMarquee(iterations = Int.MAX_VALUE),
|
||||
color = Color.White, fontSize = 12.sp, lineHeight = 15.sp,
|
||||
fontWeight = FontWeight.Medium, maxLines = 1, textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.weight(1f)
|
||||
.padding(vertical = 6.dp),
|
||||
modifier = Modifier.matchParentSize(),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(Modifier.weight(1f)) { optionContent() }
|
||||
cameraModeRail()
|
||||
Column(
|
||||
modifier = Modifier.width(52.dp)
|
||||
modifier = Modifier.width(CameraLookModeRailWidth)
|
||||
.clip(RoundedCornerShape(12.dp))
|
||||
.clickable { onExpandedChange(true) }
|
||||
.padding(vertical = 12.dp),
|
||||
.padding(vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Icon(AppIcons.ExpandLess, stringResource(R.string.camera_looks_more), tint = Color.White)
|
||||
@@ -513,6 +557,7 @@ fun LutSelector(
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
browserContent()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -600,19 +645,8 @@ fun LutSelector(
|
||||
}
|
||||
}
|
||||
LutSelectorMode.Presets -> {
|
||||
val currentPreset = allPresets.find { it.id == activePresetId }
|
||||
val currentName = currentPreset?.let { preset ->
|
||||
when (preset.id) {
|
||||
"builtin_default" -> stringResource(R.string.default_text)
|
||||
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
|
||||
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
|
||||
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
|
||||
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
|
||||
"builtin_cinematic" -> stringResource(R.string.preset_builtin_cinematic)
|
||||
"builtin_leica_m9_moment" -> stringResource(R.string.preset_builtin_leica_m9_moment)
|
||||
else -> preset.name
|
||||
}
|
||||
} ?: ""
|
||||
val currentPreset = activePreset
|
||||
val currentName = currentPreset?.let { presetDisplayName(it) }.orEmpty()
|
||||
Text(
|
||||
text = if (currentPreset != null && activePresetModified) {
|
||||
"$currentName*"
|
||||
@@ -632,27 +666,10 @@ fun LutSelector(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
if (currentPreset != null && activePresetModified) {
|
||||
LutPanelPresetActionButton(
|
||||
text = stringResource(R.string.preset_reset),
|
||||
onClick = onResetPresetClick,
|
||||
showAddIcon = false
|
||||
)
|
||||
LutPanelPresetActionButton(
|
||||
text = stringResource(R.string.preset_update),
|
||||
onClick = onSavePresetClick,
|
||||
showAddIcon = false
|
||||
)
|
||||
LutPanelPresetActionButton(
|
||||
text = stringResource(R.string.preset_save_as),
|
||||
onClick = onCreatePresetClick
|
||||
)
|
||||
} else {
|
||||
LutPanelPresetActionButton(
|
||||
text = stringResource(R.string.preset_new),
|
||||
onClick = onCreatePresetClick
|
||||
)
|
||||
}
|
||||
LutPanelPresetActionButton(
|
||||
text = stringResource(if (activePresetModified) R.string.preset_save_as else R.string.preset_new),
|
||||
onClick = onCreatePresetClick
|
||||
)
|
||||
|
||||
LutPanelIconButton(
|
||||
imageVector = Icons.Default.Settings,
|
||||
@@ -721,7 +738,7 @@ private fun LutSelectorModeTab(
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
private fun LutItem(
|
||||
internal fun LutItem(
|
||||
id: String,
|
||||
name: String,
|
||||
previewBitmap: Bitmap?,
|
||||
@@ -731,7 +748,7 @@ private fun LutItem(
|
||||
onManageClick: (() -> Unit)? = null,
|
||||
onEditClick: (() -> Unit)? = null,
|
||||
recipeTarget: BaselineColorCorrectionTarget? = null,
|
||||
isCustom: Boolean = false,
|
||||
thumbnailOnly: Boolean = false,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
@@ -743,6 +760,7 @@ private fun LutItem(
|
||||
onLongClick = onManageClick,
|
||||
onEditClick = onEditClick,
|
||||
isVip = isVip,
|
||||
thumbnailOnly = thumbnailOnly,
|
||||
modifier = modifier
|
||||
) {
|
||||
if (!isNone && previewBitmap != null) {
|
||||
|
||||
@@ -35,32 +35,19 @@ fun PresetsPanel(
|
||||
expanded: Boolean = false,
|
||||
compact: Boolean = false,
|
||||
thumbnail: Bitmap? = null,
|
||||
thumbnailInput: PresetThumbnailInput? = null
|
||||
thumbnailInput: PresetThumbnailInput? = null,
|
||||
onEditPreset: ((String) -> Unit)? = null
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val haptic = LocalHapticFeedback.current
|
||||
val source = remember(thumbnailInput, thumbnail) { thumbnailInput ?: thumbnail?.let(::PresetThumbnailInput) }
|
||||
val renderer = remember(context) { PresetThumbnailRenderer(context.applicationContext) }
|
||||
LookOptionList(
|
||||
options = allPresets,
|
||||
key = { it.id },
|
||||
selectedIndex = allPresets.indexOfFirst { it.id == activePresetId },
|
||||
expanded = expanded,
|
||||
compact = compact,
|
||||
itemFooterHeight = lookThumbnailFooterHeight(),
|
||||
modifier = modifier
|
||||
) { preset ->
|
||||
val selected = activePresetId == preset.id
|
||||
val name = when (preset.id) {
|
||||
"builtin_default" -> stringResource(R.string.default_text)
|
||||
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
|
||||
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
|
||||
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
|
||||
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
|
||||
"builtin_cinematic" -> stringResource(R.string.preset_builtin_cinematic)
|
||||
"builtin_leica_m9_moment" -> stringResource(R.string.preset_builtin_leica_m9_moment)
|
||||
else -> preset.name
|
||||
}
|
||||
val select: (CameraPreset) -> Unit = { preset ->
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onPresetSelected(preset)
|
||||
}
|
||||
val item: @Composable (CameraPreset, Boolean, () -> Unit, Modifier) -> Unit = { preset, selected, click, cardModifier ->
|
||||
val name = presetDisplayName(preset)
|
||||
val request = remember(source, preset) {
|
||||
source?.let { snapshot ->
|
||||
val transformation = object : Transformation {
|
||||
@@ -83,15 +70,14 @@ fun PresetsPanel(
|
||||
LookThumbnailItem(
|
||||
name = if (selected && activePresetModified) "$name*" else name,
|
||||
selected = selected,
|
||||
onClick = {
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onPresetSelected(preset)
|
||||
},
|
||||
onClick = click,
|
||||
onEditClick = onEditPreset?.let { edit -> { edit(preset.id) } },
|
||||
thumbnailOnly = compact,
|
||||
onLongClick = {
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onManagePresets()
|
||||
},
|
||||
modifier = if (expanded) Modifier.fillMaxWidth() else Modifier
|
||||
modifier = cardModifier
|
||||
) {
|
||||
SubcomposeAsyncImage(
|
||||
model = request,
|
||||
@@ -103,6 +89,29 @@ fun PresetsPanel(
|
||||
)
|
||||
}
|
||||
}
|
||||
if (compact) {
|
||||
CompactLookCarousel(
|
||||
options = allPresets,
|
||||
key = { it.id },
|
||||
selectedId = activePresetId,
|
||||
onSelected = select,
|
||||
// Applying a preset can reconfigure the camera. Only apply the one the user lands on.
|
||||
selectOnSettle = true,
|
||||
modifier = modifier,
|
||||
content = item
|
||||
)
|
||||
} else {
|
||||
LookOptionList(
|
||||
options = allPresets,
|
||||
key = { it.id },
|
||||
selectedIndex = allPresets.indexOfFirst { it.id == activePresetId },
|
||||
expanded = expanded,
|
||||
itemFooterHeight = lookThumbnailFooterHeight(),
|
||||
modifier = modifier
|
||||
) { preset ->
|
||||
item(preset, activePresetId == preset.id, { select(preset) }, if (expanded) Modifier.fillMaxWidth() else Modifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -111,3 +120,17 @@ private fun PresetThumbnailPlaceholder() {
|
||||
Icon(AppIcons.Image, null, tint = Color.White.copy(alpha = 0.3f), modifier = Modifier.size(20.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun presetDisplayName(preset: CameraPreset): String {
|
||||
return when (preset.id) {
|
||||
"builtin_default" -> stringResource(R.string.default_text)
|
||||
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
|
||||
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
|
||||
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
|
||||
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
|
||||
"builtin_cinematic" -> stringResource(R.string.preset_builtin_cinematic)
|
||||
"builtin_leica_m9_moment" -> stringResource(R.string.preset_builtin_leica_m9_moment)
|
||||
else -> preset.name
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,6 @@ import com.hinnka.mycamera.video.VideoLogProfile
|
||||
import com.hinnka.mycamera.color.TransferCurve
|
||||
import com.hinnka.mycamera.data.CustomImportManager
|
||||
import com.hinnka.mycamera.data.ZipCubeImportManager
|
||||
import com.hinnka.mycamera.lut.frequentLuts
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.lut.orderedLutCategoryTitles
|
||||
import com.hinnka.mycamera.raw.ColorSpace
|
||||
@@ -72,12 +71,11 @@ private data class CategoryManagementItem(
|
||||
private fun sanitizeCustomLutCategoryInput(
|
||||
category: String,
|
||||
favoriteText: String,
|
||||
frequentText: String,
|
||||
builtInText: String,
|
||||
uncategorizedText: String
|
||||
): String {
|
||||
val trimmedCategory = category.trim()
|
||||
return if (trimmedCategory == frequentText || trimmedCategory == favoriteText || trimmedCategory == builtInText || trimmedCategory == uncategorizedText) {
|
||||
return if (trimmedCategory == favoriteText || trimmedCategory == builtInText || trimmedCategory == uncategorizedText) {
|
||||
""
|
||||
} else {
|
||||
trimmedCategory
|
||||
@@ -230,15 +228,13 @@ fun FilterManagementScreen(
|
||||
|
||||
// 分类管理状态
|
||||
val categoryOrder by preferenceValue { it.categoryOrder }
|
||||
val frequentUsage by preferenceValue { it.frequentLutUsage }
|
||||
var showCategoryManagement by remember { mutableStateOf(false) }
|
||||
|
||||
val builtInText = stringResource(R.string.built_in)
|
||||
val uncategorizedText = stringResource(R.string.uncategorized)
|
||||
val favoriteText = stringResource(R.string.favorite)
|
||||
val frequentText = stringResource(R.string.frequent_filters)
|
||||
val reservedCategoryNames = remember(frequentText, favoriteText, builtInText, uncategorizedText) {
|
||||
setOf(frequentText, favoriteText, builtInText, uncategorizedText)
|
||||
val reservedCategoryNames = remember(favoriteText, builtInText, uncategorizedText) {
|
||||
setOf(favoriteText, builtInText, uncategorizedText)
|
||||
}
|
||||
|
||||
var selectedCategory by remember { mutableStateOf<String?>(null) }
|
||||
@@ -250,19 +246,17 @@ fun FilterManagementScreen(
|
||||
uncategorizedText = uncategorizedText,
|
||||
favoriteText = favoriteText,
|
||||
includeEmptyCategories = true,
|
||||
frequentText = frequentText
|
||||
)
|
||||
}
|
||||
val currentTabIndex = categories.indexOf(selectedCategory).takeIf { it >= 0 } ?: 0
|
||||
val currentCategory = categories[currentTabIndex]
|
||||
val commonCategories = categories.filter { it !in reservedCategoryNames }
|
||||
val managedCategories = categories.filter { it != frequentText && it != favoriteText && it != uncategorizedText }
|
||||
val managedCategories = categories.filter { it != favoriteText && it != uncategorizedText }
|
||||
LaunchedEffect(currentCategory) {
|
||||
selectedIds = emptySet()
|
||||
}
|
||||
val filteredLutList = remember(currentCategory, localLutList, reservedCategoryNames, frequentUsage) {
|
||||
val filteredLutList = remember(currentCategory, localLutList, reservedCategoryNames) {
|
||||
when (currentCategory) {
|
||||
frequentText -> frequentLuts(localLutList, frequentUsage)
|
||||
favoriteText -> localLutList.filter { it.isFavorite }
|
||||
builtInText -> localLutList.filter { it.isBuiltIn }
|
||||
uncategorizedText -> localLutList.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
@@ -353,7 +347,6 @@ fun FilterManagementScreen(
|
||||
|
||||
// 拖拽排序状态
|
||||
val reorderableLazyListState = rememberReorderableLazyListState(lazyListState) { from, to ->
|
||||
if (currentCategory == frequentText) return@rememberReorderableLazyListState
|
||||
val fromId = from.key as? String ?: return@rememberReorderableLazyListState
|
||||
val toId = to.key as? String ?: return@rememberReorderableLazyListState
|
||||
|
||||
@@ -767,7 +760,7 @@ fun FilterManagementScreen(
|
||||
}
|
||||
} else null,
|
||||
showCategory = categories.getOrNull(currentTabIndex) == builtInText && lutInfo.category.isNotEmpty(),
|
||||
dragModifier = if (isSelectionMode || currentCategory == frequentText || lutInfo.id == "none") null else Modifier.draggableHandle()
|
||||
dragModifier = if (isSelectionMode || lutInfo.id == "none") null else Modifier.draggableHandle()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1141,7 +1134,6 @@ fun FilterManagementScreen(
|
||||
val sanitizedCategory = sanitizeCustomLutCategoryInput(
|
||||
category = categoryText,
|
||||
favoriteText = favoriteText,
|
||||
frequentText = frequentText,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText
|
||||
)
|
||||
@@ -1331,7 +1323,6 @@ fun FilterManagementScreen(
|
||||
val targetCategory = sanitizeCustomLutCategoryInput(
|
||||
category = categoryText,
|
||||
favoriteText = favoriteText,
|
||||
frequentText = frequentText,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText
|
||||
)
|
||||
@@ -1516,9 +1507,8 @@ private fun CategoryManagementSheet(
|
||||
val builtInText = stringResource(R.string.built_in)
|
||||
val uncategorizedText = stringResource(R.string.uncategorized)
|
||||
val favoriteText = stringResource(R.string.favorite)
|
||||
val frequentText = stringResource(R.string.frequent_filters)
|
||||
val fixedNames = remember(builtInText, uncategorizedText, favoriteText, frequentText) {
|
||||
setOf(builtInText, uncategorizedText, favoriteText, frequentText)
|
||||
val fixedNames = remember(builtInText, uncategorizedText, favoriteText) {
|
||||
setOf(builtInText, uncategorizedText, favoriteText)
|
||||
}
|
||||
|
||||
var localCategories by remember(categories, fixedNames) {
|
||||
|
||||
@@ -26,9 +26,6 @@ import androidx.compose.ui.unit.sp
|
||||
import com.hinnka.mycamera.ui.theme.AccentColor
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.camera.AspectRatio
|
||||
import com.hinnka.mycamera.model.CameraPreset
|
||||
import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.model.EffectParams
|
||||
import com.hinnka.mycamera.ui.components.ColorRecipePanel
|
||||
import com.hinnka.mycamera.ui.components.LutSelector
|
||||
import com.hinnka.mycamera.ui.components.CurveChannel
|
||||
@@ -36,7 +33,6 @@ import com.hinnka.mycamera.raw.HncsFilmCurveMode
|
||||
import com.hinnka.mycamera.raw.RawProfileToneMapMode
|
||||
import com.hinnka.mycamera.raw.LumixPhotoStyle
|
||||
import com.hinnka.mycamera.raw.CanonPictureStyle
|
||||
import com.hinnka.mycamera.raw.RawToneMappingParameters
|
||||
import com.hinnka.mycamera.raw.RawRenderingEngine
|
||||
import com.hinnka.mycamera.raw.RawDenoiseDefaults
|
||||
import com.hinnka.mycamera.raw.RawSharpeningDefaults
|
||||
@@ -57,7 +53,6 @@ import com.hinnka.mycamera.ui.components.rawDcpLensOptions
|
||||
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
|
||||
import com.hinnka.mycamera.ui.camera.LutEditorTarget
|
||||
import com.hinnka.mycamera.viewmodel.CameraViewModel
|
||||
import java.util.UUID
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@Composable
|
||||
@@ -76,169 +71,110 @@ fun PresetEditorScreen(
|
||||
val context = androidx.compose.ui.platform.LocalContext.current
|
||||
val defaultNewPresetName = stringResource(R.string.preset_new_preset_default)
|
||||
|
||||
// 寻找是否存在编辑目标,如果不存在(新建预设),则尝试从 ViewModel.draftPreset 初始化,或者基于当前状态新建
|
||||
val sourcePreset = remember(presetId, allPresets, defaultNewPresetName) {
|
||||
if (presetId != null) {
|
||||
allPresets.find { it.id == presetId }
|
||||
} else {
|
||||
viewModel.draftPreset ?: viewModel.prepareCurrentSettingsPresetDraft(defaultNewPresetName)
|
||||
}
|
||||
val storedPreset = allPresets.firstOrNull { it.id == presetId }
|
||||
// Capture the camera changes once so later preference updates cannot replace edits in the form.
|
||||
val cameraEdits = remember(storedPreset) { storedPreset?.let(viewModel::unsavedCameraPreset) }
|
||||
val sourcePreset = if (presetId != null) {
|
||||
cameraEdits ?: storedPreset ?: return
|
||||
} else {
|
||||
remember { viewModel.draftPreset ?: viewModel.prepareCurrentSettingsPresetDraft(defaultNewPresetName) }
|
||||
}
|
||||
|
||||
// 在编辑状态中维护各个字段,以便保存
|
||||
var presetName by remember {
|
||||
mutableStateOf(
|
||||
sourcePreset?.name ?: defaultNewPresetName
|
||||
)
|
||||
}
|
||||
var presetName by remember { mutableStateOf(sourcePreset.name) }
|
||||
var selectedLutId by remember { mutableStateOf(sourcePreset.lutId) }
|
||||
var colorRecipe by remember { mutableStateOf(sourcePreset.colorRecipe) }
|
||||
var effects by remember { mutableStateOf(sourcePreset.effects) }
|
||||
var aspectRatio by remember { mutableStateOf(sourcePreset.aspectRatio) }
|
||||
var ultraHdrGainMapEnabled by remember { mutableStateOf(sourcePreset.ultraHdrGainMapEnabled) }
|
||||
var frameId by remember { mutableStateOf(sourcePreset.frameId) }
|
||||
|
||||
var selectedLutId by remember { mutableStateOf(sourcePreset?.lutId) }
|
||||
var colorRecipe by remember { mutableStateOf(sourcePreset?.colorRecipe ?: ColorRecipeParams.DEFAULT) }
|
||||
var effects by remember { mutableStateOf(sourcePreset?.effects ?: EffectParams.DEFAULT) }
|
||||
|
||||
|
||||
// 相机参数
|
||||
var aspectRatio by remember { mutableStateOf(sourcePreset?.aspectRatio ?: AspectRatio.RATIO_4_3.name) }
|
||||
var ultraHdrGainMapEnabled by remember {
|
||||
mutableStateOf(sourcePreset?.ultraHdrGainMapEnabled ?: false)
|
||||
}
|
||||
var frameId by remember { mutableStateOf(sourcePreset?.frameId) }
|
||||
|
||||
// 专业模式参数
|
||||
var rawDcpId by remember { mutableStateOf(sourcePreset?.rawDcpId) }
|
||||
var rawDcpIdsByLens by remember { mutableStateOf(sourcePreset?.rawDcpIdsByLens ?: emptyMap()) }
|
||||
var rawMaxSharpening by remember {
|
||||
mutableStateOf(
|
||||
sourcePreset?.rawMaxSharpening ?: RawSharpeningDefaults.DEFAULT_STRENGTH
|
||||
)
|
||||
}
|
||||
var rawMaxNoiseReduction by remember {
|
||||
mutableStateOf(
|
||||
sourcePreset?.rawMaxNoiseReduction ?: RawDenoiseDefaults.RAW_MAX_LUMA_STRENGTH
|
||||
)
|
||||
}
|
||||
var rawMaxChromaNoiseReduction by remember {
|
||||
mutableStateOf(
|
||||
sourcePreset?.rawMaxChromaNoiseReduction
|
||||
?: RawDenoiseDefaults.RAW_MAX_CHROMA_STRENGTH
|
||||
)
|
||||
}
|
||||
var rawExposureCompensation by remember {
|
||||
mutableStateOf(sourcePreset?.rawExposureCompensation ?: 0f)
|
||||
}
|
||||
var rawHighlightsAdjustment by remember {
|
||||
mutableStateOf(sourcePreset?.rawHighlightsAdjustment ?: 0f)
|
||||
}
|
||||
var rawShadowsAdjustment by remember {
|
||||
mutableStateOf(sourcePreset?.rawShadowsAdjustment ?: 0f)
|
||||
}
|
||||
var rawBlackPointCorrection by remember {
|
||||
mutableStateOf(sourcePreset?.rawBlackPointCorrection ?: 0f)
|
||||
}
|
||||
var rawWhitePointCorrection by remember {
|
||||
mutableStateOf(sourcePreset?.rawWhitePointCorrection ?: 0f)
|
||||
}
|
||||
var rawHncsFilmCurveMode by remember {
|
||||
mutableStateOf(HncsFilmCurveMode.fromPersistedValue(sourcePreset?.rawHncsFilmCurveMode))
|
||||
}
|
||||
var rawHncsColorMatchingEnabled by remember {
|
||||
mutableStateOf(sourcePreset?.rawHncsColorMatchingEnabled ?: true)
|
||||
}
|
||||
var rawLumixColorMatchingEnabled by remember {
|
||||
mutableStateOf(sourcePreset?.rawLumixColorMatchingEnabled ?: true)
|
||||
}
|
||||
var rawEngineToneCurve by remember {
|
||||
mutableStateOf(sourcePreset?.rawEngineToneCurve() ?: RawToneMappingParameters.DEFAULT)
|
||||
}
|
||||
var rawRenderingEngine by remember {
|
||||
mutableStateOf(RawRenderingEngine.fromPersistedName(sourcePreset?.rawRenderingEngine))
|
||||
}
|
||||
var rawLumixPhotoStyle by remember {
|
||||
mutableStateOf(LumixPhotoStyle.fromPersistedValue(sourcePreset?.rawLumixPhotoStyle))
|
||||
}
|
||||
var rawCanonPictureStyle by remember {
|
||||
mutableStateOf(CanonPictureStyle.fromPersistedValue(sourcePreset?.rawCanonPictureStyle))
|
||||
}
|
||||
var rawCanonUseR5ColorMatrix by remember {
|
||||
mutableStateOf(sourcePreset?.rawCanonUseR5ColorMatrix ?: false)
|
||||
}
|
||||
var rawLeicaUseM9ColorMatrix by remember {
|
||||
mutableStateOf(sourcePreset?.rawLeicaUseM9ColorMatrix ?: false)
|
||||
}
|
||||
var rawCanonExposureCompensationEv by remember {
|
||||
mutableStateOf(sourcePreset?.rawCanonExposureCompensationEv
|
||||
?: RawToneMappingParameters.CANON_EXPOSURE_COMPENSATION_DEFAULT)
|
||||
}
|
||||
var rawOppoMasterToneMap by remember { mutableStateOf(sourcePreset?.rawOppoMasterToneMap ?: false) }
|
||||
var rawSpectralFilmStock by remember { mutableStateOf(sourcePreset?.rawSpectralFilmStock ?: "kodak_portra_400") }
|
||||
var rawSpectralFilmPrint by remember { mutableStateOf(sourcePreset?.rawSpectralFilmPrint ?: "kodak_2383") }
|
||||
var rawDcpId by remember { mutableStateOf(sourcePreset.rawDcpId) }
|
||||
var rawDcpIdsByLens by remember { mutableStateOf(sourcePreset.rawDcpIdsByLens) }
|
||||
var rawMaxSharpening by remember { mutableStateOf(sourcePreset.rawMaxSharpening) }
|
||||
var rawMaxNoiseReduction by remember { mutableStateOf(sourcePreset.rawMaxNoiseReduction) }
|
||||
var rawMaxChromaNoiseReduction by remember { mutableStateOf(sourcePreset.rawMaxChromaNoiseReduction) }
|
||||
var rawExposureCompensation by remember { mutableStateOf(sourcePreset.rawExposureCompensation) }
|
||||
var rawHighlightsAdjustment by remember { mutableStateOf(sourcePreset.rawHighlightsAdjustment) }
|
||||
var rawShadowsAdjustment by remember { mutableStateOf(sourcePreset.rawShadowsAdjustment) }
|
||||
var rawBlackPointCorrection by remember { mutableStateOf(sourcePreset.rawBlackPointCorrection) }
|
||||
var rawWhitePointCorrection by remember { mutableStateOf(sourcePreset.rawWhitePointCorrection) }
|
||||
var rawHncsFilmCurveMode by remember { mutableStateOf(HncsFilmCurveMode.fromPersistedValue(sourcePreset.rawHncsFilmCurveMode)) }
|
||||
var rawHncsColorMatchingEnabled by remember { mutableStateOf(sourcePreset.rawHncsColorMatchingEnabled) }
|
||||
var rawLumixColorMatchingEnabled by remember { mutableStateOf(sourcePreset.rawLumixColorMatchingEnabled) }
|
||||
var rawEngineToneCurve by remember { mutableStateOf(sourcePreset.rawEngineToneCurve()) }
|
||||
var rawRenderingEngine by remember { mutableStateOf(RawRenderingEngine.fromPersistedName(sourcePreset.rawRenderingEngine)) }
|
||||
var rawLumixPhotoStyle by remember { mutableStateOf(LumixPhotoStyle.fromPersistedValue(sourcePreset.rawLumixPhotoStyle)) }
|
||||
var rawCanonPictureStyle by remember { mutableStateOf(CanonPictureStyle.fromPersistedValue(sourcePreset.rawCanonPictureStyle)) }
|
||||
var rawCanonUseR5ColorMatrix by remember { mutableStateOf(sourcePreset.rawCanonUseR5ColorMatrix) }
|
||||
var rawLeicaUseM9ColorMatrix by remember { mutableStateOf(sourcePreset.rawLeicaUseM9ColorMatrix) }
|
||||
var rawCanonExposureCompensationEv by remember { mutableStateOf(sourcePreset.rawCanonExposureCompensationEv) }
|
||||
var rawOppoMasterToneMap by remember { mutableStateOf(sourcePreset.rawOppoMasterToneMap) }
|
||||
var rawSpectralFilmStock by remember { mutableStateOf(sourcePreset.rawSpectralFilmStock) }
|
||||
var rawSpectralFilmPrint by remember { mutableStateOf(sourcePreset.rawSpectralFilmPrint) }
|
||||
var rawFotufilmDocument by remember {
|
||||
mutableStateOf(
|
||||
FotufilmDocumentStorage.decode(sourcePreset?.rawFotufilmDocument, "preset ${sourcePreset?.id}")
|
||||
?: if (RawRenderingEngine.fromPersistedName(sourcePreset?.rawRenderingEngine) == RawRenderingEngine.Fotufilm) {
|
||||
FotufilmDocumentStorage.decode(sourcePreset.rawFotufilmDocument, "preset ${sourcePreset.id}")
|
||||
?: if (RawRenderingEngine.fromPersistedName(sourcePreset.rawRenderingEngine) == RawRenderingEngine.Fotufilm) {
|
||||
FotufilmDocumentStorage.defaultDocument()
|
||||
} else {
|
||||
null
|
||||
}
|
||||
)
|
||||
}
|
||||
var rawDROMode by remember { mutableStateOf(sourcePreset?.rawDROMode ?: "OFF") }
|
||||
var rawDROMode by remember { mutableStateOf(sourcePreset.rawDROMode) }
|
||||
|
||||
// 专业模式基准色彩校正
|
||||
var rawBaselineLutId by remember { mutableStateOf(sourcePreset?.rawBaselineLutId) }
|
||||
var rawBaselineLutId by remember { mutableStateOf(sourcePreset.rawBaselineLutId) }
|
||||
|
||||
// 折叠卡片展开控制
|
||||
var expandProfessionalSettings by remember { mutableStateOf(false) }
|
||||
var baselineRecipeEditLutId by remember { mutableStateOf<String?>(null) }
|
||||
var baselineRecipeEditorTarget by remember { mutableStateOf<LutEditorTarget?>(null) }
|
||||
|
||||
// 保存方法
|
||||
val encodedDocument by remember { derivedStateOf { FotufilmDocumentStorage.encode(rawFotufilmDocument) } }
|
||||
val editedPreset = sourcePreset.copy(
|
||||
name = presetName,
|
||||
lutId = selectedLutId,
|
||||
colorRecipe = colorRecipe,
|
||||
effects = effects,
|
||||
aspectRatio = aspectRatio,
|
||||
ultraHdrGainMapEnabled = ultraHdrGainMapEnabled,
|
||||
frameId = frameId,
|
||||
rawDcpId = rawDcpId,
|
||||
rawDcpIdsByLens = rawDcpIdsByLens,
|
||||
rawHncsFilmCurveMode = rawHncsFilmCurveMode.persistedValue,
|
||||
rawRenderingEngine = rawRenderingEngine.name,
|
||||
rawMaxSharpening = rawMaxSharpening,
|
||||
rawMaxNoiseReduction = rawMaxNoiseReduction,
|
||||
rawMaxChromaNoiseReduction = rawMaxChromaNoiseReduction,
|
||||
rawExposureCompensation = rawExposureCompensation,
|
||||
rawHighlightsAdjustment = rawHighlightsAdjustment,
|
||||
rawShadowsAdjustment = rawShadowsAdjustment,
|
||||
rawBlackPointCorrection = rawBlackPointCorrection,
|
||||
rawWhitePointCorrection = rawWhitePointCorrection,
|
||||
rawOppoMasterToneMap = rawOppoMasterToneMap,
|
||||
rawLumixPhotoStyle = rawLumixPhotoStyle.assetName,
|
||||
rawCanonPictureStyle = rawCanonPictureStyle.persistedValue,
|
||||
rawCanonExposureCompensationEv = rawCanonExposureCompensationEv,
|
||||
rawLumixColorMatchingEnabled = rawLumixColorMatchingEnabled,
|
||||
rawHncsColorMatchingEnabled = rawHncsColorMatchingEnabled,
|
||||
rawCanonUseR5ColorMatrix = rawCanonUseR5ColorMatrix,
|
||||
rawLeicaUseM9ColorMatrix = rawLeicaUseM9ColorMatrix,
|
||||
rawAgxBlackRelativeExposure = rawEngineToneCurve.agxBlackRelativeExposure,
|
||||
rawAgxWhiteRelativeExposure = rawEngineToneCurve.agxWhiteRelativeExposure,
|
||||
rawAgxToe = rawEngineToneCurve.agxToe,
|
||||
rawAgxShoulder = rawEngineToneCurve.agxShoulder,
|
||||
rawFilmicBlackRelativeExposure = rawEngineToneCurve.filmicBlackRelativeExposure,
|
||||
rawFilmicWhiteRelativeExposure = rawEngineToneCurve.filmicWhiteRelativeExposure,
|
||||
rawSpectralFilmStock = rawSpectralFilmStock,
|
||||
rawSpectralFilmPrint = rawSpectralFilmPrint,
|
||||
rawFotufilmDocument = encodedDocument,
|
||||
rawDROMode = rawDROMode,
|
||||
rawBaselineLutId = rawBaselineLutId
|
||||
)
|
||||
val initialForm = remember(sourcePreset) { editedPreset }
|
||||
val onSave = {
|
||||
val newPresetId = presetId ?: sourcePreset?.id ?: UUID.randomUUID().toString()
|
||||
val isBuiltInFlag = sourcePreset?.isBuiltIn ?: false // 如果是内置预设的修改,依然保留 isBuiltIn 以展示内置标签
|
||||
val savedPreset = CameraPreset(
|
||||
id = newPresetId,
|
||||
name = presetName,
|
||||
lutId = selectedLutId,
|
||||
colorRecipe = colorRecipe,
|
||||
effects = effects,
|
||||
aspectRatio = aspectRatio,
|
||||
ultraHdrGainMapEnabled = ultraHdrGainMapEnabled,
|
||||
frameId = frameId,
|
||||
rawDcpId = rawDcpId,
|
||||
rawDcpIdsByLens = rawDcpIdsByLens,
|
||||
rawHncsFilmCurveMode = rawHncsFilmCurveMode.persistedValue,
|
||||
rawRenderingEngine = rawRenderingEngine.name,
|
||||
rawMaxSharpening = rawMaxSharpening,
|
||||
rawMaxNoiseReduction = rawMaxNoiseReduction,
|
||||
rawMaxChromaNoiseReduction = rawMaxChromaNoiseReduction,
|
||||
rawExposureCompensation = rawExposureCompensation,
|
||||
rawHighlightsAdjustment = rawHighlightsAdjustment,
|
||||
rawShadowsAdjustment = rawShadowsAdjustment,
|
||||
rawBlackPointCorrection = rawBlackPointCorrection,
|
||||
rawWhitePointCorrection = rawWhitePointCorrection,
|
||||
rawOppoMasterToneMap = rawOppoMasterToneMap,
|
||||
rawLumixPhotoStyle = rawLumixPhotoStyle.assetName,
|
||||
rawCanonPictureStyle = rawCanonPictureStyle.persistedValue,
|
||||
rawCanonExposureCompensationEv = rawCanonExposureCompensationEv,
|
||||
rawLumixColorMatchingEnabled = rawLumixColorMatchingEnabled,
|
||||
rawHncsColorMatchingEnabled = rawHncsColorMatchingEnabled,
|
||||
rawCanonUseR5ColorMatrix = rawCanonUseR5ColorMatrix,
|
||||
rawLeicaUseM9ColorMatrix = rawLeicaUseM9ColorMatrix,
|
||||
rawAgxBlackRelativeExposure = rawEngineToneCurve.agxBlackRelativeExposure,
|
||||
rawAgxWhiteRelativeExposure = rawEngineToneCurve.agxWhiteRelativeExposure,
|
||||
rawAgxToe = rawEngineToneCurve.agxToe,
|
||||
rawAgxShoulder = rawEngineToneCurve.agxShoulder,
|
||||
rawFilmicBlackRelativeExposure = rawEngineToneCurve.filmicBlackRelativeExposure,
|
||||
rawFilmicWhiteRelativeExposure = rawEngineToneCurve.filmicWhiteRelativeExposure,
|
||||
rawSpectralFilmStock = rawSpectralFilmStock,
|
||||
rawSpectralFilmPrint = rawSpectralFilmPrint,
|
||||
rawFotufilmDocument = FotufilmDocumentStorage.encode(rawFotufilmDocument),
|
||||
rawDROMode = rawDROMode,
|
||||
rawBaselineLutId = rawBaselineLutId,
|
||||
isBuiltIn = isBuiltInFlag
|
||||
)
|
||||
viewModel.savePreset(savedPreset)
|
||||
viewModel.savePreset(editedPreset)
|
||||
viewModel.draftPreset = null
|
||||
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
|
||||
onBack()
|
||||
@@ -265,6 +201,14 @@ fun PresetEditorScreen(
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
if (storedPreset != null && (cameraEdits != null || editedPreset != initialForm)) {
|
||||
TextButton(onClick = {
|
||||
if (cameraEdits != null) viewModel.applyPreset(storedPreset)
|
||||
onBack()
|
||||
}) {
|
||||
Text(stringResource(R.string.preset_revert))
|
||||
}
|
||||
}
|
||||
TextButton(onClick = { onSave() }) {
|
||||
Text(
|
||||
text = stringResource(R.string.preset_save),
|
||||
@@ -524,8 +468,8 @@ fun PresetEditorScreen(
|
||||
engineNames.entries.find { it.value == selectedName }?.key?.let { engine ->
|
||||
rawRenderingEngine = engine
|
||||
if (engine == RawRenderingEngine.Spektrafilm) {
|
||||
if (rawSpectralFilmStock.isBlank()) rawSpectralFilmStock = "kodak_portra_400"
|
||||
if (rawSpectralFilmPrint.isBlank()) rawSpectralFilmPrint = "kodak_2383"
|
||||
if (rawSpectralFilmStock.isNullOrBlank()) rawSpectralFilmStock = "kodak_portra_400"
|
||||
if (rawSpectralFilmPrint.isNullOrBlank()) rawSpectralFilmPrint = "kodak_2383"
|
||||
}
|
||||
if (engine == RawRenderingEngine.Fotufilm && rawFotufilmDocument == null) {
|
||||
rawFotufilmDocument = FotufilmDocumentStorage.defaultDocument()
|
||||
@@ -690,7 +634,7 @@ fun PresetEditorScreen(
|
||||
|
||||
AnimatedVisibility(visible = rawRenderingEngine == RawRenderingEngine.Spektrafilm) {
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
val currentStockLabel = SpectralFilmUiInfo.getFilmDisplayName(rawSpectralFilmStock)
|
||||
val currentStockLabel = SpectralFilmUiInfo.getFilmDisplayName(rawSpectralFilmStock ?: "kodak_portra_400")
|
||||
val stockMap = SpectralFilmUiInfo.availableFilms.associateWith { SpectralFilmUiInfo.getFilmDisplayName(it) }
|
||||
DropdownSettingItem(
|
||||
title = stringResource(R.string.settings_negative_film),
|
||||
@@ -710,7 +654,7 @@ fun PresetEditorScreen(
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
HorizontalDivider(color = Color.White.copy(alpha = 0.05f), modifier = Modifier.padding(vertical = 8.dp))
|
||||
|
||||
val currentPrintLabel = SpectralFilmUiInfo.getPrintDisplayName(rawSpectralFilmPrint)
|
||||
val currentPrintLabel = SpectralFilmUiInfo.getPrintDisplayName(rawSpectralFilmPrint ?: "kodak_2383")
|
||||
val printMap = SpectralFilmUiInfo.availablePrints.associateWith { SpectralFilmUiInfo.getPrintDisplayName(it) }
|
||||
DropdownSettingItem(
|
||||
title = stringResource(R.string.settings_print_paper),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.hinnka.mycamera.ui.settings
|
||||
|
||||
import com.hinnka.mycamera.ui.components.presetDisplayName
|
||||
import com.hinnka.mycamera.ui.prefs.preferenceValue
|
||||
import android.net.Uri
|
||||
import android.widget.Toast
|
||||
@@ -483,20 +484,6 @@ private fun PresetManagementItem(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun presetDisplayName(preset: CameraPreset): String {
|
||||
return when (preset.id) {
|
||||
"builtin_default" -> stringResource(R.string.default_text)
|
||||
"builtin_hasselblad_natural" -> stringResource(R.string.preset_builtin_hasselblad_natural)
|
||||
"builtin_portrait" -> stringResource(R.string.preset_builtin_portrait)
|
||||
"builtin_classic_film" -> stringResource(R.string.preset_builtin_classic_film)
|
||||
"builtin_monochrome" -> stringResource(R.string.preset_builtin_monochrome)
|
||||
"builtin_cinematic" -> stringResource(R.string.preset_builtin_cinematic)
|
||||
"builtin_leica_m9_moment" -> stringResource(R.string.preset_builtin_leica_m9_moment)
|
||||
else -> preset.name
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PresetBadge(text: String, highlighted: Boolean) {
|
||||
Box(
|
||||
|
||||
@@ -1244,21 +1244,21 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
fun resetActivePreset() {
|
||||
val presetId = userPreferencesRepository.current.activePresetId ?: return
|
||||
val preset = allPresets.value.firstOrNull { it.id == presetId } ?: return
|
||||
applyPreset(preset)
|
||||
}
|
||||
|
||||
fun saveCurrentSettingsToActivePreset() {
|
||||
val presetId = userPreferencesRepository.current.activePresetId ?: return
|
||||
val preset = allPresets.value.firstOrNull { it.id == presetId } ?: return
|
||||
savePreset(
|
||||
createPresetFromCurrentSettings(
|
||||
id = preset.id,
|
||||
name = preset.name,
|
||||
isBuiltIn = preset.isBuiltIn
|
||||
)
|
||||
fun unsavedCameraPreset(preset: CameraPreset): CameraPreset? {
|
||||
val matchState = activePresetMatchState.value ?: return null
|
||||
if (presetApplyInProgress.value || matchState.prefs.activePresetId != preset.id) return null
|
||||
val snapshot = matchState.toPresetMatchSnapshot()
|
||||
if (snapshot.matches(preset)) return null
|
||||
if (snapshot.isProfessionalMode) {
|
||||
return createPresetFromCurrentSettings(preset.id, preset.name, preset.isBuiltIn)
|
||||
}
|
||||
// Only merge fields this shooting mode actually applied from the preset.
|
||||
return preset.copy(
|
||||
lutId = snapshot.lutId,
|
||||
colorRecipe = snapshot.colorRecipe.withoutIndependentEffects(),
|
||||
effects = snapshot.effects,
|
||||
frameId = snapshot.frameId,
|
||||
aspectRatio = if (snapshot.captureMode == CaptureMode.PHOTO) snapshot.aspectRatio else preset.aspectRatio
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1144,6 +1144,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">徠卡一瞬</string>
|
||||
<string name="preset_save">儲存</string>
|
||||
<string name="preset_reset">重設</string>
|
||||
<string name="preset_revert">還原</string>
|
||||
<string name="preset_update">同步儲存</string>
|
||||
<string name="preset_save_as">另存新檔</string>
|
||||
<string name="preset_editor_title">編輯拍攝預設</string>
|
||||
|
||||
@@ -490,4 +490,5 @@
|
||||
<string name="frequent_filters">Häufig</string>
|
||||
<string name="camera_looks_more">Mehr</string>
|
||||
<string name="camera_looks_collapse">Einklappen</string>
|
||||
<string name="preset_revert">Zurücksetzen</string>
|
||||
</resources>
|
||||
@@ -1339,6 +1339,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">Instant Leica</string>
|
||||
<string name="preset_save">Enregistrer</string>
|
||||
<string name="preset_reset">Réinitialiser</string>
|
||||
<string name="preset_revert">Rétablir</string>
|
||||
<string name="preset_update">Mettre à jour</string>
|
||||
<string name="preset_save_as">Enregistrer sous</string>
|
||||
<string name="preset_editor_title">Modifier le préréglage</string>
|
||||
|
||||
@@ -490,4 +490,5 @@
|
||||
<string name="frequent_filters">Sering digunakan</string>
|
||||
<string name="camera_looks_more">Lainnya</string>
|
||||
<string name="camera_looks_collapse">Ciutkan</string>
|
||||
<string name="preset_revert">Pulihkan</string>
|
||||
</resources>
|
||||
@@ -999,6 +999,7 @@
|
||||
<string name="preset_builtin_cinematic">シネマティック</string>
|
||||
<string name="preset_save">保存</string>
|
||||
<string name="preset_reset">リセット</string>
|
||||
<string name="preset_revert">元に戻す</string>
|
||||
<string name="preset_update">更新</string>
|
||||
<string name="preset_save_as">別名で保存</string>
|
||||
<string name="preset_editor_title">プリセットを編集</string>
|
||||
|
||||
@@ -491,4 +491,5 @@
|
||||
<string name="frequent_filters">자주 사용</string>
|
||||
<string name="camera_looks_more">더 보기</string>
|
||||
<string name="camera_looks_collapse">접기</string>
|
||||
<string name="preset_revert">되돌리기</string>
|
||||
</resources>
|
||||
@@ -491,4 +491,5 @@
|
||||
<string name="frequent_filters">Frequentes</string>
|
||||
<string name="camera_looks_more">Mais</string>
|
||||
<string name="camera_looks_collapse">Recolher</string>
|
||||
<string name="preset_revert">Reverter</string>
|
||||
</resources>
|
||||
@@ -847,6 +847,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">ช่วงเวลาไลก้า</string>
|
||||
<string name="preset_save">บันทึก</string>
|
||||
<string name="preset_reset">รีเซ็ต</string>
|
||||
<string name="preset_revert">คืนค่า</string>
|
||||
<string name="preset_update">อัปเดต</string>
|
||||
<string name="preset_save_as">บันทึกเป็น</string>
|
||||
<string name="preset_editor_title">แก้ไขการตั้งค่าการถ่ายภาพล่วงหน้า</string>
|
||||
|
||||
@@ -1165,6 +1165,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">徕卡一瞬</string>
|
||||
<string name="preset_save">保存</string>
|
||||
<string name="preset_reset">重置</string>
|
||||
<string name="preset_revert">恢复</string>
|
||||
<string name="preset_update">同步保存</string>
|
||||
<string name="preset_save_as">另存为</string>
|
||||
<string name="preset_editor_title">编辑拍摄预设</string>
|
||||
|
||||
@@ -1138,6 +1138,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">徠卡一瞬</string>
|
||||
<string name="preset_save">儲存</string>
|
||||
<string name="preset_reset">重設</string>
|
||||
<string name="preset_revert">還原</string>
|
||||
<string name="preset_update">同步儲存</string>
|
||||
<string name="preset_save_as">另存新檔</string>
|
||||
<string name="preset_editor_title">編輯拍攝預設</string>
|
||||
|
||||
@@ -1144,6 +1144,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">徠卡一瞬</string>
|
||||
<string name="preset_save">儲存</string>
|
||||
<string name="preset_reset">重設</string>
|
||||
<string name="preset_revert">還原</string>
|
||||
<string name="preset_update">同步儲存</string>
|
||||
<string name="preset_save_as">另存新檔</string>
|
||||
<string name="preset_editor_title">編輯拍攝預設</string>
|
||||
|
||||
@@ -1176,6 +1176,7 @@
|
||||
<string name="preset_builtin_leica_m9_moment">Leica Moment</string>
|
||||
<string name="preset_save">Save</string>
|
||||
<string name="preset_reset">Reset</string>
|
||||
<string name="preset_revert">Revert</string>
|
||||
<string name="preset_update">Update</string>
|
||||
<string name="preset_save_as">Save As</string>
|
||||
|
||||
|
||||
Reference in new issue
Block a user