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…

Kaynote 1.1 almost ready ! Sweet Android Note Widget !

Edit : The new version should be up. Hopefully, I’ll fix some annoying bugs soon !

As explained my last news… I managed to make a sweet view pager indicator using drap & drop lists !

As a reminder, you can find the current version here :

Kaynote on Google Play

Now here is the new result :

Kaynote screenshot 1Screenshot Kaynote 2

It’s not coming in the upcoming hours since I have some memory leaks & bugs & translation & legacy compatibility to do !
Maybe even some layout tweaking ^^
So you might have to wait the weekend !

If you’re already interested in how some of this is done, you might want to comment since I’m going to do a tech article on how to use
https://github.com/bauerca/drag-sort-listview with https://github.com/JakeWharton/Android-ViewPagerIndicator !
Also some interesting stuff as saving & refreshing the views but also the widget !!!

Indeed you will notice that sliding the view pager will trigger a refresh on the widget so that you can have different note lists !

I’m still thinking what I’ll add to ComboTouch !

BTW I’m now living in Belgium for 7 months !

Quick news

That’s my first post for 2013  but probably not the last 🙂
As expected January was busy ! No time to code some funny stuffs !

However I’m currently « having fun » with View Pagers and Drag & Drop lists for my app Kaynote. Hopefully, I’ll release a new version this week … and a tutorial on how it’s done as well 😉 !

I’ll probably do some minor update for ComboTouch as well !

I’m supposed to be in « holidays » but I’m learning iOS quite hard to build an app for la minut’rit 🙂 ! Objective C isn’t my preferred language but I have to deal with it ( although I don’t think I’ll port ComboTouch on Iphone … ! ).

Meanwhile I finished my GIS project and a video is available here :

http://www.youtube.com/watch?v=lmylZhI64oM

The project is open-source as GPLv3.

Stay tuned.

Merry Christmas ( and happy new year if I forget ! )

Edit : The upcoming update should be for the 31/12/12 🙂 ( or the 32 😉 )
I’m working on a decent tutorial ! Hopefully, you might understand how multipliers and god mode works. ^^’

Hi guys !

ComboTouch icon with christmas hat

I don’t post quite often these last days ( ok weeks… fine… lets say months 🙂 ) ! I don’t update ComboTouch as often as I want too ^^’
As usual, my engineering school still eats most of my time ! But la minut’rit is also hanging on my skills 😉
Finally, I ended second ex-eaquo a « little » challenge called « Galileo Masters » in Aquitaine as I purposed my real-time transport application project.
( So I earned a year in a company incubator so that I can have help to work on my project )

All of this being said, I’ll might dig into some few bugs remaining in ComboTouch and delivers some news cool bonuses !!!
I might also add some challenges ! I’ll really like to add a random matchmaking online mode with a ladder … but I would be soooooo long to implement that I think I won’t have time to make anything decent at this moment ! ( yeah I have so many projects on the way that I can’t afford to spend days on this … yeah literally. Maybe if someone want to do it or has some INSANE library/API/Framework, I might give it a try 🙂 )

Finally, I wish you a Merry Christmas guys !
I hope you have fun with your gifts 😉
I personally enjoy my brand new MacBook Pro Retina ! ( yep, now, no excuses not to program on Iphone/Ipad :p )

1 month to go before I start my last internship… in Belgium 🙂
I’ll work for Bizzdev there.

If you still don’t know, you can get some free bonus over here : https://www.facebook.com/notes/combotouch/unlock-codes-/318484951593295
Don’t miss to drop a com’ if you want something special for this epic year ! ( or just like the game 😉 )

Read & Write & Lock NFC Tags in your Android App

galaxy S3 NFC

You probably found some use cases with NFC tags with your app ?
( or maybe you just intend to build an Android NFC Application )

My practical example :

I have developed an Android application for la minut’rit ( available on Google Play France only though ) and as an application giving the opportunity to buy service directly from your mobile phone.
I purposed to add some « flashy » feature : create a big poster with nfc tags under prints so that users can get right on the correct screen while putting their phone on the picture’s item.
I find it « cool » and quite user-friendly for people that want to have see everything on a wall and then just pick the right one with their phone.

What you need :

  • An android phone with NFC chip ( Samsung Galaxy S3 or a Google Nexus  for example)
  • some nfc tags ! ( just google « buy NFC tags » and you will find websites to buy some )
    Be careful, crappy nfc tags doesn’t store a lot of bytes and might not support locking feature ( or even authentication )

So How Did I do that ? :

First, start by declaring NFC permission in your AndroidManifest.xml :

  • <uses-permission android:name= »android.permission.NFC » />

Ok, as an example, here are the 2 activities I use in my app :

You might have already guessed that the first one is for reading your NFC Tags whereas the second is for writing & locking them.
I personally don’t use the writing one for the public version as you don’t want people to write your stuff anywhere ( even they could with some others apps but that’s not your problem ).

Mime type, the way to have your app recognize only your tags :

One thing that is usually really annoying is to have your nfc tags recognized by others applications but also having your have in a selector when the user tap a random nfc tag…
So the way to « fix » that is to use mime type on your nfc tags. Practically, it’s just a prefix in your data field.

The filter is done by Android through the AndroidManifest and the activity declaration :

<activity
android:name= ».nfctag.NFCTagReadingActivity »
android:label= »@string/app_name »
android:launchMode= »singleTop »
android:screenOrientation= »portrait » >
<intent-filter>
<action android:name= »android.nfc.action.NDEF_DISCOVERED » />

<data android:mimeType= »application/fr.laminutrit » />

<category android:name= »android.intent.category.DEFAULT » />
</intent-filter>
</activity>

I think you noticed the bold line : That’s how I declare that my app receive only nfc tags starting by application/fr.laminutrit. You aren’t forced to use your package name as your « identifier » but I find it quite convenient.

Closer look at the NFC Tag reading activity :

The activity will :

  • start and listen for an Intent
  • read the Intent that contains the NFC Tag data
  • do the interpretation
  • start the next Activity through providing the correct intent with the data found in the NFC Tag

It’s as simple as that. ( isn’t it ? )

As you can see I just used a simple integer that is in fact the reference of the product in our system.

Now the question would be … how to write it ?

Closer look at the NFC Tag writing activity :

NFC Tag writing activity is a little bit « harder » than its reading counterpart. Indeed, I used an AlertDialog to allow to lock after writing ( something you might want when you’re doing some production nfc tags ! ).

Nothing special in the activity declaration :

<activity
android:name= ».nfctag.NFCTagWritingActivity »
android:label= »@string/app_name »
android:launchMode= »singleTop »
android:screenOrientation= »portrait » >
</activity>

To start the activity, use the following lines :

Intent intent = new Intent( myContext, NFCTagWritingActivity.class )
intent.putExtra(« lock », false); //put true if you just want to lock and not write
intent.putExtra( « nfc_id », itemId); //itemId is your integer you want to write, you can set whatever you want if you put « lock » on true
startActivity(intent);

Write something else than a simple ID :

Writing a single field isn’t that convenient for a more complex setting.
So check the getIdAsNdef function and put anything you want to write on your NFC Tag into the String msg.
Always remember that your message can be too long if your NFC Tag is too « small » ( some are only 170 bytes long ! ).
You can try to use some JSON representation for the mapping but it will often be too long for your nfc tags…
I suggest you to go the « dirty way » with some chained key/value stuff if you can.

That’s all for now, have fun tinkering !

If you like that « tutorial », you might want to read the one on SlidingMenu & Google Maps & ActionBarSherlock & maven.

If you have any issue, just comment, I’ll try to advice you 🙂
Feel free to share & translate ( just mention the source ^^ )

What a weekend ! #BMAOpenTourisme

That was a first time ! Yep, I just had a « hackathon » 🙂
I took part into the event called « BeMyApp », it’s a kind of event where you are expected to build from scratch a prototype of a mobile application during a weekend !
That one was on OpenData & Tourism so I decided to join with 2 mates of my engineering school to try !
We met a « project leader » which had an idea and was looking for developers & designers so we made a group of 4.
We didn’t managed to get some designers or even marketers … quite a empty spot that didn’t help us to win the challenge !
Indeed we didn’t earned any prize but I think the idea wasn’t really in par with what the jury expected and winner teams were composed up to 11 persons ( quite unfair for us :p )
However there were cool and well-designed apps that won so I don’t feel like jury was totally corrupted :p
You might want to check them out thanks to #BMAOpenTourisme hashtag !

But that doesn’t really matters. Here is the app idea :

The mobile application gathers all your geotagged photos on your smartphone then through a hierarchical agglomerative clustering algorithm we select some photos that looks like to represent a decisive spot your trip and then we identify the spot through OpenData on locations. Finally we create a « postcard » that is rendered by the smartphone and sent to a server like Instagram.

We called it : TripInPic

Here an example :

That was « fun » to develop ! I slept 9h over between Friday and Monday 😉

If you want to test this event : I suggest to give it a try ! It’s a nice event 🙂
If the organisation team is as cool as the french one, you’ll definitly have a good weekend !

 

Finally I had some time to rest  update ComboTouch !

So I managed to fix some bugs I spotted through Google Analytics & Google Developer Console ( In fact most crashs aren’t reported so the new Analytics was a great help ! )
I decided that was a good opportunity to a new mode ! I felt like this one was lacking :

 

 

 

Regular players will find out that it is a 1×1 colors cooperation gameplay ! Good luck if you try it 😀

On the next update, I’ll revamp the bonus menu into a UI like Challenge one !
In fact it might be quite boring to use for you… but it is also a pain for me to add bonus into the current one !

I don’t know if people are still expecting the online version but I don’t think I’ll have time to develop it if there isn’t a good API to use it.
Wait and see ! 🙂

 

 

[Android] Maven Integration for SlidingMenu ( and ActionBarSherlock / Google Maps )

(03/11/12 ) Google just announced a new version of Maps APIs so expected a revamp of this tutorial quite soon as I found a way to implement the new system !
In fact, it should be simplier : Just use a standard SlidingFragmentActivity extending SherlockFragmentActivity and use a MapFragment.
The advantage of this new « MapFragment » is to avoid having FragmentActivity built over MapActivity adding « useless » functions to your Activity object when you don’t use a Map ! If you don’t get it, it means your don’t need a special ActionBarSherlock and just the pom.xml from my SlidingMenu … ( I still have to check potential dependency tree issues )

(12/12/12) Hum… I checked GMaps API v2… Quite cool for simple stuffs but LOOKS LIKE HORRIBLE for advanced projects… !  The new APIs doesn’t fit my usage and I’m thinking about staying on the V1 … or wait a v3 😡
As an example : If you used a real time thread to modify your overlay’s bitmaps… you have to create new Markers/Overlay objects every time… ! Great memory management.
MyLocationOverlay looks like it was merged into a higher level abstraction so that you can’t provide it the GPS data you might collect with your own location service over the application state…
I might be wrong but let’s be honest : it sucks and it’s tough to move from v1 to v2 if you did advanced features.
I’ll try to make a new post with GMaps V2 when something is definitly working 🙂

What’s for ? :

As I’m going to create an upcoming SIG App for one of my engineering school project, I wanted to use both ActionBarSherlock and SlidingMenu … but as it’s a teamwork… people expected to have some Maven stuff to ease IDE setup. You might want to check it out for a complete example working just with a Mercurial repository import in Eclipse.

It was quite troublesome since I barely know how works Maven ! ( In fact It has started to become clearer as I spent 5 hours to get it working ! )

(3/02/13) if you want to see the result here it is :

MyCUBSlidingMenuMyCUBMapView

A video of the full app is available there :

http://www.youtube.com/watch?v=lmylZhI64oM 

The requirements :

  1. First, I suggest to get Maven 3, do the path stuff to use it as command line ( scroll down the download page of Maven website for more explanations ).
  2. Now some android maven setup ( you just need to do the ANDROID_HOME path trick ).
  3. Ok now, you should be able to build stuff with Maven !
  4. You might already know that Maven create a « .m2 » directory in your « home » ( in windows something like : C:\Users\Kayrnt\.m2\ ) inside, it creates your local repository !
    As I’m building Android projects, I need Android SDK to be in this repository and referenced as a maven dependency source.
    That’s where Maven Android SDK Deployer is really useful !
  5. Download it there and do a « mvn clean install » inside the directory.
    If you are lazy, you check my maven repository where you can find Android SDK 4.1.2.

It should do the stuff !

The snippets/custom versions :

OK now the the snippets I wrote or modified :

  • ActionBarSherlock 4.2.0 ( I modified sources to use android support v4 with maps)
  • SlidingMenu (it’s a modified one with ActionBarSherlock support and with the pom.xml inside)
  • Finally an example of my pom.xml for my final project !
    If you use my « final » pom.xml is as an « example », don’t forget to completed it with signing / zipalign etc… see the maven android website.

You just have to do « mvn clean install » in ActionBarSherlock then in the SlidingMenu directory and you’re done !
Finally use « mvn android:deploy » to deploy the apk on your device.

I set the SlidingMenu apklib version to 1.0.0 since there aren’t any for the time being.

Note that it could be interesting to upload it to Maven central !

Now some potential troubleshooting :

It looks like m2e-Android doesn’t support correctly apklib in Eclipse. However building with maven in console works properly with just apklib files.
Adding « jar » files to your pom.xml allow m2e-Android to detect classes correctly but you can’t use ressources ( like @style/Theme.Light.Sherlock ) like this.
To work properly… just have your projects opened in your workspace ( the ones declaring the apklib used in your main project ).

M2e-android-configurator has a certain issue with APKlib showing problem at building in eclipse even it’s compiling just fine using a terminal.
In fact, if you want to build with maven and still want to use Eclipse as an IDE, you need to get the « Android library projects » opened in your workspace !

You might also need to specify JDK 1.6 in run configuration of your maven build if you use Eclipse else it might not find « tools.jar » instead of a JRE.

If you have any issue, just comment, I’ll try to advice you 🙂
Feel free to share & translate ( just mention the source ^^ )