diff --git a/frontend/css/styles.css b/frontend/css/styles.css index 6a43e94..60e6ebb 100644 --- a/frontend/css/styles.css +++ b/frontend/css/styles.css @@ -1315,6 +1315,9 @@ select { zoom controls. Give them slots in the right-hand stack. */ .rec-nogo-btn { right: 8px; bottom: 314px; } .rec-reroute-btn { right: 8px; bottom: 352px; } +/* Left-hand group (bottom-left), opposite the right control stack: SMS + live toggle. */ +.rec-sms-btn { left: 8px; bottom: 48px; font-size: 11px; } +.rec-live-btn { left: 8px; bottom: 86px; font-size: 10px; } /* Dark map: invert ONLY the tile layer (track, route, puck keep their colours). User-tuned filter on OSM standard tiles. Applies to every Leaflet map. */ body.dark-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(1.5); } diff --git a/frontend/js/main.js b/frontend/js/main.js index 4886587..adc76c7 100644 --- a/frontend/js/main.js +++ b/frontend/js/main.js @@ -127,7 +127,12 @@ async function init() { // toggle so a session always sees the current choice (off unless the user turned it on). try { let liveOn = localStorage.getItem("baldav_live_on") === "1"; - let liveUrl = localStorage.getItem("baldav_live_url") || "https://4aiman.top/api/live/push"; + let liveUrl = localStorage.getItem("baldav_live_url") || "https://4aiman.top/api/trackme/push"; + // migrate the old /api/live/push endpoint to /api/trackme/push (renamed server-side) + if (liveUrl.endsWith("/api/live/push")) { + liveUrl = liveUrl.replace("/api/live/push", "/api/trackme/push"); + localStorage.setItem("baldav_live_url", liveUrl); + } let liveToken = localStorage.getItem("baldav_live_token") || ""; window.__TAURI__?.core?.invoke("set_live_config", { enabled: liveOn, url: liveUrl, token: liveToken }); @@ -4767,7 +4772,6 @@ async function renderRecordingInline(container) {
- ${localStorage.getItem("baldav_sms_number") ? '' : ''}
@@ -4993,6 +4997,34 @@ async function renderRecordingInline(container) { }; btnWrap.appendChild(followBtn); + // Left-side group (bottom-left, opposite the right controls): live-location toggle + SMS. + // Live sharing can be switched on/off right here even if it was never set in the profile. + let liveBtn = document.createElement("button"); + liveBtn.className = "rec-map-btn rec-live-btn"; + liveBtn.textContent = "LIVE"; + liveBtn.title = "Трансляция местоположения вкл/выкл"; + let liveOn = localStorage.getItem("baldav_live_on") === "1"; + liveBtn.classList.toggle("active", liveOn); + liveBtn.onclick = async () => { + liveOn = !liveOn; + localStorage.setItem("baldav_live_on", liveOn ? "1" : "0"); + liveBtn.classList.toggle("active", liveOn); + let url = localStorage.getItem("baldav_live_url") || "https://4aiman.top/api/trackme/push"; + let token = localStorage.getItem("baldav_live_token") || ""; + try { await window.__TAURI__.core.invoke("set_live_config", { enabled: liveOn, url, token }); } + catch (e) { console.error("live toggle", e); } + if (liveOn && !token) appAlert("Трансляция включена, но токен не задан в профиле - точки не уйдут, пока не впишешь токен."); + }; + btnWrap.appendChild(liveBtn); + + // SMS "я тут" button + let smsBtn = document.createElement("button"); + smsBtn.className = "rec-map-btn rec-sms-btn"; + smsBtn.textContent = "СМС"; + smsBtn.title = "Отправить СМС с местоположением"; + smsBtn.onclick = () => sendLocationSms(); + btnWrap.appendChild(smsBtn); + // Roads toggle button. Roads are viewport-culled onto a canvas pane (only the segments in // view are drawn, redrawn on pan/zoom) so a huge road network doesn't jank the WebView. let roadsBtn = document.createElement("button"); @@ -5319,10 +5351,6 @@ async function renderRecordingInline(container) { } }; - // SMS "я тут" button — only present when a contact number is configured - let smsBtn = container.querySelector("#rec-sms"); - if (smsBtn) smsBtn.onclick = () => sendLocationSms(); - // Stop button container.querySelector("#rec-stop").onclick = async () => { if (GPS.recording._compassCleanup) GPS.recording._compassCleanup(); @@ -8279,7 +8307,7 @@ function showProfileModal() { Делиться местоположением онлайн
Пока включено, во время записи заезда телефон отправляет текущую точку на сервер раз в 10 секунд. Видно только тем, кому дан доступ, и только после входа. Выключается здесь же.
- +
diff --git a/src-tauri/gen/android/app/src/main/java/dev/baldav/app/LiveShare.kt b/src-tauri/gen/android/app/src/main/java/dev/baldav/app/LiveShare.kt index 48497f4..a767850 100644 --- a/src-tauri/gen/android/app/src/main/java/dev/baldav/app/LiveShare.kt +++ b/src-tauri/gen/android/app/src/main/java/dev/baldav/app/LiveShare.kt @@ -47,7 +47,8 @@ object LiveShare { // Latest fix from the GPS flush loop (every ~10s). Non-blocking: the network call runs on a // throwaway thread so it never stalls the main looper that drives GPS delivery. fun tick(ctx: Context, lat: Double, lon: Double, speed: Float, fixTs: Long) { - if (!loaded) readCfg(ctx) + // re-read every tick so toggling the record-screen LIVE button takes effect within ~10s + readCfg(ctx) if (!enabled || url.isBlank() || token.isBlank()) return if (lat == 0.0 && lon == 0.0) return // no fix yet val now = System.currentTimeMillis()