Hi,
I have an application which I want to look different on a desktop then on a mobile device, because a mobile device is usually held in your hand closer to your eyes, seen from a short distance, and you can have smaller UI components and text, but a desktop is sitting on your table, and you are sitting next to it, looking at it from a longer distance then a mobile device, as it is usually bigger, so the UI elements and font size of the text should be bigger.
With the help of members on this forum I did find how you can make the UI elements look bigger, by using RuntimeDPIProvider, but now the question is how can I set a condition that will give different runtimeDPI to different screen sizes?
Most examples of classes that extend the RuntimeDPIProvaider only take in consideration the Capabilities.screenDPI, including the original class in the Air SDK, but I want to have a different DPI for different screen sizes, which are probably made for a desktop. How do I do this?
Bellow is an example of a class that is taking in consideration not only the dpi but also the number of pixels of the screen, but I don't really understand the calculation it makes. I can't just use it as it is, because on my computer screen it has no effect, because I didn't set a very high resolution, my screen is only 1600 x 900, so I need to change the formula. I would appreciate any ideas on how I can determine the real size of a screen in inches?
Capabilities.screenResolutionX/Y doesn't help me because resolution of the screen can be changed, the same screen size can have many resolutions, and the Capabilities.screenDPI is not changing when I set a higher resolution on my screen, so how can I know the real size of the screen?
`package classes {
import flash.system.Capabilities;
import mx.core.DPIClassification;
import mx.core.RuntimeDPIProvider;
public class CustomDPIProvider extends RuntimeDPIProvider
{
public function CustomDPIProvider () {
}
override public function get runtimeDPI():Number
{
var screenX:Number = Capabilities.screenResolutionX;
var screenY:Number = Capabilities.screenResolutionY;
var pixelCheck:Number = screenX * screenY;
var pixels:Number = (screenX*screenX) + (screenY*screenY);
var screenSize:Number = Math.sqrt(pixels)/Capabilities.screenDPI;
trace("screenSize: " + screenSize + " - " + Capabilities.screenDPI + " - " + screenX +"/"+screenY + " - " + pixelCheck);
if (screenSize > 4.3 && pixelCheck > 510000 && pixelCheck < 610000 &&
Capabilities.screenDPI < 240 && pixelCheck != 1296000)
{
//trace("Force 240");
return DPIClassification.DPI_240;
}
else if (screenSize > 6.9 && screenSize < 11 && pixelCheck > 610000 && pixelCheck < 1920000 && pixelCheck != 1296000)
{
//trace("Force 240 Tablet");
return DPIClassification.DPI_240;
}
if (Capabilities.screenDPI < 200)
return DPIClassification.DPI_160;
if (Capabilities.screenDPI <= 280)
return DPIClassification.DPI_240;
return DPIClassification.DPI_320;
}
}
}`