Holidays are over !

It’s been a while since my latest post !

I have been  busy completing my internship and then the exams related to it.
I also worked on some of my own project, I spent some time on creating my Portfolio here : http://www.kayrnt.fr
But I actually spent most of my time on http://www.kapplist.com which I host on my dedicated server.
I more recently dived into Scala and did some stuff like porting my Android String Tool or doing some sample on my Github.
Finally, I’ll be joining Teads next week and moving to Montpellier. The choice was tough but the work and the team look like awesome (ok ok… the city and the weather seem cool too :D)

I promised quite a long time ago (like in january), I’ll be moving to AndEngine GL ES2.0 to expect some bug fixes ! Actually that was way longer to do than I expected since lot of the API has been updated and required a lot of refactoring ! I actually didn’t had time to retest everything so I’ll monitor crashes :)

So you can get the new 1.26 version on Download page or at https://play.google.com/store/apps/details?id=kayrnt.game.combotouch

At the same time, I’ve been working since January on the iPhone version of "la minut’rit" which is currently under beta test. It will be released soon (hopefully …).

I still don’t know if I will have time to do much more since I start my new job soon and I’m following some lessons on Coursera too.

 

Build OSGI Bundle with Maven on Android

It has been quite a while since my latest post but I worked on quite a lot of things beside my Android apps. However I’m working on OSGI Bundle at work and I’m not fan of Knopflerfish ant scripts because I find Maven way more complete and easier to use.

So I wrote a pom.xml to do the same work as the ant scripts. It might not be exactly what you want if you need to build 2 jars (one for impl and the other for api) but if you need the impl, check out this pom.xml.

Goal to build your jar bundle : clean install

If you’re not used to maven builds, please note that you should use provided scope on your dependencies for OSGI since you’re not including libraries inside your OSGI ( of course because they are loaded by the OSGI framework at runtime ). Moreover, the android-maven-plugin version used is for the SDK version 22. Check the generated jar MANIFEST.MF because the bundle plugin often add version requirement that you might have to check between the actual bundle version declared in the manifest and it’s maven dependency ! ( especially when you use built-in classes like OSGI framework classes ).

Standard directories are used (src/main/java for sources and target/classes for compiled classes). I won’t give a full tutorial on how to use Maven and the plugins behind my pom.xml because there are already quite a lot of docs on them but at least, it might save you some time ;)

If someone is interested, I might publish a fully working OSGI example :)

Android Strings tool Eclipse plugin

I have worked on this for the since a week or so and finally managed to have something "working" ! :)

That’s not perfect but I expect to get some time to update this later…

ALPHA VERSION, the source code is partially documented & manually tested. You might want to save your files first !!!

What’s for ?

This project is an Eclipse plugin designed to synchronize your strings.xml across localization :

  1. It reads your res/values.xml
  2. It compares all its ids & comments to add missing ids to your other localization

Why ?

I usually do increment builds with different languages but I’m often doing this as "indie" and when I want to sort my strings.xml I usually add them to my res/values/strings.xml and just forget to add them to others locales… and guess what ? Users don’t like SLOPPY WORK. :)

"lol" almost useless ?

Well, it will show you empty strings too fill into your strings.xml thanks to warnings… it might save you some minutes  and maybe if I could implement some translate tools API to make you a direct translation… it might actually be more efficient than doing some copy paste in http://translate.google.com/toolkit/.

I find copy pasting strings ids really boring so you have better solutions I’m looking forward to hear them ;)

Some features ?

 

  • Backup by default at <ProjectFolder>/backup/ (checkbox to disable)
  • Revert process from your backup
  • Reorder your localized strings.xml as your main strings.xml

Get it :

How to use :

  • Right click on an Android Project and hit "Sync strings.xml".

Small example :

res/values/strings.xml :

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="loading">Loading :</string>
     <string name="skipTutorial">Skip tutorial</string>
     <string name="next">Next</string>
     <!-- tutorial on screen process image -->
     <string name="tutorial1_hi1">First time on ComboTouch ?</string>
     <string name="tutorial1_hi2">Press next to start the tutorial.</string>
     <string name="tutorial2">Check the color there</string>
     <string name="tutorial3">Now just tap the right color !</string>
     <string name="tutorial4">As long as it matchs the color...</string>
     <string name="tutorial4b">Your multiplier goes up every 10*2^n !</string>
     <string name="tutorial5">Every 50*2^n boxes, you get god mode !</string>
     <string name="tutorial5b">But only for 2 seconds !</string>
     <string name="tutorial6">Now it\'s your turn !</string>

</resources>

res/values-fr/strings.xml :

<resources>
<string name="loading">Loading :</string>
     <string name="skipTutorial">Skip tutorial</string>
     <string name="next">Next</string>
</resources>

--------------------- Android Strings tool process ----------------------

Now the res/values-fr/strings.xml looks like :

<resources>
<string name="loading">Loading :</string>
     <string name="skipTutorial">Skip tutorial</string>
     <string name="next">Next</string>
     <!-- tutorial on screen process strings -->
     <string name="tutorial1_hi1"></string>
     <string name="tutorial1_hi2"></string>
     <string name="tutorial2"></string>
     <string name="tutorial3"></string>
     <string name="tutorial4"></string>
     <string name="tutorial4b"></string>
     <string name="tutorial5"></string>
     <string name="tutorial5b"></string>
     <string name="tutorial6"></string>

</resources>

It’s Open source :

You can find the source code under APACHE Licence 2.0 ( yet to submit some licence file… ) :

https://github.com/Kayrnt/AndroidStringToolPlugin

but also the standalone version ( just a java program ) :

https://github.com/Kayrnt/AndroidStringTool

Todo list :

  • play starcraft 2
  • support plurals
  • Make some tests
  • Do a proper documentation
  • fix the layout of the custom dialog & add progress bar & error management…
  • optimize perfomances (concurrency is a bitch)
  • Mavenize ?

Feel free to pull & push & fork & reuse & create plugins or whatever !

Simple Android Location Service across Activities

Introduction

I’m spent countless hours trying to find the best way to provide geolocation across a whole Android application and I found that my approach was often too short-minded to avoid service leak on my application lifecycle. So I though about rebuilding my implementation and here is the result.

I find it quite convenient to use and yet doing the job ! Hopefully it comes without (too many) memory leaks.You might want to optimize providers call to avoid them to be on constantly so that you can save battery. However since that’s not the purpose, I kept the project simple.

 

MyCUBMapView

The sample project

https://github.com/Kayrnt/SimpleLocationService

How to use

  • You should have an application with overrides the onTerminate() like in the sample.
  • Your activities using geolocation should use extends GeolocatedActivity like in the sample or just override the OnResume and OnPause methods
  • Then just use LocationServiceHelper.getInstance(getApplicationContext).getLocation() to retrieve latest location if existing !
  • Finally you might want to use a listener on some object then just use implements ILocationListener and put LocationServiceHelper.getInstance(getApplicationContext).addListener(listener) and remove method as in the sample.

Lot of projects on my way

I’m currently working on several fronts !

ComboTouch : I could say that I’m going slow yet steady on my next update. I’m currently trying ( again ) to go for the GLES2.0 of AndEngine however I wish migration was as simple as a simple setup to run ! I don’t know when I’ll be done especially since that kind of patch usually start driving me nuts when a whole part of my source code has to be rewritten.

Kaynote : Well I could say that I spend way more time on this than I expected ! Especially since I wanted some "flashy" features which are quite simple on the paper yet tough to code. "Natural" look & feel isn’t usually the simplest way to achieve things… :)
Yet I think that these updates want quite smooth… ok… not as smooth as I expected for the 1.1x ! However it’s fixed :D
I have yet to think about some new cool features :)

La minut’rit : I’m building an iOS version of the app, so it is one of the things that keep me quite busy ! Learning & programming for pro is really interesting though quite hard to see clear through. ;)
Android version will be updated as well … however no date on the schedule.

SmashThat : Don’t worry I won’t unburry it ;)

TripInPics : Oh man… I don’t have the time to handle this :x
But does anyone matters whatsoever ?

MyCUB & Inertness : Both projects are linked somehow… ! Yet I don’t know if I’ll pursue for the time being. I need to talk on that subject with some people (and follow OpenData growth). However I don’t have any server to host the MyCUB WebApp.

BAUG & Development tutorial articles : Well it’s something I mike ! I often browse around the web and find a lot of cool tutorials out there so I feel like that’s somehow my turn on some subjects ;)
I try to write some in French however I think that they are way more useful when written in English…
I’m currently going to write a short tutorial & snippet after this update. I hope it will useful (I think so at least !)

Android developer tool project : I feel like there are some missing features on strings/localization for Android developer tools and I’m going make a simple java program to save me ( and maybe you ) some precious minutes on this ! :)
I’ve a lot of ideas but not as much time I would like to develop them !

Finally, I’m "no more" student since I’m doing a 7-month internship in Belgium.
Android, OSGI, Java stuff …decent sized project :)
However I don’t know yet what will happen at the end ! (else receiving my diploma…at least I expect so :D)

Dynamic strings using SQLite database & strings.xml on Android

Introduction

That’s not a common subject and few people might run into this topic.
However, here is an example : you need to update some texts like a help component or add languages or even fix some localization mistakes… all of this without updating your APK !
Sadly, you can’t download a need "strings.xml" and replace your old one ( or even create values-fr/strings.xml )
So I actually made a proof of concept of a system to work this constraint. I guess the idea isn’t new but it still uses some tricks to make it efficient on Android.

The system

StringServerSide

In practice

  1. Starting the application, the program will read the string.xml matching the  language selected on the device and then import it to the SQL Lite Database.
  2. Then using a version system, we’ll request the server for an updated version of our strings if necessary !
  3. Depending on the version,we’ll update the database as well as the "string version" in the preferences.

How to capture all strings automatically ?

That’s quite an interesting question when you’re new to Android !
Actually, you know how to use myTextView.setText(R.string.myString);
You don’t need to do add (getString(R.string.myString), "R.string.myString") line by line :

We use Java Reflect !

Java Reflect can be used to retrieve fields from a Class as well as their values… at runtime.
So the trick is to call :

Class androidString = R.string.class;
Field[] fields = androidString.getFields();

Then with a simple loop you put your insert requests.

So this is my sample project as a demonstration.
NB : I didn’t made the server connection part. I assume that’s not really tricky to do ( I use something similar in most of my apps )

>> Sample code ( Eclipse project ) <<

Conclusion

To be honest, this method isn’t optimal. However, there aren’t much better solutions out there (or else I didn’t found them ;) ). You might use an external files (xml, json… ) to store your texts. However, I guess it will way more complicated to get decent performances as well as a elegant update management. Finally, if you can avoid it you should but you need … it’s possible. :)

Hopefully it might give ideas for some others features !

Use Drag and Drop library on Android with a View Pager Indicator – Maven [ part 1 ]

Introduction

You might wonder at some time in a project how you could reorder a list efficiently ?
Using a Drag & Drop list is one of them ! It’s a "fun" and smart way to achieve this goal.
You might also use a "select position in list" popup or some  up/down arrows but honestly it’s not ergonomic
especially when you scroll looooong lists.

KayNote Drag & Drop list inside a view pager indicator

KayNote Drag & Drop list inside a view pager indicator

To achieve this feature, we’ll use a very good library developed by Carl Bauer and its contributors.
To figure out what could be done with this lib, you might want to check out :

https://play.google.com/store/apps/details?id=com.mobeta.android.demodslv

There are 2 approaches:

  1. using standard Android library build process
  2. using standard Maven library build system

I’m fine with both, if you aren’t used to build maven projects ( and especially Android one),
you might prefer to go for the first one ! However if you’re going to manage a serious project for your company… you should take a look at it :)

Read more…

Suivre

Recevez les nouvelles publications par mail.

Rejoignez 137 autres abonnés