fix Android: load shell.rml, add loadAppContent function, fallback to built-in apps
This commit is contained in:
@@ -385,17 +385,31 @@ function getAppColor(package_id)
|
||||
return color
|
||||
end
|
||||
|
||||
-- Built-in system apps (fallback when mosis.apps not available or empty)
|
||||
local builtin_apps = {
|
||||
{package_id = "com.mosis.browser", name = "Browser", icon = "../../icons/browser.tga"},
|
||||
{package_id = "com.mosis.camera", name = "Camera", icon = "../../icons/camera.tga"},
|
||||
{package_id = "com.mosis.contacts", name = "Contacts", icon = "../../icons/contacts.tga"},
|
||||
{package_id = "com.mosis.dialer", name = "Phone", icon = "../../icons/phone.tga"},
|
||||
{package_id = "com.mosis.messages", name = "Messages", icon = "../../icons/message.tga"},
|
||||
{package_id = "com.mosis.music", name = "Music", icon = "../../icons/music.tga"},
|
||||
{package_id = "com.mosis.settings", name = "Settings", icon = "../../icons/settings.tga"},
|
||||
{package_id = "com.mosis.store", name = "Store", icon = "../../icons/store.tga"},
|
||||
}
|
||||
|
||||
-- Populate home screen with discovered apps
|
||||
function populateHomeApps()
|
||||
if not mosis or not mosis.apps then
|
||||
print("[Shell] mosis.apps not available")
|
||||
return
|
||||
local apps = nil
|
||||
|
||||
-- Try to get installed apps from mosis.apps API
|
||||
if mosis and mosis.apps then
|
||||
apps = mosis.apps.getInstalled()
|
||||
end
|
||||
|
||||
local apps = mosis.apps.getInstalled()
|
||||
-- Fall back to built-in apps if none discovered
|
||||
if not apps or #apps == 0 then
|
||||
print("[Shell] No apps discovered")
|
||||
return
|
||||
print("[Shell] Using built-in system apps")
|
||||
apps = builtin_apps
|
||||
end
|
||||
|
||||
print("[Shell] Populating home with " .. #apps .. " apps")
|
||||
@@ -468,37 +482,48 @@ end
|
||||
|
||||
-- Launch a discovered app by package_id
|
||||
function launchDiscoveredApp(package_id)
|
||||
if not mosis or not mosis.apps then
|
||||
print("[Shell] mosis.apps not available")
|
||||
showToast("Cannot launch app", "error")
|
||||
return
|
||||
print("[Shell] Launching app: " .. package_id)
|
||||
|
||||
-- Check if it's a built-in system app
|
||||
local app_id = package_id:gsub("com.mosis.", "")
|
||||
local builtin_ids = {
|
||||
browser = true, camera = true, contacts = true, dialer = true,
|
||||
messages = true, music = true, settings = true, store = true
|
||||
}
|
||||
|
||||
if builtin_ids[app_id] then
|
||||
-- Use shellNavigateTo for built-in apps
|
||||
return shellNavigateTo(app_id)
|
||||
end
|
||||
|
||||
local apps = mosis.apps.getInstalled()
|
||||
for _, app in ipairs(apps) do
|
||||
if app.package_id == package_id then
|
||||
print("[Shell] Launching discovered app: " .. package_id)
|
||||
-- Try to find in installed apps
|
||||
if mosis and mosis.apps then
|
||||
local apps = mosis.apps.getInstalled()
|
||||
for _, app in ipairs(apps) do
|
||||
if app.package_id == package_id then
|
||||
print("[Shell] Launching installed app: " .. package_id)
|
||||
|
||||
-- Push current to history
|
||||
if current_app then
|
||||
table.insert(nav_history, {
|
||||
app_id = current_app,
|
||||
app_path = current_app_path
|
||||
})
|
||||
print("[Shell] Pushed to history: " .. current_app .. " (depth: " .. #nav_history .. ")")
|
||||
-- Push current to history
|
||||
if current_app then
|
||||
table.insert(nav_history, {
|
||||
app_id = current_app,
|
||||
app_path = current_app_path
|
||||
})
|
||||
print("[Shell] Pushed to history: " .. current_app .. " (depth: " .. #nav_history .. ")")
|
||||
end
|
||||
|
||||
-- Build content path - convert entry.rml to entry_content.rml
|
||||
local entry = app.entry_point or "main.rml"
|
||||
local content_entry = entry:gsub("%.rml$", "_content.rml")
|
||||
local content_path = "apps/" .. package_id:gsub("com.mosis.", "") .. "/" .. content_entry
|
||||
|
||||
-- Switch sandbox if available
|
||||
if switchAppSandbox then
|
||||
switchAppSandbox(package_id, app.install_path)
|
||||
end
|
||||
|
||||
return loadAppContent_internal(package_id, content_path)
|
||||
end
|
||||
|
||||
-- Build content path - convert entry.rml to entry_content.rml
|
||||
local entry = app.entry_point or "main.rml"
|
||||
local content_entry = entry:gsub("%.rml$", "_content.rml")
|
||||
local content_path = "apps/" .. package_id:gsub("com.mosis.", "") .. "/" .. content_entry
|
||||
|
||||
-- Switch sandbox if available
|
||||
if switchAppSandbox then
|
||||
switchAppSandbox(package_id, app.install_path)
|
||||
end
|
||||
|
||||
return loadAppContent_internal(package_id, content_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user