WildAid / o-fish-android

Android app for the Officer's Fishery Information Sharing Hub (O-FISH). The mobile app allows fisheries officers to document and share critical information gathered during a routine vessel inspection.
Apache License 2.0
22 stars 24 forks source link

Dark Mode for Risk page #385

Closed o-fish-wildaid closed 4 years ago

o-fish-wildaid commented 4 years ago

This issue depends on #368 being completed.

When Dark Mode is on - the Risk page should look like this: https://mongodb.invisionapp.com/share/PCYZ6ZW7FR8#/screens/433591792_Boarding_-_Risk

Color key for light mode: https://mongodb.invisionapp.com/share/PCYZ6ZW7FR8#/screens/433591768_Color_Key_-_Light_Mode Color key for dark mode: https://mongodb.invisionapp.com/share/PCYZ6ZW7FR8#/screens/433591769_Color_Key_-_Dark_Mode Component Color specs for light mode: https://mongodb.invisionapp.com/share/PCYZ6ZW7FR8#/screens/433591770_Component_Colors_-_Light_Mode Component Color specs for dark mode: https://mongodb.invisionapp.com/share/PCYZ6ZW7FR8#/screens/433591771_Component_Colors_-_Dark_Mode

Both dark and light modes should follow the color key and specs above (it is possible that the current light mode is not).

Please make sure to TEST your build on a device or emulator to verify everything has changed - you can get a login and realm-app-id with easy instructions at https://wildaid.github.io/contribute/sandbox.html

ashwinpilgaonkar commented 4 years ago

Hi @o-fish-wildaid, can I work on this?

Sheeri commented 4 years ago

Hello @ashwinpilgaonkar, thanks for offering to work on this! I have assigned it to you.

Sheeri commented 4 years ago

Hello, part of the work has been done in a recent merge - the colors for night mode are in:

app/src/main/res/values-night/colors.xml

The colors for light mode are in: app/src/main/res/values/colors.xml

How's the work going? We like to have an update every 3 days, so we know the issue has not been abandoned.

ashwinpilgaonkar commented 4 years ago

Hello, part of the work has been done in a recent merge - the colors for night mode are in:

app/src/main/res/values-night/colors.xml

The colors for light mode are in: app/src/main/res/values/colors.xml

Okay, thanks for letting me know!

How's the work going? We like to have an update every 3 days, so we know the issue has not been abandoned.

Sorry for the delay, I've just begun to work on it.

Sheeri commented 4 years ago

@ashwinpilgaonkar Thanks for letting us know! If you run into issues, you can look to see if anyone else had the same issue at https://developer.mongodb.com/community/forums/tag/o-fish/ - and if not, you can start a new topic on that page (once you are logged into the forums).

ashwinpilgaonkar commented 4 years ago

Hi @Sheeri, I seem to be having an issue while trying to implement dark mode for the risk page. Regardless of whether dark mode is on or not, the app continues to use the colors specified in the non-dark-mode colors.xml. As I understand it, this should be handled automatically.

I used the following Kotlin code snippet to test whether the app is able to detect the dark mode setting -

    private fun isDarkModeOn(): Boolean {
        val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
        return currentNightMode == Configuration.UI_MODE_NIGHT_YES
    }

It always returns false, regardless of whether the Dark mode is on or off. I tested it out on a Pixel 3 API 30 emulator, running Android R 10.0+ x86

Sheeri commented 4 years ago

Hi @ashwinpilgaonkar - Looking at the dependent issue #368 - I see that it was fixed by Pull Request #390. When looking at the changed files, I can see:

app/src/main/java/org/wildaid/ofish/data/RepositoryImpl.kt has the function: override fun getDarkModeState() = realmDataSource.getDarkModeState()

so I would use that to get the Dark Mode state. Make sure to git pull against main if your branch was made before PR 390 was merged into the codebase.

Note that "dark mode" is based on the app's dark mode toggle in the user's "Me" page (from the home screen, click on the avatar in the upper right to get to the 'me' page). It is not dependent on the OS dark mode, because we support older versions of Android that do not have a dark mode in the OS.

ashwinpilgaonkar commented 4 years ago

Alright, thanks for the info!

I was under the assumption that the app is dependent on the OS dark mode.