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,11 +219,8 @@ class MainActivity : AppCompatActivity() {
binding.imgFilterOverlay.visibility = android.view.View.GONE
} else {
binding.imgFilterOverlay.visibility = android.view.View.VISIBLE
val filterColor = when (preset.id) {
"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 isBeingEdited = editingPreset != null
val filterColor = if (isBeingEdited) {
// Sophisticated ARGB mapping to simulate film filters using adjustment parameters
// Vibrance and Saturation increase opacity of the filter color
val alpha = (((preset.basic.vibrance + preset.basic.saturation) / 2f + 1.0f) * 40 + 20).toInt().coerceIn(10, 120)
@@ -241,6 +238,21 @@ class MainActivity : AppCompatActivity() {
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)
} else {
when (preset.id) {
"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)
@@ -596,6 +608,7 @@ class MainActivity : AppCompatActivity() {
.setDuration(200)
.withEndAction {
binding.cardAdvancedSliders.visibility = android.view.View.GONE
editingPreset = null
currentSelectedPreset?.let { applyPresetFilter(it) }
}
.start()