8 Replies Latest reply on Jun 29, 2015 2:00 PM by Douglas Lise

    How to open numeric keyboard on page load on an Android Rhomobile app?

    Douglas Lise

      I have a rhomobile application where I need to manually open the keyboard when the user enters on a page.

      My page has an input text as the first field where the user should input a number, so the input is of number type.

      As Android OS does not allow you to use autofocus (and open the keyboard) then I needed to write a native extension to manually open the keyboard when that page is requested.

      I achieve the intent of show the soft keyboard, but I am not able to switch/choose to show the numeric keypad. It always shows the last used keyboard type.

       

      My HTML:

       

          <input type="number" autofocus="autofocus">

       

      Native extension code, called on page request:

       

          Context context = com.rhomobile.rhodes.util.ContextFactory.getUiContext();

          InputMethodManager inputMethodManager=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);

          inputMethodManager.showSoftInput(view, 0);

       

       

      I need this to work only in Android by now.

       

      Can anyone help me?

      Thanks in advance.

        • Re: How to open numeric keyboard on page load on an Android Rhomobile app?
          Bryn Cranswick

          It would be really nice to see a fix for this issue...

           

          There have been people mentioning similar Android numeric keyboard issues since 2012:

          https://groups.google.com/forum/#!msg/rhomobile/7AVy4_n6BSY/mUOCKxYLuKgJ

           

          It's pretty fundamental as it adds an extra button press on many of our workflows (switching from text->number entry).

          Our customers have commented on how they wish they could use the number soft keyboard for entering quantities, prices and discounts.

          Using the piddly number keys on the text SIP is also very frustrating.

           

          As mentioned by Douglas if you have a text input on the previous screen and move to the next screen which has a number field, the text soft keyboard launches

          instead of the numeric.

          If you are trying to enter a decimal on Android using the number keyboard, forget it. It just doesn't happen.

           

          All issues seem to be fixed when you remove " - motorola_browser" from your build.yml but then you lose all the nice -webkit styling options.

           

          Please please please get onto fixing this..

            • Re: How to open numeric keyboard on page load on an Android Rhomobile app?
              Jon Tara
              All issues seem to be fixed when you remove " - motorola_browser" from your build.yml but then you lose all the nice -webkit styling options.


              Which one(s)? The standard Android WebView uses a WebKit browser, and supports -webkit CSS options.



                • Re: How to open numeric keyboard on page load on an Android Rhomobile app?
                  Bryn Cranswick

                  Ok i'll go into detail because it's been really frustraiting and i'd love to rant it out

                   

                  This is based on using the native_browser on a TC55 running Android JellyBean 4.1.2

                   

                  When clicking on anchors you get a blue overlay that appears before the redirect. This can be fixed by adding this css: a { -webkit-tap-highlight-color: transparent; } - so far not too bad, but lets continue.

                   

                  A lot of my anchors have a css:active state that changes their colour to give the user feedback. This no longer works unless you hold the button, which is useless. Hopefully there's a way around this because you're left with the feeling "have I pressed it?"

                   

                  Borders are seriously frustrating. Anything with a 1px solid border will display horribly. The left and top may be 1px but bottom and right will be more like 2px. Only way around this seems to be using 2px solid borders which look lame.

                   

                  Responsiveness - Using the motorola_browser redirects were smooth, css transitions were smooth and the app almost felt native. The default browser jumps around and feels noticably slower (not sure if it actually is but certainly feels so with all the glitching about).

                   

                  Keyboard (SIP) - The popup keyboard no longer moves content up when it opens. A lot of things get hidden behind it so you have to press another key to get rid of it before moving on.

                  Keyboard 2 - A lot of the screens in my app use jquery to focus on the next input when the screen loads. The focus is working but the keyboard no long automatically pops up. I'll be investigating this further.

                  Keyboard 3 - When the keyboard does finally popup you're given a lovely screen consuming autocomplete/autocorrect section above the keys (this didn't happen using motorola_browser). Fix for this is to disable autocomplete in the device's settings but isn't really a viable option if your deploying to lots of customers using their own devices. Not actually sure why it didn't show this in the motorola_browser.

                   

                  That's about it really but combined (especially the responsiveness) makes the app feel a lot worse and it'd be cool to get everything perfect before taking over the world *evil laugh*

                   

                  I've noticed that that the TC70 comes stock standy with Android KitKat. Is there an upgrade available for the TC55 to go from Jellybean -> KitKat? I did a decent search this morning but couldn't dig up anything apart from Motorola/Zebra were thinking about releasing it in Feb this year.

              • Re: How to open numeric keyboard on page load on an Android Rhomobile app?
                Bryn Cranswick

                Douglas,

                 

                Have you tried using JS/Jquery to focus on the input when the document is ready? It's a good idea to add a delay (setTimeout) as it wasn't working for me without it.

                 

                $(document).ready(function() {

                       //delay by 500ms before focusing on input so that android number keypad pops up correctly

                       var input = $(".inputClassToFocusOn");

                       setTimeout(function() {

                            input.focus();

                       },500);

                  });

                  • Re: Re: How to open numeric keyboard on page load on an Android Rhomobile app?
                    Douglas Lise

                    Sorry Bryn, I haven't follow this thread and I didn't see your question.

                    I tried several forms via javascript but anyone had worked.

                    I ended up by implementing a Rhomobile Extension, that opens "manually" the keyboard, using this java code:

                    Context context = com.rhomobile.rhodes.util.ContextFactory.getUiContext(); View view = (View)com.rhomobile.rhodes.nativeview.RhoNativeViewManager.getWebViewObject(0); InputMethodManager inputMethodManager = 
                    (InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
                    inputMethodManager.showSoftInput(view, 0);

                    So in my controller I only call the ruby wrapper that triggers the extension. How the problem is only in Android so I needed to implement it only for it.

                    Unfortunately, in some android versions the keyboard that opens is the last used (possibly text).