Finally fixed the scaling issues on iPad and android!
A quick explanation…
Inneractive and inMobi (but not Admob) send you content back with a viewport meta tag already present with scale = 1. I use a find/replace to change the meta name “viewport” to “viewport_dummy”. This lets you use your own viewport meta data.
Since the ads are served at 320x48 the existing meta tag you had without any scaling works fine for iPhones and iTouch devices.
For the iPad, you need to ad a scale parameter to make it scale up correctly. I calculate it from the content scaling since the type of scaling may be different for different apps.
For Android, the phone scales automatically up to a scale of 2x (thats the max). So, if the scale for the current device is > 2 you need to reduce the webpopup size accordingly. Unfortunately you can’t set the scale as you do with the iPad, as high density displays on ICS automatically set an additional scale factor.
Tested on iPad, iPhone, Android 4.0 (ICS) and Android 2.3 with admob, inMobi and inner-active
[code]
local function displayContentInWebPopup(x,y,width,height,contentHtml)
local filename = “webview.html”
local path = system.pathForFile( filename, system.TemporaryDirectory )
local fhandle = io.open(path,“w”)
– Default for iPhone/iTouch
local meta = “”
local newX = x
local newY = y
local newWidth = 320
local newHeight = 50
local scale = 1/display.contentScaleY
– Remove any existing viewpoint
contentHtml = string.gsub(contentHtml, ““viewport””, ““dummy_viewport””)
if system.getInfo( “platformName” ) == “Android” then
meta = “”
– Max scale for android is 2 (enforced above just in case), so adjust web popup if over 2.
if scale > 2 then scale = scale/2
newWidth = (width/scale) + 1
newHeight = (height/scale) + 2
newX = x + (width - newWidth)/2
newY = y + (height - newHeight)/2
end
elseif system.getInfo( “model” ) == “iPad” or system.getInfo( “model” ) == “iPad Simulator” then
meta = “”
end
local bodyStyle = “”
fhandle:write("[html]"…meta…""…bodyStyle…contentHtml…"[/html]")
io.close(fhandle)
local function webPopupListener( event )
if string.find(event.url, “file://”, 1, false) == 1 then
return true
else
system.openURL(event.url)
end
end
local options = { hasBackground=false, baseUrl=system.TemporaryDirectory, urlRequest=webPopupListener }
– native.showWebPopup( x, y, width, height, filename…"?"…os.time(), options)
native.showWebPopup( newX, newY, newWidth, newHeight, filename…"?"…os.time(), options)
webPopupVisible = true
currentWebPopupContent = contentHtml
end
[/code] [import]uid: 8872 topic_id: 22182 reply_id: 88758[/import]