feat(移动端优化): 实现安卓原生应用的全屏布局和安全区域处理
添加安全区域插件和样式处理,优化移动端视图布局 重构路由和导航结构,改进底部导航栏 增强原生功能集成,包括状态栏和导航栏控制 优化位置服务和后台任务处理 更新语言包和样式以适应移动端体验
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main"
|
||||
android:theme="@style/AppTheme.NoActionBarLaunch"
|
||||
android:theme="@style/AppTheme.NoActionBar"
|
||||
android:launchMode="singleTask"
|
||||
android:exported="true">
|
||||
|
||||
@@ -77,6 +77,8 @@
|
||||
|
||||
<!-- Battery optimization permissions -->
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
|
||||
<!-- Boot receiver for auto-start -->
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
@@ -1,5 +1,50 @@
|
||||
package com.ouji.factory.myapp;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsControllerCompat;
|
||||
import com.getcapacitor.BridgeActivity;
|
||||
|
||||
public class MainActivity extends BridgeActivity {}
|
||||
public class MainActivity extends BridgeActivity {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// Configure window for proper native behavior
|
||||
setupNativeWindow();
|
||||
}
|
||||
|
||||
private void setupNativeWindow() {
|
||||
// Enable edge-to-edge display
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
|
||||
// Configure status bar
|
||||
WindowInsetsControllerCompat windowInsetsController =
|
||||
WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
|
||||
|
||||
if (windowInsetsController != null) {
|
||||
// Set status bar to light mode (dark icons)
|
||||
windowInsetsController.setAppearanceLightStatusBars(true);
|
||||
// Set navigation bar to light mode (dark icons)
|
||||
windowInsetsController.setAppearanceLightNavigationBars(true);
|
||||
}
|
||||
|
||||
// Set status bar color
|
||||
getWindow().setStatusBarColor(android.graphics.Color.parseColor("#ffffff"));
|
||||
// Set navigation bar color
|
||||
getWindow().setNavigationBarColor(android.graphics.Color.parseColor("#ffffff"));
|
||||
|
||||
// Prevent screenshots and screen recording for security
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
|
||||
WindowManager.LayoutParams.FLAG_SECURE);
|
||||
|
||||
// Keep screen on during app usage
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
// Disable pull-to-refresh overscroll effect
|
||||
getWindow().getDecorView().setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:background">@null</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user