forked from trent_larson/crowd-funder-for-time-pwa
- Add @capacitor/status-bar dependency for safe area detection
- Implement SafeAreaPlugin for Android with proper inset calculation
- Create safeAreaInset.js utility for CSS custom property injection
- Update Android manifest and build configuration for plugin
- Integrate safe area handling across Vue components and views
- Update iOS Podfile and Android gradle configurations
- Add commitlint and husky for commit message validation
Technical changes:
- SafeAreaPlugin uses WindowInsets API for Android R+ devices
- Fallback detection for navigation bar and gesture bar heights
- CSS custom properties: --safe-area-inset-{top,bottom,left,right}
- Platform-specific detection (Android WebView only)
- StatusBar plugin integration for top inset calculation
56 lines
2.1 KiB
Java
56 lines
2.1 KiB
Java
package app.timesafari;
|
|
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.WindowManager;
|
|
import android.view.WindowInsetsController;
|
|
import android.view.WindowInsets;
|
|
import android.os.Build;
|
|
import android.webkit.WebView;
|
|
import android.webkit.WebSettings;
|
|
import android.webkit.WebViewClient;
|
|
import com.getcapacitor.BridgeActivity;
|
|
import app.timesafari.safearea.SafeAreaPlugin;
|
|
//import com.getcapacitor.community.sqlite.SQLite;
|
|
|
|
public class MainActivity extends BridgeActivity {
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
|
|
// Enable edge-to-edge display for modern Android
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
// Android 11+ (API 30+)
|
|
getWindow().setDecorFitsSystemWindows(false);
|
|
|
|
// Set up system UI visibility for edge-to-edge
|
|
WindowInsetsController controller = getWindow().getInsetsController();
|
|
if (controller != null) {
|
|
controller.setSystemBarsAppearance(
|
|
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS |
|
|
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS,
|
|
WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS |
|
|
WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS
|
|
);
|
|
controller.setSystemBarsBehavior(WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
|
}
|
|
} else {
|
|
// Legacy Android (API 21-29)
|
|
getWindow().getDecorView().setSystemUiVisibility(
|
|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
|
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
|
View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR |
|
|
View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
|
);
|
|
}
|
|
|
|
// Register SafeArea plugin
|
|
registerPlugin(SafeAreaPlugin.class);
|
|
|
|
// Initialize SQLite
|
|
//registerPlugin(SQLite.class);
|
|
}
|
|
|
|
|
|
} |