feat: container packing simulator + Android shell

- web/packing: scan-sweep planner (bottom-up X/Y sweep, all items per cell),
  multi-direction candidates, gap fill, stack/capacity/rigid-body checks,
  theoretical fill bound with red warning, occupancy voxel metrics
- per-item params via right-click menu (upright, stack count, capacity,
  box/voxel fit, mass); simplified left panel
- 3D: pan/zoom/rotate mouse mapping, touch gestures, draggable XYZ compass
- android: offline WebView APK build pipeline (aapt2/javac/d8/apksigner)
- docs: packing preview and mobile screenshots
This commit is contained in:
OpenCode
2026-11-26 15:26:16 +08:00
parent 31301824c4
commit 20567c0781
34 changed files with 3599 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 页面完全离线:three.js / data.js 都在 assets 里,因此不需要 INTERNET 权限 -->
<application
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboardHidden|uiMode|density"
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,129 @@
package com.occupancyfit.app;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
/**
* 单 Activity 的 WebView 外壳:加载 assets 里的 web/index.html(离线三维体素拟合页面)。
*/
public class MainActivity extends Activity {
private static final String APP_BG = "#0A0E17";
private static final String START_URL = "file:///android_asset/index.html";
private WebView webView;
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int bg = Color.parseColor(APP_BG);
getWindow().setStatusBarColor(bg);
getWindow().setNavigationBarColor(bg);
getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(bg));
webView = new WebView(this);
webView.setBackgroundColor(bg);
webView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAllowFileAccess(true);
settings.setAllowContentAccess(false);
settings.setSupportZoom(false);
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
settings.setUseWideViewPort(false);
settings.setLoadWithOverviewMode(false);
settings.setTextZoom(100);
settings.setMediaPlaybackRequiresUserGesture(false);
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
return openExternally(request.getUrl());
}
@Override
public void onPageFinished(WebView view, String url) {
view.setBackgroundColor(Color.TRANSPARENT);
}
});
// 让 WebGL 优先跑在硬件上,并允许 canvas 全屏(页面里没有,但留着不会出问题)
webView.setWebChromeClient(new WebChromeClient());
setContentView(webView);
webView.loadUrl(START_URL);
}
/** file:// 留在 WebView 内,其余 scheme 交给系统浏览器。 */
private boolean openExternally(Uri uri) {
String scheme = uri.getScheme();
if (scheme == null || "file".equals(scheme) || "about".equals(scheme)
|| "data".equals(scheme) || "blob".equals(scheme) || "javascript".equals(scheme)) {
return false;
}
try {
startActivity(new Intent(Intent.ACTION_VIEW, uri));
} catch (Exception ignored) {
// 没有浏览器可处理时静默忽略,保持在当前页面
}
return true;
}
@Override
protected void onResume() {
super.onResume();
if (webView != null) {
webView.onResume();
webView.resumeTimers();
}
}
@Override
protected void onPause() {
if (webView != null) {
webView.onPause();
webView.pauseTimers();
}
super.onPause();
}
@Override
public void onBackPressed() {
if (webView != null && webView.canGoBack()) {
webView.goBack();
return;
}
super.onBackPressed();
}
@Override
protected void onDestroy() {
if (webView != null) {
ViewGroup parent = (ViewGroup) webView.getParent();
if (parent != null) {
parent.removeView(webView);
}
webView.destroy();
webView = null;
}
super.onDestroy();
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#0B1018</color>
</resources>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">占用拟合</string>
<color name="app_bg">#0A0E17</color>
</resources>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:windowBackground">@color/app_bg</item>
<item name="android:colorBackground">@color/app_bg</item>
<item name="android:statusBarColor">@color/app_bg</item>
<item name="android:navigationBarColor">@color/app_bg</item>
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
</style>
</resources>