CLIM on Android

This post shows a way to use the CLIM library inside an Android app.

The problem

We’d like to use a simple activity with an EditText (maybe multiline) as output and another EditText as input. Since the CLIM’s engine use Standard input/output streams as default, we need to implement our custom ones.

The Layout

The layout of our activity will consists on:

  • Multiline EditText etout as output
  • EditText etin as input
  • Button btnok to commit the input (equivalent to ENTER key)

The activity_main.xml :

CLIM dependency

First things first: let’s add dependancy to CLIM in the gradle project-level build.gradle :

then the app-level build.gradle:

The Activity

Inside our activity we will prepare our CLIM engine:

For an implementation with sense, please have a look at the class.
We will see the body of prepareStreams(Engine engine) in the next section.

The Streams

Now, we need to implement our custom input and output streams to be linked to our EditTexts etin and etout respectively.

Let’s see the content of prepareStreams():

As you can see, the implementation of the OutputStream is quite simple, since we will redirect the input string to the output EditText (in the UI thread, of course).

The TextInputStream needs some extra considerations:

You can notice that the TextInputStream take the engine as the main subscriber and saves to lastContent the inputted text. The access to lastContent is managed by two synchronized methods (getLastContent() and setLastContent(…)). Finally, notice that the forceRead() method is called inside a dedicated Thread from the parent class InputStream, so it is safe to use that while loop inside.


Let’s watch and enjoy our app (using the engine as in :

Hyper Gyro

Well, often it’s so difficult to read the instruction booklet of something before using it. This is the reason I made the new app Hyper Gyro!

Since some gamers can’t lose their precious time to understand the purpose of an app like HyperIMU nor the effort made by its developer, I made what they wished for: a simple rotating wheel spinning in the background.
No settings, no protocols, no problemos

I guess this is an example of a manufacturer that meets the “needs” of the market…

I will ask for Hyper Gyro to be included in the next Android release as system app, together with their favourite multiplayer game maybe.

XSheet 4.5.0

So many changes for XSheet 4.5.0. Read more here.
Also, there were lots of requests for an intro help, so I made this video. Guess whose voice is…

XSheet 4

Finally, the version 4 of XSheet has been released!!
Several improvements have been made:

  • New feature: animatic preview
  • Enhanced smart converted and animatic generation
  • Thumbnail sketch improvements
  • GUI improvements: restyling and more intuitive project management

Discover more here.
I have in mind many other great updates to come with time.