mirror of
https://github.com/Dasemu/web-imposter-game.git
synced 2026-11-26 07:16:24 +00:00
feat: enable edge-to-edge mode and make status bar transparent in MainActivity
This commit is contained in:
1 parent
f583109aab
commit
d9e8389777
1 file changed
+22
-2
@@ -1,15 +1,35 @@
|
||||
package es.dariosevilla.impostor;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Disable edge-to-edge to prevent status bar overlap
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||
|
||||
Window window = getWindow();
|
||||
|
||||
// Enable edge-to-edge mode so CSS safe-area-inset-* values work correctly
|
||||
WindowCompat.setDecorFitsSystemWindows(window, false);
|
||||
|
||||
// Make status bar transparent so content can draw underneath
|
||||
window.setStatusBarColor(Color.TRANSPARENT);
|
||||
window.setNavigationBarColor(Color.TRANSPARENT);
|
||||
|
||||
// Set status bar icons to light (for dark backgrounds) or dark (for light backgrounds)
|
||||
WindowInsetsControllerCompat insetsController = WindowCompat.getInsetsController(window, window.getDecorView());
|
||||
if (insetsController != null) {
|
||||
// Use dark icons (false = dark icons for light status bar background)
|
||||
// The CSS handles the actual content offset via safe-area-inset-top
|
||||
insetsController.setAppearanceLightStatusBars(false);
|
||||
insetsController.setAppearanceLightNavigationBars(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user