feat(android): Capacitor APK build + native save/share bridge
- android/ — Capacitor project (build/, local.properties ignored) - app/js/native.js — bridge สำหรับ APK: savePhoto/saveZip/shareItems ผ่าน Filesystem+Share - app/js/csv.js — นำเข้าโฟลเดอร์หลายรายการจาก CSV (site,letter,datetime,name) - app/js/orient.js — จัดการ orientation ของ preview/กล้อง - app/manual.html + APK.md — คู่มือใช้งานและวิธี build APK - app/templates/folders-template.csv — เทมเพลต CSV - package.json / package-lock.json / capacitor.config.json / scripts/build-apk.sh - ปรับ ui, camera, exif, archive, db, naming, main, sw + css/README ตามงานข้างบน
This commit is contained in:
1 parent
a0bccc2316
commit
6f146aef59
75 files changed
+4637
-151
No files matched your search
+105
-10
@@ -64,9 +64,12 @@ export function cameraShell() {
|
||||
return `
|
||||
<div id="camera-view">
|
||||
<div class="stage">
|
||||
<video id="video" autoplay playsinline muted></video>
|
||||
<div class="grid-lines" id="grid-lines"></div>
|
||||
<div class="frame ratio-43" id="cam-frame">
|
||||
<video id="video" autoplay playsinline muted></video>
|
||||
<div class="grid-lines" id="grid-lines"></div>
|
||||
</div>
|
||||
<div class="cam-top">
|
||||
<button class="cam-chip ratio-chip" type="button" id="chip-ratio" data-action="toggle-ratio" aria-label="สลับอัตราส่วนภาพ 4:3 / 3:4">4:3</button>
|
||||
<button class="cam-chip" type="button" data-action="toggle-grid" aria-label="เส้นแบ่ง 3 ส่วน">${ICON.grid}</button>
|
||||
<button class="cam-chip" type="button" id="chip-torch" data-action="toggle-torch" aria-pressed="false" aria-label="ไฟแฟลช" hidden>${ICON.torch}</button>
|
||||
<button class="cam-chip" type="button" data-action="switch-camera" aria-label="สลับกล้องหน้า/หลัง">${ICON.flip}</button>
|
||||
@@ -106,7 +109,7 @@ export function hero(kind, { title, text = "", steps = [], action = null, note =
|
||||
</div>`;
|
||||
}
|
||||
|
||||
export function syncCameraControls({ torchAvailable, torchOn, zoomRange, zoomValue, gridOn, count, thumbUrl, ready }) {
|
||||
export function syncCameraControls({ torchAvailable, torchOn, zoomRange, zoomValue, gridOn, count, thumbUrl, ready, ratio }) {
|
||||
const chip = document.getElementById("chip-torch");
|
||||
if (chip) {
|
||||
chip.hidden = !torchAvailable;
|
||||
@@ -134,6 +137,15 @@ export function syncCameraControls({ torchAvailable, torchOn, zoomRange, zoomVal
|
||||
}
|
||||
}
|
||||
|
||||
const frame = document.getElementById("cam-frame");
|
||||
const ratioChip = document.getElementById("chip-ratio");
|
||||
if (frame) {
|
||||
const portrait = ratio === "3:4";
|
||||
frame.classList.toggle("ratio-43", !portrait);
|
||||
frame.classList.toggle("ratio-34", portrait);
|
||||
}
|
||||
if (ratioChip) ratioChip.textContent = ratio || "4:3";
|
||||
|
||||
const grid = document.getElementById("grid-lines");
|
||||
if (grid) grid.classList.toggle("on", !!gridOn);
|
||||
const cnt = document.getElementById("shot-count");
|
||||
@@ -147,9 +159,12 @@ export function syncCameraControls({ torchAvailable, torchOn, zoomRange, zoomVal
|
||||
// ── Folders ──
|
||||
export function renderFolders({ folders, counts, activeId, storage }) {
|
||||
const total = counts.reduce((a, b) => a + b, 0);
|
||||
let html = `<div class="section-head">
|
||||
let html = `<div class="folder-view"><div class="section-head">
|
||||
<div><h2>โฟลเดอร์</h2><div class="sub">${folders.length} โฟลเดอร์ · ${total} รูป</div></div>
|
||||
<button class="btn btn-primary" type="button" data-action="new-folder">+ โฟลเดอร์ใหม่</button>
|
||||
<div class="head-btns">
|
||||
<button class="btn btn-ghost" type="button" data-action="csv-sheet">CSV</button>
|
||||
<button class="btn btn-primary" type="button" data-action="new-folder">+ โฟลเดอร์ใหม่</button>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
if (!folders.length) {
|
||||
@@ -173,11 +188,17 @@ export function renderFolders({ folders, counts, activeId, storage }) {
|
||||
html += `</div>`;
|
||||
}
|
||||
|
||||
html += `<div class="folder-bulk">
|
||||
<button class="btn btn-ghost btn-block" type="button" data-action="zip-all">${ICON.zip} ZIP ทุกโฟลเดอร์ (${total} รูป)</button>
|
||||
</div>`;
|
||||
|
||||
html += `<div class="storage-line">
|
||||
พื้นที่เก็บในเครื่อง${storage ? ` · ใช้ ${fmtBytes(storage.usage)} จาก ${fmtBytes(storage.quota)}` : ""}
|
||||
<br><button class="btn btn-ghost" type="button" style="min-height:34px;height:34px;font-size:11px;margin-top:8px" data-action="diagnostics">ข้อมูลอุปกรณ์และกล้อง</button>
|
||||
<button class="btn btn-ghost" type="button" style="min-height:34px;height:34px;font-size:11px;margin-top:8px;margin-left:6px" data-action="show-qr">QR ลิงก์ทดสอบ</button>
|
||||
</div>`;
|
||||
|
||||
html += `</div>`;
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -205,9 +226,8 @@ export function renderGallery({ folder, images, thumbUrl }) {
|
||||
html += `</div>`;
|
||||
|
||||
html += `<div class="action-bar">
|
||||
<button class="btn btn-ghost" type="button" data-action="zip-download">${ICON.zip} ZIP (${images.length})</button>
|
||||
<button class="btn btn-primary" type="button" data-action="zip-share">${ICON.share} แชร์ ZIP</button>
|
||||
</div>`;
|
||||
<button class="btn btn-primary btn-block" type="button" data-action="zip-download">${ICON.zip} ZIP โฟลเดอร์นี้ (${images.length} รูป)</button>
|
||||
</div></div>`;
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -234,6 +254,12 @@ export function photoSheet({ record, url, folderName }) {
|
||||
}
|
||||
if (m.exif?.orientation) rows.push(["Orientation", String(m.exif.orientation)]);
|
||||
if (m.exif?.dateTimeOriginal) rows.push(["EXIF DateTimeOriginal", m.exif.dateTimeOriginal]);
|
||||
if (m.exif?.software) rows.push(["Software", m.exif.software]);
|
||||
if (m.exif?.gps?.dateStamp) {
|
||||
const t = Array.isArray(m.exif.gps.timeStamp) ? m.exif.gps.timeStamp.map((x) => String(Math.round(x)).padStart(2, "0")).join(":") : "";
|
||||
rows.push(["GPS date/time", `${m.exif.gps.dateStamp}${t ? " " + t : ""}`]);
|
||||
}
|
||||
if (m.exif?.uniqueId) rows.push(["ImageUniqueID", m.exif.uniqueId.slice(0, 16) + "…"]);
|
||||
|
||||
const rowsHtml = rows
|
||||
.map(([k, v]) => `<div class="row"><span class="k">${esc(k)}</span><span class="v">${esc(v)}</span></div>`)
|
||||
@@ -244,7 +270,18 @@ export function photoSheet({ record, url, folderName }) {
|
||||
<div class="hint">${esc(humanDateTime(record.createdAt))}</div>
|
||||
<img class="preview" src="${url}" alt="">
|
||||
<div class="meta-table">${rowsHtml}</div>
|
||||
<div class="hint" style="margin-top:10px;margin-bottom:0">ข้อมูลทั้งหมดฝังอยู่ในไฟล์ JPEG (EXIF) แล้ว — ติดไปกับรูปตอนแชร์/ดาวน์โหลด ไม่มีไฟล์แยก</div>
|
||||
<div class="sheet-actions" style="margin-top:14px">
|
||||
<button class="btn btn-ghost" type="button" data-action="rotate-photo" data-id="${esc(record.id)}" data-dir="-90" aria-label="หมุนซ้าย 90 องศา">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M2 12a10 10 0 1 0 3-7"/><path d="M2 3v6h6"/></svg>
|
||||
ซ้าย
|
||||
</button>
|
||||
<button class="btn btn-ghost" type="button" data-action="rotate-photo" data-id="${esc(record.id)}" data-dir="90" aria-label="หมุนขวา 90 องศา">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 12a10 10 0 1 1-3-7"/><path d="M22 3v6h-6"/></svg>
|
||||
ขวา
|
||||
</button>
|
||||
</div>
|
||||
<div class="sheet-actions" style="margin-top:8px">
|
||||
<button class="btn btn-ghost" type="button" data-action="close-sheet">ปิด</button>
|
||||
<button class="btn btn-primary" type="button" data-action="share-photo" data-id="${esc(record.id)}">${ICON.share} แชร์รูปนี้</button>
|
||||
</div>
|
||||
@@ -265,9 +302,9 @@ export function folderSheet(mode, { id = "", name = "", suggested = "", count =
|
||||
}
|
||||
const isNew = mode === "new";
|
||||
return `<h3>${isNew ? "โฟลเดอร์ใหม่" : "เปลี่ยนชื่อโฟลเดอร์"}</h3>
|
||||
<div class="hint">ชื่อเริ่มต้นอิงวันที่ไทย (พ.ศ.) ของวันนี้ — แก้ไขได้</div>
|
||||
<div class="hint">ชื่อเริ่มต้น = Site + ตัวอักษรถัดไป + ปี.เดือน.วัน.ชั่วโมง.นาที (แก้ได้)</div>
|
||||
<input id="folder-name-input" type="text" inputmode="text" autocomplete="off"
|
||||
value="${esc(isNew ? suggested : name)}" placeholder="Site A 2569-10-24">
|
||||
value="${esc(isNew ? suggested : name)}" placeholder="Site a 2569.10.25.21.45">
|
||||
${isNew ? `<div class="hint" style="margin-top:-6px">ถ้าชื่อซ้ำ ระบบจะเติม (2) ให้อัตโนมัติ</div>` : ""}
|
||||
<div class="sheet-actions">
|
||||
<button class="btn btn-ghost" type="button" data-action="close-sheet">ยกเลิก</button>
|
||||
@@ -290,6 +327,64 @@ export function qrSheet(url) {
|
||||
</div></div>`;
|
||||
}
|
||||
|
||||
// ── CSV import ──────────────────────────────────────────────
|
||||
export function csvSheet() {
|
||||
return `<h3>นำเข้าโฟลเดอร์จาก CSV</h3>
|
||||
<div class="hint">สร้างทีละหลายโฟลเดอร์ในครั้งเดียว — ชื่อที่ได้จะใช้กฎ Site + ตัวอักษร + ปี.เดือน.วัน.ชั่วโมง.นาที</div>
|
||||
<div class="meta-table">
|
||||
<div class="row"><span class="k">site</span><span class="v">คำนำหน้า เช่น Site (เว้นว่าง = Site)</span></div>
|
||||
<div class="row"><span class="k">letter</span><span class="v">a…z, aa… (เว้นว่าง = ไล่ต่ออัตโนมัติ)</span></div>
|
||||
<div class="row"><span class="k">datetime</span><span class="v">2569.10.25.21.45</span></div>
|
||||
<div class="row"><span class="k">name</span><span class="v">ชื่อเต็ม (ถ้าใส่ จะทับชื่อที่ประกอบ)</span></div>
|
||||
</div>
|
||||
<div class="hint" style="margin-top:12px">ตัวอย่างแถว<br><code>Site,a,2569.10.25.21.45,</code><br><code>Site,b,2569.10.25.22.10,</code></div>
|
||||
<div class="sheet-actions" style="margin-top:12px">
|
||||
<a class="btn btn-ghost" href="templates/folders-template.csv" download="folders-template.csv">ไฟล์เปล่า</a>
|
||||
<button class="btn btn-primary" type="button" data-action="pick-csv">เลือกไฟล์ CSV</button>
|
||||
</div>
|
||||
<div class="sheet-actions" style="margin-top:8px">
|
||||
<button class="btn btn-ghost btn-block" type="button" data-action="close-sheet">ปิด</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
export function importResultSheet({ created, skipped, errors = [], total }) {
|
||||
const list = errors.length
|
||||
? `<div class="notice" style="margin:12px 0 0">
|
||||
<b>ข้าม ${skipped} แถว</b>
|
||||
<ol>${errors.slice(0, 12).map((e) => `<li>แถว ${e.row}: ${esc(e.reason)}</li>`).join("")}</ol>
|
||||
${errors.length > 12 ? `<div style="margin-top:6px">…อีก ${errors.length - 12} แถว</div>` : ""}
|
||||
</div>`
|
||||
: "";
|
||||
return `<h3>สร้างโฟลเดอร์แล้ว ${created} รายการ</h3>
|
||||
<div class="hint">อ่าน ${total} แถว · สำเร็จ ${created} · ข้าม ${skipped}</div>
|
||||
${list}
|
||||
<div class="sheet-actions" style="margin-top:14px">
|
||||
<button class="btn btn-primary btn-block" type="button" data-action="close-sheet">เรียบร้อย</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// ── พร้อมแชร์ (หลังสร้าง ZIP) ────────────────────────────────
|
||||
export function shareReadySheet({ name, size, canShare, reason }) {
|
||||
const status = canShare ? "พร้อมส่งเข้าแอปอื่น" : "เบราว์เซอร์นี้ไม่รองรับการแชร์ไฟล์";
|
||||
const note = canShare
|
||||
? "แตะปุ่มด้านล่างเพื่อเปิด share sheet ของ Samsung"
|
||||
: "บันทึกไฟล์แล้วแชร์ผ่าน Files/My Files หรือเปิดด้วย Chrome";
|
||||
return `<h3>ZIP พร้อมแล้ว</h3>
|
||||
<div class="meta-table">
|
||||
<div class="row"><span class="k">ไฟล์</span><span class="v">${esc(name)}</span></div>
|
||||
<div class="row"><span class="k">ขนาด</span><span class="v">${esc(fmtBytes(size))}</span></div>
|
||||
<div class="row"><span class="k">การแชร์</span><span class="v">${esc(status)}</span></div>
|
||||
</div>
|
||||
<div class="hint" style="margin-top:12px">${esc(note)}${reason ? " · " + esc(reason) : ""}</div>
|
||||
<div class="sheet-actions">
|
||||
<button class="btn btn-ghost" type="button" data-action="save-zip">บันทึกไฟล์</button>
|
||||
<button class="btn btn-primary" type="button" data-action="share-zip-now" ${canShare ? "" : "disabled"}>แชร์ไปแอปอื่น</button>
|
||||
</div>
|
||||
<div class="sheet-actions" style="margin-top:8px">
|
||||
<button class="btn btn-ghost btn-block" type="button" data-action="close-sheet">ปิด</button>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
// ── Diagnostics ──
|
||||
export function diagnosticsSheet(rows) {
|
||||
const body = rows
|
||||
|
||||
Reference in new issue
Block a user