fix(ColorCorrection): Palette preview text contrast Issue

Root Cause: The palette preview's text color inherits dynamic colors from the BC pattern, leading to insufficient contrast against some backgrounds. This wasn't a problem in the original design, as the BC pattern was introduced later.

Solution: Set the palette preview text color to textColorPrimary to ensure the text remains legible against a wider range of background colors.

Bug: 378775277
Flag: EXEMPT bugfix
Test: atest PaletteListPreferenceTest

Change-Id: I8efb9f9d916d618b450df169292202e499d8ac0d
This commit is contained in:
Menghan Li
2024-11-14 06:45:12 +00:00
parent aa7114cf3e
commit 80f8b87e28
2 changed files with 20 additions and 4 deletions

View File

@@ -16,17 +16,20 @@
package com.android.settings.accessibility;
import static org.junit.Assert.assertEquals;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.preference.PreferenceViewHolder;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settingslib.Utils;
import org.junit.Before;
import org.junit.Test;
@@ -53,12 +56,20 @@ public final class PaletteListPreferenceTest {
@Test
public void initPaletteView_success() {
final int expectedCount =
mContext.getResources().getStringArray(R.array.setting_palette_data).length;
final ColorStateList expectedTextColor =
Utils.getColorAttr(mContext, android.R.attr.textColorPrimary);
mPaletteListPreference.onBindViewHolder(mPreferenceViewHolder);
final ViewGroup viewGroup =
mPreferenceViewHolder.itemView.findViewById(R.id.palette_view);
final int expectedCount =
mContext.getResources().getStringArray(R.array.setting_palette_data).length;
assertEquals(expectedCount, viewGroup.getChildCount());
final int childCount = viewGroup.getChildCount();
assertThat(childCount).isEqualTo(expectedCount);
for (int i = 0; i < childCount; i++) {
final TextView textView = (TextView) viewGroup.getChildAt(i);
assertThat(textView.getTextColors()).isEqualTo(expectedTextColor);
}
}
}