Latest posts from Codename One.
Blog

Async Play and Pause Support
We’ve recently released a few updates to our Media APIs in order to support a wider variety of use cases. One of these upgrades is the new AsyncMedia interface, which includes async play and pause support. The Media interface has always had play() and pause() methods, but it didn’t provide an easy way to detect when they had taken effect. On most platforms, this hasn’t been a major issue because the delay between when play() is called, and when the media actually starts playing is small, or negligible. But our Javascript port presented some new challenges due to strict browser permissions surrounding media playback. In some cases, which I’ll discuss in detail in my next blog post, the user will be prompted to provide permission to play audio, or access the microphone, when play() is called. This means that the delay between play() and when the media actually starts playing may be significant. ...

Using Component Placeholders While Loading Data
In my last post I introduced the new CN.invokeWithoutBlocking() method as a means of ensuring that your UI construction code doesn’t run into any “blocking” that could negatively affect user experience. In cases where you need to perform a network request to help build your UI, I offered some recommendations for moving blocking code out of the critical paths. One recommended pattern was to insert placeholder content into your components, which you replace with the actual data once it has been received from the server. That pattern goes something like: ...

When You Cannot Afford to Block the EDT
We recently added support for disabling invokeAndBlock() for certain sections of code. The syntax is: CN.invokeWithoutBlocking(()->{ // This code is not allowed to call invokeAndBlock() }); If any attempt is made to execute invokeAndBlock() inside that block of code, it will throw a BlockingDisallowedException. This can be useful for ensuring that your UI will be responsive, especially in cases where you’re building a new form to show to the user, and any delay will be noticed by the user. ...

Updates and Expansion
I haven’t blogged in a while. I’ve been busy working with a couple of startups, some enterprise customers and bringing new people on-board. Steve has been great in picking up some of the slack but his plate is too full to blog with the same frequency I had so the blog slowed down a bit during this time. I hope to pick it back up to a weekly post regiment but my schedule is just so tight I barely have time to breath. ...

Runtime Debugging with Groovy Console
We recently added a new tool to the Codename One simulator that will allow you to run arbitrary code snippets in your app’s runtime environment. You can access it from “File” > “Groovy Console”, while your app is running in the simulator. This will open the following dialog that will allow you to execute arbitrary Groovy code: As you may suspect, you should use the Groovy programming language in this console. If you’re not familiar with Groovy, don’t worry. The language is basically just Java with some nice short-cuts. In fact, in many cases, you can probably just write Java code, and it will still work. Personally, I like the way that Groovy lets you refer to object properties via their property name, so you don’t need to use the getter or setter methods explicitly. E.g. You can do “form.title”, instead of “form.getTitle()”, to get the form’s title. The former is converted into the latter automatically for you. ...

WKWebView and PRs
We still have features to cover from our summer vacation but we need to make a short de-tour through newer things that landed recently. One of the big highlights is the switch to WKWebView. We effectively changed the default iOS browser component to WKWebView instead of UIWebView. This resolved warnings Apple started sending out to developers about using the out of date UIWebView. This mostly went unnoticed by most developers as it should. But if your browser starts acting up this is the reason. There isn’t much we can do here as we knew that day would come where Apple will demand a switch. ...

Push Cheatsheet
Push support is one of the most complicated features to set up, due to all of the red tape you have to cut through on each platform. Each platform has its own series of hurdles you have to jump through. Apple (iOS) requires you to generate push certificates. Google (Android) requries you to set up a project in Firebase console. Microsoft requires you to register your app for the Windows store. And that’s just the beginning. ...

Terse Table, Radar Chart and Networking Enhancements
This is the 3rd installment of the updates we did over the summer and so far it isn’t the last one. We have at least one more part coming in next week… Terse Table Layout TableLayout is pretty darn verbose e.g. this snippet from the TableLayout JavaDoc: cnt.add(tl.createConstraint(). horizontalSpan(2). heightPercentage(80). verticalAlign(Component.CENTER). horizontalAlign(Component.CENTER), new Label("Span H")). add(new Label("BBB")). add(tl.createConstraint(). widthPercentage(60). heightPercentage(20), new Label("CCC")); This is pretty verbose and a bit painful to write so we added shorthand methods: ...
Icon Fonts, Popups and Infinite Scroll
As I mentioned in the last post there are a lot of new features we need to go over and it will take time to cover everything. In fact this is still a partial list and there’s a lot more on the way… Easier Icon Font Integration First off Thomas submitted a PR for a few new font icon methods: Specifically in Label he added: public void setFontIcon(Font font, char c); public void setFontIcon(Font font, char c, float size); And in FontImage he added: ...

We're Back from Vacation
Summer is finally over and the kids are going back to school/kindergarten so it’s time to go back to our regularly scheduled posts. I won’t be posting as often as before as I’ll dedicate more time for support/development activities but still there’s a lot to write about… During our time off we had a lot of changes, I’ll repeat a few big ones which you might have run into already and cover a few that might have gone under the radar. ...

Summer Vacation
You might have noticed we’ve been a bit slow with updates over the past couple of weeks as we’re dealing with a bit of a backlog. With the kids on holiday from school it’s harder to keep up not to mention our travel plans for the summer. As such we’re officially in summer vacation until September. During this time we won’t update the blog as that takes a bit too much. We will probably have Friday releases if warranted but this depends on commits. It will take us longer to evaluate some issues but we’ll still try to respond to everyone in a reasonable timeframe. Pro and enterprise support might be impacted as well due to personnel availability but should still provide fast response turnaround. ...

Post Message
BrowserComponent is a pretty powerful tool when you just want to integrate HTML into your application. We use it a lot in native apps, but surprisingly it’s just as useful when we compile an app as a web application. It lets us embed HTML into the web application. But there’s a big caveat known as SOP when we do that. SOP and CORS SOP is the “Same Origin Policy” enforced by browsers. It’s prevents CSRF (Cross Site Request Forgery) which essentially lets a site pretend it’s a different site. ...