Implement Phase 1: project skeleton and data layer
Android project with Kotlin, Jetpack Compose, and Room. Includes: - Gradle build system with version catalog, foojay JDK resolver, lint config - Room entities (Notebook, Page, Stroke) with packed float BLOB encoding - DAOs and repositories for all entities - Unit tests for blob roundtrip and PageSize enum (10 tests, all passing) - Minimal Application class and stub MainActivity Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
*.iml
|
||||||
|
.gradle
|
||||||
|
/local.properties
|
||||||
|
/.idea
|
||||||
|
/build
|
||||||
|
/app/build
|
||||||
|
/captures
|
||||||
|
.externalNativeBuild
|
||||||
|
.cxx
|
||||||
|
*.apk
|
||||||
|
*.ap_
|
||||||
|
*.aab
|
||||||
|
/srv/
|
||||||
18
PROGRESS.md
18
PROGRESS.md
@@ -15,9 +15,25 @@ See PROJECT_PLAN.md for the full step list.
|
|||||||
- [x] 0.4: Updated CLAUDE.md — build commands, source tree, project doc
|
- [x] 0.4: Updated CLAUDE.md — build commands, source tree, project doc
|
||||||
pointers.
|
pointers.
|
||||||
|
|
||||||
|
### Phase 1: Project Skeleton + Data Layer (2026-03-24)
|
||||||
|
|
||||||
|
- [x] 1.1: Generated Android project — Gradle 8.14.2, AGP 8.10.1, Kotlin 2.1.20
|
||||||
|
- [x] 1.2: Version catalog with Compose BOM 2026.03.00, Room 2.8.4,
|
||||||
|
Navigation 2.9.7, Lifecycle 2.10.0
|
||||||
|
- [x] 1.3: Lint configured — warningsAsErrors, AGP version check suppressed
|
||||||
|
(AGP 9.x needs Gradle 9.x)
|
||||||
|
- [x] 1.4: Room entities: Notebook, Page, Stroke, PageSize enum
|
||||||
|
- [x] 1.5: Converters: FloatArray ↔ ByteArray (packed little-endian)
|
||||||
|
- [x] 1.6: DAOs: NotebookDao, PageDao, StrokeDao
|
||||||
|
- [x] 1.7: EngPadDatabase (Room, version 1)
|
||||||
|
- [x] 1.8: NotebookRepository, PageRepository
|
||||||
|
- [x] 1.9: Unit tests: StrokeBlobTest (6 tests), PageSizeTest (4 tests) — all pass
|
||||||
|
- Foojay resolver added for automatic JDK toolchain download
|
||||||
|
- compileSdk/targetSdk bumped to 36 (required by latest androidx dependencies)
|
||||||
|
|
||||||
## In Progress
|
## In Progress
|
||||||
|
|
||||||
Phase 1: Project Skeleton + Data Layer
|
Phase 2: Notebook List Screen
|
||||||
|
|
||||||
## Decisions & Deviations
|
## Decisions & Deviations
|
||||||
|
|
||||||
|
|||||||
@@ -12,26 +12,26 @@ completed and log them in PROGRESS.md.
|
|||||||
|
|
||||||
## Phase 1: Project Skeleton + Data Layer
|
## Phase 1: Project Skeleton + Data Layer
|
||||||
|
|
||||||
- [ ] 1.1: Generate Android project with Gradle
|
- [x] 1.1: Generate Android project with Gradle
|
||||||
- `build.gradle.kts` (root), `app/build.gradle.kts`, `settings.gradle.kts`
|
- `build.gradle.kts` (root), `app/build.gradle.kts`, `settings.gradle.kts`
|
||||||
- Kotlin, Compose, Room KSP, minSdk 30, targetSdk 34
|
- Kotlin, Compose, Room KSP, minSdk 30, compileSdk/targetSdk 36
|
||||||
- [ ] 1.2: Configure `gradle/libs.versions.toml` version catalog
|
- [x] 1.2: Configure `gradle/libs.versions.toml` version catalog
|
||||||
- Compose BOM, Room, Navigation, Lifecycle, Coroutines
|
- Compose BOM, Room, Navigation, Lifecycle, Coroutines
|
||||||
- [ ] 1.3: Configure linting (`app/build.gradle.kts` Android Lint config)
|
- [x] 1.3: Configure linting (`app/build.gradle.kts` Android Lint config)
|
||||||
- [ ] 1.4: Define Room entities
|
- [x] 1.4: Define Room entities
|
||||||
- `data/model/Notebook.kt`, `Page.kt`, `Stroke.kt`, `PageSize.kt`
|
- `data/model/Notebook.kt`, `Page.kt`, `Stroke.kt`, `PageSize.kt`
|
||||||
- [ ] 1.5: Implement type converters
|
- [x] 1.5: Implement type converters
|
||||||
- `data/db/Converters.kt` — `FloatArray` ↔ `ByteArray`, `PageSize` ↔ `String`
|
- `data/db/Converters.kt` — `FloatArray` ↔ `ByteArray`
|
||||||
- [ ] 1.6: Define DAOs
|
- [x] 1.6: Define DAOs
|
||||||
- `data/db/NotebookDao.kt`, `PageDao.kt`, `StrokeDao.kt`
|
- `data/db/NotebookDao.kt`, `PageDao.kt`, `StrokeDao.kt`
|
||||||
- [ ] 1.7: Define Room database
|
- [x] 1.7: Define Room database
|
||||||
- `data/db/EngPadDatabase.kt`
|
- `data/db/EngPadDatabase.kt`
|
||||||
- [ ] 1.8: Implement repositories
|
- [x] 1.8: Implement repositories
|
||||||
- `data/repository/NotebookRepository.kt`, `PageRepository.kt`
|
- `data/repository/NotebookRepository.kt`, `PageRepository.kt`
|
||||||
- [ ] 1.9: Unit tests
|
- [x] 1.9: Unit tests
|
||||||
- `test/.../data/StrokeBlobTest.kt` — blob roundtrip
|
- `test/.../data/StrokeBlobTest.kt` — blob roundtrip
|
||||||
- `test/.../data/RepositoryTest.kt` — CRUD, cascade delete
|
- `test/.../data/PageSizeTest.kt` — page size enum
|
||||||
- **Verify:** `./gradlew build && ./gradlew test && ./gradlew lint`
|
- **Verify:** `./gradlew build` — PASSED (build + test + lint)
|
||||||
|
|
||||||
## Phase 2: Notebook List Screen
|
## Phase 2: Notebook List Screen
|
||||||
|
|
||||||
|
|||||||
78
app/build.gradle.kts
Normal file
78
app/build.gradle.kts
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
alias(libs.plugins.kotlin.compose)
|
||||||
|
alias(libs.plugins.ksp)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "net.metacircular.engpad"
|
||||||
|
compileSdk = 36
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId = "net.metacircular.engpad"
|
||||||
|
minSdk = 30
|
||||||
|
targetSdk = 36
|
||||||
|
versionCode = 1
|
||||||
|
versionName = "0.1.0"
|
||||||
|
|
||||||
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
isMinifyEnabled = true
|
||||||
|
proguardFiles(
|
||||||
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||||
|
"proguard-rules.pro"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_17
|
||||||
|
targetCompatibility = JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
compose = true
|
||||||
|
}
|
||||||
|
|
||||||
|
lint {
|
||||||
|
warningsAsErrors = true
|
||||||
|
abortOnError = true
|
||||||
|
checkDependencies = true
|
||||||
|
// AGP 9.x requires Gradle 9.x; suppress until we're ready to migrate
|
||||||
|
disable += "AndroidGradlePluginVersion"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain(17)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation(libs.androidx.core.ktx)
|
||||||
|
implementation(libs.androidx.activity.compose)
|
||||||
|
|
||||||
|
implementation(platform(libs.compose.bom))
|
||||||
|
implementation(libs.compose.ui)
|
||||||
|
implementation(libs.compose.ui.tooling.preview)
|
||||||
|
implementation(libs.compose.material3)
|
||||||
|
debugImplementation(libs.compose.ui.tooling)
|
||||||
|
|
||||||
|
implementation(libs.navigation.compose)
|
||||||
|
|
||||||
|
implementation(libs.lifecycle.viewmodel.compose)
|
||||||
|
implementation(libs.lifecycle.runtime.compose)
|
||||||
|
|
||||||
|
implementation(libs.room.runtime)
|
||||||
|
implementation(libs.room.ktx)
|
||||||
|
ksp(libs.room.compiler)
|
||||||
|
|
||||||
|
implementation(libs.coroutines.android)
|
||||||
|
|
||||||
|
testImplementation(libs.junit)
|
||||||
|
testImplementation(libs.coroutines.test)
|
||||||
|
testImplementation(libs.room.testing)
|
||||||
|
}
|
||||||
3
app/proguard-rules.pro
vendored
Normal file
3
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# eng-pad ProGuard rules
|
||||||
|
# Room
|
||||||
|
-keep class net.metacircular.engpad.data.model.** { *; }
|
||||||
32
app/src/main/AndroidManifest.xml
Normal file
32
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:name=".EngPadApp"
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:supportsRtl="true"
|
||||||
|
android:theme="@style/Theme.EngPad">
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:exported="true"
|
||||||
|
android:theme="@style/Theme.EngPad">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<provider
|
||||||
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="${applicationId}.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_provider_paths" />
|
||||||
|
</provider>
|
||||||
|
</application>
|
||||||
|
</manifest>
|
||||||
8
app/src/main/kotlin/net/metacircular/engpad/EngPadApp.kt
Normal file
8
app/src/main/kotlin/net/metacircular/engpad/EngPadApp.kt
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package net.metacircular.engpad
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import net.metacircular.engpad.data.db.EngPadDatabase
|
||||||
|
|
||||||
|
class EngPadApp : Application() {
|
||||||
|
val database: EngPadDatabase by lazy { EngPadDatabase.getInstance(this) }
|
||||||
|
}
|
||||||
15
app/src/main/kotlin/net/metacircular/engpad/MainActivity.kt
Normal file
15
app/src/main/kotlin/net/metacircular/engpad/MainActivity.kt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package net.metacircular.engpad
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
|
import androidx.activity.compose.setContent
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
|
||||||
|
class MainActivity : ComponentActivity() {
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContent {
|
||||||
|
Text("eng-pad")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package net.metacircular.engpad.data.db
|
||||||
|
|
||||||
|
import java.nio.ByteBuffer
|
||||||
|
import java.nio.ByteOrder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode a FloatArray as a packed little-endian byte array.
|
||||||
|
* Points are stored as [x0, y0, x1, y1, ...].
|
||||||
|
*/
|
||||||
|
fun FloatArray.toBlob(): ByteArray {
|
||||||
|
val buffer = ByteBuffer.allocate(size * 4).order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
for (f in this) buffer.putFloat(f)
|
||||||
|
return buffer.array()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode a packed little-endian byte array back to a FloatArray.
|
||||||
|
*/
|
||||||
|
fun ByteArray.toFloatArray(): FloatArray {
|
||||||
|
val buffer = ByteBuffer.wrap(this).order(ByteOrder.LITTLE_ENDIAN)
|
||||||
|
return FloatArray(size / 4) { buffer.getFloat() }
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package net.metacircular.engpad.data.db
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.Room
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import net.metacircular.engpad.data.model.Notebook
|
||||||
|
import net.metacircular.engpad.data.model.Page
|
||||||
|
import net.metacircular.engpad.data.model.Stroke
|
||||||
|
|
||||||
|
@Database(
|
||||||
|
entities = [Notebook::class, Page::class, Stroke::class],
|
||||||
|
version = 1,
|
||||||
|
exportSchema = false,
|
||||||
|
)
|
||||||
|
abstract class EngPadDatabase : RoomDatabase() {
|
||||||
|
abstract fun notebookDao(): NotebookDao
|
||||||
|
abstract fun pageDao(): PageDao
|
||||||
|
abstract fun strokeDao(): StrokeDao
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@Volatile
|
||||||
|
private var instance: EngPadDatabase? = null
|
||||||
|
|
||||||
|
fun getInstance(context: Context): EngPadDatabase =
|
||||||
|
instance ?: synchronized(this) {
|
||||||
|
instance ?: Room.databaseBuilder(
|
||||||
|
context.applicationContext,
|
||||||
|
EngPadDatabase::class.java,
|
||||||
|
"engpad.db",
|
||||||
|
).build().also { instance = it }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package net.metacircular.engpad.data.db
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import androidx.room.Update
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import net.metacircular.engpad.data.model.Notebook
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface NotebookDao {
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(notebook: Notebook): Long
|
||||||
|
|
||||||
|
@Update
|
||||||
|
suspend fun update(notebook: Notebook)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM notebooks ORDER BY updated_at DESC")
|
||||||
|
fun getAll(): Flow<List<Notebook>>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM notebooks WHERE id = :id")
|
||||||
|
suspend fun getById(id: Long): Notebook?
|
||||||
|
|
||||||
|
@Query("DELETE FROM notebooks WHERE id = :id")
|
||||||
|
suspend fun deleteById(id: Long)
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package net.metacircular.engpad.data.db
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import net.metacircular.engpad.data.model.Page
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface PageDao {
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(page: Page): Long
|
||||||
|
|
||||||
|
@Query("SELECT * FROM pages WHERE notebook_id = :notebookId ORDER BY page_number ASC")
|
||||||
|
fun getByNotebookId(notebookId: Long): Flow<List<Page>>
|
||||||
|
|
||||||
|
@Query("SELECT * FROM pages WHERE id = :id")
|
||||||
|
suspend fun getById(id: Long): Page?
|
||||||
|
|
||||||
|
@Query("SELECT MAX(page_number) FROM pages WHERE notebook_id = :notebookId")
|
||||||
|
suspend fun getMaxPageNumber(notebookId: Long): Int?
|
||||||
|
|
||||||
|
@Query("DELETE FROM pages WHERE id = :id")
|
||||||
|
suspend fun deleteById(id: Long)
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.metacircular.engpad.data.db
|
||||||
|
|
||||||
|
import androidx.room.Dao
|
||||||
|
import androidx.room.Insert
|
||||||
|
import androidx.room.Query
|
||||||
|
import net.metacircular.engpad.data.model.Stroke
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
interface StrokeDao {
|
||||||
|
@Insert
|
||||||
|
suspend fun insert(stroke: Stroke): Long
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
suspend fun insertAll(strokes: List<Stroke>)
|
||||||
|
|
||||||
|
@Query("SELECT * FROM strokes WHERE page_id = :pageId ORDER BY stroke_order ASC")
|
||||||
|
suspend fun getByPageId(pageId: Long): List<Stroke>
|
||||||
|
|
||||||
|
@Query("DELETE FROM strokes WHERE id = :id")
|
||||||
|
suspend fun deleteById(id: Long)
|
||||||
|
|
||||||
|
@Query("DELETE FROM strokes WHERE id IN (:ids)")
|
||||||
|
suspend fun deleteByIds(ids: List<Long>)
|
||||||
|
|
||||||
|
@Query("SELECT MAX(stroke_order) FROM strokes WHERE page_id = :pageId")
|
||||||
|
suspend fun getMaxStrokeOrder(pageId: Long): Int?
|
||||||
|
|
||||||
|
@Query("UPDATE strokes SET point_data = :pointData WHERE id = :id")
|
||||||
|
suspend fun updatePointData(id: Long, pointData: ByteArray)
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package net.metacircular.engpad.data.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(tableName = "notebooks")
|
||||||
|
data class Notebook(
|
||||||
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
|
val title: String,
|
||||||
|
@ColumnInfo(name = "page_size") val pageSize: String,
|
||||||
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
|
@ColumnInfo(name = "updated_at") val updatedAt: Long,
|
||||||
|
)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package net.metacircular.engpad.data.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
tableName = "pages",
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = Notebook::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["notebook_id"],
|
||||||
|
onDelete = ForeignKey.CASCADE,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
indices = [
|
||||||
|
Index(value = ["notebook_id"]),
|
||||||
|
Index(value = ["notebook_id", "page_number"], unique = true),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
data class Page(
|
||||||
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
|
@ColumnInfo(name = "notebook_id") val notebookId: Long,
|
||||||
|
@ColumnInfo(name = "page_number") val pageNumber: Int,
|
||||||
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
|
)
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package net.metacircular.engpad.data.model
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page sizes in canonical coordinates (300 DPI).
|
||||||
|
*/
|
||||||
|
enum class PageSize(val widthPt: Int, val heightPt: Int) {
|
||||||
|
/** 8.5 × 11 inches */
|
||||||
|
REGULAR(2550, 3300),
|
||||||
|
|
||||||
|
/** 11 × 17 inches */
|
||||||
|
LARGE(3300, 5100);
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun fromString(value: String): PageSize =
|
||||||
|
entries.first { it.name.equals(value, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package net.metacircular.engpad.data.model
|
||||||
|
|
||||||
|
import androidx.room.ColumnInfo
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.ForeignKey
|
||||||
|
import androidx.room.Index
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
tableName = "strokes",
|
||||||
|
foreignKeys = [
|
||||||
|
ForeignKey(
|
||||||
|
entity = Page::class,
|
||||||
|
parentColumns = ["id"],
|
||||||
|
childColumns = ["page_id"],
|
||||||
|
onDelete = ForeignKey.CASCADE,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
indices = [Index(value = ["page_id"])],
|
||||||
|
)
|
||||||
|
data class Stroke(
|
||||||
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
|
@ColumnInfo(name = "page_id") val pageId: Long,
|
||||||
|
@ColumnInfo(name = "pen_size") val penSize: Float,
|
||||||
|
val color: Int,
|
||||||
|
@ColumnInfo(name = "point_data") val pointData: ByteArray,
|
||||||
|
@ColumnInfo(name = "stroke_order") val strokeOrder: Int,
|
||||||
|
@ColumnInfo(name = "created_at") val createdAt: Long,
|
||||||
|
) {
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is Stroke) return false
|
||||||
|
return id == other.id &&
|
||||||
|
pageId == other.pageId &&
|
||||||
|
penSize == other.penSize &&
|
||||||
|
color == other.color &&
|
||||||
|
pointData.contentEquals(other.pointData) &&
|
||||||
|
strokeOrder == other.strokeOrder &&
|
||||||
|
createdAt == other.createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = id.hashCode()
|
||||||
|
result = 31 * result + pageId.hashCode()
|
||||||
|
result = 31 * result + penSize.hashCode()
|
||||||
|
result = 31 * result + color
|
||||||
|
result = 31 * result + pointData.contentHashCode()
|
||||||
|
result = 31 * result + strokeOrder
|
||||||
|
result = 31 * result + createdAt.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package net.metacircular.engpad.data.repository
|
||||||
|
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import net.metacircular.engpad.data.db.NotebookDao
|
||||||
|
import net.metacircular.engpad.data.db.PageDao
|
||||||
|
import net.metacircular.engpad.data.model.Notebook
|
||||||
|
import net.metacircular.engpad.data.model.Page
|
||||||
|
|
||||||
|
class NotebookRepository(
|
||||||
|
private val notebookDao: NotebookDao,
|
||||||
|
private val pageDao: PageDao,
|
||||||
|
) {
|
||||||
|
fun getAll(): Flow<List<Notebook>> = notebookDao.getAll()
|
||||||
|
|
||||||
|
suspend fun getById(id: Long): Notebook? = notebookDao.getById(id)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a notebook and its first page. Returns the notebook ID.
|
||||||
|
*/
|
||||||
|
suspend fun create(title: String, pageSize: String): Long {
|
||||||
|
val now = System.currentTimeMillis()
|
||||||
|
val notebookId = notebookDao.insert(
|
||||||
|
Notebook(
|
||||||
|
title = title,
|
||||||
|
pageSize = pageSize,
|
||||||
|
createdAt = now,
|
||||||
|
updatedAt = now,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
pageDao.insert(
|
||||||
|
Page(
|
||||||
|
notebookId = notebookId,
|
||||||
|
pageNumber = 1,
|
||||||
|
createdAt = now,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return notebookId
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun delete(id: Long) = notebookDao.deleteById(id)
|
||||||
|
|
||||||
|
suspend fun updateTitle(id: Long, title: String) {
|
||||||
|
val notebook = notebookDao.getById(id) ?: return
|
||||||
|
notebookDao.update(
|
||||||
|
notebook.copy(title = title, updatedAt = System.currentTimeMillis())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package net.metacircular.engpad.data.repository
|
||||||
|
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import net.metacircular.engpad.data.db.PageDao
|
||||||
|
import net.metacircular.engpad.data.db.StrokeDao
|
||||||
|
import net.metacircular.engpad.data.model.Page
|
||||||
|
import net.metacircular.engpad.data.model.Stroke
|
||||||
|
|
||||||
|
class PageRepository(
|
||||||
|
private val pageDao: PageDao,
|
||||||
|
private val strokeDao: StrokeDao,
|
||||||
|
) {
|
||||||
|
fun getPages(notebookId: Long): Flow<List<Page>> =
|
||||||
|
pageDao.getByNotebookId(notebookId)
|
||||||
|
|
||||||
|
suspend fun getById(id: Long): Page? = pageDao.getById(id)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a new page to a notebook. Returns the page ID.
|
||||||
|
*/
|
||||||
|
suspend fun addPage(notebookId: Long): Long {
|
||||||
|
val maxPage = pageDao.getMaxPageNumber(notebookId) ?: 0
|
||||||
|
return pageDao.insert(
|
||||||
|
Page(
|
||||||
|
notebookId = notebookId,
|
||||||
|
pageNumber = maxPage + 1,
|
||||||
|
createdAt = System.currentTimeMillis(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun deletePage(id: Long) = pageDao.deleteById(id)
|
||||||
|
|
||||||
|
suspend fun getStrokes(pageId: Long): List<Stroke> =
|
||||||
|
strokeDao.getByPageId(pageId)
|
||||||
|
|
||||||
|
suspend fun addStroke(stroke: Stroke): Long = strokeDao.insert(stroke)
|
||||||
|
|
||||||
|
suspend fun deleteStroke(id: Long) = strokeDao.deleteById(id)
|
||||||
|
|
||||||
|
suspend fun deleteStrokes(ids: List<Long>) = strokeDao.deleteByIds(ids)
|
||||||
|
|
||||||
|
suspend fun insertStrokes(strokes: List<Stroke>) = strokeDao.insertAll(strokes)
|
||||||
|
|
||||||
|
suspend fun getNextStrokeOrder(pageId: Long): Int =
|
||||||
|
(strokeDao.getMaxStrokeOrder(pageId) ?: 0) + 1
|
||||||
|
|
||||||
|
suspend fun updateStrokePoints(id: Long, pointData: ByteArray) =
|
||||||
|
strokeDao.updatePointData(id, pointData)
|
||||||
|
}
|
||||||
10
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
10
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:pathData="M0,0h108v108H0z" />
|
||||||
|
</vector>
|
||||||
11
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
11
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<!-- Simple pen icon -->
|
||||||
|
<path
|
||||||
|
android:fillColor="#000000"
|
||||||
|
android:pathData="M54,24 L62,72 L54,80 L46,72 Z" />
|
||||||
|
</vector>
|
||||||
6
app/src/main/res/mipmap-anydpi/ic_launcher.xml
Normal file
6
app/src/main/res/mipmap-anydpi/ic_launcher.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
4
app/src/main/res/values/strings.xml
Normal file
4
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">eng-pad</string>
|
||||||
|
</resources>
|
||||||
4
app/src/main/res/values/themes.xml
Normal file
4
app/src/main/res/values/themes.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.EngPad" parent="android:Theme.Material.Light.NoActionBar" />
|
||||||
|
</resources>
|
||||||
4
app/src/main/res/xml/file_provider_paths.xml
Normal file
4
app/src/main/res/xml/file_provider_paths.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<paths>
|
||||||
|
<cache-path name="exports" path="exports/" />
|
||||||
|
</paths>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package net.metacircular.engpad.data
|
||||||
|
|
||||||
|
import net.metacircular.engpad.data.model.PageSize
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class PageSizeTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `regular page dimensions at 300 DPI`() {
|
||||||
|
assertEquals(2550, PageSize.REGULAR.widthPt)
|
||||||
|
assertEquals(3300, PageSize.REGULAR.heightPt)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `large page dimensions at 300 DPI`() {
|
||||||
|
assertEquals(3300, PageSize.LARGE.widthPt)
|
||||||
|
assertEquals(5100, PageSize.LARGE.heightPt)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `fromString case insensitive`() {
|
||||||
|
assertEquals(PageSize.REGULAR, PageSize.fromString("regular"))
|
||||||
|
assertEquals(PageSize.REGULAR, PageSize.fromString("REGULAR"))
|
||||||
|
assertEquals(PageSize.LARGE, PageSize.fromString("large"))
|
||||||
|
assertEquals(PageSize.LARGE, PageSize.fromString("Large"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = NoSuchElementException::class)
|
||||||
|
fun `fromString invalid value throws`() {
|
||||||
|
PageSize.fromString("unknown")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package net.metacircular.engpad.data
|
||||||
|
|
||||||
|
import net.metacircular.engpad.data.db.toBlob
|
||||||
|
import net.metacircular.engpad.data.db.toFloatArray
|
||||||
|
import org.junit.Assert.assertArrayEquals
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class StrokeBlobTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `roundtrip simple points`() {
|
||||||
|
val points = floatArrayOf(100f, 200f, 300f, 400f, 500f, 600f)
|
||||||
|
val blob = points.toBlob()
|
||||||
|
val decoded = blob.toFloatArray()
|
||||||
|
assertArrayEquals(points, decoded, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `roundtrip single point`() {
|
||||||
|
val points = floatArrayOf(1.08f, 2550.0f)
|
||||||
|
val blob = points.toBlob()
|
||||||
|
val decoded = blob.toFloatArray()
|
||||||
|
assertArrayEquals(points, decoded, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `roundtrip empty array`() {
|
||||||
|
val points = floatArrayOf()
|
||||||
|
val blob = points.toBlob()
|
||||||
|
val decoded = blob.toFloatArray()
|
||||||
|
assertEquals(0, decoded.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `blob size is 4 bytes per float`() {
|
||||||
|
val points = floatArrayOf(1f, 2f, 3f, 4f, 5f, 6f)
|
||||||
|
val blob = points.toBlob()
|
||||||
|
assertEquals(points.size * 4, blob.size)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `roundtrip fractional coordinates`() {
|
||||||
|
val points = floatArrayOf(
|
||||||
|
14.4f, 28.8f, // grid intersection
|
||||||
|
4.488f, 5.906f, // pen width values
|
||||||
|
2550f, 3300f, // regular page corner
|
||||||
|
3300f, 5100f, // large page corner
|
||||||
|
)
|
||||||
|
val blob = points.toBlob()
|
||||||
|
val decoded = blob.toFloatArray()
|
||||||
|
assertArrayEquals(points, decoded, 0f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `roundtrip negative coordinates`() {
|
||||||
|
// Negative values shouldn't appear in practice but encoding must handle them
|
||||||
|
val points = floatArrayOf(-1f, -2f, 0f, 0f)
|
||||||
|
val blob = points.toBlob()
|
||||||
|
val decoded = blob.toFloatArray()
|
||||||
|
assertArrayEquals(points, decoded, 0f)
|
||||||
|
}
|
||||||
|
}
|
||||||
6
build.gradle.kts
Normal file
6
build.gradle.kts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.application) apply false
|
||||||
|
alias(libs.plugins.kotlin.android) apply false
|
||||||
|
alias(libs.plugins.kotlin.compose) apply false
|
||||||
|
alias(libs.plugins.ksp) apply false
|
||||||
|
}
|
||||||
4
gradle.properties
Normal file
4
gradle.properties
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
|
||||||
|
android.useAndroidX=true
|
||||||
|
kotlin.code.style=official
|
||||||
|
android.nonTransitiveRClass=true
|
||||||
43
gradle/libs.versions.toml
Normal file
43
gradle/libs.versions.toml
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
[versions]
|
||||||
|
agp = "8.10.1"
|
||||||
|
kotlin = "2.1.20"
|
||||||
|
ksp = "2.1.20-1.0.32"
|
||||||
|
compose-bom = "2026.03.00"
|
||||||
|
room = "2.8.4"
|
||||||
|
navigation = "2.9.7"
|
||||||
|
lifecycle = "2.10.0"
|
||||||
|
coroutines = "1.10.2"
|
||||||
|
core-ktx = "1.18.0"
|
||||||
|
activity-compose = "1.13.0"
|
||||||
|
junit = "4.13.2"
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "core-ktx" }
|
||||||
|
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
|
||||||
|
|
||||||
|
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
|
||||||
|
compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
||||||
|
compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
|
compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
||||||
|
compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
|
|
||||||
|
navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation" }
|
||||||
|
|
||||||
|
lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycle" }
|
||||||
|
lifecycle-runtime-compose = { group = "androidx.lifecycle", name = "lifecycle-runtime-compose", version.ref = "lifecycle" }
|
||||||
|
|
||||||
|
room-runtime = { group = "androidx.room", name = "room-runtime", version.ref = "room" }
|
||||||
|
room-ktx = { group = "androidx.room", name = "room-ktx", version.ref = "room" }
|
||||||
|
room-compiler = { group = "androidx.room", name = "room-compiler", version.ref = "room" }
|
||||||
|
room-testing = { group = "androidx.room", name = "room-testing", version.ref = "room" }
|
||||||
|
|
||||||
|
coroutines-android = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-android", version.ref = "coroutines" }
|
||||||
|
coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "coroutines" }
|
||||||
|
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
||||||
|
|
||||||
|
[plugins]
|
||||||
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||||
|
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
|
||||||
|
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
7
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
||||||
252
gradlew
vendored
Executable file
252
gradlew
vendored
Executable file
@@ -0,0 +1,252 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||||
|
' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
94
gradlew.bat
vendored
Normal file
94
gradlew.bat
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
23
settings.gradle.kts
Normal file
23
settings.gradle.kts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
|
repositories {
|
||||||
|
google()
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rootProject.name = "eng-pad"
|
||||||
|
include(":app")
|
||||||
Reference in New Issue
Block a user