refactor: reorganize built-in LUT categories and assets
This commit is contained in:
1 parent
5b0ad9ebb5
commit
9915360a25
67 files changed
+381
-546
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,8 +7,8 @@
|
||||
"zh": "无"
|
||||
},
|
||||
"path": "",
|
||||
"isDefault": false,
|
||||
"isVip": false
|
||||
"isVip": false,
|
||||
"category": "Digital"
|
||||
},
|
||||
{
|
||||
"id": "standard",
|
||||
@@ -16,10 +16,191 @@
|
||||
"en": "Standard",
|
||||
"zh": "标准"
|
||||
},
|
||||
"path": "standard.plut",
|
||||
"path": "digital/standard.plut",
|
||||
"category": "Digital",
|
||||
"isDefault": true,
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "canon_portrait",
|
||||
"name": {
|
||||
"en": "Canon Portrait",
|
||||
"zh": "佳能人像"
|
||||
},
|
||||
"path": "digital/canon_portrait.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "cc",
|
||||
"name": {
|
||||
"en": "Fujifilm CC",
|
||||
"zh": "富士CC"
|
||||
},
|
||||
"path": "digital/cc.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "nc",
|
||||
"name": {
|
||||
"en": "Fujifilm NC",
|
||||
"zh": "富士NC"
|
||||
},
|
||||
"path": "digital/nc.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "leica_m9",
|
||||
"name": {
|
||||
"en": "Leica M9 CCD",
|
||||
"zh": "徕卡M9"
|
||||
},
|
||||
"path": "digital/leica_m9.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "lumix_s9",
|
||||
"name": {
|
||||
"en": "LUMIX S9",
|
||||
"zh": "松下S9"
|
||||
},
|
||||
"path": "digital/lumix_s9.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "monochrome",
|
||||
"name": {
|
||||
"en": "Monochrome",
|
||||
"zh": "黑白"
|
||||
},
|
||||
"path": "digital/monochrome.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax_bright",
|
||||
"name": {
|
||||
"en": "Pentax Bright",
|
||||
"zh": "宾得明亮"
|
||||
},
|
||||
"path": "digital/pentax_bright.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_negative",
|
||||
"name": {
|
||||
"en": "Ricoh Negative",
|
||||
"zh": "理光负片"
|
||||
},
|
||||
"path": "digital/ricoh_negative.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_positive",
|
||||
"name": {
|
||||
"en": "Ricoh Positive",
|
||||
"zh": "理光正片"
|
||||
},
|
||||
"path": "digital/ricoh_positive.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "sony_fl2",
|
||||
"name": {
|
||||
"en": "Sony FL2",
|
||||
"zh": "索尼FL2"
|
||||
},
|
||||
"path": "digital/sony_fl2.plut",
|
||||
"category": "Digital",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_5207",
|
||||
"name": {
|
||||
"en": "Kodak 5207",
|
||||
"zh": "柯达5207"
|
||||
},
|
||||
"path": "film/5207.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_5219",
|
||||
"name": {
|
||||
"en": "Kodak 5219",
|
||||
"zh": "柯达5219"
|
||||
},
|
||||
"path": "film/5219.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_fujifilm_c200",
|
||||
"name": {
|
||||
"en": "Fujifilm C200",
|
||||
"zh": "富士C200"
|
||||
},
|
||||
"path": "film/C200.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_ektar_100",
|
||||
"name": {
|
||||
"en": "Kodak Ektar 100",
|
||||
"zh": "柯达Ektar100"
|
||||
},
|
||||
"path": "film/Ektar100.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_gc_400",
|
||||
"name": {
|
||||
"en": "Kodak GC 400",
|
||||
"zh": "柯达全能400"
|
||||
},
|
||||
"path": "film/GC400.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_gold_200",
|
||||
"name": {
|
||||
"en": "Kodak Gold 200",
|
||||
"zh": "柯达金200"
|
||||
},
|
||||
"path": "film/Gold200.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_portra_400",
|
||||
"name": {
|
||||
"en": "Kodak Portra 400",
|
||||
"zh": "柯达炮塔400"
|
||||
},
|
||||
"path": "film/Portra400.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_fujifilm_pro_400h",
|
||||
"name": {
|
||||
"en": "Fujifilm Pro 400H",
|
||||
"zh": "富士Pro400H"
|
||||
},
|
||||
"path": "film/Pro400H.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "log_restore_apple_log2",
|
||||
"name": {
|
||||
@@ -79,248 +260,6 @@
|
||||
"path": "log/log_restore_llog.plut",
|
||||
"category": "Log",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "leica_m9",
|
||||
"name": {
|
||||
"en": "M9 CCD",
|
||||
"zh": "徕卡M9"
|
||||
},
|
||||
"path": "Leica_M9_STD.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "leica",
|
||||
"name": {
|
||||
"en": "Leica",
|
||||
"zh": "徕卡ETN"
|
||||
},
|
||||
"path": "leica.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "monochrome",
|
||||
"name": {
|
||||
"en": "Monochrome",
|
||||
"zh": "徕卡黑白"
|
||||
},
|
||||
"path": "monochrome.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "Hasselblad",
|
||||
"name": {
|
||||
"en": "Hasselblad",
|
||||
"zh": "哈苏自然"
|
||||
},
|
||||
"path": "Hasselblad.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "Hasselblad_portrait",
|
||||
"name": {
|
||||
"en": "Hasselblad Portrait",
|
||||
"zh": "哈苏人像"
|
||||
},
|
||||
"path": "Hasselblad_portrait.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "fl3",
|
||||
"name": {
|
||||
"en": "FL3",
|
||||
"zh": "FL3"
|
||||
},
|
||||
"path": "fl3.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "nc",
|
||||
"name": {
|
||||
"en": "NC",
|
||||
"zh": "富士NC"
|
||||
},
|
||||
"path": "nc.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "cc",
|
||||
"name": {
|
||||
"en": "CC",
|
||||
"zh": "富士CC"
|
||||
},
|
||||
"path": "cc.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "astia",
|
||||
"name": {
|
||||
"en": "Astia",
|
||||
"zh": "富士Astia"
|
||||
},
|
||||
"path": "astia.plut",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_negative",
|
||||
"name": {
|
||||
"en": "Negative",
|
||||
"zh": "理光负片"
|
||||
},
|
||||
"path": "ricoh_negative.plut",
|
||||
"isDefault": false,
|
||||
"category": "Ricoh",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_positive",
|
||||
"name": {
|
||||
"en": "Positive",
|
||||
"zh": "理光正片"
|
||||
},
|
||||
"path": "ricoh_positive.plut",
|
||||
"category": "Ricoh",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_gr2_positive",
|
||||
"name": {
|
||||
"en": "Positive GR2",
|
||||
"zh": "理光正片GR2"
|
||||
},
|
||||
"path": "Ricoh_GR2_POSI.plut",
|
||||
"category": "Ricoh",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_green",
|
||||
"name": {
|
||||
"en": "Green",
|
||||
"zh": "电影绿"
|
||||
},
|
||||
"path": "ricoh_green.plut",
|
||||
"category": "Ricoh",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "ricoh_yellow",
|
||||
"name": {
|
||||
"en": "Yellow",
|
||||
"zh": "电影黄"
|
||||
},
|
||||
"path": "ricoh_yellow.plut",
|
||||
"category": "Ricoh",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax",
|
||||
"name": {
|
||||
"en": "Pentax",
|
||||
"zh": "宾得明亮"
|
||||
},
|
||||
"path": "pentax.plut",
|
||||
"category": "Pentax",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax_harubeni",
|
||||
"name": {
|
||||
"en": "Harubeni",
|
||||
"zh": "宾得春红"
|
||||
},
|
||||
"path": "Pentax_Harubeni.plut",
|
||||
"category": "Pentax",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax_katen",
|
||||
"name": {
|
||||
"en": "Katen",
|
||||
"zh": "宾得夏天"
|
||||
},
|
||||
"path": "Pentax_Katen.plut",
|
||||
"category": "Pentax",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax_kyushu",
|
||||
"name": {
|
||||
"en": "Kyushu",
|
||||
"zh": "宾得九秋"
|
||||
},
|
||||
"path": "Pentax_Kyushu.plut",
|
||||
"category": "Pentax",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "pentax_fuyuno",
|
||||
"name": {
|
||||
"en": "Fuyuno",
|
||||
"zh": "宾得冬野"
|
||||
},
|
||||
"path": "Pentax_Fuyuno.plut",
|
||||
"category": "Pentax",
|
||||
"isVip": false
|
||||
},
|
||||
{
|
||||
"id": "film_kodak_ultramax_400",
|
||||
"name": {
|
||||
"en": "Ultramax 400",
|
||||
"zh": "Ultramax 400"
|
||||
},
|
||||
"path": "ultramax400.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "e100",
|
||||
"name": {
|
||||
"en": "E100",
|
||||
"zh": "E100"
|
||||
},
|
||||
"path": "e100.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_rollei_cn200",
|
||||
"name": {
|
||||
"en": "CN200",
|
||||
"zh": "CN200"
|
||||
},
|
||||
"path": "cn200.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_natura_1600",
|
||||
"name": {
|
||||
"en": "Natura 1600",
|
||||
"zh": "Natura 1600"
|
||||
},
|
||||
"path": "nature1600.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_superia_1600",
|
||||
"name": {
|
||||
"en": "Superia 1600",
|
||||
"zh": "Superia 1600"
|
||||
},
|
||||
"path": "superia1600.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
},
|
||||
{
|
||||
"id": "film_cinestill_800t",
|
||||
"name": {
|
||||
"en": "Cinestill 800T",
|
||||
"zh": "Cinestill 800T"
|
||||
},
|
||||
"path": "cinestill800t.33.plut",
|
||||
"category": "Film",
|
||||
"isVip": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -86,7 +86,6 @@ class CustomImportManager(private val context: Context) {
|
||||
private const val MAX_RAW_NOISE_PROFILE_CHARS = 1024 * 1024
|
||||
private const val CATEGORY_OVERRIDES_CONFIG = "category_overrides.json"
|
||||
private const val FAVORITE_OVERRIDES_CONFIG = "favorite_overrides.json"
|
||||
private const val BUILT_IN_LUT_CATEGORY_INITIALIZED_CONFIG = "built_in_lut_categories_initialized.json"
|
||||
|
||||
// 自定义字体目录
|
||||
private const val CUSTOM_FONT_DIR = "custom_fonts"
|
||||
@@ -175,46 +174,6 @@ class CustomImportManager(private val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
fun initializeBuiltInLutCategoriesIfNeeded(luts: List<LutInfo>) {
|
||||
try {
|
||||
val categorizedLuts = luts
|
||||
.filter { it.isBuiltIn && it.category.isNotEmpty() }
|
||||
.associate { it.id to it.category }
|
||||
if (categorizedLuts.isEmpty()) return
|
||||
|
||||
val initializedFile = File(context.filesDir, BUILT_IN_LUT_CATEGORY_INITIALIZED_CONFIG)
|
||||
val initializedJson = if (initializedFile.exists()) {
|
||||
JSONObject(initializedFile.readText())
|
||||
} else {
|
||||
JSONObject()
|
||||
}
|
||||
|
||||
val overridesFile = File(context.filesDir, CATEGORY_OVERRIDES_CONFIG)
|
||||
val overridesJson = if (overridesFile.exists()) {
|
||||
JSONObject(overridesFile.readText())
|
||||
} else {
|
||||
JSONObject()
|
||||
}
|
||||
|
||||
var updatedCount = 0
|
||||
categorizedLuts.forEach { (id, category) ->
|
||||
if (!initializedJson.optBoolean(id, false)) {
|
||||
overridesJson.put(id, category)
|
||||
initializedJson.put(id, true)
|
||||
updatedCount++
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedCount > 0) {
|
||||
overridesFile.writeText(overridesJson.toString())
|
||||
initializedFile.writeText(initializedJson.toString())
|
||||
}
|
||||
PLog.d(TAG, "Built-in LUT categories initialized: $updatedCount")
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to initialize built-in LUT categories", e)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收藏重写映射。
|
||||
*/
|
||||
@@ -1111,17 +1070,14 @@ class CustomImportManager(private val context: Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新 LUT 分类(支持内置和自定义)
|
||||
* 更新自定义 LUT 分类
|
||||
*/
|
||||
fun updateLutCategory(lutId: String, newCategory: String): Boolean {
|
||||
if (!isCustomLutId(lutId)) return false
|
||||
return try {
|
||||
val sanitizedCategory = if (isCustomLutId(lutId)) {
|
||||
sanitizeCustomLutCategory(newCategory)
|
||||
} else {
|
||||
newCategory.trim()
|
||||
}
|
||||
val sanitizedCategory = sanitizeCustomLutCategory(newCategory)
|
||||
|
||||
// 1. 同步到分类重写文件 (核心:支持内置)
|
||||
// 同步到分类重写文件,兼容已有备份。
|
||||
val overridesFile = File(context.filesDir, CATEGORY_OVERRIDES_CONFIG)
|
||||
val overridesJson = if (overridesFile.exists()) {
|
||||
JSONObject(overridesFile.readText())
|
||||
@@ -1131,7 +1087,7 @@ class CustomImportManager(private val context: Context) {
|
||||
overridesJson.put(lutId, sanitizedCategory)
|
||||
overridesFile.writeText(overridesJson.toString())
|
||||
|
||||
// 2. 如果是自定义滤镜,也同步更新 custom_luts.json (保持一致性)
|
||||
// 同步更新 custom_luts.json。
|
||||
val configFile = File(context.filesDir, CUSTOM_LUT_CONFIG)
|
||||
if (configFile.exists()) {
|
||||
val configJson = configFile.readText()
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.hinnka.mycamera.MyCameraApplication
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.camera.AspectRatio
|
||||
import com.hinnka.mycamera.color.TransferCurve
|
||||
import com.hinnka.mycamera.lut.withDefaultBuiltInLutCategoryOrder
|
||||
import com.hinnka.mycamera.model.CameraPreset
|
||||
import com.hinnka.mycamera.raw.SpectralFilmTuning
|
||||
import org.json.JSONArray
|
||||
@@ -13,9 +14,6 @@ import org.json.JSONObject
|
||||
|
||||
// UserPreferences 字段的解析 / 序列化函数,Repository 的写入方法与 UserPreferences 的读取共用。
|
||||
|
||||
/** 内置分类在当前语言下的显示名;持久化时以稳定标识存储。 */
|
||||
internal fun builtInCategoryLabel(): String = MyCameraApplication.instance.getString(R.string.built_in)
|
||||
|
||||
// 使用数组保存首次加入顺序,避免依赖 JSON 对象键的顺序。
|
||||
internal fun parseFrequentLutUsage(value: String?): Map<String, Long>? {
|
||||
if (value == null) return null
|
||||
@@ -223,27 +221,20 @@ internal fun parseTopSheetAspectRatios(
|
||||
}
|
||||
|
||||
internal fun readCategoryOrder(preferences: Preferences): List<String> {
|
||||
val json = preferences[PreferenceKeys.CATEGORY_ORDER_JSON]
|
||||
return if (json != null) {
|
||||
val array = JSONArray(json)
|
||||
List(array.length()) { index ->
|
||||
if (array.optJSONObject(index)?.optString("type") == "built_in") {
|
||||
builtInCategoryLabel()
|
||||
} else {
|
||||
array.getString(index)
|
||||
}
|
||||
}
|
||||
val array = preferences[PreferenceKeys.CATEGORY_ORDER_JSON]?.let { JSONArray(it) }
|
||||
val legacyBuiltInLabel = MyCameraApplication.instance.getString(R.string.built_in)
|
||||
val order = if (array != null) {
|
||||
(0 until array.length()).mapNotNull { array.opt(it) as? String }
|
||||
} else {
|
||||
preferences[PreferenceKeys.CATEGORY_ORDER]?.split(",").orEmpty()
|
||||
}.filter { it.isNotBlank() }.distinct()
|
||||
}
|
||||
val isLegacyOrder = array == null ||
|
||||
(0 until array.length()).any { array.optJSONObject(it)?.optString("type") == "built_in" }
|
||||
return withDefaultBuiltInLutCategoryOrder(
|
||||
order.filter { it.isNotBlank() && it != legacyBuiltInLabel }.distinct(),
|
||||
isLegacyOrder = isLegacyOrder,
|
||||
)
|
||||
}
|
||||
|
||||
internal fun serializeCategoryOrder(order: List<String>): String {
|
||||
val builtInText = builtInCategoryLabel()
|
||||
val array = JSONArray()
|
||||
order.filter { it.isNotBlank() }.distinct().forEach { category ->
|
||||
// 系统分类使用稳定标识,切换语言后不会变成一个自定义空分类。
|
||||
array.put(if (category == builtInText) JSONObject().put("type", "built_in") else category)
|
||||
}
|
||||
return array.toString()
|
||||
}
|
||||
internal fun serializeCategoryOrder(order: List<String>): String =
|
||||
JSONArray(order.filter { it.isNotBlank() }.distinct()).toString()
|
||||
@@ -1,5 +1,17 @@
|
||||
package com.hinnka.mycamera.lut
|
||||
|
||||
internal const val DIGITAL_LUT_CATEGORY = "Digital"
|
||||
internal const val FILM_LUT_CATEGORY = "Film"
|
||||
internal val builtInLutCategories = listOf(DIGITAL_LUT_CATEGORY, FILM_LUT_CATEGORY, "Log")
|
||||
|
||||
internal fun withDefaultBuiltInLutCategoryOrder(
|
||||
categoryOrder: List<String>,
|
||||
isLegacyOrder: Boolean = false,
|
||||
): List<String> {
|
||||
if (!isLegacyOrder && categoryOrder.containsAll(builtInLutCategories)) return categoryOrder
|
||||
return (builtInLutCategories + categoryOrder).distinct()
|
||||
}
|
||||
|
||||
fun sortLutsByUserOrder(
|
||||
luts: List<LutInfo>,
|
||||
filterOrder: List<String>
|
||||
@@ -12,60 +24,59 @@ fun sortLutsByUserOrder(
|
||||
fun orderedLutCategoryTitles(
|
||||
luts: List<LutInfo>,
|
||||
categoryOrder: List<String>,
|
||||
builtInText: String,
|
||||
uncategorizedText: String,
|
||||
favoriteText: String? = null,
|
||||
includeEmptyCategories: Boolean = false,
|
||||
): List<String> {
|
||||
val reservedCategoryNames = setOfNotNull(builtInText, uncategorizedText, favoriteText)
|
||||
val reservedCategoryNames = setOfNotNull(uncategorizedText, favoriteText)
|
||||
val dynamicCategories = luts.map { it.category }
|
||||
.distinct()
|
||||
.filter { it.isNotEmpty() && it !in reservedCategoryNames }
|
||||
val hasUncategorizedLuts = luts.any { !it.isBuiltIn && it.category.isEmpty() }
|
||||
val hasUncategorizedLuts = luts.any { it.category.isEmpty() }
|
||||
// 管理页保留用户保存的空分类;拍摄和分享等选择器只展示有内容的分类。
|
||||
val orderedKnownCategories = categoryOrder.filter {
|
||||
it == builtInText || (it.isNotBlank() && it !in reservedCategoryNames &&
|
||||
(includeEmptyCategories || it in dynamicCategories))
|
||||
val orderedKnownCategories = withDefaultBuiltInLutCategoryOrder(categoryOrder).filter {
|
||||
it.isNotBlank() && it !in reservedCategoryNames &&
|
||||
(it in dynamicCategories || (includeEmptyCategories && it !in builtInLutCategories))
|
||||
}.distinct()
|
||||
val remainingDynamic = dynamicCategories.filterNot { it in orderedKnownCategories }.sorted()
|
||||
val remainingDynamic = (dynamicCategories - orderedKnownCategories.toSet()).sorted()
|
||||
|
||||
return buildList {
|
||||
favoriteText?.let { add(it) }
|
||||
if (orderedKnownCategories.isEmpty()) {
|
||||
add(builtInText)
|
||||
addAll(remainingDynamic)
|
||||
} else {
|
||||
addAll(orderedKnownCategories)
|
||||
if (builtInText !in orderedKnownCategories) add(builtInText)
|
||||
addAll(remainingDynamic)
|
||||
}
|
||||
addAll(orderedKnownCategories)
|
||||
addAll(remainingDynamic)
|
||||
if (hasUncategorizedLuts) {
|
||||
add(uncategorizedText)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun List<LutInfo>.inLutCategory(
|
||||
category: String,
|
||||
uncategorizedText: String,
|
||||
favoriteText: String? = null,
|
||||
): List<LutInfo> {
|
||||
val items = when (category) {
|
||||
favoriteText -> filter { it.isFavorite }
|
||||
uncategorizedText -> filter { it.category.isEmpty() }
|
||||
else -> filter { it.category == category }
|
||||
}
|
||||
return items.sortedBy { it.id != "none" }
|
||||
}
|
||||
|
||||
fun groupLutsForDisplay(
|
||||
luts: List<LutInfo>,
|
||||
categoryOrder: List<String>,
|
||||
builtInText: String,
|
||||
uncategorizedText: String,
|
||||
favoriteText: String? = null,
|
||||
): List<Pair<String, List<LutInfo>>> {
|
||||
val categories = orderedLutCategoryTitles(
|
||||
luts = luts,
|
||||
categoryOrder = categoryOrder,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText,
|
||||
favoriteText = favoriteText,
|
||||
)
|
||||
return categories.mapNotNull { category ->
|
||||
val items = when (category) {
|
||||
favoriteText -> luts.filter { it.isFavorite }
|
||||
builtInText -> luts.filter { it.isBuiltIn }
|
||||
uncategorizedText -> luts.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
else -> luts.filter { it.category == category }
|
||||
}
|
||||
val items = luts.inLutCategory(category, uncategorizedText, favoriteText)
|
||||
items.takeIf { it.isNotEmpty() }?.let { category to it }
|
||||
}
|
||||
}
|
||||
@@ -195,9 +195,7 @@ class LutManager(private val context: Context) {
|
||||
* 初始化,扫描可用的 LUT 文件(包括内置和自定义)
|
||||
*/
|
||||
fun initialize() {
|
||||
val configuredBuiltInLuts = LutParser.listAvailableLuts(context, BUILT_IN_LUT_FOLDER)
|
||||
customImportManager.initializeBuiltInLutCategoriesIfNeeded(configuredBuiltInLuts)
|
||||
val builtInLuts = configuredBuiltInLuts.map { it.copy(category = "") }
|
||||
val builtInLuts = LutParser.listAvailableLuts(context, BUILT_IN_LUT_FOLDER)
|
||||
val customLuts = customImportManager.getCustomLuts()
|
||||
val categoryOverrides = customImportManager.getCategoryOverrides()
|
||||
val favoriteOverrides = customImportManager.getFavoriteOverrides()
|
||||
@@ -205,9 +203,9 @@ class LutManager(private val context: Context) {
|
||||
// 合并列表并以 ID 去重,避免 ID 重复导致的 Jetpack Compose 主键重复崩溃
|
||||
val allLuts = (customLuts + builtInLuts).distinctBy { it.id }
|
||||
|
||||
// 应用分类重写 (用户手动创建的分类会通过这里恢复)
|
||||
// 自定义 LUT 恢复用户分类,内置 LUT 使用目录配置中的分类。
|
||||
availableLuts = allLuts.map { lut ->
|
||||
val overriddenCategory = categoryOverrides[lut.id]
|
||||
val overriddenCategory = categoryOverrides[lut.id].takeUnless { lut.isBuiltIn }
|
||||
val overriddenFavorite = favoriteOverrides[lut.id]
|
||||
val encoding = if (lut.fileName.isBlank()) null else runCatching {
|
||||
val input = if (lut.isBuiltIn) context.assets.open(lut.fileName)
|
||||
|
||||
@@ -216,7 +216,7 @@ data class CameraPreset(
|
||||
CameraPreset(
|
||||
id = "builtin_hasselblad_natural",
|
||||
name = "builtin_hasselblad_natural",
|
||||
lutId = "Hasselblad",
|
||||
lutId = null,
|
||||
colorRecipe = ColorRecipeParams.DEFAULT,
|
||||
effects = EffectParams.DEFAULT,
|
||||
rawRenderingEngine = RawRenderingEngine.Hncs.name,
|
||||
@@ -225,7 +225,7 @@ data class CameraPreset(
|
||||
CameraPreset(
|
||||
id = "builtin_portrait",
|
||||
name = "builtin_portrait",
|
||||
lutId = "astia",
|
||||
lutId = "canon_portrait",
|
||||
colorRecipe = ColorRecipeParams.DEFAULT.copy(
|
||||
tonality = -0.6f,
|
||||
sharpness = -0.2f
|
||||
@@ -262,7 +262,7 @@ data class CameraPreset(
|
||||
CameraPreset(
|
||||
id = "builtin_cinematic",
|
||||
name = "builtin_cinematic",
|
||||
lutId = "ricoh_yellow",
|
||||
lutId = "sony_fl2",
|
||||
colorRecipe = ColorRecipeParams.DEFAULT.copy(
|
||||
shadows = -0.08f,
|
||||
highlights = 0.05f
|
||||
|
||||
@@ -65,6 +65,7 @@ import com.hinnka.mycamera.livephoto.VivoLivePhotoCreator
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.lut.groupLutsForDisplay
|
||||
import com.hinnka.mycamera.lut.sortLutsByUserOrder
|
||||
import com.hinnka.mycamera.ui.components.lutCategoryTitle
|
||||
import com.hinnka.mycamera.ui.theme.PhotonCameraTheme
|
||||
import com.hinnka.mycamera.utils.PLog
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -796,13 +797,11 @@ private fun ApplyLutScreen(
|
||||
}
|
||||
val lutData by sortedLutsFlow.collectAsState(initial = Triple(emptyList(), emptyList(), null))
|
||||
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 groupedLuts = remember(lutData.first, lutData.second, builtInText, uncategorizedText) {
|
||||
val groupedLuts = remember(lutData.first, lutData.second, uncategorizedText) {
|
||||
groupLutsForDisplay(
|
||||
luts = lutData.first,
|
||||
categoryOrder = lutData.second,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText,
|
||||
)
|
||||
}
|
||||
@@ -853,7 +852,7 @@ private fun ApplyLutScreen(
|
||||
groupedLuts.forEach { (groupTitle, luts) ->
|
||||
item(key = "header_$groupTitle") {
|
||||
Text(
|
||||
text = groupTitle,
|
||||
text = lutCategoryTitle(groupTitle),
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = Color.White.copy(alpha = 0.6f),
|
||||
modifier = Modifier.padding(top = 4.dp, bottom = 2.dp)
|
||||
|
||||
@@ -40,7 +40,12 @@ 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.DIGITAL_LUT_CATEGORY
|
||||
import com.hinnka.mycamera.lut.FILM_LUT_CATEGORY
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.lut.builtInLutCategories
|
||||
import com.hinnka.mycamera.lut.inLutCategory
|
||||
import com.hinnka.mycamera.lut.orderedLutCategoryTitles
|
||||
import com.hinnka.mycamera.model.CameraPreset
|
||||
import com.hinnka.mycamera.model.LutSelectorMode
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -50,18 +55,11 @@ import com.hinnka.mycamera.ui.icons.AppIcons
|
||||
/** Camera browsing is opt-in; editors and external camera integrations keep their horizontal layout. */
|
||||
enum class LutSelectorPresentation { Horizontal, Compact, Expanded }
|
||||
|
||||
private sealed class LutCategoryTab {
|
||||
data object Favorite : LutCategoryTab()
|
||||
data object BuiltIn : LutCategoryTab()
|
||||
data object Uncategorized : LutCategoryTab()
|
||||
data class Category(val name: String) : LutCategoryTab()
|
||||
}
|
||||
|
||||
private fun LutCategoryTab.stableKey(): String = when (this) {
|
||||
LutCategoryTab.Favorite -> "fixed:favorite"
|
||||
LutCategoryTab.BuiltIn -> "fixed:built_in"
|
||||
LutCategoryTab.Uncategorized -> "fixed:uncategorized"
|
||||
is LutCategoryTab.Category -> "category:$name"
|
||||
@Composable
|
||||
internal fun lutCategoryTitle(category: String): String = when (category) {
|
||||
DIGITAL_LUT_CATEGORY -> stringResource(R.string.lut_category_digital)
|
||||
FILM_LUT_CATEGORY -> stringResource(R.string.lut_category_film)
|
||||
else -> category
|
||||
}
|
||||
|
||||
private val LutPanelSurface = Color.Black.copy(alpha = 0.15f)
|
||||
@@ -201,55 +199,13 @@ fun LutSelector(
|
||||
onEditPreset: ((String) -> Unit)? = null
|
||||
) {
|
||||
val favoriteText = stringResource(R.string.favorite)
|
||||
val builtInText = stringResource(R.string.built_in)
|
||||
val uncategorizedText = stringResource(R.string.uncategorized)
|
||||
val styleText = stringResource(R.string.filter)
|
||||
val frameText = stringResource(R.string.frame)
|
||||
val presetText = stringResource(R.string.preset_title)
|
||||
|
||||
// 分类逻辑
|
||||
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 }
|
||||
val hasUncategorizedLuts = availableLuts.any { !it.isBuiltIn && it.category.isEmpty() }
|
||||
val orderedEntries = categoryOrder.filter { it == builtInText || dynamicCategories.contains(it) }
|
||||
val remainingDynamic = dynamicCategories.filterNot { it in orderedEntries }.sorted()
|
||||
|
||||
buildList {
|
||||
add(LutCategoryTab.Favorite)
|
||||
if (orderedEntries.isEmpty()) {
|
||||
add(LutCategoryTab.BuiltIn)
|
||||
addAll(remainingDynamic.map(LutCategoryTab::Category))
|
||||
} else {
|
||||
orderedEntries.forEach { entry ->
|
||||
when (entry) {
|
||||
builtInText -> add(LutCategoryTab.BuiltIn)
|
||||
else -> add(LutCategoryTab.Category(entry))
|
||||
}
|
||||
}
|
||||
if (builtInText !in orderedEntries) add(LutCategoryTab.BuiltIn)
|
||||
addAll(remainingDynamic.map(LutCategoryTab::Category))
|
||||
}
|
||||
|
||||
if (hasUncategorizedLuts) {
|
||||
add(LutCategoryTab.Uncategorized)
|
||||
}
|
||||
}
|
||||
}
|
||||
fun LutCategoryTab.contains(lut: LutInfo): Boolean = when (this) {
|
||||
LutCategoryTab.Favorite -> lut.isFavorite
|
||||
LutCategoryTab.BuiltIn -> lut.isBuiltIn
|
||||
LutCategoryTab.Uncategorized -> !lut.isBuiltIn && lut.category.isEmpty()
|
||||
is LutCategoryTab.Category -> lut.category == name
|
||||
}
|
||||
|
||||
fun preferredCategoryFor(lut: LutInfo): LutCategoryTab = when {
|
||||
lut.isFavorite -> LutCategoryTab.Favorite
|
||||
LutCategoryTab.Category(lut.category) in categoryTabs -> LutCategoryTab.Category(lut.category)
|
||||
lut.isBuiltIn -> LutCategoryTab.BuiltIn
|
||||
else -> LutCategoryTab.Uncategorized
|
||||
val categoryTabs = remember(availableLuts, categoryOrder, favoriteText, uncategorizedText) {
|
||||
orderedLutCategoryTitles(availableLuts, categoryOrder, uncategorizedText, favoriteText)
|
||||
}
|
||||
|
||||
val activeLutId = currentLutId
|
||||
@@ -265,22 +221,19 @@ fun LutSelector(
|
||||
|
||||
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)
|
||||
mutableStateOf<String?>(null)
|
||||
}
|
||||
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
|
||||
}
|
||||
?: selectedLut?.let { if (it.isFavorite) favoriteText else it.category.ifEmpty { uncategorizedText } }
|
||||
?.takeIf { it in categoryTabs }
|
||||
?: builtInLutCategories.firstOrNull { it in categoryTabs }
|
||||
?: categoryTabs.first()
|
||||
val lutOptions = remember(selectedCategory, availableLuts, favoriteText, uncategorizedText) {
|
||||
availableLuts.inLutCategory(selectedCategory, uncategorizedText, favoriteText)
|
||||
}
|
||||
|
||||
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 -> availableLuts.filter { it.category == category.name }
|
||||
LaunchedEffect(activeLutId, availableLuts, compact) {
|
||||
if (!compact && selectedLut != null && selectedLut !in lutOptions) {
|
||||
browsedCategory = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,7 +341,7 @@ fun LutSelector(
|
||||
LaunchedEffect(selectedCategory, tabIndex, activeLutId) {
|
||||
val layout = tabListState.layoutInfo
|
||||
val fullyVisible = layout.visibleItemsInfo.any {
|
||||
it.key == selectedCategory.stableKey() && it.offset >= layout.viewportStartOffset &&
|
||||
it.key == selectedCategory && it.offset >= layout.viewportStartOffset &&
|
||||
it.offset + it.size <= layout.viewportEndOffset
|
||||
}
|
||||
if (!fullyVisible) tabListState.scrollToItem(tabIndex)
|
||||
@@ -401,17 +354,10 @@ fun LutSelector(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
contentPadding = PaddingValues(horizontal = 8.dp)
|
||||
) {
|
||||
items(categoryTabs, key = { it.stableKey() }) { category ->
|
||||
items(categoryTabs, key = { it }) { category ->
|
||||
val isSelected = selectedCategory == category
|
||||
val categoryName = when (category) {
|
||||
LutCategoryTab.Favorite -> favoriteText
|
||||
LutCategoryTab.BuiltIn -> builtInText
|
||||
LutCategoryTab.Uncategorized -> uncategorizedText
|
||||
is LutCategoryTab.Category -> category.name
|
||||
}
|
||||
|
||||
Text(
|
||||
text = categoryName,
|
||||
text = lutCategoryTitle(category),
|
||||
color = if (isSelected) AccentColor else Color.White,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = if (isSelected) FontWeight.SemiBold else FontWeight.Medium,
|
||||
@@ -436,7 +382,7 @@ fun LutSelector(
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(
|
||||
if (selectedCategory == LutCategoryTab.Favorite) R.string.favorite_empty_title
|
||||
if (selectedCategory == favoriteText) R.string.favorite_empty_title
|
||||
else R.string.category_empty_title
|
||||
),
|
||||
color = Color.White.copy(alpha = 0.6f),
|
||||
|
||||
@@ -47,8 +47,12 @@ 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.DIGITAL_LUT_CATEGORY
|
||||
import com.hinnka.mycamera.lut.LutInfo
|
||||
import com.hinnka.mycamera.lut.builtInLutCategories
|
||||
import com.hinnka.mycamera.lut.inLutCategory
|
||||
import com.hinnka.mycamera.lut.orderedLutCategoryTitles
|
||||
import com.hinnka.mycamera.ui.components.lutCategoryTitle
|
||||
import com.hinnka.mycamera.raw.ColorSpace
|
||||
import com.hinnka.mycamera.ui.camera.autoRotate
|
||||
import com.hinnka.mycamera.ui.camera.LutEditBottomSheet
|
||||
@@ -70,25 +74,20 @@ private data class CategoryManagementItem(
|
||||
|
||||
private fun sanitizeCustomLutCategoryInput(
|
||||
category: String,
|
||||
favoriteText: String,
|
||||
builtInText: String,
|
||||
uncategorizedText: String
|
||||
reservedCategoryNames: Set<String>,
|
||||
categoryTitles: Map<String, String>,
|
||||
): String {
|
||||
val trimmedCategory = category.trim()
|
||||
return if (trimmedCategory == favoriteText || trimmedCategory == builtInText || trimmedCategory == uncategorizedText) {
|
||||
""
|
||||
} else {
|
||||
trimmedCategory
|
||||
}
|
||||
if (trimmedCategory in reservedCategoryNames) return ""
|
||||
return categoryTitles.entries.firstOrNull { it.value == trimmedCategory }?.key ?: trimmedCategory
|
||||
}
|
||||
|
||||
private fun sanitizeCategoryOrder(
|
||||
order: List<String>,
|
||||
builtInText: String,
|
||||
reservedCategoryNames: Set<String>
|
||||
): List<String> {
|
||||
return order
|
||||
.filter { it.isNotBlank() && (it == builtInText || it !in reservedCategoryNames) }
|
||||
.filter { it.isNotBlank() && it !in reservedCategoryNames }
|
||||
.distinct()
|
||||
}
|
||||
|
||||
@@ -121,11 +120,9 @@ fun FilterManagementScreen(
|
||||
val isPurchased by viewModel.isPurchased.collectAsState()
|
||||
val availableLuts = viewModel.availableLutList
|
||||
val fallbackLutId = availableLuts.firstOrNull { it.isDefault }?.id
|
||||
val selectedLutId = if (manageVideoLut) {
|
||||
videoLutId ?: photoLutId ?: fallbackLutId
|
||||
} else {
|
||||
photoLutId ?: fallbackLutId
|
||||
}
|
||||
val selectedLutId = videoLutId.takeIf { manageVideoLut && availableLuts.any { lut -> lut.id == it } }
|
||||
?: photoLutId.takeIf { availableLuts.any { lut -> lut.id == it } }
|
||||
?: fallbackLutId
|
||||
val customImportManager = viewModel.getCustomImportManager()
|
||||
val scope = rememberCoroutineScope()
|
||||
val context = LocalContext.current
|
||||
@@ -236,73 +233,61 @@ fun FilterManagementScreen(
|
||||
val reservedCategoryNames = remember(favoriteText, builtInText, uncategorizedText) {
|
||||
setOf(favoriteText, builtInText, uncategorizedText)
|
||||
}
|
||||
val categoryTitles = builtInLutCategories.associateWith { lutCategoryTitle(it) }
|
||||
|
||||
var selectedCategory by remember { mutableStateOf<String?>(null) }
|
||||
val categories = remember(localLutList, categoryOrder, favoriteText, builtInText, uncategorizedText, reservedCategoryNames) {
|
||||
val categories = remember(localLutList, categoryOrder, favoriteText, uncategorizedText) {
|
||||
orderedLutCategoryTitles(
|
||||
luts = localLutList,
|
||||
categoryOrder = categoryOrder,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText,
|
||||
favoriteText = favoriteText,
|
||||
includeEmptyCategories = true,
|
||||
)
|
||||
}
|
||||
val currentTabIndex = categories.indexOf(selectedCategory).takeIf { it >= 0 } ?: 0
|
||||
val currentTabIndex = categories.indexOf(selectedCategory ?: DIGITAL_LUT_CATEGORY)
|
||||
.takeIf { it >= 0 } ?: 0
|
||||
val currentCategory = categories[currentTabIndex]
|
||||
val commonCategories = categories.filter { it !in reservedCategoryNames }
|
||||
val managedCategories = categories.filter { it != favoriteText && it != uncategorizedText }
|
||||
val managedCategories = categories.filter { it !in reservedCategoryNames }
|
||||
LaunchedEffect(currentCategory) {
|
||||
selectedIds = emptySet()
|
||||
}
|
||||
val filteredLutList = remember(currentCategory, localLutList, reservedCategoryNames) {
|
||||
when (currentCategory) {
|
||||
favoriteText -> localLutList.filter { it.isFavorite }
|
||||
builtInText -> localLutList.filter { it.isBuiltIn }
|
||||
uncategorizedText -> localLutList.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
else -> localLutList.filter { it.category == currentCategory }
|
||||
}
|
||||
val filteredLutList = remember(currentCategory, localLutList, uncategorizedText, favoriteText) {
|
||||
localLutList.inLutCategory(currentCategory, uncategorizedText, favoriteText)
|
||||
}
|
||||
|
||||
var hasLocated by remember(locateLutId) { mutableStateOf(false) }
|
||||
|
||||
// 自动定位到指定滤镜
|
||||
LaunchedEffect(locateLutId, categories) {
|
||||
if (!locateLutId.isNullOrEmpty() && !hasLocated && categories.isNotEmpty()) {
|
||||
LaunchedEffect(locateLutId, categories, localLutList) {
|
||||
if (!locateLutId.isNullOrEmpty() && !hasLocated) {
|
||||
// 确保本地列表已同步且包含目标项
|
||||
val targetLut = localLutList.find { it.id == locateLutId }
|
||||
if (targetLut != null) {
|
||||
// 等待页面入场动画完成 (约 350ms),避免与 Navigation 切换动画抢占资源导致掉帧卡顿
|
||||
kotlinx.coroutines.delay(350)
|
||||
|
||||
|
||||
// 查找目标所属分类
|
||||
val categoryName = if (targetLut.isFavorite) favoriteText
|
||||
else if (targetLut.isBuiltIn) builtInText
|
||||
else if (targetLut.category.isEmpty()) uncategorizedText
|
||||
else targetLut.category
|
||||
else targetLut.category.ifEmpty { uncategorizedText }
|
||||
val categoryIndex = categories.indexOf(categoryName)
|
||||
|
||||
|
||||
if (categoryIndex >= 0 && currentCategory != categoryName) {
|
||||
selectedCategory = categoryName
|
||||
// 等待 Tab 切换引起的列表重组完成
|
||||
kotlinx.coroutines.delay(150)
|
||||
kotlinx.coroutines.delay(150)
|
||||
}
|
||||
|
||||
|
||||
// 重新获取当前分类下的列表并定位
|
||||
val filteredLutsNow = when (categoryName) {
|
||||
favoriteText -> localLutList.filter { it.isFavorite }
|
||||
builtInText -> localLutList.filter { it.isBuiltIn }
|
||||
uncategorizedText -> localLutList.filter { !it.isBuiltIn && it.category.isEmpty() }
|
||||
else -> localLutList.filter { it.category == categoryName }
|
||||
}
|
||||
|
||||
val filteredLutsNow = localLutList.inLutCategory(categoryName, uncategorizedText, favoriteText)
|
||||
|
||||
val indexInFiltered = filteredLutsNow.indexOfFirst { it.id == locateLutId }
|
||||
if (indexInFiltered >= 0) {
|
||||
// 使用带动画的滚动,给用户一个明确的"定位"视觉反馈
|
||||
lazyListState.animateScrollToItem(maxOf(0, indexInFiltered - 1))
|
||||
}
|
||||
hasLocated = true
|
||||
}
|
||||
hasLocated = true // 标记为已定位,避免后续数据变化时反复触发
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +298,8 @@ fun FilterManagementScreen(
|
||||
if (uris.isNotEmpty()) {
|
||||
pendingImportUris = uris
|
||||
pendingZipUris = uris.filter { isZipImportUri(context, it) }.toSet()
|
||||
categoryText = currentCategory.takeIf { it !in reservedCategoryNames }.orEmpty()
|
||||
categoryText = if (currentCategory in reservedCategoryNames) "" else
|
||||
categoryTitles[currentCategory] ?: currentCategory
|
||||
showImportCategoryDialog = true
|
||||
}
|
||||
}
|
||||
@@ -438,11 +424,15 @@ fun FilterManagementScreen(
|
||||
)
|
||||
}
|
||||
// 批量分类
|
||||
IconButton(onClick = {
|
||||
categorizingIds = selectedIds.toList()
|
||||
categoryText = ""
|
||||
showCategoryDialog = true
|
||||
}) {
|
||||
val selectedCustomLutIds = availableLuts.filter { it.id in selectedIds && !it.isBuiltIn }.map { it.id }
|
||||
IconButton(
|
||||
enabled = selectedCustomLutIds.isNotEmpty(),
|
||||
onClick = {
|
||||
categorizingIds = selectedCustomLutIds
|
||||
categoryText = ""
|
||||
showCategoryDialog = true
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Label,
|
||||
contentDescription = "Batch Categorize",
|
||||
@@ -571,7 +561,7 @@ fun FilterManagementScreen(
|
||||
},
|
||||
text = {
|
||||
Text(
|
||||
text = category,
|
||||
text = lutCategoryTitle(category),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = if (currentTabIndex == index) FontWeight.Bold else FontWeight.Normal
|
||||
)
|
||||
@@ -738,10 +728,10 @@ fun FilterManagementScreen(
|
||||
}
|
||||
}
|
||||
} else null,
|
||||
onEditCategory = if (!isSelectionMode) {
|
||||
onEditCategory = if (!lutInfo.isBuiltIn && !isSelectionMode) {
|
||||
{
|
||||
categorizingIds = listOf(lutInfo.id)
|
||||
categoryText = lutInfo.category
|
||||
categoryText = categoryTitles[lutInfo.category] ?: lutInfo.category
|
||||
showCategoryDialog = true
|
||||
}
|
||||
} else null,
|
||||
@@ -759,7 +749,6 @@ fun FilterManagementScreen(
|
||||
}
|
||||
}
|
||||
} else null,
|
||||
showCategory = categories.getOrNull(currentTabIndex) == builtInText && lutInfo.category.isNotEmpty(),
|
||||
dragModifier = if (isSelectionMode || lutInfo.id == "none") null else Modifier.draggableHandle()
|
||||
)
|
||||
}
|
||||
@@ -1086,7 +1075,7 @@ fun FilterManagementScreen(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// 常用分类快速选择
|
||||
if (commonCategories.isNotEmpty()) {
|
||||
if (managedCategories.isNotEmpty()) {
|
||||
Text(
|
||||
text = stringResource(R.string.common_categories),
|
||||
fontSize = 12.sp,
|
||||
@@ -1108,11 +1097,12 @@ fun FilterManagementScreen(
|
||||
)
|
||||
}
|
||||
|
||||
commonCategories.forEach { cat ->
|
||||
managedCategories.forEach { cat ->
|
||||
val title = categoryTitles[cat] ?: cat
|
||||
InputChip(
|
||||
selected = categoryText == cat,
|
||||
onClick = { categoryText = cat },
|
||||
label = { Text(cat) },
|
||||
selected = categoryText == title,
|
||||
onClick = { categoryText = title },
|
||||
label = { Text(title) },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1133,9 +1123,8 @@ fun FilterManagementScreen(
|
||||
onClick = {
|
||||
val sanitizedCategory = sanitizeCustomLutCategoryInput(
|
||||
category = categoryText,
|
||||
favoriteText = favoriteText,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText
|
||||
reservedCategoryNames = reservedCategoryNames,
|
||||
categoryTitles = categoryTitles,
|
||||
)
|
||||
scope.launch {
|
||||
withContext(Dispatchers.IO) {
|
||||
@@ -1292,7 +1281,7 @@ fun FilterManagementScreen(
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
// 常用分类快速选择
|
||||
if (commonCategories.isNotEmpty()) {
|
||||
if (managedCategories.isNotEmpty()) {
|
||||
Text(
|
||||
text = stringResource(R.string.common_categories),
|
||||
fontSize = 12.sp,
|
||||
@@ -1303,11 +1292,12 @@ fun FilterManagementScreen(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp)
|
||||
) {
|
||||
commonCategories.forEach { cat ->
|
||||
managedCategories.forEach { cat ->
|
||||
val title = categoryTitles[cat] ?: cat
|
||||
InputChip(
|
||||
selected = categoryText == cat,
|
||||
onClick = { categoryText = cat },
|
||||
label = { Text(cat) }
|
||||
selected = categoryText == title,
|
||||
onClick = { categoryText = title },
|
||||
label = { Text(title) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1322,9 +1312,8 @@ fun FilterManagementScreen(
|
||||
onClick = {
|
||||
val targetCategory = sanitizeCustomLutCategoryInput(
|
||||
category = categoryText,
|
||||
favoriteText = favoriteText,
|
||||
builtInText = builtInText,
|
||||
uncategorizedText = uncategorizedText
|
||||
reservedCategoryNames = reservedCategoryNames,
|
||||
categoryTitles = categoryTitles,
|
||||
)
|
||||
val urisToImport = pendingImportUris
|
||||
val curveToUse = selectedCurve
|
||||
@@ -1434,9 +1423,10 @@ fun FilterManagementScreen(
|
||||
) {
|
||||
CategoryManagementSheet(
|
||||
categories = managedCategories,
|
||||
reservedNames = reservedCategoryNames + categoryTitles.values,
|
||||
onSaveOrder = { newOrder ->
|
||||
viewModel.saveCategoryOrder(
|
||||
sanitizeCategoryOrder(newOrder, builtInText, reservedCategoryNames)
|
||||
sanitizeCategoryOrder(newOrder, reservedCategoryNames)
|
||||
)
|
||||
},
|
||||
onRenameCategory = { oldName, newName, updatedOrder ->
|
||||
@@ -1454,7 +1444,6 @@ fun FilterManagementScreen(
|
||||
// 在排序中更新
|
||||
val newOrder = sanitizeCategoryOrder(
|
||||
updatedOrder,
|
||||
builtInText,
|
||||
reservedCategoryNames
|
||||
)
|
||||
viewModel.saveCategoryOrder(newOrder).join()
|
||||
@@ -1478,12 +1467,11 @@ fun FilterManagementScreen(
|
||||
// 从排序中移除
|
||||
val newOrder = sanitizeCategoryOrder(
|
||||
updatedOrder,
|
||||
builtInText,
|
||||
reservedCategoryNames
|
||||
)
|
||||
viewModel.saveCategoryOrder(newOrder).join()
|
||||
}
|
||||
if (selectedCategory == target) selectedCategory = builtInText
|
||||
if (selectedCategory == target) selectedCategory = null
|
||||
viewModel.refreshCustomContent()
|
||||
}
|
||||
}
|
||||
@@ -1500,20 +1488,16 @@ fun FilterManagementScreen(
|
||||
@Composable
|
||||
private fun CategoryManagementSheet(
|
||||
categories: List<String>,
|
||||
reservedNames: Set<String>,
|
||||
onSaveOrder: (List<String>) -> Unit,
|
||||
onRenameCategory: (String, String, List<String>) -> Unit,
|
||||
onDeleteCategory: (String, List<String>) -> Unit
|
||||
) {
|
||||
val builtInText = stringResource(R.string.built_in)
|
||||
val uncategorizedText = stringResource(R.string.uncategorized)
|
||||
val favoriteText = stringResource(R.string.favorite)
|
||||
val fixedNames = remember(builtInText, uncategorizedText, favoriteText) {
|
||||
setOf(builtInText, uncategorizedText, favoriteText)
|
||||
}
|
||||
val unavailableNames = reservedNames + builtInLutCategories
|
||||
|
||||
var localCategories by remember(categories, fixedNames) {
|
||||
var localCategories by remember(categories) {
|
||||
mutableStateOf(categories.map { name ->
|
||||
CategoryManagementItem(name = name, isFixed = name in fixedNames)
|
||||
CategoryManagementItem(name = name, isFixed = name in builtInLutCategories)
|
||||
})
|
||||
}
|
||||
val lazyListState = rememberLazyListState()
|
||||
@@ -1599,7 +1583,7 @@ private fun CategoryManagementSheet(
|
||||
)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
Text(
|
||||
text = category.name,
|
||||
text = lutCategoryTitle(category.name),
|
||||
color = Color.White,
|
||||
modifier = Modifier.weight(1f),
|
||||
fontSize = 16.sp
|
||||
@@ -1632,7 +1616,7 @@ private fun CategoryManagementSheet(
|
||||
// 新建分类对话框
|
||||
if (showAddDialog) {
|
||||
val trimmedName = newCategoryName.trim()
|
||||
val nameUnavailable = trimmedName in fixedNames || localCategories.any { it.name == trimmedName }
|
||||
val nameUnavailable = trimmedName in unavailableNames || localCategories.any { it.name == trimmedName }
|
||||
AlertDialog(
|
||||
onDismissRequest = { showAddDialog = false },
|
||||
title = { Text(stringResource(R.string.new_category)) },
|
||||
@@ -1656,7 +1640,7 @@ private fun CategoryManagementSheet(
|
||||
val trimmedName = newCategoryName.trim()
|
||||
if (
|
||||
trimmedName.isNotBlank() &&
|
||||
trimmedName !in fixedNames &&
|
||||
trimmedName !in unavailableNames &&
|
||||
localCategories.none { it.name == trimmedName }
|
||||
) {
|
||||
localCategories += CategoryManagementItem(
|
||||
@@ -1682,7 +1666,7 @@ private fun CategoryManagementSheet(
|
||||
// 重命名分类对话框
|
||||
if (showRenameDialog && renamingCategory != null) {
|
||||
val trimmedName = renameCategoryText.trim()
|
||||
val nameUnavailable = trimmedName in fixedNames ||
|
||||
val nameUnavailable = trimmedName in unavailableNames ||
|
||||
localCategories.any { it.name == trimmedName && it.name != renamingCategory }
|
||||
AlertDialog(
|
||||
onDismissRequest = { showRenameDialog = false },
|
||||
@@ -1709,7 +1693,7 @@ private fun CategoryManagementSheet(
|
||||
if (
|
||||
newName.isNotEmpty() &&
|
||||
newName != oldName &&
|
||||
newName !in fixedNames &&
|
||||
newName !in unavailableNames &&
|
||||
localCategories.none { it.name == newName }
|
||||
) {
|
||||
localCategories = localCategories.map {
|
||||
@@ -1779,7 +1763,6 @@ private fun FilterManagementItem(
|
||||
onExport: (() -> Unit)? = null,
|
||||
onEditCategory: (() -> Unit)? = null,
|
||||
onToggleFavorite: (() -> Unit)? = null,
|
||||
showCategory: Boolean = false,
|
||||
dragModifier: Modifier? = null,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -1873,20 +1856,6 @@ private fun FilterManagementItem(
|
||||
)
|
||||
}
|
||||
|
||||
// 分类标签
|
||||
if (showCategory) {
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Text(
|
||||
text = lutInfo.category,
|
||||
color = Color.White.copy(alpha = 0.7f),
|
||||
fontSize = 10.sp,
|
||||
modifier = Modifier
|
||||
.clip(RoundedCornerShape(4.dp))
|
||||
.background(Color.White.copy(alpha = 0.15f))
|
||||
.padding(horizontal = 4.dp, vertical = 1.dp)
|
||||
)
|
||||
}
|
||||
|
||||
if (lutInfo.isFavorite) {
|
||||
Spacer(modifier = Modifier.width(4.dp))
|
||||
Icon(
|
||||
@@ -1939,15 +1908,16 @@ private fun FilterManagementItem(
|
||||
onDismissRequest = { showMenu = false },
|
||||
modifier = Modifier.background(Color(0xFF2C313F))
|
||||
) {
|
||||
// 分类修改 (所有滤镜可用)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.category), color = Color.White) },
|
||||
leadingIcon = { Icon(AppIcons.Label, null, tint = Color.White.copy(alpha = 0.7f)) },
|
||||
onClick = {
|
||||
showMenu = false
|
||||
onEditCategory?.invoke()
|
||||
}
|
||||
)
|
||||
if (onEditCategory != null) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.category), color = Color.White) },
|
||||
leadingIcon = { Icon(AppIcons.Label, null, tint = Color.White.copy(alpha = 0.7f)) },
|
||||
onClick = {
|
||||
showMenu = false
|
||||
onEditCategory()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (onToggleFavorite != null) {
|
||||
DropdownMenuItem(
|
||||
|
||||
@@ -4035,12 +4035,13 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
|
||||
private fun resolveLutIdForMode(preferences: UserPreferences, mode: CaptureMode): String? {
|
||||
val lutManager = contentRepository.lutManager
|
||||
return resolveLutIdForCaptureMode(
|
||||
photoLutId = preferences.lutId,
|
||||
videoLutId = preferences.videoLutId,
|
||||
photoLutId = preferences.lutId?.takeIf { lutManager.getLutInfo(it) != null },
|
||||
videoLutId = preferences.videoLutId?.takeIf { lutManager.getLutInfo(it) != null },
|
||||
separateVideoLutEnabled = preferences.separateVideoLutEnabled,
|
||||
captureMode = mode,
|
||||
defaultLutId = availableLutList.firstOrNull { it.isDefault }?.id,
|
||||
defaultLutId = lutManager.getAvailableLuts().firstOrNull { it.isDefault }?.id,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -663,6 +663,8 @@
|
||||
<string name="favorite_empty_title">尚無收藏</string>
|
||||
<string name="favorite_empty_message">點按濾鏡上的星號,即可將它加入此處。</string>
|
||||
<string name="built_in">內置</string>
|
||||
<string name="lut_category_digital">數碼</string>
|
||||
<string name="lut_category_film">膠片</string>
|
||||
<string name="custom">自訂</string>
|
||||
<string name="uncategorized">未分類</string>
|
||||
<string name="input_curve">輸入曲線</string>
|
||||
|
||||
@@ -249,6 +249,8 @@
|
||||
<string name="delete_category_title">Kategorie löschen</string>
|
||||
<string name="delete_category_message">Sind Sie sicher, dass Sie die Kategorie \"%s\" löschen möchten? LUTs in dieser Kategorie werden auf unkategorisiert zurückgesetzt.</string>
|
||||
<string name="built_in">Integriert</string>
|
||||
<string name="lut_category_digital">Digital</string>
|
||||
<string name="lut_category_film">Film</string>
|
||||
<string name="custom">Eigene</string>
|
||||
<string name="input_curve">Eingangskurve</string>
|
||||
|
||||
|
||||
@@ -249,6 +249,8 @@
|
||||
<string name="delete_category_title">Supprimer la catégorie</string>
|
||||
<string name="delete_category_message">Voulez-vous vraiment supprimer la catégorie \"%s\" ? Les LUTs de cette catégorie seront réinitialisées comme non catégorisées.</string>
|
||||
<string name="built_in">Intégré</string>
|
||||
<string name="lut_category_digital">Numérique</string>
|
||||
<string name="lut_category_film">Argentique</string>
|
||||
<string name="custom">Personnalisé</string>
|
||||
<string name="input_curve">Courbe d\'entrée</string>
|
||||
|
||||
|
||||
@@ -249,6 +249,8 @@
|
||||
<string name="delete_category_title">Hapus Kategori</string>
|
||||
<string name="delete_category_message">Apakah Anda yakin ingin menghapus kategori \"%s\"? LUT di bawah kategori ini akan diatur ulang ke tidak berkategori.</string>
|
||||
<string name="built_in">Bawaan</string>
|
||||
<string name="lut_category_digital">Digital</string>
|
||||
<string name="lut_category_film">Film</string>
|
||||
<string name="custom">Kustom</string>
|
||||
<string name="input_curve">Kurva Input</string>
|
||||
|
||||
|
||||
@@ -287,6 +287,8 @@
|
||||
<string name="delete_category_message">カテゴリ「%s」を削除してもよろしいですか?このカテゴリ内のLUTは未分類にリセットされます。</string>
|
||||
<string name="favorite_empty_message">フィルターの☆をタップするとここに表示されます。</string>
|
||||
<string name="built_in">プリセット</string>
|
||||
<string name="lut_category_digital">デジタル</string>
|
||||
<string name="lut_category_film">フィルム</string>
|
||||
<string name="custom">カスタム</string>
|
||||
<string name="uncategorized">未分類</string>
|
||||
<string name="input_curve">入力カーブ</string>
|
||||
|
||||
@@ -250,6 +250,8 @@
|
||||
<string name="delete_category_title">카테고리 삭제</string>
|
||||
<string name="delete_category_message">카테고리 \"%s\"을(를) 삭제하시겠습니까? 이 카테고리의 LUT는 분류되지 않음으로 초기화됩니다.</string>
|
||||
<string name="built_in">내장</string>
|
||||
<string name="lut_category_digital">디지털</string>
|
||||
<string name="lut_category_film">필름</string>
|
||||
<string name="custom">사용자 정의</string>
|
||||
<string name="input_curve">입력 곡선</string>
|
||||
|
||||
|
||||
@@ -250,6 +250,8 @@
|
||||
<string name="delete_category_title">Excluir Categoria</string>
|
||||
<string name="delete_category_message">Tem certeza de que deseja excluir a categoria \"%s\"? Os LUTs nesta categoria serão redefinidos para sem categoria.</string>
|
||||
<string name="built_in">Integrado</string>
|
||||
<string name="lut_category_digital">Digital</string>
|
||||
<string name="lut_category_film">Filme</string>
|
||||
<string name="custom">Personalizado</string>
|
||||
<string name="input_curve">Curva de Entrada</string>
|
||||
|
||||
|
||||
@@ -459,6 +459,8 @@
|
||||
<string name="favorite_empty_title">ยังไม่มีรายการโปรด</string>
|
||||
<string name="favorite_empty_message">แตะดาวบนฟิลเตอร์เพื่อเพิ่มไว้ที่นี่</string>
|
||||
<string name="built_in">ที่มากับแอป</string>
|
||||
<string name="lut_category_digital">ดิจิทัล</string>
|
||||
<string name="lut_category_film">ฟิล์ม</string>
|
||||
<string name="custom">กำหนดเอง</string>
|
||||
<string name="uncategorized">ไม่มีหมวดหมู่</string>
|
||||
<string name="input_curve">เส้นโค้งอินพุต</string>
|
||||
|
||||
@@ -684,6 +684,8 @@
|
||||
<string name="favorite_empty_title">暂无收藏</string>
|
||||
<string name="favorite_empty_message">点击滤镜上的星标,即可将它添加到这里。</string>
|
||||
<string name="built_in">内置</string>
|
||||
<string name="lut_category_digital">数码</string>
|
||||
<string name="lut_category_film">胶片</string>
|
||||
<string name="custom">自定义</string>
|
||||
<string name="uncategorized">未分类</string>
|
||||
<string name="input_curve">输入曲线</string>
|
||||
|
||||
@@ -663,6 +663,8 @@
|
||||
<string name="favorite_empty_title">尚無收藏</string>
|
||||
<string name="favorite_empty_message">點按濾鏡上的星號,即可將它加入此處。</string>
|
||||
<string name="built_in">內置</string>
|
||||
<string name="lut_category_digital">數碼</string>
|
||||
<string name="lut_category_film">菲林</string>
|
||||
<string name="custom">自訂</string>
|
||||
<string name="uncategorized">未分類</string>
|
||||
<string name="input_curve">輸入曲線</string>
|
||||
|
||||
@@ -663,6 +663,8 @@
|
||||
<string name="favorite_empty_title">尚無收藏</string>
|
||||
<string name="favorite_empty_message">點按濾鏡上的星號,即可將它加入此處。</string>
|
||||
<string name="built_in">內置</string>
|
||||
<string name="lut_category_digital">數位</string>
|
||||
<string name="lut_category_film">底片</string>
|
||||
<string name="custom">自訂</string>
|
||||
<string name="uncategorized">未分類</string>
|
||||
<string name="input_curve">輸入曲線</string>
|
||||
|
||||
@@ -711,6 +711,8 @@
|
||||
<string name="favorite_empty_title">No favorites yet</string>
|
||||
<string name="favorite_empty_message">Tap the star on a filter to find it here.</string>
|
||||
<string name="built_in">Built-in</string>
|
||||
<string name="lut_category_digital">Digital</string>
|
||||
<string name="lut_category_film">Film</string>
|
||||
<string name="custom">Custom</string>
|
||||
<string name="uncategorized">Uncategorized</string>
|
||||
<string name="input_curve">Input Curve</string>
|
||||
|
||||
Reference in new issue
Block a user