Fix: Enable real-time ARGB color overlay preview updates by bypassing hardcoded colors in edit mode

This commit is contained in:
2026-07-05 18:20:46 +07:00
parent bcbb853558
commit b5d7311447
@@ -219,28 +219,40 @@ class MainActivity : AppCompatActivity() {
binding.imgFilterOverlay.visibility = android.view.View.GONE binding.imgFilterOverlay.visibility = android.view.View.GONE
} else { } else {
binding.imgFilterOverlay.visibility = android.view.View.VISIBLE binding.imgFilterOverlay.visibility = android.view.View.VISIBLE
val filterColor = when (preset.id) { val isBeingEdited = editingPreset != null
"instax_faded_warm_01" -> android.graphics.Color.argb(55, 255, 152, 0) val filterColor = if (isBeingEdited) {
"instax_bw_cool" -> android.graphics.Color.argb(80, 128, 128, 128) // Sophisticated ARGB mapping to simulate film filters using adjustment parameters
"instax_cool_summer" -> android.graphics.Color.argb(45, 0, 188, 212) // Vibrance and Saturation increase opacity of the filter color
else -> { val alpha = (((preset.basic.vibrance + preset.basic.saturation) / 2f + 1.0f) * 40 + 20).toInt().coerceIn(10, 120)
// Sophisticated ARGB mapping to simulate film filters using adjustment parameters
// Vibrance and Saturation increase opacity of the filter color // Temperature (+ is warm/red-yellow), Brightness, Clarity, and ShadowsTintR affect red
val alpha = (((preset.basic.vibrance + preset.basic.saturation) / 2f + 1.0f) * 40 + 20).toInt().coerceIn(10, 120) val tempWarmth = if (preset.basic.temperature > 0) preset.basic.temperature * 50f else 0f
val r = (((preset.advanced.clarity + preset.basic.brightness) / 2f + 1.0f) * 100 + 30 + tempWarmth + (preset.toneCurve.shadowsTintR * 30)).toInt().coerceIn(0, 255)
// Temperature (+ is warm/red-yellow), Brightness, Clarity, and ShadowsTintR affect red
val tempWarmth = if (preset.basic.temperature > 0) preset.basic.temperature * 50f else 0f // Contrast, Tint (- is green), and ShadowsTintG affect green
val r = (((preset.advanced.clarity + preset.basic.brightness) / 2f + 1.0f) * 100 + 30 + tempWarmth + (preset.toneCurve.shadowsTintR * 30)).toInt().coerceIn(0, 255) val tintGreen = if (preset.basic.tint < 0) -preset.basic.tint * 50f else 0f
val g = ((preset.basic.contrast + 1.0f) * 90 + 20 + tintGreen + (preset.toneCurve.shadowsTintG * 30)).toInt().coerceIn(0, 255)
// Contrast, Tint (- is green), and ShadowsTintG affect green
val tintGreen = if (preset.basic.tint < 0) -preset.basic.tint * 50f else 0f // Dehaze, cool Temperature (- is blue), and ShadowsTintB affect blue
val g = ((preset.basic.contrast + 1.0f) * 90 + 20 + tintGreen + (preset.toneCurve.shadowsTintG * 30)).toInt().coerceIn(0, 255) val tempCoolness = if (preset.basic.temperature < 0) -preset.basic.temperature * 60f else 0f
val b = (((preset.advanced.dehaze + 1.0f) * 80) + 20 + tempCoolness + (preset.toneCurve.shadowsTintB * 30)).toInt().coerceIn(0, 255)
// Dehaze, cool Temperature (- is blue), and ShadowsTintB affect blue
val tempCoolness = if (preset.basic.temperature < 0) -preset.basic.temperature * 60f else 0f android.graphics.Color.argb(alpha, r, g, b)
val b = (((preset.advanced.dehaze + 1.0f) * 80) + 20 + tempCoolness + (preset.toneCurve.shadowsTintB * 30)).toInt().coerceIn(0, 255) } else {
when (preset.id) {
android.graphics.Color.argb(alpha, r, g, b) "instax_faded_warm_01" -> android.graphics.Color.argb(55, 255, 152, 0)
"instax_bw_cool" -> android.graphics.Color.argb(80, 128, 128, 128)
"instax_cool_summer" -> android.graphics.Color.argb(45, 0, 188, 212)
else -> {
val alpha = (((preset.basic.vibrance + preset.basic.saturation) / 2f + 1.0f) * 40 + 20).toInt().coerceIn(10, 120)
val tempWarmth = if (preset.basic.temperature > 0) preset.basic.temperature * 50f else 0f
val r = (((preset.advanced.clarity + preset.basic.brightness) / 2f + 1.0f) * 100 + 30 + tempWarmth + (preset.toneCurve.shadowsTintR * 30)).toInt().coerceIn(0, 255)
val tintGreen = if (preset.basic.tint < 0) -preset.basic.tint * 50f else 0f
val g = ((preset.basic.contrast + 1.0f) * 90 + 20 + tintGreen + (preset.toneCurve.shadowsTintG * 30)).toInt().coerceIn(0, 255)
val tempCoolness = if (preset.basic.temperature < 0) -preset.basic.temperature * 60f else 0f
val b = (((preset.advanced.dehaze + 1.0f) * 80) + 20 + tempCoolness + (preset.toneCurve.shadowsTintB * 30)).toInt().coerceIn(0, 255)
android.graphics.Color.argb(alpha, r, g, b)
}
} }
} }
binding.imgFilterOverlay.setBackgroundColor(filterColor) binding.imgFilterOverlay.setBackgroundColor(filterColor)
@@ -596,6 +608,7 @@ class MainActivity : AppCompatActivity() {
.setDuration(200) .setDuration(200)
.withEndAction { .withEndAction {
binding.cardAdvancedSliders.visibility = android.view.View.GONE binding.cardAdvancedSliders.visibility = android.view.View.GONE
editingPreset = null
currentSelectedPreset?.let { applyPresetFilter(it) } currentSelectedPreset?.let { applyPresetFilter(it) }
} }
.start() .start()