Summary:
With the new Android 10, there is a system-wide dark theme available.
Most of the apps automatically turn on/off the dark theme if it is enabled in the phone's setting.
We can add an option in our app's settings which will automatically switch to the preferred mode.
Screen-shots:

Would you like to work on this issue?
Yes
@nicolas-raoul @neslihanturan @misaochan What do you suggest?
This would be nice, but we should also keep our in-app setting IMO.
@neslihanturan Yes, we should keep it since Android 10 is new and not available to all phones yet.
@madhurgupta10 IIUC, you're thinking of changing the existing into something like the following:

Is that correct? If that is, then it would be a good addition indeed.
@sivaraam Indeed this is what I am suggesting
@madhurgupta10 @sivaraam Or there could be just the two options, Light or Dark, and by default, the system's default theme should be selected?
@ashishkumar0207 I think it would be fine as well since most users who use dark mode on other apps won't prefer white mode on our app and vice-versa.
I think it would be better to provide the options following the guidelines mentioned in the Android Developer guide for Dark theme:
When running on devices running Android 9 or earlier, the recommended theme options are:
- Light
- Dark
- Set by Battery Saver (the recommended default option)
When running on Android 10 (API level 29) and higher, the recommended options are different, to allow the user to override the system default:
- Light
- Dark
- System default (the recommended default option)
Note that if the user selects Light, then Battery Saver will not change that setting.
This sounds sensible to me. This might improve the scope of the task but I hope it's for the better :slightly_smiling_face:
There seems to be a lot of discussion in the PR. So, can someone quickly catch me up on something? Were the changes done so that the options are provided as suggested in the above comment as seemed to be the consensus? I'm mostly wondering about whether we show different options for the different Android versions.
@sivaraam I changed the night mode setting from a simple switch to a list preference. User can now set it as Dark or Light or Default (System-Wide Theme)
In Android 10 if the default is selected in Commons app setting then the app will follow the system setting.
For older devices default system-wide theme remains Light or incase a custom skin of android supports dark theme then the app will also support it.
For a quick recap, the Commons app now follows the same theme system used by Contacts, Gmail, etc.
There isn't actually a real mapping to these settings specifically but that is because we don't have a dayNight theme.
What the app does for auto is check the configuration to see if night mode is active and if so sets the theme dark, otherwise light.
Hopefully we will get to using AppCompatDelegate.setDefaultNightMode(). once #3461 is done
I've noted some general comments about the change in a PR comment. Now some replies to the some points:
For older devices default system-wide theme remains Light or incase a custom skin of android supports dark theme then the app will also support it.
Ah ha! I totally missed this when I said I'm not sure what happens on Android 9 or lower devices for the "Default" option in the PR comment. Sorry about that.
For a quick recap, the Commons app now follows the same theme system used by Contacts, Gmail, etc.
Not exactly, I would say. At least not in Android 5.1 devices. Gmail doesn't even have an option to change the theme in Android 5.1. In Android 10, I see an option to change the theme. This is for the same versions of the app. I'm surprised they don't provide an option to switch between "Light" and "Dark" themes in Android 5.1. Anyways, that's not our concern now 馃し鈥嶁檪 So, moving on.
The behaviour of the Contacts app seems to mimic what's described in the developer guide including the options shown for the different Android versions. If resolving #3461 required to get this right, then fine. I'm just trying to clarify that the app still isn't there yet.
Hopefully we will get to using AppCompatDelegate.setDefaultNightMode(). once #3461 is done
If that would improve the status quo, that would be great!
Most helpful comment
I think it would be better to provide the options following the guidelines mentioned in the Android Developer guide for Dark theme:
This sounds sensible to me. This might improve the scope of the task but I hope it's for the better :slightly_smiling_face: