|
|
|
|
📦 com.mjn.puzzle
├── 📂 data # Data Layer
│ ├── 📂 local # Room Database
│ ├── 📂 model # Data Models
│ └── 📂 repository # Repositories
├── 📂 engine # Core Engine
│ ├── 🔧 GridLayoutEngine # Grid Layout Engine
│ └── 🔧 OccupancyMatrix # Occupancy Matrix Algorithm
└── 📂 ui # UI Layer
├── 📂 home # Home Screen
├── 📂 editor # Template Editor
├── 📂 puzzle # Puzzle Preview
│ ├── 📂 components # UI Components
│ ├── 📂 gesture # Gesture Handlers
│ └── 📂 renderer # Renderers
└── 📂 theme # Material3 Theme
| Technology | Description |
|---|---|
| Kotlin | 100% Kotlin |
| Jetpack Compose | Modern declarative UI |
| Material Design 3 | Latest Material You |
| Room Database | Local data persistence |
| Coil | Image loading |
| Navigation Compose | Navigation framework |
| ViewModel | MVVM architecture |
| Coroutines + Flow | Async programming |
- Android Studio Hedgehog (2023.1.1) or higher
- JDK 11+
- Android SDK 35
- Gradle 8.0+
1️⃣ Clone the repository
git clone https://github.com/yourusername/puzzle.git
cd puzzle2️⃣ Open the project
studio .3️⃣ Build
./gradlew build4️⃣ Run
./gradlew installDebug1. 🏠 Select or create a template on home screen
2. ✏️ Split/merge cells in the editor
3. 📷 Pick photos in puzzle screen
4. 🎨 Adjust border & corner styles
5. 💾 Export HD collage to gallery
| Gesture | Function |
|---|---|
| 👆 Tap | Select cell |
| 👆👆 Long press + drag | Swap photos |
| 🤏 Pinch | Zoom photo |
| ✋ Two-finger rotate | Rotate photo |
| 👋 Two-finger pan | Move photo |
The project uses an innovative occupancy matrix algorithm for layout management:
// Each matrix cell records the owning Cell ID
// Supports arbitrary cell merging & splitting
class OccupancyMatrix {
fun splitHorizontally(cellId: String)
fun splitVertically(cellId: String)
fun mergeCells(id1: String, id2: String)
}Advantages:
- ✅ Supports any rectangular cell combination
- ✅ Auto-handles merge boundaries
- ✅ O(n) space complexity
- ✅ Unlimited split depth
This project is licensed under the MIT License.
|
|
|
|
📦 com.mjn.puzzle
├── 📂 data # 数据层
│ ├── 📂 local # Room 数据库
│ ├── 📂 model # 数据模型
│ └── 📂 repository # 数据仓库
├── 📂 engine # 核心引擎
│ ├── 🔧 GridLayoutEngine # 网格布局引擎
│ └── 🔧 OccupancyMatrix # 占用矩阵算法
└── 📂 ui # UI 层
├── 📂 home # 主页
├── 📂 editor # 模板编辑器
├── 📂 puzzle # 拼图预览
│ ├── 📂 components # UI 组件
│ ├── 📂 gesture # 手势处理
│ └── 📂 renderer # 渲染器
└── 📂 theme # Material3 主题
| 技术 | 说明 |
|---|---|
| Kotlin | 100% Kotlin 编写 |
| Jetpack Compose | 现代声明式 UI 框架 |
| Material Design 3 | 最新 Material You 设计语言 |
| Room Database | 本地数据持久化 |
| Coil | 高性能图片加载库 |
| Navigation Compose | Compose 导航框架 |
| ViewModel | MVVM 架构组件 |
| Coroutines + Flow | 异步编程 |
- Android Studio Hedgehog (2023.1.1) 或更高版本
- JDK 11+
- Android SDK 35
- Gradle 8.0+
1️⃣ 克隆项目
git clone https://github.com/yourusername/puzzle.git
cd puzzle2️⃣ 打开项目
studio .3️⃣ 同步 & 构建
./gradlew build4️⃣ 运行应用
./gradlew installDebug1. 🏠 在主页选择或创建模板
2. ✏️ 在编辑器中分割/合并格子
3. 📷 进入拼图界面选择照片
4. 🎨 调整边框、圆角样式
5. 💾 导出高清拼图到相册
| 手势 | 功能 |
|---|---|
| 👆 单击 | 选中格子 |
| 👆👆 长按拖动 | 交换照片位置 |
| 🤏 双指缩放 | 缩放照片 |
| ✋ 双指旋转 | 旋转照片 |
| 👋 双指平移 | 移动照片位置 |
项目采用独创的占用矩阵算法来管理格子布局:
// 每个矩阵单元记录所属的 Cell ID
// 支持任意形状的格子合并与分割
class OccupancyMatrix {
fun splitHorizontally(cellId: String) // 横向分割
fun splitVertically(cellId: String) // 纵向分割
fun mergeCells(id1: String, id2: String) // 合并格子
}优势:
- ✅ 支持任意矩形格子组合
- ✅ 自动处理合并边界
- ✅ 高效的空间复杂度 O(n)
- ✅ 支持无限层级分割
- 🎉 首次发布
- ✨ 模板创建与编辑
- 📷 照片导入与编辑
- 💾 高清导出功能
欢迎贡献代码!请遵循以下步骤:
- Fork 本仓库
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 提交 Pull Request
本项目基于 MIT License 开源。
- Jetpack Compose - 现代 Android UI 工具包
- Material Design 3 - 设计规范



