Latest posts from Codename One.
Blog

Questions of the Week 44
This weeks release adds support for JavaScript push but I’d recommend you don’t use it in production yet… The main issue is that we might change the way JavaScript push keys are generated so it might be better to put this on hold or only experiment with this for now. Regardless it’s a pretty big change to the push server so we have the old version standing by and might revert it if things get hairy. ...

Security Section
We’ve had a lot of security related posts in the past few months as we refined many edge cases with some customers. These posts are difficult to comb thru as they are all over the place and it’s hard to get a glance of “what’s available”. So we added a new security section to the developer guide which adds some general information about Codename One security and includes most of the details about what you can do in terms of security. ...

Push on JavaScript
Up until now push notification in Codename One only worked for Android & iOS devices. This is about to change this weekend when the JavaScript port should (almost) seamlessly start working with push! This is pretty cool as push to the web is a pain with every browser taking a somewhat different route but with Codename One this will “mostly” work. The JavaScript port will generate push keys that match the notation cn1-web. ...

TIP: Lightweight Rich Text View
A very common request is support for rich text in Codename One, this is hard to do in a generic/performant cross platform way but can be done as I explained in my answer here. This is pretty common though so it might be worth it doing this in a generic way. Building a “proper” rich text view would take some work as there are many edge cases & complexities. However, since we already have an XML parser that’s perfectly capable of parsing HTML I decided to try a very simple HTML based syntax just to show how easy it would be to create something generic like this. I avoided the “link” use case as that would require some link handler code and I avoided font sizes/colors as I didn’t want to go into attributes and related complexities. ...

Questions of the Week 43
Surprisingly the big VM update we had last week didn’t trigger any major regressions but we did break some versioned build behavior with the string obfuscation feature. Todays update is far more tame and should mostly include minor bug fixes and not to many new/disruptive features. There were a lot of questions but most of them weren’t broad enough for this forum, so I’ll discuss only two questions and in both cases I’ll talk less about the question and more about the implications. ...

ToastBar Actions & URLImage Caching
I wrote on the Friday post about a few cool pull requests from Diamond but I didn’t provide a usage example for that API. Probably the best usage example is gmail style undo. If you are not a gmail user then the gmail app essentially never prompts for confirmation! It just does whatever you ask and pops a “toast message” with an option to undo. So if you clicked by mistake you have 3-4 seconds to take that back! ...

Obfuscated Constants
One of the first things a hacker will do when compromising an app is look at it. E.g. if I want to exploit a bank’s login UI I would look at the label next to the login and then search for it in the decompiled code. So if the UI has the String “enter user name and password” I can search for that. It won’t lead directly to a hack or exploit but it will show you the approximate area of the code where we should look and it makes the first step that much easier. Obfuscation helps as it removes descriptive method names but it can’t hide the Strings we use in constants. So if an app has a secret encoding it even slightly can make a difference… ...

ParparVM Optimizations: Java on iOS now 2.8x Faster
TLDR: ParparVM is now up to 2.8x faster, and produces binaries that are 15%-20% smaller than before. If you build your app for iOS today, you may notice a performance boost due to some improvements to ParparVM – the AOT compiler we use to build Codename One apps for iOS. Read on for a short history of ParparVM, as well as some details about these improvements. A Brief History Of ParparVM In the beginning, Codename One used XMLVM to build apps for iOS. It worked by converting Java byte-codes into its own XML representation, and then converting that XML into C-code. Unfortunately XMLVM was an academic project, and was announced in 2014 that development on it would be discontinued. We were faced with a choice. Do we continue to use XMLVM and simply support it ourselves, or do we migrate to something else. At the time RoboVM was an exciting new technology that compiled Java to LLVM and could produce iOS apps. I had also created a proof of concept port using Avian, an AOT compiler for Java that could produce iOS binaries. A fourth option, which seemed overly ambitious at the time, was to create our own tool from scratch. Ultimately, that is the avenue that was chosen, and ParparVM was born. ...

TIP: Use iOS CocoaPods Dependencies in Native Code
Last week I talked about using gradle dependencies to build native code, this week I’ll talk about the iOS equivalent: CocoaPods. We’ve discussed CocoaPods before but this bares repeating especially in the context of a specific cn1lib like intercom. CocoaPods allow us to add a native library dependency to iOS far more easily than Gradle. However, I did run into a caveat with target OS versioning. By default we target iOS 7.0 or newer which is supported by Intercom only for older versions of the library. Annoyingly CocoaPods seemed to work, to solve this we had to explicitly define the build hint ios.pods.platform=8.0 to force iOS 8 or newer. ...

Questions of the Week 42
This weeks update will go out a bit late or maybe even tomorrow. The reason for the postponing is the scope of the changes. We’ve made a lot of changes to ParparVM and we are very concerned that there will be regressions. So we would like this update to go in later in case we need to revert that work. Steve wrote a detailed post about the changes he made to ParparVM which we will post next week… ...

Moving to 64bit by Default
When building an iOS debug version of the app we only build a 32bit version to save build time. Otherwise the build will take almost twice as long as every file would be compiled twice. This worked well and was also fast enough. However, Apple started sending warnings to old 32bit apps and mistakes our apps as such. The crux of the issue is Apple forcing developers to support 64 bit, we already support it and have for years. But now Apple is showing a warning on apps built without 64 bit support even if they are only meant for debug. ...

Autosizing, Add All & iOS Redirects
One of the common requests we received over the years is a way to let text “fit” into the allocated space so the font will match almost exactly the width available. In some designs this is very important but it’s also very tricky. Measuring the width of a String is a surprisingly expensive operation on some OS’s. Unfortunately, there is no other way other than trial & error to find the “best size”. ...