Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions platform/android/template/update_manifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,18 @@ if (string.len(stringBuffer) > 0) then
end
manifestKeys.USER_SUPPORTS_SCREENS = stringBuffer

-- Add Corona activity flags if provided
-- Add Corona activity flags if provided. configChanges is pulled out
-- here and merged into the template's existing value below — the
-- template hardcodes that attribute on CoronaActivity, so emitting it
-- here too would duplicate the attribute.
stringBuffer = ""
local userConfigChanges
for settingName, settingValue in pairs(coronaActivityFlags) do
stringBuffer = stringBuffer .. 'android:' .. settingName .. '="' .. tostring(settingValue) .. '"\n'
if settingName == "configChanges" then
userConfigChanges = tostring(settingValue)
else
stringBuffer = stringBuffer .. 'android:' .. settingName .. '="' .. tostring(settingValue) .. '"\n'
end
end
-- set default (attributes can't appear multiple times)
if string.find(stringBuffer, "resizeableActivity") == nil then
Expand All @@ -795,6 +803,31 @@ end

manifestKeys.USER_CORONA_ACTIVITY_ATTRIBUTES = stringBuffer

-- Merge coronaActivityFlags.configChanges into the template's existing
-- list. Append-only with dedup — the engine never removes a flag the
-- template ships with, and apps that don't opt in get the exact same
-- manifest as before. Lets a developer add e.g.
-- coronaActivityFlags = { configChanges = "smallestScreenSize|screenLayout|uiMode" }
-- so tablet rotation rides onConfigurationChanged instead of recreating
-- the activity (which replayed the splash screen on some OEM ROMs).
local templateConfigChanges = "keyboard|keyboardHidden|navigation|screenSize|orientation"
local mergedConfigChanges = templateConfigChanges
if userConfigChanges and #userConfigChanges > 0 then
local seen = {}
for flag in string.gmatch(templateConfigChanges, "[^|]+") do
seen[flag] = true
end
for flag in string.gmatch(userConfigChanges, "[^|]+") do
if not seen[flag] then
mergedConfigChanges = mergedConfigChanges .. "|" .. flag
seen[flag] = true
end
end
end

local oldConfigChanges = 'android:configChanges="' .. templateConfigChanges .. '"'
local newConfigChanges = 'android:configChanges="' .. mergedConfigChanges .. '"'

-- Create "uses-feature" tags.

-- If the application is landscape only then we don't want the uses portrait feature since it will remove the landscape only devices
Expand Down Expand Up @@ -991,6 +1024,9 @@ end
local newManifestFileHandle = io.open( newManifestFilePath, "w" )
for line in manifestTemplateFileHandle:lines() do
local replacedLine = replace(line, manifestKeys)
if mergedConfigChanges ~= templateConfigChanges then
replacedLine = string.gsub(replacedLine, oldConfigChanges, newConfigChanges, 1)
end
newManifestFileHandle:write( replacedLine, "\n" )
end

Expand Down