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

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

问题描述:

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

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

我们是否有任何 api 来检查 android 中颜色反转模式的启用/禁用状态?

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;

}