Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Night mode on CheeseDetailsActivity #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jonathan-caryl
Copy link

@chrisbanes on the CheeseDetailsActivity there's the 'Night mode' menu, but it doesn't show the correctly checked mode, and selecting the items does nothing. I've extracted the code to handle the checking and selecting into a helper class — seemed neater than putting it in a common base class.

I bumped the gradle/support lib versions at the same time, good to keep up-to-date.

@jonathan-caryl
Copy link
Author

Updated, removed casts no longer required with support lib v26.

private void setNightMode(@AppCompatDelegate.NightMode int nightMode) {
AppCompatDelegate.setDefaultNightMode(nightMode);

activity.recreate();
Copy link

@nachtien nachtien Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the grandparent activity (parent of the parent)? It might not be destroyed, causing the new mode not to be set. @chrisbanes, this is an issue we ran into, and I assume this is why it wasn't implemented here because it's a bit of a hack job.

We used startActivityForResult in our implementation, and then set the result code based on if the theme was changed or not, and depending on what code was returned, we recreate the activity. Activities before the parent wouldn't be updated unless Android destroys them and they are restarted. Anyone know of the best way around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants