Latest posts from Codename One.
Blog

In the Shadow
Diamond asked us about an easy way to do dropshadows in Codename One to which I answered that it’s pretty easy thanks to our Gaussian blur support… We ended up with this code which is usable but probably not as intuitive for most: Form hi = new Form("Drop Shadow", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER)); FontImage mm = FontImage.createMaterial(FontImage.MATERIAL_PERSON, "Button", 30); int[] rgb = mm.toImage().getRGB(); for(int iter = 0 ; iter < rgb.length ; iter++) { rgb[iter] = rgb[iter] & 0xff000000; } Image shadow = Image.createImage(rgb, mm.getWidth(), mm.getHeight()); if(Display.getInstance().isGaussianBlurSupported()) { shadow = Display.getInstance().gaussianBlurImage(shadow, 10); } Label top = new Label(mm, "Container"); Label bottom = new Label(shadow, "Container"); bottom.getAllStyles().setMargin(1, 0, 1, 0); bottom.getAllStyles().setMarginUnit(Style.UNIT_TYPE_DIPS); hi.add(BorderLayout.CENTER, LayeredLayout.encloseIn(bottom, top)); hi.show(); The effect is attractive and commonplace so I think it would be great to add it universally so we added two methods which will be a part of the coming update. These methods are in the Effects class and are both simple utility methods. Once creates a shadow and incorporates it into a new image at the given location. The other returns the shadow alone which you can shift/position as you see fit (e.g. if you have similarly shaped images this might also be useful in terms of CPU/RAM). ...

Questions of the Week XX
We will make another attempt to migrate to the new xcode 7.x build servers this Sunday. This might introduce some disruptions to your iOS builds but those should be fixable. One of the stackoverflow discussions below sparked an interesting group discussion about improving the UI design of a Codename One app. If you feel your app could use a design/UX improvement feel free to post it to the forum. We are no substitute to a proper UX/UI designer but having worked on a lot of apps we might be able to help a bit with some feedback/ideas. ...

Performance True Story
We had almost everything ready for the release of the kitchen sink demo this week until one of our fixes broke the build and we couldn’t get everything out in time. It’s disappointing but this means one more week to refine the demo. During our debugging of the contacts demo that is a part of the new kitchen sink we noticed its performance was sub par. I assumed this was due to the implementation of getAllContacts & that there is nothing to do. While debugging another issue Steve noticed an anomaly during the loading of the contacts. ...

Performant Radial Gradients
One of the first Codename One performance tips is: “Don’t use gradients”. We already wrote about improved performance to gradients in the past but that covered linear gradients and didn’t cover radials on iOS. With recent commits radial gradients are now performant on iOS/Android and elsewhere. On iOS Steve implemented gradients as a shader which should deliver great performance. I’m not sure if this is good enough to deliver the level of performance we see from image borders and it’s harder to work with low level graphics primitives. ...
Using Icon Fonts Such as Fontello
A lot of our focus in the past couple of releases has been around the material design icon fonts, they changed the way we build UIs. We also support arbitrary font icons, this features isn’t limited to material icons and we blogged about it a while back. After going back and forth with developers we got the sense that using an icon font such as fontello wasn’t clear. In this short tutorial we’ll try to explain the process and benefits. ...

Avoiding Lists
When picking up a new UI API people often start with a list of items. Lists are often used for navigation, logic and data so it’s a natural place to start. Codename One’s List class is a bad place to start though… It’s complex and encumbered and has far better alternatives. How did we Get Here? When we initially created the List API we were heavily inspired by Swing’s architecture. The ability to create an infinitely sized list without a performance penalty was attractive and seemed like a good direction for our original 2mb RAM target devices (back in 2006-7). We knew the renderer/model approach was hard for developers to perceive but we also assumed a lot of Swing developers would find it instantly familiar. ...

Questions of the Week XIX
It’s cucumber season, there is little going on around here and elsewhere. Stackoverflow mirrors this general trend with seasonal low activity. Our update to the build servers today includes a lot of fixes but is still tame compared to the last update. Onwards to the questions on stackoverflow: Cannot edit new locale in Codename One IntelliJ plugin This is a bug in the current version of the plugins. A workaround is described in the answer… ...

Image Overriding
I hoped todays post would cover the new Kitchen Sink demo but due to a couple of bugs we decided to postpone that to next week. In the meantime I’d like to discuss something I did there which is actually pretty cool and most developers have no idea that we can do: Image Overriding. The new kitchen sink renders a set of icons like the old demo. In this version of the demo we wanted to show off graphics drawing which is an important feature missing from the old demo. Steve’s clock demo is a great example of that! ...

Xcode Migration Revisited Again
We tried migrating to the new iOS build servers before and decided to revert the change due to xcode crashes. After a lot of work we think the new server code is ready for production. We will try to migrate to these new servers again on the 28th of August (Sunday) to minimize impact if something goes horribly wrong. If you read the old post covering the iphone_new build target you can skip the rest of the post as it’s pretty much the same. ...

Improved Background Behavior
A couple of years ago at Google IO one of the prominent speakers turned to the audience and asked them: “Raise your hands if you understand the activity lifecycle”. He then proceeded to call them “liars”, claiming that after all his years at Google he still doesn’t get it properly… As a guy who worked on VM’s and understands some of the nuance I totally get his point. Lifecycle is hard. On Android it seems the developers took a difficult subject and made it even harder. With that in mind our implementation of background behavior on Android was lacking in some regards and Steve did a major overhaul of the implementation. Like all overhauls this could trigger some regressions so please keep your eyes open for such cases. ...

New Peers on by Default on Android
Starting with the next Friday release we will migrate to the new peer support. This migration will allow us to focus on a single code base and remove the branch where we are maintaining the old peer support. If you run into issues you can use the android.newPeer=false build hint to see if the issue is due to the new peers. __ This is an undocumented temporary flag! We will remove this flag soon! Because of that you MUST report regressions you encounter and MUST NOT set the flag without further action… ...

Questions of the Week XVIII
This has been a very busy week with huge changes and new features to the code base. Because of that we will shift the Friday release this week to Sunday so we’ll be able to revert the deployment if build issues occur without affecting too many people. Besides the big changes and new plugin versions we’re also including a major overhaul of the Android background processes that should improve the behavior of Codename One apps for background tasks. Notice that this is a pretty huge change that might include regressions so be sure to report them as soon as possible. ...