I would like to know if Android has any flag to be added into configChanges
in an Activity attribute in the AndroidManifest for modifications in the Invert Colors option of the device.
The android doc shows the following flags:
- "mcc"
- "mnc"
- "locale"
- "touchscreen"
- "keyboard"
- "keyboardHidden"
- "navigation"
- "screenLayout"
- "fontScale"
- "uiMode" // this one is for the dark mode
- "orientation"
- "density"
- "screenSize"
- "smallestScreenSize"
But none of them deal with it.
Invert colors option:
Press the Windows key on your keyboard, or click the Windows icon at the bottom left of your screen, and type "Magnifier." Open the search result that comes up. 2. Scroll down through this menu until you find "Invert colors" select it.
Invert colors Windows 10 hotkey, keyboard shortcut – Sometimes you can fix the problems with inverted colors simply by using a single keyboard shortcut. That shortcut is usually left Alt + left Shift + Print Screen, so feel free to try it.
If you need to check the state of inverted colors I see just two possible solutions.
Manual check. Taken from this question:
Get enable/disable status and of accessibility Colour inversion mode
fun isInversionModeEnabled(): Boolean {
var isInversionEnabled = false
val accessibilityEnabled = try {
Settings.Secure.getInt(contentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED)
} catch (e: Settings.SettingNotFoundException) {
Log.d(TAG, "Error finding setting ACCESSIBILITY_DISPLAY_INVERSION_ENABLED: " + e.message)
Log.d(TAG, "Checking negative color enabled status")
val SEM_HIGH_CONTRAST = "high_contrast"
Settings.System.getInt(contentResolver, 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
}
And also you can use AccessibilityService
.
On inversion color changed i've got such event:
EventType: TYPE_VIEW_CLICKED; EventTime: 170718119; PackageName: com.android.systemui;
MovementGranularity: 0; Action: 0; ContentChangeTypes: []; WindowChangeTypes: [] [
ClassName: android.widget.Switch; Text: [Invert colors]; ContentDescription: On;
So i can check the current state somehow like this:
override fun onAccessibilityEvent(event: AccessibilityEvent) {
val isInvertedColorsChanged = event.text.contains("Invert colors")
if (isInvertedColorsChanged) {
val isEnabled = event.contentDescription == "On"
//do what you need
}
}
I'm not sure it will work for every device.
I've never done it before, so maybe there is a better solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With