Hide color mode preference depending on Accessibility settings
Currently, when certain Accessibility color transforms are enabled, the color mode preference radio buttons are disabled. To avoid confusing users, hide the color mode preference entirely. If the color mode settings screen is already open when the Accessibility transforms are enabled, return the user back to the previous screen. Bug: 77695840 Test: make ROBOTEST_FILTER=ColorModePreferenceFragmentTest RunSettingsRoboTests -j40 Change-Id: I44812713bdc739b843e5806711d25ea950aa6250
This commit is contained in:
@@ -41,7 +41,9 @@ public class ColorModePreferenceController extends BasePreferenceController {
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mConfigWrapper.isScreenWideColorGamut() ? AVAILABLE : DISABLED_FOR_USER;
|
||||
return mConfigWrapper.isScreenWideColorGamut()
|
||||
&& !getColorDisplayController().getAccessibilityTransformActivated() ?
|
||||
AVAILABLE : DISABLED_FOR_USER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -16,7 +16,6 @@ package com.android.settings.display;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.internal.app.ColorDisplayController;
|
||||
@@ -25,7 +24,6 @@ import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.applications.LayoutPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.widget.RadioButtonPickerFragment;
|
||||
import com.android.settings.widget.RadioButtonPreference;
|
||||
import com.android.settingslib.widget.CandidateInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -81,14 +79,13 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment
|
||||
@Override
|
||||
protected List<? extends CandidateInfo> getCandidates() {
|
||||
Context c = getContext();
|
||||
final boolean enabled = !mController.getAccessibilityTransformActivated();
|
||||
return Arrays.asList(
|
||||
new ColorModeCandidateInfo(c.getText(R.string.color_mode_option_natural),
|
||||
KEY_COLOR_MODE_NATURAL, enabled),
|
||||
KEY_COLOR_MODE_NATURAL, true /* enabled */),
|
||||
new ColorModeCandidateInfo(c.getText(R.string.color_mode_option_boosted),
|
||||
KEY_COLOR_MODE_BOOSTED, enabled),
|
||||
KEY_COLOR_MODE_BOOSTED, true /* enabled */),
|
||||
new ColorModeCandidateInfo(c.getText(R.string.color_mode_option_saturated),
|
||||
KEY_COLOR_MODE_SATURATED, enabled)
|
||||
KEY_COLOR_MODE_SATURATED, true /* enabled */)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -153,16 +150,10 @@ public class ColorModePreferenceFragment extends RadioButtonPickerFragment
|
||||
|
||||
@Override
|
||||
public void onAccessibilityTransformChanged(boolean state) {
|
||||
// Disable controls when a11y transforms are enabled, and vice versa
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
if (screen != null) {
|
||||
final int count = screen.getPreferenceCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
final Preference pref = screen.getPreference(i);
|
||||
if (pref instanceof RadioButtonPreference) {
|
||||
pref.setEnabled(!state);
|
||||
}
|
||||
}
|
||||
// Color modes are no not configurable when Accessibility transforms are enabled. Close
|
||||
// this fragment in that case.
|
||||
if (state) {
|
||||
getActivity().onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user