Skip to content

Dynamic window background based on plugin state#146

Merged
dinitri merged 2 commits intocapacitor-camera-layeringfrom
capacitor-dynamic-window-bg
Mar 24, 2026
Merged

Dynamic window background based on plugin state#146
dinitri merged 2 commits intocapacitor-camera-layeringfrom
capacitor-dynamic-window-bg

Conversation

@sc-nick
Copy link
Copy Markdown
Contributor

@sc-nick sc-nick commented Mar 2, 2026

Force a black window background while the plugin is active and restore the previous background on exit

Comment on lines +457 to +465
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
WindowInsetsController controller = cordova.getActivity().getWindow().getInsetsController();
int nightMode = cordova.getActivity().getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK;
if (controller != null) {
if (nightMode == android.content.res.Configuration.UI_MODE_NIGHT_YES) {
controller.setSystemBarsAppearance(0, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS | WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
} else {
controller.setSystemBarsAppearance(WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS | WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS, WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS | WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's the use here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's used to adjust the color of the status bar and nav bar icons based on the system theme

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, but why do we adapt to the system's theme?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The issue: status bar icons are not visible in light mode

Icons must be forced to a light color while the plugin is active since the window background is black. When the plugin is no longer active, the default behavior is restored allowing icon colors to adapt automatically to the system theme.

@dinitri dinitri merged commit 73064f7 into capacitor-camera-layering Mar 24, 2026
1 check failed
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.

3 participants