Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.getcapacitor.plugin;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
Expand Down Expand Up @@ -77,6 +80,7 @@ public void onPageCommitVisible(WebView view, String url) {
@Override
protected void handleOnConfigurationChanged(Configuration newConfig) {
super.handleOnConfigurationChanged(newConfig);

setStyle(currentStyle, "");
}

Expand Down Expand Up @@ -250,6 +254,8 @@ private void setStyle(String style, String bar) {
if (bar.isEmpty() || bar.equals(BAR_GESTURE_BAR)) {
windowInsetsControllerCompat.setAppearanceLightNavigationBars(!style.equals(STYLE_DARK));
}

getActivity().getWindow().getDecorView().setBackgroundColor(getThemeColor(getContext(), android.R.attr.windowBackground));
}

private void setHidden(boolean hide, String bar) {
Expand Down Expand Up @@ -282,6 +288,14 @@ private String getStyleForTheme() {
return STYLE_DARK;
}

public int getThemeColor(Context context, int attrRes) {
TypedValue typedValue = new TypedValue();

Resources.Theme theme = context.getTheme();
theme.resolveAttribute(attrRes, typedValue, true);
return typedValue.data;
}

private Integer getWebViewMajorVersion() {
PackageInfo info = WebViewCompat.getCurrentWebViewPackage(getContext());
if (info != null && info.versionName != null) {
Expand Down