diff --git a/base-apps/com.mosis.browser/browser.lua b/base-apps/com.mosis.browser/browser.lua new file mode 100644 index 0000000..d9246ad --- /dev/null +++ b/base-apps/com.mosis.browser/browser.lua @@ -0,0 +1,307 @@ +-- browser.lua - Web browser functionality +-- Handles URL navigation, tabs, bookmarks, and history + +local browser_doc = nil +local tabs = {} +local current_tab_id = 1 +local history = {} +local bookmarks = {} + +-- Sample page content +local pages = { + ["example.com"] = { + title = "Example Domain", + secure = true, + content = [[ +
Example Domain
+
+ This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission. +
+
+ More information... +
+ ]] + }, + ["google.com"] = { + title = "Google", + secure = true, + content = [[ +
+
G
+
o
+
o
+
g
+
l
+
e
+
+ +
+
+ ]] + }, + ["mosis.app"] = { + title = "Mosis - Virtual Smartphone for VR", + secure = true, + content = [[ +
Welcome to Mosis
+
+ Mosis is a virtual smartphone OS for VR games and applications. Experience a phone-like device inside your virtual reality environment. +
+
+
+
Browse Apps
+
Discover apps for your virtual phone
+
+
+
For Developers
+
Build apps for the Mosis platform
+
+
+ ]] + }, + ["default"] = { + title = "Page Not Found", + secure = false, + content = [[ +
+
:(
+
Page Not Found
+
The requested page could not be loaded.
+
+ ]] + } +} + +-- Initialize tabs +local function initTabs() + tabs = { + {id = 1, url = "example.com", title = "Example Domain"} + } + current_tab_id = 1 +end + +-- Initialize browser +function initBrowser(doc) + print("[Browser] Initializing...") + browser_doc = doc + initTabs() + loadPage(tabs[1].url) +end + +-- Get current tab +local function getCurrentTab() + for _, tab in ipairs(tabs) do + if tab.id == current_tab_id then + return tab + end + end + return tabs[1] +end + +-- Load a page +function loadPage(url) + if not browser_doc then return end + + print("[Browser] Loading: " .. url) + + -- Clean URL + url = url:gsub("^https?://", ""):gsub("^www%.", ""):gsub("/$", "") + + -- Update current tab + local tab = getCurrentTab() + if tab then + tab.url = url + end + + -- Add to history + table.insert(history, 1, {url = url, time = "Just now"}) + + -- Get page data + local page = pages[url] or pages["default"] + if tab then + tab.title = page.title + end + + -- Update URL bar + local url_input = browser_doc:GetElementById("url-input") + if url_input then + url_input.value = url + end + + -- Update secure icon + local secure_icon = browser_doc:GetElementById("secure-icon") + if secure_icon then + if page.secure then + secure_icon.inner_rml = "S" + secure_icon.style.color = "#4CAF50" + else + secure_icon.inner_rml = "!" + secure_icon.style.color = "#F44336" + end + end + + -- Update page title + local title = browser_doc:GetElementById("page-title") + if title then + title.inner_rml = page.title + end + + -- Update content + local content = browser_doc:GetElementById("browser-content") + if content then + content.inner_rml = [[
]] .. page.content .. [[
]] + end + + -- Update tab count + updateTabCount() +end + +-- Navigate to URL +function navigateToUrl(url) + loadPage(url) +end + +-- Handle URL input +function onUrlSubmit() + if not browser_doc then return end + + local input = browser_doc:GetElementById("url-input") + if input then + local url = input.value or "" + if url ~= "" then + loadPage(url) + end + end +end + +-- Go back in history +function browserBack() + if #history > 1 then + table.remove(history, 1) -- Remove current page + local prev = history[1] + if prev then + loadPage(prev.url) + end + end +end + +-- Go forward (simplified - just reload) +function browserForward() + if showToast then + showToast("No forward history") + end +end + +-- Refresh page +function browserRefresh() + local tab = getCurrentTab() + if tab then + loadPage(tab.url) + if showToast then + showToast("Page refreshed") + end + end +end + +-- Update tab count display +function updateTabCount() + if not browser_doc then return end + + local count = browser_doc:GetElementById("tab-count") + if count then + count.inner_rml = tostring(#tabs) + end +end + +-- Open new tab +function newTab() + local new_id = #tabs + 1 + table.insert(tabs, { + id = new_id, + url = "mosis.app", + title = "New Tab" + }) + current_tab_id = new_id + loadPage("mosis.app") + updateTabCount() + print("[Browser] New tab opened: " .. new_id) +end + +-- Show tabs view +function showTabs() + print("[Browser] Show tabs") + if showToast then + showToast(#tabs .. " tab(s) open") + end +end + +-- Close current tab +function closeTab() + if #tabs > 1 then + for i, tab in ipairs(tabs) do + if tab.id == current_tab_id then + table.remove(tabs, i) + break + end + end + current_tab_id = tabs[1].id + loadPage(tabs[1].url) + updateTabCount() + else + if showToast then + showToast("Cannot close last tab") + end + end +end + +-- Add to bookmarks +function addBookmark() + local tab = getCurrentTab() + if tab then + table.insert(bookmarks, { + url = tab.url, + title = tab.title + }) + if showToast then + showToast("Bookmark added") + end + end +end + +-- Show bookmarks +function showBookmarks() + print("[Browser] Show bookmarks") + if showToast then + showToast(#bookmarks .. " bookmark(s)") + end +end + +-- Show history +function showHistory() + print("[Browser] Show history") + if showToast then + showToast(#history .. " items in history") + end +end + +-- Share page +function sharePage() + local tab = getCurrentTab() + if tab then + print("[Browser] Share: " .. tab.url) + if showToast then + showToast("Share: " .. tab.url) + end + end +end + +-- Show menu +function showBrowserMenu() + print("[Browser] Show menu") + -- TODO: Show dropdown menu +end + +-- Go to home +function browserHome() + loadPage("mosis.app") +end diff --git a/base-apps/com.mosis.browser/browser.rml b/base-apps/com.mosis.browser/browser.rml index bfbba21..a3e1ec8 100644 --- a/base-apps/com.mosis.browser/browser.rml +++ b/base-apps/com.mosis.browser/browser.rml @@ -6,6 +6,7 @@ + Browser - +
12:30 @@ -179,66 +192,52 @@
-
+
-
+
- S - + S +
-
+
-
+
-
+
-
Example Domain
+
Example Domain
This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.
- More information... -
- -
-
Related Links
-
-
IANA - IANA-managed Reserved Domains
-
www.iana.org > domains > reserved
-
Certain domains are set aside and unavailable for registration.
-
-
-
RFC 2606 - Reserved Top Level DNS Names
-
tools.ietf.org > html > rfc2606
-
This document describes domain names reserved for documentation.
-
+ More information...
-
+
Home
-
- 1 +
+ 1 Tabs
-
+
New Tab
-
+
Menu
diff --git a/base-apps/com.mosis.camera/camera.lua b/base-apps/com.mosis.camera/camera.lua new file mode 100644 index 0000000..418aba2 --- /dev/null +++ b/base-apps/com.mosis.camera/camera.lua @@ -0,0 +1,360 @@ +-- camera.lua - Camera app functionality +-- Handles capture, modes, flash, zoom, and camera switching + +local camera_doc = nil +local current_mode = "photo" -- photo, video, portrait, night +local flash_mode = "auto" -- auto, on, off +local timer_mode = "off" -- off, 3, 10 +local is_front_camera = false +local is_recording = false +local zoom_level = 1.0 +local photo_count = 0 +local video_duration = 0 +local video_timer_id = nil + +-- Camera modes +local modes = {"Night", "Portrait", "Photo", "Video", "More"} + +-- Initialize camera +function initCamera(doc) + print("[Camera] Initializing...") + camera_doc = doc + updateModeDisplay() + updateFlashDisplay() + updateTimerDisplay() + updateZoomDisplay() +end + +-- Update mode display +function updateModeDisplay() + if not camera_doc then return end + + for _, mode in ipairs(modes) do + local mode_el = camera_doc:GetElementById("mode-" .. mode:lower()) + if mode_el then + if mode:lower() == current_mode then + mode_el:SetClass("active", true) + else + mode_el:SetClass("active", false) + end + end + end + + -- Update capture button appearance for video mode + local capture_btn = camera_doc:GetElementById("capture-button") + if capture_btn then + if current_mode == "video" then + if is_recording then + capture_btn.inner_rml = [[
]] + else + capture_btn.inner_rml = [[
]] + end + else + capture_btn.inner_rml = [[
]] + end + end +end + +-- Switch camera mode +function switchMode(mode) + print("[Camera] Switching to mode: " .. mode) + current_mode = mode:lower() + + -- Stop recording if switching from video + if is_recording then + stopRecording() + end + + updateModeDisplay() + + if showToast then + showToast(mode .. " mode") + end +end + +-- Toggle flash +function toggleFlash() + if flash_mode == "auto" then + flash_mode = "on" + elseif flash_mode == "on" then + flash_mode = "off" + else + flash_mode = "auto" + end + + print("[Camera] Flash: " .. flash_mode) + updateFlashDisplay() +end + +-- Update flash display +function updateFlashDisplay() + if not camera_doc then return end + + local indicator = camera_doc:GetElementById("flash-indicator") + if indicator then + local text = "Flash: " + if flash_mode == "auto" then + text = text .. "Auto" + elseif flash_mode == "on" then + text = text .. "On" + else + text = text .. "Off" + end + indicator.inner_rml = text + end +end + +-- Toggle timer +function toggleTimer() + if timer_mode == "off" then + timer_mode = "3" + elseif timer_mode == "3" then + timer_mode = "10" + else + timer_mode = "off" + end + + print("[Camera] Timer: " .. timer_mode) + updateTimerDisplay() +end + +-- Update timer display +function updateTimerDisplay() + if not camera_doc then return end + + local indicator = camera_doc:GetElementById("timer-indicator") + if indicator then + local text = "Timer: " + if timer_mode == "off" then + text = text .. "Off" + else + text = text .. timer_mode .. "s" + end + indicator.inner_rml = text + end +end + +-- Zoom in +function zoomIn() + if zoom_level < 10.0 then + zoom_level = math.min(zoom_level + 0.5, 10.0) + updateZoomDisplay() + end +end + +-- Zoom out +function zoomOut() + if zoom_level > 0.5 then + zoom_level = math.max(zoom_level - 0.5, 0.5) + updateZoomDisplay() + end +end + +-- Update zoom display +function updateZoomDisplay() + if not camera_doc then return end + + local indicator = camera_doc:GetElementById("zoom-level") + if indicator then + indicator.inner_rml = string.format("%.1fx", zoom_level) + end + + print("[Camera] Zoom: " .. zoom_level) +end + +-- Switch camera (front/back) +function switchCamera() + is_front_camera = not is_front_camera + print("[Camera] Switched to " .. (is_front_camera and "front" or "back") .. " camera") + + if showToast then + showToast(is_front_camera and "Front camera" or "Back camera") + end + + -- Update viewfinder placeholder + local placeholder = camera_doc:GetElementById("viewfinder-placeholder") + if placeholder then + local icon = is_front_camera and "F" or "C" + placeholder.inner_rml = [[ +
]] .. icon .. [[
+
]] .. (is_front_camera and "Front Camera" or "Camera Preview") .. [[
+
Tap to focus
+ ]] + end +end + +-- Capture photo or start/stop video +function capture() + if current_mode == "video" then + if is_recording then + stopRecording() + else + startRecording() + end + else + takePhoto() + end +end + +-- Take a photo +function takePhoto() + print("[Camera] Taking photo...") + + -- Check timer + if timer_mode ~= "off" then + local delay = tonumber(timer_mode) * 1000 + if showToast then + showToast("Timer: " .. timer_mode .. " seconds") + end + + if setTimeout then + setTimeout(function() + actuallyTakePhoto() + end, delay) + else + actuallyTakePhoto() + end + else + actuallyTakePhoto() + end +end + +-- Actually capture the photo +function actuallyTakePhoto() + photo_count = photo_count + 1 + print("[Camera] Photo captured! Total: " .. photo_count) + + -- Flash effect + if flash_mode == "on" or (flash_mode == "auto" and not is_front_camera) then + -- Simulate flash + end + + -- Show capture animation/feedback + local viewfinder = camera_doc:GetElementById("camera-viewfinder") + if viewfinder then + viewfinder.style["background-color"] = "#FFFFFF" + if setTimeout then + setTimeout(function() + viewfinder.style["background-color"] = "#1a1a1a" + end, 100) + end + end + + if showToast then + showToast("Photo saved") + end + + -- Update gallery preview + updateGalleryPreview() +end + +-- Start video recording +function startRecording() + print("[Camera] Starting recording...") + is_recording = true + video_duration = 0 + + updateModeDisplay() + + -- Start timer + if setInterval then + video_timer_id = setInterval(function() + video_duration = video_duration + 1 + updateRecordingTime() + end, 1000) + end + + -- Show recording indicator + local indicator = camera_doc:GetElementById("recording-indicator") + if indicator then + indicator.style.display = "flex" + end +end + +-- Stop video recording +function stopRecording() + print("[Camera] Stopping recording...") + is_recording = false + + -- Stop timer + if video_timer_id and clearInterval then + clearInterval(video_timer_id) + video_timer_id = nil + end + + updateModeDisplay() + + -- Hide recording indicator + local indicator = camera_doc:GetElementById("recording-indicator") + if indicator then + indicator.style.display = "none" + end + + if showToast then + local minutes = math.floor(video_duration / 60) + local seconds = video_duration % 60 + showToast(string.format("Video saved (%02d:%02d)", minutes, seconds)) + end + + video_duration = 0 +end + +-- Update recording time display +function updateRecordingTime() + if not camera_doc then return end + + local time_el = camera_doc:GetElementById("recording-time") + if time_el then + local minutes = math.floor(video_duration / 60) + local seconds = video_duration % 60 + time_el.inner_rml = string.format("%02d:%02d", minutes, seconds) + end +end + +-- Update gallery preview +function updateGalleryPreview() + -- In a real app, this would show the last captured photo + local preview = camera_doc:GetElementById("gallery-preview") + if preview then + preview.style["background-color"] = "#4CAF50" + end +end + +-- Open gallery +function openGallery() + print("[Camera] Opening gallery...") + if navigateTo then + navigateTo("gallery") + else + if showToast then + showToast("Gallery: " .. photo_count .. " photos") + end + end +end + +-- Open camera settings +function openCameraSettings() + print("[Camera] Opening settings...") + if showToast then + showToast("Camera settings") + end +end + +-- Handle tap to focus +function onViewfinderTap(x, y) + print("[Camera] Focus at: " .. x .. ", " .. y) + + -- Move focus indicator + local focus = camera_doc:GetElementById("focus-indicator") + if focus then + focus.style.left = x .. "px" + focus.style.top = y .. "px" + focus.style.opacity = "1" + + if setTimeout then + setTimeout(function() + focus.style.opacity = "0.8" + end, 500) + end + end +end diff --git a/base-apps/com.mosis.camera/camera.rml b/base-apps/com.mosis.camera/camera.rml index 8e8b1dc..c24a3e9 100644 --- a/base-apps/com.mosis.camera/camera.rml +++ b/base-apps/com.mosis.camera/camera.rml @@ -6,6 +6,7 @@ + Camera - +
12:30 @@ -296,13 +339,13 @@
-
+
-
+
-
+
@@ -311,7 +354,7 @@
-
+
C
Camera Preview
@@ -328,39 +371,43 @@
-
+
-
Flash: Auto
-
Timer: Off
+
Flash: Auto
+
Timer: Off
+
+
+ 00:00 +
-
-
- 1.0x -
+
+
-
+ 1.0x +
+
- Night - Portrait - Photo - Video - More + Night + Portrait + Photo + Video + More
-