package com.gnexus.shserv;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import com.getcapacitor.BridgeActivity;
public class MainActivity extends BridgeActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// Override Capacitor's hard-coded theme before super.onCreate()
setTheme(R.style.AppTheme_NoActionBar);
super.onCreate(savedInstanceState);
// Prevent edge-to-edge: content must NOT draw behind status bar
Window window = getWindow();
WindowCompat.setDecorFitsSystemWindows(window, true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
// Capacitor SystemBars plugin installs an OnApplyWindowInsetsListener
// that intercepts system bars insets and returns them as 0. This breaks
// fitsSystemWindows. We reset it and force the CoordinatorLayout
// (WebView parent) to handle insets natively.
View webView = findViewById(com.getcapacitor.android.R.id.webview);
if (webView != null) {
ViewGroup parent = (ViewGroup) webView.getParent();
if (parent != null) {
ViewCompat.setOnApplyWindowInsetsListener(parent, null);
parent.setFitsSystemWindows(true);
}
}
}
}