Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

My input text is cut off halfway on some Android devices!! PLS HELP!
Started by Lava Level Feb 03 2013 03:22 AM

- - - - -
100 replies to this topic
[TOPIC CONTROLS]
Page 2 of 5 1 2 3 4 »
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

jack95

[GLOBAL: userInfoPane.html]
jack95
  • Contributor

  • 197 posts
  • Corona SDK

All of these "fixed" are workarounds for broken textfield components. This is a rather well-known problem I heard about before I even downloaded the sdk.



[TOPIC: post.html]
#27

Anderoth

[GLOBAL: userInfoPane.html]
Anderoth
  • Contributor

  • 278 posts
  • Corona SDK

This is a problem with Android and if you search on Google you will find a 100 different hacks in native code to try and deal with it. I do not know if any of them deal with it correctly or how much research Corona devs have put into testing them to get a good Corona'sized solution. I do know handling it now in Corona is a ridiculous pain or at least my initial work into it was.

 

In the end I had to use a brute force method. By testing and retesting on every device size and dpi available to me I came up with a number to adjust the text size to fit the textbox's height on whichever device it is currently loaded on. It's a horrible hack and has not been tested in a released app yet.

 

What blows my mind is that the OS doesn't handle this on it's own somehow. If the text is too tall for the textbox, the textbox should resize to fit, regardless of what the programmer has set the size to be. Also if no font size is put at all it should auto-size the text to fit the padding of the textbox on it's own. I can think of no circumstance where anyone would want to put text in a textbox that is cut off.



[TOPIC: post.html]
#28

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,072 posts
  • Enterprise

It worked for me:

local fontSize = 12 / display.contentScaleY

print(fontSize)
print(display.contentScaleY)

    local yearIF = native.newTextField( (display.contentWidth / 2), 180, (display.contentWidth*0.45), 35)
    yearIF.font = native.newFont( native.systemFont, _G.fontSize )
    yearIF.size = fontSize
    yearIF.text = ""
    yearIF:setTextColor( 81, 81, 81 )
    yearIF.inputType = "number"

 

It printed:

I/Corona  (28615): 25.457746386707
I/Corona  (28615): 0.47136929631233

 

and here is what I got:

android.png

 

This was on my Google Nexus 7.  The config.lua for this test was:

 

    application =
    {
        content =
        {
            width = 320,
            height = 568,
            scale = "letterBox",
            --xAlign = "center",
            --yAlign = "center",
            imageSuffix =
            {
                ["@2x"] = 1.5,
                ["@4x"] = 3.0,
            },
        },
    }

 

For fun, I did the test with the config.lua in the Ultimate Config.lua and it produced the same thing.



[TOPIC: post.html]
#29

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

@Anderoth yeah it is a big problem for us .. 

@Rob hmm I am currently having a problem for those devices that have a resolution of 320x480 below ( especially 240x320 ) . In what resolution did you tested it on?



[TOPIC: post.html]
#30

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,072 posts
  • Enterprise

@09.SemperFidelis, what is your config.lua like?  What is your code where you are creating the native text field?  What device are you using?  What version of Corona SDK?



[TOPIC: post.html]
#31

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

Hi Rob! I already posted my config.lua, textfield code, and test-device in this thread. Hmm my Corona version is 2013.1076. Is that the correct version code?
I found a little solution for my problem: 

in my main.lua I have this little code:

_G.fontSize = 12 / display.contentScaleY

if display.pixelWidth <= 240 and display.pixelHeight <= 320 then
    _G.fieldSize = 40
elseif display.pixelWidth <= 320 and display.pixelHeight <= 480 then
    _G.fieldSize = 37
elseif display.pixelWidth <= 480 and display.pixelHeight <= 800 then
    _G.fieldSize = 34
else
    _G.fieldSize = 30
end

and for my native text field(s):
 

	yearIF = native.newTextField( (display.contentWidth / 2), 190, (display.contentWidth*0.45),  _G.fieldSize)
	yearIF.font = native.newFont( native.systemFont,  _G.fontSize )
	yearIF.size =  _G.fontSize
	yearIF.text = ""
	yearIF:setTextColor( 81, 81, 81 )
	yearIF.inputType = "number"
	yearIF:addEventListener( "userInput", fieldHandler )

-- But I still have a little problem on the 240x320 device resolutions..



[TOPIC: post.html]
#32

TandG

[GLOBAL: userInfoPane.html]
TandG
  • Contributor

  • 422 posts
  • Corona SDK

For Android devices why don't you do something like the following:

 

    local textBoxScale = 1
    local textBoxFontSize = 16
    local widthIn = system.getInfo( "androidDisplayWidthInInches" ) 
    local heightIn = system.getInfo( "androidDisplayHeightInInches" ) 
 
    --Make sure its not nil... e.g. the simulator will return nil.
    if widthIn ~= nil and heightIn ~= nil then 
        local diagIn = math.sqrt((widthIn*widthIn)+(heightIn*heightIn))  --Diagonal in inches
        textBoxScale = diagIn/3.5   --3.5 is the iphones diagonal in inches..
    else
        textBoxScale = 4/3.5  --Default to a 4 inch diagonal.
    end
    textBoxFontSize = textBoxFontSize*textBoxScale

 

Some Android devices don't actually give you the correct width and height, but you can run extra checks against the  device name to do those manually. I haven't actually tested the exact code above, but if your using letterBox and 480x320 in config then i don't see why it wouldn't work :)

 

 

 

[Edit]

ps. I forgot to mention that changing the font size based off the contentScaleY variable will not work in a lot of cases if your using a plain config with scaling and a size of 480x320. For example without any changes to the font size it will fit on both the iPhone3GS and the iPhone4 perfectly despite the latter having twice the pixel resolution. If your using the contentScale to base your font size off and not the diagonal in inches, your iPhone4 text would be twice the size as a iPhone3GS. Therefore using the actual inches of the device is the way to go in my opinion. I've just started setting up a more advanced version of the above in my code so i'll test it on multiple devices to see how it goes!



[TOPIC: post.html]
#33

krystian6

[GLOBAL: userInfoPane.html]
krystian6
  • Contributor

  • 560 posts
  • Corona SDK

If you want, I've got few devices with different resolutions I could test that for you [both tablets and phones], just send me links to your test apks in private messages.



[TOPIC: post.html]
#34

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

@TandG -- thanks a lot bro! I'll try your code!
@krystian6 -- thanks! but I can test my apk into different resolutions with our Nexus 7 :)



[TOPIC: post.html]
#35

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK


@krystian6 -- thanks! but I can test my apk into different resolutions with our Nexus 7 :)

Are you changing the nexus 7 resolution some how?



[TOPIC: post.html]
#36

fkaktos

[GLOBAL: userInfoPane.html]
fkaktos
  • Enthusiast

  • 53 posts
  • Corona SDK

I have the same problem on Galaxy, Xperia, Optimus LG. The text is cut off.

It works perfectly on my Nexus 7.

 

Any help?

 

my code

 

local fontSize = 12 / display.contentScaleY



myField = native.newTextField( 215, 48, 141, 27)
myField.hasBackground=false
myField.font = native.newFont( "GROBOLD", _G.fontSize )
myField.size = _G.fontSize
myField:setTextColor( 67, 25, 24 )   
myField.align = "center"

my config.lua:

 

 

application = {
    content = {
        width = 320,
        height = 480, 
        scale = "zoomStretch",

        
        
        imageSuffix =
        {
            ["@1-5"] = 1.5, 
            ["@2x"]  = 2,   
            ["@3x"]  = 3,   
            ["@4x"]  = 4,   
        },
        
    },

	license =
	{
		google =
		{
			key = "Your key here"
		},
	},
}


[TOPIC: post.html]
#37

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

I think TandG basically got it, for android.

 

To be specific, "point size" is defined as equal to 0.376mm (almost universal standard). This is a real size - based on the device your app is running on. This means a *native* point size of about 67 should be one inch tall (giant, from an input field standpoint) on any device, if implemented properly.

 

Simply mapping the contentScale does not take into account the devices physical size, as TandG pointed out. As T said (may I call you that, T?), one device (4 inches tall) could be 320x480, and another (also 4 inches tall) could be 640x960 ) as is the case with the 3gs and 4S on the iOS side - which causes a factor of 2 to be needed there...)

 

On the android side, at least for some OS versions, there are the system info values he pointed out. (But I think there's an error in his calc, see below code). It would be helpful to know what Droid OS levels will give back that info (and to get it on iOS somehow, even if it be through hard wiring it into the SDK for known iOS platforms, since they are so few).

 

One important change to TandG's code is to remove his triangle code and just make it a straight up a font height scaler, which from my first tests seems to work well.

 

    if( utils.isAndroid == true ) then      -- try and get the real width / height and deal with it            
        print(" -- -- Android font size calc...")
        local fontScale = 1
        local widthIn = system.getInfo( "androidDisplayWidthInInches" )
        local heightIn = system.getInfo( "androidDisplayHeightInInches" )
     
        --Make sure its not nil... e.g. the simulator will return nil.
        if widthIn ~= nil and heightIn ~= nil then

            -- heightIn is height of actual droid app is running on

            fontScale =  heightIn / 3.5        -- 3.5 is height of original iOS device, we are mapping to based on our original asset sizes / font sizes
            print(" -- widthIn = ", widthIn)
            print(" -- heightIn = ", heightIn)
            print(" fontScale == ", fontScale)
       else
           print(" -- unable to retrieve screen width, height ... defaulting to deprecated scale algorithm")
       end
 
        inputFontSize = targetFontSize*fontScale  -- targetFontSize is something like 20, a typical iPhone type point size
        -- inputFontSize is the native font size to use for Corona native text .creation / .size field
    end

 

Well, that's my two cents anyways.



[TOPIC: post.html]
#38

TandG

[GLOBAL: userInfoPane.html]
TandG
  • Contributor

  • 422 posts
  • Corona SDK

T is fine by me :)

 

Luckily adding iOS devices into the above is nice and easy as theres only 4 different screen sizes. Android on the other hand still has some problems...

 

From doing some testing it seems that some Android phones don't send back accurate width and height variables. Therefore we need to somehow get around that issue... One way would be to run specific device checks to override diagIn e.g:

if device == "GT-I8160" then diagIn = 5.2
elseif device == "GT-I8190" or device == "GT-I8730" then diagIn = 4      --S3 MINI.
 
The problem with that is theres probably a large amount of devices out there that will send back inaccurate information, and finding which devices they are will be hard. Maybe we can run checks with the expected dpi against the actual dpi to see if theres too big a difference? I'm not sure yet but i'll look into it. 


[TOPIC: post.html]
#39

krystian6

[GLOBAL: userInfoPane.html]
krystian6
  • Contributor

  • 560 posts
  • Corona SDK

When I was using cocos2d I ran into similar issues. Text fields would differ on Android and iOS.

 

What I did was:

- I've created a text input field

- Covered it with my own custom text input field

 

When user tapped on my custom text input field, the native one took over and displayed keyboard etc. When typing I took over the input and displayed it in my custom text field.

 

I know it sounds like a lot of hassle, but good luck creating if statement for over 2000 android devices [because the fact that a device sends correct values now, doesn't mean it won't stop with next os update/on a different rom].

 

The only downside is that text selection is a ***** and it would be easier to just drop support for it than to try to handle it.

 

I'm not entirely sure this is 100% possible with Corona, like I've said I did it with cocos and I could access any native functionality I wanted, but it seems like a workaround.



[TOPIC: post.html]
#40

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

T, it's just the device screen height in inches that's needed, not DPI.

 

The reason is that when we set a point size, say 20, we are asking for a font that is 7.52 mm tall -- for the device we are targeting (what our contentScale is set for, and all our assets are sized for). If your content scale is 320x480 or 640x960, you are likely targeting a standard iphone, whos screen is 3.5 inches tall.

 

I'm curious as to how bad the height reporting is on android. Is it just lesser brands, or, as is hinted in your post, major brands like the Samsung S3 (hinted at in your post).

 

Is it like 5% of android phones report the wrong screen height, or more like 25%? Off brand, or mainstream phones? Any idea?

 

Also, I started putting together code to deal with this, starting with cleaning up my iOS side (the old methods use display.contentScaleX and have problems dealing with 3gs vs 4, etc)... At this point, my iOS side looks like this (stole a little detection code from a BeyondtheTech forum post).

 

        print(" -- -- iOS font size calc...")
        local fontScale = 1
        local heightIn = 3.5        -- default to stnadard iPhone size        
        
        if( sysType == "iPhone2,1" ) then       -- 3GS        
            heightIn = 3.5
            print(" -- iPhone 3GS detected")        
        elseif( string.match(sysType, "iPhone3") or string.match(sysType, "iPhone4") ) then       -- iPhone 4, 4S        
            heightIn = 3.5
            print(" -- iPhone 4 detected")        
        elseif sysType == "iPad2,5" or sysType == "iPad2,6" or sysType == "iPad2,7" or sysType == "iPad2,8" then    -- 2,8 is unknown, just a guess at next mini #
            heightIn = 6.25                    -- mini
            print(" -- iPad mini detected")        
        elseif( string.match(sysType, "iPad") ) then       -- standard iPad
            heightIn = 7.75                
            print(" -- iPad detected")        
        else
            print(" -- unrecognized iOS device, using default 3.5 inches tall") -- iPods will fall to here, they are 3.5 anyways...
        end
        fontScale =  heightIn / 3.5 -- 3.5 is actual iPhone height
        inputFontSize = targetFontSize*fontScale            -- inputFontSize is point size to use in native call
 
 

 

Only got to test it on my iPad (retina) so far, but the calculated font size appears to be dead on. Also, note that the heightIn used is the straight up and down (NOT diagonal) height of the screen - as this is what the point size relates to (direct, vertical height, not diagonal).

 

Edit: oh snap, the actual height of 3gs, 4, 4s, etc is 3 inches.. Seems to work with diag height of 3.5, but the numbers aren't quite perfect... Hmmm.

 

OK, I think I understand the issue (3 inches vs. 3.5..). I think 3 is the correct value to calc the proper point size - however, there is an additional source of error I realized that needs to be considered.

 

When you use content scaling, the SDK will try and fill the device space as best it can with your app. This can leave empty space above or below (or to the sides, which aren't a concern for the font calc).

 

What this means is that the app might be mapped onto just 3 inches of the device. Not a problem on the 3gs, 4, or 4s. But the iPhone 5 is taller.

 

To deal with it, corona chops off a little on the top and bottom, making the effective area for your app 3 inches tall. Using the straight up real height of the iphone 5 would throw the calc off (as the sdk has already chopped the effective height being mapped onto).

 

This same issue, the space the content scaling throws away above/below the app would also need to be factored in on the droid side as well.



[TOPIC: post.html]
#41

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

OK T, I think I got it. I only have an iPad retina and a motorola atrix to test on, but the font size looks identical (scaled I mean, irl the ipad font is much larger because it's scaled up like my other content).

 

But the font really does look identical on these devices. I have plugged in screen height numbers for the other iOS devices which I think are correct, but I'll have to test on the devices.

 

For droid, it retrieves the screen height as in your post above, and uses that to do the calc. The code also compensates for corona chopping off the top and bottom of the screen to map the virtual content into. Only seen that code execute on my droid atrix, and it seems to be right, but I'll need to try it on some other devices to make sure all my add/subtract stuff is correct. Font size looks perfect (relative to my other content) on my atrix though (identical to how it appears on my retina ipad).

 

    print(" -- calcFontSize()")
    print("-----------------------" )    
            
    local sysType = system.getInfo("architectureInfo")
    print(" -- sysType == ", sysType)            
    print(" -- display.contentScaleY  == ", display.contentScaleY )
    print(" -- display.screenOriginY  == ", display.screenOriginY )          
    
    inputFontSize = targetFontSize / display.contentScaleY    -- old method is fallback (ends up being sim setting)
    
    if( utils.isAndroid == true ) then      -- try and get the real width / height and deal with it            
        print(" -- -- Android font size calc...")
        
        local missingInches = display.screenOriginY * -2     -- account for both top and bottom area (x2), and change the sign sign since originY is always negative, if it exists...
        
        missingInches = missingInches / 320             -- 320 is 1 inch, in my 640x960 virual content space (960 == 3 inches for my app, designed for a standard iphone 4 display)        
                                                        -- different contentScale sizes will use a different virtual pixel / inch value (eg, 320x480 virtual content = missingInches / 160)
        print(" -- missing inches == ", missingInches)
        
        local fontScale = 1
        local heightIn = system.getInfo( "androidDisplayHeightInInches" )
        local widthIn = system.getInfo( "androidDisplayWidthInInches" )
        print(" -- original height == ", heightIn)
        
        heightIn = heightIn - missingInches               
     
        --Make sure its not nil... e.g. the simulator will return nil, perhaps some bad devices will too...
        if heightIn ~= nil then
            -- heightIn is height of actual droid app is running on
            fontScale =  heightIn / 3.0 -- 3.0 is actual iPhone 3gs /4 /4s height
            print(" -- fontsize set on actual droid screen inch height")
            print(" -- widthIn = ", widthIn)
            print(" -- heightIn = ", heightIn)
        else
            fontScale = 4/3  --Default to a 4 inch diagonal (iphone is 3.0)
            print(" -- fontsize set to 4 inch phone size")
        end
        
        print(" fontScale == ", fontScale)
        inputFontSize = targetFontSize*fontScale            
    else                                    -- else is iOS
        print(" -- -- iOS font size calc...")
        local fontScale = 1
        local heightIn = 3                                  -- default to stnadard iPhone size        
        local missingInches = display.screenOriginY * -2    -- account for both top and bottom area (x2), and change the sign sign originY is negative, if it exists...
        
        missingInches = missingInches / 320             -- 320 is 1 inch, in my 640x960 virual content space (960 == 3 inches for my app, designed for a standard iphone 4 display)
                                                        -- different contentScale sizes will use a different virtual pixel / inch value (eg, 320x480 virtual content = missingInches / 160)        
        print(" -- missing inches == ", missingInches)
        --
        -- Since there is no corona facility to get the screen height of the device on iOS, we'll determine it ourselves.
        --
        if( sysType == "iPhone2,1" ) then       -- 3GS        
            heightIn = 3.0 - missingInches      -- original iPhone size
            print(" -- iPhone 3GS detected")        
        elseif( string.match(sysType, "iPhone3") or string.match(sysType, "iPhone4") ) then       -- iPhone 4, 4S        
            heightIn = 3.0 - missingInches      -- Same size as the old 3gs- better resolution, but same size
            print(" -- iPhone 4 detected")        
        elseif( string.match(sysType, "iPhone5")  ) then       -- iPhone 5
            heightIn = 4.0 - missingInches      -- Should go back to 3, after missing inches chopped off by corona are deducted.
            print(" -- iPhone 5 detected")      -- This phones screen is taller, a little... Corona will end up chopping it off though
        elseif sysType == "iPad2,5" or sysType == "iPad2,6" or sysType == "iPad2,7" or sysType == "iPad2,8" then    -- 2,8 is unknown, just a guess at next mini #
            heightIn = 6.25 - missingInches     -- mini
            print(" -- iPad mini detected")     -- A good amount taller. Need a much bigger point size for this device, for the input fonts to look scaled right     
        elseif( string.match(sysType, "iPad") ) then       -- standard iPad
            heightIn = 7.75 - missingInches     -- iPad
            print(" -- iPad detected")          -- MUCH taller screen, really gonna need to scale fonts up in point size for this bad boy (or they will look less than half size for the field)
        else
            print(" -- unrecognized iOS device, using default 3.5 inches tall") -- iPods will fall to here, they are 3.5 anyways...
            if( missingInches == 0 ) then
                -- iPod falls through to here (and it is 3 inches tall, and any missing inches accounted for in a tall version, so that works for now)
                heightIn = 3.0 - missingInches  -- I would hope this is typical, zero extra on an unknown ios device
            else
                heightIn = 4.0 - missingInches  -- otherwise, we'll take a flying guess that the unknown device is bigger than a tiny breadbox, and smaller than a car. (4 inches tall, iphone 5 format)
            end
        end        
        fontScale =  heightIn / 3.0                 -- 3.0 inches is actual iPhone 4 height (that my content is based on)
        inputFontSize = targetFontSize*fontScale            
    end
                
    print(" -- final fontsize == ", inputFontSize)
    print("-----------------------" )    

    return inputFontSize

 

So the big question to me is, are there many droid devices actually reporting the *wrong* height. If so, then this might not work out. If, however, they are returning the right height (but it was being used as if it were diagonal height, or some other mistake), then this should work mint.



[TOPIC: post.html]
#42

TandG

[GLOBAL: userInfoPane.html]
TandG
  • Contributor

  • 422 posts
  • Corona SDK

In regards to dpi, i meant that phones reporting the incorrect width and height may also return the incorrect dpi. Therefore you could check the actual versus reported dpi to see if you need to consider that phone as "dodgy".  If they are wildly different you know that the calculations your doing above won't be correct for that phone and that you should go back to the default 4 inch height. I'll need to test that on a few devices to see if theres anything to it though..

 

You codes looking good! I'll give that a go shortly. This may be me being a little stupid, but why exactly do you need to calculate the missing height when you are already setting the height in inches to the correct value? 

 

And finally when it comes to Android devices i'm afraid there probably is a fair few who give the wrong height. My Samsung S3 mini i use for testing does, my clients Galaxy Ace (i think thats the one) does and also his Droid Razr. Considering we only have about 7 Android devices between us three of them being wrong is a pretty considerable percentage. All of those devices return the wrong height and width which was throwing off my original diagonal calculation. Therefore some kind of validation check for each device would be handy, maybe the dpi check may work but i'm hoping theres some more options to try out as well. 



[TOPIC: post.html]
#43

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

Heya T,

 

missingInches represents the amount in the borders above and below the app, the little apron corona makes above and below your app. When you use content scaling, corona determines if the device aspect ratio is the same as your and of not, maps your app inside - leaving that area unused (as you know, I'm sure).

 

So now, your app is mapped to a smaller height than the entire screen. To calculate the correct (and proportionally accurate) font size for this smaller area (smaller inches), a reduction needs to be made (called missing inches). If this is not removed, the font will be a little too large (it would be calculated as if the app were stretched to the whole screen without this reduction.) Hope that all makes sense.

 

Thanks for the tip on DPI, I'll look into it. Also, curious as to what specific incorrect values you have seen, as in - what specifically did it report the height of the S3, Galaxy Ace, and / or droid razr report?



[TOPIC: post.html]
#44

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

Are you changing the nexus 7 resolution some how?

yes! using some command prompt thingy while connected on my device. For example: 
 

adb shell am display-size 320x480
adb shell am display-density 165

Well first, I think you need Android SDK and NDK running in your computer. And just a reminder, this is only a simulation, results may vary in an actual device with that resolution,

@TandG , @mpappas
As a very young developer, Ive learned a lot from you guys. Thanks a lot! 
By the way, I am receiving an error on:

local heightIn = system.getInfo( "androidDisplayHeightInInches" )

as well as on widthIn. They are returning nil in my device. Any ideas?



[TOPIC: post.html]
#45

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

@09.SemperFidelis - Thanks for the props!

 

What device is returning the nil? Specifically, what model and Android OS version is it?



[TOPIC: post.html]
#46

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

Where there any issues from Apple review team for those that have done the solution where the real input input is hidden and using a rect as a "fake" input? Seeing that the text is not selectable and it may not look exactly native. 



[TOPIC: post.html]
#47

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

@mpappas - Nexus 7, Android 4.2.2. Thanks for the response.
@jonjonsson - yep bro its another workaround for this but it is not that user-friendly in my opinion. 



[TOPIC: post.html]
#48

mpappas

[GLOBAL: userInfoPane.html]
mpappas
  • Contributor

  • 527 posts
  • Enterprise

@Fidelis - I tested today on a new nexus 7 running 4.2.2 and it works... I'm using the daily builds, but I thought that functionality was in the last public release too... Maybe it is related to your changing screen resolutions on the nexus 7 (using adb?).



[TOPIC: post.html]
#49

Fidelis

[GLOBAL: userInfoPane.html]
Fidelis
  • Enthusiast

  • 30 posts
  • Corona SDK

@mpappas - I realized Im using the previous version of Corona. I downloaded the latest public release and it works! thanks a lot!



[TOPIC: post.html]
#50

searchm

[GLOBAL: userInfoPane.html]
searchm
  • Contributor

  • 187 posts
  • Corona SDK

Thanks for the good work!

 

so I sum this up,

 

I got this in my main view:

 

local fieldSize, fontSize

if android() == true then

  fontSize = getAndroidFontSize(18)

  fieldSize = 25 / display.contentScaleY

else

  fontSize = 18
  fieldSize = 25

end


url_textfield = native.newTextField( 28, 219, 180, fieldSize)
url_textfield.font = native.newFont( "Arial",  fontSize )
url_textfield.size =  fontSize
url_textfield.text = ""
url_textfield.inputType = "url"
url_textfield.hasBackground = false
url_textfield:addEventListener( "userInput", input_listener )

 

and Mpappas routine as a function:

 


function getAndroidFontSize(targetFontSize)


        print(" -- calcFontSize()")
        print("-----------------------" )    
                
        local sysType = system.getInfo("architectureInfo")
        print(" -- sysType == ", sysType)            
        print(" -- display.contentScaleY  == ", display.contentScaleY )
        print(" -- display.screenOriginY  == ", display.screenOriginY )          
        
        inputFontSize = targetFontSize / display.contentScaleY    -- old method is fallback (ends up being sim setting)
        
        if android() == true then      -- try and get the real width / height and deal with it            
            print(" -- -- Android font size calc...")
            
            local missingInches = display.screenOriginY * -2     -- account for both top and bottom area (x2), and change the sign sign since originY is always negative, if it exists...
            
            missingInches = missingInches / 320             -- 320 is 1 inch, in my 640x960 virual content space (960 == 3 inches for my app, designed for a standard iphone 4 display)        
                                                            -- different contentScale sizes will use a different virtual pixel / inch value (eg, 320x480 virtual content = missingInches / 160)
            print(" -- missing inches == ", missingInches)
            
            local fontScale = 1
            local heightIn = system.getInfo( "androidDisplayHeightInInches" )
            local widthIn = system.getInfo( "androidDisplayWidthInInches" )
            print(" -- original height == ", heightIn)
            
            heightIn = heightIn - missingInches               
         
            --Make sure its not nil... e.g. the simulator will return nil, perhaps some bad devices will too...
            if heightIn ~= nil then
                -- heightIn is height of actual droid app is running on
                fontScale =  heightIn / 3.0 -- 3.0 is actual iPhone 3gs /4 /4s height
                print(" -- fontsize set on actual droid screen inch height")
                print(" -- widthIn = ", widthIn)
                print(" -- heightIn = ", heightIn)
            else
                fontScale = 4/3  --Default to a 4 inch diagonal (iphone is 3.0)
                print(" -- fontsize set to 4 inch phone size")
            end
            
            print(" fontScale == ", fontScale)
            inputFontSize = targetFontSize*fontScale            
        

        end

        return inputFontSize

end

this works fine on my samsung galaxy I

 

I removed the iOS part because on iOS it just works fine the way it is.

 

Is this correct? Can someone confirm?




[topic_controls]
Page 2 of 5 1 2 3 4 »
 
[/topic_controls]