mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Android: Avoid restarting activities on system-wide theme change
This commit is contained in:
parent
f72bad64d2
commit
33a735dfd8
6 changed files with 21 additions and 14 deletions
|
|
@ -2562,18 +2562,25 @@ public:
|
|||
|
||||
bool isDarkModeEnabled() const noexcept { return darkModeEnabled; }
|
||||
|
||||
void onActivityStarted (jobject /*activity*/) override
|
||||
private:
|
||||
void onActivityStarted (jobject) override
|
||||
{
|
||||
const auto isEnabled = getDarkModeSetting();
|
||||
|
||||
if (darkModeEnabled != isEnabled)
|
||||
{
|
||||
darkModeEnabled = isEnabled;
|
||||
Desktop::getInstance().darkModeChanged();
|
||||
}
|
||||
updateMode();
|
||||
}
|
||||
|
||||
void onActivityConfigurationChanged (jobject) override
|
||||
{
|
||||
updateMode();
|
||||
}
|
||||
|
||||
void updateMode()
|
||||
{
|
||||
const auto current = getDarkModeSetting();
|
||||
|
||||
if (std::exchange (darkModeEnabled, current) != current)
|
||||
Desktop::getInstance().darkModeChanged();
|
||||
}
|
||||
|
||||
private:
|
||||
static bool getDarkModeSetting()
|
||||
{
|
||||
auto* env = getEnv();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue