Jason Vertucio

You know me! ™

Another reason why I hate Android

Screen Shot 2013-09-16 at 14.20.20

I’m sitting here at work wondering why this Mobile Framework that I’m developing works flawlessly on my iOS Simulator and on my iPhones and iPad, but literally doesn’t even have my stylesheets on Android.

Turns out—ready for this?

Turns out that I stash my framework in a folder called _framework. And you’ll never guess which folder of files wasn’t reading!

Seriously. Everyone goes on and on about how Android is better than the mobile Apple OS.

  1. I hate programming for every splintered version out there (over 30% are still running such an obsolete, two versions ago version of Android)
  2. I hate that I literally wasted three hours trying to figure out that when I renamed _framework to framework everything worked fine! IT DIDN’T WORK BECAUSE OF A STUPID UNDERSCORE. AND NOW IT WORKS.
  3. Actually, that’s a lie. Because now I’m getting errors with DOM elements not being found, even though there they are in my Chrome Desktop environment, and also on all the iOS devices!!!!!!!

/rant

iOS, I love you. I love you because you take the time to be as stable as possible. You run on, at most, six different devices.  And people don’t say of you, “Just don’t upgrade the OS.” And I love you because when I program something for you, I don’t have to worry about you not working.

For all interested, once I’ve had a successful deployment of this MOB Framework, I will release it. Maybe you’ll try it out. Maybe you’ll love it.

Mobile Web Apps, making the keyboard disappear

code
So, just for fun, I decided to make a little mobile web app to change from Fahrenheit to Celsius (of vice versa in case you needed that instead). But there were two problems with it.

(a) if I hit BACKSPACE, it wouldn’t update the converted temperature
(b) couldn’t get the keyboard to disappear
(c) oops, also had a problem with disappearing zeroes at the end of the number.

Well, (c) was easy. My RegEx was wrong. (a) was also pretty easy, once I found out about the new html5 input event (keypress was not reading BACKSPACES on my iPhone). But (b). Oh, that nasty (b)!

Stack Overflow had this same question, and a user linked to this blog and the long and short of it is

  1. var hideKeyboard = function(ev) {
  2.   // Don't actually hide the keyboard if we are on the INPUT
  3.   if ( ev.target.tagName === 'INPUT' ) return;
  4.  
  5.   document.activeElement.blur();
  6. }

Now this would be fine and dandy except where do you call the function?! I quickly determined that in my app, which is just a single-page thing, I could safely put the listener on the window itself.

  1. window.addEventListener('touchstart',hideKeyboard);

This code will only remove the keyboard when the active element is an INPUT. For some reason it doesn’t work on textareas. But the solution is to blur all inputs at the same time. I’m not doing it because my amp is simple enough to skip that step.

This bit of code was an immense help to me, and I hope it ends up being an immense help to you, as well!