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:
Bkk1234 committed 2026-11-20 08:50:42 +07:00
1 parent a0bccc2316
commit 6f146aef59
75 files changed
+4637 -151

No files matched your search

+58 -3
View File
@@ -23,10 +23,65 @@ export function bkkParts(date = new Date()) {
};
}
/** "Site A 2569-10-24" */
export function defaultFolderName(date = new Date()) {
/** "2569.10.25.21.45" — ปี พ.ศ..เดือน.วัน.ชั่วโมง.นาที */
export function folderStamp(date = new Date()) {
const p = bkkParts(date);
return `${SITE_LABEL} ${p.thaiYear}-${p.month}-${p.day}`;
return `${p.thaiYear}.${p.month}.${p.day}.${p.hour}.${p.minute}`;
}
/** 0→a, 25→z, 26→aa, 27→ab … (แบบคอลัมน์ Excel) */
export function letterForIndex(index) {
let n = Math.max(0, Math.trunc(index)) + 1;
let s = "";
while (n > 0) {
const r = (n - 1) % 26;
s = String.fromCharCode(97 + r) + s;
n = Math.floor((n - 1) / 26);
}
return s;
}
/** a→0, z→25, aa→26 … (คืน -1 ถ้าไม่ใช่ a-z ล้วน) */
export function indexForLetters(letters) {
const s = String(letters || "").trim().toLowerCase();
if (!/^[a-z]+$/.test(s)) return -1;
let n = 0;
for (const ch of s) n = n * 26 + (ch.charCodeAt(0) - 97 + 1);
return n - 1;
}
/** ตัวอักษรถัดไปจากชื่อโฟลเดอร์ที่มีอยู่: Site a …, Site b … */
export function nextLetter(existingNames = []) {
let max = -1;
for (const name of existingNames) {
const m = /^site\s+([a-z]+)\s+\d/.exec(String(name).toLowerCase());
if (m) max = Math.max(max, indexForLetters(m[1]));
}
return letterForIndex(max + 1);
}
/** ประกอบชื่อ: Site <letter> <stamp> */
export function makeFolderName({ site = SITE_LABEL, letter = "a", date = new Date(), datetime } = {}) {
return `${site} ${letter} ${datetime || folderStamp(date)}`;
}
/** ชื่อเริ่มต้นของโฟลเดอร์ใหม่ (ไล่ตัวอักษรอัตโนมัติ) */
export function defaultFolderName(existingNames = [], date = new Date()) {
return makeFolderName({ letter: nextLetter(existingNames), date });
}
/** ตรวจ/ทำความสะอาดค่า datetime จาก CSV → "2569.10.25.21.45" (คืน null ถ้าใช้ไม่ได้) */
export function normalizeFolderStamp(input, fallback = null) {
const raw = String(input ?? "").trim();
if (!raw) return fallback;
const nums = raw.match(/\d+/g);
if (!nums || nums.length < 3) return null;
const [y, mo, d, h = "0", mi = "0"] = nums.map((x) => Number(x));
const year = y > 2400 ? y : y + 543; // รับทั้ง ค.ศ. และ พ.ศ.
if (year < 2400 || year > 2700) return null;
if (mo < 1 || mo > 12 || d < 1 || d > 31 || h > 23 || mi > 59) return null;
const p2 = (n) => String(n).padStart(2, "0");
return `${year}.${p2(mo)}.${p2(d)}.${p2(h)}.${p2(mi)}`;
}
/** EXIF DateTimeOriginal: "YYYY:MM:DD HH:MM:SS" (เวลาไทย) */