Get enable/disable status and of accessibility Colour inversion mode
Asked Answered
G

2

5

In my application i need to make some UI changes when user enable accessibility colour inversion mode.

Do we have any api to check enable/disable status of colour inversion mode in android?

Gabion answered 17/5, 2017 at 18:35 Comment(2)
What change do you need to make based on color inversion? I can't think of any cases where this would be a good accessibility practice even if it were possible.Moritz
In my screen there are some places where gray background and white text is available. Now when inversion mode applied i system will change the gray background to near black and white text to black. So here both since background and text colour both are black, so user is unable to see text. So my intension is if the inversion is enabled change the text colour as white or any other visible colour.This i want to programaticallyGabion
G
5

Below is the code to check enable/disable status of accessibility inversion mode. In some phone inversion mode will be available as "Negative colour".

public boolean isInversionModeEnabled() {
    boolean isInversionEnabled =  false;
    int accessibilityEnabled = 0;
    try {
        accessibilityEnabled = Settings.Secure.getInt(this.getContentResolver(),
                android.provider.Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED);
    } catch (SettingNotFoundException e) {
        Log.d(TAG, "Error finding setting ACCESSIBILITY_DISPLAY_INVERSION_ENABLED: " + e.getMessage());
        Log.d(TAG, "Checking negative color enabled status");
        final String SEM_HIGH_CONTRAST = "high_contrast";
        accessibilityEnabled = Settings.System.getInt(getContentResolver(), SEM_HIGH_CONTRAST, 0);
    }
    if (accessibilityEnabled == 1) {
        Log.d(TAG, "inversion  or negative colour is enabled");
        isInversionEnabled = true;
    } else {
        Log.d(TAG, "inversion  or negative colour is disabled");
    }
    return isInversionEnabled;

}
Gabion answered 18/6, 2017 at 18:53 Comment(1)
For what devices / accessibility setting would high_contrast return true?Marden
M
0

Color inversion does not change the contrast ratio between colors, so if you have white text on a gray background to start, and you claim that the inverted black on dark gray is hard to see, then it is just as hard for some users to see the original text.

Perhaps the original text color should have been black? Ultimately, per WCAG criterion 1.4.3 on Contrast, you should have a minimum ratio of 4.5:1. See this post on the UX Stack Exchange for how to compute using black vs. white text.

Moritz answered 17/5, 2017 at 21:22 Comment(3)
"Perhaps the original text color should have been black? " Actually our HID is like that , the reason behind is when user open the screen(lets say login screen where we have usename and pwd) the button text on grey border is white, once user enter uname and pwd then button colour will change to black. So when i open my screen i want to check whether inversion mode is enabled or not. If inversion mode is enabled then i want to change the colour of the button to grey or some such to visible to user. Similarly my application should listen(like broadcast) if user enable/disable inversion mode.Gabion
I understand what you want to do, but your motivation for doing it is poor contrast ratio. My point is that the contrast ratio in your original content without color inversion is mathematically equivalent. You are trying to solve the problem in the wrong way. If you change your non-inverted colors to have good contrast, then the inverted mode won't be a problem.Moritz
Ok..Let me check. Could you please give your inputs on below? - Is there any api to check whether inversion mode enable or disable? - Is there any way to get notify app that inversion mode enable/disable dynamic changes?Gabion

© 2022 - 2024 — McMap. All rights reserved.