Getting started with Cicada

28 views
Skip to first unread message

Joe Hughes

unread,
Apr 16, 2011, 7:37:05 AM4/16/11
to Cicada
The Cicada project aims to make it easier to write apps for Android
that interact with Apollo bluetooth watches. Right now things are
still in a very rough state (patches welcome!), but here's a quick
introduction to using what's there so far.

The lowest-level part of the Cicada project is ApolloLib: it's a very
thin wrapper to encapsulate the OpenWatch/Apollo interface. Use this
if you just want to have a standalone app and want to make the part of
your app that talks to OpenWatch a bit more legible and less error-
prone. I won't go into it here, but the "HelloCicada" sample app
shows how to build something simple using only ApolloLib:
https://github.com/cicada-dev/cicada/tree/master/samples/hellocicada

However, once you start having multiple apps on your Android phone
that interact with the Apollo device, you quickly find that you need
to manually coordinate between your apps so that they don't grab each
others' button press events and don't push screen updates that stop
each others' watch UIs.

The main Cicada app shell is an attempt to keep the app author from
having to do that coordination, and to provide a central app-picking
and configuration UI. Here's how to build an app for the Cicada
environment:

1) Get Apollo hardware and the special Apollo version of OpenWatch.
(As I write this, these are only available from Fossil.) Install
OpenWatch on your Android device, and pair it with the watch.

2) Install the Eclipse IDE and the Android SDK (with its Eclipse
plugin) on your development machine.

3) Clone the cicada repository from GitHub onto your development
machine:
https://github.com/cicada-dev/cicada

4) In Eclipse, do File > Import... > Existing Projects into
Workspace. Do this for the following project directories:
apollolib/
cicadalib/
cicada/
samples/digitalclock/

5) In Eclipse, create a run target for Cicada (the app shell), and
trigger it to build and launch Cicada on your Android device.
Optionally, do the same thing for the DigitalClock sample, so that you
can try selecting it and running it from the Cicada app list on the
watch.

6) In Eclipse, create a new Android Project for your app. You don't
need to check the box for creating an activity—at minimum, a Cicada
App only needs a service if you don't have a phone-side UI.

7) Right-click your new project in the Eclipse package explorer,
choose Properties, then in the Android > Library section, add
CicadaLib

8) In your project, create a new subclass of CicadaApp to implement
the core UI of your app. At minimum, you need to implement onDraw()
to scribble something on the device canvas so that you can see some
effect when you launch your app.

9) Edit your app's AndroidManifest.xml to define a service entry for
your new app class, something like this:

<service android:name=".(your class name)"
android:label="@string/app_name"
android:exported="true">
<meta-data android:name="org.cicadasong.cicada.apptype"
android:value="APP" />
</service>

The most important Cicada-specific details are the "android:exported",
which lets the Cicada launch your app, and the "meta-data" tag, which
lets Cicada identify your app as Cicada-compatible when you install it
on the Android device.

(The other valid values for the apptype meta-data are "WIDGET" and
"WIDGET_AND_APP", both of which allow your app to be used as a
"widget" by Cicada, in which case your onDraw() would get a canvas
that's 1/3 of the usual display height, so it can be displayed in
combination with other widgets.)

10) Create a Run Configuration for your app, then trigger it to build
and install the app on your Android device. If everything worked, you
should be able to launch the Cicada app shell on the watch, and launch
your new app from the list! (In the app list, use the top right and
bottom right buttons to move the selection up and down, and the middle
right button to launch the selected app. From there, the top left
button should return you to the app list.)

So that's my first draft. Please do comment with problems you
encountered while following these instructions, or things that you
didn't find clear, so we can improve it in later iterations.

Joe

Joe Hughes

unread,
Oct 3, 2011, 12:52:41 PM10/3/11
to Cicada
BTW, someone was just asking me for more detail about how to draw
things in Cicada.

In general, you draw what you want to appear on the screen in your
app's onDraw() method, using standard Java Canvas methods. Whenever
you want to trigger a redraw, just call invalidate() and your onDraw()
method will be called again. The Digital Clock app has some examples
of how this works—it updates the screen both when the timer ticks off,
and when the user presses the button to toggle between 12 and 24-hour
modes.

Note that you don't have to explicitly invalidate() in
onResume()—Cicada does this for you.

Joe

Juan Martín

unread,
Oct 3, 2011, 2:43:23 PM10/3/11
to cicad...@googlegroups.com
Yes, I was trying to ask how to draw a basic figure but my english is not good :)
Ok, good to know I can use whatever way of painting on canvas, I will try this night before bed time.

Thank you!
   Juan Martín



2011/10/3 Joe Hughes <joe.hug...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Cicada" group.
To post to this group, send email to cicad...@googlegroups.com.
To unsubscribe from this group, send email to cicada-dev+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cicada-dev?hl=en.


Juan Martín

unread,
Oct 3, 2011, 4:51:21 PM10/3/11
to cicad...@googlegroups.com
It worked! Photo attached.

Saludos,
   Juan Martín
IMG_20111003_224757.jpg

Joe Hughes

unread,
Oct 3, 2011, 7:23:54 PM10/3/11
to Cicada
Congrats on your first Cicada app, Juan!

Joe

On Oct 3, 9:51 pm, Juan Martín <nau...@gmail.com> wrote:
> It worked! Photo attached.
>
> Saludos,
>    Juan Martín
>
> El 3 de octubre de 2011 20:43, Juan Martín <nau...@gmail.com> escribió:
>
>
>
>
>
>
>
> > Yes, I was trying to ask how to draw a basic figure but my english is not
> > good :)
> > Ok, good to know I can use whatever way of painting on canvas, I will try
> > this night before bed time.
>
> > Thank you!
> >    Juan Martín
>
> > 2011/10/3 Joe Hughes <joe.hughes.c...@gmail.com>
>
> >> BTW, someone was just asking me for more detail about how to draw
> >> things in Cicada.
>
> >> In general, you draw what you want to appear on the screen in your
> >> app's onDraw() method, using standard Java Canvas methods.  Whenever
> >> you want to trigger a redraw, just call invalidate() and your onDraw()
> >> method will be called again.  The Digital Clock app has some examples
> >> of how this works—it updates the screen both when the timer ticks off,
> >> and when the user presses the button to toggle between 12 and 24-hour
> >> modes.
>
> >> Note that you don't have to explicitly invalidate() in
> >> onResume()—Cicada does this for you.
>
> >> Joe
>
> >> On Sat, Apr 16, 2011 at 12:37 PM, Joe Hughes <joe.hughes.c...@gmail.com>
>  IMG_20111003_224757.jpg
> 984KViewDownload

dominicclifton

unread,
Oct 5, 2011, 1:36:43 PM10/5/11
to Cicada
Joe should mention that he builds on Linux. I build on windows and
it's fine but i had to manually copy some fonts from one project's res/
fonts to the main cicada/res/fonts directory.

Also if building on windows ensure that the android dependencies are
correct - you may need to re-create them. Open the cicada project
properties and click the android tab and ensure that apollolib and
cicadalib are listed. On mine they show up as '..\apollolib' and '..
\clcadalib' since i recreated them, before they had a red X in front
of them and the paths were like '../apollolib' etc.

Joe didn't mention which android API's you'll need, they currently
need api 5 and 8 if my memory serves me correctly.

Dom

Joe Hughes

unread,
Oct 6, 2011, 8:14:40 AM10/6/11
to Cicada
Thanks, Dominic. I'm actually doing most of my work on Mac OS X, but
close enough. :]

I've been meaning to copy those font directories in the core project
since you and Steve reported running into that problem, but it's been
a busy week and I haven't had a chance to sit down and hack yet; feel
free to fix it and send a pull request on GitHub.

The code in Cicada is currently written for API level 8 (Froyo/2.2).

Joe

On Oct 5, 6:36 pm, dominicclifton <mailinglist.goo...@hydras-
Reply all
Reply to author
Forward
0 new messages