Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# CodePocket 更新日志

## [0.1.1] — 2026-11-25

移动端布局收口版本。不改 Python 引擎和 Git 地基,只把手机、横屏、平板和字体放大下的摆放做明确,避免继续靠“看起来差不多”。

### 响应式布局

- 新增 `EditorLayoutPolicy`:600dp 以上或 520dp 以上的矮横屏切为左右两栏;普通手机竖屏仍上下排布,给代码留高度。
- 顶栏在宽度小于 480dp 或字体缩放达到 1.3 倍时进入紧凑模式:只保留菜单、保存、运行/停止;预览、命令面板、调试收进“更多”下拉菜单,44dp 触控目标不再互相挤压。
- 抽屉宽度按屏幕宽度计算(200–272dp),窄屏不再让侧栏吃掉主界面。
- 快捷动作从固定四列改为窄屏/大字号三列,避免“项目/导入/设置”等两字标签被压成省略号。
- 宽屏顶栏才显示语言名和“仅编辑”,小屏只留文件名;文件名仍单行省略。

### 测试

- `EditorLayoutPolicyTest` 覆盖两栏阈值、紧凑顶栏阈值、抽屉宽度和动作列数。
- `EditorTopBarTest` 用 Compose/Robolectric 验证紧凑顶栏把预览收进“更多”、宽屏顶栏保留预览入口。
- 全量 JVM/Robolectric:179 tests / 0 failures / 0 errors / 0 skipped。

### 边界

- 本版仍无 ARM64 真机验收;Robolectric 只能证明节点存在和交互路径,不等于 ROM 上的最终手感。
- 不做 Gradle/Java/Kotlin 工程构建、完整 LSP、原生 wheel ABI,边界与 0.1.0 相同。

## [0.1.0] — 2026-11-25

跨小数位的“可信移动 IDE”版本。重点不是再加面板,而是把 Python 引擎、Git 审阅、包安装和质量门禁补成能长期使用的地基。
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ Three runtimes are bundled inside the APK: a natively cross-compiled CPython 3.1
- **Python pdb debugger**: real stdlib `pdb`; breakpoints, next/step/continue, `p locals()`, stack, quit; quick-action bar in output panel
- **Offline by design**: no language server process, no model download, hard caps at 300 `.py` files / 512KB per file

### Mobile layout pass (0.1.1)
- **Compact toolbar**: below 480dp or at 1.3× font scale, the top bar keeps only menu, save and run/stop; preview, command palette and debug move into a **更多** menu so 44dp touch targets stop squeezing the filename
- **Width-based two-pane**: 600dp tablets and short landscape phones (≥520dp wide) place output beside the editor; normal portrait phones keep the vertical stack so code height is not sacrificed
- **Adaptive drawer**: sidebar width is clamped to 200–272dp by screen width; quick actions switch from four to three columns on narrow screens or large fonts
- **Tests**: `EditorLayoutPolicyTest` for breakpoints, `EditorTopBarTest` for compact/wide Compose behavior; 179 JVM/Robolectric tests all green

### Trusted mobile IDE foundation (0.1.0)
- **Python engine isolation**: Python runs in `android:process=":engine"`; the main process holds only a Messenger proxy. The output panel's **重启引擎** action kills and rebinds only the engine process, preserving unsaved editor buffers, Git and terminal state
- **Git review loop**: per-file stage / unstage, stage-all, commit-staged-only, and a diff dialog (working tree vs index, untracked files as all-added); 200KB output cap with bounded streaming so a 100MB log does not OOM
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId = "com.devterminal"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
versionCode = 40
versionName = "0.1.0"
versionCode = 41
versionName = "0.1.1"
vectorDrawables { useSupportLibrary = true }
// 原生 CPython 引擎:同时打 arm64 与 x86_64(后者用于模拟器/ChromeOS)
ndk { abiFilters += listOf("arm64-v8a", "x86_64") }
Expand Down
41 changes: 41 additions & 0 deletions app/src/main/java/com/devterminal/ui/EditorLayoutPolicy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.devterminal.ui

/**
* 主界面的宽度/字号断点。
*
* 这些数字只负责「布局决策」,不参与绘制,因此可以单测。
* 取舍:
* - 600dp 是 Material 的 medium 起点;到了它,编辑器与输出面板并排才不会把代码压成一条。
* - 480dp 是普通手机与小平板的分界;低于它,顶栏必须收掉次要动作。
* - 1.3 倍字体是 200% 字体设置前的预警线;再放大时,图标和标题会先互相挤。
*/
object EditorLayoutPolicy {
const val TWO_PANE_MIN_WIDTH_DP = 600
const val COMPACT_TOOLBAR_MAX_WIDTH_DP = 480
const val COMPACT_TOOLBAR_MIN_FONT_SCALE = 1.3f
const val DRAWER_MAX_WIDTH_DP = 272
const val DRAWER_MIN_WIDTH_DP = 200
private const val DRAWER_WIDTH_FRACTION = 0.86f

/**
* 宽屏/平板用左右两栏;普通手机竖屏仍保持上下结构,给代码留高度。
* 520dp 以上的横屏手机即使没到 600dp,也横向摆放:这时高度通常只有 320dp,
* 上下叠放会把编辑器压没。
*/
fun useTwoPane(widthDp: Float, heightDp: Float): Boolean =
widthDp >= TWO_PANE_MIN_WIDTH_DP || (widthDp > heightDp && widthDp >= 520f)

/** 小屏或大字号时,顶栏只保留主操作,其余进入「更多」。 */
fun useCompactToolbar(widthDp: Int, fontScale: Float): Boolean =
widthDp < COMPACT_TOOLBAR_MAX_WIDTH_DP || fontScale >= COMPACT_TOOLBAR_MIN_FONT_SCALE

/** 抽屉最宽 272dp,但窄屏上必须给主界面留出至少 14% 的可见区域。 */
fun drawerWidthDp(widthDp: Int): Int {
val fraction = (widthDp * DRAWER_WIDTH_FRACTION).toInt()
return maxOf(DRAWER_MIN_WIDTH_DP, minOf(DRAWER_MAX_WIDTH_DP, fraction))
}

/** 快捷动作在窄屏/大字号下改成三列,避免四列文字被压成省略号。 */
fun drawerColumns(widthDp: Int, fontScale: Float): Int =
if (widthDp < 480 || fontScale >= 1.5f) 3 else 4
}
Loading
Loading