获取启用/禁用状态和可访问性颜色反转模式

问题描述:

在我的应用程序中,当用户启用辅助功能颜色反转模式时,我需要进行一些UI更改。

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

我们是否有任何API可以检查颜色反转的启用/禁用状态

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

下面是检查可访问性反转模式的启用/禁用状态的代码。

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;

}