Loading src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.settings.accessibility; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; Loading @@ -38,10 +37,10 @@ public class ReduceBrightColorsIntensityPreferenceController extends SliderPrefe @Override public int getAvailabilityStatus() { if (!ColorDisplayManager.isColorTransformAccelerated(mContext)) { if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) { return UNSUPPORTED_ON_DEVICE; } else if (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0) != 1) { } if (!mColorDisplayManager.isReduceBrightColorsActivated()) { return DISABLED_DEPENDENT_SETTING; } return AVAILABLE; Loading src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java +9 −1 Original line number Diff line number Diff line Loading @@ -17,21 +17,29 @@ package com.android.settings.accessibility; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.provider.Settings; import com.android.settings.core.TogglePreferenceController; /** PreferenceController for persisting feature activation state after a restart. */ public class ReduceBrightColorsPersistencePreferenceController extends TogglePreferenceController { private final ColorDisplayManager mColorDisplayManager; public ReduceBrightColorsPersistencePreferenceController( Context context, String preferenceKey) { super(context, preferenceKey); mColorDisplayManager = context.getSystemService(ColorDisplayManager.class); } @Override public int getAvailabilityStatus() { // TODO(b/170970675): call into CDS to get availability/config status if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) { return UNSUPPORTED_ON_DEVICE; } if (!mColorDisplayManager.isReduceBrightColorsActivated()) { return DISABLED_DEPENDENT_SETTING; } return AVAILABLE; } Loading src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class ReduceBrightColorsPreferenceController extends TogglePreferenceCont @Override public int getAvailabilityStatus() { return ColorDisplayManager.isColorTransformAccelerated(mContext) ? AVAILABLE return ColorDisplayManager.isReduceBrightColorsAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } Loading src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON; import android.app.settings.SettingsEnums; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -175,8 +176,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre new BaseSearchIndexProvider(R.xml.reduce_bright_colors_settings) { @Override protected boolean isPageSearchEnabled(Context context) { // TODO(b/170970675): call into CDS to get availability/config status return true; return ColorDisplayManager.isReduceBrightColorsAvailable(context); } }; } tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1); doReturn(true).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isTrue(); } @Test Loading @@ -64,7 +64,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0); doReturn(true).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isTrue(); } @Test Loading @@ -72,7 +72,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1); doReturn(false).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isFalse(); } Loading Loading
src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceController.java +3 −4 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ package com.android.settings.accessibility; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.provider.Settings; import androidx.preference.Preference; import androidx.preference.PreferenceScreen; Loading @@ -38,10 +37,10 @@ public class ReduceBrightColorsIntensityPreferenceController extends SliderPrefe @Override public int getAvailabilityStatus() { if (!ColorDisplayManager.isColorTransformAccelerated(mContext)) { if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) { return UNSUPPORTED_ON_DEVICE; } else if (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0) != 1) { } if (!mColorDisplayManager.isReduceBrightColorsActivated()) { return DISABLED_DEPENDENT_SETTING; } return AVAILABLE; Loading
src/com/android/settings/accessibility/ReduceBrightColorsPersistencePreferenceController.java +9 −1 Original line number Diff line number Diff line Loading @@ -17,21 +17,29 @@ package com.android.settings.accessibility; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.provider.Settings; import com.android.settings.core.TogglePreferenceController; /** PreferenceController for persisting feature activation state after a restart. */ public class ReduceBrightColorsPersistencePreferenceController extends TogglePreferenceController { private final ColorDisplayManager mColorDisplayManager; public ReduceBrightColorsPersistencePreferenceController( Context context, String preferenceKey) { super(context, preferenceKey); mColorDisplayManager = context.getSystemService(ColorDisplayManager.class); } @Override public int getAvailabilityStatus() { // TODO(b/170970675): call into CDS to get availability/config status if (!ColorDisplayManager.isReduceBrightColorsAvailable(mContext)) { return UNSUPPORTED_ON_DEVICE; } if (!mColorDisplayManager.isReduceBrightColorsActivated()) { return DISABLED_DEPENDENT_SETTING; } return AVAILABLE; } Loading
src/com/android/settings/accessibility/ReduceBrightColorsPreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ public class ReduceBrightColorsPreferenceController extends TogglePreferenceCont @Override public int getAvailabilityStatus() { return ColorDisplayManager.isColorTransformAccelerated(mContext) ? AVAILABLE return ColorDisplayManager.isReduceBrightColorsAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE; } Loading
src/com/android/settings/accessibility/ToggleReduceBrightColorsPreferenceFragment.java +2 −2 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON; import android.app.settings.SettingsEnums; import android.content.Context; import android.hardware.display.ColorDisplayManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; Loading Loading @@ -175,8 +176,7 @@ public class ToggleReduceBrightColorsPreferenceFragment extends ToggleFeaturePre new BaseSearchIndexProvider(R.xml.reduce_bright_colors_settings) { @Override protected boolean isPageSearchEnabled(Context context) { // TODO(b/170970675): call into CDS to get availability/config status return true; return ColorDisplayManager.isReduceBrightColorsAvailable(context); } }; }
tests/unit/src/com/android/settings/accessibility/ReduceBrightColorsIntensityPreferenceControllerTest.java +3 −3 Original line number Diff line number Diff line Loading @@ -56,7 +56,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1); doReturn(true).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isTrue(); } @Test Loading @@ -64,7 +64,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 0); doReturn(true).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isTrue(); } @Test Loading @@ -72,7 +72,7 @@ public class ReduceBrightColorsIntensityPreferenceControllerTest { Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED, 1); doReturn(false).when(mResources).getBoolean( com.android.internal.R.bool.config_setColorTransformAccelerated); R.bool.config_reduceBrightColorsAvailable); assertThat(mPreferenceController.isAvailable()).isFalse(); } Loading