How to Force Dark Mode?

Post your questions and help other users.

Moderator: Martin

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

How to Force Dark Mode?

Post by Philip » 03 Jul 2020 14:03

My Samsung Galaxy Note 10+ has an option under Settings > Developer options > Force Dark mode. This forces all apps (even those which don't have a native Dark Mode) to use a "dark mode" setting.

Unfortunately this setting unsets itself every time I reboot my handset, so I have to manually turn it back on.

I'd like to get Automagic to do this for me. I can use Start Activity with android.settings.APPLICATION_DEVELOPMENT_SETTINGS in the action field to open Developer Options, but can't see any way to toggle Force Dark Mode.

Is this possible?
--
Philip

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to Force Dark Mode?

Post by Micky Micky » 03 Jul 2020 21:25

Hello,

It may be possible with additional information in the START ACTIVITY action. I cannot help you with that.

Normally CONTROL UI action would provide a solution but the Overlay Control doesn't work with Settings pages. So you can't get the toggle switch information.

However, one crude (and it's very crude) solution is to use the gesture recorder to record swipes up and a swipe across. This will simulate the actions you do when changing the setting manually.

You can't record the gestures on the settings page, but you can on the Automagic screen. A lot of trial and error is involved to get it right. I would wait to see if someone can provide the information required for START ACTIVITY settings.

Good luck

Micky
Crude but it works.

User avatar
Hit
Posts: 91
Joined: 20 Jan 2020 11:31

Re: How to Force Dark Mode?

Post by Hit » 04 Jul 2020 12:06

Hello, Philip.

I have an idea that you can use Action: Set System Setting to change the setting that make your phone to force dark mode if it exist.

You can find it yourself.
Another way you can try this to find that setting if it is exist: Secure Setting Logger

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to Force Dark Mode?

Post by Micky Micky » 04 Jul 2020 13:10

Hello

The setting exists on my Samsung S10

display_night_theme

But it only toggles the setting, it doesn't activate it.

Nice approach if it did work. Still worth trying as results can vary depending on the phone.

Thank you

Micky
Crude but it works.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to Force Dark Mode?

Post by Desmanto » 05 Jul 2020 15:05

Most of the time, setting in the developer option are protected by special API. You might need to open the setting page again to force the system reread the secure setting you have changed.

The other way is to open the development setting, use the control UI scrollForwardById(elementid) several times until the designated toggle and then use clickById() or other type to toggle the dark mode. If you don't restart the mode frequently, some UI distraction at every reboot should be tolerable.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to Force Dark Mode?

Post by Micky Micky » 05 Jul 2020 15:21

Hello,

Control UI can't use the overlay on settings pages.

Try it.

Micky
Crude but it works.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to Force Dark Mode?

Post by Desmanto » 05 Jul 2020 17:43

@Micky : I just tested it, scrollForward() works fine in the developer options. I don't know with other phone/ROM, but it is working at my RN5 Whyred, with ROM AEX 6.7, based on Pie 9.0. Maybe some other ROM protect the setting pages or flagged it as secure, so can't be accessed by Accessibility.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to Force Dark Mode?

Post by Micky Micky » 05 Jul 2020 17:54

Desmanto,

You can't use ClickById etc because the overlay function of Control UI doesn't work in that settings page. Unless you know another way.

Yes you can scroll about, that's what my original suggestion was explaining. My method involves a bit of trial & error to move down to the correct point and the swipe across on the toggle switch for dark mode.

(BTW I'm quite proud of the crudeness of it)

Micky
Crude but it works.

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: How to Force Dark Mode?

Post by Desmanto » 05 Jul 2020 18:37

Try Control UI in the developer option menu, i got something like this when I click on the "System UI demo mode"
Developer Options - System UI Mode.png
Developer Options - System UI Mode.png (284.06 KiB) Viewed 17946 times
From there, I can use scrollForwardByld("android:id/title"). I can loop this several times to reach the setting I want.

Of course, this is at my phone. It might be different in other phone/ROM.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Micky Micky
Posts: 179
Joined: 16 Oct 2019 17:38

Re: How to Force Dark Mode?

Post by Micky Micky » 05 Jul 2020 18:45

Lucky you.

Any settings page on my S10 causes the overlay controls to disappear.

Maybe the OP can see it on their phone. If so, then you can help.

Many thanks

Micky
Crude but it works.

Post Reply