Duplicate Calendars on CM11

On CM11 (Android 4.4.3) i got an issue that the local android calendars could not be found (false SQL query).
This results in an endless loop of syncing and hundrets of duplicate calendars.

I also created a Gradle build file for easier support of other IDEs

Update: 
merged SSL check from jojoF, 
merged perfomance tweak from Griffon26,
fixed color handling