Get enable/disable status and of accessibility Colour inversion mode

醉酒当歌 提交于 2019-12-01 06:59:52

问题


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?


回答1:


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;

}



回答2:


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.



来源:https://stackoverflow.com/questions/44032468/get-enable-disable-status-and-of-accessibility-colour-inversion-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!